(self["webpackChunk_padloc_pwa"] = self["webpackChunk_padloc_pwa"] || []).push([["app_src_elements_app_ts"],{

/***/ "../core/vendor/jsbn.js":
/*!******************************!*\
  !*** ../core/vendor/jsbn.js ***!
  \******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "BigInteger": () => (/* binding */ BigInteger),
/* harmony export */   "SecureRandom": () => (/* binding */ SecureRandom)
/* harmony export */ });
// Copyright (c) 2005  Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.

// Basic JavaScript BN library - subset useful for RSA encryption.

// Bits per digit
var dbits;

// JavaScript engine analysis
var canary = 0xdeadbeefcafe;
var j_lm = (canary & 0xffffff) == 0xefcafe;

// (public) Constructor
function BigInteger(a, b, c) {
    if (a != null)
        if ("number" == typeof a) this.fromNumber(a, b, c);
        else if (b == null && "string" != typeof a) this.fromString(a, 256);
        else this.fromString(a, b);
}

// return new, unset BigInteger
function nbi() {
    return new BigInteger(null);
}

// am: Compute w_j += (x*this_i), propagate carries,
// c is initial carry, returns final carry.
// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
// We need to select the fastest one that works in this environment.

// am1: use a single mult and divide to get the high bits,
// max digit bits should be 26 because
// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
function am1(i, x, w, j, c, n) {
    while (--n >= 0) {
        var v = x * this[i++] + w[j] + c;
        c = Math.floor(v / 0x4000000);
        w[j++] = v & 0x3ffffff;
    }
    return c;
}
// am2 avoids a big mult-and-extract completely.
// Max digit bits should be <= 30 because we do bitwise ops
// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
function am2(i, x, w, j, c, n) {
    var xl = x & 0x7fff,
        xh = x >> 15;
    while (--n >= 0) {
        var l = this[i] & 0x7fff;
        var h = this[i++] >> 15;
        var m = xh * l + h * xl;
        l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
        c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
        w[j++] = l & 0x3fffffff;
    }
    return c;
}
// Alternately, set max digit bits to 28 since some
// browsers slow down when dealing with 32-bit numbers.
function am3(i, x, w, j, c, n) {
    var xl = x & 0x3fff,
        xh = x >> 14;
    while (--n >= 0) {
        var l = this[i] & 0x3fff;
        var h = this[i++] >> 14;
        var m = xh * l + h * xl;
        l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
        c = (l >> 28) + (m >> 14) + xh * h;
        w[j++] = l & 0xfffffff;
    }
    return c;
}
var inBrowser = typeof navigator !== "undefined";
if (inBrowser && j_lm && navigator.appName == "Microsoft Internet Explorer") {
    BigInteger.prototype.am = am2;
    dbits = 30;
} else if (inBrowser && j_lm && navigator.appName != "Netscape") {
    BigInteger.prototype.am = am1;
    dbits = 26;
} else {
    // Mozilla/Netscape seems to prefer am3
    BigInteger.prototype.am = am3;
    dbits = 28;
}

BigInteger.prototype.DB = dbits;
BigInteger.prototype.DM = (1 << dbits) - 1;
BigInteger.prototype.DV = 1 << dbits;

var BI_FP = 52;
BigInteger.prototype.FV = Math.pow(2, BI_FP);
BigInteger.prototype.F1 = BI_FP - dbits;
BigInteger.prototype.F2 = 2 * dbits - BI_FP;

// Digit conversions
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
var BI_RC = new Array();
var rr, vv;
rr = "0".charCodeAt(0);
for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
rr = "a".charCodeAt(0);
for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
rr = "A".charCodeAt(0);
for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;

function int2char(n) {
    return BI_RM.charAt(n);
}
function intAt(s, i) {
    var c = BI_RC[s.charCodeAt(i)];
    return c == null ? -1 : c;
}

// (protected) copy this to r
function bnpCopyTo(r) {
    for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
    r.t = this.t;
    r.s = this.s;
}

// (protected) set from integer value x, -DV <= x < DV
function bnpFromInt(x) {
    this.t = 1;
    this.s = x < 0 ? -1 : 0;
    if (x > 0) this[0] = x;
    else if (x < -1) this[0] = x + this.DV;
    else this.t = 0;
}

// return bigint initialized to value
function nbv(i) {
    var r = nbi();
    r.fromInt(i);
    return r;
}

// (protected) set from string and radix
function bnpFromString(s, b) {
    var k;
    if (b == 16) k = 4;
    else if (b == 8) k = 3;
    else if (b == 256) k = 8;
    // byte array
    else if (b == 2) k = 1;
    else if (b == 32) k = 5;
    else if (b == 4) k = 2;
    else {
        this.fromRadix(s, b);
        return;
    }
    this.t = 0;
    this.s = 0;
    var i = s.length,
        mi = false,
        sh = 0;
    while (--i >= 0) {
        var x = k == 8 ? s[i] & 0xff : intAt(s, i);
        if (x < 0) {
            if (s.charAt(i) == "-") mi = true;
            continue;
        }
        mi = false;
        if (sh == 0) this[this.t++] = x;
        else if (sh + k > this.DB) {
            this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
            this[this.t++] = x >> (this.DB - sh);
        } else this[this.t - 1] |= x << sh;
        sh += k;
        if (sh >= this.DB) sh -= this.DB;
    }
    if (k == 8 && (s[0] & 0x80) != 0) {
        this.s = -1;
        if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
    }
    this.clamp();
    if (mi) BigInteger.ZERO.subTo(this, this);
}

// (protected) clamp off excess high words
function bnpClamp() {
    var c = this.s & this.DM;
    while (this.t > 0 && this[this.t - 1] == c) --this.t;
}

// (public) return string representation in given radix
function bnToString(b) {
    if (this.s < 0) return "-" + this.negate().toString(b);
    var k;
    if (b == 16) k = 4;
    else if (b == 8) k = 3;
    else if (b == 2) k = 1;
    else if (b == 32) k = 5;
    else if (b == 4) k = 2;
    else return this.toRadix(b);
    var km = (1 << k) - 1,
        d,
        m = false,
        r = "",
        i = this.t;
    var p = this.DB - ((i * this.DB) % k);
    if (i-- > 0) {
        if (p < this.DB && (d = this[i] >> p) > 0) {
            m = true;
            r = int2char(d);
        }
        while (i >= 0) {
            if (p < k) {
                d = (this[i] & ((1 << p) - 1)) << (k - p);
                d |= this[--i] >> (p += this.DB - k);
            } else {
                d = (this[i] >> (p -= k)) & km;
                if (p <= 0) {
                    p += this.DB;
                    --i;
                }
            }
            if (d > 0) m = true;
            if (m) r += int2char(d);
        }
    }
    return m ? r : "0";
}

// (public) -this
function bnNegate() {
    var r = nbi();
    BigInteger.ZERO.subTo(this, r);
    return r;
}

// (public) |this|
function bnAbs() {
    return this.s < 0 ? this.negate() : this;
}

// (public) return + if this > a, - if this < a, 0 if equal
function bnCompareTo(a) {
    var r = this.s - a.s;
    if (r != 0) return r;
    var i = this.t;
    r = i - a.t;
    if (r != 0) return this.s < 0 ? -r : r;
    while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
    return 0;
}

// returns bit length of the integer x
function nbits(x) {
    var r = 1,
        t;
    if ((t = x >>> 16) != 0) {
        x = t;
        r += 16;
    }
    if ((t = x >> 8) != 0) {
        x = t;
        r += 8;
    }
    if ((t = x >> 4) != 0) {
        x = t;
        r += 4;
    }
    if ((t = x >> 2) != 0) {
        x = t;
        r += 2;
    }
    if ((t = x >> 1) != 0) {
        x = t;
        r += 1;
    }
    return r;
}

// (public) return the number of bits in "this"
function bnBitLength() {
    if (this.t <= 0) return 0;
    return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
}

// (protected) r = this << n*DB
function bnpDLShiftTo(n, r) {
    var i;
    for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
    for (i = n - 1; i >= 0; --i) r[i] = 0;
    r.t = this.t + n;
    r.s = this.s;
}

// (protected) r = this >> n*DB
function bnpDRShiftTo(n, r) {
    for (var i = n; i < this.t; ++i) r[i - n] = this[i];
    r.t = Math.max(this.t - n, 0);
    r.s = this.s;
}

// (protected) r = this << n
function bnpLShiftTo(n, r) {
    var bs = n % this.DB;
    var cbs = this.DB - bs;
    var bm = (1 << cbs) - 1;
    var ds = Math.floor(n / this.DB),
        c = (this.s << bs) & this.DM,
        i;
    for (i = this.t - 1; i >= 0; --i) {
        r[i + ds + 1] = (this[i] >> cbs) | c;
        c = (this[i] & bm) << bs;
    }
    for (i = ds - 1; i >= 0; --i) r[i] = 0;
    r[ds] = c;
    r.t = this.t + ds + 1;
    r.s = this.s;
    r.clamp();
}

// (protected) r = this >> n
function bnpRShiftTo(n, r) {
    r.s = this.s;
    var ds = Math.floor(n / this.DB);
    if (ds >= this.t) {
        r.t = 0;
        return;
    }
    var bs = n % this.DB;
    var cbs = this.DB - bs;
    var bm = (1 << bs) - 1;
    r[0] = this[ds] >> bs;
    for (var i = ds + 1; i < this.t; ++i) {
        r[i - ds - 1] |= (this[i] & bm) << cbs;
        r[i - ds] = this[i] >> bs;
    }
    if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
    r.t = this.t - ds;
    r.clamp();
}

// (protected) r = this - a
function bnpSubTo(a, r) {
    var i = 0,
        c = 0,
        m = Math.min(a.t, this.t);
    while (i < m) {
        c += this[i] - a[i];
        r[i++] = c & this.DM;
        c >>= this.DB;
    }
    if (a.t < this.t) {
        c -= a.s;
        while (i < this.t) {
            c += this[i];
            r[i++] = c & this.DM;
            c >>= this.DB;
        }
        c += this.s;
    } else {
        c += this.s;
        while (i < a.t) {
            c -= a[i];
            r[i++] = c & this.DM;
            c >>= this.DB;
        }
        c -= a.s;
    }
    r.s = c < 0 ? -1 : 0;
    if (c < -1) r[i++] = this.DV + c;
    else if (c > 0) r[i++] = c;
    r.t = i;
    r.clamp();
}

// (protected) r = this * a, r != this,a (HAC 14.12)
// "this" should be the larger one if appropriate.
function bnpMultiplyTo(a, r) {
    var x = this.abs(),
        y = a.abs();
    var i = x.t;
    r.t = i + y.t;
    while (--i >= 0) r[i] = 0;
    for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
    r.s = 0;
    r.clamp();
    if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
}

// (protected) r = this^2, r != this (HAC 14.16)
function bnpSquareTo(r) {
    var x = this.abs();
    var i = (r.t = 2 * x.t);
    while (--i >= 0) r[i] = 0;
    for (i = 0; i < x.t - 1; ++i) {
        var c = x.am(i, x[i], r, 2 * i, 0, 1);
        if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
            r[i + x.t] -= x.DV;
            r[i + x.t + 1] = 1;
        }
    }
    if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
    r.s = 0;
    r.clamp();
}

// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
// r != q, this != m.  q or r may be null.
function bnpDivRemTo(m, q, r) {
    var pm = m.abs();
    if (pm.t <= 0) return;
    var pt = this.abs();
    if (pt.t < pm.t) {
        if (q != null) q.fromInt(0);
        if (r != null) this.copyTo(r);
        return;
    }
    if (r == null) r = nbi();
    var y = nbi(),
        ts = this.s,
        ms = m.s;
    var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
    if (nsh > 0) {
        pm.lShiftTo(nsh, y);
        pt.lShiftTo(nsh, r);
    } else {
        pm.copyTo(y);
        pt.copyTo(r);
    }
    var ys = y.t;
    var y0 = y[ys - 1];
    if (y0 == 0) return;
    var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);
    var d1 = this.FV / yt,
        d2 = (1 << this.F1) / yt,
        e = 1 << this.F2;
    var i = r.t,
        j = i - ys,
        t = q == null ? nbi() : q;
    y.dlShiftTo(j, t);
    if (r.compareTo(t) >= 0) {
        r[r.t++] = 1;
        r.subTo(t, r);
    }
    BigInteger.ONE.dlShiftTo(ys, t);
    t.subTo(y, y); // "negative" y so we can replace sub with am later
    while (y.t < ys) y[y.t++] = 0;
    while (--j >= 0) {
        // Estimate quotient digit
        var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
        if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {
            // Try it out
            y.dlShiftTo(j, t);
            r.subTo(t, r);
            while (r[i] < --qd) r.subTo(t, r);
        }
    }
    if (q != null) {
        r.drShiftTo(ys, q);
        if (ts != ms) BigInteger.ZERO.subTo(q, q);
    }
    r.t = ys;
    r.clamp();
    if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
    if (ts < 0) BigInteger.ZERO.subTo(r, r);
}

// (public) this mod a
function bnMod(a) {
    var r = nbi();
    this.abs().divRemTo(a, null, r);
    if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
    return r;
}

// Modular reduction using "classic" algorithm
function Classic(m) {
    this.m = m;
}
function cConvert(x) {
    if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
    else return x;
}
function cRevert(x) {
    return x;
}
function cReduce(x) {
    x.divRemTo(this.m, null, x);
}
function cMulTo(x, y, r) {
    x.multiplyTo(y, r);
    this.reduce(r);
}
function cSqrTo(x, r) {
    x.squareTo(r);
    this.reduce(r);
}

Classic.prototype.convert = cConvert;
Classic.prototype.revert = cRevert;
Classic.prototype.reduce = cReduce;
Classic.prototype.mulTo = cMulTo;
Classic.prototype.sqrTo = cSqrTo;

// (protected) return "-1/this % 2^DB"; useful for Mont. reduction
// justification:
//         xy == 1 (mod m)
//         xy =  1+km
//   xy(2-xy) = (1+km)(1-km)
// x[y(2-xy)] = 1-k^2m^2
// x[y(2-xy)] == 1 (mod m^2)
// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
// JS multiply "overflows" differently from C/C++, so care is needed here.
function bnpInvDigit() {
    if (this.t < 1) return 0;
    var x = this[0];
    if ((x & 1) == 0) return 0;
    var y = x & 3; // y == 1/x mod 2^2
    y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
    y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
    y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
    // last step - calculate inverse mod DV directly;
    // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
    y = (y * (2 - ((x * y) % this.DV))) % this.DV; // y == 1/x mod 2^dbits
    // we really want the negative inverse, and -DV < y < DV
    return y > 0 ? this.DV - y : -y;
}

// Montgomery reduction
function Montgomery(m) {
    this.m = m;
    this.mp = m.invDigit();
    this.mpl = this.mp & 0x7fff;
    this.mph = this.mp >> 15;
    this.um = (1 << (m.DB - 15)) - 1;
    this.mt2 = 2 * m.t;
}

// xR mod m
function montConvert(x) {
    var r = nbi();
    x.abs().dlShiftTo(this.m.t, r);
    r.divRemTo(this.m, null, r);
    if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
    return r;
}

// x/R mod m
function montRevert(x) {
    var r = nbi();
    x.copyTo(r);
    this.reduce(r);
    return r;
}

// x = x/R mod m (HAC 14.32)
function montReduce(x) {
    while (
        x.t <= this.mt2 // pad x so am has enough room later
    )
        x[x.t++] = 0;
    for (var i = 0; i < this.m.t; ++i) {
        // faster way of calculating u0 = x[i]*mp mod DV
        var j = x[i] & 0x7fff;
        var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
        // use am to combine the multiply-shift-add into one call
        j = i + this.m.t;
        x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
        // propagate carry
        while (x[j] >= x.DV) {
            x[j] -= x.DV;
            x[++j]++;
        }
    }
    x.clamp();
    x.drShiftTo(this.m.t, x);
    if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
}

// r = "x^2/R mod m"; x != r
function montSqrTo(x, r) {
    x.squareTo(r);
    this.reduce(r);
}

// r = "xy/R mod m"; x,y != r
function montMulTo(x, y, r) {
    x.multiplyTo(y, r);
    this.reduce(r);
}

Montgomery.prototype.convert = montConvert;
Montgomery.prototype.revert = montRevert;
Montgomery.prototype.reduce = montReduce;
Montgomery.prototype.mulTo = montMulTo;
Montgomery.prototype.sqrTo = montSqrTo;

// (protected) true iff this is even
function bnpIsEven() {
    return (this.t > 0 ? this[0] & 1 : this.s) == 0;
}

// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
function bnpExp(e, z) {
    if (e > 0xffffffff || e < 1) return BigInteger.ONE;
    var r = nbi(),
        r2 = nbi(),
        g = z.convert(this),
        i = nbits(e) - 1;
    g.copyTo(r);
    while (--i >= 0) {
        z.sqrTo(r, r2);
        if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
        else {
            var t = r;
            r = r2;
            r2 = t;
        }
    }
    return z.revert(r);
}

// (public) this^e % m, 0 <= e < 2^32
function bnModPowInt(e, m) {
    var z;
    if (e < 256 || m.isEven()) z = new Classic(m);
    else z = new Montgomery(m);
    return this.exp(e, z);
}

// protected
BigInteger.prototype.copyTo = bnpCopyTo;
BigInteger.prototype.fromInt = bnpFromInt;
BigInteger.prototype.fromString = bnpFromString;
BigInteger.prototype.clamp = bnpClamp;
BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
BigInteger.prototype.drShiftTo = bnpDRShiftTo;
BigInteger.prototype.lShiftTo = bnpLShiftTo;
BigInteger.prototype.rShiftTo = bnpRShiftTo;
BigInteger.prototype.subTo = bnpSubTo;
BigInteger.prototype.multiplyTo = bnpMultiplyTo;
BigInteger.prototype.squareTo = bnpSquareTo;
BigInteger.prototype.divRemTo = bnpDivRemTo;
BigInteger.prototype.invDigit = bnpInvDigit;
BigInteger.prototype.isEven = bnpIsEven;
BigInteger.prototype.exp = bnpExp;

// public
BigInteger.prototype.toString = bnToString;
BigInteger.prototype.negate = bnNegate;
BigInteger.prototype.abs = bnAbs;
BigInteger.prototype.compareTo = bnCompareTo;
BigInteger.prototype.bitLength = bnBitLength;
BigInteger.prototype.mod = bnMod;
BigInteger.prototype.modPowInt = bnModPowInt;

// "constants"
BigInteger.ZERO = nbv(0);
BigInteger.ONE = nbv(1);

// Copyright (c) 2005-2009  Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.

// Extended JavaScript BN functions, required for RSA private ops.

// Version 1.1: new BigInteger("0", 10) returns "proper" zero
// Version 1.2: square() API, isProbablePrime fix

// (public)
function bnClone() {
    var r = nbi();
    this.copyTo(r);
    return r;
}

// (public) return value as integer
function bnIntValue() {
    if (this.s < 0) {
        if (this.t == 1) return this[0] - this.DV;
        else if (this.t == 0) return -1;
    } else if (this.t == 1) return this[0];
    else if (this.t == 0) return 0;
    // assumes 16 < DB < 32
    return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
}

// (public) return value as byte
function bnByteValue() {
    return this.t == 0 ? this.s : (this[0] << 24) >> 24;
}

// (public) return value as short (assumes DB>=16)
function bnShortValue() {
    return this.t == 0 ? this.s : (this[0] << 16) >> 16;
}

// (protected) return x s.t. r^x < DV
function bnpChunkSize(r) {
    return Math.floor((Math.LN2 * this.DB) / Math.log(r));
}

// (public) 0 if this == 0, 1 if this > 0
function bnSigNum() {
    if (this.s < 0) return -1;
    else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
    else return 1;
}

// (protected) convert to radix string
function bnpToRadix(b) {
    if (b == null) b = 10;
    if (this.signum() == 0 || b < 2 || b > 36) return "0";
    var cs = this.chunkSize(b);
    var a = Math.pow(b, cs);
    var d = nbv(a),
        y = nbi(),
        z = nbi(),
        r = "";
    this.divRemTo(d, y, z);
    while (y.signum() > 0) {
        r = (a + z.intValue()).toString(b).substr(1) + r;
        y.divRemTo(d, y, z);
    }
    return z.intValue().toString(b) + r;
}

// (protected) convert from radix string
function bnpFromRadix(s, b) {
    this.fromInt(0);
    if (b == null) b = 10;
    var cs = this.chunkSize(b);
    var d = Math.pow(b, cs),
        mi = false,
        j = 0,
        w = 0;
    for (var i = 0; i < s.length; ++i) {
        var x = intAt(s, i);
        if (x < 0) {
            if (s.charAt(i) == "-" && this.signum() == 0) mi = true;
            continue;
        }
        w = b * w + x;
        if (++j >= cs) {
            this.dMultiply(d);
            this.dAddOffset(w, 0);
            j = 0;
            w = 0;
        }
    }
    if (j > 0) {
        this.dMultiply(Math.pow(b, j));
        this.dAddOffset(w, 0);
    }
    if (mi) BigInteger.ZERO.subTo(this, this);
}

// (protected) alternate constructor
function bnpFromNumber(a, b, c) {
    if ("number" == typeof b) {
        // new BigInteger(int,int,RNG)
        if (a < 2) this.fromInt(1);
        else {
            this.fromNumber(a, c);
            if (!this.testBit(a - 1))
                // force MSB set
                this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
            if (this.isEven()) this.dAddOffset(1, 0); // force odd
            while (!this.isProbablePrime(b)) {
                this.dAddOffset(2, 0);
                if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
            }
        }
    } else {
        // new BigInteger(int,RNG)
        var x = new Array(),
            t = a & 7;
        x.length = (a >> 3) + 1;
        b.nextBytes(x);
        if (t > 0) x[0] &= (1 << t) - 1;
        else x[0] = 0;
        this.fromString(x, 256);
    }
}

// (public) convert to bigendian byte array
function bnToByteArray() {
    var i = this.t,
        r = new Array();
    r[0] = this.s;
    var p = this.DB - ((i * this.DB) % 8),
        d,
        k = 0;
    if (i-- > 0) {
        if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) r[k++] = d | (this.s << (this.DB - p));
        while (i >= 0) {
            if (p < 8) {
                d = (this[i] & ((1 << p) - 1)) << (8 - p);
                d |= this[--i] >> (p += this.DB - 8);
            } else {
                d = (this[i] >> (p -= 8)) & 0xff;
                if (p <= 0) {
                    p += this.DB;
                    --i;
                }
            }
            if ((d & 0x80) != 0) d |= -256;
            if (k == 0 && (this.s & 0x80) != (d & 0x80)) ++k;
            if (k > 0 || d != this.s) r[k++] = d;
        }
    }
    return r;
}

function bnEquals(a) {
    return this.compareTo(a) == 0;
}
function bnMin(a) {
    return this.compareTo(a) < 0 ? this : a;
}
function bnMax(a) {
    return this.compareTo(a) > 0 ? this : a;
}

// (protected) r = this op a (bitwise)
function bnpBitwiseTo(a, op, r) {
    var i,
        f,
        m = Math.min(a.t, this.t);
    for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]);
    if (a.t < this.t) {
        f = a.s & this.DM;
        for (i = m; i < this.t; ++i) r[i] = op(this[i], f);
        r.t = this.t;
    } else {
        f = this.s & this.DM;
        for (i = m; i < a.t; ++i) r[i] = op(f, a[i]);
        r.t = a.t;
    }
    r.s = op(this.s, a.s);
    r.clamp();
}

// (public) this & a
function op_and(x, y) {
    return x & y;
}
function bnAnd(a) {
    var r = nbi();
    this.bitwiseTo(a, op_and, r);
    return r;
}

// (public) this | a
function op_or(x, y) {
    return x | y;
}
function bnOr(a) {
    var r = nbi();
    this.bitwiseTo(a, op_or, r);
    return r;
}

// (public) this ^ a
function op_xor(x, y) {
    return x ^ y;
}
function bnXor(a) {
    var r = nbi();
    this.bitwiseTo(a, op_xor, r);
    return r;
}

// (public) this & ~a
function op_andnot(x, y) {
    return x & ~y;
}
function bnAndNot(a) {
    var r = nbi();
    this.bitwiseTo(a, op_andnot, r);
    return r;
}

// (public) ~this
function bnNot() {
    var r = nbi();
    for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
    r.t = this.t;
    r.s = ~this.s;
    return r;
}

// (public) this << n
function bnShiftLeft(n) {
    var r = nbi();
    if (n < 0) this.rShiftTo(-n, r);
    else this.lShiftTo(n, r);
    return r;
}

// (public) this >> n
function bnShiftRight(n) {
    var r = nbi();
    if (n < 0) this.lShiftTo(-n, r);
    else this.rShiftTo(n, r);
    return r;
}

// return index of lowest 1-bit in x, x < 2^31
function lbit(x) {
    if (x == 0) return -1;
    var r = 0;
    if ((x & 0xffff) == 0) {
        x >>= 16;
        r += 16;
    }
    if ((x & 0xff) == 0) {
        x >>= 8;
        r += 8;
    }
    if ((x & 0xf) == 0) {
        x >>= 4;
        r += 4;
    }
    if ((x & 3) == 0) {
        x >>= 2;
        r += 2;
    }
    if ((x & 1) == 0) ++r;
    return r;
}

// (public) returns index of lowest 1-bit (or -1 if none)
function bnGetLowestSetBit() {
    for (var i = 0; i < this.t; ++i) if (this[i] != 0) return i * this.DB + lbit(this[i]);
    if (this.s < 0) return this.t * this.DB;
    return -1;
}

// return number of 1 bits in x
function cbit(x) {
    var r = 0;
    while (x != 0) {
        x &= x - 1;
        ++r;
    }
    return r;
}

// (public) return number of set bits
function bnBitCount() {
    var r = 0,
        x = this.s & this.DM;
    for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x);
    return r;
}

// (public) true iff nth bit is set
function bnTestBit(n) {
    var j = Math.floor(n / this.DB);
    if (j >= this.t) return this.s != 0;
    return (this[j] & (1 << n % this.DB)) != 0;
}

// (protected) this op (1<<n)
function bnpChangeBit(n, op) {
    var r = BigInteger.ONE.shiftLeft(n);
    this.bitwiseTo(r, op, r);
    return r;
}

// (public) this | (1<<n)
function bnSetBit(n) {
    return this.changeBit(n, op_or);
}

// (public) this & ~(1<<n)
function bnClearBit(n) {
    return this.changeBit(n, op_andnot);
}

// (public) this ^ (1<<n)
function bnFlipBit(n) {
    return this.changeBit(n, op_xor);
}

// (protected) r = this + a
function bnpAddTo(a, r) {
    var i = 0,
        c = 0,
        m = Math.min(a.t, this.t);
    while (i < m) {
        c += this[i] + a[i];
        r[i++] = c & this.DM;
        c >>= this.DB;
    }
    if (a.t < this.t) {
        c += a.s;
        while (i < this.t) {
            c += this[i];
            r[i++] = c & this.DM;
            c >>= this.DB;
        }
        c += this.s;
    } else {
        c += this.s;
        while (i < a.t) {
            c += a[i];
            r[i++] = c & this.DM;
            c >>= this.DB;
        }
        c += a.s;
    }
    r.s = c < 0 ? -1 : 0;
    if (c > 0) r[i++] = c;
    else if (c < -1) r[i++] = this.DV + c;
    r.t = i;
    r.clamp();
}

// (public) this + a
function bnAdd(a) {
    var r = nbi();
    this.addTo(a, r);
    return r;
}

// (public) this - a
function bnSubtract(a) {
    var r = nbi();
    this.subTo(a, r);
    return r;
}

// (public) this * a
function bnMultiply(a) {
    var r = nbi();
    this.multiplyTo(a, r);
    return r;
}

// (public) this^2
function bnSquare() {
    var r = nbi();
    this.squareTo(r);
    return r;
}

// (public) this / a
function bnDivide(a) {
    var r = nbi();
    this.divRemTo(a, r, null);
    return r;
}

// (public) this % a
function bnRemainder(a) {
    var r = nbi();
    this.divRemTo(a, null, r);
    return r;
}

// (public) [this/a,this%a]
function bnDivideAndRemainder(a) {
    var q = nbi(),
        r = nbi();
    this.divRemTo(a, q, r);
    return new Array(q, r);
}

// (protected) this *= n, this >= 0, 1 < n < DV
function bnpDMultiply(n) {
    this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
    ++this.t;
    this.clamp();
}

// (protected) this += n << w words, this >= 0
function bnpDAddOffset(n, w) {
    if (n == 0) return;
    while (this.t <= w) this[this.t++] = 0;
    this[w] += n;
    while (this[w] >= this.DV) {
        this[w] -= this.DV;
        if (++w >= this.t) this[this.t++] = 0;
        ++this[w];
    }
}

// A "null" reducer
function NullExp() {}
function nNop(x) {
    return x;
}
function nMulTo(x, y, r) {
    x.multiplyTo(y, r);
}
function nSqrTo(x, r) {
    x.squareTo(r);
}

NullExp.prototype.convert = nNop;
NullExp.prototype.revert = nNop;
NullExp.prototype.mulTo = nMulTo;
NullExp.prototype.sqrTo = nSqrTo;

// (public) this^e
function bnPow(e) {
    return this.exp(e, new NullExp());
}

// (protected) r = lower n words of "this * a", a.t <= n
// "this" should be the larger one if appropriate.
function bnpMultiplyLowerTo(a, n, r) {
    var i = Math.min(this.t + a.t, n);
    r.s = 0; // assumes a,this >= 0
    r.t = i;
    while (i > 0) r[--i] = 0;
    var j;
    for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
    for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i);
    r.clamp();
}

// (protected) r = "this * a" without lower n words, n > 0
// "this" should be the larger one if appropriate.
function bnpMultiplyUpperTo(a, n, r) {
    --n;
    var i = (r.t = this.t + a.t - n);
    r.s = 0; // assumes a,this >= 0
    while (--i >= 0) r[i] = 0;
    for (i = Math.max(n - this.t, 0); i < a.t; ++i) r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
    r.clamp();
    r.drShiftTo(1, r);
}

// Barrett modular reduction
function Barrett(m) {
    // setup Barrett
    this.r2 = nbi();
    this.q3 = nbi();
    BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
    this.mu = this.r2.divide(m);
    this.m = m;
}

function barrettConvert(x) {
    if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m);
    else if (x.compareTo(this.m) < 0) return x;
    else {
        var r = nbi();
        x.copyTo(r);
        this.reduce(r);
        return r;
    }
}

function barrettRevert(x) {
    return x;
}

// x = x mod m (HAC 14.42)
function barrettReduce(x) {
    x.drShiftTo(this.m.t - 1, this.r2);
    if (x.t > this.m.t + 1) {
        x.t = this.m.t + 1;
        x.clamp();
    }
    this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
    this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
    while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1);
    x.subTo(this.r2, x);
    while (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
}

// r = x^2 mod m; x != r
function barrettSqrTo(x, r) {
    x.squareTo(r);
    this.reduce(r);
}

// r = x*y mod m; x,y != r
function barrettMulTo(x, y, r) {
    x.multiplyTo(y, r);
    this.reduce(r);
}

Barrett.prototype.convert = barrettConvert;
Barrett.prototype.revert = barrettRevert;
Barrett.prototype.reduce = barrettReduce;
Barrett.prototype.mulTo = barrettMulTo;
Barrett.prototype.sqrTo = barrettSqrTo;

// (public) this^e % m (HAC 14.85)
function bnModPow(e, m) {
    var i = e.bitLength(),
        k,
        r = nbv(1),
        z;
    if (i <= 0) return r;
    else if (i < 18) k = 1;
    else if (i < 48) k = 3;
    else if (i < 144) k = 4;
    else if (i < 768) k = 5;
    else k = 6;
    if (i < 8) z = new Classic(m);
    else if (m.isEven()) z = new Barrett(m);
    else z = new Montgomery(m);

    // precomputation
    var g = new Array(),
        n = 3,
        k1 = k - 1,
        km = (1 << k) - 1;
    g[1] = z.convert(this);
    if (k > 1) {
        var g2 = nbi();
        z.sqrTo(g[1], g2);
        while (n <= km) {
            g[n] = nbi();
            z.mulTo(g2, g[n - 2], g[n]);
            n += 2;
        }
    }

    var j = e.t - 1,
        w,
        is1 = true,
        r2 = nbi(),
        t;
    i = nbits(e[j]) - 1;
    while (j >= 0) {
        if (i >= k1) w = (e[j] >> (i - k1)) & km;
        else {
            w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
            if (j > 0) w |= e[j - 1] >> (this.DB + i - k1);
        }

        n = k;
        while ((w & 1) == 0) {
            w >>= 1;
            --n;
        }
        if ((i -= n) < 0) {
            i += this.DB;
            --j;
        }
        if (is1) {
            // ret == 1, don't bother squaring or multiplying it
            g[w].copyTo(r);
            is1 = false;
        } else {
            while (n > 1) {
                z.sqrTo(r, r2);
                z.sqrTo(r2, r);
                n -= 2;
            }
            if (n > 0) z.sqrTo(r, r2);
            else {
                t = r;
                r = r2;
                r2 = t;
            }
            z.mulTo(r2, g[w], r);
        }

        while (j >= 0 && (e[j] & (1 << i)) == 0) {
            z.sqrTo(r, r2);
            t = r;
            r = r2;
            r2 = t;
            if (--i < 0) {
                i = this.DB - 1;
                --j;
            }
        }
    }
    return z.revert(r);
}

// (public) gcd(this,a) (HAC 14.54)
function bnGCD(a) {
    var x = this.s < 0 ? this.negate() : this.clone();
    var y = a.s < 0 ? a.negate() : a.clone();
    if (x.compareTo(y) < 0) {
        var t = x;
        x = y;
        y = t;
    }
    var i = x.getLowestSetBit(),
        g = y.getLowestSetBit();
    if (g < 0) return x;
    if (i < g) g = i;
    if (g > 0) {
        x.rShiftTo(g, x);
        y.rShiftTo(g, y);
    }
    while (x.signum() > 0) {
        if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x);
        if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y);
        if (x.compareTo(y) >= 0) {
            x.subTo(y, x);
            x.rShiftTo(1, x);
        } else {
            y.subTo(x, y);
            y.rShiftTo(1, y);
        }
    }
    if (g > 0) y.lShiftTo(g, y);
    return y;
}

// (protected) this % n, n < 2^26
function bnpModInt(n) {
    if (n <= 0) return 0;
    var d = this.DV % n,
        r = this.s < 0 ? n - 1 : 0;
    if (this.t > 0)
        if (d == 0) r = this[0] % n;
        else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
    return r;
}

// (public) 1/this % m (HAC 14.61)
function bnModInverse(m) {
    var ac = m.isEven();
    if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
    var u = m.clone(),
        v = this.clone();
    var a = nbv(1),
        b = nbv(0),
        c = nbv(0),
        d = nbv(1);
    while (u.signum() != 0) {
        while (u.isEven()) {
            u.rShiftTo(1, u);
            if (ac) {
                if (!a.isEven() || !b.isEven()) {
                    a.addTo(this, a);
                    b.subTo(m, b);
                }
                a.rShiftTo(1, a);
            } else if (!b.isEven()) b.subTo(m, b);
            b.rShiftTo(1, b);
        }
        while (v.isEven()) {
            v.rShiftTo(1, v);
            if (ac) {
                if (!c.isEven() || !d.isEven()) {
                    c.addTo(this, c);
                    d.subTo(m, d);
                }
                c.rShiftTo(1, c);
            } else if (!d.isEven()) d.subTo(m, d);
            d.rShiftTo(1, d);
        }
        if (u.compareTo(v) >= 0) {
            u.subTo(v, u);
            if (ac) a.subTo(c, a);
            b.subTo(d, b);
        } else {
            v.subTo(u, v);
            if (ac) c.subTo(a, c);
            d.subTo(b, d);
        }
    }
    if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
    if (d.compareTo(m) >= 0) return d.subtract(m);
    if (d.signum() < 0) d.addTo(m, d);
    else return d;
    if (d.signum() < 0) return d.add(m);
    else return d;
}

var lowprimes = [
    2,
    3,
    5,
    7,
    11,
    13,
    17,
    19,
    23,
    29,
    31,
    37,
    41,
    43,
    47,
    53,
    59,
    61,
    67,
    71,
    73,
    79,
    83,
    89,
    97,
    101,
    103,
    107,
    109,
    113,
    127,
    131,
    137,
    139,
    149,
    151,
    157,
    163,
    167,
    173,
    179,
    181,
    191,
    193,
    197,
    199,
    211,
    223,
    227,
    229,
    233,
    239,
    241,
    251,
    257,
    263,
    269,
    271,
    277,
    281,
    283,
    293,
    307,
    311,
    313,
    317,
    331,
    337,
    347,
    349,
    353,
    359,
    367,
    373,
    379,
    383,
    389,
    397,
    401,
    409,
    419,
    421,
    431,
    433,
    439,
    443,
    449,
    457,
    461,
    463,
    467,
    479,
    487,
    491,
    499,
    503,
    509,
    521,
    523,
    541,
    547,
    557,
    563,
    569,
    571,
    577,
    587,
    593,
    599,
    601,
    607,
    613,
    617,
    619,
    631,
    641,
    643,
    647,
    653,
    659,
    661,
    673,
    677,
    683,
    691,
    701,
    709,
    719,
    727,
    733,
    739,
    743,
    751,
    757,
    761,
    769,
    773,
    787,
    797,
    809,
    811,
    821,
    823,
    827,
    829,
    839,
    853,
    857,
    859,
    863,
    877,
    881,
    883,
    887,
    907,
    911,
    919,
    929,
    937,
    941,
    947,
    953,
    967,
    971,
    977,
    983,
    991,
    997
];
var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];

// (public) test primality with certainty >= 1-.5^t
function bnIsProbablePrime(t) {
    var i,
        x = this.abs();
    if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
        for (i = 0; i < lowprimes.length; ++i) if (x[0] == lowprimes[i]) return true;
        return false;
    }
    if (x.isEven()) return false;
    i = 1;
    while (i < lowprimes.length) {
        var m = lowprimes[i],
            j = i + 1;
        while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
        m = x.modInt(m);
        while (i < j) if (m % lowprimes[i++] == 0) return false;
    }
    return x.millerRabin(t);
}

// (protected) true if probably prime (HAC 4.24, Miller-Rabin)
function bnpMillerRabin(t) {
    var n1 = this.subtract(BigInteger.ONE);
    var k = n1.getLowestSetBit();
    if (k <= 0) return false;
    var r = n1.shiftRight(k);
    t = (t + 1) >> 1;
    if (t > lowprimes.length) t = lowprimes.length;
    var a = nbi();
    for (var i = 0; i < t; ++i) {
        //Pick bases at random, instead of starting at 2
        a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
        var y = a.modPow(r, this);
        if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
            var j = 1;
            while (j++ < k && y.compareTo(n1) != 0) {
                y = y.modPowInt(2, this);
                if (y.compareTo(BigInteger.ONE) == 0) return false;
            }
            if (y.compareTo(n1) != 0) return false;
        }
    }
    return true;
}

// protected
BigInteger.prototype.chunkSize = bnpChunkSize;
BigInteger.prototype.toRadix = bnpToRadix;
BigInteger.prototype.fromRadix = bnpFromRadix;
BigInteger.prototype.fromNumber = bnpFromNumber;
BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
BigInteger.prototype.changeBit = bnpChangeBit;
BigInteger.prototype.addTo = bnpAddTo;
BigInteger.prototype.dMultiply = bnpDMultiply;
BigInteger.prototype.dAddOffset = bnpDAddOffset;
BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
BigInteger.prototype.modInt = bnpModInt;
BigInteger.prototype.millerRabin = bnpMillerRabin;

// public
BigInteger.prototype.clone = bnClone;
BigInteger.prototype.intValue = bnIntValue;
BigInteger.prototype.byteValue = bnByteValue;
BigInteger.prototype.shortValue = bnShortValue;
BigInteger.prototype.signum = bnSigNum;
BigInteger.prototype.toByteArray = bnToByteArray;
BigInteger.prototype.equals = bnEquals;
BigInteger.prototype.min = bnMin;
BigInteger.prototype.max = bnMax;
BigInteger.prototype.and = bnAnd;
BigInteger.prototype.or = bnOr;
BigInteger.prototype.xor = bnXor;
BigInteger.prototype.andNot = bnAndNot;
BigInteger.prototype.not = bnNot;
BigInteger.prototype.shiftLeft = bnShiftLeft;
BigInteger.prototype.shiftRight = bnShiftRight;
BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
BigInteger.prototype.bitCount = bnBitCount;
BigInteger.prototype.testBit = bnTestBit;
BigInteger.prototype.setBit = bnSetBit;
BigInteger.prototype.clearBit = bnClearBit;
BigInteger.prototype.flipBit = bnFlipBit;
BigInteger.prototype.add = bnAdd;
BigInteger.prototype.subtract = bnSubtract;
BigInteger.prototype.multiply = bnMultiply;
BigInteger.prototype.divide = bnDivide;
BigInteger.prototype.remainder = bnRemainder;
BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
BigInteger.prototype.modPow = bnModPow;
BigInteger.prototype.modInverse = bnModInverse;
BigInteger.prototype.pow = bnPow;
BigInteger.prototype.gcd = bnGCD;
BigInteger.prototype.isProbablePrime = bnIsProbablePrime;

// JSBN-specific extension
BigInteger.prototype.square = bnSquare;

// Expose the Barrett function
BigInteger.prototype.Barrett = Barrett;

// BigInteger interfaces not implemented in jsbn:

// BigInteger(int signum, byte[] magnitude)
// double doubleValue()
// float floatValue()
// int hashCode()
// long longValue()
// static BigInteger valueOf(long val)

// Random number generator - requires a PRNG backend, e.g. prng4.js

// For best results, put code like
// <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'>
// in your main HTML document.

var rng_state;
var rng_pool;
var rng_pptr;

// Mix in a 32-bit integer into the pool
function rng_seed_int(x) {
    rng_pool[rng_pptr++] ^= x & 255;
    rng_pool[rng_pptr++] ^= (x >> 8) & 255;
    rng_pool[rng_pptr++] ^= (x >> 16) & 255;
    rng_pool[rng_pptr++] ^= (x >> 24) & 255;
    if (rng_pptr >= rng_psize) rng_pptr -= rng_psize;
}

// Mix in the current time (w/milliseconds) into the pool
function rng_seed_time() {
    rng_seed_int(new Date().getTime());
}

// Initialize the pool with junk if needed.
if (rng_pool == null) {
    rng_pool = new Array();
    rng_pptr = 0;
    var t;
    if (typeof window !== "undefined" && window.crypto) {
        if (window.crypto.getRandomValues) {
            // Use webcrypto if available
            var ua = new Uint8Array(32);
            window.crypto.getRandomValues(ua);
            for (t = 0; t < 32; ++t) rng_pool[rng_pptr++] = ua[t];
        } else if (navigator.appName == "Netscape" && navigator.appVersion < "5") {
            // Extract entropy (256 bits) from NS4 RNG if available
            var z = window.crypto.random(32);
            for (t = 0; t < z.length; ++t) rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
        }
    }
    while (rng_pptr < rng_psize) {
        // extract some randomness from Math.random()
        t = Math.floor(65536 * Math.random());
        rng_pool[rng_pptr++] = t >>> 8;
        rng_pool[rng_pptr++] = t & 255;
    }
    rng_pptr = 0;
    rng_seed_time();
    //rng_seed_int(window.screenX);
    //rng_seed_int(window.screenY);
}

function rng_get_byte() {
    if (rng_state == null) {
        rng_seed_time();
        rng_state = prng_newstate();
        rng_state.init(rng_pool);
        for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) rng_pool[rng_pptr] = 0;
        rng_pptr = 0;
        //rng_pool = null;
    }
    // TODO: allow reseeding after first request
    return rng_state.next();
}

function rng_get_bytes(ba) {
    var i;
    for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
}

function SecureRandom() {}

SecureRandom.prototype.nextBytes = rng_get_bytes;

// prng4.js - uses Arcfour as a PRNG

function Arcfour() {
    this.i = 0;
    this.j = 0;
    this.S = new Array();
}

// Initialize arcfour context from key, an array of ints, each from [0..255]
function ARC4init(key) {
    var i, j, t;
    for (i = 0; i < 256; ++i) this.S[i] = i;
    j = 0;
    for (i = 0; i < 256; ++i) {
        j = (j + this.S[i] + key[i % key.length]) & 255;
        t = this.S[i];
        this.S[i] = this.S[j];
        this.S[j] = t;
    }
    this.i = 0;
    this.j = 0;
}

function ARC4next() {
    var t;
    this.i = (this.i + 1) & 255;
    this.j = (this.j + this.S[this.i]) & 255;
    t = this.S[this.i];
    this.S[this.i] = this.S[this.j];
    this.S[this.j] = t;
    return this.S[(t + this.S[this.i]) & 255];
}

Arcfour.prototype.init = ARC4init;
Arcfour.prototype.next = ARC4next;

// Plug in your RNG constructor here
function prng_newstate() {
    return new Arcfour();
}

// Pool size must be a multiple of 4 and greater than 32.
// An array of bytes the size of the pool will be passed to init()
var rng_psize = 256;


/***/ }),

/***/ "../locale/res/wordlists lazy recursive ^\\.\\/.*\\.json$":
/*!*********************************************************************!*\
  !*** ../locale/res/wordlists/ lazy ^\.\/.*\.json$ namespace object ***!
  \*********************************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

var map = {
	"./de.json": [
		"../locale/res/wordlists/de.json",
		"locale_res_wordlists_de_json"
	],
	"./en.json": [
		"../locale/res/wordlists/en.json",
		"locale_res_wordlists_en_json"
	],
	"./es.json": [
		"../locale/res/wordlists/es.json",
		"locale_res_wordlists_es_json"
	],
	"./fr.json": [
		"../locale/res/wordlists/fr.json",
		"locale_res_wordlists_fr_json"
	],
	"./pt.json": [
		"../locale/res/wordlists/pt.json",
		"locale_res_wordlists_pt_json"
	]
};
function webpackAsyncContext(req) {
	if(!__webpack_require__.o(map, req)) {
		return Promise.resolve().then(() => {
			var e = new Error("Cannot find module '" + req + "'");
			e.code = 'MODULE_NOT_FOUND';
			throw e;
		});
	}

	var ids = map[req], id = ids[0];
	return __webpack_require__.e(ids[1]).then(() => {
		return __webpack_require__.t(id, 3 | 16);
	});
}
webpackAsyncContext.keys = () => (Object.keys(map));
webpackAsyncContext.id = "../locale/res/wordlists lazy recursive ^\\.\\/.*\\.json$";
module.exports = webpackAsyncContext;

/***/ }),

/***/ "./node_modules/css-loader/dist/cjs.js!../app/assets/fonts/fonts.css":
/*!***************************************************************************!*\
  !*** ./node_modules/css-loader/dist/cjs.js!../app/assets/fonts/fonts.css ***!
  \***************************************************************************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _pwa_node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../pwa/node_modules/css-loader/dist/runtime/cssWithMappingToString.js */ "./node_modules/css-loader/dist/runtime/cssWithMappingToString.js");
/* harmony import */ var _pwa_node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_pwa_node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _pwa_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../pwa/node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
/* harmony import */ var _pwa_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_pwa_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../pwa/node_modules/css-loader/dist/runtime/getUrl.js */ "./node_modules/css-loader/dist/runtime/getUrl.js");
/* harmony import */ var _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _Nunito_Light_ttf__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Nunito-Light.ttf */ "../app/assets/fonts/Nunito-Light.ttf");
/* harmony import */ var _Nunito_Regular_ttf__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Nunito-Regular.ttf */ "../app/assets/fonts/Nunito-Regular.ttf");
/* harmony import */ var _Nunito_SemiBold_ttf__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Nunito-SemiBold.ttf */ "../app/assets/fonts/Nunito-SemiBold.ttf");
/* harmony import */ var _Nunito_Bold_ttf__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Nunito-Bold.ttf */ "../app/assets/fonts/Nunito-Bold.ttf");
/* harmony import */ var _Inconsolata_Regular_ttf__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Inconsolata-Regular.ttf */ "../app/assets/fonts/Inconsolata-Regular.ttf");
/* harmony import */ var _Padlock_eot__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Padlock.eot */ "../app/assets/fonts/Padlock.eot");
/* harmony import */ var _Padlock_woff__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Padlock.woff */ "../app/assets/fonts/Padlock.woff");
/* harmony import */ var _Padlock_ttf__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Padlock.ttf */ "../app/assets/fonts/Padlock.ttf");
/* harmony import */ var _Padlock_svg__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Padlock.svg */ "../app/assets/fonts/Padlock.svg");
/* harmony import */ var _fontawesome_webfont_eot__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./fontawesome-webfont.eot */ "../app/assets/fonts/fontawesome-webfont.eot");
/* harmony import */ var _fontawesome_webfont_woff2__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./fontawesome-webfont.woff2 */ "../app/assets/fonts/fontawesome-webfont.woff2");
/* harmony import */ var _fontawesome_webfont_woff__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./fontawesome-webfont.woff */ "../app/assets/fonts/fontawesome-webfont.woff");
/* harmony import */ var _fontawesome_webfont_ttf__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fontawesome-webfont.ttf */ "../app/assets/fonts/fontawesome-webfont.ttf");
/* harmony import */ var _fontawesome_webfont_svg__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./fontawesome-webfont.svg */ "../app/assets/fonts/fontawesome-webfont.svg");
// Imports

















var ___CSS_LOADER_EXPORT___ = _pwa_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_pwa_node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0___default()));
var ___CSS_LOADER_URL_REPLACEMENT_0___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Nunito_Light_ttf__WEBPACK_IMPORTED_MODULE_3__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_1___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Nunito_Regular_ttf__WEBPACK_IMPORTED_MODULE_4__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_2___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Nunito_SemiBold_ttf__WEBPACK_IMPORTED_MODULE_5__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_3___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Nunito_Bold_ttf__WEBPACK_IMPORTED_MODULE_6__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_4___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Inconsolata_Regular_ttf__WEBPACK_IMPORTED_MODULE_7__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_5___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Padlock_eot__WEBPACK_IMPORTED_MODULE_8__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_6___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Padlock_woff__WEBPACK_IMPORTED_MODULE_9__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_7___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Padlock_ttf__WEBPACK_IMPORTED_MODULE_10__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_8___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_Padlock_svg__WEBPACK_IMPORTED_MODULE_11__["default"], { hash: "#Padlock" });
var ___CSS_LOADER_URL_REPLACEMENT_9___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_fontawesome_webfont_eot__WEBPACK_IMPORTED_MODULE_12__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_10___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_fontawesome_webfont_woff2__WEBPACK_IMPORTED_MODULE_13__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_11___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_fontawesome_webfont_woff__WEBPACK_IMPORTED_MODULE_14__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_12___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_fontawesome_webfont_ttf__WEBPACK_IMPORTED_MODULE_15__["default"]);
var ___CSS_LOADER_URL_REPLACEMENT_13___ = _pwa_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(_fontawesome_webfont_svg__WEBPACK_IMPORTED_MODULE_16__["default"]);
// Module
___CSS_LOADER_EXPORT___.push([module.id, "@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 300;\n    src: local(\"Nunito Light\"), local(\"Nunito-Light\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_0___ + ") format(\"truetype\");\n}\n@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 400;\n    src: local(\"Nunito Regular\"), local(\"Nunito-Regular\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_1___ + ") format(\"truetype\");\n}\n@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 600;\n    src: local(\"Nunito SemiBold\"), local(\"Nunito-SemiBold\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_2___ + ") format(\"truetype\");\n}\n@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 700;\n    src: local(\"Nunito Bold\"), local(\"Nunito-Bold\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_3___ + ") format(\"truetype\");\n}\n@font-face {\n    font-family: \"Inconsolata\";\n    font-style: normal;\n    font-weight: 400;\n    src: local(\"Inconsolata Regular\"), local(\"Inconsolata-Regular\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_4___ + ") format(\"truetype\");\n}\n\n@font-face {\n    font-family: \"Padlock\";\n    src: url(" + ___CSS_LOADER_URL_REPLACEMENT_5___ + ");\n    src: url(" + ___CSS_LOADER_URL_REPLACEMENT_5___ + ") format(\"embedded-opentype\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_6___ + ") format(\"woff\"),\n        url(" + ___CSS_LOADER_URL_REPLACEMENT_7___ + ") format(\"truetype\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_8___ + ") format(\"svg\");\n    font-weight: normal;\n    font-style: normal;\n}\n\n@font-face {\n    font-family: \"FontAwesome\";\n    src: url(" + ___CSS_LOADER_URL_REPLACEMENT_9___ + ");\n    src: url(" + ___CSS_LOADER_URL_REPLACEMENT_9___ + ") format(\"embedded-opentype\"),\n        url(" + ___CSS_LOADER_URL_REPLACEMENT_10___ + ") format(\"woff2\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_11___ + ") format(\"woff\"),\n        url(" + ___CSS_LOADER_URL_REPLACEMENT_12___ + ") format(\"truetype\"), url(" + ___CSS_LOADER_URL_REPLACEMENT_13___ + ") format(\"svg\");\n    font-weight: normal;\n    font-style: normal;\n}\n", "",{"version":3,"sources":["webpack://./../app/assets/fonts/fonts.css"],"names":[],"mappings":"AAAA;IACI,qBAAqB;IACrB,kBAAkB;IAClB,gBAAgB;IAChB,6GAA6F;AACjG;AACA;IACI,qBAAqB;IACrB,kBAAkB;IAClB,gBAAgB;IAChB,iHAAmG;AACvG;AACA;IACI,qBAAqB;IACrB,kBAAkB;IAClB,gBAAgB;IAChB,mHAAsG;AAC1G;AACA;IACI,qBAAqB;IACrB,kBAAkB;IAClB,gBAAgB;IAChB,2GAA0F;AAC9F;AACA;IACI,0BAA0B;IAC1B,kBAAkB;IAClB,gBAAgB;IAChB,2HAAkH;AACtH;;AAEA;IACI,sBAAsB;IACtB,4CAAyB;IACzB;yHACuF;IACvF,mBAAmB;IACnB,kBAAkB;AACtB;;AAEA;IACI,0BAA0B;IAC1B,4CAAqC;IACrC;;2HAEuG;IACvG,mBAAmB;IACnB,kBAAkB;AACtB","sourcesContent":["@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 300;\n    src: local(\"Nunito Light\"), local(\"Nunito-Light\"), url(./Nunito-Light.ttf) format(\"truetype\");\n}\n@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 400;\n    src: local(\"Nunito Regular\"), local(\"Nunito-Regular\"), url(./Nunito-Regular.ttf) format(\"truetype\");\n}\n@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 600;\n    src: local(\"Nunito SemiBold\"), local(\"Nunito-SemiBold\"), url(./Nunito-SemiBold.ttf) format(\"truetype\");\n}\n@font-face {\n    font-family: \"Nunito\";\n    font-style: normal;\n    font-weight: 700;\n    src: local(\"Nunito Bold\"), local(\"Nunito-Bold\"), url(./Nunito-Bold.ttf) format(\"truetype\");\n}\n@font-face {\n    font-family: \"Inconsolata\";\n    font-style: normal;\n    font-weight: 400;\n    src: local(\"Inconsolata Regular\"), local(\"Inconsolata-Regular\"), url(./Inconsolata-Regular.ttf) format(\"truetype\");\n}\n\n@font-face {\n    font-family: \"Padlock\";\n    src: url(\"./Padlock.eot\");\n    src: url(\"./Padlock.eot\") format(\"embedded-opentype\"), url(\"./Padlock.woff\") format(\"woff\"),\n        url(\"./Padlock.ttf\") format(\"truetype\"), url(\"./Padlock.svg#Padlock\") format(\"svg\");\n    font-weight: normal;\n    font-style: normal;\n}\n\n@font-face {\n    font-family: \"FontAwesome\";\n    src: url(\"./fontawesome-webfont.eot\");\n    src: url(\"./fontawesome-webfont.eot\") format(\"embedded-opentype\"),\n        url(\"./fontawesome-webfont.woff2\") format(\"woff2\"), url(\"./fontawesome-webfont.woff\") format(\"woff\"),\n        url(\"./fontawesome-webfont.ttf\") format(\"truetype\"), url(\"./fontawesome-webfont.svg\") format(\"svg\");\n    font-weight: normal;\n    font-style: normal;\n}\n"],"sourceRoot":""}]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);


/***/ }),

/***/ "../app/assets/fonts/Inconsolata-Regular.ttf":
/*!***************************************************!*\
  !*** ../app/assets/fonts/Inconsolata-Regular.ttf ***!
  \***************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "4d410e4977b3525f9fca202da60d43ed.ttf");

/***/ }),

/***/ "../app/assets/fonts/Nunito-Bold.ttf":
/*!*******************************************!*\
  !*** ../app/assets/fonts/Nunito-Bold.ttf ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "e21224eb684dfa21443683a3fc963a3b.ttf");

/***/ }),

/***/ "../app/assets/fonts/Nunito-Light.ttf":
/*!********************************************!*\
  !*** ../app/assets/fonts/Nunito-Light.ttf ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "d0adc2b29b7472077dc7439642f1439a.ttf");

/***/ }),

/***/ "../app/assets/fonts/Nunito-Regular.ttf":
/*!**********************************************!*\
  !*** ../app/assets/fonts/Nunito-Regular.ttf ***!
  \**********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "c6d06da41ec4b66d90868ce6bf337cbd.ttf");

/***/ }),

/***/ "../app/assets/fonts/Nunito-SemiBold.ttf":
/*!***********************************************!*\
  !*** ../app/assets/fonts/Nunito-SemiBold.ttf ***!
  \***********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "2f14cbb7792a42471b1b64de35797d7a.ttf");

/***/ }),

/***/ "../app/assets/fonts/Padlock.eot":
/*!***************************************!*\
  !*** ../app/assets/fonts/Padlock.eot ***!
  \***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "e3a2c12708311d5e47193da456ccdcba.eot");

/***/ }),

/***/ "../app/assets/fonts/Padlock.svg":
/*!***************************************!*\
  !*** ../app/assets/fonts/Padlock.svg ***!
  \***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "49d0dfccb2c7333add0c1277ce21fa1e.svg");

/***/ }),

/***/ "../app/assets/fonts/Padlock.ttf":
/*!***************************************!*\
  !*** ../app/assets/fonts/Padlock.ttf ***!
  \***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "5503c8e2713e276d4a2cdff45e6991c9.ttf");

/***/ }),

/***/ "../app/assets/fonts/Padlock.woff":
/*!****************************************!*\
  !*** ../app/assets/fonts/Padlock.woff ***!
  \****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "021f830e3290aad20514c75c92ab00c9.woff");

/***/ }),

/***/ "../app/assets/fonts/fontawesome-webfont.eot":
/*!***************************************************!*\
  !*** ../app/assets/fonts/fontawesome-webfont.eot ***!
  \***************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "3d1a8e52672c4af418771bcd7e4111f5.eot");

/***/ }),

/***/ "../app/assets/fonts/fontawesome-webfont.svg":
/*!***************************************************!*\
  !*** ../app/assets/fonts/fontawesome-webfont.svg ***!
  \***************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "9659db92dbc9c899169660fa07a18838.svg");

/***/ }),

/***/ "../app/assets/fonts/fontawesome-webfont.ttf":
/*!***************************************************!*\
  !*** ../app/assets/fonts/fontawesome-webfont.ttf ***!
  \***************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "ecbe95f309be4cee7aa3f894386282f6.ttf");

/***/ }),

/***/ "../app/assets/fonts/fontawesome-webfont.woff":
/*!****************************************************!*\
  !*** ../app/assets/fonts/fontawesome-webfont.woff ***!
  \****************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "2f7fbbd7d8eee807e437e660436c6033.woff");

/***/ }),

/***/ "../app/assets/fonts/fontawesome-webfont.woff2":
/*!*****************************************************!*\
  !*** ../app/assets/fonts/fontawesome-webfont.woff2 ***!
  \*****************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "f862b0f4608b4f0fb945113ef8dcdfa3.woff2");

/***/ }),

/***/ "../app/assets/fonts/fonts.css":
/*!*************************************!*\
  !*** ../app/assets/fonts/fonts.css ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _pwa_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../../pwa/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
/* harmony import */ var _pwa_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_pwa_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _pwa_node_modules_css_loader_dist_cjs_js_fonts_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !!../../../pwa/node_modules/css-loader/dist/cjs.js!./fonts.css */ "./node_modules/css-loader/dist/cjs.js!../app/assets/fonts/fonts.css");

            

var options = {};

options.insert = "head";
options.singleton = false;

var update = _pwa_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_pwa_node_modules_css_loader_dist_cjs_js_fonts_css__WEBPACK_IMPORTED_MODULE_1__["default"], options);



/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_pwa_node_modules_css_loader_dist_cjs_js_fonts_css__WEBPACK_IMPORTED_MODULE_1__["default"].locals || {});

/***/ }),

/***/ "../app/src/elements/alert-dialog.ts":
/*!*******************************************!*\
  !*** ../app/src/elements/alert-dialog.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AlertDialog": () => (/* binding */ AlertDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};



const defaultButtonLabel = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("OK");
let AlertDialog = class AlertDialog extends _dialog__WEBPACK_IMPORTED_MODULE_2__.Dialog {
    constructor() {
        super(...arguments);
        this.buttonLabel = defaultButtonLabel;
        this.dialogTitle = "";
        this.message = "";
        this.type = "info";
        this.icon = "";
        this.options = [];
        this.hideIcon = false;
        this.vertical = false;
    }
    renderContent() {
        const { message, dialogTitle, options, icon, vertical } = this;
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <div class="content">
                <div class="info" ?hidden=${!dialogTitle && !message}>
                    <pl-icon class="info-icon" icon="${icon}"></pl-icon>
                    <div class="info-body">
                        <div class="info-title">${dialogTitle}</div>
                        <div class="info-text ${this.dialogTitle ? "small" : ""}">${message}</div>
                    </div>
                </div>

                <div class="actions ${vertical || options.length > 2 ? "vertical" : ""}">
                    ${options.map((o, i) => _base__WEBPACK_IMPORTED_MODULE_1__.html `
                                <button class="tap ${this._buttonClass(i)}" @click=${() => this.done(i)}>${o}</button>
                            `)}
                </div>
            </div>
        `;
    }
    done(i = -1) {
        super.done(i);
    }
    show({ message = "", title = "", options = ["OK"], type = "info", preventDismiss = false, hideIcon = false, vertical = false, icon, preventAutoClose } = {}) {
        this.message = message;
        this.dialogTitle = title;
        this.type = type;
        this.preventDismiss = preventDismiss;
        this.options = options;
        this.hideIcon = hideIcon;
        this.vertical = vertical;
        this.icon = icon || this._icon(type);
        if (typeof preventAutoClose !== "undefined") {
            this.preventAutoClose = preventAutoClose;
        }
        return super.show();
    }
    _icon(type) {
        switch (type) {
            case "info":
                return "info-round";
            case "warning":
                return "error";
            case "success":
                return "success";
            case "question":
            case "choice":
            case "destructive":
                return "question";
            default:
                return "";
        }
    }
    _buttonClass(i) {
        if (i === 0) {
            return this.type === "destructive" ? "negative" : this.type !== "choice" ? "primary" : "";
        }
        else {
            return "";
        }
    }
};
AlertDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_2__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            :host([hide-icon]) .info-icon {
                display: none;
            }

            :host([hide-icon]) .info-text,
            :host([hide-icon]) .info-title {
                text-align: center;
            }

            .info-text:not(.small) {
                font-size: var(--font-size-default);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], AlertDialog.prototype, "buttonLabel", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], AlertDialog.prototype, "dialogTitle", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], AlertDialog.prototype, "message", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)({ reflect: true, attribute: "type" }),
    __metadata("design:type", String)
], AlertDialog.prototype, "type", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Object)
], AlertDialog.prototype, "icon", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Array)
], AlertDialog.prototype, "options", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)({ attribute: "hide-icon", reflect: true }),
    __metadata("design:type", Boolean)
], AlertDialog.prototype, "hideIcon", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], AlertDialog.prototype, "vertical", void 0);
AlertDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-alert-dialog")
], AlertDialog);



/***/ }),

/***/ "../app/src/elements/app.ts":
/*!**********************************!*\
  !*** ../app/src/elements/app.ts ***!
  \**********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "App": () => (/* binding */ App)
/* harmony export */ });
/* harmony import */ var _assets_fonts_fonts_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../assets/fonts/fonts.css */ "../app/assets/fonts/fonts.css");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _mixins_auto_lock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../mixins/auto-lock */ "../app/src/mixins/auto-lock.ts");
/* harmony import */ var _mixins_error_handling__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../mixins/error-handling */ "../app/src/mixins/error-handling.ts");
/* harmony import */ var _mixins_auto_sync__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../mixins/auto-sync */ "../app/src/mixins/auto-sync.ts");
/* harmony import */ var _mixins_service_worker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../mixins/service-worker */ "../app/src/mixins/service-worker.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _items_list__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./items-list */ "../app/src/elements/items-list.ts");
/* harmony import */ var _settings__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./settings */ "../app/src/elements/settings.ts");
/* harmony import */ var _org_view__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./org-view */ "../app/src/elements/org-view.ts");
/* harmony import */ var _orgs_list__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./orgs-list */ "../app/src/elements/orgs-list.ts");
/* harmony import */ var _start__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./start */ "../app/src/elements/start.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _lib_clipboard__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../lib/clipboard */ "../app/src/lib/clipboard.ts");
/* harmony import */ var _menu__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./menu */ "../app/src/elements/menu.ts");
/* harmony import */ var _invite_dialog__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./invite-dialog */ "../app/src/elements/invite-dialog.ts");
/* harmony import */ var _item_dialog__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./item-dialog */ "../app/src/elements/item-dialog.ts");
/* harmony import */ var _create_org_dialog__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./create-org-dialog */ "../app/src/elements/create-org-dialog.ts");
/* harmony import */ var _choose_plan_dialog__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./choose-plan-dialog */ "../app/src/elements/choose-plan-dialog.ts");
/* harmony import */ var _premium_dialog__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./premium-dialog */ "../app/src/elements/premium-dialog.ts");
/* harmony import */ var _create_item_dialog__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./create-item-dialog */ "../app/src/elements/create-item-dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





























class App extends (0,_mixins_service_worker__WEBPACK_IMPORTED_MODULE_10__.ServiceWorker)((0,_mixins_state__WEBPACK_IMPORTED_MODULE_6__.StateMixin)((0,_mixins_auto_sync__WEBPACK_IMPORTED_MODULE_9__.AutoSync)((0,_mixins_error_handling__WEBPACK_IMPORTED_MODULE_8__.ErrorHandling)((0,_mixins_auto_lock__WEBPACK_IMPORTED_MODULE_7__.AutoLock)(_base__WEBPACK_IMPORTED_MODULE_11__.BaseElement))))) {
    constructor() {
        super();
        this.locked = true;
        this.loggedIn = false;
        this.singletonContainer = true;
        this._ready = false;
        this._menuOpen = false;
        this.load();
    }
    get router() {
        return _globals__WEBPACK_IMPORTED_MODULE_5__.router;
    }
    shouldUpdate() {
        return this._ready;
    }
    async load() {
        await _globals__WEBPACK_IMPORTED_MODULE_5__.app.loaded;
        // Try syncing account so user can unlock with new password in case it has changed
        if (_globals__WEBPACK_IMPORTED_MODULE_5__.app.state.loggedIn) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.app.fetchAccount();
        }
        this._ready = true;
        this._routeChanged();
        const spinner = document.querySelector(".spinner");
        spinner.style.display = "none";
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_11__.html `
            <div class="offline" ?hidden=${_globals__WEBPACK_IMPORTED_MODULE_5__.app.online}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("o f f l i n e")}

                <pl-icon icon="info" class="tap" @click=${this._showOfflineAlert}></pl-icon>
            </div>

            <div class="main">
                <pl-start id="startView"></pl-start>

                <div class="wrapper">
                    <pl-menu></pl-menu>

                    <div class="views">
                        <pl-settings></pl-settings>

                        <pl-org-view></pl-org-view>

                        <pl-orgs-list></pl-orgs-list>

                        <pl-items-list></pl-items-list>

                        <div
                            class="menu-scrim showing"
                            @touchstart=${(e) => this._closeMenu(e)}
                            @click=${(e) => this._closeMenu(e)}
                        ></div>
                    </div>
                </div>

                <slot></slot>
            </div>
        `;
    }
    stateChanged() {
        this.locked = this.state.locked;
        this.loggedIn = this.state.loggedIn;
        super.stateChanged();
    }
    updated(changes) {
        if (changes.has("locked")) {
            if (this.locked) {
                this._locked();
            }
            else {
                this._unlocked();
            }
        }
        if (changes.has("loggedIn")) {
            if (this.loggedIn) {
                this._loggedIn();
            }
            else {
                this._loggedOut();
            }
        }
    }
    _locked() {
        this.$(".wrapper").classList.remove("active");
        (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.clearDialogs)();
        (0,_lib_clipboard__WEBPACK_IMPORTED_MODULE_21__.clearClipboard)();
        this._routeChanged();
    }
    _unlocked(instant = false) {
        setTimeout(async () => {
            if (!this.$(".wrapper")) {
                await this.updateComplete;
            }
            this.$(".wrapper").classList.add("active");
            if (typeof _globals__WEBPACK_IMPORTED_MODULE_5__.router.params.next !== "undefined") {
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go(_globals__WEBPACK_IMPORTED_MODULE_5__.router.params.next, {}, true);
            }
            else {
                this._routeChanged();
            }
        }, instant ? 0 : 600);
    }
    _loggedIn() { }
    _loggedOut() { }
    _toggleMenu() {
        this._menuOpen = !this._menuOpen;
    }
    _closeMenu(e) {
        this._menuOpen = false;
        e.preventDefault();
    }
    _dialogOpen(e) {
        const dialog = e.target;
        this.classList.add("dialog-open");
        if (dialog.hideApp) {
            this.classList.add("hide-app");
        }
    }
    _dialogClose() {
        this.classList.remove("dialog-open");
        this.classList.remove("hide-app");
    }
    async _routeChanged() {
        if (!this._ready) {
            return;
        }
        _dialog__WEBPACK_IMPORTED_MODULE_20__.Dialog.closeAll();
        await _globals__WEBPACK_IMPORTED_MODULE_5__.app.loaded;
        const path = _globals__WEBPACK_IMPORTED_MODULE_5__.router.path;
        let match;
        if (path === "recover") {
            this._startView.recover();
            return;
        }
        if (!_globals__WEBPACK_IMPORTED_MODULE_5__.app.account) {
            if (path === "login") {
                this._startView.login();
            }
            else if ((match = path.match(/^signup(?:\/([^\/]+))?$/))) {
                const [, step] = match;
                this._startView.signup(step);
            }
            else {
                const params = _globals__WEBPACK_IMPORTED_MODULE_5__.router.params;
                if (path) {
                    params.next = path;
                }
                if ((match = path.match(/^invite\/([^\/]+)\/([^\/]+)$/))) {
                    const [, org, id] = match;
                    params.invite = org + "," + id;
                }
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go(params.verify ? "signup" : "login", params, true);
            }
            return;
        }
        if (this.state.locked) {
            if (path === "unlock") {
                this._startView.unlock();
            }
            else {
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("unlock", path ? { next: path, nobio: "1", ..._globals__WEBPACK_IMPORTED_MODULE_5__.router.params } : undefined, true);
            }
            return;
        }
        if (path === "settings") {
            this._openView(this._settings);
            this._menu.selected = "settings";
        }
        else if ((match = path.match(/^orgs?(?:\/([^\/]+))?$/))) {
            const [, id] = match;
            const org = id && _globals__WEBPACK_IMPORTED_MODULE_5__.app.getOrg(id);
            if (id && !org) {
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("orgs", undefined, true);
                return;
            }
            if (org) {
                this._orgView.orgId = id || "";
                this._openView(this._orgView);
                this._menu.selected = `orgs/${id}`;
            }
            else {
                this._openView(this._orgs);
                this._menu.selected = "orgs";
            }
        }
        else if ((match = path.match(/^items(?:\/([^\/]+))?$/))) {
            const [, id] = match;
            const { vault, tag, favorites, attachments, recent, host } = _globals__WEBPACK_IMPORTED_MODULE_5__.router.params;
            this._items.selected = id || "";
            this._items.vault = vault || "";
            this._items.tag = tag || "";
            this._items.favorites = favorites === "true";
            this._items.attachments = attachments === "true";
            this._items.recent = recent === "true";
            this._items.host = host === "true";
            this._openView(this._items);
            this._menu.selected = vault
                ? `vault/${vault}`
                : tag
                    ? `tag/${tag}`
                    : favorites
                        ? "favorites"
                        : recent
                            ? "recent"
                            : attachments
                                ? "attachments"
                                : host
                                    ? "host"
                                    : "items";
            const item = id && _globals__WEBPACK_IMPORTED_MODULE_5__.app.getItem(id);
            if (item) {
                const { newitem, edit, addattachment, ...rest } = _globals__WEBPACK_IMPORTED_MODULE_5__.router.params;
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.params = rest;
                this._itemDialog.isNew = typeof newitem !== "undefined";
                this._itemDialog.show(item.item.id);
                if (typeof edit !== "undefined") {
                    this._itemDialog.edit();
                    if (this._itemDialog.isNew && typeof addattachment !== "undefined") {
                        this._itemDialog.addAttachment();
                    }
                }
                _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateLastUsed(item.item);
            }
        }
        else if ((match = path.match(/^invite\/([^\/]+)\/([^\/]+)$/))) {
            const [, orgId, id] = match;
            const invite = await _globals__WEBPACK_IMPORTED_MODULE_5__.app.getInvite(orgId, id);
            const org = _globals__WEBPACK_IMPORTED_MODULE_5__.app.getOrg(orgId);
            if (invite) {
                if (org && org.isAdmin(_globals__WEBPACK_IMPORTED_MODULE_5__.app.account)) {
                    await org.unlock(_globals__WEBPACK_IMPORTED_MODULE_5__.app.account);
                    await invite.unlock(org.invitesKey);
                }
                this._inviteDialog.show(invite);
            }
            else {
                await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Could not find invite! Did you use the correct link?"), { type: "warning" });
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("items", undefined, true);
            }
        }
        else if ((match = path.match(/^plans?\/(.+)\/?$/))) {
            const billingProvider = _globals__WEBPACK_IMPORTED_MODULE_5__.app.state.billingProvider;
            if (!billingProvider) {
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("items", undefined, true);
                return;
            }
            const planType = parseInt(match[1]);
            if (planType === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.PlanType.Premium) {
                await this._premiumDialog.show();
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("items", undefined, true);
            }
            else {
                const plan = billingProvider.plans.find(p => p.type === planType);
                if (plan && plan.type !== _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.PlanType.Free) {
                    const org = await this._createOrgDialog.show(plan);
                    if (org) {
                        _globals__WEBPACK_IMPORTED_MODULE_5__.router.go(`orgs/${org.id}`);
                    }
                    else {
                        _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("items", undefined, true);
                    }
                }
                else {
                    _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("items", undefined, true);
                }
            }
        }
        else {
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("items", undefined, true);
        }
    }
    async _openView(view) {
        if (view === this._view) {
            return;
        }
        if (view) {
            view.classList.add("showing");
            view.active = true;
        }
        if (this._view) {
            this._view.classList.remove("showing");
            this._view.active = false;
        }
        this._view = view;
    }
    _keydown(event) {
        if (this.state.locked || _input__WEBPACK_IMPORTED_MODULE_13__.Input.activeInput) {
            return;
        }
        const control = event.ctrlKey || event.metaKey;
        // ESCAPE -> Back
        if (event.key === "Escape") {
            if (_dialog__WEBPACK_IMPORTED_MODULE_20__.Dialog.openDialogs.size) {
                _dialog__WEBPACK_IMPORTED_MODULE_20__.Dialog.closeAll();
            }
        }
        // CTRL/CMD (+ Shift) + F -> Search (All)
        else if (control && event.key === "f") {
            event.preventDefault();
            const { vault, tags, recent, favorites, attachments, ...rest } = _globals__WEBPACK_IMPORTED_MODULE_5__.router.params;
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("items", event.shiftKey ? rest : { vault, tags, recent, favorites, attachments, ...rest });
            this._items.search();
        }
    }
    _androidBack() {
        if (!this.locked && _globals__WEBPACK_IMPORTED_MODULE_5__.router.canGoBack) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.back();
        }
        else {
            navigator.Backbutton && navigator.Backbutton.goBack();
        }
    }
    async _newItem() {
        const vault = (_globals__WEBPACK_IMPORTED_MODULE_5__.router.params.vault && _globals__WEBPACK_IMPORTED_MODULE_5__.app.getVault(_globals__WEBPACK_IMPORTED_MODULE_5__.router.params.vault)) || undefined;
        await this._createItemDialog.show(vault);
    }
    async _createOrg() {
        let plan = null;
        if (_globals__WEBPACK_IMPORTED_MODULE_5__.app.billingEnabled) {
            plan = await this._choosePlanDialog.show();
            if (!plan) {
                return;
            }
        }
        const org = await this._createOrgDialog.show(plan);
        if (org) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go(`orgs/${org.id}`);
        }
    }
    async _getPremium(e) {
        const message = e.detail && e.detail.message;
        const icon = (e.detail && e.detail.icon) || "error";
        const confirmed = !message || (await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.confirm)(message, (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Get Premium"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Cancel"), { icon }));
        if (confirmed) {
            await this._premiumDialog.show();
        }
        this._routeChanged();
    }
    _showOfflineAlert() {
        (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("It looks like the app cannot connect to the Padloc servers right now, probably due " +
            "to a missing internet connection. You can still access your vaults and even create " +
            "or edit Vault Items but your changes won't be synchronized until you're back online."), { title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("You're Offline") });
    }
    async _enableBiometricAuth(e) {
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.confirm)((e.detail && e.detail.message) || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Do you want to enable biometric unlock for this device?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Setup"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Cancel"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Biometric Unlock")
        });
        if (!confirmed) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.app.forgetMasterKey();
            return;
        }
        try {
            const authenticated = await (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_3__.biometricAuth)();
            if (!authenticated) {
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Biometric authentication failed! Canceling Setup."), {
                    title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Setup Failed"),
                    type: "warning"
                });
                _globals__WEBPACK_IMPORTED_MODULE_5__.app.forgetMasterKey();
                return;
            }
        }
        catch (e) {
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Biometric unlock failed! Canceling Setup. (Reason: {0})", e.message), {
                title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Setup Failed"),
                type: "warning"
            });
            _globals__WEBPACK_IMPORTED_MODULE_5__.app.forgetMasterKey();
            return;
        }
        if (_globals__WEBPACK_IMPORTED_MODULE_5__.app.account.locked) {
            const password = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Please enter your master password!"), {
                title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Biometric Unlock"),
                label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Enter Master Password"),
                type: "password",
                validate: async (pwd) => {
                    try {
                        await _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.unlock(pwd);
                    }
                    catch (e) {
                        throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Wrong password! Please try again!");
                    }
                    return pwd;
                }
            });
            if (!password) {
                _globals__WEBPACK_IMPORTED_MODULE_5__.app.forgetMasterKey();
                return;
            }
            await _globals__WEBPACK_IMPORTED_MODULE_5__.app.unlock(password);
        }
        await _globals__WEBPACK_IMPORTED_MODULE_5__.app.rememberMasterKey();
        await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Biometric unlock activated successfully!"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Biometric Unlock"),
            type: "success",
            preventAutoClose: true
        });
    }
    async _fieldDragged({ detail: { event, item, index } }) {
        const field = item.fields[index];
        const target = event.target;
        target.classList.add("dragging");
        target.addEventListener("dragend", () => target.classList.remove("dragging"), { once: true });
        const totp = target.querySelector("pl-totp") || (target.shadowRoot && target.shadowRoot.querySelector("pl-totp"));
        event.dataTransfer.setData("text/plain", field.type === "totp" && totp ? totp.token : field.value);
    }
}
App.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_4__.config.cssVars,
    _styles__WEBPACK_IMPORTED_MODULE_4__.shared,
    _base__WEBPACK_IMPORTED_MODULE_11__.css `
            @keyframes fadeIn {
                from {
                    opacity: 0;
                }
            }

            :host {
                background: linear-gradient(
                    var(--color-gradient-highlight-to) 0%,
                    var(--color-gradient-highlight-from) 100%
                );
                overflow: hidden;
                color: var(--color-foreground);
                position: fixed;
                width: 100%;
                height: 100%;
                animation: fadeIn 0.5s;
                display: flex;
                flex-direction: column;
                --menu-width: 250px;
            }

            .main {
                flex: 1;
                position: relative;
                perspective: 1000px;
            }

            .wrapper {
                display: flex;
                transform-origin: 0 center;
                transition: transform 0.4s cubic-bezier(0.6, 0, 0.2, 1);
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.fullbleed()}
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.gradientDark()}
            }

            pl-menu {
                width: var(--menu-width);
            }

            .views {
                flex: 1;
                position: relative;
                margin: var(--gutter-size);
                margin-left: 0;
                background: var(--color-quaternary);
                border-radius: var(--border-radius);
                overflow: hidden;
            }

            .views > * {
                transition: opacity 0.4s;
                border-radius: var(--border-radius);
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.fullbleed()}
            }

            .views > :not(.showing) {
                opacity: 0;
                z-index: -1;
                pointer-events: none;
            }

            .wrapper:not(.active),
            :host(.dialog-open) .wrapper {
                transform: translate3d(0, 0, -150px) rotateX(5deg);
                border-radius: var(--border-radius);
            }

            :host(.dialog-open.hide-app) {
                background: transparent;
            }

            :host(.dialog-open.hide-app) .main > * {
                opacity: 0;
            }

            .offline {
                background: var(--color-negative);
                color: var(--color-tertiary);
                padding: 8px;
                text-align: center;
                z-index: 100;
                font-weight: 600;
                font-size: var(--font-size-small);
                position: relative;
            }

            .offline pl-icon {
                position: absolute;
                right: 0;
                bottom: 0;
                font-size: var(--font-size-micro);
                margin: 4px;
                width: 30px;
                height: 30px;
            }

            .menu-scrim {
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.fullbleed()}
                z-index: 10;
                background: var(--color-tertiary);
                opacity: 0.3;
                transition: opacity 0.3s;
                display: none;
            }

            @supports (-webkit-overflow-scrolling: touch) {
                .offline {
                    padding-top: max(calc(env(safe-area-inset-top) - 8px), 8px);
                    margin-bottom: calc(-1 * max(env(safe-area-inset-top), 8px) + 8px);
                }
            }

            @media (max-width: 700px) {
                .views {
                    transition: transform 0.3s cubic-bezier(0.6, 0, 0.2, 1);
                    ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.fullbleed()}
                }

                .views {
                    margin: 0;
                }

                .views,
                .views > * {
                    border-radius: 0;
                }

                :host([menu-open]) .views {
                    transform: translate(var(--menu-width), 0);
                }

                pl-menu {
                    transition: transform 0.3s cubic-bezier(0.6, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.6, 0, 0.2, 1);
                }

                .menu-scrim {
                    display: block;
                }

                :host(:not([menu-open])) .menu-scrim {
                    opacity: 0;
                    pointer-events: none;
                }

                :host(:not([menu-open])) pl-menu {
                    opacity: 0;
                    transform: translate(-100px, 0);
                }
            }

            @media (min-width: 1200px) {
                .wrapper {
                    border-radius: 8px;
                    overflow: hidden;
                    box-shadow: rgba(0, 0, 0, 0.5) 0 1px 3px;
                    margin: auto;
                    overflow: hidden;
                    top: 20px;
                    left: 20px;
                    right: 20px;
                    bottom: 20px;
                    max-width: 1200px;
                    max-height: 900px;
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.property)(),
    __metadata("design:type", Object)
], App.prototype, "locked", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.property)(),
    __metadata("design:type", Object)
], App.prototype, "loggedIn", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.property)({ type: Boolean, reflect: true, attribute: "singleton-container" }),
    __metadata("design:type", Object)
], App.prototype, "singletonContainer", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.property)(),
    __metadata("design:type", Object)
], App.prototype, "_ready", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.query)("pl-start"),
    __metadata("design:type", _start__WEBPACK_IMPORTED_MODULE_18__.Start)
], App.prototype, "_startView", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.query)("pl-settings"),
    __metadata("design:type", _settings__WEBPACK_IMPORTED_MODULE_15__.Settings)
], App.prototype, "_settings", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.query)("pl-org-view"),
    __metadata("design:type", _org_view__WEBPACK_IMPORTED_MODULE_16__.OrgView)
], App.prototype, "_orgView", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.query)("pl-items-list"),
    __metadata("design:type", _items_list__WEBPACK_IMPORTED_MODULE_14__.ItemsList)
], App.prototype, "_items", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.query)("pl-orgs-list"),
    __metadata("design:type", _orgs_list__WEBPACK_IMPORTED_MODULE_17__.OrgsList)
], App.prototype, "_orgs", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.query)("pl-menu"),
    __metadata("design:type", _menu__WEBPACK_IMPORTED_MODULE_22__.Menu)
], App.prototype, "_menu", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.dialog)("pl-invite-dialog"),
    __metadata("design:type", _invite_dialog__WEBPACK_IMPORTED_MODULE_23__.InviteDialog)
], App.prototype, "_inviteDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.dialog)("pl-item-dialog"),
    __metadata("design:type", _item_dialog__WEBPACK_IMPORTED_MODULE_24__.ItemDialog)
], App.prototype, "_itemDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.dialog)("pl-choose-plan-dialog"),
    __metadata("design:type", _choose_plan_dialog__WEBPACK_IMPORTED_MODULE_26__.ChoosePlanDialog)
], App.prototype, "_choosePlanDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.dialog)("pl-create-org-dialog"),
    __metadata("design:type", _create_org_dialog__WEBPACK_IMPORTED_MODULE_25__.CreateOrgDialog)
], App.prototype, "_createOrgDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.dialog)("pl-premium-dialog"),
    __metadata("design:type", _premium_dialog__WEBPACK_IMPORTED_MODULE_27__.PremiumDialog)
], App.prototype, "_premiumDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_19__.dialog)("pl-create-item-dialog"),
    __metadata("design:type", _create_item_dialog__WEBPACK_IMPORTED_MODULE_28__.CreateItemDialog)
], App.prototype, "_createItemDialog", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.property)(),
    __metadata("design:type", Object)
], App.prototype, "_view", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.property)({ reflect: true, attribute: "menu-open" }),
    __metadata("design:type", Boolean)
], App.prototype, "_menuOpen", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("toggle-menu"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], App.prototype, "_toggleMenu", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("dialog-open"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [CustomEvent]),
    __metadata("design:returntype", void 0)
], App.prototype, "_dialogOpen", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("dialog-close"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], App.prototype, "_dialogClose", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("route-changed", _globals__WEBPACK_IMPORTED_MODULE_5__.router),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], App.prototype, "_routeChanged", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("keydown", document),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [KeyboardEvent]),
    __metadata("design:returntype", void 0)
], App.prototype, "_keydown", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("backbutton", document),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], App.prototype, "_androidBack", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("create-item"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], App.prototype, "_newItem", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("create-org"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], App.prototype, "_createOrg", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("get-premium"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [CustomEvent]),
    __metadata("design:returntype", Promise)
], App.prototype, "_getPremium", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("enable-biometric-auth"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [CustomEvent]),
    __metadata("design:returntype", Promise)
], App.prototype, "_enableBiometricAuth", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_11__.listen)("field-dragged"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [CustomEvent]),
    __metadata("design:returntype", Promise)
], App.prototype, "_fieldDragged", null);
window.customElements.define("pl-app", App);


/***/ }),

/***/ "../app/src/elements/attachment-dialog.ts":
/*!************************************************!*\
  !*** ../app/src/elements/attachment-dialog.ts ***!
  \************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AttachmentDialog": () => (/* binding */ AttachmentDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _view__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./view */ "../app/src/elements/view.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};










let AttachmentDialog = class AttachmentDialog extends _dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog {
    constructor() {
        super(...arguments);
        this.info = null;
        this.itemId = null;
        this.preventDismiss = true;
        this._progress = null;
        this._error = "";
        this._attachment = null;
        this._preview = null;
    }
    get _item() {
        const found = (this.itemId && _globals__WEBPACK_IMPORTED_MODULE_2__.app.getItem(this.itemId)) || null;
        return found && found.item;
    }
    get _vault() {
        const found = (this.itemId && _globals__WEBPACK_IMPORTED_MODULE_2__.app.getItem(this.itemId)) || null;
        return found && found.vault;
    }
    show({ info, item }) {
        this.info = info;
        this.itemId = item;
        this._error = "";
        this._progress = null;
        this._preview = null;
        this._attachment = null;
        this._download();
        return super.show();
    }
    done() {
        if (this._objectUrl) {
            URL.revokeObjectURL(this._objectUrl);
        }
        this._objectUrl = undefined;
        this._preview = null;
        this._attachment = null;
        super.done();
    }
    async _delete() {
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to delete this attachment?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Attachment"),
            type: "destructive"
        });
        if (confirmed) {
            await _globals__WEBPACK_IMPORTED_MODULE_2__.app.deleteAttachment(this.itemId, this.info);
            this.done();
        }
        else {
            this.open = true;
        }
    }
    async _download() {
        this._progress = null;
        this._error = "";
        const att = await _globals__WEBPACK_IMPORTED_MODULE_2__.app.downloadAttachment(this.info);
        const download = att.downloadProgress;
        const handler = () => (this._progress = download.progress);
        download.addEventListener("progress", handler);
        try {
            await download.completed;
        }
        catch (e) { }
        download.removeEventListener("progress", handler);
        this._progress = null;
        if (download.error) {
            this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Download failed!");
        }
        else {
            this._attachment = att;
            this._preview = await this._getPreview(att);
        }
    }
    async _getPreview(att) {
        if (!this.info) {
            return null;
        }
        const mType = (0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.mediaType)(this.info.type);
        switch (mType) {
            case "pdf":
                this._objectUrl = await att.toObjectURL();
                return _base__WEBPACK_IMPORTED_MODULE_6__.html `
                    <object class="content preview pdf" type="application/pdf" data="${this._objectUrl}"></object>
                `;
            case "image":
                this._objectUrl = await att.toObjectURL();
                return _base__WEBPACK_IMPORTED_MODULE_6__.html `
                    <div class="content preview image">
                        <img src="${this._objectUrl}" />
                    </div>
                `;
            case "text":
            case "code":
                const text = await att.toText();
                return _base__WEBPACK_IMPORTED_MODULE_6__.html `<pre class="content preview ${mType}"><code>${text}</pre></code>`;
            default:
                return null;
        }
    }
    async _saveToDisk() {
        if (!this._attachment || !this.info) {
            throw "Need to download attachment first!";
        }
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Do you want to save this file to your disk? WARNING: Doing " +
            "this will leave the file exposed and unprotected on your " +
            "harddrive!"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Save"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel"), { title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Save To Disk"), type: "warning" });
        this.open = true;
        if (confirmed) {
            (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.saveFile)(this.info.name, this.info.type, await this._attachment.getData());
        }
    }
    async _edit() {
        if (!this.info) {
            return;
        }
        this.open = false;
        await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.prompt)("", {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Edit Name"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Save"),
            value: this.info.name,
            label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Attachment Name"),
            validate: async (name) => {
                if (!name) {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter an attachment name!");
                }
                if (name !== this.info.name) {
                    this.info.name = name;
                    await _globals__WEBPACK_IMPORTED_MODULE_2__.app.updateItem(this._item, {});
                }
                return name;
            }
        });
        this.open = true;
    }
    renderContent() {
        if (!this.info) {
            return _base__WEBPACK_IMPORTED_MODULE_6__.html ``;
        }
        return _base__WEBPACK_IMPORTED_MODULE_6__.html `
            <header>
                <div class="name">${this.info.name}</div>
                <pl-icon icon="close" class="tap" @click=${() => this.done()}></pl-icon>
            </header>

            ${this._preview ||
            _base__WEBPACK_IMPORTED_MODULE_6__.html `
                    <div class="content info">
                        <pl-spinner
                            class="loading-spinner"
                            .active=${!!this._progress}
                            ?hidden=${!this._progress}
                        ></pl-spinner>
                        <pl-icon .icon=${(0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.fileIcon)(this.info.type)} ?hidden=${!!this._progress}></pl-icon>

                        <div class="mime-type ellipis">${this.info.type || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unknown File Type")}</div>

                        <div class="error" ?hidden=${!this._error}>${this._error}</div>

                        <div class="size" ?hidden=${!!this._error}>
                            ${this._progress
                ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("downloading... {0}/{1}", (0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.fileSize)(this._progress.loaded), (0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.fileSize)(this._progress.total))
                : (0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.fileSize)(this.info.size)}
                        </div>
                    </div>
                `}

            <div class="fabs">
                <pl-icon icon="delete" class="fab tap destructive" @click=${this._delete}></pl-icon>
                <div class="flex"></div>
                <pl-icon icon="edit" class="fab light tap" @click=${this._edit}></pl-icon>
                <pl-icon
                    icon="download"
                    class="fab light tap"
                    ?disabled=${!this._attachment}
                    @click=${this._saveToDisk}
                ></pl-icon>
            </div>
        `;
    }
};
AttachmentDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog.styles,
    ..._view__WEBPACK_IMPORTED_MODULE_9__.View.styles,
    _base__WEBPACK_IMPORTED_MODULE_6__.css `
            .inner {
                background: none;
                box-shadow: none;
                border-radius: 0;
                ${_styles__WEBPACK_IMPORTED_MODULE_3__.mixins.fullbleed()}
                max-width: none;
                display: flex;
                flex-direction: column;
            }

            .scrim {
                background: var(--color-secondary);
            }

            :host([open]) .scrim {
                opacity: 1;
            }

            header {
                box-shadow: rgba(0, 0, 0, 0.15) 0px 1px 3px;
            }

            header > .name {
                flex: 1;
                font-weight: bold;
                text-align: center;
                ${_styles__WEBPACK_IMPORTED_MODULE_3__.mixins.ellipsis()}
            }

            .info,
            .preview {
                flex: 1;
                position: relative;
            }

            .preview.image {
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 8px;
            }

            .preview.image img {
                width: 100%;
                height: 100%;
                object-fit: scale-down;
            }

            .preview.text,
            .preview.code {
                margin: 0;
                background: var(--color-quaternary);
                font-size: var(--font-size-tiny);
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .preview code {
                padding: 16px;
                padding-bottom: 80px;
                max-width: 100%;
                max-height: 100%;
                box-sizing: border-box;
                ${_styles__WEBPACK_IMPORTED_MODULE_3__.mixins.scroll()}
            }

            .preview.text {
                white-space: normal;
            }

            .preview.text code {
                max-width: 600px;
            }

            .info {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                color: var(--color-tertiary);
            }

            .info > pl-icon {
                width: 100px;
                height: 100px;
                font-size: 80px;
            }

            .controls {
                display: flex;
                align-items: center;
                padding: 12px;
                background: var(--color-tertiarty);
                border-radius: var(--border-radius);
            }

            .mime-type {
                font-weight: bold;
                margin-top: 8px;
            }

            .error {
                font-size: var(--font-size-small);
                margin-bottom: 12px;
                color: var(--color-negative);
                font-weight: bold;
            }

            .size {
                font-size: var(--font-size-small);
                margin-bottom: 12px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], AttachmentDialog.prototype, "info", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], AttachmentDialog.prototype, "itemId", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], AttachmentDialog.prototype, "_progress", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], AttachmentDialog.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", String)
], AttachmentDialog.prototype, "_objectUrl", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], AttachmentDialog.prototype, "_attachment", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], AttachmentDialog.prototype, "_preview", void 0);
AttachmentDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.element)("pl-attachment-dialog")
], AttachmentDialog);



/***/ }),

/***/ "../app/src/elements/base-input.ts":
/*!*****************************************!*\
  !*** ../app/src/elements/base-input.ts ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "BaseInput": () => (/* binding */ BaseInput)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};


let activeInput = null;
// On touch devices, blur active input when tapping on a non-input
document.addEventListener("touchend", () => {
    if (activeInput) {
        activeInput.blur();
    }
});
class BaseInput extends _base__WEBPACK_IMPORTED_MODULE_0__.BaseElement {
    constructor() {
        super(...arguments);
        this.autocapitalize = "off";
        this.disabled = false;
        this.focused = false;
        this.invalid = false;
        this.placeholder = "";
        this.label = "";
        this.noTab = false;
        this.readonly = false;
        this.required = false;
        this.selectOnFocus = false;
        this._prevValue = this.value;
    }
    get value() {
        return (this._inputElement && this._inputElement.value) || "";
    }
    set value(val) {
        (async () => {
            if (!this._inputElement) {
                await this.updateComplete;
            }
            const oldValue = this._inputElement.value;
            this._inputElement.value = val;
            this.requestUpdate("value", oldValue);
        })();
    }
    static get activeInput() {
        return activeInput;
    }
    async focus() {
        if (!this._inputElement) {
            await this.updateComplete;
        }
        this._inputElement.focus();
    }
    async blur() {
        if (!this._inputElement) {
            await this.updateComplete;
        }
        this._inputElement.blur();
    }
    selectAll() {
        try {
            this._inputElement.setSelectionRange(0, this.value.length);
        }
        catch (e) {
            this._inputElement.select();
        }
    }
    _focused(e) {
        e.stopPropagation();
        this.focused = true;
        activeInput = this;
        this.dispatch("focus");
        if (this.selectOnFocus) {
            setTimeout(() => this.selectAll(), 10);
        }
    }
    _blurred(e) {
        e.stopPropagation();
        this.focused = false;
        this.dispatch("blur");
        if (activeInput === this) {
            activeInput = null;
        }
    }
    _changeHandler(e) {
        e.stopPropagation();
        this.dispatch("change", { prevValue: this._prevValue, value: this.value }, true, true);
        this._prevValue = this.value;
    }
    _touchend(e) {
        e.stopPropagation();
    }
    render() {
        const { value, focused, label, placeholder } = this;
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            ${this._renderInput()}

            <label ?float=${focused || !!value || !!placeholder} ?hidden=${!label}>${label}</label>
        `;
    }
}
BaseInput.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_1__.shared,
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            :host {
                display: block;
                position: relative;
                font-size: inherit;
                font-weight: inherit;
                font-family: inherit;
                background: var(--shade-2-color);
                border-radius: var(--border-radius);
                padding: 12px 10px;
            }

            input {
                box-sizing: border-box;
                text-overflow: ellipsis;
                box-shadow: none;
            }

            .input-element {
                text-align: inherit;
                width: 100%;
                min-height: inherit;
                line-height: inherit;
                caret-color: currentColor;
                cursor: inherit;
            }

            textarea {
                overflow-wrap: break-word;
            }

            ::-webkit-search-cancel-button {
                display: none;
            }

            ::-webkit-placeholder {
                text-shadow: inherit;
                color: inherit;
                opacity: 0.5;
            }

            label {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                padding: 12px 10px;
                opacity: 0.5;
                transition: transform 0.2s, color 0.2s, opacity 0.5s;
                cursor: text;
                pointer-events: none;
            }

            label[float] {
                transform: scale(0.8) translate(0, -32px);
                color: var(--color-highlight);
                font-weight: bold;
                opacity: 1;
            }

            .input-element[disabled] {
                opacity: 1;
                -webkit-text-fill-color: currentColor;
            }

            @supports (-webkit-overflow-scrolling: touch) {
                input[type="date"],
                input[type="month"] {
                    display: block;
                    min-height: 1.5em;
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String)
], BaseInput.prototype, "autocapitalize", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], BaseInput.prototype, "disabled", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], BaseInput.prototype, "focused", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], BaseInput.prototype, "invalid", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String)
], BaseInput.prototype, "placeholder", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String)
], BaseInput.prototype, "label", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ attribute: "no-tab" }),
    __metadata("design:type", Boolean)
], BaseInput.prototype, "noTab", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], BaseInput.prototype, "readonly", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], BaseInput.prototype, "required", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ attribute: "select-on-focus" }),
    __metadata("design:type", Boolean)
], BaseInput.prototype, "selectOnFocus", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], BaseInput.prototype, "value", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.query)(".input-element"),
    __metadata("design:type", HTMLInputElement)
], BaseInput.prototype, "_inputElement", void 0);


/***/ }),

/***/ "../app/src/elements/base.ts":
/*!***********************************!*\
  !*** ../app/src/elements/base.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "html": () => (/* reexport safe */ lit_element__WEBPACK_IMPORTED_MODULE_1__.html),
/* harmony export */   "css": () => (/* reexport safe */ lit_element__WEBPACK_IMPORTED_MODULE_1__.css),
/* harmony export */   "svg": () => (/* reexport safe */ lit_element__WEBPACK_IMPORTED_MODULE_1__.svg),
/* harmony export */   "BaseElement": () => (/* binding */ BaseElement),
/* harmony export */   "element": () => (/* binding */ element),
/* harmony export */   "property": () => (/* binding */ property),
/* harmony export */   "query": () => (/* binding */ query),
/* harmony export */   "queryAll": () => (/* binding */ queryAll),
/* harmony export */   "listen": () => (/* binding */ listen),
/* harmony export */   "observe": () => (/* binding */ observe)
/* harmony export */ });
/* harmony import */ var reflect_metadata__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! reflect-metadata */ "../app/node_modules/reflect-metadata/Reflect.js");
/* harmony import */ var reflect_metadata__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(reflect_metadata__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lit_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lit-element */ "../app/node_modules/lit-element/lit-element.js");



class BaseElement extends lit_element__WEBPACK_IMPORTED_MODULE_1__.LitElement {
    constructor() {
        super(...arguments);
        this._$ = {};
        this._$$ = {};
        this._listeners = [];
    }
    /**
     * Find first element macthing the selector in the element's shadow root, caching the result
     * @param selector query selector string
     */
    $(sel, cached = false) {
        if (!cached || !this._$[sel]) {
            const e = this.renderRoot.querySelector(sel);
            if (e) {
                this._$[sel] = e;
            }
        }
        return this._$[sel];
    }
    /**
     * Find first element macthing the selector in the element's shadow root, caching the result
     * @param selector query selector string
     */
    $$(sel, cached = false) {
        if (!cached || !this._$[sel]) {
            const e = this.renderRoot.querySelectorAll(sel);
            if (e) {
                this._$$[sel] = e;
            }
        }
        return this._$$[sel];
    }
    /**
     * Fires a custom event with the specified name
     * @param name Name of the event
     * @param detail Optional event detail object
     * @param bubbles Optional - if the event bubbles. Default is TRUE.
     * @param composed Optional - if the event bubbles past the shadow root. Default is TRUE.
     */
    dispatch(name, detail, bubbles = true, composed = true) {
        if (name) {
            const init = {
                bubbles: typeof bubbles === "boolean" ? bubbles : true,
                composed: typeof composed === "boolean" ? composed : true
            };
            if (detail) {
                init.detail = detail;
            }
            this.dispatchEvent(new CustomEvent(name, init));
        }
    }
    get node() {
        return this;
    }
    connectedCallback() {
        super.connectedCallback();
        const declarations = this.constructor._listeners;
        if (!declarations) {
            return;
        }
        for (const decl of declarations) {
            (async () => {
                let targets = [];
                if (!decl.target) {
                    targets = [this];
                }
                else if (typeof decl.target === "string") {
                    // a string target property indicates that the target is a child of this element,
                    // so we have to make sure the renderRoot is created first
                    await this.updateComplete;
                    targets = this.$$(decl.target);
                }
                else if (typeof decl.target.addEventListener === "function") {
                    targets = [decl.target];
                }
                if (!targets.length) {
                    throw "invalid event target: " + decl.target;
                }
                const handler = (e) => {
                    decl.handler.call(this, e);
                };
                for (const target of targets) {
                    target.addEventListener(decl.name, handler);
                    this._listeners.push({
                        target,
                        handler,
                        name: decl.name
                    });
                }
            })();
        }
    }
    disconnectedCallback() {
        let listener;
        while ((listener = this._listeners.pop())) {
            listener.target.removeEventListener(listener.name, listener.handler);
        }
    }
    updated(changed) {
        let proto = this;
        do {
            const observers = proto.constructor._observers;
            if (!observers) {
                return;
            }
            for (const observer of observers) {
                if (observer.props.some(p => changed.has(p))) {
                    observer.handler.call(this, changed);
                }
            }
        } while (proto instanceof BaseElement && (proto = Object.getPrototypeOf(proto)));
    }
}
/**
 * Decorator for defining a new custom element
 * @param name tag name of custom element
 */
function element(name) {
    return (c) => {
        if (name) {
            window.customElements.define(name, c);
        }
    };
}
function property(options) {
    return (proto, name) => {
        options = options || {};
        if (!options.type) {
            // @ts-ignore
            options.type = getType(proto, name);
        }
        proto.constructor.createProperty(name, options);
    };
}
function getType(prototype, propertyName) {
    if (Reflect.hasMetadata) {
        if (Reflect.hasMetadata("design:type", prototype, propertyName)) {
            return Reflect.getMetadata("design:type", prototype, propertyName);
        }
    }
    return null;
}
/**
 * Decorator to create a getter for the specified selector
 * @param selector selector to find the element
 */
function query(selector, cached = false) {
    return (prototype, propertyName) => {
        Object.defineProperty(prototype, propertyName, {
            get() {
                return this.$(selector, cached);
            },
            enumerable: true,
            configurable: true
        });
    };
}
/**
 * Decorator to create a getter that returns a nodelist of all
 * elements matching the selector
 * @param selector selector query
 */
function queryAll(selector, cached = false) {
    return (prototype, propertyName) => {
        Object.defineProperty(prototype, propertyName, {
            get() {
                return this.$$(selector, cached);
            },
            enumerable: true,
            configurable: true
        });
    };
}
/**
 * Decorator to add event handlers
 * @param name name of event, e.g. 'click'
 * @param selector EventTarget or a selector to the node to listen to e.g. '#myButton'
 */
function listen(name, target) {
    return (prototype, methodName) => {
        const { constructor } = prototype;
        if (!constructor.hasOwnProperty("_listeners")) {
            Object.defineProperty(constructor, "_listeners", { value: [] });
        }
        constructor._listeners.push({
            name,
            target,
            handler: prototype[methodName]
        });
    };
}
/**
 * Decortator to define an observer that gets called back
 * whenever any of the specified property is updated
 * @param properties list of properties to observe
 */
function observe(...properties) {
    return (prototype, methodName) => {
        const { constructor } = prototype;
        if (!constructor.hasOwnProperty("_observers")) {
            Object.defineProperty(constructor, "_observers", { value: [] });
        }
        constructor._observers.push({
            props: properties,
            handler: prototype[methodName]
        });
    };
}


/***/ }),

/***/ "../app/src/elements/billing-dialog.ts":
/*!*********************************************!*\
  !*** ../app/src/elements/billing-dialog.ts ***!
  \*********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "BillingDialog": () => (/* binding */ BillingDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_countries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/countries */ "../locale/src/countries.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _select__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./select */ "../app/src/elements/select.ts");
/* harmony import */ var _assets_fonts_Nunito_Regular_ttf__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../assets/fonts/Nunito-Regular.ttf */ "../app/assets/fonts/Nunito-Regular.ttf");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











let BillingDialog = class BillingDialog extends _dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog {
    constructor() {
        super(...arguments);
        this.condensed = false;
        this.dialogTitle = "";
        this.message = "";
        this.submitLabel = "";
        this.preventDismiss = true;
        this._error = "";
        this._editingPaymentMethod = false;
        this._isBusiness = false;
    }
    async show({ condensed, title, message, submitLabel, billingInfo }) {
        this.condensed = condensed || false;
        this.dialogTitle = title || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Update Billing Info");
        this.message = message || "";
        this.submitLabel = submitLabel || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Save");
        this._billingInfo = billingInfo;
        this._editingPaymentMethod = !this._billingInfo || !this._billingInfo.paymentMethod;
        // $l(
        //                     "Add your billing info now so you're all set to keep using Padloc once the trial period is over. Don't worry, you won't be charged yet!"
        //                 )
        if (_globals__WEBPACK_IMPORTED_MODULE_4__.app.state.billingProvider && !this._stripe) {
            this._initStripe();
        }
        return super.show();
    }
    async _initStripe() {
        const stripePubKey = _globals__WEBPACK_IMPORTED_MODULE_4__.app.state.billingProvider && _globals__WEBPACK_IMPORTED_MODULE_4__.app.state.billingProvider.config.publicKey;
        if (!stripePubKey) {
            return;
        }
        const Stripe = await (0,_lib_util__WEBPACK_IMPORTED_MODULE_3__.loadScript)("https://js.stripe.com/v3/", "Stripe");
        const stripe = (this._stripe = Stripe(stripePubKey));
        const elements = stripe.elements({
            fonts: [
                {
                    src: `local("Nunito Regular"), local("Nunito-Regular"), url(${_assets_fonts_Nunito_Regular_ttf__WEBPACK_IMPORTED_MODULE_10__["default"]}) format("truetype")`,
                    family: "Nunito",
                    style: "normal",
                    weight: 400
                }
            ]
        });
        const card = (this._cardElement = elements.create("card", {
            iconStyle: "solid",
            hidePostalCode: true,
            style: {
                base: {
                    fontFamily: '"Nunito", "Helvetica Neue", Helvetica, sans-serif',
                    fontSmoothing: "antialiased",
                    fontSize: "18px"
                }
            }
        }));
        const cardElement = document.createElement("div");
        this.appendChild(cardElement);
        card.mount(cardElement);
        let cardEmpty = true;
        card.addEventListener("change", (e) => {
            this._error = (e.error && e.error.message) || "";
            cardEmpty = e.empty;
        });
        card.addEventListener("blur", () => {
            if (cardEmpty) {
                this._editingPaymentMethod = !this._billingInfo || !this._billingInfo.paymentMethod;
            }
        });
    }
    async _editPaymentMethod() {
        this._editingPaymentMethod = true;
        await this.updateComplete;
        this._cardElement.focus();
    }
    async _submit() {
        if (this._submitButton.state === "loading") {
            return;
        }
        this._error = "";
        let paymentMethod;
        if (this._editingPaymentMethod) {
            this._submitButton.start();
            const { token, error } = await this._stripe.createToken(this._cardElement);
            if (error) {
                this._error = error.message;
                this._submitButton.fail();
                return;
            }
            this._submitButton.success();
            paymentMethod = {
                name: `${token.card.brand} •••• •••• •••• ${token.card.last4}`,
                source: token.id
            };
        }
        const address = new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.BillingAddress().fromRaw({
            name: this._nameInput.value,
            street: this._streetInput.value,
            postalCode: this._zipInput.value,
            city: this._cityInput.value,
            country: this._countrySelect.selected.code
        });
        const coupon = this._couponInput.value;
        this.done(new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.UpdateBillingParams({
            account: this._billingInfo.account,
            org: this._billingInfo.org,
            email: this._emailInput.value,
            address,
            paymentMethod,
            coupon
        }));
    }
    renderContent() {
        const billingInfo = this._billingInfo || new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.BillingInfo();
        let { email, address, paymentMethod, discount } = billingInfo;
        email = email || (_globals__WEBPACK_IMPORTED_MODULE_4__.app.account.billing && _globals__WEBPACK_IMPORTED_MODULE_4__.app.account.billing.email) || _globals__WEBPACK_IMPORTED_MODULE_4__.app.account.email;
        const name = address.name || _globals__WEBPACK_IMPORTED_MODULE_4__.app.account.name;
        const countryOptions = [
            { code: "", toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Select A Country") },
            ..._padloc_locale_src_countries__WEBPACK_IMPORTED_MODULE_0__.countries.map(c => Object.assign(c, { toString: () => c.name }))
        ];
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <header>
                <pl-icon></pl-icon>
                <div class="title flex">${this.dialogTitle}</div>
                <pl-icon icon="cancel" class="tap" @click=${() => this.done()}></pl-icon>
            </header>

            <div class="content">
                ${!_globals__WEBPACK_IMPORTED_MODULE_4__.app.billingEnabled
            ? _base__WEBPACK_IMPORTED_MODULE_5__.html `
                          <div class="payment-disabled-message">
                              ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)('To update your billing info and payment method, please log in through our website (found under "Settings") ' +
                "or contact us at ")}
                              <a href="mailto:support@padloc.app">support@padloc.app</a>!
                          </div>
                      `
            : _base__WEBPACK_IMPORTED_MODULE_5__.html `
                          <div class="message">
                              ${this.message}
                          </div>

                          <label>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Payment Details")}</label>

                          <div class="card-wrapper item" ?hidden=${!this._editingPaymentMethod}>
                              <slot></slot>
                          </div>

                          <div class="error item" ?hidden="${!this._error}">
                              ${this._error}
                          </div>

                          ${paymentMethod
                ? _base__WEBPACK_IMPORTED_MODULE_5__.html `
                                    <div class="payment-method item" ?hidden=${this._editingPaymentMethod}>
                                        <pl-icon icon="credit"></pl-icon>
                                        <div class="flex">
                                            ${paymentMethod.name}
                                        </div>
                                        <pl-icon icon="edit" class="tap" @click=${this._editPaymentMethod}></pl-icon>
                                    </div>
                                `
                : _base__WEBPACK_IMPORTED_MODULE_5__.html ``}

                          <div ?hidden="condensed">
                              <label>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Billing Address")}</label>

                              <pl-input
                                  id="emailInput"
                                  class="item"
                                  .type="email"
                                  .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Billing Email")}
                                  .value=${email}
                              ></pl-input>

                              <pl-input
                                  id="nameInput"
                                  class="item"
                                  .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Name")}
                                  .value=${name}
                              ></pl-input>

                              <pl-input
                                  id="streetInput"
                                  class="item"
                                  .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Address")}
                                  .value=${address.street}
                              ></pl-input>

                              <div class="city-wrapper">
                                  <pl-input
                                      id="zipInput"
                                      class="item"
                                      .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Postal Code")}
                                      .value=${address.postalCode}
                                  ></pl-input>

                                  <pl-input
                                      id="cityInput"
                                      class="item"
                                      .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("City")}
                                      .value=${address.city}
                                  ></pl-input>
                              </div>

                              <pl-select
                                  class="item"
                                  id="countrySelect"
                                  .options=${countryOptions}
                                  .selected=${countryOptions.find(c => c.code === address.country)}
                              ></pl-select>

                              <label>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Tax Info")}</label>

                              <pl-toggle-button
                                  class="item tap"
                                  reverse
                                  .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("This is a business")}
                                  value=${this._isBusiness}
                                  @change=${(e) => (this._isBusiness = e.detail.value)}
                              ></pl-toggle-button>

                              <pl-input
                                  id="taxIdInput"
                                  class="item"
                                  .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Tax ID")}
                                  ?hidden=${!this._isBusiness}
                              ></pl-input>
                          </div>

                          <label>Coupon</label>

                          <div class="discount item" ?hidden=${!discount}>
                              <span class="name">${discount && discount.name}</span>
                              <span class="coupon">(${discount && discount.coupon})</span>
                          </div>

                          <pl-input
                              class="item"
                              id="couponInput"
                              placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Coupon Code")}
                              ?hidden=${!!discount}
                          ></pl-input>

                          <div class="actions">
                              <pl-loading-button class="primary tap" id="submitButton" @click=${this._submit}>
                                  ${this.submitLabel}
                              </pl-loading-button>

                              <button class="tap" @click=${() => this.done()} ?hidden=${this.condensed}>
                                  ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel")}
                              </button>
                          </div>
                      `}
            </div>
        `;
    }
    renderAfter() {
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <button class="tap skip-button" @click=${() => this.done()} ?hidden=${!this.condensed}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Add Later")}
            </button>
        `;
    }
};
BillingDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            .inner {
                background: var(--color-quaternary);
            }

            h1 {
                display: block;
                text-align: center;
            }

            label {
                font-weight: bold;
                margin: 8px 16px;
                font-size: var(--font-size-small);
            }

            .card-wrapper {
                padding: 14px 0 14px 12px;
            }

            .city-wrapper {
                display: grid;
                grid-template-columns: 1fr 1fr;
                grid-gap: 8px;
                margin: 8px;
            }

            .city-wrapper > * {
                margin: 0;
            }

            .payment-method {
                display: flex;
                align-items: center;
                padding: 5px;
                font-weight: bold;
            }

            .message {
                font-size: var(--font-size-small);
                padding: 0 20px 10px 20px;
            }

            .skip-button {
                background: none;
                color: var(--color-tertiary);
                margin-top: 8px;
            }

            .discount {
                padding: 12px;
            }

            .discount .name {
                font-weight: bold;
            }

            .discount .coupon {
                opacity: 0.7;
                font-family: var(--font-family-mono);
            }

            .payment-disabled-message {
                padding: 30px;
                text-align: center;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Boolean)
], BillingDialog.prototype, "condensed", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], BillingDialog.prototype, "dialogTitle", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], BillingDialog.prototype, "message", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], BillingDialog.prototype, "submitLabel", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], BillingDialog.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.BillingInfo)
], BillingDialog.prototype, "_billingInfo", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Boolean)
], BillingDialog.prototype, "_editingPaymentMethod", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Boolean)
], BillingDialog.prototype, "_isBusiness", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#submitButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], BillingDialog.prototype, "_submitButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#emailInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], BillingDialog.prototype, "_emailInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#nameInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], BillingDialog.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#streetInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], BillingDialog.prototype, "_streetInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#zipInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], BillingDialog.prototype, "_zipInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#cityInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], BillingDialog.prototype, "_cityInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#countrySelect"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_9__.Select)
], BillingDialog.prototype, "_countrySelect", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#couponInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], BillingDialog.prototype, "_couponInput", void 0);
BillingDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.element)("pl-billing-dialog")
], BillingDialog);



/***/ }),

/***/ "../app/src/elements/billing-info.ts":
/*!*******************************************!*\
  !*** ../app/src/elements/billing-info.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "BillingInfoElement": () => (/* binding */ BillingInfoElement)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_countries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/countries */ "../locale/src/countries.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _billing_dialog__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./billing-dialog */ "../app/src/elements/billing-dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};









let BillingInfoElement = class BillingInfoElement extends _base__WEBPACK_IMPORTED_MODULE_5__.BaseElement {
    constructor() {
        super(...arguments);
        this.billing = null;
    }
    async _update() {
        if (this._editButton.state === "loading") {
            return;
        }
        const billingInfo = this.billing;
        const params = await this._billingDialog.show({ billingInfo });
        if (params) {
            this._editButton.start();
            try {
                await _globals__WEBPACK_IMPORTED_MODULE_4__.app.updateBilling(params);
                this._editButton.success();
            }
            catch (e) {
                this._editButton.fail();
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)(e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!"), { type: "warning" });
                throw e;
            }
        }
    }
    render() {
        if (!this.billing) {
            return _base__WEBPACK_IMPORTED_MODULE_5__.html ``;
        }
        const billing = this.billing;
        const country = _padloc_locale_src_countries__WEBPACK_IMPORTED_MODULE_0__.countries.find(c => c.code === billing.address.country);
        const postalCode = billing.address.postalCode;
        const city = billing.address.city;
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <pl-loading-button id="editButton" class="edit-button tap icon" @click=${this._update}>
                <pl-icon icon="edit"></pl-icon>
            </pl-loading-button>

            <pl-icon icon="credit" class="data-icon"></pl-icon>

            <div class="data payment-method">
                ${billing.paymentMethod
            ? _base__WEBPACK_IMPORTED_MODULE_5__.html `
                          <div>
                              ${billing.paymentMethod.name}
                          </div>
                      `
            : _base__WEBPACK_IMPORTED_MODULE_5__.html `
                          <div class="missing" @click=${this._update}>
                              ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Add Payment Method")}
                          </div>
                      `}
            </div>

            ${billing.email || billing.address.name
            ? _base__WEBPACK_IMPORTED_MODULE_5__.html `
                      <pl-icon icon="address" class="data-icon"></pl-icon>

                      <div class="data">
                          <div class="billing-email">${billing.email}</div>
                          <div class="billing-name">${billing.address.name}</div>
                          <div class="billing-street">${billing.address.street}</div>
                          <div class="billing-city">
                              ${postalCode ? `${postalCode}, ` : ""} ${city ? `${city}, ` : ""}
                              ${country ? `${country.name}` : ""}
                          </div>
                      </div>
                  `
            : _base__WEBPACK_IMPORTED_MODULE_5__.html ``}
            ${billing.discount
            ? _base__WEBPACK_IMPORTED_MODULE_5__.html `
                      <pl-icon icon="discount" class="data-icon"></pl-icon>

                      <div class="data discount">
                          ${billing.discount.name}
                      </div>
                  `
            : _base__WEBPACK_IMPORTED_MODULE_5__.html ``}
        `;
    }
};
BillingInfoElement.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_2__.shared,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            :host {
                padding: 8px;
                display: grid;
                grid-template-columns: 36px 1fr;
                position: relative;
            }

            .payment-method,
            .billing-email,
            .discount {
                font-weight: bold;
            }

            .data {
                margin: 8px 6px;
            }

            .edit-button {
                position: absolute;
                top: 8px;
                right: 8px;
                z-index: 1;
            }

            .missing {
                opacity: 0.7;
                cursor: pointer;
            }

            .data-icon {
                width: 36px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], BillingInfoElement.prototype, "billing", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#editButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], BillingInfoElement.prototype, "_editButton", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.dialog)("pl-billing-dialog"),
    __metadata("design:type", _billing_dialog__WEBPACK_IMPORTED_MODULE_8__.BillingDialog)
], BillingInfoElement.prototype, "_billingDialog", void 0);
BillingInfoElement = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.element)("pl-billing-info")
], BillingInfoElement);



/***/ }),

/***/ "../app/src/elements/card-input.ts":
/*!*****************************************!*\
  !*** ../app/src/elements/card-input.ts ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "CardInput": () => (/* binding */ CardInput)
/* harmony export */ });
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _assets_fonts_Nunito_Regular_ttf__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../assets/fonts/Nunito-Regular.ttf */ "../app/assets/fonts/Nunito-Regular.ttf");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




let CardInput = class CardInput extends _base__WEBPACK_IMPORTED_MODULE_2__.BaseElement {
    constructor() {
        super(...arguments);
        this.stripePubKey = "pk_test_jTF9rjIV9LyiyJ6ir2ARE8Oy";
        this.error = "";
    }
    async getToken() {
        this.error = "";
        const { token, error } = await this._stripe.createToken(this._cardElement);
        if (error) {
            this.error = error.message;
            this.dispatch("change", { error: this.error });
            throw error;
        }
        return token.id;
    }
    async connectedCallback() {
        super.connectedCallback();
        const Stripe = await (0,_lib_util__WEBPACK_IMPORTED_MODULE_0__.loadScript)("https://js.stripe.com/v3/", "Stripe");
        const stripe = (this._stripe = Stripe(this.stripePubKey));
        const elements = stripe.elements({
            fonts: [
                {
                    src: `local("Nunito Regular"), local("Nunito-Regular"), url(${_assets_fonts_Nunito_Regular_ttf__WEBPACK_IMPORTED_MODULE_3__["default"]}) format("truetype")`,
                    family: "Nunito",
                    style: "normal",
                    weight: 400
                }
            ]
        });
        const card = (this._cardElement = elements.create("card", {
            iconStyle: "solid",
            hidePostalCode: true,
            style: {
                base: {
                    fontFamily: '"Nunito", "Helvetica Neue", Helvetica, sans-serif',
                    fontSmoothing: "antialiased",
                    fontSize: "18px"
                },
                invalid: {
                // color: "#ff6666",
                // textShadow: "none"
                }
            }
        }));
        const cardElement = document.createElement("div");
        this.appendChild(cardElement);
        card.mount(cardElement);
        card.addEventListener("change", (e) => {
            this.error = (e.error && e.error.message) || "";
            this.dispatch("change", { error: this.error });
        });
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <slot></slot>
        `;
    }
};
CardInput.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_1__.shared,
    _base__WEBPACK_IMPORTED_MODULE_2__.css `
            :host {
                display: block;
                padding: 14px 0 14px 12px;
                border-radius: var(--border-radius);
                background: var(--color-shade-1);
            }

            :host(.item) {
                background: var(--color-tertiary);
                border: solid 1px var(--color-shade-1);
                border-bottom-width: 3px;
                margin: var(--gutter-size);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Object)
], CardInput.prototype, "stripePubKey", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Object)
], CardInput.prototype, "error", void 0);
CardInput = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.element)("pl-card-input")
], CardInput);



/***/ }),

/***/ "../app/src/elements/choose-plan-dialog.ts":
/*!*************************************************!*\
  !*** ../app/src/elements/choose-plan-dialog.ts ***!
  \*************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ChoosePlanDialog": () => (/* binding */ ChoosePlanDialog)
/* harmony export */ });
/* harmony import */ var lit_html_directives_unsafe_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/unsafe-html */ "../app/node_modules/lit-html/directives/unsafe-html.js");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @padloc/core/src/org */ "../core/src/org.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};








let ChoosePlanDialog = class ChoosePlanDialog extends _dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog {
    constructor() {
        super(...arguments);
        this._plans = [];
    }
    async show(org) {
        const result = super.show();
        this._org = org;
        if (!_globals__WEBPACK_IMPORTED_MODULE_5__.app.state.billingProvider) {
            this.done();
        }
        else {
            this._plans = _globals__WEBPACK_IMPORTED_MODULE_5__.app.state.billingProvider.plans.filter(p => [_padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.PlanType.Family, _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.PlanType.Team, _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.PlanType.Business].includes(p.type))
                .sort((a, b) => a.type - b.type);
        }
        return result;
    }
    _renderPlan(plan) {
        const monthlyPrice = Math.round(plan.cost / 12);
        const trialDaysLeft = this._org && this._org.billing ? this._org.billing.trialDaysLeft : 30;
        return _base__WEBPACK_IMPORTED_MODULE_6__.html `
            <div
                style=${plan.color
            ? `--color-highlight: ${plan.color}; --color-highlight-text: var(--color-tertiary);`
            : ""}
                class="plan"
                @click=${() => this.done(plan)}
            >
                <div class="plan-header">
                    <div class="plan-name">
                        ${plan.name}
                    </div>
                    <div class="plan-description">
                        ${(0,lit_html_directives_unsafe_html__WEBPACK_IMPORTED_MODULE_0__.unsafeHTML)(plan.description.replace(/\*\*(.+)\*\*/g, "<strong>$1</strong>"))}
                    </div>
                    <div class="flex"></div>
                    <div class="plan-trial" ?hidden=${!trialDaysLeft}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Free For {0} Days", trialDaysLeft.toString())}
                    </div>
                    <div class="plan-then" ?hidden=${!trialDaysLeft}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("then")}
                    </div>
                    <div class="plan-price">
                        <div class="plan-price-currency">
                            $
                        </div>
                        <div class="plan-price-dollars">
                            ${Math.floor(monthlyPrice / 100)}
                        </div>
                        <div class="plan-price-cents">
                            .${(monthlyPrice % 100).toString().padEnd(2, "0")}
                        </div>
                    </div>
                    <div class="plan-unit">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("per user / month")}
                    </div>
                    <div class="flex"></div>
                    <div class="plan-fineprint">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("USD, billed annually")}
                    </div>
                </div>

                <ul class="features">
                    ${plan.features.map(feature => _base__WEBPACK_IMPORTED_MODULE_6__.html `
                            <li>
                                ${(0,lit_html_directives_unsafe_html__WEBPACK_IMPORTED_MODULE_0__.unsafeHTML)(feature.replace(/\*\*(.+)\*\*/g, "<strong>$1</strong>"))}
                            </li>
                        `)}
                </ul>

                <div class="flex"></div>

                <button class="tap">
                    ${this._org ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Choose Plan") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Try For Free")}
                </button>
            </div>
        `;
    }
    //
    // renderBefore() {
    //     return html`
    //         <h2>${$l("Choose A Plan")}</h2>
    //     `;
    // }
    renderContent() {
        const plans = this._plans;
        return _base__WEBPACK_IMPORTED_MODULE_6__.html `
            ${plans.map(plan => this._renderPlan(plan))}
        `;
    }
};
ChoosePlanDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_6__.css `
            h2 {
                color: var(--color-tertiary);
                margin: 0;
            }

            .outer {
                padding: 0;
            }

            .inner {
                background: transparent;
                box-shadow: none;
                max-width: 100%;
                width: 100%;
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.scroll()}
                scroll-snap-type: x mandatory;
                white-space: nowrap;
                padding: 12px 24px;
                text-align: center;
                display: block;
            }

            .plans {
                min-width: 100%;
                display: flex;
                padding: 20px 50px;
                box-sizing: border-box;
                justify-content: center;
            }

            .plan {
                flex: 1;
                white-space: normal;
                width: 100%;
                max-width: 330px;
                background: var(--color-tertiary);
                border-radius: var(--border-radius);
                overflow: hidden;
                display: inline-flex;
                flex-direction: column;
                cursor: pointer;
                scroll-snap-align: center;
                text-align: center;
                will-change: transform;
            }

            .plan:not(:last-child) {
                margin-right: 12px;
            }

            .plan-header {
                text-align: center;
                padding: 20px;
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                display: flex;
                flex-direction: column;
                position: relative;
            }

            /*
            .plan-header::before {
                content: "";
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.fullbleed()}
                background: linear-gradient(rgba(255, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0.2) 100%);
            }
            */

            .plan-name {
                font-size: 2rem;
                margin-bottom: 10px;
                font-weight: bold;
            }

            .plan-description {
                font-size: 1.1rem;
            }

            .plan-trial {
                font-size: 1.5rem;
                margin-top: 8px;
            }

            .plan-then {
                font-size: var(--font-size-small);
                margin: 4px 0 -4px 0;
            }

            .plan-price {
                letter-spacing: 0.1em;
                display: flex;
                align-items: flex-start;
                justify-content: center;
                font-weight: bold;
                font-size: 1.2rem;
                margin-top: 8px;
            }

            .plan-price-currency {
                line-height: 1em;
                margin-top: 0.4em;
            }

            .plan-price-dollars {
                font-size: 3em;
                line-height: 1em;
            }

            .plan-price-cents {
                font-size: 1.5em;
                line-height: 1em;
                margin-top: 0.2em;
            }

            .plan-unit {
                font-size: var(--font-size-small);
            }

            .plan-fineprint {
                font-size: var(--font-size-tiny);
                opacity: 0.8;
            }

            .features {
                font-size: var(--font-size-small);
            }

            .features > * {
                margin: 0;
                padding: 10px 15px;
                border: none;
                border-radius: 0;
            }

            .features > :not(:last-child) {
                border-bottom: solid 1px var(--color-shade-1);
            }

            .plan button {
                margin: 8px;
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                font-weight: bold;
            }

            .tabs {
                color: var(--color-tertiary);
                justify-content: center;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Array)
], ChoosePlanDialog.prototype, "_plans", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_3__.Org)
], ChoosePlanDialog.prototype, "_org", void 0);
ChoosePlanDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.element)("pl-choose-plan-dialog")
], ChoosePlanDialog);



/***/ }),

/***/ "../app/src/elements/clipboard.ts":
/*!****************************************!*\
  !*** ../app/src/elements/clipboard.ts ***!
  \****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Clipboard": () => (/* binding */ Clipboard)
/* harmony export */ });
/* harmony import */ var lit_html_directives_style_map__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/style-map */ "../app/node_modules/lit-html/directives/style-map.js");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





let Clipboard = class Clipboard extends _base__WEBPACK_IMPORTED_MODULE_3__.BaseElement {
    constructor() {
        super(...arguments);
        this.item = null;
        this.field = null;
        this._tMinusClear = 0;
        this._resolve = null;
    }
    shouldUpdate() {
        return !!this.item && !!this.field;
    }
    render() {
        const { item, field, _tMinusClear } = this;
        return _base__WEBPACK_IMPORTED_MODULE_3__.html `
            <div class="inner">
            <pl-icon icon="clipboard"></pl-icon>

            <div class="name">${item.name} / ${field.name}</div>

            <button class="clear-button tap" @click=${() => this.clear()}>
                <svg class="countdown" viewBox="0 0 10 10">
                    <defs>
                        <filter id="shadow">
                            <feOffset dx="-0.3" in="SourceAlpha" result="shadowOffsetOuter1"/>
                            <feColorMatrix values="0 0 0 0 0   0 0 0 0 0   0 0 0 0 0  0 0 0 0.2 0" in="shadowOffsetOuter1"/>
                        </filter>
                    </defs>

                    <circle
                        filter="url(#shadow)"
                        cx="5"
                        cy="5"
                        r="4"
                        style=${(0,lit_html_directives_style_map__WEBPACK_IMPORTED_MODULE_0__.styleMap)({ strokeDashoffset: ((1 - (_tMinusClear / 60)) * 25).toString() })}
                    />

                    <circle
                        cx="5"
                        cy="5"
                        r="4"
                        style=${(0,lit_html_directives_style_map__WEBPACK_IMPORTED_MODULE_0__.styleMap)({ strokeDashoffset: ((1 - (_tMinusClear / 60)) * 25).toString() })}
                    />
                </svg>

                <div>
                    ${_tMinusClear}s
                </div>
            </button>
            </div>
        `;
    }
    async set(item, field, duration = 60) {
        clearInterval(this._interval);
        this.item = item;
        this.field = field;
        const value = await field.transform();
        (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.setClipboard)(value);
        const tStart = Date.now();
        this._tMinusClear = duration;
        this._interval = window.setInterval(() => {
            const dt = tStart + duration * 1000 - Date.now();
            if (dt <= 0) {
                this.clear();
            }
            else {
                this._tMinusClear = Math.floor(dt / 1000);
            }
        }, 1000);
        setTimeout(() => this.classList.add("showing"), 10);
        return new Promise(resolve => {
            this._resolve = resolve;
        });
    }
    clear() {
        clearInterval(this._interval);
        (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.setClipboard)(" ");
        this.classList.remove("showing");
        this._resolve && this._resolve();
        this._resolve = null;
    }
};
Clipboard.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_2__.shared,
    _base__WEBPACK_IMPORTED_MODULE_3__.css `
            :host {
                display: flex;
                justify-content: center;
                transition: transform 0.5s cubic-bezier(1, -0.3, 0, 1.3);
                position: fixed;
                left: 70px;
                right: 70px;
                bottom: 15px;
                z-index: 100;
                pointer-events: none;
            }

            .inner {
                display: flex;
                align-items: center;
                border-radius: var(--border-radius);
                color: var(--color-background);
                text-shadow: rgba(0, 0, 0, 0.2) 0 1px 0;
                max-width: 100%;
                box-shadow: rgba(0, 0, 0, 0.3) 0 1px 2px;
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.gradientHighlight(true)}
                pointer-events: auto;
            }

            pl-icon {
                flex: none;
            }

            :host(:not(.showing)) {
                transform: translateY(150%);
            }

            .content {
                flex: 1;
                padding: 15px;
            }

            .name {
                font-weight: bold;
                flex-grow: 1;
                font-size: var(--font-size-tiny);
                line-height: 15px;
                margin: 4px 4px 4px 0;
                text-align: center;
            }

            .clear-button {
                padding: 0;
                width: 36px;
                height: 36px;
                margin: 4px;
                line-height: normal;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                border-radius: 100%;
                font-size: 10px;
                flex: none;
                background: transparent;
                position: relative;
                font-weight: bold;
            }

            .countdown {
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.fullbleed()}
                width: 32px;
                height: 32px;
                margin: auto;
                border-radius: 100%;
            }

            .countdown circle {
                transform-origin: center center;
                transform: rotate(-90deg);
                fill: none;
                stroke: currentColor;
                stroke-width: 0.8;
                stroke-dasharray: 25;
                stroke-linecap: round;
                transition: stroke-dashoffset 1s linear;
            }

            @supports (-webkit-overflow-scrolling: touch) {
                :host {
                    left: 80px;
                    right: 80px;
                    bottom: calc(env(safe-area-inset-bottom) / 1.5);
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Object)
], Clipboard.prototype, "item", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Object)
], Clipboard.prototype, "field", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Number)
], Clipboard.prototype, "_tMinusClear", void 0);
Clipboard = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.element)("pl-clipboard")
], Clipboard);



/***/ }),

/***/ "../app/src/elements/create-invites-dialog.ts":
/*!****************************************************!*\
  !*** ../app/src/elements/create-invites-dialog.ts ***!
  \****************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "CreateInvitesDialog": () => (/* binding */ CreateInvitesDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};







let CreateInvitesDialog = class CreateInvitesDialog extends _dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog {
    constructor() {
        super(...arguments);
        this._emails = [];
        this._error = "";
        this._maxEmails = 50;
    }
    _isValid(email) {
        return /\S+@\S+\.\S+/.test(email);
    }
    _input() {
        const emails = this._emailInput.value.split(/[,;\s]+/);
        this._emails = [...new Set([...this._emails, ...emails.slice(0, -1).filter(e => !!e)])];
        this._emailInput.value = emails[emails.length - 1];
        this.requestUpdate();
    }
    _enter() {
        const emails = this._emailInput.value.split(/[,;\s]+/);
        this._emails = [...new Set([...this._emails, ...emails.filter(e => !!e)])];
        this._emailInput.value = "";
        this.requestUpdate();
    }
    _keydown(e) {
        if (e.key === "Backspace" && !this._emailInput.value) {
            this._emails.pop();
            this.requestUpdate();
        }
    }
    _remove(email) {
        this._emails = this._emails.filter(e => e !== email);
    }
    async _submit() {
        if (this._submitButton.state === "loading") {
            return;
        }
        if (!this._emails.length) {
            this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter at least one email address!");
            this.rumble();
            return;
        }
        if (this._emails.length > this._maxEmails) {
            this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You have entered too many email addresses! Please delete some before submitting!");
            this.rumble();
            return;
        }
        if (this._emails.some(email => !this._isValid(email))) {
            this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Some of the emails you entered appear to be invalid!");
            this.rumble();
            return;
        }
        this._error = "";
        this._submitButton.start();
        try {
            const invites = await _globals__WEBPACK_IMPORTED_MODULE_1__.app.createInvites(this._org, this._emails);
            this._submitButton.success();
            this.done(invites);
        }
        catch (e) {
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong! Please try again later!");
            this._submitButton.fail();
            this.rumble();
        }
    }
    async show(org) {
        this._org = org;
        this._emails = [];
        this._error = "";
        return super.show();
    }
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <header>
                <div class="title flex">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Invite New Members")}</div>
            </header>

            <div class="content">
                <div class="message">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter up to {0} email addresses of the persons you would like to invite, separated by spaces or commas!", this._maxEmails.toString())}
                </div>

                <div class="tags item" @click=${() => this._emailInput.focus()}>
                    ${this._emails.map(email => _base__WEBPACK_IMPORTED_MODULE_2__.html `
                            <div class="tag ${this._isValid(email) ? "" : "warning"}">
                                <div>${email}</div>
                                <pl-icon icon="cancel" class="tap" @click=${() => this._remove(email)}></pl-icon>
                            </div>
                        `)}

                    <pl-input
                        .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Email Address")}
                        type="email"
                        @enter=${this._enter}
                        @input=${this._input}
                        @blur=${this._enter}
                        @keydown=${this._keydown}
                    ></pl-input>

                    <div class="email-count" ?warning=${this._emails.length > this._maxEmails}>
                        ${this._emails.length}/${this._maxEmails}
                    </div>
                </div>

                <div class="item error" ?hidden=${!this._error}>${this._error}</div>
            </div>

            <div class="footer">
                <div class="actions">
                    <pl-loading-button id="submitButton" @click=${this._submit} class="primary tap">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Submit")}
                    </pl-loading-button>
                    <button @click=${this.dismiss} class="transparent tap">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel")}
                    </button>
                </div>
            </div>
        `;
    }
};
CreateInvitesDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_2__.css `
            :host {
                text-align: center;
            }

            .inner {
                background: var(--color-quaternary);
            }

            .message {
                font-size: var(--font-size-small);
                margin: 8px 20px;
            }

            .tags {
                flex-wrap: wrap;
                margin: 8px;
                padding: 12px 12px 6px 12px;
                justify-content: center;
                position: relative;
            }

            .tags > * {
                margin-bottom: 6px;
            }

            .tag > pl-icon {
                font-size: var(--font-size-micro);
                margin: 0 -3px 0 0;
            }

            pl-input {
                text-align: left;
                background: transparent;
                font-size: var(--font-size-small);
                padding: 4px 8px;
            }

            .email-count {
                font-weight: bold;
                position: absolute;
                bottom: 8px;
                right: 8px;
                margin: 0;
                font-size: var(--font-size-tiny);
            }

            .email-count[warning] {
                color: var(--color-negative);
            }

            .error.item {
                padding: 8px;
                color: var(--color-negative);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Array)
], CreateInvitesDialog.prototype, "_emails", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", String)
], CreateInvitesDialog.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.query)("pl-input"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_3__.Input)
], CreateInvitesDialog.prototype, "_emailInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.query)("#submitButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_5__.LoadingButton)
], CreateInvitesDialog.prototype, "_submitButton", void 0);
CreateInvitesDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.element)("pl-create-invites-dialog")
], CreateInvitesDialog);



/***/ }),

/***/ "../app/src/elements/create-item-dialog.ts":
/*!*************************************************!*\
  !*** ../app/src/elements/create-item-dialog.ts ***!
  \*************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "CreateItemDialog": () => (/* binding */ CreateItemDialog)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/item */ "../core/src/item.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _select__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./select */ "../app/src/elements/select.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};







let CreateItemDialog = class CreateItemDialog extends _dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog {
    constructor() {
        super(...arguments);
        this._template = _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__.ITEM_TEMPLATES[0];
        this.preventDismiss = true;
    }
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <header>
                <div class="title flex">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("New Vault Item")}</div>
            </header>

            <div class="content">
                <pl-select
                    id="vaultSelect"
                    class="vault-select tap item"
                    icon="vault"
                    .options=${_globals__WEBPACK_IMPORTED_MODULE_2__.app.vaults.filter(v => _globals__WEBPACK_IMPORTED_MODULE_2__.app.hasWritePermissions(v))}
                ></pl-select>

                <div class="message">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("What kind of item you would like to add?")}
                </div>

                <div class="templates">
                    ${_padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__.ITEM_TEMPLATES.map(template => _base__WEBPACK_IMPORTED_MODULE_4__.html `
                            <div
                                class="item template tap"
                                @click=${() => (this._template = template)}
                                ?active=${this._template === template}
                            >
                                <pl-icon icon=${template.icon} class="icon"></pl-icon>
                                <div>${template.toString()}</div>
                            </div>
                        `)}
                </div>
            </div>

            <div class="footer">
                <div class="actions">
                    <button @click=${() => this._enter()} class="primary tap">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Create")}</button>

                    <button @click=${() => this.done()} class="transparent tap">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel")}</button>
                </div>
            </div>
        `;
    }
    async _enter() {
        const vault = this._vaultSelect.selected;
        const quota = _globals__WEBPACK_IMPORTED_MODULE_2__.app.getItemsQuota(vault);
        if (quota !== -1 && vault.items.size >= quota) {
            this.done();
            if (_globals__WEBPACK_IMPORTED_MODULE_2__.app.billingEnabled) {
                this.dispatch("get-premium", {
                    message: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("You have reached the maximum number of items for this account. " +
                        "Upgrade to Premium to get unlimited items for your private vault!"),
                    icon: "list"
                });
            }
            else {
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("You have reached the maximum number of items for this account!"), { type: "warning" });
            }
            return;
        }
        const item = await _globals__WEBPACK_IMPORTED_MODULE_2__.app.createItem("", vault, this._template.fields.map(f => new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__.Field({ ...f, value: "" })));
        this.done(item);
        const params = { ..._globals__WEBPACK_IMPORTED_MODULE_2__.router.params, edit: "true", newitem: "true" };
        if (this._template.attachment) {
            params.addattachment = "true";
        }
        _globals__WEBPACK_IMPORTED_MODULE_2__.router.go(`items/${item.id}`, params);
    }
    async show(vault = _globals__WEBPACK_IMPORTED_MODULE_2__.app.mainVault) {
        await this.updateComplete;
        this._vaultSelect.selected = vault;
        return super.show();
    }
};
CreateItemDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            .inner {
                background: var(--color-quaternary);
                max-width: 500px;
            }

            pl-input,
            pl-select {
                text-align: center;
            }

            .templates {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
                grid-gap: 8px;
                margin: var(--gutter-size);
            }

            .template {
                padding: 4px;
                display: flex;
                align-items: center;
                margin: 0;
                font-weight: 600;
            }

            .vault-select,
            .template[active] {
                background: var(--color-primary);
                color: var(--color-tertiary);
                font-weight: bold;
                text-shadow: rgba(0, 0, 0, 0.15) 0 2px 0;
            }

            .icon {
                margin-right: 4px;
            }

            .message {
                text-align: center;
                margin: 20px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#vaultSelect"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_5__.Select)
], CreateItemDialog.prototype, "_vaultSelect", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], CreateItemDialog.prototype, "_template", void 0);
CreateItemDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-create-item-dialog")
], CreateItemDialog);



/***/ }),

/***/ "../app/src/elements/create-org-dialog.ts":
/*!************************************************!*\
  !*** ../app/src/elements/create-org-dialog.ts ***!
  \************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "CreateOrgDialog": () => (/* binding */ CreateOrgDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _card_input__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./card-input */ "../app/src/elements/card-input.ts");
/* harmony import */ var _billing_dialog__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./billing-dialog */ "../app/src/elements/billing-dialog.ts");
/* harmony import */ var _choose_plan_dialog__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./choose-plan-dialog */ "../app/src/elements/choose-plan-dialog.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











let CreateOrgDialog = class CreateOrgDialog extends _dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog {
    constructor() {
        super(...arguments);
        this.plan = null;
        this.quantity = 1;
        this._updateBillingParams = null;
        this._error = "";
        this._org = null;
    }
    async show(plan) {
        this.plan = plan;
        this.quantity = (plan && plan.min) || 1;
        this._updateBillingParams = null;
        this._org = null;
        this._error = "";
        return super.show();
    }
    async _submit() {
        if (this._submitButton.state === "loading") {
            return;
        }
        const name = this._nameInput.value;
        if (!name) {
            this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter an organization name!");
            return;
        }
        this._error = "";
        this._submitButton.start();
        if (!this._org) {
            try {
                this._org = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.createOrg(name);
            }
            catch (e) {
                this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!");
                this._submitButton.fail();
                return;
            }
        }
        if (this.plan) {
            const params = this._updateBillingParams || new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.UpdateBillingParams();
            params.plan = this.plan.id;
            params.members = this.quantity;
            params.org = this._org.id;
            try {
                await _globals__WEBPACK_IMPORTED_MODULE_3__.app.updateBilling(params);
            }
            catch (e) {
                this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!");
                this._submitButton.fail();
                return;
            }
        }
        const org = (this._org = _globals__WEBPACK_IMPORTED_MODULE_3__.app.getOrg(this._org.id));
        // Create first vault and group
        if (org.quota.groups) {
            const everyone = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.createGroup(org, "Everyone", [org.getMember(_globals__WEBPACK_IMPORTED_MODULE_3__.app.account)]);
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.createVault("Main", org, [], [{ name: everyone.name, readonly: false }]);
        }
        else {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.createVault("Main", org, [{ id: _globals__WEBPACK_IMPORTED_MODULE_3__.app.account.id, readonly: false }]);
        }
        this._submitButton.success();
        this.done(org);
    }
    async _updateQuantity() {
        const quantity = parseInt(this._quantityInput.value);
        const { min, max } = this.plan;
        if (!isNaN(quantity) && quantity >= min && quantity <= max) {
            this.quantity = quantity;
        }
    }
    async _updateBillingInfo() {
        this.open = false;
        const billingInfo = new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.BillingInfo();
        billingInfo.address.name = this._nameInput.value;
        const billing = await this._billingDialog.show({
            billingInfo
        });
        if (billing) {
            this._updateBillingParams = billing;
            this._error = "";
        }
        this.open = true;
    }
    async _changePlan() {
        this.open = false;
        const plan = await this._choosePlanDialog.show();
        if (plan) {
            this.plan = plan;
        }
        this.open = true;
    }
    _renderBilling(plan) {
        const monthlyPrice = Math.round((this.quantity * plan.cost) / 12);
        const paymentMethod = this._updateBillingParams && this._updateBillingParams.paymentMethod;
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <div class="plan item">
                <pl-icon class="tap edit-plan-icon" icon="edit" @click=${this._changePlan}></pl-icon>

                <div class="plan-name">
                    ${plan.name}
                </div>

                <div class="flex"></div>

                <div class="plan-trial">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Free For {0} Days", (30).toString())}
                </div>

                <div class="plan-then">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("then")}
                </div>

                <div class="plan-price">
                    <div class="plan-price-currency">$</div>
                    <div class="plan-price-dollars">
                        ${Math.floor(monthlyPrice / 100)}
                    </div>
                    <div class="plan-price-cents">
                        .${(monthlyPrice % 100).toString().padEnd(2, "0")}
                    </div>
                </div>

                <div class="plan-unit">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("per month")}
                </div>

                <div class="plan-fineprint">
                    (${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("USD, billed annually")})
                </div>

                <div class="flex"></div>
            </div>

            <div class="quantity-wrapper" ?hidden=${plan.max < 2}>
                <div class="quantity-minmax flex">
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} min", plan.min.toString())}</div>
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} max", plan.max.toString())}</div>
                </div>
                <pl-input
                    id="quantityInput"
                    class="quantity-input item"
                    type="number"
                    .value=${this.quantity}
                    .min=${plan.min}
                    .max=${plan.max}
                    @input=${this._updateQuantity}
                    @blur=${() => (this._quantityInput.value = this.quantity.toString())}
                ></pl-input>
                <div class="quantity-label flex">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Seats")}
                </div>
            </div>

            <div class="payment-method item tap" @click=${this._updateBillingInfo}>
                <pl-icon icon="credit"></pl-icon>
                ${paymentMethod
            ? _base__WEBPACK_IMPORTED_MODULE_4__.html `
                          <div>
                              ${paymentMethod.name}
                          </div>
                      `
            : _base__WEBPACK_IMPORTED_MODULE_4__.html `
                          <div>
                              ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Add Billing Info")}
                          </div>
                      `}
            </div>
        `;
    }
    renderContent() {
        const plan = this.plan;
        const color = (plan && plan.color) || "var(--color-primary)";
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <header>
                <pl-icon></pl-icon>
                <div class="title flex">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Create Organization")}</div>
                <pl-icon icon="cancel" class="tap" @click=${this.dismiss}></pl-icon>
            </header>

            <div class="content" style=${`--color-highlight: ${color}; --color-highlight-text: var(--color-tertiary);`}>
                <pl-input
                    id="nameInput"
                    class="item"
                    .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Organization Name")}
                    .value=${(this._org && this._org.name) || ""}
                ></pl-input>

                ${plan ? this._renderBilling(plan) : _base__WEBPACK_IMPORTED_MODULE_4__.html ``}

                <div class="error item" ?hidden="${!this._error}">
                    ${this._error}
                </div>

                <pl-loading-button id="submitButton" class="tap primary" @click=${this._submit}>
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Create")}
                </pl-loading-button>
            </div>
        `;
    }
};
CreateOrgDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            .inner {
                background: var(--color-quaternary);
                text-align: center;
            }

            .plan {
                text-align: center;
                padding: 20px;
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                display: flex;
                flex-direction: column;
                position: relative;
            }

            .plan-name {
                font-size: 1.7rem;
                margin-bottom: 8px;
                font-weight: bold;
            }

            .plan-trial {
                font-size: 1.2rem;
                margin-bottom: 8px;
            }

            .plan-then {
                font-size: var(--font-size-tiny);
                margin-bottom: 8px;
            }

            .plan-price {
                letter-spacing: 0.1em;
                display: flex;
                align-items: flex-start;
                justify-content: center;
                font-weight: bold;
                font-size: 1rem;
                margin: 5px;
            }

            .plan-price-currency {
                line-height: 1em;
                margin-top: 0.4em;
            }

            .plan-price-dollars {
                font-size: 3em;
                line-height: 1em;
            }

            .plan-price-cents {
                font-size: 1.5em;
                line-height: 1em;
                margin-top: 0.2em;
            }

            .plan-unit {
                font-size: var(--font-size-small);
            }

            .plan-fineprint {
                font-size: var(--font-size-tiny);
                opacity: 0.7;
                margin: 4px 0 -4px 0;
            }

            pl-loading-button {
                font-weight: bold;
            }

            pl-loading-button.primary {
                margin: 8px;
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                font-weight: bold;
                border-bottom: solid 3px var(--color-shade-2);
            }

            .error {
                color: var(--color-negative);
                padding: 8px;
                text-align: center;
            }

            .payment-method {
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 4px;
                font-weight: bold;
            }

            .quantity-wrapper {
                display: flex;
                align-items: center;
                justify-content: center;
                margin: 8px;
            }

            .quantity-label {
                font-weight: bold;
                padding: 12px;
                font-size: 1.2em;
                text-align: left;
            }

            .quantity-input {
                width: 60px;
                margin: 0;
                font-weight: bold;
                font-size: 1.5rem;
            }

            .quantity-minmax {
                font-size: var(--font-size-micro);
                opacity: 0.5;
                text-align: right;
                padding: 12px;
            }

            .edit-plan-icon {
                position: absolute;
                top: 8px;
                right: 8px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], CreateOrgDialog.prototype, "plan", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Number)
], CreateOrgDialog.prototype, "quantity", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], CreateOrgDialog.prototype, "_updateBillingParams", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], CreateOrgDialog.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], CreateOrgDialog.prototype, "_org", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#nameInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_10__.Input)
], CreateOrgDialog.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#quantityInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_10__.Input)
], CreateOrgDialog.prototype, "_quantityInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#submitButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_6__.LoadingButton)
], CreateOrgDialog.prototype, "_submitButton", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.dialog)("pl-billing-dialog"),
    __metadata("design:type", _billing_dialog__WEBPACK_IMPORTED_MODULE_8__.BillingDialog)
], CreateOrgDialog.prototype, "_billingDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.dialog)("pl-choose-plan-dialog"),
    __metadata("design:type", _choose_plan_dialog__WEBPACK_IMPORTED_MODULE_9__.ChoosePlanDialog)
], CreateOrgDialog.prototype, "_choosePlanDialog", void 0);
CreateOrgDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-create-org-dialog")
], CreateOrgDialog);



/***/ }),

/***/ "../app/src/elements/dialog.ts":
/*!*************************************!*\
  !*** ../app/src/elements/dialog.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Dialog": () => (/* binding */ Dialog)
/* harmony export */ });
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../lib/animation */ "../app/src/lib/animation.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var Dialog_1;




let Dialog = Dialog_1 = class Dialog extends _base__WEBPACK_IMPORTED_MODULE_2__.BaseElement {
    constructor() {
        super(...arguments);
        this.open = false;
        this.preventDismiss = false;
        this.preventAutoClose = false;
        this.dismissOnTapOutside = true;
        this.hideApp = false;
        this.isShowing = false;
    }
    static closeAll() {
        for (const dialog of Dialog_1.openDialogs) {
            if (!dialog.preventAutoClose) {
                dialog.done();
            }
        }
    }
    done(result) {
        this._resolve && this._resolve(result);
        this._resolve = null;
        this.open = false;
        Dialog_1.openDialogs.delete(this);
    }
    async show(_input = undefined) {
        Dialog_1.openDialogs.add(this);
        this.open = true;
        return new Promise(resolve => {
            this._resolve = resolve;
        });
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <div class="scrim"></div>

            <div class="outer" @click=${this._tappedOutside}>
                ${this.renderBefore()}
                <div id="inner" class="inner" @click=${(e) => e.stopPropagation()}>
                    ${this.renderContent()}
                </div>
                ${this.renderAfter()}
            </div>
        `;
    }
    renderBefore() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <slot name="before"></slot>
        `;
    }
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <slot></slot>
        `;
    }
    renderAfter() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <slot name="after"></slot>
        `;
    }
    _back(e) {
        if (this.open) {
            this.dismiss();
            e.preventDefault();
            e.stopPropagation();
        }
    }
    rumble() {
        (0,_lib_animation__WEBPACK_IMPORTED_MODULE_1__.animateElement)(this.$("#inner"), { animation: "rumble", duration: 200, clear: true });
    }
    _openChanged() {
        clearTimeout(this._hideTimeout);
        // Set _display: block_ if we're showing. If we're hiding
        // we need to wait until the transitions have finished before we
        // set _display: none_.
        if (this.open) {
            if (_input__WEBPACK_IMPORTED_MODULE_3__.Input.activeInput) {
                _input__WEBPACK_IMPORTED_MODULE_3__.Input.activeInput.blur();
            }
            this.style.display = "";
            this.offsetLeft;
            this.isShowing = true;
            this.setAttribute("open", "");
        }
        else {
            this.removeAttribute("open");
            this._hideTimeout = window.setTimeout(() => {
                this.style.display = "none";
                this.isShowing = false;
            }, 400);
        }
        this.dispatch(this.open ? "dialog-open" : "dialog-close", { dialog: this }, true, true);
    }
    _tappedOutside() {
        if (this.dismissOnTapOutside) {
            this.dismiss();
        }
    }
    dismiss() {
        if (!this.preventDismiss) {
            this.dispatch("dialog-dismiss");
            this.done();
        }
    }
};
Dialog.openDialogs = new Set();
Dialog.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_0__.shared,
    _base__WEBPACK_IMPORTED_MODULE_2__.css `
            :host {
                display: block;
                ${_styles__WEBPACK_IMPORTED_MODULE_0__.mixins.fullbleed()}
                z-index: 10;
            }

            :host(:not([open])) {
                pointer-events: none;
            }

            .outer {
                height: 100%;
                display: flex;
                position: relative;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                padding: 12px;
                box-sizing: border-box;
                transition: transform 400ms cubic-bezier(0.08, 0.85, 0.3, 1.15) 0s,
                    opacity 200ms cubic-bezier(0.6, 0, 0.2, 1) 0s;
            }

            .scrim {
                display: block;
                background: #000000;
                opacity: 0;
                transition: opacity 400ms cubic-bezier(0.6, 0, 0.2, 1);
                ${_styles__WEBPACK_IMPORTED_MODULE_0__.mixins.fullbleed()}
                position: fixed;
            }

            :host([open]) .scrim {
                opacity: 0.8;
            }

            .inner {
                position: relative;
                width: 100%;
                max-height: 100%;
                box-sizing: border-box;
                max-width: var(--pl-dialog-max-width, 400px);
                z-index: 1;
                border-radius: var(--border-radius);
                box-shadow: rgba(0, 0, 0, 0.25) 0 0 5px;
                overflow: hidden;
                background: var(--color-tertiary);
                display: flex;
                flex-direction: column;
            }

            .content {
                flex: 1;
                ${_styles__WEBPACK_IMPORTED_MODULE_0__.mixins.scroll()}
            }

            .footer {
                background: var(--color-tertiary);
                margin: 0;
                border-top: solid 1px var(--color-shade-1);
            }

            .actions {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
                grid-gap: var(--gutter-size);
                margin: var(--gutter-size);
            }

            .actions.vertical {
                grid-template-columns: 1fr;
            }

            :host(:not([open])) .outer {
                opacity: 0;
                transform: scale(0.8);
                transition: transform 200ms cubic-bezier(0.6, 0, 0.2, 1), opacity 200ms cubic-bezier(0.6, 0, 0.2, 1);
            }

            @supports (-webkit-overflow-scrolling: touch) {
                .outer {
                    padding-top: max(env(safe-area-inset-top), 12px);
                    padding-bottom: max(env(safe-area-inset-bottom), 12px);
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Boolean)
], Dialog.prototype, "open", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Boolean)
], Dialog.prototype, "preventDismiss", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Boolean)
], Dialog.prototype, "preventAutoClose", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Boolean)
], Dialog.prototype, "dismissOnTapOutside", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.listen)("backbutton", window),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Event]),
    __metadata("design:returntype", void 0)
], Dialog.prototype, "_back", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.observe)("open"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], Dialog.prototype, "_openChanged", null);
Dialog = Dialog_1 = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.element)("pl-dialog")
], Dialog);



/***/ }),

/***/ "../app/src/elements/export-dialog.ts":
/*!********************************************!*\
  !*** ../app/src/elements/export-dialog.ts ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ExportDialog": () => (/* binding */ ExportDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/encoding */ "../core/src/encoding.ts");
/* harmony import */ var _lib_import__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/import */ "../app/src/lib/import.ts");
/* harmony import */ var _lib_export__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/export */ "../app/src/lib/export.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _select__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./select */ "../app/src/elements/select.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};










let ExportDialog = class ExportDialog extends _dialog__WEBPACK_IMPORTED_MODULE_9__.Dialog {
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_7__.html `
            <h1>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Export Data")}</h1>

            <pl-select
                id="vaultSelect"
                .options=${_globals__WEBPACK_IMPORTED_MODULE_5__.app.vaults}
                .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Target Vault")}
                @change=${() => this.requestUpdate()}
            >
            </pl-select>

            <pl-select
                id="formatSelect"
                .options=${_lib_export__WEBPACK_IMPORTED_MODULE_4__.supportedFormats}
                .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Format")}
                @change=${() => this.requestUpdate()}
            ></pl-select>

            <div class="csv-note" ?hidden=${this._formatSelect && this._formatSelect.selected !== _lib_import__WEBPACK_IMPORTED_MODULE_3__.CSV}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("WARNING: Exporting to CSV format will save your data without encyryption of any " +
            "kind which means it can be read by anyone. We strongly recommend exporting your data as " +
            "a secure, encrypted file, instead!")}
            </div>

            <button @click=${() => this._export()} class="tap primary">
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Export {0} Items", this._vaultSelect && this._vaultSelect.selected.items.size.toString())}
            </button>
        `;
    }
    async show() {
        await this.updateComplete;
        this._formatSelect.selected = _lib_import__WEBPACK_IMPORTED_MODULE_3__.PBES2;
        this._vaultSelect.selected = _globals__WEBPACK_IMPORTED_MODULE_5__.app.mainVault;
        return super.show();
    }
    async _export() {
        const vault = this._vaultSelect.selected;
        const items = [...vault.items];
        const date = new Date().toISOString().substr(0, 10);
        let data = "";
        let fileName = "";
        let type = "text/plain";
        switch (this._formatSelect.selected.format) {
            case _lib_import__WEBPACK_IMPORTED_MODULE_3__.CSV.format:
                data = await (0,_lib_export__WEBPACK_IMPORTED_MODULE_4__.asCSV)(items);
                fileName = `${vault.name.replace(/ /g, "_")}_${date}.csv`;
                type = "text/csv";
                break;
            case _lib_import__WEBPACK_IMPORTED_MODULE_3__.PBES2.format:
                this.open = false;
                const password = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please choose a password to protect this backup with!"), {
                    title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose Password"),
                    type: "password",
                    placeholder: "Enter Password",
                    validate: async (val) => {
                        if (!val) {
                            throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please choose a password!");
                        }
                        return val;
                    }
                });
                if (!password) {
                    this.open = true;
                    return;
                }
                const repeated = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please repeat the password!"), {
                    title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose Password"),
                    type: "password",
                    placeholder: "Repeat Password",
                    validate: async (val) => {
                        if (val !== password) {
                            throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Password not repeated correctly!");
                        }
                        return val;
                    }
                });
                if (!repeated) {
                    this.open = true;
                    return;
                }
                data = await (0,_lib_export__WEBPACK_IMPORTED_MODULE_4__.asPBES2Container)(items, password);
                fileName = `${vault.name.replace(/ /g, "_")}_${date}.pbes2`;
                break;
            default:
                return;
        }
        (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.saveFile)(fileName, type, (0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_2__.stringToBytes)(data));
        this.done();
    }
};
ExportDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_9__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_7__.css `
            .inner {
                display: flex;
                flex-direction: column;
            }

            pl-input,
            pl-select,
            button {
                text-align: center;
                margin: 0 10px 10px 10px;
                background: var(--shade-2-color);
                border-radius: 8px;
            }

            h1 {
                display: block;
                text-align: center;
            }

            .csv-note {
                font-size: var(--font-size-micro);
                text-align: center;
                padding: 0px 20px 20px 20px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#formatSelect"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_8__.Select)
], ExportDialog.prototype, "_formatSelect", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#vaultSelect"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_8__.Select)
], ExportDialog.prototype, "_vaultSelect", void 0);
ExportDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.element)("pl-export-dialog")
], ExportDialog);



/***/ }),

/***/ "../app/src/elements/field-type-dialog.ts":
/*!************************************************!*\
  !*** ../app/src/elements/field-type-dialog.ts ***!
  \************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "FieldTypeDialog": () => (/* binding */ FieldTypeDialog)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/item */ "../core/src/item.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};




let FieldTypeDialog = class FieldTypeDialog extends _dialog__WEBPACK_IMPORTED_MODULE_3__.Dialog {
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <header>
                <pl-icon></pl-icon>
                <div class="title flex">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Choose A Field Type")}</div>
                <pl-icon icon="cancel" class="tap" @click=${this.dismiss}></pl-icon>
            </header>

            <div class="content">
                <div class="message">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("What kind of field you would like to add?")}
                </div>
                <div class="field-defs">
                    ${[...Object.values(_padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__.FIELD_DEFS)].map(fieldDef => _base__WEBPACK_IMPORTED_MODULE_2__.html `
                            <div class="item field-def tap" @click=${() => this.done(fieldDef)}>
                                <pl-icon icon=${fieldDef.icon} class="icon"></pl-icon>
                                <div>${fieldDef.name}</div>
                            </div>
                        `)}
                </div>
            </div>
        `;
    }
};
FieldTypeDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_3__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_2__.css `
            .inner {
                background: var(--color-quaternary);
                max-width: 440px;
            }

            .field-defs {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
                grid-gap: 8px;
                margin: 8px;
            }

            .field-def {
                padding: 8px;
                display: flex;
                align-items: center;
                margin: 0;
                font-weight: 600;
            }

            .icon {
                margin-right: 4px;
            }

            .message {
                text-align: center;
                margin: 20px;
            }
        `
];
FieldTypeDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.element)("pl-field-type-dialog")
], FieldTypeDialog);



/***/ }),

/***/ "../app/src/elements/field.ts":
/*!************************************!*\
  !*** ../app/src/elements/field.ts ***!
  \************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "FieldElement": () => (/* binding */ FieldElement)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/item */ "../core/src/item.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _textarea__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./textarea */ "../app/src/elements/textarea.ts");
/* harmony import */ var _totp__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./totp */ "../app/src/elements/totp.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};









let FieldElement = class FieldElement extends _base__WEBPACK_IMPORTED_MODULE_3__.BaseElement {
    constructor() {
        super(...arguments);
        this.editing = false;
        this.name = "";
        this.value = "";
        this.type = _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__.FieldType.Note;
        this._masked = false;
    }
    get _fieldDef() {
        return _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__.FIELD_DEFS[this.type] || _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_0__.FIELD_DEFS.text;
    }
    get _fieldActions() {
        const actions = [{ icon: "copy", action: () => this.dispatch("copy-clipboard") }];
        if (this._fieldDef.mask) {
            actions.push({ icon: this._masked ? "show" : "hide", action: () => (this._masked = !this._masked) });
        }
        return actions;
    }
    focus() {
        const inputToFocus = this._nameInput.value ? this._valueInput : this._nameInput;
        inputToFocus.focus();
    }
    _typeChanged() {
        this._masked = this._fieldDef.mask;
    }
    _editingChanged() {
        if (!this.editing) {
            this.setAttribute("draggable", "true");
        }
        else {
            this.removeAttribute("draggable");
        }
    }
    _renderDisplayValue() {
        const format = this._fieldDef.format || ((value, _masked) => value);
        switch (this.type) {
            case "totp":
                return _base__WEBPACK_IMPORTED_MODULE_3__.html `
                    <pl-totp class="value-display" .secret=${this.value} .time=${Date.now()}></pl-totp>
                `;
            default:
                return _base__WEBPACK_IMPORTED_MODULE_3__.html `
                    <pre class="value-display">${format(this.value, this._masked)}</pre>
                `;
        }
    }
    _renderEditValue() {
        switch (this.type) {
            case "note":
                return _base__WEBPACK_IMPORTED_MODULE_3__.html `
                    <pl-textarea
                        class="value-input"
                        .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Enter Notes Here")}
                        @input=${() => (this.value = this._valueInput.value)}
                        autosize
                        .value=${this.value}
                    >
                    </pl-textarea>
                `;
            case "totp":
                return _base__WEBPACK_IMPORTED_MODULE_3__.html `
                    <pl-input
                        class="value-input"
                        .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Enter Secret")}
                        type="text"
                        @input=${() => (this.value = this._valueInput.value)}
                        .value=${this.value}
                    >
                    </pl-input>
                    <pl-icon icon="qrcode" class="tap" @click=${() => this.dispatch("get-totp-qr")}></pl-icon>
                `;
            case "password":
                return _base__WEBPACK_IMPORTED_MODULE_3__.html `
                    <pl-input
                        class="value-input"
                        .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Enter Password")}
                        type="text"
                        @input=${() => (this.value = this._valueInput.value)}
                        .value=${this.value}
                    >
                    </pl-input>
                    <pl-icon icon="generate" class="tap" @click=${() => this.dispatch("generate")}></pl-icon>
                `;
            default:
                let inputType;
                switch (this.type) {
                    case "email":
                    case "url":
                    case "date":
                    case "month":
                        inputType = this.type;
                        break;
                    case "pin":
                    case "credit":
                        inputType = "number";
                        break;
                    case "phone":
                        inputType = "tel";
                        break;
                    default:
                        inputType = "text";
                }
                return _base__WEBPACK_IMPORTED_MODULE_3__.html `
                    <pl-input
                        class="value-input"
                        .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Enter Value Here")}
                        .type=${inputType}
                        .pattern=${this._fieldDef.pattern}
                        @input=${() => (this.value = this._valueInput.value)}
                        .value=${this.value}
                    >
                    </pl-input>
                `;
        }
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_3__.html `
            <div class="field-buttons left" ?hidden=${!this.editing}>
                <pl-icon
                    icon="menu"
                    class="drag-handle"
                    @mouseover=${() => this.setAttribute("draggable", "true")}
                    @mouseout=${() => this.removeAttribute("draggable")}
                >
                </pl-icon>

                <pl-icon icon="remove" class="tap" @click=${() => this.dispatch("remove")}> </pl-icon>
            </div>

            <div class="fields-container flex">
                <div class="field-header">
                    <pl-icon icon="${this._fieldDef.icon}"></pl-icon>

                    <pl-input
                        class="name-input"
                        placeholder="${this.editing ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Enter Field Name") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Unnamed")}"
                        .value=${this.name}
                        @input=${() => (this.name = this._nameInput.value)}
                        ?readonly=${!this.editing}
                    >
                    </pl-input>
                </div>

                <div class="field-value">
                    ${this.editing ? this._renderEditValue() : this._renderDisplayValue()}
                </div>
            </div>

            <div class="field-buttons right" ?hidden=${this.editing}>
                ${this._fieldActions.map(({ icon, action }) => _base__WEBPACK_IMPORTED_MODULE_3__.html `
                        <pl-icon icon=${icon} class="tap" @click=${action}></pl-icon>
                    `)}
            </div>
        `;
    }
};
FieldElement.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_2__.shared,
    _base__WEBPACK_IMPORTED_MODULE_3__.css `
            :host {
                display: flex;
                border-radius: 8px;
                min-height: 80px;
                opacity: 0.999;
            }

            .field-buttons {
                display: flex;
                flex-direction: column;
                margin: 4px;
            }

            .field-buttons.right {
                margin-left: -4px;
            }

            .field-buttons.left {
                margin-right: -4px;
            }

            :host(:not(:hover)) .field-buttons.right {
                visibility: hidden;
            }

            .field-header {
                display: flex;
                margin-bottom: 4px;
                font-size: var(--font-size-tiny);
                font-weight: bold;
                color: var(--color-highlight);
                align-items: center;
                position: relative;
            }

            .field-header pl-icon {
                border-radius: 0;
                font-size: 10px;
                width: 10px;
                height: 11px;
                position: absolute;
                left: 8px;
                top: 8px;
            }

            .field-value {
                display: flex;
            }

            .field-value > :not(:first-child) {
                margin-left: 4px;
            }

            .value-input,
            .value-display {
                font-family: var(--font-family-mono);
                font-size: 110%;
                padding: 4px 8px;
                line-height: 1.4em;
                flex: 1;
                width: 0;
            }

            .value-display {
                white-space: pre-wrap;
                overflow-wrap: break-word;
                user-select: text;
                cursor: text;
            }

            .fields-container {
                margin: 8px;
                width: 0;
            }

            .name-input {
                flex: 1;
                min-width: 0;
                padding: 0 10px 0 24px;
                line-height: 30px;
            }

            .name-input,
            .value-input {
                height: auto;
                box-sizing: border-box;
                background: none;
            }

            .value-input {
                border: dashed 1px var(--color-shade-2);
            }

            .name-input[readonly] {
                border: none;
            }

            :host([draggable]),
            :host([draggable]) .name-input {
                cursor: grab;
            }

            :host([draggable]):active {
                cursor: grabbing;
            }

            @supports (-webkit-overflow-scrolling: touch) {
                .field-header pl-icon {
                    top: 11px;
                }

                .drag-handle {
                    display: none;
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Boolean)
], FieldElement.prototype, "editing", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", String)
], FieldElement.prototype, "name", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", String)
], FieldElement.prototype, "value", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", String)
], FieldElement.prototype, "type", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Boolean)
], FieldElement.prototype, "_masked", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)(".name-input"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_5__.Input)
], FieldElement.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)(".value-input"),
    __metadata("design:type", Object)
], FieldElement.prototype, "_valueInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.observe)("type"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], FieldElement.prototype, "_typeChanged", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.observe)("editing"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], FieldElement.prototype, "_editingChanged", null);
FieldElement = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.element)("pl-field")
], FieldElement);



/***/ }),

/***/ "../app/src/elements/generator.ts":
/*!****************************************!*\
  !*** ../app/src/elements/generator.ts ***!
  \****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Generator": () => (/* binding */ Generator)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/util */ "../core/src/util.ts");
/* harmony import */ var _padloc_core_src_diceware__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/diceware */ "../core/src/diceware.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _lib_animation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/animation */ "../app/src/lib/animation.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./slider */ "../app/src/elements/slider.ts");
/* harmony import */ var _toggle_button__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./toggle-button */ "../app/src/elements/toggle-button.ts");
/* harmony import */ var _select__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./select */ "../app/src/elements/select.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











const separators = [
    {
        value: "-",
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Dash") + " ( - )"
    },
    {
        value: "_",
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Underscore") + " ( _ )"
    },
    {
        value: "/",
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Slash") + " ( / )"
    },
    {
        value: " ",
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Space") + " (   )"
    }
];
class Generator extends _dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog {
    constructor() {
        super(...arguments);
        this.value = "";
        this.mode = "words";
    }
    renderContent() {
        const { value } = this;
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <div class="header">
                <div class="header-title">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Generate Password")}</div>
                <div class="tabs">
                    <div
                        class="flex tab tap"
                        ?active=${this.mode === "words"}
                        @click=${() => this._selectMode("words")}
                    >
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("passphrase")}
                    </div>
                    <div
                        class="flex tab tap"
                        ?active=${this.mode === "chars"}
                        @click=${() => this._selectMode("chars")}
                    >
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("random string")}
                    </div>
                </div>
            </div>

            <div class="content">
                <div ?hidden=${this.mode !== "words"} class="controls">
                    <pl-select
                        id="separator"
                        .options=${separators}
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Word Separator")}
                        class="item tap"
                    ></pl-select>

                    <pl-select
                        id="language"
                        .options=${_padloc_core_src_diceware__WEBPACK_IMPORTED_MODULE_1__.AVAILABLE_LANGUAGES}
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Language")}
                        class="item tap"
                    ></pl-select>

                    <pl-slider
                        id="wordCount"
                        unit=" ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("words")}"
                        value="4"
                        min="3"
                        max="6"
                        class="item tap"
                    ></pl-slider>
                </div>

                <div ?hidden=${this.mode !== "chars"} class="controls">
                    <pl-toggle-button id="lower" label="a-z" class="item tap" reverse></pl-toggle-button>

                    <pl-toggle-button id="upper" label="A-Z" class="item tap" reverse></pl-toggle-button>

                    <pl-toggle-button id="numbers" label="0-9" class="item tap" reverse></pl-toggle-button>

                    <pl-toggle-button id="other" label="?()/%..." class="item tap" reverse></pl-toggle-button>

                    <pl-slider id="length" label="${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("length")}" value="20" min="5" max="50" class="item"></pl-slider>
                </div>

                <pl-icon icon="arrow-down" class="arrow"></pl-icon>

                <div class="result item" @click=${() => this._generate()}>
                    <div>
                        ${value}
                    </div>

                    <div class="hint">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Click To Shuffle")}
                    </div>
                </div>
            </div>

            <div class="footer">
                <div class="actions">
                    <button class="primary tap" @click=${() => this._confirm()}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Use")}</button>
                    <button class="transparent tap" @click=${() => this.dismiss()}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Discard")}</button>
                </div>
            </div>
        `;
    }
    firstUpdated() {
        this._lower.active = this._upper.active = this._numbers.active = true;
    }
    async show() {
        await this.updateComplete;
        this._generate();
        return super.show();
    }
    async _generate() {
        const separator = (this._separator && this._separator.selected && this._separator.selected.value) || "-";
        const language = (this._language && this._language.selected && this._language.selected.value) || _globals__WEBPACK_IMPORTED_MODULE_4__.app.state.device.locale;
        switch (this.mode) {
            case "words":
                this.value = await (0,_padloc_core_src_diceware__WEBPACK_IMPORTED_MODULE_1__.generatePassphrase)(this._wordCount.value, separator, [language]);
                break;
            case "chars":
                let charSet = "";
                this._lower.active && (charSet += _padloc_core_src_util__WEBPACK_IMPORTED_MODULE_0__.chars.lower);
                this._upper.active && (charSet += _padloc_core_src_util__WEBPACK_IMPORTED_MODULE_0__.chars.upper);
                this._numbers.active && (charSet += _padloc_core_src_util__WEBPACK_IMPORTED_MODULE_0__.chars.numbers);
                this._other.active && (charSet += _padloc_core_src_util__WEBPACK_IMPORTED_MODULE_0__.chars.other);
                this.value = charSet ? await (0,_padloc_core_src_util__WEBPACK_IMPORTED_MODULE_0__.randomString)(this._length.value, charSet) : "";
                break;
        }
        (0,_lib_animation__WEBPACK_IMPORTED_MODULE_3__.animateElement)(this._result, { animation: "bounce" });
    }
    _confirm() {
        this.done(this.value);
    }
    _selectMode(mode) {
        this.mode = mode;
        this._generate();
    }
}
Generator.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            .inner {
                background: var(--color-quaternary);
                display: flex;
                flex-direction: column;
            }

            .header {
                background: var(--color-tertiary);
                text-align: center;
                font-weight: bold;
            }

            .header-title {
                font-size: 120%;
                padding: 20px 20px 10px 20px;
            }

            .charsets {
                display: flex;
            }

            .charsets > * {
                flex: 1;
            }

            pl-toggle-button {
                display: block;
                border-bottom: solid 1px rgba(0, 0, 0, 0.1);
            }

            pl-slider {
                display: flex;
                height: var(--row-height);
                border-bottom: solid 1px rgba(0, 0, 0, 0.1);
            }

            .controls > pl-select {
                margin-top: calc(2 * var(--gutter-size));
            }

            .result {
                font-family: var(--font-family-mono);
                text-align: center;
                font-size: 120%;
                overflow-wrap: break-word;
                font-weight: bold;
                padding: 20px;
                margin: var(--gutter-size);
                cursor: pointer;
            }

            .result > .hint {
                margin: 8px 0 -12px 0;
                font-size: var(--font-size-micro);
                color: var(--color-shade-3);
            }

            .arrow {
                display: block;
                margin: -10px auto;
                font-size: 120%;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], Generator.prototype, "value", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], Generator.prototype, "mode", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#separator"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_9__.Select)
], Generator.prototype, "_separator", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#language"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_9__.Select)
], Generator.prototype, "_language", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#wordCount"),
    __metadata("design:type", _slider__WEBPACK_IMPORTED_MODULE_7__.Slider)
], Generator.prototype, "_wordCount", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#lower"),
    __metadata("design:type", _toggle_button__WEBPACK_IMPORTED_MODULE_8__.ToggleButton)
], Generator.prototype, "_lower", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#upper"),
    __metadata("design:type", _toggle_button__WEBPACK_IMPORTED_MODULE_8__.ToggleButton)
], Generator.prototype, "_upper", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#numbers"),
    __metadata("design:type", _toggle_button__WEBPACK_IMPORTED_MODULE_8__.ToggleButton)
], Generator.prototype, "_numbers", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#other"),
    __metadata("design:type", _toggle_button__WEBPACK_IMPORTED_MODULE_8__.ToggleButton)
], Generator.prototype, "_other", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#length"),
    __metadata("design:type", _slider__WEBPACK_IMPORTED_MODULE_7__.Slider)
], Generator.prototype, "_length", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)(".result"),
    __metadata("design:type", HTMLDivElement)
], Generator.prototype, "_result", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.listen)("change"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Generator.prototype, "_generate", null);
window.customElements.define("pl-generator", Generator);


/***/ }),

/***/ "../app/src/elements/group-dialog.ts":
/*!*******************************************!*\
  !*** ../app/src/elements/group-dialog.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "GroupDialog": () => (/* binding */ GroupDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _toggle_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./toggle-button */ "../app/src/elements/toggle-button.ts");
/* harmony import */ var _member_item__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./member-item */ "../app/src/elements/member-item.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};









let GroupDialog = class GroupDialog extends _dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog {
    constructor() {
        super(...arguments);
        this.group = null;
        this.org = null;
        this._membersFilter = "";
        this._error = "";
        this._members = new Set();
    }
    _getCurrentMembers() {
        const members = new Set();
        if (!this.group || !this.org) {
            return members;
        }
        for (const member of this.org.getMembersForGroup(this.group)) {
            members.add(member.id);
        }
        return members;
    }
    get _hasChanged() {
        if (!this._nameInput) {
            return false;
        }
        const currentMembers = this._getCurrentMembers();
        const membersChanged = this._members.size !== currentMembers.size ||
            [...this._members.values()].some(group => !currentMembers.has(group));
        const nameChanged = this.group ? this.group.name !== this._nameInput.value : !!this._nameInput.value;
        return this._members.size && this._nameInput.value && (membersChanged || nameChanged);
    }
    async show({ org, group }) {
        this.org = org;
        this.group = group;
        this._members = this._getCurrentMembers();
        this._error = "";
        await this.updateComplete;
        this._nameInput.value = group ? group.name : "";
        this._clearMembersFilter();
        if (group) {
            setTimeout(() => this._nameInput.focus(), 100);
        }
        await super.show();
    }
    _toggleMember(member) {
        if (this._members.has(member.id)) {
            this._members.delete(member.id);
        }
        else {
            this._members.add(member.id);
        }
        this.requestUpdate();
    }
    async _save() {
        if (this._saveButton.state === "loading") {
            return;
        }
        this._error = "";
        this._saveButton.start();
        try {
            const org = this.org;
            const members = [...this._members.values()].map(id => org.getMember({ id }));
            if (this.group) {
                await _globals__WEBPACK_IMPORTED_MODULE_1__.app.updateGroup(org, this.group, members, this._nameInput.value);
            }
            else {
                await _globals__WEBPACK_IMPORTED_MODULE_1__.app.createGroup(org, this._nameInput.value, members);
            }
            this._saveButton.success();
            this.done();
        }
        catch (e) {
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!");
            this._saveButton.fail();
            throw e;
        }
    }
    async _deleteGroup() {
        this.open = false;
        const deleted = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to delete this group?"), {
            type: "destructive",
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Group"),
            placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Type 'DELETE' to confirm"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete"),
            validate: async (val) => {
                if (val !== "DELETE") {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Type 'DELETE' to confirm");
                }
                await _globals__WEBPACK_IMPORTED_MODULE_1__.app.updateOrg(this.org.id, async (org) => {
                    org.groups = org.groups.filter(group => group.name !== this.group.name);
                });
                return val;
            }
        });
        if (deleted) {
            this.done();
        }
        else {
            this.open = true;
        }
    }
    _updateMembersFilter() {
        this._membersFilter = this._filterMembersInput.value;
    }
    _clearMembersFilter() {
        this._membersFilter = this._filterMembersInput.value = "";
    }
    shouldUpdate() {
        return !!this.org;
    }
    renderContent() {
        const org = this.org;
        const memFilter = this._membersFilter.toLowerCase();
        const members = memFilter
            ? org.members.filter(({ name, email }) => email.toLowerCase().includes(memFilter) || name.toLowerCase().includes(memFilter))
            : org.members;
        // members.sort((a, b) => this._members.has(a.id) - this._members.has(b.id));
        const canEdit = org.isAdmin(_globals__WEBPACK_IMPORTED_MODULE_1__.app.account);
        const canDelete = this.group && canEdit;
        return _base__WEBPACK_IMPORTED_MODULE_3__.html `
            <header>
                <pl-icon icon="group"></pl-icon>
                <pl-input
                    id="nameInput"
                    class="flex"
                    .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Group Name")}
                    .readonly=${!canEdit}
                    @input=${() => this.requestUpdate()}
                ></pl-input>
                <pl-icon
                    icon="delete"
                    class="delete-button tap"
                    @click=${this._deleteGroup}
                    ?hidden=${!canDelete}
                ></pl-icon>
            </header>

            <div class="content">
                <div class="search-wrapper item">
                    <pl-icon icon="search"></pl-icon>
                    <pl-input
                        id="filterMembersInput"
                        placeholder="${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Search...")}"
                        @input=${this._updateMembersFilter}
                    ></pl-input>
                    <pl-icon icon="cancel" class="tap" @click=${this._clearMembersFilter}></pl-icon>
                </div>

                ${members.map(member => _base__WEBPACK_IMPORTED_MODULE_3__.html `
                        <pl-toggle-button
                            class="item tap"
                            reverse
                            @click=${() => this._toggleMember(member)}
                            .active=${this._members.has(member.id)}
                            ?disabled=${!canEdit}
                        >
                            <pl-member-item hideRole .member=${member}></pl-member-item>
                        </pl-toggle-button>
                    `)}

                <div class="error item" ?hidden="${!this._error}">
                    ${this._error}
                </div>
            </div>

            <div class="footer">
                <div class="actions">
                    <pl-loading-button
                        class="tap primary"
                        id="saveButton"
                        ?disabled=${!canEdit || !this._hasChanged}
                        @click=${this._save}
                    >
                        ${this.group ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Save") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Create Group")}
                    </pl-loading-button>

                    <button class="transparent tap" @click=${this.dismiss}>
                        ${!this.group || this._hasChanged ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Close")}
                    </button>
                </div>
            </div>
        `;
    }
};
GroupDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_3__.css `
            .inner {
                background: var(--color-quaternary);
            }

            pl-toggle-button {
                display: block;
                padding: 0 15px 0 0;
            }

            .delete-button {
                color: var(--color-negative);
                font-size: var(--font-size-default);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Object)
], GroupDialog.prototype, "group", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Object)
], GroupDialog.prototype, "org", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("#saveButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_5__.LoadingButton)
], GroupDialog.prototype, "_saveButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("#nameInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_6__.Input)
], GroupDialog.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("#filterMembersInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_6__.Input)
], GroupDialog.prototype, "_filterMembersInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", String)
], GroupDialog.prototype, "_membersFilter", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", String)
], GroupDialog.prototype, "_error", void 0);
GroupDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.element)("pl-group-dialog")
], GroupDialog);



/***/ }),

/***/ "../app/src/elements/group-item.ts":
/*!*****************************************!*\
  !*** ../app/src/elements/group-item.ts ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "GroupItem": () => (/* binding */ GroupItem)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/org */ "../core/src/org.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




let GroupItem = class GroupItem extends _base__WEBPACK_IMPORTED_MODULE_2__.BaseElement {
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <pl-icon class="icon" icon="group"></pl-icon>

            <div class="group-info">
                <div class="group-name ellipsis">${this.group.name}</div>

                <div class="tags small">
                    <div class="tag">
                        <pl-icon icon="user"></pl-icon>

                        <div>${this.group.members.length}</div>
                    </div>

                    <div class="tag">
                        <pl-icon icon="vaults"></pl-icon>

                        <div>${this.group.vaults.length}</div>
                    </div>
                </div>
            </div>
        `;
    }
};
GroupItem.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_1__.shared,
    _base__WEBPACK_IMPORTED_MODULE_2__.css `
            :host {
                display: flex;
                align-items: center;
                padding: 4px 0;
            }

            .icon {
                font-size: 120%;
                margin: 8px;
                background: #eee;
                border: solid 1px #ddd;
                width: 45px;
                height: 45px;
            }

            .tags {
                margin: 4px 0;
            }

            .group-name {
                font-weight: bold;
                margin-bottom: 4px;
            }

            .group-info {
                flex: 1;
                width: 0;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.Group)
], GroupItem.prototype, "group", void 0);
GroupItem = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.element)("pl-group-item")
], GroupItem);



/***/ }),

/***/ "../app/src/elements/icon.ts":
/*!***********************************!*\
  !*** ../app/src/elements/icon.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "PlIcon": () => (/* binding */ PlIcon)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};

let PlIcon = class PlIcon extends _base__WEBPACK_IMPORTED_MODULE_0__.BaseElement {
    constructor() {
        super(...arguments);
        this.icon = "";
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            <div></div>
        `;
    }
};
PlIcon.styles = [
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            :host {
                display: inline-block;
                text-align: center;
                font-family: "FontAwesome";
                color: inherit;
                font-size: inherit;
                position: relative;
                height: 40px;
                width: 40px;
                font-weight: normal !important;
                border-radius: 100%;
                overflow: hidden;
            }

            div {
                position: absolute;
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
                margin: auto;
                height: 0;
                line-height: 0;
            }

            :host([icon="add"]) > div::before {
                content: "\\f067";
            }

            :host([icon="menu"]) > div::before {
                content: "\\f0c9";
            }

            :host([icon="close"]) > div::before {
                content: "\\f00d";
            }

            :host([icon="more"]) > div::before {
                content: "\\f141";
            }

            :host([icon="delete"]) > div::before {
                content: "\\f2ed";
            }

            :host([icon="copy"]) > div::before {
                /* content: "\\f24d"; */
                content: "\\f0c5";
            }

            :host([icon="edit"]) > div::before {
                content: "\\f303";
            }

            :host([icon="forward"]) > div::before {
                content: "\\f054";
            }

            :host([icon="backward"]) > div::before {
                content: "\\f053";
            }

            :host([icon="check"]) > div::before {
                content: "\\f00c";
            }

            :host([icon="cancel"]) > div::before {
                content: "\\f00d";
            }

            :host([icon="generate"]) > div::before {
                content: "\\f522";
            }

            :host([icon="tag"]) > div::before {
                content: "\\f02b";
            }

            :host([icon="tags"]) > div::before {
                content: "\\f02c";
            }

            :host([icon="dropdown"]) > div::before {
                content: "\\f0d7";
            }

            :host([icon="dropup"]) > div::before {
                content: "\\f0d8";
            }

            :host([icon="settings"]) > div::before {
                content: "\\f013";
            }

            :host([icon="cloud"]) > div::before {
                content: "\\f0c2";
            }

            :host([icon="lock"]) > div::before {
                content: "\\f023";
            }

            :host([icon="refresh"]) > div::before {
                content: "\\f2f1";
            }

            :host([icon="unlock"]) > div::before {
                content: "\\f13e";
            }

            :host([icon="export"]) > div::before {
                content: "\\f093";
            }

            :host([icon="import"]) > div::before {
                content: "\\f019";
            }

            :host([icon="search"]) > div::before {
                content: "\\f002";
            }

            :host([icon="info"]) > div::before {
                content: "\\f129";
            }

            :host([icon="info-round"]) > div::before {
                content: "\\f05a";
            }

            :host([icon="download"]) > div::before {
                content: "\\f019";
            }

            :host([icon="upload"]) > div::before {
                content: "\\f093";
            }

            :host([icon="show"]) > div::before {
                content: "\\f06e";
            }

            :host([icon="hide"]) > div::before {
                content: "\\f070";
            }

            :host([icon="checked"]) > div::before {
                content: "\\f14a";
            }

            :host([icon="checkall"]) > div::before {
                content: "\\f560";
            }

            :host([icon="success"]) > div::before {
                content: "\\f058";
            }

            :host([icon="unchecked"]) > div::before {
                content: "\\f146";
            }

            :host([icon="share"]) > div::before {
                content: "\\f045";
            }

            :host([icon="logout"]) > div::before {
                content: "\\f2f5";
            }

            :host([icon="mail"]) > div::before {
                content: "\\f0e0";
            }

            :host([icon="user"]) > div::before {
                content: "\\f007";
            }

            :host([icon="record"]) > div::before {
                content: "\\f15b";
            }

            :host([icon="mobile"]) > div::before {
                content: "\\f10b";
                font-size: 140%;
            }

            :host([icon="database"]) > div::before {
                content: "\\f1c0";
            }

            :host([icon="time"]) > div::before {
                content: "\\f017";
            }

            :host([icon="error"]) > div::before {
                content: "\\f071";
            }

            :host([icon="question"]) > div::before {
                content: "\\f059";
            }

            :host([icon="desktop"]) > div::before {
                content: "\\f109";
            }

            :host([icon="group"]) > div::before {
                content: "\\f509";
            }

            :host([icon="members"]) > div::before {
                content: "\\f0c0";
            }

            :host([icon="vaults"]) > div::before {
                content: "\\f1b3";
            }

            :host([icon="vault"]) > div::before {
                content: "\\f1b2";
            }

            :host([icon="share"]) > div::before {
                content: "\\f064";
            }

            :host([icon="invite"]) > div::before {
                content: "\\f234";
            }

            :host([icon="trusted"]) > div::before {
                content: "\\f4fc";
            }

            :host([icon="removeuser"]) > div::before {
                content: "\\f506";
            }

            :host([icon="org"]) > div::before {
                content: "\\f0c0";
            }

            // :host([icon="logo"]) > div::before {
            //     content: "\\f447";
            // }

            :host([icon="list"]) > div::before {
                content: "\\f550";
            }

            :host([icon="remove"]) > div::before {
                content: "\\f056";
            }

            :host([icon="password"]) > div::before {
                content: "\\f069";
            }

            :host([icon="admins"]) > div::before {
                content: "\\f509";
            }

            :host([icon="archive"]) > div::before {
                content: "\\f187";
            }

            :host([icon="attachment"]) > div::before {
                content: "\\f0c6";
            }

            :host([icon="file"]) > div::before {
                content: "\\f15b";
            }

            :host([icon="file-video"]) > div::before {
                content: "\\f1c8";
            }

            :host([icon="file-pdf"]) > div::before {
                content: "\\f1c1";
            }

            :host([icon="file-image"]) > div::before {
                content: "\\f1c5";
            }

            :host([icon="file-csv"]) > div::before {
                content: "\\f6dd";
            }

            :host([icon="file-code"]) > div::before {
                content: "\\f1c9";
            }

            :host([icon="file-archive"]) > div::before {
                content: "\\f1c6";
            }

            :host([icon="file-audio"]) > div::before {
                content: "\\f1c7";
            }

            :host([icon="file-text"]) > div::before {
                content: "\\f15c";
            }

            :host([icon="file-certificate"]) > div::before {
                content: "\\f56c";
            }

            :host([icon="arrow-down"]) > div::before {
                content: "\\f309";
            }

            :host([icon="favorite"]) > div::before {
                content: "\\f005";
            }

            :host([icon="qrcode"]) > div::before {
                content: "\\f029";
            }

            :host([icon="credit"]) > div::before {
                content: "\\f09d";
            }

            :host([icon="address"]) > div::before {
                content: "\\f2bb";
            }

            :host([icon="discount"]) > div::before {
                content: "\\f295";
            }

            :host([icon="dollar"]) > div::before {
                content: "\\f155";
            }

            :host([icon="storage"]) > div::before {
                content: "\\f49e";
            }

            :host([icon="hirarchy"]) > div::before {
                content: "\\f0e8";
            }

            :host([icon="web"]) > div::before {
                content: "\\f57d";
            }

            :host([icon="bank"]) > div::before {
                content: "\\f53d";
            }

            :host([icon="login"]) > div::before {
                content: "\\f2f6";
            }

            :host([icon="sim"]) > div::before {
                content: "\\f7c4";
            }

            :host([icon="wifi"]) > div::before {
                content: "\\f1eb";
            }

            :host([icon="passport"]) > div::before {
                content: "\\f5ab";
            }

            :host([icon="note"]) > div::before {
                content: "\\f036";
            }

            :host([icon="custom"]) > div::before {
                content: "\\f249";
            }

            :host([icon="email"]) > div::before {
                content: "\\f1fa";
            }

            :host([icon="fingerprint"]) > div::before {
                content: "\\f577";
            }

            :host([icon="totp"]) > div::before {
                content: "\\f1da";
            }

            :host([icon="month"]) > div::before {
                content: "\\f133";
            }

            :host([icon="date"]) > div::before {
                content: "\\f073";
            }

            :host([icon="phone"]) > div::before {
                content: "\\f095";
            }

            :host([icon="text"]) > div::before {
                content: "\\f031";
            }

            :host([icon="clipboard"]) > div::before {
                content: "\\f328";
            }

            :host([icon="logo"]) > div::before {
                font-family: "Padlock";
                content: "\\0041";
                font-size: 110%;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", String)
], PlIcon.prototype, "icon", void 0);
PlIcon = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.element)("pl-icon")
], PlIcon);



/***/ }),

/***/ "../app/src/elements/import-dialog.ts":
/*!********************************************!*\
  !*** ../app/src/elements/import-dialog.ts ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ImportDialog": () => (/* binding */ ImportDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _lib_import__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../lib/import */ "../app/src/lib/import.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _select__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./select */ "../app/src/elements/select.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};







let ImportDialog = class ImportDialog extends _dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog {
    constructor() {
        super(...arguments);
        this._rawData = "";
        this._items = [];
    }
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <h1>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Import Data")}</h1>

            <pl-select
                id="formatSelect"
                .options=${_lib_import__WEBPACK_IMPORTED_MODULE_1__.supportedFormats}
                .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Format")}
                @change=${this._parseString}
                disabled
            ></pl-select>

            <div class="csv-note" ?hidden=${this._formatSelect && this._formatSelect.selected !== _lib_import__WEBPACK_IMPORTED_MODULE_1__.CSV}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("IMPORTANT: Before importing, please make sure that your CSV data " +
            "is structured according to Padlocks specific requirements!")}
                <a href="https://padlock.io/howto/import/#importing-from-csv" target="_blank">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Learn More")}</a>
            </div>

            <pl-select id="vaultSelect" .options=${_globals__WEBPACK_IMPORTED_MODULE_3__.app.vaults} .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Target Vault")}></pl-select>

            <button @click=${() => this._import()} class="tap primary" ?disabled=${!this._items.length}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Import {0} Items", this._items.length.toString())}
            </button>
        `;
    }
    async show(input) {
        await this.updateComplete;
        const result = super.show();
        this._rawData = input;
        this._formatSelect.selected = _lib_import__WEBPACK_IMPORTED_MODULE_1__.guessFormat(input) || _lib_import__WEBPACK_IMPORTED_MODULE_1__.CSV;
        this._parseString();
        this._vaultSelect.selected = _globals__WEBPACK_IMPORTED_MODULE_3__.app.mainVault;
        return result;
    }
    async _parseString() {
        const rawStr = this._rawData;
        switch (this._formatSelect.selected.format) {
            case _lib_import__WEBPACK_IMPORTED_MODULE_1__.PADLOCK_LEGACY.format:
                this.open = false;
                const pwd = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This file is protected by a password."), {
                    title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Password"),
                    placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Password"),
                    type: "password",
                    validate: async (pwd) => {
                        try {
                            this._items = await _lib_import__WEBPACK_IMPORTED_MODULE_1__.asPadlockLegacy(rawStr, pwd);
                        }
                        catch (e) {
                            throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Wrong Password");
                        }
                        return pwd;
                    }
                });
                this.open = true;
                if (pwd === null) {
                    this.done();
                }
                break;
            case _lib_import__WEBPACK_IMPORTED_MODULE_1__.LASTPASS.format:
                this._items = await _lib_import__WEBPACK_IMPORTED_MODULE_1__.asLastPass(rawStr);
                break;
            case _lib_import__WEBPACK_IMPORTED_MODULE_1__.CSV.format:
                this._items = await _lib_import__WEBPACK_IMPORTED_MODULE_1__.asCSV(rawStr);
                break;
            case _lib_import__WEBPACK_IMPORTED_MODULE_1__.PBES2.format:
                this.open = false;
                const pwd2 = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This file is protected by a password."), {
                    title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Password"),
                    placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Password"),
                    type: "password",
                    validate: async (pwd) => {
                        try {
                            this._items = await _lib_import__WEBPACK_IMPORTED_MODULE_1__.asPBES2Container(rawStr, pwd);
                        }
                        catch (e) {
                            throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Wrong Password");
                        }
                        return pwd;
                    }
                });
                this.open = true;
                if (pwd2 === null) {
                    this.done();
                }
                break;
            default:
                this._items = [];
        }
    }
    async _import() {
        const vault = this._vaultSelect.selected;
        const quota = _globals__WEBPACK_IMPORTED_MODULE_3__.app.getItemsQuota(vault);
        if (quota !== -1 && vault.items.size + this._items.length > quota) {
            this.done();
            if (_globals__WEBPACK_IMPORTED_MODULE_3__.app.billingEnabled) {
                this.dispatch("get-premium", {
                    message: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("The number of imported items exceeds your remaining quota. " +
                        "Upgrade to Premium to get unlimited items for your private vault!"),
                    icon: "list"
                });
            }
            else {
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("The number of imported items exceeds your remaining quota."), { type: "warning" });
            }
            return;
        }
        _globals__WEBPACK_IMPORTED_MODULE_3__.app.addItems(this._items, vault);
        // this.dispatch("data-imported", { items: items });
        this.done();
        (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Successfully imported {0} items.", this._items.length.toString()), { type: "success" });
    }
};
ImportDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            .inner {
                display: flex;
                flex-direction: column;
            }

            pl-input,
            pl-select,
            button {
                text-align: center;
                margin: 0 10px 10px 10px;
                background: var(--shade-2-color);
                border-radius: 8px;
            }

            h1 {
                display: block;
                text-align: center;
            }

            .csv-note {
                font-size: var(--font-size-micro);
                text-align: center;
                padding: 0px 20px 20px 20px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", String)
], ImportDialog.prototype, "_rawData", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Array)
], ImportDialog.prototype, "_items", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#formatSelect"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_5__.Select)
], ImportDialog.prototype, "_formatSelect", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#vaultSelect"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_5__.Select)
], ImportDialog.prototype, "_vaultSelect", void 0);
ImportDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-import-dialog")
], ImportDialog);



/***/ }),

/***/ "../app/src/elements/input.ts":
/*!************************************!*\
  !*** ../app/src/elements/input.ts ***!
  \************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Input": () => (/* binding */ Input)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _base_input__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base-input */ "../app/src/elements/base-input.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};


let Input = class Input extends _base_input__WEBPACK_IMPORTED_MODULE_1__.BaseInput {
    constructor() {
        super(...arguments);
        this.type = "";
        this.pattern = "";
    }
    get validationMessage() {
        return this._inputElement.validationMessage;
    }
    _keydown(e) {
        if (e.key === "Enter") {
            this.checkValidity();
            this.dispatch("enter");
            e.preventDefault();
            e.stopPropagation();
        }
        else if (e.key === "Escape") {
            this.dispatch("escape");
            e.preventDefault();
            e.stopPropagation();
        }
    }
    _renderInput() {
        const { placeholder, readonly, noTab, disabled, autocapitalize, required, type, pattern } = this;
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            <input
                class="input-element"
                .placeholder=${placeholder}
                ?readonly=${readonly}
                .tabIndex=${noTab ? "-1" : ""}
                ?disabled=${disabled}
                autocapitalize="${autocapitalize ? "" : "off"}"
                ?required=${required}
                autocomplete="off"
                spellcheck="false"
                autocorrect="off"
                type="${type}"
                pattern="${pattern || ".*"}"
                @focus=${this._focused}
                @blur=${this._blurred}
                @change=${this._changeHandler}
                @touchend=${this._touchend}
            />
        `;
    }
    checkValidity() {
        return this._inputElement && this._inputElement.checkValidity();
    }
    reportValidity() {
        return this._inputElement && this._inputElement.reportValidity();
    }
};
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String)
], Input.prototype, "type", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String)
], Input.prototype, "pattern", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.listen)("keydown"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [KeyboardEvent]),
    __metadata("design:returntype", void 0)
], Input.prototype, "_keydown", null);
Input = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.element)("pl-input")
], Input);



/***/ }),

/***/ "../app/src/elements/invite-dialog.ts":
/*!********************************************!*\
  !*** ../app/src/elements/invite-dialog.ts ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "InviteDialog": () => (/* binding */ InviteDialog)
/* harmony export */ });
/* harmony import */ var lit_html_directives_until__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/until */ "../app/node_modules/lit-html/directives/until.js");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _member_dialog__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./member-dialog */ "../app/src/elements/member-dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};










let InviteDialog = class InviteDialog extends _dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog {
    constructor() {
        super(...arguments);
        this.invite = null;
        this._error = "";
        this._pollInterval = 5000;
    }
    get _enableActions() {
        return !!this.invite && !this.invite.expired && !this.invite.accepted;
    }
    async show(invite) {
        this._error = "";
        this.invite = invite;
        setTimeout(() => this._refresh(), this._pollInterval);
        return super.show();
    }
    dismiss() {
        super.dismiss();
        _globals__WEBPACK_IMPORTED_MODULE_3__.router.go(`orgs/${this.invite.org.id}`);
    }
    async _refresh() {
        if (!this.invite || !this.open || this.invite.accepted) {
            return;
        }
        const invite = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.getInvite(this.invite.org.id, this.invite.id);
        if (invite) {
            invite.secret = this.invite.secret;
            invite.expires = this.invite.expires;
            this.invite = invite;
        }
        setTimeout(() => this._refresh(), this._pollInterval);
    }
    shouldUpdate() {
        return !!this.invite;
    }
    renderContent() {
        const { email, expires, expired, org, accepted, purpose } = this.invite;
        const forMe = email === _globals__WEBPACK_IMPORTED_MODULE_3__.app.account.email;
        const status = expired
            ? { icon: "time", class: "warning", text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("This invite has expired") }
            : accepted
                ? { icon: "check", class: "", text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Accepted") }
                : {
                    icon: "time",
                    class: "",
                    text: (0,lit_html_directives_until__WEBPACK_IMPORTED_MODULE_0__.until)((async () => {
                        return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("expires {0}", await (0,_lib_util__WEBPACK_IMPORTED_MODULE_2__.formatDateFromNow)(expires));
                    })())
                };
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <header>
                <pl-icon></pl-icon>

                <div class="title flex">
                    ${purpose === "confirm_membership" ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Confirm Membership") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Organization Invite")}
                </div>

                <pl-icon icon="cancel" class="tap" @click=${() => this.dismiss()}></pl-icon>
            </header>

            <div class="content">
                <div class="tags">
                    <div class="tag org highlight">
                        <pl-icon icon="org"></pl-icon>

                        <div>${org.name}</div>
                    </div>
                </div>

                ${forMe ? this._inviteeBody() : this._adminBody()}

                <div class="tags">
                    <div class="tag ${status.class}">
                        <pl-icon icon="${status.icon}"></pl-icon>

                        <div>${status.text}</div>
                    </div>
                </div>

                <div class="invite-text" ?hidden=${!forMe || !accepted}>
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Please wait for an admin to complete the process. " +
            "You will be notified as soon as you receive access.")}
                </div>

                <div class="item error" ?hidden=${!this._error}>
                    ${this._error}
                </div>

                <div class="actions">
                    ${forMe ? this._inviteeActions() : this._adminActions()}
                </div>
            </div>
        `;
    }
    _inviteeBody() {
        const { org, purpose } = this.invite;
        const { _enableActions } = this;
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <div class="invite-text">
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)(purpose === "confirm_membership"
            ? "Please confirm your membership for the {0} organization."
            : "You've been invited to join the {0} organization.", org.name)}
            </div>

            <pl-input
                class="code-input tiles-2"
                id="codeInput"
                ?hidden=${!_enableActions}
                @enter=${() => this._accept()}
                label="${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Enter Confirmation Code")}"
            >
            </pl-input>

            <div class="invite-text small" ?hidden=${!_enableActions}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("If you haven't received the confirmation code yet, please ask the organization owner " +
            "to provide it to you!")}
            </div>
        `;
    }
    _inviteeActions() {
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <pl-loading-button
                id="acceptButton"
                class="tap primary"
                ?hidden=${!this._enableActions}
                @click=${() => this._accept()}
            >
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)(this.invite.purpose === "confirm_membership" ? "Confirm" : "Accept")}
            </pl-loading-button>
        `;
    }
    _adminBody() {
        const { _enableActions } = this;
        const { email, secret, purpose } = this.invite;
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <div class="invite-text">
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)(purpose === "confirm_membership"
            ? "A membership confirmation request was sent to:"
            : "An invite was sent to:")}
            </div>

            <div class="invite-email">${email}</div>

            <div class="invite-text" ?hidden=${!_enableActions}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("They will also need the following confirmation code, which " +
            "you should communicate to them separately:")}
            </div>

            <div class="invite-code" ?hidden=${!_enableActions}>${secret}</div>
        `;
    }
    _adminActions() {
        const { accepted, expired, purpose } = this.invite;
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <pl-loading-button
                ?hidden=${!accepted}
                ?disabled=${!accepted || expired}
                id="confirmButton"
                class="tap primary"
                @click=${() => this._confirm()}
            >
                <pl-icon icon="invite"></pl-icon>

                <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)(purpose === "confirm_membership" ? "Confirm" : "Add Member")}</div>
            </pl-loading-button>

            <pl-loading-button id="deleteButton" class="tap negative" @click=${() => this._delete()}>
                <pl-icon icon="delete"></pl-icon>

                <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Delete")}</div>
            </pl-loading-button>

            <pl-loading-button ?hidden=${accepted} id="resendButton" class="tap" @click=${() => this._resend()}>
                <pl-icon icon="mail"></pl-icon>

                <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Resend")}</div>
            </pl-loading-button>
        `;
    }
    async _delete() {
        if (this._deleteButton.state === "loading") {
            return;
        }
        this._deleteButton.start();
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.deleteInvite(this.invite);
            this._deleteButton.success();
            this.dismiss();
        }
        catch (e) {
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!");
            this._deleteButton.fail();
            throw e;
        }
        this.dismiss();
    }
    async _resend() {
        if (this._resendButton.state === "loading") {
            return;
        }
        this._resendButton.start();
        let org = _globals__WEBPACK_IMPORTED_MODULE_3__.app.getOrg(this.invite.org.id);
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.deleteInvite(this.invite);
            this.invite = (await _globals__WEBPACK_IMPORTED_MODULE_3__.app.createInvites(org, [this.invite.email], this.invite.purpose))[0];
            _globals__WEBPACK_IMPORTED_MODULE_3__.router.go(`invite/${this.invite.org.id}/${this.invite.id}`, undefined, true);
            this._resendButton.success();
        }
        catch (e) {
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!");
            this._resendButton.fail();
            throw e;
        }
    }
    async _accept() {
        if (this._acceptButton.state === "loading") {
            return;
        }
        if (!this._codeInput.value) {
            this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Please enter a confirmation code!");
            this.rumble();
            return;
        }
        this._acceptButton.start();
        try {
            const success = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.acceptInvite(this.invite, this._codeInput.value.toLowerCase());
            if (success) {
                this._acceptButton.success();
                this.dismiss();
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("You have successfully accepted the invite. You'll be notified once you've been granted access."), { type: "success" });
            }
            else {
                this._acceptButton.fail();
                this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Wrong confirmation code. Please try again!");
                this.rumble();
                return;
            }
        }
        catch (e) {
            this._acceptButton.fail();
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!");
            this.rumble();
        }
    }
    async _confirm() {
        if (this._confirmButton.state === "loading") {
            return;
        }
        this._confirmButton.start();
        try {
            const member = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.confirmInvite(this.invite);
            this._confirmButton.success();
            this.open = false;
            await this._memberDialog.show({ org: _globals__WEBPACK_IMPORTED_MODULE_3__.app.getOrg(this.invite.org.id), member });
            this.dismiss();
        }
        catch (e) {
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!");
            this._confirmButton.fail();
            throw e;
        }
    }
};
InviteDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            :host {
                text-align: center;
            }

            .invite-text {
                font-size: var(--font-size-small);
                margin: 20px;
            }

            .invite-text.small {
                font-size: var(--font-size-tiny);
            }

            .invite-text.error {
                color: var(--color-error);
                text-shadow: none;
                font-weight: bold;
            }

            .invite-email {
                font-size: 120%;
                margin: 15px;
                font-weight: bold;
            }

            .invite-code {
                font-size: 200%;
                font-family: var(--font-family-mono);
                text-transform: uppercase;
                margin: 20px;
                letter-spacing: 5px;
                font-weight: bold;
                user-select: text;
                cursor: text;
            }

            .tags {
                justify-content: center;
                overflow: visible;
                margin: 20px 0;
            }

            .tag.org {
                font-size: var(--font-size-small);
                padding: 4px 16px;
            }

            .code-input {
                border-radius: 8px;
                margin: 15px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], InviteDialog.prototype, "invite", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#acceptButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], InviteDialog.prototype, "_acceptButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#resendButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], InviteDialog.prototype, "_resendButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#deleteButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], InviteDialog.prototype, "_deleteButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#confirmButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], InviteDialog.prototype, "_confirmButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#codeInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], InviteDialog.prototype, "_codeInput", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.dialog)("pl-member-dialog"),
    __metadata("design:type", _member_dialog__WEBPACK_IMPORTED_MODULE_9__.MemberDialog)
], InviteDialog.prototype, "_memberDialog", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], InviteDialog.prototype, "_error", void 0);
InviteDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.element)("pl-invite-dialog")
], InviteDialog);



/***/ }),

/***/ "../app/src/elements/invite-item.ts":
/*!******************************************!*\
  !*** ../app/src/elements/invite-item.ts ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "InviteItem": () => (/* binding */ InviteItem)
/* harmony export */ });
/* harmony import */ var lit_html_directives_until__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/until */ "../app/node_modules/lit-html/directives/until.js");
/* harmony import */ var _padloc_core_src_invite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/invite */ "../core/src/invite.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _member_dialog__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./member-dialog */ "../app/src/elements/member-dialog.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











let InviteItem = class InviteItem extends _base__WEBPACK_IMPORTED_MODULE_7__.BaseElement {
    async _confirm() {
        if (this._confirmButton.state === "loading") {
            return;
        }
        this._confirmButton.start();
        try {
            const member = await _globals__WEBPACK_IMPORTED_MODULE_5__.app.confirmInvite(this.invite);
            this._confirmButton.success();
            await this._memberDialog.show({ org: _globals__WEBPACK_IMPORTED_MODULE_5__.app.getOrg(this.invite.org.id), member });
        }
        catch (e) {
            this._confirmButton.fail();
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.alert)(e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Something went wrong. Please try again later!"), { type: "warning" });
        }
    }
    shoudUpdate() {
        return !!this.invite;
    }
    render() {
        const inv = this.invite;
        const account = _globals__WEBPACK_IMPORTED_MODULE_5__.app.account;
        const org = _globals__WEBPACK_IMPORTED_MODULE_5__.app.getOrg(inv.org.id);
        const status = inv.expired
            ? { icon: "time", class: "warning", text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("expired") }
            : inv.accepted
                ? { icon: "check", class: "highlight", text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("accepted") }
                : {
                    icon: "time",
                    class: "",
                    text: (async () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("{0}", await (0,_lib_util__WEBPACK_IMPORTED_MODULE_3__.formatDateFromNow)(inv.expires, false)))()
                };
        let secret = Promise.resolve("");
        if (org.isAdmin(account)) {
            const unlockOrg = org.unlock(account);
            secret = (async () => {
                await unlockOrg;
                await inv.unlock(org.invitesKey);
                return inv.secret;
            })();
        }
        return _base__WEBPACK_IMPORTED_MODULE_7__.html `
            <pl-icon class="icon" icon="mail"></pl-icon>

            <div class="invite-info">
                <div class="invite-email ellipsis">${inv.email}</div>

                <div class="tags small">
                    <div class="tag ${status.class}">
                        <pl-icon icon="${status.icon}"></pl-icon>

                        <div>${(0,lit_html_directives_until__WEBPACK_IMPORTED_MODULE_0__.until)(status.text)}</div>
                    </div>
                </div>
            </div>

            <pl-loading-button
                class="tap primary confirm-button"
                ?hidden=${!inv.accepted || inv.expired}
                @click=${this._confirm}
            >
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Confirm")}
            </pl-loading-button>

            <div class="invite-code" ?hidden=${inv.accepted || inv.expired}>
                <div class="invite-code-label">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_2__.translate)("Confirmation Code:")}</div>

                <div class="invite-code-value">${(0,lit_html_directives_until__WEBPACK_IMPORTED_MODULE_0__.until)(secret)}</div>
            </div>
        `;
    }
};
InviteItem.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_4__.shared,
    _base__WEBPACK_IMPORTED_MODULE_7__.css `
            :host {
                display: flex;
                align-items: center;
                padding: 4px 0;
            }

            .icon {
                font-size: 120%;
                margin: 10px;
                background: #eee;
                border: solid 1px #ddd;
                width: 45px;
                height: 45px;
            }

            .tags {
                margin: 4px 0;
            }

            .invite-info {
                flex: 1;
                width: 0;
            }

            .invite:hover {
                background: #fafafa;
            }

            .invite .tags {
                padding: 0;
                margin: 0;
            }

            .invite-email {
                font-weight: bold;
                margin-bottom: 4px;
            }

            .invite-code {
                text-align: center;
                margin: 12px;
            }

            .invite-code-label {
                font-weight: bold;
                font-size: var(--font-size-micro);
            }

            .invite-code-value {
                font-size: 140%;
                font-family: var(--font-family-mono);
                font-weight: bold;
                text-transform: uppercase;
                cursor: text;
                user-select: text;
                letter-spacing: 2px;
            }

            .confirm-button {
                padding: 6px 8px;
                margin: 12px;
                font-size: var(--font-size-small);
                align-self: center;
            }

            @media (max-width: 400px) {
                .invite-code {
                    display: none;
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.property)(),
    __metadata("design:type", _padloc_core_src_invite__WEBPACK_IMPORTED_MODULE_1__.Invite)
], InviteItem.prototype, "invite", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)(".confirm-button"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_8__.LoadingButton)
], InviteItem.prototype, "_confirmButton", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-member-dialog"),
    __metadata("design:type", _member_dialog__WEBPACK_IMPORTED_MODULE_9__.MemberDialog)
], InviteItem.prototype, "_memberDialog", void 0);
InviteItem = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.element)("pl-invite-item")
], InviteItem);



/***/ }),

/***/ "../app/src/elements/item-dialog.ts":
/*!******************************************!*\
  !*** ../app/src/elements/item-dialog.ts ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ItemDialog": () => (/* binding */ ItemDialog)
/* harmony export */ });
/* harmony import */ var lit_html_directives_until__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/until */ "../app/node_modules/lit-html/directives/until.js");
/* harmony import */ var lit_html_directives_repeat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lit-html/directives/repeat */ "../app/node_modules/lit-html/directives/repeat.js");
/* harmony import */ var _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/item */ "../core/src/item.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_otp__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @padloc/core/src/otp */ "../core/src/otp.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_clipboard__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../lib/clipboard */ "../app/src/lib/clipboard.ts");
/* harmony import */ var _lib_animation__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../lib/animation */ "../app/src/lib/animation.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _tags_input__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tags-input */ "../app/src/elements/tags-input.ts");
/* harmony import */ var _move_items_dialog__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./move-items-dialog */ "../app/src/elements/move-items-dialog.ts");
/* harmony import */ var _field__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./field */ "../app/src/elements/field.ts");
/* harmony import */ var _generator__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./generator */ "../app/src/elements/generator.ts");
/* harmony import */ var _attachment_dialog__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./attachment-dialog */ "../app/src/elements/attachment-dialog.ts");
/* harmony import */ var _upload_dialog__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./upload-dialog */ "../app/src/elements/upload-dialog.ts");
/* harmony import */ var _qr_dialog__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./qr-dialog */ "../app/src/elements/qr-dialog.ts");
/* harmony import */ var _field_type_dialog__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./field-type-dialog */ "../app/src/elements/field-type-dialog.ts");
/* harmony import */ var _view__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./view */ "../app/src/elements/view.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};























let ItemDialog = class ItemDialog extends _dialog__WEBPACK_IMPORTED_MODULE_11__.Dialog {
    constructor() {
        super(...arguments);
        this.itemId = "";
        this.isNew = false;
        this._editing = false;
        this._fields = [];
        this._draggingIndex = -1;
        this._dragOverIndex = -1;
    }
    get _item() {
        const found = (this.itemId && _globals__WEBPACK_IMPORTED_MODULE_7__.app.getItem(this.itemId)) || null;
        return found && found.item;
    }
    get _vault() {
        const found = (this.itemId && _globals__WEBPACK_IMPORTED_MODULE_7__.app.getItem(this.itemId)) || null;
        return found && found.vault;
    }
    async show(itemId) {
        this._editing = false;
        this.itemId = itemId;
        await this.updateComplete;
        this._itemChanged();
        // Workaround for weird bug where name input is sometimes empty after opening dialog
        setTimeout(() => this._itemChanged(), 200);
        const promise = super.show();
        await this.updateComplete;
        (0,_lib_animation__WEBPACK_IMPORTED_MODULE_9__.animateCascade)(this.$$(".content > *"));
        return promise;
    }
    async addAttachment() {
        await this.updateComplete;
        if (this._vault.id === _globals__WEBPACK_IMPORTED_MODULE_7__.app.mainVault.id && !_globals__WEBPACK_IMPORTED_MODULE_7__.app.account.quota.storage && _globals__WEBPACK_IMPORTED_MODULE_7__.app.billingEnabled) {
            this.dispatch("get-premium", {
                message: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Upgrade to Premium now and get 1GB of encrypted file storage!"),
                icon: "storage"
            });
            this.done();
            return;
        }
        this._fileInput.click();
    }
    dismiss() {
        super.dismiss();
        _globals__WEBPACK_IMPORTED_MODULE_7__.router.go("items");
    }
    done() {
        super.done();
        this.itemId = "";
        this._itemChanged();
    }
    renderContent() {
        if (_globals__WEBPACK_IMPORTED_MODULE_7__.app.state.locked || !this._item || !this._vault) {
            return _base__WEBPACK_IMPORTED_MODULE_10__.html ``;
        }
        const { updated, updatedBy } = this._item;
        const vault = this._vault;
        const org = vault.org && _globals__WEBPACK_IMPORTED_MODULE_7__.app.getOrg(vault.org.id);
        const readonly = !_globals__WEBPACK_IMPORTED_MODULE_7__.app.hasWritePermissions(vault);
        const updatedByMember = org && org.getMember({ id: updatedBy });
        const attachments = this._item.attachments || [];
        const isFavorite = _globals__WEBPACK_IMPORTED_MODULE_7__.app.account.favorites.has(this.itemId);
        return _base__WEBPACK_IMPORTED_MODULE_10__.html `
            <header>
                <pl-icon icon="close" class="tap close-icon" @click=${this.dismiss} ?hidden=${this._editing}></pl-icon>
                <pl-input
                    id="nameInput"
                    class="name flex"
                    .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Enter Item Name")}
                    ?readonly=${!this._editing}
                >
                </pl-input>
                <pl-icon
                    icon="favorite"
                    class="favorite"
                    ?active=${isFavorite}
                    @click=${() => this._setFavorite(!isFavorite)}
                ></pl-icon>
            </header>

            <div class="content">
                <pl-tags-input .editing=${this._editing} .vault=${this._vault} @move=${this._move}></pl-tags-input>

                ${(0,lit_html_directives_repeat__WEBPACK_IMPORTED_MODULE_1__.repeat)(this._fields, field => `${this.itemId}_${field.name}_${field.type}`, (field, index) => _base__WEBPACK_IMPORTED_MODULE_10__.html `
                        <pl-field
                            class="item"
                            .name=${field.name}
                            .value=${field.value}
                            .type=${field.type}
                            .editing=${this._editing}
                            @edit=${() => this._editField(index)}
                            @copy-clipboard=${() => (0,_lib_clipboard__WEBPACK_IMPORTED_MODULE_8__.setClipboard)(this._item, field)}
                            @remove=${() => this._removeField(index)}
                            @generate=${() => this._generateValue(index)}
                            @get-totp-qr=${() => this._getTotpQR(index)}
                            @dragstart=${(e) => this._dragstart(e, index)}
                            @dragenter=${(e) => this._dragenter(e, index)}
                            @dragover=${(e) => this._dragover(e)}
                            @dragend=${(e) => this._dragend(e)}
                            @drop=${(e) => this._drop(e)}
                        >
                        </pl-field>
                    `)}
                ${attachments.map(a => _base__WEBPACK_IMPORTED_MODULE_10__.html `
                        <div
                            class="attachment item ${this._editing ? "" : "tap"}"
                            @click=${() => this._openAttachment(a)}
                        >
                            <pl-icon icon=${(0,_lib_util__WEBPACK_IMPORTED_MODULE_5__.fileIcon)(a.type)} class="file-icon" ?hidden=${this._editing}></pl-icon>
                            <pl-icon
                                icon="remove"
                                class="attachment-remove tap"
                                ?hidden=${!this._editing}
                                @click=${() => this._deleteAttachment(a)}
                            ></pl-icon>
                            <div class="attachment-body">
                                <div class="attachment-name ellipsis">${a.name}</div>
                                <div class="attachment-size">${(0,_lib_util__WEBPACK_IMPORTED_MODULE_5__.fileSize)(a.size)}</div>
                            </div>
                        </div>
                    `)}

                <div class="actions" ?hidden=${!this._editing}>
                    <button class="icon tap" @click=${() => this._addField()}>
                        <pl-icon icon="add"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Field")}</div>
                    </button>

                    <button class="icon tap" @click=${this.addAttachment}>
                        <pl-icon icon="attachment"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Attachment")}</div>
                    </button>

                    <button class="icon tap" @click=${this._move}>
                        <pl-icon icon="share"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Move")}</div>
                    </button>

                    <button class="icon tap negative" @click=${this._deleteItem} ?hidden=${this.isNew}>
                        <pl-icon icon="delete"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Delete")}</div>
                    </button>
                </div>

                <div class="updated">
                    ${(0,lit_html_directives_until__WEBPACK_IMPORTED_MODULE_0__.until)((0,_lib_util__WEBPACK_IMPORTED_MODULE_5__.formatDateFromNow)(updated))}
                    ${updatedByMember && " " + (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("by {0}", updatedByMember.email)}
                </div>
            </div>

            <div class="fabs" ?hidden=${this._editing}>
                <div class="flex"></div>

                <pl-icon icon="edit" class="tap fab" @click=${() => this.edit()} ?disabled=${readonly}> </pl-icon>
            </div>

            <div class="fabs" ?hidden=${!this._editing}>
                <button class="primary icon fab tap save-button" @click=${this.save}>
                    <pl-icon icon="check"></pl-icon>
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Save")}</div>
                </button>

                <div class="spacer"></div>

                <button class="icon fab tap cancel-button" @click=${this.cancelEdit}>
                    <pl-icon icon="cancel"></pl-icon>
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Cancel")}</div>
                </button>
            </div>

            <input type="file" hidden @change=${this._attachFile} />
        `;
    }
    async edit() {
        if (!_globals__WEBPACK_IMPORTED_MODULE_7__.app.hasWritePermissions(this._vault)) {
            return;
        }
        this._editing = true;
        await this.updateComplete;
        setTimeout(() => this._nameInput.focus(), 100);
    }
    async cancelEdit() {
        if (this.isNew) {
            _globals__WEBPACK_IMPORTED_MODULE_7__.app.deleteItems([this._item]);
            this.dismiss();
        }
        else {
            this._fields = this._getFields();
            await this.updateComplete;
            this._editing = false;
            this._itemChanged();
        }
        this.isNew = false;
    }
    save() {
        _globals__WEBPACK_IMPORTED_MODULE_7__.app.updateItem(this._item, {
            name: this._nameInput.value,
            fields: this._getFields(),
            tags: this._tagsInput.tags
        });
        this._editing = false;
        this._itemChanged();
        this.isNew = false;
    }
    _editingChanged() {
        this.dismissOnTapOutside = !this._editing;
    }
    _getFields() {
        return [...this._fieldInputs].map((fieldEl) => {
            return new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_2__.Field({
                name: fieldEl.name,
                value: fieldEl.value,
                type: fieldEl.type
            });
        });
    }
    _itemChanged() {
        if (this._item) {
            this._nameInput.value = this._item.name;
            this._fields = this._item.fields.map(f => new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_2__.Field({ ...f }));
            this._tagsInput.tags = [...this._item.tags];
        }
        else {
            this._nameInput.value = "";
            this._fields = [];
            this._tagsInput.tags = [];
        }
    }
    _removeField(index) {
        this._fields = this._fields.filter((_, i) => i !== index);
    }
    async _deleteItem() {
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Are you sure you want to delete this item?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Delete"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Cancel"), {
            type: "destructive"
        });
        if (confirmed) {
            _globals__WEBPACK_IMPORTED_MODULE_7__.app.deleteItems([this._item]);
            _globals__WEBPACK_IMPORTED_MODULE_7__.router.go("items");
        }
        else {
            this.open = true;
        }
    }
    async _addField() {
        this.open = false;
        const fieldDef = await this._fieldTypeDialog.show();
        this.open = true;
        if (!fieldDef) {
            return;
        }
        this._fields.push(new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_2__.Field({ name: fieldDef.name, value: "", type: fieldDef.type }));
        this.requestUpdate();
        await this.updateComplete;
        setTimeout(() => this._fieldInputs[this._fields.length - 1].focus(), 100);
    }
    async _move() {
        if (!_globals__WEBPACK_IMPORTED_MODULE_7__.app.hasWritePermissions(this._vault)) {
            return;
        }
        this.open = false;
        if (this._item.attachments.length) {
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Items with attachments cannot be moved!"), { type: "warning" });
        }
        else {
            const movedItems = await this._moveItemsDialog.show([{ item: this._item, vault: this._vault }]);
            if (movedItems && movedItems.length) {
                _globals__WEBPACK_IMPORTED_MODULE_7__.router.go(`items/${movedItems[0].id}`);
            }
        }
        this.open = true;
    }
    async _editField(index) {
        if (!_globals__WEBPACK_IMPORTED_MODULE_7__.app.hasWritePermissions(this._vault)) {
            return;
        }
        this._editing = true;
        await this.updateComplete;
        this._fieldInputs[index].focus();
    }
    async _generateValue(index) {
        this.open = false;
        const value = await this._generator.show();
        this.open = true;
        if (value) {
            this._fields[index].value = value;
        }
    }
    async _attachFile() {
        const file = this._fileInput.files[0];
        this._fileInput.value = "";
        if (!file) {
            return;
        }
        if (file.size > 5e6) {
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("The selected file is too large! Only files of up to 5 MB are supported."), {
                type: "warning"
            });
            return;
        }
        this.open = false;
        const att = await this._uploadDialog.show({ item: this.itemId, file });
        if (att) {
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("File uploaded successfully!"), { type: "success" });
        }
        this.open = true;
    }
    async _openAttachment(info) {
        if (this._editing) {
            return;
        }
        this.open = false;
        await this._attachmentDialog.show({ item: this.itemId, info });
        this.open = true;
    }
    async _getTotpQR(index) {
        this.open = false;
        const data = await this._qrDialog.show();
        if (data) {
            try {
                const { secret } = (0,_padloc_core_src_otp__WEBPACK_IMPORTED_MODULE_4__.parseURL)(data);
                this._fields[index].value = secret;
            }
            catch (e) {
                await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.alert)("Invalid Code! Please try again!", { type: "warning" });
                return this._getTotpQR(index);
            }
        }
        this.open = true;
    }
    _setFavorite(favorite) {
        _globals__WEBPACK_IMPORTED_MODULE_7__.app.toggleFavorite(this.itemId, favorite);
        this.requestUpdate();
    }
    async _deleteAttachment(a) {
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Are you sure you want to delete this attachment?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Delete"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Cancel"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Delete Attachment"),
            type: "destructive"
        });
        this.open = true;
        if (confirmed) {
            await _globals__WEBPACK_IMPORTED_MODULE_7__.app.deleteAttachment(this.itemId, a);
            this.requestUpdate();
        }
    }
    _drop(e) {
        // console.log("drop", e, this._draggingIndex, this._dragOverIndex);
        e.preventDefault();
        e.stopPropagation();
        return false;
    }
    async _dragstart(event, index) {
        // console.log("dragstart", event);
        this._draggingIndex = index;
        this.dispatch("field-dragged", { item: this._item, index, event });
        event.target.classList.add("dragging");
        this.classList.add("dragging");
    }
    _dragenter(e, index) {
        // console.log("dragenter", e);
        e.dataTransfer.dropEffect = "move";
        this._dragOverIndex = index;
        for (const [i, field] of this._fieldInputs.entries()) {
            field.classList.toggle("dragover", i === index && i !== this._draggingIndex && i !== this._draggingIndex - 1);
        }
    }
    _dragover(e) {
        e.preventDefault();
    }
    _dragend(_e) {
        // console.log("dragend", e, this._draggingIndex, this._dragOverIndex);
        if (this._draggingIndex !== -1 || this._dragOverIndex !== -1) {
            const field = this._fields[this._draggingIndex];
            this._fields.splice(this._draggingIndex, 1);
            const targetIndex = this._dragOverIndex >= this._draggingIndex ? this._dragOverIndex : this._dragOverIndex + 1;
            this._fields.splice(targetIndex, 0, field);
            this.requestUpdate();
        }
        for (const field of this._fieldInputs) {
            field.classList.remove("dragging");
            field.classList.remove("dragover");
        }
        this.classList.remove("dragging");
        this._dragOverIndex = -1;
        this._draggingIndex = -1;
    }
};
ItemDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_11__.Dialog.styles,
    ..._view__WEBPACK_IMPORTED_MODULE_22__.View.styles,
    _base__WEBPACK_IMPORTED_MODULE_10__.css `
            .inner {
                max-width: 500px;
                background: var(--color-quaternary);
                display: flex;
                flex-direction: column;
                min-height: 500px;
                max-height: 100%;
            }

            .content {
                padding-bottom: 50px;
            }

            .content > * {
                margin: 12px;
            }

            .name {
                padding: 0 8px;
                margin: 0 8px;
                line-height: 40px;
                text-align: center;
            }

            :host([editing]) .name {
                border: dashed 1px var(--color-shade-3);
                text-align: left;
            }

            pl-field {
                position: relative;
            }

            .content > pl-tags-input {
                margin: 12px 16px;
            }

            :host(:not([editing])) pl-field:hover {
                background: #eee;
            }

            .updated {
                text-align: center;
                font-size: var(--font-size-tiny);
                color: var(--color-shade-4);
                font-weight: 600;
                margin: 30px;
            }

            .updated::before {
                font-family: FontAwesome;
                font-size: 80%;
                content: "\\f303";
                display: inline-block;
                margin-right: 4px;
            }

            .attachment {
                display: flex;
                align-items: center;
                padding: 12px;
                margin: 12px;
            }

            .attachment-body {
                flex: 1;
                width: 0;
            }

            .attachment .file-icon {
                font-size: 150%;
                margin: 0 4px 0 -4px;
            }

            .attachment-name {
                font-size: var(--font-size-small);
                font-weight: bold;
                line-height: 1.5em;
            }

            .attachment-size {
                font-size: var(--font-size-tiny);
            }

            .attachment-remove {
                margin: 0 8px 0 -8px;
            }

            .favorite {
                color: var(--color-secondary);
                opacity: 0.3;
                cursor: pointer;
                transition: transform 0.2s cubic-bezier(0.05, 0.7, 0.03, 3) 0s;
                transform: scale(0.9);
            }

            .favorite:hover {
                opacity: 0.6;
            }

            .favorite[active] {
                color: var(--color-negative);
                opacity: 1;
                transform: scale(1);
            }

            .editing {
                text-align: center;
                padding: 8px;
                margin: 0 0 0 12px;
                box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
                border-radius: var(--border-radius);
                background: rgba(255, 255, 255, 0.9);
            }

            .actions {
                grid-template-columns: 1fr 1fr;
            }

            .actions > button {
                font-size: var(--font-size-small);
                background: none;
                padding: 10px 8px 10px 0;
                border: dashed 1px;
                font-weight: bold;
            }

            .actions > button.negative {
                color: var(--color-negative);
                border-color: var(--color-negative);
            }

            .save-button,
            .cancel-button {
                flex: 1;
                max-width: 200px;
                min-width: 120px;
            }

            :host(.dragging) .content > * {
                will-change: transform;
                transition: transform 0.2s;
            }

            pl-field.dragover::after {
                content: "";
                display: block;
                height: 30px;
                border: dashed 2px var(--color-primary);
                width: 100%;
                box-sizing: border-box;
                position: absolute;
                bottom: -45px;
                border-radius: var(--border-radius);
            }

            pl-field.dragover ~ * {
                transform: translate3d(0, 40px, 0);
            }

            @media (max-width: 700px) {
                .outer {
                    padding: 0;
                }

                .inner {
                    border-radius: 0;
                    max-width: 100%;
                    width: 100%;
                    height: 100%;
                }

                .scrim {
                    display: none;
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.property)(),
    __metadata("design:type", String)
], ItemDialog.prototype, "itemId", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.property)(),
    __metadata("design:type", Boolean)
], ItemDialog.prototype, "isNew", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.property)({ reflect: true, attribute: "editing" }),
    __metadata("design:type", Boolean)
], ItemDialog.prototype, "_editing", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.property)(),
    __metadata("design:type", Array)
], ItemDialog.prototype, "_fields", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.query)("#nameInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_13__.Input)
], ItemDialog.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.query)("pl-tags-input"),
    __metadata("design:type", _tags_input__WEBPACK_IMPORTED_MODULE_14__.TagsInput)
], ItemDialog.prototype, "_tagsInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.queryAll)("pl-field"),
    __metadata("design:type", Array)
], ItemDialog.prototype, "_fieldInputs", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.query)("input[type='file']"),
    __metadata("design:type", HTMLInputElement)
], ItemDialog.prototype, "_fileInput", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-move-items-dialog"),
    __metadata("design:type", _move_items_dialog__WEBPACK_IMPORTED_MODULE_15__.MoveItemsDialog)
], ItemDialog.prototype, "_moveItemsDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-generator"),
    __metadata("design:type", _generator__WEBPACK_IMPORTED_MODULE_17__.Generator)
], ItemDialog.prototype, "_generator", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-attachment-dialog"),
    __metadata("design:type", _attachment_dialog__WEBPACK_IMPORTED_MODULE_18__.AttachmentDialog)
], ItemDialog.prototype, "_attachmentDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-upload-dialog"),
    __metadata("design:type", _upload_dialog__WEBPACK_IMPORTED_MODULE_19__.UploadDialog)
], ItemDialog.prototype, "_uploadDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-qr-dialog"),
    __metadata("design:type", _qr_dialog__WEBPACK_IMPORTED_MODULE_20__.QRDialog)
], ItemDialog.prototype, "_qrDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-field-type-dialog"),
    __metadata("design:type", _field_type_dialog__WEBPACK_IMPORTED_MODULE_21__.FieldTypeDialog)
], ItemDialog.prototype, "_fieldTypeDialog", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.observe)("_editing"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], ItemDialog.prototype, "_editingChanged", null);
ItemDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_10__.element)("pl-item-dialog")
], ItemDialog);



/***/ }),

/***/ "../app/src/elements/items-filter.ts":
/*!*******************************************!*\
  !*** ../app/src/elements/items-filter.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ItemsFilter": () => (/* binding */ ItemsFilter)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





let ItemsFilter = class ItemsFilter extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_1__.StateMixin)(_base__WEBPACK_IMPORTED_MODULE_4__.BaseElement) {
    constructor() {
        super(...arguments);
        this.vault = "";
        this.tag = "";
        this.favorites = false;
        this.attachments = false;
        this.recent = false;
        this.host = "";
        this.searching = false;
        this._selecting = false;
    }
    render() {
        if (!_globals__WEBPACK_IMPORTED_MODULE_3__.app.mainVault || !_globals__WEBPACK_IMPORTED_MODULE_3__.app.account) {
            return _base__WEBPACK_IMPORTED_MODULE_4__.html ``;
        }
        const { vault: vaultId, tag, favorites, attachments, recent, host } = this;
        const vault = _globals__WEBPACK_IMPORTED_MODULE_3__.app.getVault(vaultId);
        const cl = favorites
            ? "favorites"
            : recent
                ? "recent"
                : vault
                    ? "vault"
                    : attachments
                        ? "attachments"
                        : tag
                            ? "filter-tag"
                            : host
                                ? "host"
                                : "all";
        const label = favorites
            ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Favorites")
            : recent
                ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Recently Used")
                : attachments
                    ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Attachments")
                    : host
                        ? this.state.currentHost
                        : vault
                            ? vault.name
                            : tag || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("All Items");
        const count = _globals__WEBPACK_IMPORTED_MODULE_3__.app.count;
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <button class="tap ${cl}" @click=${() => (this._selecting = !this._selecting)}>
                <pl-icon icon="search" class="search-icon" ?hidden=${!this.searching}></pl-icon>

                <div>${label}</div>

                <pl-icon icon="dropdown"></pl-icon>
            </button>

            <div class="scrim" @click=${() => this._dismiss()}>
                <div class="list ${cl}">
                    <button class="host tap" @click=${() => this._select({ host: true })} ?hidden=${!count.currentHost}>
                        <pl-icon icon="web"></pl-icon>
                        <div>
                            ${this.state.currentHost}
                        </div>
                        <div class="count">${count.currentHost}</div>
                    </button>

                    <button class="all tap" @click=${() => this._select({})}>
                        <pl-icon icon="list"></pl-icon>
                        <div>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("All Items")}
                        </div>
                        <div class="count">${count.total}</div>
                    </button>

                    <button class="recent tap" @click=${() => this._select({ recent: true })}>
                        <pl-icon icon="time"></pl-icon>
                        <div>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Recently Used")}
                        </div>
                        <div class="count">${count.recent}</div>
                    </button>

                    <button class="attachments tap" @click=${() => this._select({ attachments: true })}>
                        <pl-icon icon="attachment"></pl-icon>
                        <div>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Attachments")}
                        </div>
                        <div class="count">${count.attachments}</div>
                    </button>

                    <button class="favorites tap" @click=${() => this._select({ favorites: true })}>
                        <pl-icon icon="favorite"></pl-icon>
                        <div>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Favorites")}
                        </div>
                        <div class="count">${count.favorites}</div>
                    </button>

                    <button class="vault tap" @click=${() => this._select({ vault: _globals__WEBPACK_IMPORTED_MODULE_3__.app.mainVault.id })}>
                        <pl-icon icon="vault"></pl-icon>
                        <div>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("My Vault")}
                        </div>
                        <div class="count">${_globals__WEBPACK_IMPORTED_MODULE_3__.app.mainVault.items.size}</div>
                    </button>

                    ${_globals__WEBPACK_IMPORTED_MODULE_3__.app.orgs.map(org => {
            const vaults = _globals__WEBPACK_IMPORTED_MODULE_3__.app.vaults.filter(v => v.org && v.org.id === org.id);
            return _base__WEBPACK_IMPORTED_MODULE_4__.html `
                            <h4>${org.name}</h4>

                            ${vaults.map(vault => _base__WEBPACK_IMPORTED_MODULE_4__.html `
                                    <button class="vault tap" @click=${() => this._select({ vault: vault.id })}>
                                        <pl-icon icon="vault"></pl-icon>
                                        <div>
                                            ${vault.name}
                                        </div>
                                        <div class="count">${vault.items.size}</div>
                                    </button>
                                `)}
                        `;
        })}

                    <h4>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Tags")}</h4>

                    <div class="no-tags" ?hidden=${!!this.state.tags.length}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You don't have any tags yet.")}
                    </div>

                    ${_globals__WEBPACK_IMPORTED_MODULE_3__.app.state.tags.map(([tag, count]) => _base__WEBPACK_IMPORTED_MODULE_4__.html `
                            <button class="filter-tag tap" @click=${() => this._select({ tag })}>
                                <pl-icon icon="tag"></pl-icon>
                                <div>
                                    ${tag}
                                </div>
                                <div class="count">${count}</div>
                            </button>
                        `)}
                </div>
            </div>
        `;
    }
    _select({ tag, vault, favorites, recent, attachments, host }) {
        const params = {};
        if (tag) {
            params.tag = tag;
        }
        if (vault) {
            params.vault = vault;
        }
        if (favorites) {
            params.favorites = favorites;
        }
        if (attachments) {
            params.attachments = attachments;
        }
        if (recent) {
            params.recent = recent;
        }
        if (host) {
            params.host = host;
        }
        _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("items", params);
    }
    _dismiss() {
        this._selecting = false;
    }
};
ItemsFilter.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_2__.shared,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            :host {
                display: block;
                text-align: center;
                overflow: visible;
            }

            button {
                display: flex;
                margin: 0 auto;
                align-items: center;
                font-weight: bold;
                padding: 6px 12px;
                border-radius: 20px;
                line-height: normal;
                box-sizing: border-box;
                overflow: hidden;
                max-width: 100%;
                background: var(--color-shade-1);
                border-bottom: solid 2px var(--color-shade-2);
                margin-bottom: -2px;
                font-size: var(--font-size-small);
            }

            button.vault {
                background: var(--color-primary);
                color: var(--color-tertiary);
                text-shadow: rgba(0, 0, 0, 0.2) 0 2px 0;
                border-bottom: solid 2px var(--color-shade-4);
            }

            button.filter-tag {
                background: var(--color-secondary);
                color: var(--color-tertiary);
                text-shadow: rgba(0, 0, 0, 0.2) 0 2px 0;
                border-bottom: solid 2px #222;
            }

            button.favorites,
            button.host {
                background: var(--color-negative);
                color: var(--color-tertiary);
                text-shadow: rgba(0, 0, 0, 0.2) 0 2px 0;
                border-bottom: solid 2px var(--color-shade-4);
            }

            button pl-icon {
                font-size: 85%;
                width: 20px;
                height: 20px;
                margin-right: -6px;
            }

            button pl-icon.search-icon {
                margin-right: 3px;
                margin-left: -4px;
            }

            .list pl-icon {
                margin-left: -4px;
                margin-right: 2px;
                margin-top: 1px;
                font-size: 80%;
                width: 25px;
            }

            button > div,
            .option > div {
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.ellipsis()}
            }

            .scrim {
                z-index: 10;
                border-top: solid 3px #f2f2f2;
                background: rgba(255, 255, 255, 0.5);
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.fullbleed()}
                top: 60px;
                will-change: opacity;
                transition: opacity 200ms cubic-bezier(0.6, 0, 0.2, 1);
            }

            :host(:not([selecting])) .scrim {
                opacity: 0;
                pointer-events: none;
            }

            :host(:not([selecting])) .list {
                transform: translate3d(0, -100%, 0);
            }

            .list {
                padding: 12px 6px 6px 6px;
                background: var(--color-tertiary);
                box-sizing: border-box;
                max-height: 100%;
                width: 100%;
                font-size: var(--font-size-tiny);
                border-bottom: solid 3px var(--color-shade-1);
                will-change: transform;
                transition: transform 200ms cubic-bezier(0.6, 0, 0.2, 1);
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.scroll()}
            }

            .list button {
                margin-bottom: 6px;
                border-bottom: none;
                padding: 5px 10px;
                text-shadow: none;
            }

            h4 {
                margin: 16px 10px 10px 10px;
                text-align: center;
                opacity: 0.8;
            }

            .no-tags {
                font-size: var(--font-size-micro);
                padding: 5px 10px 15px 10px;
                opacity: 0.5;
            }

            .count {
                opacity: 0.7;
                margin-left: 6px;
                margin-right: 2px;
                font-size: var(--font-size-tiny);
            }

            @supports (-webkit-overflow-scrolling: touch) {
                .scrim {
                    top: calc(50px + max(env(safe-area-inset-top), 8px));
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", String)
], ItemsFilter.prototype, "vault", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", String)
], ItemsFilter.prototype, "tag", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Boolean)
], ItemsFilter.prototype, "favorites", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Boolean)
], ItemsFilter.prototype, "attachments", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Boolean)
], ItemsFilter.prototype, "recent", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", String)
], ItemsFilter.prototype, "host", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Boolean)
], ItemsFilter.prototype, "searching", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)({ reflect: true, attribute: "selecting" }),
    __metadata("design:type", Boolean)
], ItemsFilter.prototype, "_selecting", void 0);
ItemsFilter = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-items-filter")
], ItemsFilter);



/***/ }),

/***/ "../app/src/elements/items-list.ts":
/*!*****************************************!*\
  !*** ../app/src/elements/items-list.ts ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ItemsList": () => (/* binding */ ItemsList)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/util */ "../core/src/util.ts");
/* harmony import */ var lit_html_directives_cache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lit-html/directives/cache */ "../app/node_modules/lit-html/directives/cache.js");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _lib_clipboard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/clipboard */ "../app/src/lib/clipboard.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _view__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./view */ "../app/src/elements/view.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _move_items_dialog__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./move-items-dialog */ "../app/src/elements/move-items-dialog.ts");
/* harmony import */ var _attachment_dialog__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./attachment-dialog */ "../app/src/elements/attachment-dialog.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _items_filter__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./items-filter */ "../app/src/elements/items-filter.ts");
/* harmony import */ var _virtual_list__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtual-list */ "../app/src/elements/virtual-list.ts");
/* harmony import */ var _totp__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./totp */ "../app/src/elements/totp.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};


















function filterByString(fs, rec) {
    if (!fs) {
        return true;
    }
    const content = [rec.name, ...rec.tags, ...rec.fields.map(f => f.name), ...rec.fields.map(f => f.value)]
        .join(" ")
        .toLowerCase();
    return content.search((0,_padloc_core_src_util__WEBPACK_IMPORTED_MODULE_1__.escapeRegex)(fs.toLowerCase())) !== -1;
}
let ItemsList = class ItemsList extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_3__.StateMixin)(_view__WEBPACK_IMPORTED_MODULE_10__.View) {
    constructor() {
        super(...arguments);
        this.selected = "";
        this.multiSelect = false;
        this.vault = "";
        this.tag = "";
        this.favorites = false;
        this.attachments = false;
        this.recent = false;
        this.host = false;
        this._listItems = [];
        this._filterShowing = false;
        this._cachedBounds = null;
        this._multiSelect = new Map();
        this._updateItems = (0,_padloc_core_src_util__WEBPACK_IMPORTED_MODULE_1__.debounce)(() => {
            this._listItems = this._getItems();
        }, 50);
    }
    async stateChanged() {
        // Clear items from selection that are no longer in list (due to filtering)
        for (const id of this._multiSelect.keys()) {
            if (!this._listItems.some(i => i.item.id === id)) {
                this._multiSelect.delete(id);
            }
        }
        // When the app is getting locked, give the lock animation some time to finish
        if (this._listItems.length && this.state.locked) {
            await (0,_padloc_core_src_util__WEBPACK_IMPORTED_MODULE_1__.wait)(500);
        }
        this._updateItems();
    }
    async search() {
        this._filterShowing = true;
        await this.updateComplete;
        this._filterInput.focus();
    }
    cancelFilter() {
        this._filterInput.value = "";
        this._filterInput.blur();
        this._filterShowing = false;
        this._updateItems();
    }
    selectItem(item) {
        if (this.multiSelect) {
            if (this._multiSelect.has(item.item.id)) {
                this._multiSelect.delete(item.item.id);
            }
            else {
                this._multiSelect.set(item.item.id, item);
            }
            this.requestUpdate();
        }
        else {
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go(`items/${item.item.id}`);
        }
    }
    selectAll() {
        this.multiSelect = true;
        for (const item of this._listItems) {
            this._multiSelect.set(item.item.id, item);
        }
        this.requestUpdate();
    }
    clearSelection() {
        this._multiSelect.clear();
        this.requestUpdate();
    }
    cancelMultiSelect() {
        this._multiSelect.clear();
        this.multiSelect = false;
        this.requestUpdate();
    }
    firstUpdated() {
        this._resizeHandler();
    }
    render() {
        const placeholder = this._listItems.length
            ? {}
            : this._filterShowing
                ? {
                    icon: "search",
                    text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Your search did not match any items.")
                }
                : this.vault
                    ? {
                        icon: "vault",
                        text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This vault does not have any items yet.")
                    }
                    : this.attachments
                        ? {
                            icon: "attachment",
                            text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You don't have any attachments yet.")
                        }
                        : this.favorites
                            ? {
                                icon: "favorite",
                                text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You don't have any favorites yet.")
                            }
                            : this.recent
                                ? {
                                    icon: "time",
                                    text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You don't have any recently used items!")
                                }
                                : {
                                    icon: "list",
                                    text: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You don't have any items yet.")
                                };
        return _base__WEBPACK_IMPORTED_MODULE_9__.html `
            <header>
                <pl-icon
                    icon="menu"
                    class="tap menu-button"
                    @click=${() => this.dispatch("toggle-menu")}
                    ?hidden=${this._filterShowing}
                ></pl-icon>

                <div class="spacer" ?hidden=${this._filterShowing}></div>

                <pl-items-filter
                    .vault=${this.vault}
                    .tag=${this.tag}
                    .favorites=${this.favorites}
                    .recent=${this.recent}
                    .host=${this.host}
                    .attachments=${this.attachments}
                    .searching=${this._filterShowing}
                ></pl-items-filter>

                <div class="spacer" ?hidden=${this._filterShowing}></div>

                <pl-input
                    class="flex"
                    .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Type To Search")}
                    id="filterInput"
                    select-on-focus
                    @input=${this._updateItems}
                    @escape=${this.cancelFilter}
                    ?hidden=${!this._filterShowing}
                >
                </pl-input>

                <pl-icon
                    icon="search"
                    class="tap"
                    @click=${() => this.search()}
                    ?hidden=${this._filterShowing}
                ></pl-icon>

                <pl-icon
                    class="tap"
                    icon="cancel"
                    @click=${() => this.cancelFilter()}
                    ?hidden=${!this._filterShowing}
                ></pl-icon>
            </header>

            <main id="main">
                <pl-virtual-list
                    .data=${this._listItems}
                    .minItemWidth=${300}
                    .itemHeight=${111}
                    .renderItem=${(item) => this._renderItem(item)}
                    .guard=${({ item, vault }) => [
            item.name,
            item.tags,
            item.fields,
            vault,
            item.id === this.selected,
            this.multiSelect,
            this._multiSelect.has(item.id)
        ]}
                ></pl-virtual-list>
            </main>

            <div class="empty-placeholder" ?hidden=${!placeholder.text}>
                <pl-icon icon="${placeholder.icon}"></pl-icon>

                <div>${placeholder.text}</div>
            </div>

            <div class="fabs" ?hidden=${this.multiSelect}>
                <pl-icon icon="checked" class="tap fab" @click=${() => (this.multiSelect = true)}></pl-icon>

                <div class="flex"></div>

                <pl-icon icon="add" class="tap fab primary" @click=${() => this.dispatch("create-item")}></pl-icon>
            </div>

            <div class="fabs" ?hidden=${!this.multiSelect}>
                <pl-icon
                    icon="checkall"
                    class="tap fab"
                    @click=${() => (this._multiSelect.size ? this.clearSelection() : this.selectAll())}
                >
                </pl-icon>

                <pl-icon icon="cancel" class="tap fab" @click=${() => this.cancelMultiSelect()}></pl-icon>

                <div class="flex selected-count">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} items selected", this._multiSelect.size.toString())}</div>

                <pl-icon icon="share" class="tap fab" @click=${() => this._moveItems()}></pl-icon>

                <pl-icon icon="delete" class="tap fab destructive" @click=${() => this._deleteItems()}></pl-icon>
            </div>
        `;
    }
    _resizeHandler() {
        delete this._cachedBounds;
    }
    //
    // private _scrollToIndex(i: number) {
    //     const el = this.$(`pl-item-item[index="${i}"]`);
    //     if (el) {
    //         this._main.scrollTop = el.offsetTop - 6;
    //     }
    // }
    //
    // private _scrollToSelected() {
    //     const selected = this._selected.values()[0];
    //     const i = this._listItems.indexOf(selected);
    //     if (i !== -1 && (i < this._firstVisibleIndex || i > this._lastVisibleIndex)) {
    //         this._scrollToIndex(i);
    //     }
    // }
    // private async _animateItems(delay = 100) {
    //     await this.updateComplete;
    //     this._main.style.opacity = "0";
    //     setTimeout(() => {
    //         this._scrollHandler();
    //         const elements = Array.from(this.$$(".list-item"));
    //         const animated = elements.slice(this._firstVisibleIndex, this._lastVisibleIndex + 1);
    //
    //         animateCascade(animated, { clear: true });
    //         this._main.style.opacity = "1";
    //     }, delay);
    // }
    async _deleteItems() {
        let selected = [...this._multiSelect.values()];
        if (selected.some(({ vault }) => !_globals__WEBPACK_IMPORTED_MODULE_5__.app.hasWritePermissions(vault))) {
            const proceed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Some items in your selection are from Vaults you don't have write access " +
                "to and cannot be deleted. Do you want to proceed deleting the other items?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Yes"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No"));
            if (!proceed) {
                return;
            }
            selected = selected.filter(({ vault }) => _globals__WEBPACK_IMPORTED_MODULE_5__.app.hasWritePermissions(vault));
        }
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to delete these items? This action can not be undone!"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete {0} Items", selected.length.toString()), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel"), { type: "destructive" });
        if (confirmed) {
            await _globals__WEBPACK_IMPORTED_MODULE_5__.app.deleteItems(selected.map(i => i.item));
            this.cancelMultiSelect();
        }
    }
    async _moveItems() {
        let selected = [...this._multiSelect.values()];
        if (selected.some(({ item }) => !!item.attachments.length)) {
            const proceed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Some items in your selection have attachments and cannot be moved. " +
                "Do you want to proceed moving the other items?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Yes"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No"));
            if (!proceed) {
                return;
            }
            selected = selected.filter(({ item }) => !item.attachments.length);
        }
        if (selected.some(({ vault }) => !_globals__WEBPACK_IMPORTED_MODULE_5__.app.hasWritePermissions(vault))) {
            const proceed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Some items in your selection are from Vaults you don't have write " +
                "access to and cannot be moved. Do you want to proceed moving the other items?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Yes"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No"));
            if (!proceed) {
                return;
            }
            selected = selected.filter(({ vault }) => _globals__WEBPACK_IMPORTED_MODULE_5__.app.hasWritePermissions(vault));
        }
        const movedItems = await this._moveItemsDialog.show(selected);
        if (movedItems) {
            this.cancelMultiSelect();
        }
    }
    _copyField({ item }, index, e) {
        e.stopPropagation();
        (0,_lib_clipboard__WEBPACK_IMPORTED_MODULE_4__.setClipboard)(item, item.fields[index]);
        const fieldEl = e.target;
        fieldEl.classList.add("copied");
        setTimeout(() => fieldEl.classList.remove("copied"), 1000);
        _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateLastUsed(item);
        this.dispatch("field-clicked", { item, index });
    }
    async _dragFieldStart({ item }, index, event) {
        this.dispatch("field-dragged", { item, index, event });
        return true;
    }
    _openAttachment(a, item, e) {
        e.stopPropagation();
        this._attachmentDialog.show({ info: a, item: item.id });
    }
    _getItems() {
        const { vault: vaultId, tag, favorites, attachments, recent, host } = this;
        const filter = (this._filterInput && this._filterInput.value) || "";
        const recentThreshold = new Date(Date.now() - _globals__WEBPACK_IMPORTED_MODULE_5__.app.settings.recentLimit * 24 * 60 * 60 * 1000);
        let items = [];
        if (host) {
            items = this.app.getItemsForHost(this.app.state.currentHost);
        }
        else {
            for (const vault of this.state.vaults) {
                // Filter by vault
                if (vaultId && vault.id !== vaultId) {
                    continue;
                }
                for (const item of vault.items) {
                    if (
                    // filter by tag
                    (!tag || item.tags.includes(tag)) &&
                        (!favorites || _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.favorites.has(item.id)) &&
                        (!attachments || !!item.attachments.length) &&
                        (!recent ||
                            (_globals__WEBPACK_IMPORTED_MODULE_5__.app.state.lastUsed.has(item.id) && _globals__WEBPACK_IMPORTED_MODULE_5__.app.state.lastUsed.get(item.id) > recentThreshold)) &&
                        filterByString(filter || "", item)) {
                        items.push({
                            vault,
                            item,
                            section: "",
                            firstInSection: false,
                            lastInSection: false
                        });
                    }
                }
            }
        }
        items.sort((a, b) => {
            const x = a.item.name.toLowerCase();
            const y = b.item.name.toLowerCase();
            return x > y ? 1 : x < y ? -1 : 0;
        });
        return items;
    }
    _renderItem(li) {
        const { item, vault, warning } = li;
        const tags = [];
        if (!this.vault && _globals__WEBPACK_IMPORTED_MODULE_5__.app.mainVault && vault.id !== _globals__WEBPACK_IMPORTED_MODULE_5__.app.mainVault.id) {
            tags.push({ name: vault.name, icon: "", class: "highlight" });
        }
        if (warning) {
            tags.push({ icon: "error", class: "warning", name: "" });
        }
        if (item.tags.length === 1) {
            const t = item.tags.find(t => t === _globals__WEBPACK_IMPORTED_MODULE_5__.router.params.tag) || item.tags[0];
            tags.push({
                name: t,
                class: ""
            });
        }
        else if (item.tags.length) {
            tags.push({
                icon: "tag",
                name: item.tags.length.toString(),
                class: ""
            });
        }
        const attCount = (item.attachments && item.attachments.length) || 0;
        if (attCount) {
            tags.push({
                name: attCount.toString(),
                icon: "attachment",
                class: ""
            });
        }
        if (_globals__WEBPACK_IMPORTED_MODULE_5__.app.account.favorites.has(item.id)) {
            tags.push({
                name: "",
                icon: "favorite",
                class: "warning"
            });
        }
        return _base__WEBPACK_IMPORTED_MODULE_9__.html `
            <div class="item" ?selected=${item.id === this.selected} @click="${() => this.selectItem(li)}}">
                ${(0,lit_html_directives_cache__WEBPACK_IMPORTED_MODULE_2__.cache)(this.multiSelect
            ? _base__WEBPACK_IMPORTED_MODULE_9__.html `
                              <div
                                  class="item-check"
                                  ?hidden=${!this.multiSelect}
                                  ?checked=${this._multiSelect.has(item.id)}
                              ></div>
                          `
            : "")}

                <div class="item-body">
                    <div class="item-header">
                        <div class="item-name" ?disabled=${!item.name}>
                            ${item.name || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No Name")}
                        </div>

                        <div class="tags small">
                            ${tags.map(tag => _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                    <div class="tag ${tag.class}">
                                        ${tag.icon
            ? _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                                  <pl-icon icon="${tag.icon}"></pl-icon>
                                              `
            : ""}
                                        ${tag.name
            ? _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                                  <div class="tag-name ellipsis">
                                                      ${tag.name}
                                                  </div>
                                              `
            : ""}
                                    </div>
                                `)}
                        </div>
                    </div>

                    <div class="item-fields">
                        ${item.fields.map((f, i) => {
            return _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                <div
                                    class="item-field tap"
                                    @click=${(e) => this._copyField(li, i, e)}
                                    draggable="true"
                                    @dragstart=${(e) => this._dragFieldStart(li, i, e)}
                                >
                                    <div class="item-field-label">
                                        <div class="item-field-name">
                                            <pl-icon icon="${f.icon}"></pl-icon>
                                            ${f.name || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unnamed")}
                                        </div>
                                        ${f.type === "totp"
                ? _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                                  <pl-totp class="item-field-value" .secret=${f.value}></pl-totp>
                                              `
                : _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                                  <div class="item-field-value">
                                                      ${f.format(true)}
                                                  </div>
                                              `}
                                    </div>

                                    <div class="copied-message">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("copied")}</div>
                                </div>
                            `;
        })}
                        ${item.attachments.map(a => _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                <div
                                    class="item-field attachment tap"
                                    @click=${(e) => this._openAttachment(a, item, e)}
                                >
                                    <div class="item-field-label">
                                        <div class="item-field-name ellipsis">
                                            <pl-icon icon="attachment"></pl-icon>
                                            ${a.name}
                                        </div>
                                        <div class="item-field-value">
                                            <pl-icon icon=${(0,_lib_util__WEBPACK_IMPORTED_MODULE_8__.fileIcon)(a.type)} class="file-icon"></pl-icon>
                                            <span>${(0,_lib_util__WEBPACK_IMPORTED_MODULE_8__.fileSize)(a.size)}</span>
                                        </div>
                                    </div>
                                </div>
                            `)}
                        ${(0,lit_html_directives_cache__WEBPACK_IMPORTED_MODULE_2__.cache)(!item.fields.length && !item.attachments.length
            ? _base__WEBPACK_IMPORTED_MODULE_9__.html `
                                      <div class="item-field" disabled ?hidden=${!!item.fields.length}>
                                          <div class="item-field-label">
                                              <div class="item-field-name">
                                                  ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No Fields")}
                                              </div>
                                              <div class="item-field-value">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This item has no fields.")}</div>
                                          </div>
                                      </div>
                                  `
            : "")}
                    </div>
                </div>
            </div>
        `;
    }
};
ItemsList.styles = [
    ..._view__WEBPACK_IMPORTED_MODULE_10__.View.styles,
    _base__WEBPACK_IMPORTED_MODULE_9__.css `
            :host {
                display: flex;
                flex-direction: column;
                box-sizing: border-box;
                position: relative;
                background: var(--color-quaternary);
                border-radius: var(--border-radius);
            }

            header {
                overflow: visible;
                z-index: 10;
            }

            header pl-input {
                font-size: var(--font-size-default);
                padding: 0 0 0 10px;
            }

            pl-items-filter {
                min-width: 0;
            }

            main {
                padding-bottom: 70px;
                position: relative;
            }

            .section-header {
                grid-column: 1/-1;
                font-weight: bold;
                display: flex;
                align-items: flex-end;
                height: 35px;
                box-sizing: border-box;
                padding: 0 10px 5px 10px;
                background: var(--color-quaternary);
                display: flex;
                z-index: 1;
                position: -webkit-sticky;
                position: sticky;
                top: -3px;
                margin-bottom: -8px;
                font-size: var(--font-size-small);
            }

            .item {
                box-sizing: border-box;
                display: flex;
                align-items: center;
                margin: 6px;
                cursor: pointer;
                /*
                box-shadow: rgba(0, 0, 0, 0.1) 0 1px 8px;
                border: none;
                */
            }

            .item-body {
                flex: 1;
                min-width: 0;
            }

            .item .tags {
                padding: 0;
            }

            .item .tags .tag-name {
                max-width: 60px;
            }

            .item-header {
                height: 24px;
                margin: 12px 12px 8px 12px;
                position: relative;
                display: flex;
                align-items: center;
            }

            .item-name {
                ${_styles__WEBPACK_IMPORTED_MODULE_7__.mixins.ellipsis()}
                font-weight: 600;
                flex: 1;
                min-width: 0;
                line-height: 24px;
            }

            .item-fields {
                position: relative;
                display: flex;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                padding: 0 0 6px 6px;
            }

            .item-fields::after {
                content: "";
                display: block;
                width: 6px;
                flex: none;
                /*
                position: absolute;
                z-index: 1;
                right: 0;
                top: 0;
                bottom: 0;
                background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
                 */
            }

            .item-field {
                cursor: pointer;
                font-size: var(--font-size-tiny);
                position: relative;
                flex: 1;
                border-radius: 8px;
                max-width: calc(60%);
                opacity: 0.999;
            }

            .item-field.dragging {
                background: var(--color-tertiary);
            }

            .item-field.dragging::after {
                background: none;
            }

            .item-field > * {
                transition: transform 0.2s cubic-bezier(1, -0.3, 0, 1.3), opacity 0.2s;
            }

            .item-field:not(.copied) .copied-message,
            .item-field.copied .item-field-label {
                opacity: 0;
                transform: scale(0);
            }

            .copied-message {
                ${_styles__WEBPACK_IMPORTED_MODULE_7__.mixins.fullbleed()}
                border-radius: inherit;
                font-weight: bold;
                color: var(--color-primary);
                text-align: center;
                line-height: 45px;
            }

            .copied-message::before {
                font-family: "FontAwesome";
                content: "\\f00c\\ ";
            }

            .item-field-label {
                padding: 4px 6px;
                pointer-events: none;
                min-width: 0;
            }

            .item-field-name {
                font-size: var(--font-size-micro);
                color: var(--color-primary);
                margin-bottom: 2px;
                font-weight: 600;
                ${_styles__WEBPACK_IMPORTED_MODULE_7__.mixins.ellipsis()}
                line-height: 16px;
                height: 16px;
            }

            .item-field-name pl-icon {
                font-size: 9px;
                color: var(--color-primary);
                display: inline-block;
                height: 10px;
                width: 10px;
                border-radius: 0;
                position: relative;
                top: 1px;
            }

            .item-field-value {
                font-weight: 600;
                line-height: 19px;
                height: 19px;
                ${_styles__WEBPACK_IMPORTED_MODULE_7__.mixins.ellipsis()}
            }

            .item-field-value > * {
                vertical-align: middle;
            }

            .item-field.attachment {
                display: flex;
                align-items: center;
            }

            .attachment .file-icon {
                display: inline-block;
                height: 1em;
                width: 1em;
                font-size: 90%;
                border-radius: 0;
                vertical-align: middle;
            }

            .item:focus:not([selected]) {
                border-color: var(--color-highlight);
                color: #4ca8d9;
            }

            .item[selected] {
                background: #e6e6e6;
                border-color: #ddd;
            }

            .item-check {
                position: relative;
                width: 30px;
                height: 30px;
                box-sizing: border-box;
                border: solid 3px transparent;
                background: var(--color-shade-1);
                border-radius: 30px;
                margin: 12px;
                margin-right: 0;
            }

            .item-check::after {
                content: "";
                display: block;
                ${_styles__WEBPACK_IMPORTED_MODULE_7__.mixins.fullbleed()}
                background: var(--color-negative);
                border-radius: inherit;
                transition: transform 0.2s, opacity 0.2s;
                transition-timing-function: cubic-bezier(1, -0.3, 0, 1.3);
            }

            .item-check:not([checked])::after {
                opacity: 0;
                transform: scale(0);
            }

            .selected-count {
                text-align: center;
                display: block;
                margin-left: 12px;
                background: rgba(255, 255, 255, 0.9);
                border-radius: var(--border-radius);
                padding: 12px 4px;
                line-height: 1.2em;
                font-size: var(--font-size-tiny);
                font-weight: bold;
                box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
            }

            pl-virtual-list {
                padding: 6px;
                padding-bottom: 65px;
                ${_styles__WEBPACK_IMPORTED_MODULE_7__.mixins.fullbleed()}
                ${_styles__WEBPACK_IMPORTED_MODULE_7__.mixins.scroll()}
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", String)
], ItemsList.prototype, "selected", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", Boolean)
], ItemsList.prototype, "multiSelect", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", String)
], ItemsList.prototype, "vault", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", String)
], ItemsList.prototype, "tag", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", Boolean)
], ItemsList.prototype, "favorites", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", Boolean)
], ItemsList.prototype, "attachments", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", Boolean)
], ItemsList.prototype, "recent", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", Boolean)
], ItemsList.prototype, "host", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", Array)
], ItemsList.prototype, "_listItems", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.query)("#filterInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_11__.Input)
], ItemsList.prototype, "_filterInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.property)(),
    __metadata("design:type", Boolean)
], ItemsList.prototype, "_filterShowing", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-move-items-dialog"),
    __metadata("design:type", _move_items_dialog__WEBPACK_IMPORTED_MODULE_12__.MoveItemsDialog)
], ItemsList.prototype, "_moveItemsDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_6__.dialog)("pl-attachment-dialog"),
    __metadata("design:type", _attachment_dialog__WEBPACK_IMPORTED_MODULE_13__.AttachmentDialog)
], ItemsList.prototype, "_attachmentDialog", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.observe)("vault"),
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.observe)("tag"),
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.observe)("favorites"),
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.observe)("attachments"),
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.observe)("recent"),
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.observe)("host"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], ItemsList.prototype, "stateChanged", null);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.listen)("resize", window),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], ItemsList.prototype, "_resizeHandler", null);
ItemsList = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_9__.element)("pl-items-list")
], ItemsList);



/***/ }),

/***/ "../app/src/elements/loading-button.ts":
/*!*********************************************!*\
  !*** ../app/src/elements/loading-button.ts ***!
  \*********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "LoadingButton": () => (/* binding */ LoadingButton)
/* harmony export */ });
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _spinner__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./spinner */ "../app/src/elements/spinner.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




let LoadingButton = class LoadingButton extends _base__WEBPACK_IMPORTED_MODULE_1__.BaseElement {
    constructor() {
        super(...arguments);
        this.state = "idle";
        this.noTab = false;
    }
    render() {
        const { state, noTab } = this;
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <button type="button" class="${state}" tabindex="${noTab ? "-1" : ""}">
                <div class="label"><slot></slot></div>

                <pl-spinner .active="${state == "loading"}" class="spinner"></pl-spinner>

                <pl-icon icon="check" class="icon-success"></pl-icon>

                <pl-icon icon="cancel" class="icon-fail"></pl-icon>
            </button>
        `;
    }
    static get is() {
        return "pl-loading-button";
    }
    _click(e) {
        if (this.state === "loading") {
            e.stopPropagation();
        }
    }
    start() {
        clearTimeout(this._stopTimeout);
        this.state = "loading";
    }
    stop() {
        this.state = "idle";
    }
    success() {
        this.state = "success";
        this._stopTimeout = window.setTimeout(() => this.stop(), 1000);
    }
    fail() {
        this.state = "fail";
        this._stopTimeout = window.setTimeout(() => this.stop(), 1000);
    }
};
LoadingButton.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_0__.shared,
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            :host {
                display: flex;
                padding: 12px 15px;
            }

            :host([state="loading"]) button {
                cursor: progress;
            }

            button {
                background: transparent;
                position: relative;
                flex: 1;
                height: auto;
                padding: 0;
            }

            button > * {
                transition: transform 0.2s cubic-bezier(1, -0.3, 0, 1.3), opacity 0.2s;
                will-change: transform;
            }

            button > :not(.label) {
                ${_styles__WEBPACK_IMPORTED_MODULE_0__.mixins.absoluteCenter()}
            }

            button > .label {
                display: flex;
                align-items: center;
                justify-content: center;
            }

            :host(.vertical) .label {
                flex-direction: column;
            }

            button.loading .label,
            button.success .label,
            button.fail .label,
            button:not(.loading) .spinner,
            button:not(.success) .icon-success,
            button:not(.fail) .icon-fail {
                opacity: 0.5;
                transform: scale(0);
            }

            button pl-icon {
                font-size: 120%;
            }

            pl-spinner {
                width: 30px;
                height: 30px;
            }

            :host(.icon) {
                background: transparent !important;
                border-radius: 100% !important;
                padding: 0;
                line-height: 0;
            }

            :host(:not(.icon)) ::slotted(pl-icon:first-child) {
                margin: -10px 0 -10px -10px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)({ reflect: true }),
    __metadata("design:type", String)
], LoadingButton.prototype, "state", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Boolean)
], LoadingButton.prototype, "noTab", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.listen)("click"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [MouseEvent]),
    __metadata("design:returntype", void 0)
], LoadingButton.prototype, "_click", null);
LoadingButton = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-loading-button")
], LoadingButton);



/***/ }),

/***/ "../app/src/elements/login.ts":
/*!************************************!*\
  !*** ../app/src/elements/login.ts ***!
  \************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Login": () => (/* binding */ Login)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/mfa */ "../core/src/mfa.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _start_form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./start-form */ "../app/src/elements/start-form.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _password_input__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./password-input */ "../app/src/elements/password-input.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _logo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./logo */ "../app/src/elements/logo.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











let Login = class Login extends _start_form__WEBPACK_IMPORTED_MODULE_5__.StartForm {
    constructor() {
        super(...arguments);
        this._failedCount = 0;
    }
    async reset() {
        await this.updateComplete;
        this._emailInput.value = _globals__WEBPACK_IMPORTED_MODULE_3__.router.params.email || "";
        this._passwordInput.value = "";
        this._loginButton.stop();
        this._failedCount = 0;
        super.reset();
        if (_globals__WEBPACK_IMPORTED_MODULE_3__.router.params.verifying) {
            this._verifyEmail();
        }
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <div flex></div>

            <form>
                <pl-logo class="animate"></pl-logo>

                <pl-input
                    id="emailInput"
                    type="email"
                    required
                    select-on-focus
                    .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Email Address")}
                    class="animate tap"
                    @enter=${() => this._submit()}
                >
                </pl-input>

                <pl-password-input
                    id="passwordInput"
                    required
                    select-on-focus
                    .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Master Password")}
                    class="animate tap"
                    @enter=${() => this._submit()}
                >
                </pl-password-input>

                <pl-loading-button id="loginButton" class="tap animate" @click=${() => this._submit()}>
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Login")}
                </pl-loading-button>

                ${this._errorMessage
            ? _base__WEBPACK_IMPORTED_MODULE_4__.html `
                          <div class="error note animate">${this._errorMessage}</div>
                      `
            : ""}

                <div class="hint animate">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("New to Padloc?")}
                </div>

                <button type="button" class="tap signup animate" @click=${() => _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("signup")}>
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Sign Up Now")}
                </button>
            </form>

            <div flex></div>
        `;
    }
    async _verifyEmail() {
        _globals__WEBPACK_IMPORTED_MODULE_3__.router.params = { ..._globals__WEBPACK_IMPORTED_MODULE_3__.router.params, email: this._emailInput.value, verifying: "1" };
        const res = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter the confirmation code sent to your email address to proceed!"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("One Last Step!"),
            placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Verification Code"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Submit"),
            type: "number",
            pattern: "[0-9]*",
            validate: async (code) => {
                try {
                    return _globals__WEBPACK_IMPORTED_MODULE_3__.app.retrieveMFAToken(this._emailInput.value, code, _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_2__.MFAPurpose.Login);
                }
                catch (e) {
                    if (e.code === _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.MFA_TRIES_EXCEEDED) {
                        (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Maximum number of tries exceeded! Please resubmit and try again!"), {
                            type: "warning"
                        });
                        return null;
                    }
                    throw e.message ||
                        `Something went wrong while we were processing your request. Please try again later! (Error Code: ${e.code})`;
                }
            }
        });
        if (res) {
            this._verificationToken = res.token;
        }
        const { email, verifying, ...rest } = _globals__WEBPACK_IMPORTED_MODULE_3__.router.params;
        _globals__WEBPACK_IMPORTED_MODULE_3__.router.params = rest;
        return res;
    }
    async _accountDoesntExist(email) {
        const signup = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("An account with this email address does not exist!"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Sign Up"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel"), {
            icon: "info"
        });
        if (signup) {
            _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("signup", { email });
        }
    }
    async _submit() {
        if (this._loginButton.state === "loading") {
            return;
        }
        if (!this._emailInput.reportValidity()) {
            return;
        }
        this._emailInput.blur();
        this._passwordInput.blur();
        const email = this._emailInput.value;
        let password = this._passwordInput.value;
        if (this._emailInput.invalid) {
            this._errorMessage = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter a valid email address!");
            this.rumble();
            this._emailInput.focus();
            return;
        }
        if (!password) {
            this._errorMessage = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter your master password!");
            this.rumble();
            this._passwordInput.focus();
            return;
        }
        this._errorMessage = "";
        this._loginButton.start();
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.login(email, password, this._verificationToken);
            this._loginButton.success();
            this.done();
        }
        catch (e) {
            switch (e.code) {
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.MFA_REQUIRED:
                    this._loginButton.stop();
                    await _globals__WEBPACK_IMPORTED_MODULE_3__.app.requestMFACode(email, _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_2__.MFAPurpose.Login);
                    const verify = await this._verifyEmail();
                    if (!verify) {
                        return;
                    }
                    if (!verify.hasAccount) {
                        if (verify.hasLegacyAccount) {
                            this._migrateAccount(email, password, verify.legacyToken, verify.token);
                        }
                        else {
                            this._accountDoesntExist(email);
                        }
                        return;
                    }
                    return this._submit();
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.INVALID_CREDENTIALS:
                    this._errorMessage = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Wrong username or password. Please try again!");
                    this._loginButton.fail();
                    this.rumble();
                    this._failedCount++;
                    if (this._failedCount > 2) {
                        const recover = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Can't remember your master password?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Recover Account"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Try Again"));
                        if (recover) {
                            _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("recover", { email });
                        }
                    }
                    else {
                        this._passwordInput.focus();
                    }
                    return;
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.NOT_FOUND:
                    this._loginButton.fail();
                    this._accountDoesntExist(email);
                    return;
                default:
                    this._loginButton.fail();
                    throw e;
            }
        }
    }
};
Login.styles = [
    ..._start_form__WEBPACK_IMPORTED_MODULE_5__.StartForm.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            .hint {
                font-size: var(--font-size-tiny);
                box-sizing: border-box;
                transition: max-height 0.3s;
                max-height: 100px;
                margin: 40px 0 -20px 0;
            }

            button.signup {
                background: none;
                border: none;
                height: auto;
                line-height: normal;
                font-weight: bold;
                height: var(--row-height);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", String)
], Login.prototype, "_errorMessage", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#emailInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_6__.Input)
], Login.prototype, "_emailInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#passwordInput"),
    __metadata("design:type", _password_input__WEBPACK_IMPORTED_MODULE_7__.PasswordInput)
], Login.prototype, "_passwordInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#loginButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_8__.LoadingButton)
], Login.prototype, "_loginButton", void 0);
Login = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-login")
], Login);



/***/ }),

/***/ "../app/src/elements/logo.ts":
/*!***********************************!*\
  !*** ../app/src/elements/logo.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Logo": () => (/* binding */ Logo)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};

let Logo = class Logo extends _base__WEBPACK_IMPORTED_MODULE_0__.BaseElement {
    constructor() {
        super(...arguments);
        this.reveal = false;
    }
    _logo() {
        return _base__WEBPACK_IMPORTED_MODULE_0__.svg `
        <svg viewBox="0 -12 380 120" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
            <defs>

                <filter id="shadow">
                    <feOffset dy="3" in="SourceAlpha" result="shadowOffsetOuter1"/>
                    <feColorMatrix values="0 0 0 0 0   0 0 0 0 0   0 0 0 0 0  0 0 0 0.3 0" in="shadowOffsetOuter1"/>
                </filter>

            </defs>

            <g class="padloc shadow" filter="url(#shadow)">

                <path class="p" d="M26.4525939,21 C31.4460596,21 35.9653942,22.1535365 40.0107335,24.460644 C44.0560727,26.7677515 47.2322485,29.9439273 49.539356,33.9892665 C51.8464635,38.0346058 53,42.5539404 53,47.5474061 C53,52.4776633 51.8464635,56.9653942 49.539356,61.0107335 C47.2322485,65.0560727 44.0560727,68.2322485 40.0107335,70.539356 C35.9653942,72.8464635 31.4460596,74 26.4525939,74 C21.9647957,74 17.9037153,73.036086 14.2692308,71.108229 C10.6347463,69.180372 7.77460792,66.5414598 5.68872987,63.1914132 L5.68872987,92.7728086 C5.68872987,93.6577265 5.43589996,94.3530088 4.93023256,94.8586762 C4.42456515,95.3643436 3.7292829,95.6171735 2.84436494,95.6171735 C2.0226554,95.6171735 1.34317502,95.3643436 0.805903399,94.8586762 C0.26863178,94.3530088 1.13686838e-13,93.6577265 1.13686838e-13,92.7728086 L1.13686838e-13,46.9785331 C0.0632084258,42.1114843 1.2641505,37.6869609 3.60286225,33.7048301 C5.94157401,29.7226992 9.11774976,26.609731 13.1314848,24.3658318 C17.1452198,22.1219327 21.5855451,21 26.4525939,21 Z M26.4525939,68.6905188 C30.3715163,68.6905188 33.9111351,67.7740104 37.0715564,65.940966 C40.2319776,64.1079217 42.728673,61.5796226 44.5617174,58.3559928 C46.3947617,55.1323631 47.3112701,51.5295369 47.3112701,47.5474061 C47.3112701,43.5652753 46.3947617,39.962449 44.5617174,36.7388193 C42.728673,33.5151896 40.2319776,30.9710886 37.0715564,29.1064401 C33.9111351,27.2417915 30.3715163,26.3094812 26.4525939,26.3094812 C22.5336715,26.3094812 18.9940528,27.2417915 15.8336315,29.1064401 C12.6732102,30.9710886 10.1923167,33.5151896 8.39087657,36.7388193 C6.58943643,39.962449 5.68872987,43.5652753 5.68872987,47.5474061 C5.68872987,51.5295369 6.58943643,55.1323631 8.39087657,58.3559928 C10.1923167,61.5796226 12.6732102,64.1079217 15.8336315,65.940966 C18.9940528,67.7740104 22.5336715,68.6905188 26.4525939,68.6905188 Z"></path>

                <path class="a" d="M101.903818,21 C106.834075,21 111.321806,22.1535365 115.367145,24.460644 C119.412485,26.7677515 122.58866,29.9439273 124.895768,33.9892665 C127.202876,38.0346058 128.356412,42.5539404 128.356412,47.5474061 L128.356412,70.5867621 C128.356412,71.4084716 128.103582,72.087952 127.597915,72.6252236 C127.092247,73.1624952 126.396965,73.431127 125.512047,73.431127 C124.690338,73.431127 124.010857,73.1624952 123.473586,72.6252236 C122.936314,72.087952 122.667682,71.4084716 122.667682,70.5867621 L122.667682,63.1914132 C120.581804,66.5414598 117.721666,69.180372 114.087181,71.108229 C110.452697,73.036086 106.391616,74 101.903818,74 C96.9103524,74 92.3910178,72.8464635 88.3456785,70.539356 C84.3003393,68.2322485 81.1241635,65.0560727 78.817056,61.0107335 C76.5099484,56.9653942 75.356412,52.4776633 75.356412,47.5474061 C75.356412,42.5539404 76.5099484,38.0346058 78.817056,33.9892665 C81.1241635,29.9439273 84.3003393,26.7677515 88.3456785,24.460644 C92.3910178,22.1535365 96.9103524,21 101.903818,21 Z M101.903818,68.6905188 C105.82274,68.6905188 109.362359,67.7740104 112.52278,65.940966 C115.683202,64.1079217 118.164095,61.5796226 119.965535,58.3559928 C121.766976,55.1323631 122.667682,51.5295369 122.667682,47.5474061 C122.667682,43.5652753 121.766976,39.962449 119.965535,36.7388193 C118.164095,33.5151896 115.683202,30.9710886 112.52278,29.1064401 C109.362359,27.2417915 105.82274,26.3094812 101.903818,26.3094812 C97.9848957,26.3094812 94.4452769,27.2417915 91.2848556,29.1064401 C88.1244343,30.9710886 85.627739,33.5151896 83.7946946,36.7388193 C81.9616503,39.962449 81.0451419,43.5652753 81.0451419,47.5474061 C81.0451419,51.5295369 81.9616503,55.1323631 83.7946946,58.3559928 C85.627739,61.5796226 88.1244343,64.1079217 91.2848556,65.940966 C94.4452769,67.7740104 97.9848957,68.6905188 101.903818,68.6905188 Z"></path>

                <path class="d" d="M200.453612,1 C201.33121,1 202.020742,1.2507387 202.522227,1.75222363 C203.023712,2.25370856 203.27445,2.94324 203.27445,3.82083863 L203.27445,49.2363405 C203.211765,54.063133 202.020756,58.4510603 199.701388,62.4002541 C197.38202,66.349448 194.232115,69.4366682 190.251579,71.6620076 C186.271042,73.887347 181.867444,75 177.040651,75 C172.088487,75 167.606533,73.8560047 163.594654,71.5679797 C159.582774,69.2799547 156.432869,66.1300497 154.144844,62.1181703 C151.856819,58.1062908 150.712824,53.6243365 150.712824,48.6721728 C150.712824,43.7826947 151.856819,39.3320827 154.144844,35.3202033 C156.432869,31.3083239 159.582774,28.1584189 163.594654,25.8703939 C167.606533,23.5823689 172.088487,22.4383736 177.040651,22.4383736 C181.49133,22.4383736 185.51882,23.3943149 189.123243,25.3062262 C192.727666,27.2181375 195.564148,29.8352227 197.632773,33.1575604 L197.632773,3.82083863 C197.632773,2.94324 197.899183,2.25370856 198.432011,1.75222363 C198.964838,1.2507387 199.638699,1 200.453612,1 Z M177.040651,69.7344346 C180.927159,69.7344346 184.437501,68.8098356 187.571782,66.9606099 C190.706063,65.1113842 193.166436,62.588326 194.952976,59.3913596 C196.739517,56.1943932 197.632773,52.6213666 197.632773,48.6721728 C197.632773,44.722979 196.739517,41.1499525 194.952976,37.952986 C193.166436,34.7560196 190.706063,32.2486326 187.571782,30.4307497 C184.437501,28.6128668 180.927159,27.703939 177.040651,27.703939 C173.154143,27.703939 169.643801,28.6128668 166.50952,30.4307497 C163.375239,32.2486326 160.899195,34.7560196 159.081312,37.952986 C157.263429,41.1499525 156.354501,44.722979 156.354501,48.6721728 C156.354501,52.6213666 157.263429,56.1943932 159.081312,59.3913596 C160.899195,62.588326 163.375239,65.1113842 166.50952,66.9606099 C169.643801,68.8098356 173.154143,69.7344346 177.040651,69.7344346 Z"></path>

                <path class="l" d="M230,2.8425096 C230,2.02133606 230.268457,1.34229889 230.805378,0.805377721 C231.342299,0.268456556 232.021336,0 232.84251,0 C233.663683,0 234.34272,0.268456556 234.879641,0.805377721 C235.416563,1.34229889 235.685019,2.02133606 235.685019,2.8425096 L235.685019,71.1574904 C235.685019,71.9786639 235.416563,72.6577011 234.879641,73.1946223 C234.34272,73.7315434 233.663683,74 232.84251,74 C232.021336,74 231.342299,73.7315434 230.805378,73.1946223 C230.268457,72.6577011 230,71.9786639 230,71.1574904 L230,2.8425096 Z"></path>

                <path class="o" d="M286.957975,22 C291.888232,22 296.375963,23.1535365 300.421302,25.460644 C304.466642,27.7677515 307.642817,30.9439273 309.949925,34.9892665 C312.257032,39.0346058 313.410569,43.5539404 313.410569,48.5474061 C313.410569,53.4776633 312.257032,57.9653942 309.949925,62.0107335 C307.642817,66.0560727 304.466642,69.2322485 300.421302,71.539356 C296.375963,73.8464635 291.888232,75 286.957975,75 C281.964509,75 277.445175,73.8464635 273.399835,71.539356 C269.354496,69.2322485 266.17832,66.0560727 263.871213,62.0107335 C261.564105,57.9653942 260.410569,53.4776633 260.410569,48.5474061 C260.410569,43.5539404 261.564105,39.0346058 263.871213,34.9892665 C266.17832,30.9439273 269.354496,27.7677515 273.399835,25.460644 C277.445175,23.1535365 281.964509,22 286.957975,22 Z M286.957975,27.3094812 C283.039052,27.3094812 279.499434,28.2417915 276.339012,30.1064401 C273.178591,31.9710886 270.681896,34.5151896 268.848851,37.7388193 C267.015807,40.962449 266.099299,44.5652753 266.099299,48.5474061 C266.099299,52.5295369 267.015807,56.1323631 268.848851,59.3559928 C270.681896,62.5796226 273.178591,65.1079217 276.339012,66.940966 C279.499434,68.7740104 283.039052,69.6905188 286.957975,69.6905188 C290.876897,69.6905188 294.416516,68.7740104 297.576937,66.940966 C300.737359,65.1079217 303.218252,62.5796226 305.019692,59.3559928 C306.821132,56.1323631 307.721839,52.5295369 307.721839,48.5474061 C307.721839,44.5652753 306.821132,40.962449 305.019692,37.7388193 C303.218252,34.5151896 300.737359,31.9710886 297.576937,30.1064401 C294.416516,28.2417915 290.876897,27.3094812 286.957975,27.3094812 Z"></path>

                <path class="c" d="M359.820963,22 C363.873552,22 367.577816,22.7915094 370.933866,24.374552 C374.289917,25.9575945 377.202671,28.3004624 379.672218,31.4032258 C380.115469,32.0364428 380.337092,32.5746692 380.337092,33.0179211 C380.337092,33.904425 379.893847,34.6009533 379.007343,35.1075269 C378.564091,35.4874571 378.057525,35.6774194 377.48763,35.6774194 C376.601126,35.6774194 375.872937,35.2974948 375.303042,34.5376344 C371.250453,29.725185 366.089812,27.3189964 359.820963,27.3189964 C356.148304,27.3189964 352.887286,28.2213171 350.037809,30.0259857 C347.188332,31.8306542 344.987936,34.3476541 343.436554,37.5770609 C341.885173,40.8064678 341.109494,44.447411 341.109494,48.5 C341.109494,52.4892673 341.964324,56.0985502 343.67401,59.327957 C345.383696,62.5573638 347.758224,65.0901939 350.797666,66.9265233 C353.837107,68.7628527 357.319749,69.6810036 361.245694,69.6810036 C366.818004,69.6810036 371.282117,68.1296451 374.638167,65.0268817 C375.208063,64.4569864 375.872931,64.172043 376.632791,64.172043 C377.32933,64.172043 377.899217,64.3936656 378.342468,64.8369176 C378.975685,65.4068129 379.292289,66.1033412 379.292289,66.9265233 C379.292289,67.623062 379.039006,68.1929488 378.532433,68.6362007 C376.316173,70.6624952 373.720022,72.2296838 370.743902,73.3378136 C367.767782,74.4459434 364.601744,75 361.245694,75 C356.369923,75 351.969131,73.8443963 348.043185,71.5331541 C344.11724,69.221912 341.030353,66.0400442 338.782433,61.9874552 C336.534512,57.9348662 335.410569,53.4390928 335.410569,48.5 C335.410569,43.4975855 336.455361,38.9859819 338.544977,34.9650538 C340.634594,30.9441257 343.547348,27.778088 347.283329,25.4668459 C351.019309,23.1556037 355.198479,22 359.820963,22 Z"></path>

            </g>

            <g class="padloc">

                <path class="p" d="M26.4525939,21 C31.4460596,21 35.9653942,22.1535365 40.0107335,24.460644 C44.0560727,26.7677515 47.2322485,29.9439273 49.539356,33.9892665 C51.8464635,38.0346058 53,42.5539404 53,47.5474061 C53,52.4776633 51.8464635,56.9653942 49.539356,61.0107335 C47.2322485,65.0560727 44.0560727,68.2322485 40.0107335,70.539356 C35.9653942,72.8464635 31.4460596,74 26.4525939,74 C21.9647957,74 17.9037153,73.036086 14.2692308,71.108229 C10.6347463,69.180372 7.77460792,66.5414598 5.68872987,63.1914132 L5.68872987,92.7728086 C5.68872987,93.6577265 5.43589996,94.3530088 4.93023256,94.8586762 C4.42456515,95.3643436 3.7292829,95.6171735 2.84436494,95.6171735 C2.0226554,95.6171735 1.34317502,95.3643436 0.805903399,94.8586762 C0.26863178,94.3530088 1.13686838e-13,93.6577265 1.13686838e-13,92.7728086 L1.13686838e-13,46.9785331 C0.0632084258,42.1114843 1.2641505,37.6869609 3.60286225,33.7048301 C5.94157401,29.7226992 9.11774976,26.609731 13.1314848,24.3658318 C17.1452198,22.1219327 21.5855451,21 26.4525939,21 Z M26.4525939,68.6905188 C30.3715163,68.6905188 33.9111351,67.7740104 37.0715564,65.940966 C40.2319776,64.1079217 42.728673,61.5796226 44.5617174,58.3559928 C46.3947617,55.1323631 47.3112701,51.5295369 47.3112701,47.5474061 C47.3112701,43.5652753 46.3947617,39.962449 44.5617174,36.7388193 C42.728673,33.5151896 40.2319776,30.9710886 37.0715564,29.1064401 C33.9111351,27.2417915 30.3715163,26.3094812 26.4525939,26.3094812 C22.5336715,26.3094812 18.9940528,27.2417915 15.8336315,29.1064401 C12.6732102,30.9710886 10.1923167,33.5151896 8.39087657,36.7388193 C6.58943643,39.962449 5.68872987,43.5652753 5.68872987,47.5474061 C5.68872987,51.5295369 6.58943643,55.1323631 8.39087657,58.3559928 C10.1923167,61.5796226 12.6732102,64.1079217 15.8336315,65.940966 C18.9940528,67.7740104 22.5336715,68.6905188 26.4525939,68.6905188 Z"></path>

                <path class="a" d="M101.903818,21 C106.834075,21 111.321806,22.1535365 115.367145,24.460644 C119.412485,26.7677515 122.58866,29.9439273 124.895768,33.9892665 C127.202876,38.0346058 128.356412,42.5539404 128.356412,47.5474061 L128.356412,70.5867621 C128.356412,71.4084716 128.103582,72.087952 127.597915,72.6252236 C127.092247,73.1624952 126.396965,73.431127 125.512047,73.431127 C124.690338,73.431127 124.010857,73.1624952 123.473586,72.6252236 C122.936314,72.087952 122.667682,71.4084716 122.667682,70.5867621 L122.667682,63.1914132 C120.581804,66.5414598 117.721666,69.180372 114.087181,71.108229 C110.452697,73.036086 106.391616,74 101.903818,74 C96.9103524,74 92.3910178,72.8464635 88.3456785,70.539356 C84.3003393,68.2322485 81.1241635,65.0560727 78.817056,61.0107335 C76.5099484,56.9653942 75.356412,52.4776633 75.356412,47.5474061 C75.356412,42.5539404 76.5099484,38.0346058 78.817056,33.9892665 C81.1241635,29.9439273 84.3003393,26.7677515 88.3456785,24.460644 C92.3910178,22.1535365 96.9103524,21 101.903818,21 Z M101.903818,68.6905188 C105.82274,68.6905188 109.362359,67.7740104 112.52278,65.940966 C115.683202,64.1079217 118.164095,61.5796226 119.965535,58.3559928 C121.766976,55.1323631 122.667682,51.5295369 122.667682,47.5474061 C122.667682,43.5652753 121.766976,39.962449 119.965535,36.7388193 C118.164095,33.5151896 115.683202,30.9710886 112.52278,29.1064401 C109.362359,27.2417915 105.82274,26.3094812 101.903818,26.3094812 C97.9848957,26.3094812 94.4452769,27.2417915 91.2848556,29.1064401 C88.1244343,30.9710886 85.627739,33.5151896 83.7946946,36.7388193 C81.9616503,39.962449 81.0451419,43.5652753 81.0451419,47.5474061 C81.0451419,51.5295369 81.9616503,55.1323631 83.7946946,58.3559928 C85.627739,61.5796226 88.1244343,64.1079217 91.2848556,65.940966 C94.4452769,67.7740104 97.9848957,68.6905188 101.903818,68.6905188 Z"></path>

                <path class="d" d="M200.453612,1 C201.33121,1 202.020742,1.2507387 202.522227,1.75222363 C203.023712,2.25370856 203.27445,2.94324 203.27445,3.82083863 L203.27445,49.2363405 C203.211765,54.063133 202.020756,58.4510603 199.701388,62.4002541 C197.38202,66.349448 194.232115,69.4366682 190.251579,71.6620076 C186.271042,73.887347 181.867444,75 177.040651,75 C172.088487,75 167.606533,73.8560047 163.594654,71.5679797 C159.582774,69.2799547 156.432869,66.1300497 154.144844,62.1181703 C151.856819,58.1062908 150.712824,53.6243365 150.712824,48.6721728 C150.712824,43.7826947 151.856819,39.3320827 154.144844,35.3202033 C156.432869,31.3083239 159.582774,28.1584189 163.594654,25.8703939 C167.606533,23.5823689 172.088487,22.4383736 177.040651,22.4383736 C181.49133,22.4383736 185.51882,23.3943149 189.123243,25.3062262 C192.727666,27.2181375 195.564148,29.8352227 197.632773,33.1575604 L197.632773,3.82083863 C197.632773,2.94324 197.899183,2.25370856 198.432011,1.75222363 C198.964838,1.2507387 199.638699,1 200.453612,1 Z M177.040651,69.7344346 C180.927159,69.7344346 184.437501,68.8098356 187.571782,66.9606099 C190.706063,65.1113842 193.166436,62.588326 194.952976,59.3913596 C196.739517,56.1943932 197.632773,52.6213666 197.632773,48.6721728 C197.632773,44.722979 196.739517,41.1499525 194.952976,37.952986 C193.166436,34.7560196 190.706063,32.2486326 187.571782,30.4307497 C184.437501,28.6128668 180.927159,27.703939 177.040651,27.703939 C173.154143,27.703939 169.643801,28.6128668 166.50952,30.4307497 C163.375239,32.2486326 160.899195,34.7560196 159.081312,37.952986 C157.263429,41.1499525 156.354501,44.722979 156.354501,48.6721728 C156.354501,52.6213666 157.263429,56.1943932 159.081312,59.3913596 C160.899195,62.588326 163.375239,65.1113842 166.50952,66.9606099 C169.643801,68.8098356 173.154143,69.7344346 177.040651,69.7344346 Z"></path>

                <path class="l" d="M230,2.8425096 C230,2.02133606 230.268457,1.34229889 230.805378,0.805377721 C231.342299,0.268456556 232.021336,0 232.84251,0 C233.663683,0 234.34272,0.268456556 234.879641,0.805377721 C235.416563,1.34229889 235.685019,2.02133606 235.685019,2.8425096 L235.685019,71.1574904 C235.685019,71.9786639 235.416563,72.6577011 234.879641,73.1946223 C234.34272,73.7315434 233.663683,74 232.84251,74 C232.021336,74 231.342299,73.7315434 230.805378,73.1946223 C230.268457,72.6577011 230,71.9786639 230,71.1574904 L230,2.8425096 Z"></path>

                <path class="o" d="M286.957975,22 C291.888232,22 296.375963,23.1535365 300.421302,25.460644 C304.466642,27.7677515 307.642817,30.9439273 309.949925,34.9892665 C312.257032,39.0346058 313.410569,43.5539404 313.410569,48.5474061 C313.410569,53.4776633 312.257032,57.9653942 309.949925,62.0107335 C307.642817,66.0560727 304.466642,69.2322485 300.421302,71.539356 C296.375963,73.8464635 291.888232,75 286.957975,75 C281.964509,75 277.445175,73.8464635 273.399835,71.539356 C269.354496,69.2322485 266.17832,66.0560727 263.871213,62.0107335 C261.564105,57.9653942 260.410569,53.4776633 260.410569,48.5474061 C260.410569,43.5539404 261.564105,39.0346058 263.871213,34.9892665 C266.17832,30.9439273 269.354496,27.7677515 273.399835,25.460644 C277.445175,23.1535365 281.964509,22 286.957975,22 Z M286.957975,27.3094812 C283.039052,27.3094812 279.499434,28.2417915 276.339012,30.1064401 C273.178591,31.9710886 270.681896,34.5151896 268.848851,37.7388193 C267.015807,40.962449 266.099299,44.5652753 266.099299,48.5474061 C266.099299,52.5295369 267.015807,56.1323631 268.848851,59.3559928 C270.681896,62.5796226 273.178591,65.1079217 276.339012,66.940966 C279.499434,68.7740104 283.039052,69.6905188 286.957975,69.6905188 C290.876897,69.6905188 294.416516,68.7740104 297.576937,66.940966 C300.737359,65.1079217 303.218252,62.5796226 305.019692,59.3559928 C306.821132,56.1323631 307.721839,52.5295369 307.721839,48.5474061 C307.721839,44.5652753 306.821132,40.962449 305.019692,37.7388193 C303.218252,34.5151896 300.737359,31.9710886 297.576937,30.1064401 C294.416516,28.2417915 290.876897,27.3094812 286.957975,27.3094812 Z"></path>

                <path class="c" d="M359.820963,22 C363.873552,22 367.577816,22.7915094 370.933866,24.374552 C374.289917,25.9575945 377.202671,28.3004624 379.672218,31.4032258 C380.115469,32.0364428 380.337092,32.5746692 380.337092,33.0179211 C380.337092,33.904425 379.893847,34.6009533 379.007343,35.1075269 C378.564091,35.4874571 378.057525,35.6774194 377.48763,35.6774194 C376.601126,35.6774194 375.872937,35.2974948 375.303042,34.5376344 C371.250453,29.725185 366.089812,27.3189964 359.820963,27.3189964 C356.148304,27.3189964 352.887286,28.2213171 350.037809,30.0259857 C347.188332,31.8306542 344.987936,34.3476541 343.436554,37.5770609 C341.885173,40.8064678 341.109494,44.447411 341.109494,48.5 C341.109494,52.4892673 341.964324,56.0985502 343.67401,59.327957 C345.383696,62.5573638 347.758224,65.0901939 350.797666,66.9265233 C353.837107,68.7628527 357.319749,69.6810036 361.245694,69.6810036 C366.818004,69.6810036 371.282117,68.1296451 374.638167,65.0268817 C375.208063,64.4569864 375.872931,64.172043 376.632791,64.172043 C377.32933,64.172043 377.899217,64.3936656 378.342468,64.8369176 C378.975685,65.4068129 379.292289,66.1033412 379.292289,66.9265233 C379.292289,67.623062 379.039006,68.1929488 378.532433,68.6362007 C376.316173,70.6624952 373.720022,72.2296838 370.743902,73.3378136 C367.767782,74.4459434 364.601744,75 361.245694,75 C356.369923,75 351.969131,73.8443963 348.043185,71.5331541 C344.11724,69.221912 341.030353,66.0400442 338.782433,61.9874552 C336.534512,57.9348662 335.410569,53.4390928 335.410569,48.5 C335.410569,43.4975855 336.455361,38.9859819 338.544977,34.9650538 C340.634594,30.9441257 343.547348,27.778088 347.283329,25.4668459 C351.019309,23.1556037 355.198479,22 359.820963,22 Z"></path>

            </g>
        </svg>`;
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            ${this._logo()}
        `;
    }
};
Logo.styles = [
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            :host {
                position: relative;
                display: block;
                width: 200px;
                height: 52px;
            }

            :host([reveal]) .padloc > * {
                stroke-dashoffset: 0;
            }

            svg {
                width: 100%;
                height: 100%;
                fill: none;
                stroke: currentColor;
                stroke-linecap: round;
                stroke-width: 7;
            }

            .padloc > * {
                transition: stroke-dashoffset 1.4s cubic-bezier(0.57, 0.25, 0, 0.99);
                stroke-dashoffset: 0;
            }

            .p {
                stroke-dashoffset: 234px;
                stroke-dasharray: 234px;
                transition-delay: 0s;
            }

            .a {
                stroke-dashoffset: 190px;
                stroke-dasharray: 190px;
                transition-delay: 0.1s;
            }

            .d {
                stroke-dashoffset: 232px;
                stroke-dasharray: 232px;
                transition-delay: 0.2s;
            }

            .l {
                stroke-dashoffset: 155px;
                stroke-dasharray: 155px;
                transition-delay: 0.3s;
            }

            .o {
                stroke-dashoffset: 168px;
                stroke-dasharray: 168px;
                transition-delay: 0.4s;
            }

            .c {
                stroke-dashoffset: 237px;
                stroke-dasharray: 237px;
                transition-delay: 0.5s;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], Logo.prototype, "reveal", void 0);
Logo = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.element)("pl-logo")
], Logo);



/***/ }),

/***/ "../app/src/elements/member-dialog.ts":
/*!********************************************!*\
  !*** ../app/src/elements/member-dialog.ts ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "MemberDialog": () => (/* binding */ MemberDialog)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/org */ "../core/src/org.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _toggle_button__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./toggle-button */ "../app/src/elements/toggle-button.ts");
/* harmony import */ var _group_item__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./group-item */ "../app/src/elements/group-item.ts");
/* harmony import */ var _member_item__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./member-item */ "../app/src/elements/member-item.ts");
/* harmony import */ var _vault_item__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./vault-item */ "../app/src/elements/vault-item.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};













let MemberDialog = class MemberDialog extends _dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog {
    constructor() {
        super(...arguments);
        this.org = null;
        this.member = null;
        this._error = "";
        this._vaults = new Map();
        this._groups = new Set();
    }
    _getCurrentVaults() {
        const vaults = new Map();
        if (!this.org || !this.member) {
            return vaults;
        }
        for (const vault of this.org.vaults) {
            const v = this.member && this.member.vaults.find(v => v.id === vault.id);
            vaults.set(vault.id, {
                read: !!v,
                write: !!v && !v.readonly
            });
        }
        return vaults;
    }
    _getCurrentGroups() {
        return this.org && this.member
            ? new Set(this.org.getGroupsForMember(this.member).map(g => g.name))
            : new Set();
    }
    get _hasChanged() {
        if (!this.org || !this.member) {
            return false;
        }
        const currentVaults = this._getCurrentVaults();
        const vaultsChanged = this.org.vaults.some(({ id }) => {
            const c = currentVaults.get(id);
            const s = this._vaults.get(id);
            return c.read !== s.read || c.write !== s.write;
        });
        const currentGroups = this._getCurrentGroups();
        const groupsChanged = currentGroups.size !== this._groups.size ||
            [...this._groups.values()].some(name => !currentGroups.has(name));
        return vaultsChanged || groupsChanged;
    }
    async show({ member, org }) {
        this.member = member;
        this.org = org;
        this._groups = this._getCurrentGroups();
        this._vaults = this._getCurrentVaults();
        this._error = "";
        await this.updateComplete;
        return super.show();
    }
    _toggleGroup(group) {
        if (this._groups.has(group.name)) {
            this._groups.delete(group.name);
        }
        else {
            this._groups.add(group.name);
        }
        this.requestUpdate();
    }
    _toggleVault({ id }) {
        const { read } = this._vaults.get(id);
        this._vaults.set(id, read ? { read: false, write: false } : { read: true, write: true });
        this.requestUpdate();
    }
    _toggleRead({ id }, event) {
        if (event) {
            event.stopImmediatePropagation();
        }
        const sel = this._vaults.get(id);
        sel.read = !sel.read;
        if (!sel.read) {
            sel.write = false;
        }
        this.requestUpdate();
    }
    _toggleWrite({ id }, event) {
        if (event) {
            event.stopImmediatePropagation();
        }
        const sel = this._vaults.get(id);
        sel.write = !sel.write;
        if (sel.write) {
            sel.read = true;
        }
        this.requestUpdate();
    }
    async _save() {
        if (this._saveButton.state === "loading") {
            return;
        }
        this._error = "";
        this._saveButton.start();
        const vaults = [...this._vaults.entries()]
            .filter(([, { read }]) => read)
            .map(([id, { write }]) => ({ id, readonly: !write }));
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.updateMember(this.org, this.member, {
                vaults,
                groups: [...this._groups]
            });
            this._saveButton.success();
            this.done();
        }
        catch (e) {
            this._saveButton.fail();
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!");
            throw e;
        }
    }
    async _showOptions() {
        const isAdmin = this.member.role === _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgRole.Admin;
        this.open = false;
        const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.choose)("", [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Remove"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Suspend"), isAdmin ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Remove Admin") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Make Admin")], {
            hideIcon: true,
            type: "destructive"
        });
        switch (choice) {
            case 0:
                this._removeMember();
                break;
            case 1:
                this._suspendMember();
                break;
            case 2:
                isAdmin ? this._removeAdmin() : this._makeAdmin();
                break;
            default:
                this.open = true;
        }
    }
    async _removeMember() {
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Are you sure you want to remove this member from this organization?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Remove"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel"), {
            type: "destructive",
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Remove Member")
        });
        this.open = true;
        if (confirmed) {
            this._saveButton.start();
            try {
                await _globals__WEBPACK_IMPORTED_MODULE_3__.app.removeMember(this.org, this.member);
                this._saveButton.success();
                this.done();
            }
            catch (e) {
                this._saveButton.fail();
                throw e;
            }
        }
    }
    async _makeAdmin() {
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Are you sure you want to make this member an admin? " +
            "Admins can manage vaults, groups and permissions."), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Make Admin"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel"));
        this.open = true;
        if (confirmed) {
            this._saveButton.start();
            try {
                this.member = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.updateMember(this.org, this.member, { role: _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgRole.Admin });
                this._saveButton.success();
            }
            catch (e) {
                this._saveButton.fail();
                throw e;
            }
        }
    }
    async _removeAdmin() {
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Are you sure you want to remove this member as admin?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Remove Admin"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel"), { type: "destructive" });
        this.open = true;
        if (confirmed) {
            this._saveButton.start();
            try {
                this.member = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.updateMember(this.org, this.member, { role: _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgRole.Member });
                this._saveButton.success();
            }
            catch (e) {
                this._saveButton.fail();
                throw e;
            }
        }
    }
    async _suspendMember() {
        this.open = false;
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Are you sure you want to suspend this member?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Suspend Member"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel"), { type: "destructive" });
        this.open = true;
        if (confirmed) {
            this._saveButton.start();
            try {
                this.member = await _globals__WEBPACK_IMPORTED_MODULE_3__.app.updateMember(this.org, this.member, { role: _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgRole.Suspended });
                this._saveButton.success();
                this.done();
            }
            catch (e) {
                this._saveButton.fail();
                throw e;
            }
        }
    }
    shouldUpdate() {
        return !!this.org && !!this.member;
    }
    renderContent() {
        const org = this.org;
        const member = this.member;
        const accountIsOwner = org.isOwner(_globals__WEBPACK_IMPORTED_MODULE_3__.app.account);
        const accountIsAdmin = org.isAdmin(_globals__WEBPACK_IMPORTED_MODULE_3__.app.account);
        const memberIsOwner = org.isOwner(member);
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <header>
                <pl-member-item .member=${member} class="flex"></pl-member-item>
                <pl-icon
                    icon="more"
                    class="more-button tap"
                    ?hidden=${!accountIsOwner || memberIsOwner}
                    @click=${this._showOptions}
                ></pl-icon>
            </header>

            <div class="content">
                <div class="subheader" ?hidden=${!org.groups.length}>
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Groups")}</div>
                </div>

                ${org.groups.map(group => _base__WEBPACK_IMPORTED_MODULE_5__.html `
                        <pl-toggle-button
                            ?disabled=${!accountIsAdmin}
                            class="item tap"
                            reverse
                            @click=${() => this._toggleGroup(group)}
                            .active=${this._groups.has(group.name)}
                        >
                            <pl-group-item .group=${group}></pl-group-item>
                        </pl-toggle-button>
                    `)}

                <div class="subheader">
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Vaults")}</div>
                    <div class="flex"></div>
                    <div class="permission">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("read")}</div>
                    <div class="permission">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("write")}</div>
                </div>

                ${org.vaults.map(vault => _base__WEBPACK_IMPORTED_MODULE_5__.html `
                        <div class="item tap" @click=${() => this._toggleVault(vault)} ?disabled=${!accountIsAdmin}>
                            <pl-vault-item .vault=${vault} class="flex"></pl-vault-item>
                            <pl-toggle
                                .active=${this._vaults.get(vault.id).read}
                                @click=${(e) => this._toggleRead(vault, e)}
                            ></pl-toggle>
                            <pl-toggle
                                .active=${this._vaults.get(vault.id).write}
                                @click=${(e) => this._toggleWrite(vault, e)}
                            ></pl-toggle>
                        </div>
                    `)}

                <div class="error item" ?hidden="${!this._error}">
                    ${this._error}
                </div>
            </div>

            <div class="footer">
                <div class="actions">
                    <pl-loading-button
                        class="tap primary"
                        id="saveButton"
                        ?disabled=${!accountIsAdmin || !this._hasChanged}
                        @click=${this._save}
                    >
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Save")}
                    </pl-loading-button>

                    <button class="transparent tap" @click=${this.dismiss}>
                        ${this._hasChanged ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Close")}
                    </button>
                </div>
            </div>
        `;
    }
};
MemberDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            .inner {
                background: var(--color-quaternary);
            }

            pl-toggle-button {
                display: block;
                padding: 0 15px 0 0;
            }

            .more-button {
                font-size: var(--font-size-small);
                align-self: flex-start;
                width: 30px;
                height: 30px;
                margin-top: 5px;
            }

            .subheader {
                margin: 8px;
                font-weight: bold;
                display: flex;
                align-items: flex-end;
                padding: 0 8px;
                font-size: var(--font-size-small);
            }

            .subheader .permission {
                width: 50px;
                font-size: var(--font-size-tiny);
                text-align: center;
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.ellipsis()}
            }

            .item {
                display: flex;
                align-items: center;
            }

            .item pl-toggle {
                margin-right: 14px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], MemberDialog.prototype, "org", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], MemberDialog.prototype, "member", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#saveButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], MemberDialog.prototype, "_saveButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], MemberDialog.prototype, "_error", void 0);
MemberDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.element)("pl-member-dialog")
], MemberDialog);



/***/ }),

/***/ "../app/src/elements/member-item.ts":
/*!******************************************!*\
  !*** ../app/src/elements/member-item.ts ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "MemberItem": () => (/* binding */ MemberItem)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/org */ "../core/src/org.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _randomart__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./randomart */ "../app/src/elements/randomart.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};






let MemberItem = class MemberItem extends _base__WEBPACK_IMPORTED_MODULE_3__.BaseElement {
    constructor() {
        super(...arguments);
        this.hideRole = false;
    }
    render() {
        const isAdmin = this.member.role === _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgRole.Admin;
        const isOwner = this.member.role === _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgRole.Owner;
        const isSuspended = this.member.role === _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgRole.Suspended;
        const groups = (this.org && this.org.getGroupsForMember(this.member).filter(g => g.name !== "Everyone")) || [];
        return _base__WEBPACK_IMPORTED_MODULE_3__.html `
            <pl-fingerprint .key=${this.member.publicKey}></pl-fingerprint>

            <div class="member-info">
                <div class="name-wrapper">
                    <div class="member-name ellipsis">${this.member.name}</div>

                    <div class="tiny tags">
                        ${groups.map(group => _base__WEBPACK_IMPORTED_MODULE_3__.html `
                                <div class="tag">
                                    <pl-icon icon="group"></pl-icon>
                                    ${group.name}
                                </div>
                            `)}
                        ${!this.hideRole && isOwner
            ? _base__WEBPACK_IMPORTED_MODULE_3__.html `
                                  <div class="tag warning">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Owner")}</div>
                              `
            : !this.hideRole && isAdmin
                ? _base__WEBPACK_IMPORTED_MODULE_3__.html `
                                  <div class="tag highlight">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Admin")}</div>
                              `
                : !this.hideRole && isSuspended
                    ? _base__WEBPACK_IMPORTED_MODULE_3__.html `
                                  <div class="tag warning">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Suspended")}</div>
                              `
                    : ""}
                    </div>
                </div>

                <div class="member-email ellipsis">${this.member.email}</div>
            </div>
        `;
    }
};
MemberItem.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_2__.shared,
    _base__WEBPACK_IMPORTED_MODULE_3__.css `
            :host {
                display: flex;
                align-items: center;
                padding: 8px;
            }

            pl-fingerprint {
                color: var(--color-secondary);
                --color-background: var(--color-tertiary);
                width: 45px;
                height: 45px;
                border-radius: 100%;
                border: solid 1px var(--border-color);
                margin-right: 8px;
            }

            .member-info {
                flex: 1;
                width: 0;
            }

            .name-wrapper {
                display: flex;
            }

            .name-wrapper > .tags {
                margin: 0 0 0 4px;
            }

            .member-name {
                font-weight: bold;
                flex: 1;
                width: 0;
            }

            .member-email {
                font-size: 90%;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.OrgMember)
], MemberItem.prototype, "member", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.Org)
], MemberItem.prototype, "org", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Boolean)
], MemberItem.prototype, "hideRole", void 0);
MemberItem = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.element)("pl-member-item")
], MemberItem);



/***/ }),

/***/ "../app/src/elements/menu.ts":
/*!***********************************!*\
  !*** ../app/src/elements/menu.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Menu": () => (/* binding */ Menu)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _logo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./logo */ "../app/src/elements/logo.ts");
/* harmony import */ var _spinner__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spinner */ "../app/src/elements/spinner.ts");
/* harmony import */ var _report_errors_dialog__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./report-errors-dialog */ "../app/src/elements/report-errors-dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











let Menu = class Menu extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_6__.StateMixin)(_base__WEBPACK_IMPORTED_MODULE_7__.BaseElement) {
    constructor() {
        super(...arguments);
        this.selected = "items";
    }
    _goTo(path, params) {
        this.dispatch("toggle-menu");
        _globals__WEBPACK_IMPORTED_MODULE_3__.router.go(path, params);
    }
    _lock() {
        this.dispatch("toggle-menu");
        _globals__WEBPACK_IMPORTED_MODULE_3__.app.lock();
    }
    _getPremium(e) {
        e && e.stopPropagation();
        this.dispatch("get-premium");
        this.dispatch("toggle-menu");
    }
    _reportErrors() {
        this._reportErrorsDialog.show();
    }
    _displayVaultError(vault, e) {
        e && e.stopPropagation();
        const error = vault.error;
        switch (error.code) {
            case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_2__.ErrorCode.UNSUPPORTED_VERSION:
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("A newer version of Padloc is required to synchronize this vault. Please update to the latest version now!"), {
                    title: "Update Required",
                    type: "warning"
                });
                return;
            case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_2__.ErrorCode.MISSING_ACCESS:
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This vault could not be synchronized because you no longer have access to it."), {
                    title: "Sync Failed",
                    type: "warning"
                });
                return;
            default:
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)(error.message ||
                    (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("An unknown error occured while synchronizing this vault. If this problem persists please contact customer support."), {
                    title: "Sync Failed",
                    type: "warning"
                });
                return;
        }
    }
    render() {
        const mainVault = _globals__WEBPACK_IMPORTED_MODULE_3__.app.mainVault;
        const account = _globals__WEBPACK_IMPORTED_MODULE_3__.app.account;
        if (!mainVault || !account) {
            return _base__WEBPACK_IMPORTED_MODULE_7__.html ``;
        }
        const itemsQuota = _globals__WEBPACK_IMPORTED_MODULE_3__.app.getItemsQuota();
        const tags = _globals__WEBPACK_IMPORTED_MODULE_3__.app.state.tags;
        const count = _globals__WEBPACK_IMPORTED_MODULE_3__.app.count;
        const showSettingsWarning = _globals__WEBPACK_IMPORTED_MODULE_3__.app.billingEnabled &&
            account.billing &&
            (!account.billing.subscription || account.billing.subscription.status === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.SubscriptionStatus.Inactive);
        const showUpgradeButton = _globals__WEBPACK_IMPORTED_MODULE_3__.app.billingEnabled &&
            (!account.billing ||
                !account.billing.subscription ||
                account.billing.subscription.plan.type === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.PlanType.Free) &&
            itemsQuota !== -1;
        return _base__WEBPACK_IMPORTED_MODULE_7__.html `
            <div class="scroller">
                <pl-logo reveal></pl-logo>

                <div class="version">v${"3.1.4"}</div>

                <div class="separator"></div>

                <nav>
                    <ul>
                        <li class="tap" @click=${() => this._goTo("items", {})} ?selected=${this.selected === "items"}>
                            <pl-icon icon="list"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Items")}</div>
                        </li>

                        <li
                            class="sub-item tap favorites"
                            @click=${() => this._goTo("items", { host: true })}
                            ?selected=${this.selected === "host"}
                            ?hidden=${!count.currentHost}
                        >
                            <pl-icon icon="web"></pl-icon>

                            <div>${this.app.state.currentHost}</div>

                            <div class="detail">${count.currentHost}</div>
                        </li>

                        <li
                            class="sub-item tap"
                            @click=${() => this._goTo("items", { recent: true })}
                            ?selected=${this.selected === "recent"}
                        >
                            <pl-icon icon="time"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Recently Used")}</div>

                            <div class="detail">${count.recent}</div>
                        </li>

                        <li
                            class="sub-item tap favorites"
                            @click=${() => this._goTo("items", { favorites: true })}
                            ?selected=${this.selected === "favorites"}
                        >
                            <pl-icon icon="favorite"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Favorites")}</div>

                            <div class="detail">${count.favorites}</div>
                        </li>

                        <li
                            class="sub-item tap"
                            @click=${() => this._goTo("items", { attachments: true })}
                            ?selected=${this.selected === "attachments"}
                        >
                            <pl-icon icon="attachment"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Attachments")}</div>

                            <div class="detail">${count.attachments}</div>
                        </li>

                        <li
                            class="sub-item tap vault"
                            @click=${() => this._goTo("items", { vault: mainVault.id })}
                            ?selected=${this.selected === `vault/${mainVault.id}`}
                        >
                            <pl-icon icon="vault"></pl-icon>
                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("My Vault")}</div>
                            ${mainVault.error
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                      <div
                                          class="detail tap warning"
                                          @click=${(e) => this._displayVaultError(mainVault, e)}
                                      >
                                          <pl-icon icon="error"></pl-icon>
                                      </div>
                                  `
            : itemsQuota !== -1
                ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                      <div class="detail tap warning" @click=${this._getPremium}>
                                          ${mainVault.items.size} / ${itemsQuota}
                                      </div>
                                  `
                : _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                      <div class="detail">
                                          ${mainVault.items.size}
                                      </div>
                                  `}
                        </li>

                        ${_globals__WEBPACK_IMPORTED_MODULE_3__.app.orgs.map(org => {
            const vaults = _globals__WEBPACK_IMPORTED_MODULE_3__.app.vaults.filter(v => v.org && v.org.id === org.id);
            return _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                <div class="subsection">
                                    <div class="subsection-header">${org.name}</div>
                                    ${vaults.map(vault => {
                return _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                            <li
                                                class="sub-item tap vault"
                                                @click=${() => this._goTo("items", { vault: vault.id })}
                                                ?selected=${this.selected === `vault/${vault.id}`}
                                            >
                                                <pl-icon icon="vault"></pl-icon>
                                                <div>${vault.name}</div>

                                                ${vault.error
                    ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                                          <div
                                                              class="detail tap warning"
                                                              @click=${(e) => this._displayVaultError(vault, e)}
                                                          >
                                                              <pl-icon icon="error"></pl-icon>
                                                          </div>
                                                      `
                    : _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                                          <div class="detail">
                                                              ${vault.items.size}
                                                          </div>
                                                      `}
                                            </li>
                                        `;
            })}
                                </div>
                            `;
        })}

                        <div class="subsection" ?hidden=${!tags.length}>
                            <div class="subsection-header">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Tags")}</div>
                            ${tags.map(([tag, count]) => _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <li
                                        class="sub-item tap"
                                        @click=${() => this._goTo("items", { tag })}
                                        ?selected=${this.selected === `tag/${tag}`}
                                    >
                                        <pl-icon icon="tag"></pl-icon>

                                        <div>${tag}</div>

                                        <div class="detail">${count}</div>
                                    </li>
                                `)}
                        </div>

                        <li class="new sub-item tap" @click=${() => this.dispatch("create-item")}>
                            <pl-icon icon="add"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("New Vault Item")}</div>
                        </li>

                        <div class="separator"></div>

                        <li class="tap" ?selected=${this.selected === "orgs"} @click=${() => this._goTo("orgs")}>
                            <pl-icon icon="hirarchy"></pl-icon>

                            <div>
                                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Orgs & Teams")}
                            </div>
                        </li>

                        ${_globals__WEBPACK_IMPORTED_MODULE_3__.app.orgs.map(org => _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                <li
                                    class="sub-item tap"
                                    ?selected=${this.selected === `orgs/${org.id}`}
                                    @click=${() => this._goTo(`orgs/${org.id}`)}
                                >
                                    <pl-icon icon="org"></pl-icon>

                                    <div>${org.name}</div>

                                    <div class="detail warning" ?hidden=${!org.frozen}>
                                        <pl-icon icon="error"></pl-icon>
                                    </div>
                                </li>
                            `)}

                        <li class="new sub-item tap" @click=${() => this.dispatch("create-org")}>
                            <pl-icon icon="add"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("New Organization")}</div>
                        </li>

                        <div class="separator"></div>

                        <li
                            class="tap"
                            @click=${() => this._goTo("settings")}
                            ?selected=${this.selected === "settings"}
                        >
                            <pl-icon icon="settings"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Settings")}</div>

                            <div class="detail warning" ?hidden=${!showSettingsWarning}>
                                <pl-icon icon="error"></pl-icon>
                            </div>
                        </li>

                        <li class="get-premium tap" @click=${this._getPremium} ?hidden=${!showUpgradeButton}>
                            <pl-icon icon="favorite"></pl-icon>

                            <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Get Premium")}</div>
                        </li>
                    </ul>
                </nav>
            </div>

            <div class="footer">
                <pl-icon icon="lock" class="tap" @click=${this._lock}></pl-icon>
                <pl-icon icon="refresh" class="tap" @click=${() => _globals__WEBPACK_IMPORTED_MODULE_3__.app.synchronize()}></pl-icon>
                <div class="flex"></div>
                <pl-spinner .active=${_globals__WEBPACK_IMPORTED_MODULE_3__.app.state.syncing} class="syncing"></pl-spinner>
                <button class="errors-button tap" @click=${this._reportErrors} ?hidden=${!_globals__WEBPACK_IMPORTED_MODULE_3__.app.state._errors.length}>
                    <pl-icon icon="error" class="warning-icon"></pl-icon>
                    <div>${_globals__WEBPACK_IMPORTED_MODULE_3__.app.state._errors.length}</div>
                </button>
            </div>
        `;
    }
};
Menu.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_4__.shared,
    _base__WEBPACK_IMPORTED_MODULE_7__.css `
            :host {
                display: flex;
                flex-direction: column;
                color: var(--color-tertiary);
                font-size: var(--font-size-small);
            }

            .scroller {
                flex: 1;
                height: 0;
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.scroll()}
                padding: 10px 0;
            }

            li {
                background: transparent;
                border: none;
                display: flex;
                align-items: center;
                height: 40px;
                margin: 2px 10px;
                padding-right: 10px;
                border-radius: 8px;
                overflow: hidden;
                height: 40px;
                font-weight: 600;
                --color-highlight: var(--color-tertiary);
                --color-foreground: var(--color-secondary);
            }

            li:not(.sub-item) {
                margin-top: 8px;
            }

            li[selected] {
                background: var(--color-highlight);
                box-shadow: rgba(0, 0, 0, 0.1) 0 1px 1px;
                color: var(--color-foreground);
                font-weight: bold;
            }

            li div {
                flex: 1;
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.ellipsis()}
            }

            h3 {
                font-size: 100%;
                margin-top: 30px;
                padding: 0 20px;
                opacity: 0.8;
                font-weight: normal;
            }

            .sub-item {
                height: 35px;
                font-size: var(--font-size-tiny);
                margin-left: 20px;
            }

            .sub-item pl-icon {
                width: 30px;
                height: 30px;
                font-size: 90%;
            }

            .favorites,
            .host {
                --color-highlight: var(--color-negative);
                --color-foreground: var(--color-tertiary);
            }

            .vault {
                --color-highlight: var(--color-primary);
                --color-foreground: var(--color-tertiary);
            }

            .new {
                opacity: 0.6;
            }

            pl-logo {
                height: 30px;
                margin: 15px auto 0 auto;
                opacity: 0.25;
            }

            .version {
                text-align: center;
                margin-bottom: 15px;
                font-size: var(--font-size-micro);
                font-weight: 600;
                opacity: 0.3;
            }

            .no-tags {
                font-size: var(--font-size-micro);
                padding: 0 20px;
                opacity: 0.5;
                width: 100px;
            }

            .footer {
                padding: 5px;
                display: flex;
                align-items: center;
                box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 15px 0px;
                z-index: 1;
            }

            .footer pl-icon {
                width: 30px;
                height: 30px;
                font-size: var(--font-size-tiny);
            }

            .syncing {
                width: 20px;
                height: 20px;
                margin: 5px;
            }

            .get-premium {
                background: var(--color-negative);
            }

            li .detail {
                margin-left: 2px;
                flex: none;
                opacity: 0.7;
                font-weight: semi-bold;
                padding: 2px 6px;
                margin-right: -4px;
                opacity: 1;
                border-radius: var(--border-radius);
                display: flex;
            }

            li .detail pl-icon {
                height: 20px;
                width: 20px;
            }

            .detail.warning {
                color: white;
                opacity: 1;
                background: var(--color-negative);
            }

            .separator {
                height: 2px;
                background: var(--color-shade-2);
                border-radius: 100%;
                margin: 8px 16px;
            }

            .errors-button {
                background: var(--color-negative);
                padding: 0;
                padding-right: 8px;
                display: flex;
                align-items: center;
                font-weight: bold;
            }

            .subsection-header {
                margin: 12px 8px 6px 26px;
                opacity: 0.7;
                font-size: var(--font-size-tiny);
            }

            @supports (-webkit-overflow-scrolling: touch) {
                pl-logo {
                    margin-top: max(env(safe-area-inset-top), 15px);
                }

                .footer {
                    padding-bottom: max(calc(env(safe-area-inset-bottom) / 3), 5px);
                    padding-left: max(calc(env(safe-area-inset-bottom) / 3), 5px);
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.property)(),
    __metadata("design:type", String)
], Menu.prototype, "selected", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.dialog)("pl-report-errors-dialog"),
    __metadata("design:type", _report_errors_dialog__WEBPACK_IMPORTED_MODULE_10__.ReportErrorsDialog)
], Menu.prototype, "_reportErrorsDialog", void 0);
Menu = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.element)("pl-menu")
], Menu);



/***/ }),

/***/ "../app/src/elements/move-items-dialog.ts":
/*!************************************************!*\
  !*** ../app/src/elements/move-items-dialog.ts ***!
  \************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "MoveItemsDialog": () => (/* binding */ MoveItemsDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _select__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./select */ "../app/src/elements/select.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





let MoveItemsDialog = class MoveItemsDialog extends _dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog {
    constructor() {
        super(...arguments);
        this.items = [];
        this.vaults = [];
    }
    renderContent() {
        const itemsDescription = this.items.length === 1 ? `'${this.items[0].item.name}'` : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} Items", this.items.length.toString());
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <h1>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Move {0} To", itemsDescription)}</h1>

            <div class="message" ?hidden=${this.vaults.length}>
                ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No target vaults available!")}
            </div>

            <pl-select id="vaultSelect" .options=${this.vaults} .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Vault")} ?hidden=${!this.vaults.length}>
            </pl-select>

            <div class="actions">
                <button @click=${this._enter} class="primary tap" ?disabled=${!this.vaults.length}>
                    ${this.items.length === 1 ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Move Item") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Move Items")}
                </button>
                <button @click=${this.dismiss} class="tap">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel")}
                </button>
            </div>
        `;
    }
    async _enter() {
        this.done(await _globals__WEBPACK_IMPORTED_MODULE_1__.app.moveItems(this.items.map(i => i.item), this._vaultSelect.selected));
    }
    async show(items) {
        this.items = items;
        const sourceVaults = this.items.reduce((sv, i) => sv.add(i.vault), new Set());
        this.vaults =
            sourceVaults.size === 1
                ? _globals__WEBPACK_IMPORTED_MODULE_1__.app.vaults.filter(v => _globals__WEBPACK_IMPORTED_MODULE_1__.app.hasWritePermissions(v) && v !== sourceVaults.values().next().value)
                : _globals__WEBPACK_IMPORTED_MODULE_1__.app.vaults.filter(v => _globals__WEBPACK_IMPORTED_MODULE_1__.app.hasWritePermissions(v));
        // this._vaultSelect.options = vaults;
        await this.updateComplete;
        this._vaultSelect.selected = this.vaults[0];
        return super.show();
    }
};
MoveItemsDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_2__.css `
            pl-input,
            pl-select {
                text-align: center;
                margin: 12px;
            }

            .actions {
                margin: 12px;
                grid-gap: 12px;
            }

            h1 {
                display: block;
                text-align: center;
            }

            .message {
                margin: 8px;
                text-align: center;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Array)
], MoveItemsDialog.prototype, "items", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.property)(),
    __metadata("design:type", Array)
], MoveItemsDialog.prototype, "vaults", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.query)("#vaultSelect"),
    __metadata("design:type", _select__WEBPACK_IMPORTED_MODULE_3__.Select)
], MoveItemsDialog.prototype, "_vaultSelect", void 0);
MoveItemsDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.element)("pl-move-items-dialog")
], MoveItemsDialog);



/***/ }),

/***/ "../app/src/elements/org-view.ts":
/*!***************************************!*\
  !*** ../app/src/elements/org-view.ts ***!
  \***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "OrgView": () => (/* binding */ OrgView)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/org */ "../core/src/org.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _view__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./view */ "../app/src/elements/view.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _vault_dialog__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./vault-dialog */ "../app/src/elements/vault-dialog.ts");
/* harmony import */ var _group_dialog__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./group-dialog */ "../app/src/elements/group-dialog.ts");
/* harmony import */ var _member_dialog__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./member-dialog */ "../app/src/elements/member-dialog.ts");
/* harmony import */ var _create_invites_dialog__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./create-invites-dialog */ "../app/src/elements/create-invites-dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _billing_info__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./billing-info */ "../app/src/elements/billing-info.ts");
/* harmony import */ var _subscription__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./subscription */ "../app/src/elements/subscription.ts");
/* harmony import */ var _member_item__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./member-item */ "../app/src/elements/member-item.ts");
/* harmony import */ var _group_item__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./group-item */ "../app/src/elements/group-item.ts");
/* harmony import */ var _vault_item__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./vault-item */ "../app/src/elements/vault-item.ts");
/* harmony import */ var _invite_item__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./invite-item */ "../app/src/elements/invite-item.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};






















let OrgView = class OrgView extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_3__.StateMixin)(_view__WEBPACK_IMPORTED_MODULE_8__.View) {
    constructor() {
        super(...arguments);
        this.orgId = "";
        this._page = "members";
        this._membersFilter = "";
    }
    get _org() {
        return _globals__WEBPACK_IMPORTED_MODULE_6__.app.getOrg(this.orgId);
    }
    async _createInvite() {
        const invites = await this._createInvitesDialog.show(this._org);
        if (invites) {
            if (invites.length === 1) {
                _globals__WEBPACK_IMPORTED_MODULE_6__.router.go(`invite/${invites[0].org.id}/${invites[0].id}`);
            }
            else {
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Successfully created {0} invites!", invites.length.toString()));
                this._page = "invites";
            }
        }
    }
    _showInvite(invite) {
        _globals__WEBPACK_IMPORTED_MODULE_6__.router.go(`invite/${invite.org.id}/${invite.id}`);
    }
    async _createVault() {
        await this._vaultDialog.show({ org: this._org, vault: null });
    }
    async _showGroup(group) {
        await this._groupDialog.show({ org: this._org, group });
    }
    async _createGroup() {
        await this._groupDialog.show({ org: this._org, group: null });
    }
    async _showVault(vault) {
        await this._vaultDialog.show({ org: this._org, vault: vault });
    }
    _updateMembersFilter() {
        this._membersFilter = this._filterMembersInput.value;
    }
    async _showMember(member) {
        const org = this._org;
        if (member.role === _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_1__.OrgRole.Suspended) {
            if (!org.isOwner(_globals__WEBPACK_IMPORTED_MODULE_6__.app.account)) {
                return;
            }
            const invite = org.invites.find(invite => invite.email === member.email);
            if (invite) {
                this._showInvite(invite);
            }
            else {
                const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.choose)("", [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Remove Member"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unsuspend")], { type: "destructive" });
                switch (choice) {
                    case 0:
                        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to remove this member from this organization?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Remove"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel"), {
                            type: "destructive",
                            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Remove Member")
                        });
                        if (confirmed) {
                            await _globals__WEBPACK_IMPORTED_MODULE_6__.app.removeMember(org, member);
                        }
                        break;
                    case 1:
                        const [invite] = await _globals__WEBPACK_IMPORTED_MODULE_6__.app.createInvites(org, [member.email], "confirm_membership");
                        _globals__WEBPACK_IMPORTED_MODULE_6__.router.go(`invite/${invite.org.id}/${invite.id}`);
                        break;
                }
            }
        }
        else {
            await this._memberDialog.show({ org: org, member });
        }
    }
    async _deleteOrg() {
        const deleted = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to delete this organization? " +
            "All associated vaults and the data within them will be lost! " +
            "This action can not be undone."), {
            type: "destructive",
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Organization"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete"),
            placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Type 'DELETE' to confirm"),
            validate: async (val) => {
                if (val !== "DELETE") {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Type 'DELETE' to confirm");
                }
                await _globals__WEBPACK_IMPORTED_MODULE_6__.app.deleteOrg(this._org.id);
                return val;
            }
        });
        if (deleted) {
            _globals__WEBPACK_IMPORTED_MODULE_6__.router.go("");
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)("Organization deleted successfully.", { type: "success" });
        }
    }
    async _changeName() {
        await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.prompt)("", {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Rename Organization"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Save"),
            label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Company Name"),
            value: this._org.name,
            validate: async (name) => {
                if (!name) {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter a name!");
                }
                await _globals__WEBPACK_IMPORTED_MODULE_6__.app.updateOrg(this._org.id, async (org) => (org.name = name));
                return name;
            }
        });
    }
    async _rotateKeys() {
        if (this._rotateKeysButton.state === "loading") {
            return;
        }
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Do you want to rotate this organizations cryptographic keys? All organization " +
            "memberships will have to be reconfirmed but no data will be lost."), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Confirm"));
        if (!confirmed) {
            return;
        }
        this._rotateKeysButton.start();
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_6__.app.rotateOrgKeys(this._org);
            this._rotateKeysButton.success();
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("The organizations cryptographic keys have been rotated successfully and " +
                "membership confirmation requests for all members have been sent out."), { type: "success" });
        }
        catch (e) {
            this._rotateKeysButton.fail();
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)(e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!"), { type: "warning" });
        }
    }
    _orgChanged() {
        this._page = "members";
        this._clearMembersFilter();
    }
    _clearMembersFilter() {
        this._membersFilter = this._filterMembersInput.value = "";
    }
    shouldUpdate() {
        return !!this._org;
    }
    render() {
        const org = this._org;
        const isOwner = org.isOwner(_globals__WEBPACK_IMPORTED_MODULE_6__.app.account);
        const isAdmin = isOwner || org.isAdmin(_globals__WEBPACK_IMPORTED_MODULE_6__.app.account);
        const invites = org.invites;
        const groups = org.groups;
        const vaults = org.vaults;
        const memFilter = this._membersFilter.toLowerCase();
        const members = memFilter
            ? org.members.filter(({ name, email }) => email.toLowerCase().includes(memFilter) || name.toLowerCase().includes(memFilter))
            : org.members;
        const billing = org.billing || Object.assign(new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.BillingInfo(), { org: org.id });
        return _base__WEBPACK_IMPORTED_MODULE_7__.html `
            <header>
                <div class="header-inner">
                    <pl-icon class="tap menu-button" icon="menu" @click=${() => this.dispatch("toggle-menu")}></pl-icon>
                    <div class="title flex ellipsis">${org.name}</div>
                    <pl-icon></pl-icon>
                </div>

                <div class="tabs">
                    <div class="spacer"></div>

                    <div class="tap" ?active=${this._page === "members"} @click=${() => (this._page = "members")}>
                        <pl-icon icon="members"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Members")}</div>
                    </div>

                    <div
                        class="tap"
                        ?active=${this._page === "groups"}
                        @click=${() => (this._page = "groups")}
                        ?hidden=${!org.groups.length && !org.quota.groups}
                    >
                        <pl-icon icon="group"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Groups")}</div>
                    </div>

                    <div class="tap" ?active=${this._page === "vaults"} @click=${() => (this._page = "vaults")}>
                        <pl-icon icon="vaults"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Vaults")}</div>
                    </div>

                    <div
                        class="tap"
                        ?active=${this._page === "settings"}
                        @click=${() => (this._page = "settings")}
                        ?hidden=${!isOwner}
                    >
                        <pl-icon icon="settings"></pl-icon>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Settings")}</div>
                    </div>

                    <div class="spacer"></div>
                </div>
            </header>

            <main>
                <div class="wrapper">
                    <div ?hidden=${this._page !== "members"} class="subview">
                        ${org.frozen
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                  <div class="error item">
                                      ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This organization currently does not have an active subscription " +
                'and has been put in "frozen" state as a result. While in this state, ' +
                "you won't be able to make any changes to members, groups or vaults of this " +
                "organization.")}
                                      <button class="tap" @click=${() => (this._page = "settings")}>
                                          ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Update Subscription")}
                                      </button>
                                  </div>
                              `
            : ""}

                        <div class="search-wrapper item">
                            <pl-icon icon="search"></pl-icon>
                            <pl-input
                                id="filterMembersInput"
                                placeholder="${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Search...")}"
                                @input=${this._updateMembersFilter}
                            ></pl-input>
                            <pl-icon icon="cancel" class="tap" @click=${this._clearMembersFilter}></pl-icon>
                        </div>
                        <ul>
                            <li
                                class="new-button item tap"
                                @click=${this._createInvite}
                                ?hidden=${!isOwner || members.length < 50}
                            >
                                <pl-icon icon="invite"></pl-icon>
                                <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Invite New Members")}</div>
                            </li>

                            ${invites.map(inv => _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <li class="item tap" @click=${() => this._showInvite(inv)}>
                                        <pl-invite-item .invite=${inv}></pl-invite-item>
                                    </li>
                                `)}
                            ${members.map(member => _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <li class="tap member item" @click=${() => this._showMember(member)}>
                                        <pl-member-item .member=${member} .org=${this._org}></pl-member-item>
                                    </li>
                                `)}

                            <li class="new-button tap item" @click=${this._createInvite} ?hidden=${!isOwner}>
                                <pl-icon icon="add"></pl-icon>
                                <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Invite New Members")}</div>
                            </li>
                        </ul>
                    </div>

                    <div ?hidden=${this._page !== "groups"} class="subview">
                        ${org.frozen
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                  <div class="error item">
                                      ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This organization currently does not have an active subscription " +
                'and has been put in "frozen" state as a result. While in this state, ' +
                "you won't be able to make any changes to members, groups or vaults of this " +
                "organization.")}
                                      <button class="tap" ?hidden=${!isOwner} @click=${() => (this._page = "settings")}>
                                          ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Update Subscription")}
                                      </button>
                                  </div>
                              `
            : ""}
                        <ul>
                            ${groups.map(group => _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <li @click=${() => this._showGroup(group)} class="item tap">
                                        <pl-group-item .group=${group}></pl-group-item>
                                    </li>
                                `)}
                            <li class="new-button tap item" @click=${this._createGroup} ?hidden=${!isAdmin}>
                                <pl-icon icon="add"></pl-icon>
                                <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("New Group")}</div>
                            </li>
                        </ul>
                    </div>

                    <div ?hidden=${this._page !== "vaults"} class="subview">
                        ${org.frozen
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                  <div class="error item">
                                      ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This organization currently does not have an active subscription " +
                'and has been put in "frozen" state as a result. While in this state, ' +
                "you won't be able to make any changes to members, groups or vaults of this " +
                "organization.")}
                                      <button class="tap" ?hidden=${!isOwner} @click=${() => (this._page = "settings")}>
                                          ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Update Subscription")}
                                      </button>
                                  </div>
                              `
            : ""}
                        <ul>
                            ${vaults.map(vault => _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <li @click=${() => this._showVault(vault)} class="item tap">
                                        <pl-vault-item
                                            .vault=${vault}
                                            .groups=${org.getGroupsForVault(vault).length}
                                            .members=${org.getMembersForVault(vault).length}
                                        ></pl-vault-item>
                                    </li>
                                `)}
                            <li class="new-button tap item" @click=${this._createVault} ?hidden=${!isAdmin}>
                                <pl-icon icon="add"></pl-icon>
                                <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("New Vault")}</div>
                            </li>
                        </ul>
                    </div>

                    <div ?hidden=${this._page !== "settings"} class="subview settings">
                        ${org.frozen
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                  <div class="error item">
                                      ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This organization currently does not have an active subscription " +
                'and has been put in "frozen" state as a result. While in this state, ' +
                "you won't be able to make any changes to members, groups or vaults of this " +
                "organization.")}
                                  </div>
                              `
            : ""}
                        ${_globals__WEBPACK_IMPORTED_MODULE_6__.app.billingEnabled
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                  <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Subscription")}</h3>

                                  <pl-subscription .org=${this._org} class="item"></pl-subscription>

                                  <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Billing Info")}</h3>

                                  <pl-billing-info .billing=${billing} class="item"></pl-billing-info>
                              `
            : ""}

                        <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Security")}</h3>

                        <pl-loading-button id="rotateKeysButton" class="tap item" @click=${this._rotateKeys}
                            >${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Rotate Cryptographic Keys")}</pl-loading-button
                        >

                        <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("General")}</h3>

                        <button class="tap item" @click=${this._changeName}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Change Organization Name")}</button>

                        <button class="item tap negative" @click=${this._deleteOrg}>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Organization")}
                        </button>
                    </div>
                </div>
            </main>
        `;
    }
};
OrgView.styles = [
    ..._view__WEBPACK_IMPORTED_MODULE_8__.View.styles,
    _base__WEBPACK_IMPORTED_MODULE_7__.css `
            :host {
                display: flex;
                flex-direction: column;
                background: var(--color-quaternary);
                border-radius: var(--border-radius);
            }

            .wrapper {
                position: relative;
                width: 100%;
                height: 100%;
                max-width: 500px;
                margin: 0 auto;
            }

            .subview {
                position: relative;
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.fullbleed()}
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.scroll()}
            }

            header {
                display: block;
                border: none;
            }

            .header-inner {
                display: flex;
                align-items: center;
                margin-bottom: 10px;
            }

            .header-inner .title {
                text-align: center;
            }

            header > .tabs {
                margin: -10px;
            }

            .tabs .spacer {
                padding: 0;
            }

            .new-button {
                display: flex;
                font-weight: bold;
                align-items: center;
                justify-content: center;
                padding: 8px;
            }

            .new-button > pl-icon {
                font-size: 80%;
                width: 30px;
                height: 30px;
            }

            .settings {
                padding: 8px;
            }

            .settings > button,
            .settings > pl-loading-button {
                text-align: center;
                display: block;
                font-weight: bold;
            }

            .settings .item {
                margin: 8px 0;
            }

            .settings h3 {
                margin: 18px 8px 12px 8px;
                text-align: center;
            }

            .settings button {
                width: 100%;
            }

            .error.item button {
                width: 100%;
                margin-top: 8px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.property)(),
    __metadata("design:type", String)
], OrgView.prototype, "orgId", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#filterMembersInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_9__.Input)
], OrgView.prototype, "_filterMembersInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#rotateKeysButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_14__.LoadingButton)
], OrgView.prototype, "_rotateKeysButton", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.dialog)("pl-vault-dialog"),
    __metadata("design:type", _vault_dialog__WEBPACK_IMPORTED_MODULE_10__.VaultDialog)
], OrgView.prototype, "_vaultDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.dialog)("pl-group-dialog"),
    __metadata("design:type", _group_dialog__WEBPACK_IMPORTED_MODULE_11__.GroupDialog)
], OrgView.prototype, "_groupDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.dialog)("pl-member-dialog"),
    __metadata("design:type", _member_dialog__WEBPACK_IMPORTED_MODULE_12__.MemberDialog)
], OrgView.prototype, "_memberDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.dialog)("pl-create-invites-dialog"),
    __metadata("design:type", _create_invites_dialog__WEBPACK_IMPORTED_MODULE_13__.CreateInvitesDialog)
], OrgView.prototype, "_createInvitesDialog", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.property)(),
    __metadata("design:type", String)
], OrgView.prototype, "_page", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.property)(),
    __metadata("design:type", String)
], OrgView.prototype, "_membersFilter", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.observe)("orgId"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], OrgView.prototype, "_orgChanged", null);
OrgView = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.element)("pl-org-view")
], OrgView);



/***/ }),

/***/ "../app/src/elements/orgs-list.ts":
/*!****************************************!*\
  !*** ../app/src/elements/orgs-list.ts ***!
  \****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "OrgsList": () => (/* binding */ OrgsList)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _view__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./view */ "../app/src/elements/view.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};






let OrgsList = class OrgsList extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_1__.StateMixin)(_view__WEBPACK_IMPORTED_MODULE_4__.View) {
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_3__.html `
            <header>
                <pl-icon class="tap menu-button" icon="menu" @click=${() => this.dispatch("toggle-menu")}></pl-icon>

                <div class="title flex">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Orgs & Teams")}</div>

                <pl-icon></pl-icon>
            </header>

            <main>
                <div class="orgs">
                    ${_globals__WEBPACK_IMPORTED_MODULE_2__.app.orgs.map(org => _base__WEBPACK_IMPORTED_MODULE_3__.html `
                            <div class="org item tap" @click=${() => _globals__WEBPACK_IMPORTED_MODULE_2__.router.go(`orgs/${org.id}`)}>
                                <pl-icon class="org-icon" icon="org"></pl-icon>

                                <div class="org-info">
                                    <div class="org-name ellipsis">${org.name}</div>

                                    <div class="tags small">
                                        <div class="tag">
                                            <pl-icon icon="org"></pl-icon>

                                            <div>${org.members.length}</div>
                                        </div>

                                        <div class="tag">
                                            <pl-icon icon="group"></pl-icon>

                                            <div>${org.groups.length}</div>
                                        </div>

                                        <div class="tag">
                                            <pl-icon icon="vault"></pl-icon>

                                            <div>${org.vaults.length}</div>
                                        </div>

                                        <div class="warning tag" ?hidden=${!org.frozen}>
                                            <pl-icon icon="error"></pl-icon>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        `)}
                </div>

                <div class="empty-placeholder" ?hidden=${!!_globals__WEBPACK_IMPORTED_MODULE_2__.app.orgs.length}>
                    <pl-icon icon="org"></pl-icon>

                    <div>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Organizations allow you to securely share passwords, documents and other data " +
            "within your family, team or any other kind of group!")}
                    </div>

                    <button class="primary tap" @click=${() => this.dispatch("create-org")}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Create Organization")}
                    </button>
                </div>

                <div class="fabs">
                    <div class="flex"></div>

                    <pl-icon icon="add" class="tap fab" @click=${() => this.dispatch("create-org")}></pl-icon>
                </div>
            </main>
        `;
    }
};
OrgsList.styles = [
    ..._view__WEBPACK_IMPORTED_MODULE_4__.View.styles,
    _base__WEBPACK_IMPORTED_MODULE_3__.css `
            :host {
                background: var(--color-quaternary);
                display: flex;
                flex-direction: column;
            }

            .orgs {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
                grid-gap: 12px;
                margin: 12px;
            }

            .orgs > * {
                margin: 0;
            }

            .org {
                padding: 16px;
                display: flex;
                align-items: center;
            }

            .org-icon {
                font-size: 120%;
                margin-right: 12px;
                background: #eee;
                border: solid 1px #ddd;
                width: 50px;
                height: 50px;
            }

            .org .tags {
                margin: 4px 0;
            }

            .org-name {
                font-weight: bold;
                margin-bottom: 4px;
                font-size: 120%;
                font-weight: 600;
            }

            .org-info {
                flex: 1;
                width: 0;
            }

            .new-org {
                background: none;
                border: dashed 1px;
                font-weight: bold;
            }
        `
];
OrgsList = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.element)("pl-orgs-list")
], OrgsList);



/***/ }),

/***/ "../app/src/elements/password-input.ts":
/*!*********************************************!*\
  !*** ../app/src/elements/password-input.ts ***!
  \*********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "PasswordInput": () => (/* binding */ PasswordInput)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};



let PasswordInput = class PasswordInput extends _input__WEBPACK_IMPORTED_MODULE_1__.Input {
    constructor() {
        super();
        this.type = "password";
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            ${super.render()}

            <pl-icon
                icon="${this.type === "password" ? "show" : "hide"}"
                class="mask-icon tap"
                @click=${this._toggleMasked}
            >
            </pl-icon>
        `;
    }
    _toggleMasked() {
        this.type = this.type === "password" ? "text" : "password";
    }
};
PasswordInput.styles = [
    ..._input__WEBPACK_IMPORTED_MODULE_1__.Input.styles,
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            input {
                font-size: 120%;
                font-family: var(--font-family-mono);
            }

            .mask-icon {
                position: absolute;
                z-index: 1;
                right: 5px;
                top: 0;
                bottom: 0;
                margin: auto;
                opacity: 0.8;
            }
        `
];
PasswordInput = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.element)("pl-password-input"),
    __metadata("design:paramtypes", [])
], PasswordInput);



/***/ }),

/***/ "../app/src/elements/premium-dialog.ts":
/*!*********************************************!*\
  !*** ../app/src/elements/premium-dialog.ts ***!
  \*********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "PremiumDialog": () => (/* binding */ PremiumDialog)
/* harmony export */ });
/* harmony import */ var lit_html_directives_unsafe_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/unsafe-html */ "../app/node_modules/lit-html/directives/unsafe-html.js");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _card_input__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./card-input */ "../app/src/elements/card-input.ts");
/* harmony import */ var _billing_dialog__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./billing-dialog */ "../app/src/elements/billing-dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











let PremiumDialog = class PremiumDialog extends _dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog {
    constructor() {
        super(...arguments);
        this.plan = null;
        this._error = "";
        this._updateBillingParams = null;
    }
    async _submit() {
        if (this._submitButton.state === "loading") {
            return;
        }
        this._error = "";
        this._submitButton.start();
        const params = this._updateBillingParams ||
            new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.UpdateBillingParams({
                account: _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.id
            });
        params.plan = this.plan.id;
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateBilling(params);
            this._submitButton.success();
            this.done();
        }
        catch (e) {
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!");
            this._submitButton.fail();
            return;
        }
    }
    async show() {
        const result = super.show();
        const plan = _globals__WEBPACK_IMPORTED_MODULE_5__.app.state.billingProvider && _globals__WEBPACK_IMPORTED_MODULE_5__.app.state.billingProvider.plans.find(p => p.type === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.PlanType.Premium);
        if (plan) {
            this.plan = plan;
            this._error = "";
            this._updateBillingParams = null;
        }
        else {
            this.done();
        }
        return result;
    }
    async _updateBillingInfo() {
        this.open = false;
        const billing = await this._billingDialog.show({
            billingInfo: Object.assign(new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_2__.BillingInfo(), { account: _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.id })
        });
        if (billing) {
            this._updateBillingParams = billing;
            this._error = "";
        }
        this.open = true;
    }
    renderContent() {
        if (!this.plan || !_globals__WEBPACK_IMPORTED_MODULE_5__.app.account) {
            return _base__WEBPACK_IMPORTED_MODULE_6__.html ``;
        }
        const plan = this.plan;
        const monthlyPrice = Math.round(plan.cost / 12);
        const paymentMethod = (this._updateBillingParams && this._updateBillingParams.paymentMethod) ||
            (_globals__WEBPACK_IMPORTED_MODULE_5__.app.account.billing && _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.billing.paymentMethod);
        const trialDaysLeft = _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.billing ? _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.billing.trialDaysLeft : 30;
        return _base__WEBPACK_IMPORTED_MODULE_6__.html `
            <div
                class="plan"
                style=${plan.color
            ? `--color-highlight: ${plan.color}; --color-highlight-text: var(--color-tertiary);`
            : ""}
            >
                <div class="plan-header">
                    <pl-icon class="tap close-icon" icon="cancel" @click=${() => this.done()}></pl-icon>

                    <div class="plan-name">
                        ${plan.name}
                    </div>

                    <div class="flex"></div>

                    <div class="plan-trial" ?hidden=${!trialDaysLeft}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Free For {0} Days", trialDaysLeft.toString())}
                    </div>

                    <div class="plan-then" ?hidden=${!trialDaysLeft}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("then")}
                    </div>

                    <div class="plan-price">
                        <div class="plan-price-currency">$</div>
                        <div class="plan-price-dollars">
                            ${Math.floor(monthlyPrice / 100)}
                        </div>
                        <div class="plan-price-cents">
                            .${(monthlyPrice % 100).toString().padEnd(2, "0")}
                        </div>
                    </div>

                    <div class="plan-unit">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("per month")}
                    </div>

                    <div class="flex"></div>

                    <div class="plan-fineprint">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("USD, billed annually")}
                    </div>
                </div>

                <ul class="features">
                    ${plan.features.map(feature => _base__WEBPACK_IMPORTED_MODULE_6__.html `
                            <li>
                                ${(0,lit_html_directives_unsafe_html__WEBPACK_IMPORTED_MODULE_0__.unsafeHTML)(feature.replace(/\*\*(.+)\*\*/g, "<strong>$1</strong>"))}
                            </li>
                        `)}
                </ul>

                <div class="payment-method item tap" @click=${this._updateBillingInfo}>
                    <pl-icon icon="credit"></pl-icon>
                    ${paymentMethod
            ? _base__WEBPACK_IMPORTED_MODULE_6__.html `
                              <div>
                                  ${paymentMethod.name}
                              </div>
                          `
            : _base__WEBPACK_IMPORTED_MODULE_6__.html `
                              <div>
                                  ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Add Billing Info")}
                              </div>
                          `}
                </div>

                <div class="error item" ?hidden="${!this._error}">
                    ${this._error}
                </div>

                <pl-loading-button id="submitButton" class="tap primary" @click=${this._submit}>
                    ${trialDaysLeft ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Start Trial") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Buy Now")}
                </pl-loading-button>
            </div>
        `;
    }
};
PremiumDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_6__.css `
            .plan {
                height: 100%;
                display: flex;
                flex-direction: column;
            }

            .inner {
                background: var(--color-quaternary);
                text-align: center;
            }

            .plan-header {
                text-align: center;
                padding: 20px;
                /* background: linear-gradient(180deg, #59c6ff 0%, #077cb9 100%); */
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                display: flex;
                flex-direction: column;
                position: relative;
            }

            .close-icon {
                position: absolute;
                top: 8px;
                right: 8px;
            }

            .plan-name {
                font-size: 2rem;
                margin-bottom: 10px;
                font-weight: bold;
            }

            .plan-trial {
                font-size: 1.5rem;
                margin-bottom: 10px;
            }

            .plan-then {
                font-size: var(--font-size-small);
                margin-bottom: 10px;
            }

            .plan-price {
                letter-spacing: 0.1em;
                display: flex;
                align-items: flex-start;
                justify-content: center;
                font-weight: bold;
                font-size: 1.2rem;
                margin: 5px;
            }

            .plan-price-currency {
                line-height: 1em;
                margin-top: 0.4em;
            }

            .plan-price-dollars {
                font-size: 3em;
                line-height: 1em;
            }

            .plan-price-cents {
                font-size: 1.5em;
                line-height: 1em;
                margin-top: 0.2em;
            }

            .plan-unit {
                font-size: var(--font-size-small);
                margin-bottom: 15px;
            }

            .plan-fineprint {
                font-size: var(--font-size-tiny);
                opacity: 0.8;
            }

            .quantity {
                font-size: 1.6rem;
                margin-top: 20px;
            }

            pl-loading-button {
                font-weight: bold;
            }

            pl-loading-button.primary {
                margin: 8px;
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                font-weight: bold;
                border-bottom: solid 3px var(--color-shade-2);
            }

            .error {
                color: var(--color-negative);
                padding: 8px;
                text-align: center;
            }

            .payment-method {
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 4px;
                font-weight: bold;
                margin-bottom: 0;
            }

            .change-plan {
                background: transparent;
                color: var(--color-tertiary);
                font-weight: bold;
                margin: 4px;
            }

            .features {
                font-size: var(--font-size-small);
                margin-top: 8px;
                flex: 1;
                ${_styles__WEBPACK_IMPORTED_MODULE_4__.mixins.scroll()}
            }

            .features > * {
                padding: 10px 15px;
            }

            .features > :not(:last-child) {
                border-bottom: solid 1px var(--color-shade-1);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], PremiumDialog.prototype, "plan", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], PremiumDialog.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", Object)
], PremiumDialog.prototype, "_updateBillingParams", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#submitButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_8__.LoadingButton)
], PremiumDialog.prototype, "_submitButton", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.dialog)("pl-billing-dialog"),
    __metadata("design:type", _billing_dialog__WEBPACK_IMPORTED_MODULE_10__.BillingDialog)
], PremiumDialog.prototype, "_billingDialog", void 0);
PremiumDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.element)("pl-premium-dialog")
], PremiumDialog);



/***/ }),

/***/ "../app/src/elements/prompt-dialog.ts":
/*!********************************************!*\
  !*** ../app/src/elements/prompt-dialog.ts ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "PromptDialog": () => (/* binding */ PromptDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





const defaultConfirmLabel = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("OK");
const defaultCancelLabel = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel");
const defaultType = "text";
const defaultPlaceholder = "";
let PromptDialog = class PromptDialog extends _dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog {
    constructor() {
        super(...arguments);
        this.confirmLabel = defaultConfirmLabel;
        this.cancelLabel = defaultCancelLabel;
        this.title = "";
        this.message = "";
        this.placeholder = defaultPlaceholder;
        this.label = "";
        this.preventDismiss = true;
        this.type = defaultType;
        this.pattern = "";
        this._validationMessage = "";
    }
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <div class="content">
                <h1 ?hidden=${!this.title}>${this.title}</h1>

                <div class="message" ?hidden=${!this.message}>${this.message}</div>

                <pl-input
                    class="tap"
                    .type=${this.type}
                    .placeholder=${this.placeholder}
                    .label=${this.label}
                    .pattern=${this.pattern}
                    @enter=${() => this._confirmButton.click()}
                >
                </pl-input>

                <div class="actions">
                    <pl-loading-button
                        id="confirmButton"
                        class="tap ${this.type === "destructive" ? "negative" : "primary"}"
                        @click=${() => this._confirm()}
                    >
                        ${this.confirmLabel}
                    </pl-loading-button>

                    <button class="tap" @click=${() => this.done(null)} ?hidden=${!this.cancelLabel}>
                        ${this.cancelLabel}
                    </button>
                </div>
            </div>
        `;
    }
    renderAfter() {
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <div class="validation-message" slot="after">${this._validationMessage}</div>
        `;
    }
    done(val) {
        this._validationMessage = "";
        super.done(val);
    }
    async show({ title = "", message = "", placeholder = defaultPlaceholder, label = "", value = "", type = defaultType, pattern = "", confirmLabel = defaultConfirmLabel, cancelLabel = defaultCancelLabel, preventDismiss = true, preventAutoClose = false, validate } = {}) {
        this.title = title;
        this.message = message;
        this.type = type;
        this.pattern = pattern;
        this.placeholder = placeholder;
        this.label = label;
        this.confirmLabel = confirmLabel;
        this.cancelLabel = cancelLabel;
        this.preventDismiss = preventDismiss;
        this.preventAutoClose = preventAutoClose;
        this.validate = validate;
        this._validationMessage = "";
        await this.updateComplete;
        this._confirmButton.stop();
        this._input.value = value;
        setTimeout(() => this._input.focus(), 300);
        return super.show();
    }
    async _confirm() {
        let val = this._input.value;
        if (this.validate) {
            this._confirmButton.start();
            try {
                val = await this.validate(val, this._input);
                this._confirmButton.success();
                this.done(val);
            }
            catch (e) {
                this.rumble();
                this._validationMessage = e;
                this._confirmButton.fail();
            }
        }
        else {
            this.done(val);
        }
    }
};
PromptDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_4__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            h1 {
                display: block;
                text-align: center;
            }

            .message {
                margin: 20px;
                text-align: center;
            }

            pl-input {
                text-align: center;
                margin: 8px;
            }

            .validation-message {
                position: relative;
                margin-top: 15px;
                font-weight: bold;
                font-size: var(--font-size-small);
                color: var(--color-error);
                text-shadow: none;
                text-align: center;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "confirmLabel", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "cancelLabel", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "title", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "message", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "placeholder", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "label", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Boolean)
], PromptDialog.prototype, "preventDismiss", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)({ reflect: true }),
    __metadata("design:type", String)
], PromptDialog.prototype, "type", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "pattern", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Function)
], PromptDialog.prototype, "validate", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], PromptDialog.prototype, "_validationMessage", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.query)("#confirmButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_3__.LoadingButton)
], PromptDialog.prototype, "_confirmButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.query)("pl-input"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_2__.Input)
], PromptDialog.prototype, "_input", void 0);
PromptDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-prompt-dialog")
], PromptDialog);



/***/ }),

/***/ "../app/src/elements/qr-dialog.ts":
/*!****************************************!*\
  !*** ../app/src/elements/qr-dialog.ts ***!
  \****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "QRDialog": () => (/* binding */ QRDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _view__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./view */ "../app/src/elements/view.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};








let QRDialog = class QRDialog extends _dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog {
    constructor() {
        super(...arguments);
        this.hideApp = true;
    }
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <header>
                <pl-icon></pl-icon>
                <div class="title flex">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Scan QR Code")}
                </div>
                <pl-icon class="tap" icon="close" @click=${() => this.done()}></pl-icon>
            </header>
            <canvas></canvas>
            <div class="seeker"></div>
        `;
    }
    async show() {
        (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.scanQR)().then((res) => this.done(res), (err) => {
            this.done();
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Failed to scan QR code. Error: " + err.toString()), {
                type: "warning"
            });
        });
        return super.show();
    }
    done(data) {
        (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.stopScanQR)();
        super.done(data);
    }
};
QRDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog.styles,
    ..._view__WEBPACK_IMPORTED_MODULE_6__.View.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            .inner {
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.fullbleed()}
                border-radius: 0;
                max-width: 100%;
                display: flex;
                flex-direction: column;
                background: transparent;
            }

            .scrim {
                background: transparent;
            }

            .seeker {
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.fullbleed()}
                width: 300px;
                height: 300px;
                border: solid 3px var(--color-negative);
                border-radius: var(--border-radius);
                margin: auto;
            }
        `
];
QRDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-qr-dialog")
], QRDialog);



/***/ }),

/***/ "../app/src/elements/randomart.ts":
/*!****************************************!*\
  !*** ../app/src/elements/randomart.ts ***!
  \****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Fingerprint": () => (/* binding */ Fingerprint)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_randomart__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/randomart */ "../core/src/randomart.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var lit_html__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lit-html */ "../app/node_modules/lit-html/lit-html.js");
/* harmony import */ var lit_html_directives_until__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lit-html/directives/until */ "../app/node_modules/lit-html/directives/until.js");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





let Fingerprint = class Fingerprint extends _base__WEBPACK_IMPORTED_MODULE_4__.BaseElement {
    async _grid() {
        const size = 11;
        const fingerprint = await (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.getCryptoProvider)().fingerprint(this.key);
        const art = (0,_padloc_core_src_randomart__WEBPACK_IMPORTED_MODULE_0__.randomArt)(fingerprint, { width: size, height: size });
        const rects = [];
        for (const [x, line] of art.values.entries()) {
            for (const [y, val] of line.entries()) {
                rects.push(lit_html__WEBPACK_IMPORTED_MODULE_2__.svg `<rect x="${x}" y="${y}" width="1" height="1" opacity="${val / 10}" />`);
            }
        }
        return lit_html__WEBPACK_IMPORTED_MODULE_2__.svg `
            <svg viewBox="0 0 ${size} ${size}">
                ${rects}
            </svg>
        `;
    }
    shouldUpdate() {
        return !!this.key;
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            ${(0,lit_html_directives_until__WEBPACK_IMPORTED_MODULE_3__.until)(this._grid())}
        `;
    }
};
Fingerprint.styles = [
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            :host {
                display: block;
                width: 100px;
                height: 100px;
                position: relative;
                overflow: hidden;
                background: var(--color-background);
                color: var(--color-foreground);
            }

            svg {
                width: 100%;
                height: 100%;
                fill: currentColor;
                pointer-events: none;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Uint8Array)
], Fingerprint.prototype, "key", void 0);
Fingerprint = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-fingerprint")
], Fingerprint);



/***/ }),

/***/ "../app/src/elements/recover.ts":
/*!**************************************!*\
  !*** ../app/src/elements/recover.ts ***!
  \**************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Recover": () => (/* binding */ Recover)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/mfa */ "../core/src/mfa.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _start_form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./start-form */ "../app/src/elements/start-form.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};










let Recover = class Recover extends _start_form__WEBPACK_IMPORTED_MODULE_5__.StartForm {
    constructor() {
        super(...arguments);
        this._weakPassword = false;
    }
    get _email() {
        return _globals__WEBPACK_IMPORTED_MODULE_3__.router.params.email || "";
    }
    async reset() {
        this._passwordInput.value = "";
        this._repeatPasswordInput.value = "";
        this._submitButton.stop();
        super.reset();
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <div flex></div>

            <form>
                <button class="back-button tap animate" type="button" @click=${() => _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("login")}>
                    <pl-icon icon="backward"></pl-icon>
                    <div>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Back To Login")}
                    </div>
                </button>

                <h1 class="animate">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Recover Account")}</h1>

                <div class="title animate">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter your email address and new master password.")}
                </div>

                <pl-input
                    id="emailInput"
                    type="email"
                    required
                    .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Email Address")}
                    .value=${this._email}
                    class="tiles-2 animate"
                    @enter=${() => this._submit()}
                >
                </pl-input>

                <pl-input
                    id="passwordInput"
                    type="password"
                    required
                    .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("New Master Password")}
                    class="tiles-2 animate"
                    @change=${() => this._updatePwdStrength()}
                    @enter=${() => this._submit()}
                >
                </pl-input>

                <div class="error note" ?hidden=${!this._weakPassword}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("WARNING: Weak Password!")}</div>

                <pl-input
                    id="repeatPasswordInput"
                    type="password"
                    required
                    .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Repeat Master Password")}
                    class="tiles-2 animate"
                    @enter=${() => this._submit()}
                >
                </pl-input>

                <div class="error note animate recovery-notes">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("IMPORTANT, READ CAREFULLY: Padloc is designed in a way that makes it impossible " +
            "for us to access the data encrypted in any of your vaults even if we wanted to. " +
            "While this is essential to ensuring the security of your data, it also has the " +
            "following implications:")}
                    <ul>
                        <li>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Any data stored in your private vault can not be recovered and will be permantently lost.")}
                        </li>
                        <li>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("All your organization memberships will be suspended temporarily until " +
            "confirmed by the organization owner.")}
                        </li>
                        <li>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("All members of organizations you own will be suspended temporarily until " +
            "confirmed by you.")}
                        </li>
                    </ul>
                </div>

                <pl-loading-button id="submitButton" class="tap animate" @click=${() => this._submit()}>
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Recover Account")}
                </pl-loading-button>
            </form>

            <div flex></div>
        `;
    }
    async _submit() {
        if (this._submitButton.state === "loading") {
            return;
        }
        this._emailInput.blur();
        this._passwordInput.blur();
        if (this._emailInput.invalid) {
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_8__.alert)(this._emailInput.validationMessage || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter a valid email address!"), {
                type: "warning"
            });
            return;
        }
        if (!this._passwordInput.value) {
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_8__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter a master password!"), { type: "warning" });
            return;
        }
        if (this._passwordInput.value !== this._repeatPasswordInput.value) {
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_8__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You didn't repeat your master password correctly. Try again!"), { type: "warning" });
            return;
        }
        const email = this._emailInput.value;
        const password = this._passwordInput.value;
        const strength = await (0,_lib_util__WEBPACK_IMPORTED_MODULE_9__.passwordStrength)(password);
        if (strength.score < 2) {
            const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_8__.choose)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("The password you entered is weak which makes it easier for attackers to break " +
                "the encryption used to protect your data. Try to use a longer password or include a " +
                "variation of uppercase, lowercase and special characters as well as numbers!"), [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Learn More"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose Different Password"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Use Anyway")], {
                type: "warning",
                title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("WARNING: Weak Password"),
                hideIcon: true,
                preventDismiss: true
            });
            switch (choice) {
                case 0:
                    this._openPwdHowTo();
                    return;
                case 1:
                    this._passwordInput.focus();
                    return;
            }
        }
        await _globals__WEBPACK_IMPORTED_MODULE_3__.app.requestMFACode(email, _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_2__.MFAPurpose.Recover);
        return this._recover(email, password);
    }
    async _recover(email, password) {
        this._submitButton.start();
        const verify = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_8__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("To complete the account recovery process, please enter " +
            "the confirmation code sent to your email address!"), {
            placeholder: "Enter Verification Code",
            confirmLabel: "Submit",
            validate: async (code) => {
                try {
                    return await _globals__WEBPACK_IMPORTED_MODULE_3__.app.retrieveMFAToken(email, code, _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_2__.MFAPurpose.Recover);
                }
                catch (e) {
                    if (e.code === _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.MFA_TRIES_EXCEEDED) {
                        (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_8__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Maximum number of tries exceeded! Please resubmit and try again!"), {
                            type: "warning"
                        });
                        return "";
                    }
                    throw e.message || e.code || e.toString();
                }
            }
        });
        if (!verify) {
            this._submitButton.stop();
            return;
        }
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.recoverAccount({ email, password, verify: verify.token });
            this._submitButton.success();
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_8__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Account recovery successful!"), { type: "success" });
            _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("login");
        }
        catch (e) {
            this._submitButton.fail();
            throw e;
        }
    }
    async _updatePwdStrength() {
        const pwd = this._passwordInput.value;
        const result = await (0,_lib_util__WEBPACK_IMPORTED_MODULE_9__.passwordStrength)(pwd);
        const score = result.score;
        this._weakPassword = score < 3;
    }
    _openPwdHowTo() {
        window.open("https://padlock.io/howto/choose-master-password/", "_system");
    }
};
Recover.styles = [
    ..._start_form__WEBPACK_IMPORTED_MODULE_5__.StartForm.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            h1 {
                display: block;
                text-align: center;
                margin: 10px;
            }

            .title {
                width: 300px;
                margin: 10px auto 30px auto;
                font-size: var(--font-size-small);
                font-weight: bold;
                letter-spacing: 0.5px;
                padding: 0 10px;
            }

            #submitButton {
                margin-bottom: 30px;
            }

            .login {
                text-decoration: underline;
                cursor: pointer;
            }

            .recovery-notes {
                text-align: left;
                padding: 20px;
                margin: 10px;
            }

            .recovery-notes ul {
                list-style: disc;
            }

            .recovery-notes li {
                margin: 10px 20px 0 20px;
                background: transparent;
                border: none;
            }

            .back-button {
                display: flex;
                align-items: center;
                padding: 4px 8px 4px 4px;
                background: transparent;
                align-self: flex-start;
                margin-top: 20px;
            }

            .back-button:not:hover {
                opacity: 0.8;
            }

            .back-button pl-icon {
                width: 15px;
                height: 15px;
                margin-right: 4px;
                font-size: 0.8em;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], Recover.prototype, "_weakPassword", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#emailInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_6__.Input)
], Recover.prototype, "_emailInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#passwordInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_6__.Input)
], Recover.prototype, "_passwordInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#repeatPasswordInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_6__.Input)
], Recover.prototype, "_repeatPasswordInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#submitButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], Recover.prototype, "_submitButton", void 0);
Recover = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-recover")
], Recover);



/***/ }),

/***/ "../app/src/elements/report-errors-dialog.ts":
/*!***************************************************!*\
  !*** ../app/src/elements/report-errors-dialog.ts ***!
  \***************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ReportErrorsDialog": () => (/* binding */ ReportErrorsDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};





let ReportErrorsDialog = class ReportErrorsDialog extends _dialog__WEBPACK_IMPORTED_MODULE_3__.Dialog {
    _reportErrors() {
        const email = "support@padloc.app" || 0;
        const subject = "Padloc Error Report";
        const message = `

----- enter your comment above -----

IMPORTANT: Please verify that the message below does not contain any sensitive data before sending this email!

The following errors occurred:

${_globals__WEBPACK_IMPORTED_MODULE_1__.app.state._errors.join("\n\n")}

Device Info:

${JSON.stringify(_globals__WEBPACK_IMPORTED_MODULE_1__.app.state.device.toRaw(), null, 4)}
`;
        (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_4__.composeEmail)(email, subject, message);
        this._dismissErrors();
    }
    _dismissErrors() {
        _globals__WEBPACK_IMPORTED_MODULE_1__.app.setState({ _errors: [] });
        this.done();
    }
    renderContent() {
        return _base__WEBPACK_IMPORTED_MODULE_2__.html `
            <header>
                <div class="title flex">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Report Errors")}
                </div>
            </header>

            <div class="content">
                <div class="error note item">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} Errors Detected", _globals__WEBPACK_IMPORTED_MODULE_1__.app.state._errors.length.toString())}</div>
                <div class="message">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Padloc has registered {0} errors during your use of the app. " +
            "These errors may not have any impact on functionality and can often be ignored, " +
            "but reporting them may help us diagnose problems, identify possible failure " +
            "modes and generally improve the stability of the app.", _globals__WEBPACK_IMPORTED_MODULE_1__.app.state._errors.length.toString())}
                </div>
                <div class="actions">
                    <button class="primary tap" @click=${this._reportErrors}>Report</button>
                    <button class="tap" @click=${this._dismissErrors}>Dismiss</button>
                </div>
            </div>
        `;
    }
};
ReportErrorsDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_3__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_2__.css `
            .message {
                margin: 18px;
            }
        `
];
ReportErrorsDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_2__.element)("pl-report-errors-dialog")
], ReportErrorsDialog);



/***/ }),

/***/ "../app/src/elements/select.ts":
/*!*************************************!*\
  !*** ../app/src/elements/select.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Select": () => (/* binding */ Select)
/* harmony export */ });
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};


let Select = class Select extends _base__WEBPACK_IMPORTED_MODULE_1__.BaseElement {
    constructor() {
        super(...arguments);
        this.options = [];
        this.label = "";
        this.icon = "";
    }
    render() {
        const { options, selected, label, icon } = this;
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            ${icon
            ? _base__WEBPACK_IMPORTED_MODULE_1__.html `
                      <pl-icon icon=${icon} class="left"></pl-icon>
                  `
            : ""}

            <select
                id="selectEl"
                class="${icon ? "pad-left" : ""}"
                .selectedIndex=${options.indexOf(selected)}
                @change=${() => this._changed()}
            >
                ${options.map(o => _base__WEBPACK_IMPORTED_MODULE_1__.html `
                        <option>${o}</option>
                    `)}
            </select>

            <pl-icon icon="dropdown" class="right"></pl-icon>

            <label for="selectEl" float>${label}</label>
        `;
    }
    async _propsChanged() {
        if (!this.selected) {
            this.selected = this.options[0];
        }
        await this.updateComplete;
        this._select.selectedIndex = this.options.indexOf(this.selected);
    }
    _changed() {
        this.selected = this.options[this._select.selectedIndex];
        this.dispatch("change");
    }
};
Select.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_0__.shared,
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            :host {
                display: block;
                position: relative;
                padding: 0;
                height: var(--row-height);
                padding: 0 15px;
                background: var(--shade-2-color);
                border-radius: var(--border-radius);
            }

            select {
                width: 100%;
                height: 100%;
                box-sizing: border-box;
                cursor: pointer;
            }

            select.pad-left {
                padding-left: 30px;
            }

            option {
                background-color: var(--color-tertiary);
                color: var(--color-secondary);
            }

            label {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                padding: 13px;
                opacity: 0.5;
                transition: transform 0.2s, color 0.2s, opacity 0.5s;
                cursor: text;
                pointer-events: none;
            }

            label[float] {
                transform: scale(0.8) translate(0, -32px);
                color: var(--color-highlight);
                font-weight: bold;
                opacity: 1;
            }

            pl-icon {
                position: absolute;
                width: 20px;
                height: 20px;
                top: 0;
                bottom: 0;
                margin: auto;
                pointer-events: none;
            }

            pl-icon.right {
                right: 12px;
            }

            pl-icon.left {
                left: 14px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Array)
], Select.prototype, "options", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Object)
], Select.prototype, "selected", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], Select.prototype, "label", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], Select.prototype, "icon", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.query)("select"),
    __metadata("design:type", HTMLSelectElement)
], Select.prototype, "_select", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.observe)("options"),
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.observe)("selected"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Select.prototype, "_propsChanged", null);
Select = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-select")
], Select);



/***/ }),

/***/ "../app/src/elements/settings.ts":
/*!***************************************!*\
  !*** ../app/src/elements/settings.ts ***!
  \***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Settings": () => (/* binding */ Settings)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _view__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./view */ "../app/src/elements/view.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _import_dialog__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./import-dialog */ "../app/src/elements/import-dialog.ts");
/* harmony import */ var _export_dialog__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./export-dialog */ "../app/src/elements/export-dialog.ts");
/* harmony import */ var _billing_info__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./billing-info */ "../app/src/elements/billing-info.ts");
/* harmony import */ var _randomart__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./randomart */ "../app/src/elements/randomart.ts");
/* harmony import */ var _subscription__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subscription */ "../app/src/elements/subscription.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};















let Settings = class Settings extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_6__.StateMixin)(_view__WEBPACK_IMPORTED_MODULE_8__.View) {
    shouldUpdate() {
        return !!_globals__WEBPACK_IMPORTED_MODULE_5__.app.account;
    }
    render() {
        const { settings, billingEnabled } = _globals__WEBPACK_IMPORTED_MODULE_5__.app;
        const account = _globals__WEBPACK_IMPORTED_MODULE_5__.app.account;
        const billing = account.billing || new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.BillingInfo();
        return _base__WEBPACK_IMPORTED_MODULE_7__.html `
            <header>
                <pl-icon class="tap menu-button" icon="menu" @click=${() => this.dispatch("toggle-menu")}></pl-icon>

                <div class="title flex">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Settings")}</div>

                <pl-icon></pl-icon>
            </header>

            <main>
                <div class="wrapper">
                    <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Profile")}</h3>

                    <div class="account item">
                        <pl-fingerprint .key=${account.publicKey}></pl-fingerprint>

                        <div class="account-info">
                            <div class="account-name">${account.name}</div>

                            <div class="account-email">${account.email}</div>
                        </div>

                        <pl-icon class="tap" icon="edit" @click=${() => this._editAccount()}></pl-icon>
                    </div>

                    <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Security")}</h3>

                    <button class="tap item" @click=${() => this._logout()}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Log Out")}</button>

                    <button class="tap item" @click=${() => this._changePassword()}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Change Master Password")}
                    </button>

                    ${billingEnabled
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                              <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Subscription")}</h3>

                              <pl-subscription class="item"></pl-subscription>

                              <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Billing Info")}</h3>

                              <pl-billing-info .billing=${billing} class="item"></pl-billing-info>
                          `
            : _base__WEBPACK_IMPORTED_MODULE_7__.html ``}

                    <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Auto Lock")}</h3>

                    <pl-toggle-button
                        id="autoLockButton"
                        .active=${settings.autoLock}
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Lock Automatically")}
                        class="item tap"
                        reverse
                    >
                    </pl-toggle-button>

                    <pl-slider
                        id="autoLockDelaySlider"
                        .min="1"
                        .max="10"
                        .step="1"
                        .value=${settings.autoLockDelay}
                        .unit=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)(" min")}
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("After")}
                        ?hidden=${!settings.autoLock}
                        class="item"
                    >
                    </pl-slider>

                    ${_globals__WEBPACK_IMPORTED_MODULE_5__.app.supportsBiometricUnlock
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                              <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Biometric Unlock")}</h3>
                              <pl-toggle-button
                                  id="biometricUnlockButton"
                                  .active=${_globals__WEBPACK_IMPORTED_MODULE_5__.app.remembersMasterKey}
                                  .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enable Biometric Unlock")}
                                  class="item tap"
                                  reverse
                                  @change=${this._toggleBiometricUnlock}
                              >
                              </pl-toggle-button>
                          `
            : ""}

                    <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Import / Export")}</h3>

                    <button class="item tap" @click=${() => this._import()}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Import...")}</button>

                    <button class="item tap" @click=${() => this._export()}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Export...")}</button>

                    <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Support")}</h3>

                    <button @click=${() => this._openWebsite()} class="item tap">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Website")}</button>

                    <button @click=${() => this._sendMail()} class="item tap">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Contact Support")}</button>

                    <h3>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Danger Zone")}</h3>

                    <button @click=${() => this._deleteAccount()} class="item tap negative">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Account")}
                    </button>
                </div>
            </main>

            <input type="file" accept="text/plain,.csv,.pls,.set,.pbes2" hidden @change=${() => this._importFile()} />
        `;
    }
    _updateSettings() {
        _globals__WEBPACK_IMPORTED_MODULE_5__.app.setSettings({
            autoLock: this.$("#autoLockButton").active,
            autoLockDelay: this.$("#autoLockDelaySlider").value
        });
    }
    _editAccount() {
        const account = _globals__WEBPACK_IMPORTED_MODULE_5__.app.account;
        (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.prompt)("", {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Edit Profile"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Save"),
            value: account.name,
            label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Name"),
            validate: async (name) => {
                if (!name) {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter a name!");
                }
                if (name !== account.name) {
                    await _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateAccount(async (account) => (account.name = name));
                }
                return name;
            }
        });
    }
    async _logout() {
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Do you really want to log out?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Log Out"));
        if (confirmed) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.app.logout();
        }
    }
    //* Opens the change password dialog and resets the corresponding input elements
    async _changePassword() {
        const success = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter your current password!"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Change Master Password"),
            label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Current Password"),
            type: "password",
            validate: async (pwd) => {
                try {
                    await _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.unlock(pwd);
                }
                catch (e) {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Wrong password! Please try again!");
                }
                return pwd;
            }
        });
        if (!success) {
            return;
        }
        const newPwd = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Now choose a new master password!"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Change Master Password"),
            label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter New Password"),
            type: "password",
            validate: async (val) => {
                if (val === "") {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter a password!");
                }
                return val;
            }
        });
        if (newPwd === null) {
            return;
        }
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please confirm your new password!"), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Change Master Password"),
            label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Repeat New Password"),
            type: "password",
            validate: async (pwd) => {
                if (pwd !== newPwd) {
                    throw "Wrong password! Please try again!";
                }
                return pwd;
            }
        });
        if (!confirmed) {
            return;
        }
        await _globals__WEBPACK_IMPORTED_MODULE_5__.app.changePassword(newPwd);
        (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Master password changed successfully."), { type: "success" });
    }
    _openWebsite() {
        window.open("https://padloc.app", "_system");
    }
    _sendMail() {
        const email = "support@padloc.app" || 0;
        const subject = "Padloc Support Request";
        const message = `

----- enter your message above -----

NOTE: Below we have included some information about your device that may help
us analyse any problems you may be having. If you're not comfortable sharing
this data simply delete this of the email!

Device Info: ${JSON.stringify(_globals__WEBPACK_IMPORTED_MODULE_5__.app.state.device.toRaw(), null, 4)}
`;
        (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_2__.composeEmail)(email, subject, message);
    }
    async _import() {
        this._fileInput.click();
    }
    async _importFile() {
        const file = this._fileInput.files[0];
        const reader = new FileReader();
        reader.onload = async () => {
            await this._importDialog.show(reader.result);
            this._fileInput.value = "";
        };
        reader.readAsText(file);
    }
    _export() {
        this._exportDialog.show();
    }
    async _deleteAccount() {
        const success = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter your master password to proceed."), {
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Account"),
            label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Master Password"),
            type: "password",
            validate: async (pwd) => {
                try {
                    await _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.unlock(pwd);
                }
                catch (e) {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Wrong password! Please try again!");
                }
                return pwd;
            }
        });
        if (!success) {
            return;
        }
        const deleted = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to delete this account? " +
            "All associated vaults and the data within them will be lost and any active subscriptions will be canceled immediately. " +
            "This action can not be undone!"), {
            type: "destructive",
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Account"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete"),
            placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Type 'DELETE' to confirm"),
            validate: async (val) => {
                if (val !== "DELETE") {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Type 'DELETE' to confirm");
                }
                try {
                    await _globals__WEBPACK_IMPORTED_MODULE_5__.app.deleteAccount();
                }
                catch (e) {
                    throw e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!");
                }
                return val;
            }
        });
        if (deleted) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("");
        }
    }
    async _toggleBiometricUnlock(e) {
        e.stopPropagation();
        const toggle = e.target;
        console.log(toggle.active);
        if (toggle.active) {
            this.dispatch("enable-biometric-auth");
        }
        else {
            const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to disable biometric unlock?"));
            if (confirmed) {
                await _globals__WEBPACK_IMPORTED_MODULE_5__.app.forgetMasterKey();
            }
            else {
                toggle.active = true;
            }
        }
    }
};
Settings.styles = [
    ..._view__WEBPACK_IMPORTED_MODULE_8__.View.styles,
    _base__WEBPACK_IMPORTED_MODULE_7__.css `
            :host {
                background: var(--color-quaternary);
                display: flex;
                flex-direction: column;
            }

            h3 {
                margin: 18px 8px 12px 8px;
                text-align: center;
            }

            .wrapper {
                max-width: 500px;
                margin: 0 auto;
                padding: 0 8px 8px 8px;
            }

            button {
                display: block;
            }

            .item {
                width: 100%;
                box-sizing: border-box;
                margin: 12px 0;
            }

            .account {
                font-size: 110%;
                display: flex;
                align-items: center;
            }

            pl-fingerprint {
                width: 60px;
                height: 60px;
                border-radius: 100%;
                border: solid 1px var(--border-color);
                margin: 15px;
            }

            .account-info {
                flex: 1;
                min-width: 0;
                padding-right: 18px;
            }

            .account-email {
                ${_styles__WEBPACK_IMPORTED_MODULE_3__.mixins.ellipsis()}
            }

            .account-email {
                font-weight: bold;
                ${_styles__WEBPACK_IMPORTED_MODULE_3__.mixins.ellipsis()}
            }

            .account pl-icon {
                width: 50px;
                height: 50px;
                margin: 5px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("input[type='file']"),
    __metadata("design:type", HTMLInputElement)
], Settings.prototype, "_fileInput", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.dialog)("pl-import-dialog"),
    __metadata("design:type", _import_dialog__WEBPACK_IMPORTED_MODULE_10__.ImportDialog)
], Settings.prototype, "_importDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.dialog)("pl-export-dialog"),
    __metadata("design:type", _export_dialog__WEBPACK_IMPORTED_MODULE_11__.ExportDialog)
], Settings.prototype, "_exportDialog", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.listen)("change"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], Settings.prototype, "_updateSettings", null);
Settings = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.element)("pl-settings")
], Settings);



/***/ }),

/***/ "../app/src/elements/signup.ts":
/*!*************************************!*\
  !*** ../app/src/elements/signup.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Signup": () => (/* binding */ Signup)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _padloc_core_src_diceware__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/diceware */ "../core/src/diceware.ts");
/* harmony import */ var _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @padloc/core/src/mfa */ "../core/src/mfa.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _start_form__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./start-form */ "../app/src/elements/start-form.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _password_input__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./password-input */ "../app/src/elements/password-input.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _generator__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./generator */ "../app/src/elements/generator.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _logo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./logo */ "../app/src/elements/logo.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};















const steps = ["", "verify", "password"];
let Signup = class Signup extends _start_form__WEBPACK_IMPORTED_MODULE_7__.StartForm {
    constructor() {
        super(...arguments);
        this._password = "";
        this._step = "start";
    }
    get _verificationToken() {
        return _globals__WEBPACK_IMPORTED_MODULE_5__.router.params.verify || _globals__WEBPACK_IMPORTED_MODULE_5__.router.params.token || "";
    }
    get _email() {
        return _globals__WEBPACK_IMPORTED_MODULE_5__.router.params.email || "";
    }
    get _name() {
        return _globals__WEBPACK_IMPORTED_MODULE_5__.router.params.name || "";
    }
    get _invite() {
        const inviteString = _globals__WEBPACK_IMPORTED_MODULE_5__.router.params.invite;
        if (inviteString) {
            const [org, id] = inviteString.split(",");
            return { org, id };
        }
        else {
            return undefined;
        }
    }
    async reset() {
        this._repeatPasswordInput.value = "";
        this._codeInput.value = "";
        this._submitEmailButton.stop();
        this._verifyEmailButton.stop();
        this._submitPasswordButton.stop();
        setTimeout(() => (this._logo.reveal = true), 500);
    }
    async goToStep(step = "") {
        const i = steps.indexOf(step);
        if (i === -1) {
            return;
        }
        const iPrev = steps.indexOf(this._step);
        const wrappers = this.$$(".wrapper");
        const wrapper = wrappers[i];
        const prevWrapper = wrappers[iPrev];
        wrapper.removeAttribute("hidden");
        this._animateIn(wrapper.querySelectorAll(".animate"));
        if (prevWrapper && prevWrapper !== wrapper) {
            this._animateOut(prevWrapper.querySelectorAll(".animate"));
            setTimeout(() => prevWrapper.setAttribute("hidden", ""), 1000);
        }
        this._step = step;
        if (step === "password" && !this._password) {
            this._generatePassphrase();
        }
        setTimeout(() => this.requestUpdate(), 10);
    }
    async _generatePassphrase() {
        this._password = await (0,_padloc_core_src_diceware__WEBPACK_IMPORTED_MODULE_2__.generatePassphrase)(4, " ", [_globals__WEBPACK_IMPORTED_MODULE_5__.app.state.device.locale]);
        const wrapper = this.$(".master-password");
        wrapper.classList.add("reveal");
        setTimeout(() => wrapper.classList.remove("reveal"), 2000);
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_6__.html `
            <div class="wrapper" hidden>
                <div flex></div>

                <form>
                    <pl-logo class="animate"></pl-logo>

                    <div class="title animate">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Welcome to Padloc! Let's get you started by creating an account for you.")}
                    </div>

                    <pl-input
                        id="emailInput"
                        type="email"
                        required
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Email Address")}
                        .value=${this._email}
                        class="tiles-2 animate"
                        @enter=${() => this._submitEmail()}
                    >
                    </pl-input>

                    <div class="hint animate">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Your email address serves as your username and allows us to get in touch with you. " +
            "Don't worry, we would never send you any spam!")}
                    </div>

                    <pl-input
                        id="nameInput"
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Your Name")}
                        .value=${this._name}
                        class="tiles-2 animate"
                        @enter=${() => this._submitEmail()}
                    >
                    </pl-input>

                    <div class="hint animate">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("What should we call you?")}
                    </div>

                    <pl-loading-button
                        id="submitEmailButton"
                        class="tap tiles-3 animate"
                        @click=${() => this._submitEmail()}
                    >
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Continue")}
                    </pl-loading-button>
                </form>

                <div flex></div>

                <div class="login-wrapper animate">
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Already have an account?")}
                    <span class="link" @click=${() => _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("login")}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Sign In")}</span>
                </div>
            </div>

            <div class="wrapper" hidden>
                <div flex></div>

                <form>
                    <h1 class="animate">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You've Got Mail!")}</h1>

                    <div class="hint animate">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("To verify your email address, please enter the confirmation code we sent to {0}.", this._email)}
                    </div>

                    <pl-input
                        id="codeInput"
                        type="number"
                        pattern="[0-9]*"
                        required
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Confirmation Code")}
                        class="tiles-2 animate"
                        @enter=${() => this._verifyEmail()}
                    >
                    </pl-input>

                    <pl-loading-button
                        id="verifyEmailButton"
                        class="tap tiles-3 animate"
                        @click=${() => this._verifyEmail()}
                    >
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Continue")}
                    </pl-loading-button>
                </form>

                <div flex></div>
            </div>

            <div class="wrapper" hidden>
                <div flex></div>

                <form class="master-password-form">
                    <h1 class="animate">
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Say hello to your")}</div>
                        <strong>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Master Password")}</strong>
                    </h1>

                    <div class="hint animate">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("It's the last password you'll ever have to remember! " +
            "Please memorize it and never reveal it to anyone (not even us)! " +
            "We recommend writing it down on a piece of paper and " +
            "storing it somewhere safe, at least until you have it safely memorized.")}
                    </div>

                    <div class="master-password animate">
                        <div class="master-password-value">
                            <span>${this._password}</span>
                        </div>

                        <div class="master-password-cover">
                            ${(0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.isTouch)() ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("[Tap To Reveal]") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("[Hover To Reveal]")}
                        </div>
                    </div>

                    <div class="hint animate">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("This random passphrase was generated just for you and is designed " +
            "to be both secure and easy to remember. Don't like it?")}
                    </div>

                    <div class="password-actions animate">
                        <button type="button" class="password-action tap" @click=${this._generatePassphrase}>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Try Another One")}
                        </button>
                        or
                        <button type="button" class="password-action tap" @click=${this._editMasterPassword}>
                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose Your Own")}
                        </button>
                    </div>

                    <pl-password-input
                        id="repeatPasswordInput"
                        required
                        .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Repeat Master Password")}
                        class="tiles-2 animate repeat-master-password"
                        @enter=${() => this._submitPassword()}
                    >
                    </pl-password-input>

                    <pl-loading-button
                        id="submitPasswordButton"
                        class="tap tiles-3 animate"
                        @click=${() => this._submitPassword()}
                    >
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Continue")}
                    </pl-loading-button>
                </form>

                <div flex></div>
            </div>
        `;
    }
    async _submitEmail() {
        if (this._submitEmailButton.state === "loading") {
            return;
        }
        if (!this._emailInput.reportValidity()) {
            return;
        }
        const email = this._emailInput.value;
        const name = this._nameInput.value;
        if (this._verificationToken) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("signup/password", { ..._globals__WEBPACK_IMPORTED_MODULE_5__.router.params, email, name });
        }
        else {
            this._submitEmailButton.start();
            try {
                await _globals__WEBPACK_IMPORTED_MODULE_5__.app.requestMFACode(email, _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_3__.MFAPurpose.Signup);
                this._submitEmailButton.success();
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("signup/verify", { ..._globals__WEBPACK_IMPORTED_MODULE_5__.router.params, email, name });
            }
            catch (e) {
                this._submitEmailButton.fail();
                throw e;
            }
        }
    }
    async _verifyEmail() {
        if (this._verifyEmailButton.state === "loading") {
            return;
        }
        this._verifyEmailButton.start();
        try {
            const verify = await _globals__WEBPACK_IMPORTED_MODULE_5__.app.retrieveMFAToken(this._email, this._codeInput.value, _padloc_core_src_mfa__WEBPACK_IMPORTED_MODULE_3__.MFAPurpose.Signup);
            if (verify.hasAccount) {
                this._verifyEmailButton.stop();
                this._accountExists();
                return;
            }
            if (verify.hasLegacyAccount) {
                const migrated = await this._migrateAccount(this._email, "", verify.legacyToken, verify.token, this._name);
                if (migrated) {
                    this._verifyEmailButton.success();
                }
                else {
                    const { verify, ...params } = _globals__WEBPACK_IMPORTED_MODULE_5__.router.params;
                    _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("signup", params);
                    this._emailInput.focus();
                }
                return;
            }
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("signup/password", { ..._globals__WEBPACK_IMPORTED_MODULE_5__.router.params, token: verify.token });
            this._verifyEmailButton.success();
        }
        catch (e) {
            if (e.code === _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.MFA_TRIES_EXCEEDED) {
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_12__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Maximum number of tries exceeded! Please resubmit and try again!"), { type: "warning" });
                _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("signup");
                return;
            }
            this._verifyEmailButton.fail();
            throw e;
        }
    }
    async _submitPassword() {
        if (this._submitPasswordButton.state === "loading") {
            return;
        }
        if (this._password !== this._repeatPasswordInput.value) {
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_12__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You didn't repeat your master password correctly. Try again!"), { type: "warning" });
            return;
        }
        const email = this._email;
        const name = this._name;
        const password = this._password;
        this._submitPasswordButton.start();
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_5__.app.signup({ email, password, name, verify: this._verificationToken, invite: this._invite });
            this._submitPasswordButton.success();
            this.done();
        }
        catch (e) {
            this._submitPasswordButton.fail();
            switch (e.code) {
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.ACCOUNT_EXISTS:
                    this._accountExists();
                    return;
                default:
                    throw e;
            }
        }
        this._password = "";
    }
    async _accountExists() {
        const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_12__.choose)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("An account with this email address already exists!"), [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Login"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Change Email")], { type: "warning" });
        if (choice === 0) {
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("login");
        }
        else {
            const { verify, ...params } = _globals__WEBPACK_IMPORTED_MODULE_5__.router.params;
            _globals__WEBPACK_IMPORTED_MODULE_5__.router.go("signup", params);
            this._emailInput.focus();
        }
    }
    async _editMasterPassword() {
        const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_12__.choose)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("We recommend using a randomly generated password that is both strong and easy to remember."), [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Keep This One"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Generate Another"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose My Own")], { title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Want A Different Master Password?") });
        let newPwd;
        switch (choice) {
            case 0:
                break;
            case 1:
                newPwd = await this._generator.show();
                break;
            case 2:
                newPwd = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_12__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("We recommend using a randomly generated password that is both strong and easy to remember."), { title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose Own Master Password"), label: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Master Password"), type: "password" });
                break;
        }
        if (newPwd) {
            const strength = await (0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.passwordStrength)(newPwd);
            if (strength.score < 2) {
                const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_12__.choose)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("The password you entered is weak which makes it easier for attackers to break " +
                    "the encryption used to protect your data. Try to use a longer password or include a " +
                    "variation of uppercase, lowercase and special characters as well as numbers!"), [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose Different Password"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Use Anyway")], {
                    type: "warning",
                    title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("WARNING: Weak Password"),
                    hideIcon: true,
                    preventDismiss: true
                });
                if (choice === 0) {
                    return this._editMasterPassword();
                }
            }
            this._password = newPwd;
        }
    }
};
Signup.styles = [
    ..._start_form__WEBPACK_IMPORTED_MODULE_7__.StartForm.styles,
    _base__WEBPACK_IMPORTED_MODULE_6__.css `
            h1 {
                display: block;
                text-align: center;
                margin: 20px 10px;
            }

            .master-password-form {
                max-width: 500px;
            }

            .title {
                max-width: 310px;
                margin: 30px auto;
                font-size: var(--font-size-small);
                font-weight: bold;
                letter-spacing: 0.5px;
                padding: 0 10px;
            }

            #submitButton {
                margin-bottom: 30px;
            }

            .login-wrapper {
                font-size: var(--font-size-small);
                padding: 8px;
                margin: 8px 0;
                opacity: 0.7;
            }

            .link {
                text-decoration: underline;
                cursor: pointer;
                font-weight: bold;
            }

            pl-input:not([focused]) + .hint {
                color: rgba(0, 0, 0, 0.2);
                text-shadow: none;
            }

            .master-password {
                position: relative;
                background: var(--shade-2-color);
                font-family: var(--font-family-mono);
                font-size: 120%;
                padding: 20px;
                overflow-wrap: break-word;
            }

            .master-password-cover {
                ${_styles__WEBPACK_IMPORTED_MODULE_13__.mixins.fullbleed()}
                height: 2em;
                line-height: 2em;
                margin: auto;
                font-weight: bold;
                text-shadow: none;
                color: rgba(0, 0, 0, 0.3);
            }

            .master-password:hover {
                background: var(--shade-3-color);
            }

            .master-password > * {
                transition: transform 0.2s cubic-bezier(1, -0.3, 0, 1.3), opacity 0.2s;
            }

            .master-password:not(:hover):not(.reveal) .master-password-value,
            .master-password:hover .master-password-cover,
            .master-password.reveal .master-password-cover {
                opacity: 0;
                transform: scale(0);
            }

            .hint.subtle {
                opacity: 0.5;
            }

            [focused] + .hint.subtle {
                opacity: 1;
            }

            .password-actions {
                margin: -20px 0 30px 0;
            }

            .password-action {
                padding: 6px 10px;
                margin: 0 4px;
                font-size: var(--font-size-tiny);
                font-weight: 600;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.property)(),
    __metadata("design:type", String)
], Signup.prototype, "_password", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#emailInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], Signup.prototype, "_emailInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#nameInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], Signup.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#codeInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], Signup.prototype, "_codeInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#repeatPasswordInput"),
    __metadata("design:type", _password_input__WEBPACK_IMPORTED_MODULE_9__.PasswordInput)
], Signup.prototype, "_repeatPasswordInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#submitEmailButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_10__.LoadingButton)
], Signup.prototype, "_submitEmailButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#verifyEmailButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_10__.LoadingButton)
], Signup.prototype, "_verifyEmailButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.query)("#submitPasswordButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_10__.LoadingButton)
], Signup.prototype, "_submitPasswordButton", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_12__.dialog)("pl-generator"),
    __metadata("design:type", _generator__WEBPACK_IMPORTED_MODULE_11__.Generator)
], Signup.prototype, "_generator", void 0);
Signup = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_6__.element)("pl-signup")
], Signup);



/***/ }),

/***/ "../app/src/elements/slider.ts":
/*!*************************************!*\
  !*** ../app/src/elements/slider.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Slider": () => (/* binding */ Slider)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};


let Slider = class Slider extends _base__WEBPACK_IMPORTED_MODULE_0__.BaseElement {
    constructor() {
        super(...arguments);
        this.min = 1;
        this.max = 10;
        this.value = this.min;
        this.unit = "";
        this.step = 1;
        this.label = "";
        this.hideValue = false;
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            <label>${this.label}</label>

            <input
                type="range"
                .value=${this.value}
                .min=${this.min}
                .max=${this.max}
                .step=${this.step}
                @input=${() => this._inputChange()}
            />

            <span class="value-display" ?hidden=${this.hideValue}>${this.value}${this.unit}</span>
        `;
    }
    _inputChange() {
        const prev = this.value;
        this.value = parseFloat(this._input.value);
        this.dispatch("change", { prev: prev, value: this.value }, true, true);
    }
};
Slider.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_1__.shared,
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            :host {
                display: flex;
                align-items: center;
                height: var(--row-height);
                padding: 0 15px;
                font-size: inherit;
                --track-color: var(--slider-track-color, rgba(0, 0, 0, 0.1));
                --knob-color: var(--slider-knob-color, var(--color-highlight));
                --track-size: var(--slider-track-size, 2px);
                --knob-size: var(--slider-knob-size, 25px);
            }

            input[type="range"] {
                -webkit-appearance: none;
                width: 100%;
                margin: 0;
                padding: 0;
                flex: 1;
                height: auto;
                min-height: var(--knob-size);
            }

            input[type="range"]:focus {
                outline: none;
            }

            label {
                margin-right: 10px;
            }

            label:empty {
                display: none;
            }

            .value-display {
                margin-left: 10px;
            }

            input[type="range"]::-webkit-slider-runnable-track {
                width: 100%;
                cursor: pointer;
                border-radius: 100%;
                height: 0.2em;
                background: var(--shade-2);
            }

            input[type="range"]::-webkit-slider-thumb {
                -webkit-appearance: none;
                -moz-appearance: none;
                appearance: none;
                height: var(--knob-size);
                width: var(--knob-size);
                margin-top: calc(0.5 * var(--track-size) - 0.5 * var(--knob-size));
                position: relative;
                border-radius: 100%;
                background: var(--knob-color);
                cursor: pointer;
                border: none;
                box-sizing: border-box;
                background-clip: content-box;
            }

            input[type="range"]:active::-webkit-slider-thumb {
                transform: scale(1.1);
            }

            input[type="range"]::-moz-range-track {
                width: 100%;
                height: var(--track-size);
                cursor: pointer;
                background: var(--track-color);
                border-radius: 100%;
            }

            input[type="range"]::-moz-range-thumb {
                -webkit-appearance: none;
                -moz-appearance: none;
                appearance: none;
                height: var(--knob-size);
                width: var(--knob-size);
                margin-top: calc(0.5 * var(--track-size) - 0.5 * var(--knob-size));
                position: relative;
                border-radius: 100%;
                background: var(--knob-color);
                cursor: pointer;
                border: none;
                box-sizing: border-box;
                background-clip: content-box;
            }

            input[type="range"]:active::-moz-range-thumb {
                transform: scale(1.1);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", Number)
], Slider.prototype, "min", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", Number)
], Slider.prototype, "max", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", Number)
], Slider.prototype, "value", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String)
], Slider.prototype, "unit", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", Number)
], Slider.prototype, "step", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", String)
], Slider.prototype, "label", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", Boolean)
], Slider.prototype, "hideValue", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.query)("input"),
    __metadata("design:type", HTMLInputElement)
], Slider.prototype, "_input", void 0);
Slider = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.element)("pl-slider")
], Slider);



/***/ }),

/***/ "../app/src/elements/spinner.ts":
/*!**************************************!*\
  !*** ../app/src/elements/spinner.ts ***!
  \**************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Spinner": () => (/* binding */ Spinner)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};

let Spinner = class Spinner extends _base__WEBPACK_IMPORTED_MODULE_0__.BaseElement {
    constructor() {
        super(...arguments);
        this.active = false;
    }
    _activeChanged() {
        clearTimeout(this._stopTimeout);
        if (this.active) {
            this._circle.classList.add("spinning");
        }
        else {
            this._stopTimeout = window.setTimeout(() => this._circle.classList.remove("spinning"), 300);
        }
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            ${_base__WEBPACK_IMPORTED_MODULE_0__.svg `
                <svg viewBox="0 0 100 100">
                    <circle cx="50" cy="50" r="40" />
                </svg>
            `}
        `;
    }
};
Spinner.styles = [
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            @keyframes spin {
                from {
                    stroke-dashoffset: 240;
                }

                to {
                    stroke-dashoffset: 40;
                }
            }

            @keyframes rotate {
                to {
                    transform: rotate(360deg);
                }
            }

            :host {
                display: block;
                width: 40px;
                height: 40px;
                position: relative;
                transition: opacity 0.3s;
                will-change: opacity;
            }

            :host(:not([active])) {
                opacity: 0;
            }

            svg {
                width: 100%;
                height: 100%;
            }

            circle {
                fill: none;
                stroke: currentColor;
                stroke-linecap: round;
                stroke-width: 10;
                stroke-dasharray: 252;
                transform-origin: center center;
                will-change: transform;
            }

            circle.spinning {
                animation: spin 1.5s cubic-bezier(0.44, 0.22, 0.64, 0.86) alternate infinite,
                    rotate linear 1.2s infinite;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], Spinner.prototype, "active", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.query)("circle"),
    __metadata("design:type", SVGCircleElement)
], Spinner.prototype, "_circle", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.observe)("active"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], Spinner.prototype, "_activeChanged", null);
Spinner = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.element)("pl-spinner")
], Spinner);



/***/ }),

/***/ "../app/src/elements/start-form.ts":
/*!*****************************************!*\
  !*** ../app/src/elements/start-form.ts ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "StartForm": () => (/* binding */ StartForm)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/api */ "../core/src/api.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _lib_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/animation */ "../app/src/lib/animation.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _lib_import__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../lib/import */ "../app/src/lib/import.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _logo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./logo */ "../app/src/elements/logo.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};










const styles = _base__WEBPACK_IMPORTED_MODULE_3__.css `
    @keyframes reveal {
        from {
            transform: translate(0, 30px);
            opacity: 0;
        }
    }

    @keyframes fade {
        to {
            transform: translate(0, -200px);
            opacity: 0;
        }
    }

    :host,
    .wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.fullbleed()}
        ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.scroll()}
    }

    form {
        width: 100%;
        max-width: 400px;
    }

    form > * {
        border-radius: 8px;
        margin: 12px;
    }

    pl-logo {
        margin: 40px auto 30px auto;
    }

    pl-loading-button {
        overflow: hidden;
        font-weight: bold;
    }

    .hint {
        font-size: var(--font-size-small);
        box-sizing: border-box;
        padding: 0 10px;
        margin-bottom: 30px;
        transition: color 0.2s;
    }

    .hint.warning {
        color: #ffc107;
        font-weight: bold;
        margin: 0;
        padding: 0;
        text-shadow: none;
    }
`;
class StartForm extends _base__WEBPACK_IMPORTED_MODULE_3__.BaseElement {
    _animateIn(nodes) {
        return (0,_lib_animation__WEBPACK_IMPORTED_MODULE_4__.animateCascade)(nodes, {
            animation: "reveal",
            duration: 1000,
            fullDuration: 1500,
            initialDelay: 300,
            fill: "backwards",
            clear: 3000
        });
    }
    _animateOut(nodes) {
        (0,_lib_animation__WEBPACK_IMPORTED_MODULE_4__.animateCascade)(nodes, {
            animation: "fade",
            duration: 400,
            fullDuration: 600,
            initialDelay: 0,
            fill: "forwards",
            easing: "cubic-bezier(1, 0, 0.2, 1)",
            clear: 3000
        });
    }
    reset() {
        this._animateIn(this.$$(".animate"));
        this.requestUpdate();
        this._logo && setTimeout(() => (this._logo.reveal = true), 500);
    }
    done() {
        this._animateOut(this.$$(".animate"));
    }
    rumble() {
        (0,_lib_animation__WEBPACK_IMPORTED_MODULE_4__.animateElement)(this.$("form"), { animation: "rumble", duration: 200, clear: true });
    }
    async _migrateAccount(email, password, legacyToken, signupToken, name = "") {
        const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("You don't have a Padloc 3 account yet but we've found " +
            "an account from an older version. " +
            "Would you like to migrate your account to Padloc 3 now?"), {
            title: "Account Migration",
            icon: "user",
            options: [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Migrate"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Learn More"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel")]
        });
        if (choice === 1) {
            window.open("https://padloc.app/help/migrate-v3", "_system");
            return this._migrateAccount(email, password, legacyToken, signupToken, name);
        }
        else if (choice === 2) {
            return false;
        }
        const legacyData = await _globals__WEBPACK_IMPORTED_MODULE_7__.app.api.getLegacyData(new _padloc_core_src_api__WEBPACK_IMPORTED_MODULE_1__.GetLegacyDataParams({
            email,
            verify: legacyToken
        }));
        let items = null;
        try {
            if (!password) {
                throw "No password provided";
            }
            await legacyData.unlock(password);
            items = await (0,_lib_import__WEBPACK_IMPORTED_MODULE_6__.importLegacyContainer)(legacyData);
        }
        catch (e) {
            password = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter your master password!"), {
                title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Migrating Account"),
                placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Master Password"),
                confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Submit"),
                type: "password",
                preventAutoClose: true,
                validate: async (password) => {
                    try {
                        await legacyData.unlock(password);
                        items = await (0,_lib_import__WEBPACK_IMPORTED_MODULE_6__.importLegacyContainer)(legacyData);
                    }
                    catch (e) {
                        throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Wrong password! Please try again!");
                    }
                    return password;
                }
            });
        }
        if (items && password) {
            await _globals__WEBPACK_IMPORTED_MODULE_7__.app.signup({ email, password, verify: signupToken, name });
            await _globals__WEBPACK_IMPORTED_MODULE_7__.app.addItems(items, _globals__WEBPACK_IMPORTED_MODULE_7__.app.mainVault);
            const deleteLegacy = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Your account and all associated data was migrated successfully! Do you want to delete your old account now?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Yes"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No"), { title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Delete Legacy Account"), icon: "delete", preventAutoClose: true });
            if (deleteLegacy) {
                await _globals__WEBPACK_IMPORTED_MODULE_7__.app.api.deleteLegacyAccount();
            }
            await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("All done! Please note that you won't be able to access your Padloc 3 account " +
                "with older versions of the app, so please make sure you have the latest version installed " +
                "on all your devices! (You can find download links for all platforms at " +
                "https://padloc.app/downloads/). Enjoy using Padloc 3!"), {
                title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Migration Complete"),
                type: "success"
            });
            return true;
        }
        else {
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_5__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unfortunately we could not complete migration of your data."), {
                type: "warning"
            });
            return false;
        }
    }
}
StartForm.styles = [_styles__WEBPACK_IMPORTED_MODULE_2__.shared, styles];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("pl-logo"),
    __metadata("design:type", _logo__WEBPACK_IMPORTED_MODULE_8__.Logo)
], StartForm.prototype, "_logo", void 0);


/***/ }),

/***/ "../app/src/elements/start.ts":
/*!************************************!*\
  !*** ../app/src/elements/start.ts ***!
  \************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Start": () => (/* binding */ Start)
/* harmony export */ });
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _unlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./unlock */ "../app/src/elements/unlock.ts");
/* harmony import */ var _login__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./login */ "../app/src/elements/login.ts");
/* harmony import */ var _signup__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./signup */ "../app/src/elements/signup.ts");
/* harmony import */ var _recover__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./recover */ "../app/src/elements/recover.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};








let Start = class Start extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_2__.StateMixin)(_base__WEBPACK_IMPORTED_MODULE_3__.BaseElement) {
    constructor() {
        super(...arguments);
        this.open = false;
    }
    async unlock() {
        await this.updateComplete;
        this._showForm(this._unlockForm);
    }
    async login() {
        await this.updateComplete;
        this._showForm(this._loginForm);
    }
    async signup(step) {
        await this.updateComplete;
        this._signupForm.goToStep(step);
        this._showForm(this._signupForm);
    }
    async recover() {
        await this.updateComplete;
        this._showForm(this._recoverForm);
    }
    stateChanged() {
        this.open = !_globals__WEBPACK_IMPORTED_MODULE_0__.app.state.locked;
    }
    async _showForm(form) {
        for (const f of [this._unlockForm, this._loginForm, this._signupForm, this._recoverForm]) {
            if (f === form) {
                f.classList.add("showing");
                f.reset();
            }
            else {
                f.classList.remove("showing");
                f.done();
            }
        }
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_3__.html `
            <pl-unlock class="form"></pl-unlock>

            <pl-login class="form"></pl-login>

            <pl-signup class="form"></pl-signup>

            <pl-recover class="form"></pl-recover>
        `;
    }
};
Start.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_1__.shared,
    _base__WEBPACK_IMPORTED_MODULE_3__.css `
            :host {
                --color-background: var(--color-primary);
                --color-foreground: var(--color-tertiary);
                --color-highlight: var(--color-secondary);
                color: var(--color-foreground);
                display: flex;
                flex-direction: column;
                z-index: 5;
                text-align: center;
                text-shadow: rgba(0, 0, 0, 0.15) 0 2px 0;
                background: linear-gradient(180deg, #59c6ff 0%, #077cb9 100%);
                transition: transform 0.4s cubic-bezier(1, 0, 0.2, 1);
                ${_styles__WEBPACK_IMPORTED_MODULE_1__.mixins.fullbleed()}
                ${_styles__WEBPACK_IMPORTED_MODULE_1__.mixins.scroll()}
            }

            main {
                ${_styles__WEBPACK_IMPORTED_MODULE_1__.mixins.fullbleed()}
                background: transparent;
                min-height: 510px;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
            }

            .form:not(.showing) {
                opacity: 0;
                transition: opacity 1s;
                pointer-events: none;
            }

            :host([open]) {
                pointer-events: none;
            }

            :host([open]) {
                transition-delay: 0.4s;
                transform: translate3d(0, -100%, 0);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], Start.prototype, "open", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("pl-unlock"),
    __metadata("design:type", _unlock__WEBPACK_IMPORTED_MODULE_4__.Unlock)
], Start.prototype, "_unlockForm", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("pl-login"),
    __metadata("design:type", _login__WEBPACK_IMPORTED_MODULE_5__.Login)
], Start.prototype, "_loginForm", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("pl-signup"),
    __metadata("design:type", _signup__WEBPACK_IMPORTED_MODULE_6__.Signup)
], Start.prototype, "_signupForm", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("pl-recover"),
    __metadata("design:type", _recover__WEBPACK_IMPORTED_MODULE_7__.Recover)
], Start.prototype, "_recoverForm", void 0);
Start = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.element)("pl-start")
], Start);



/***/ }),

/***/ "../app/src/elements/subscription.ts":
/*!*******************************************!*\
  !*** ../app/src/elements/subscription.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "OrgSubscription": () => (/* binding */ OrgSubscription)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _mixins_state__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../mixins/state */ "../app/src/mixins/state.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _update_subscription_dialog__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./update-subscription-dialog */ "../app/src/elements/update-subscription-dialog.ts");
/* harmony import */ var _billing_dialog__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./billing-dialog */ "../app/src/elements/billing-dialog.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};












let OrgSubscription = class OrgSubscription extends (0,_mixins_state__WEBPACK_IMPORTED_MODULE_6__.StateMixin)(_base__WEBPACK_IMPORTED_MODULE_7__.BaseElement) {
    constructor() {
        super(...arguments);
        this.org = null;
    }
    get _billing() {
        return this.org ? this.org.billing : _globals__WEBPACK_IMPORTED_MODULE_5__.app.account && _globals__WEBPACK_IMPORTED_MODULE_5__.app.account.billing;
    }
    get _subscription() {
        return this._billing && this._billing.subscription;
    }
    async _update() {
        const sub = this._subscription;
        if (this.org) {
            if (!sub) {
                this._updatePlan();
                return;
            }
        }
        else {
            if (!sub || sub.plan.type === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.PlanType.Free) {
                this.dispatch("get-premium");
                return;
            }
        }
        const canceled = sub.status === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.SubscriptionStatus.Canceled;
        const choices = canceled ? [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Resume Subscription")] : [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel Subscription")];
        if (this.org) {
            choices.push((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Update Plan"));
        }
        const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.choose)("", choices);
        switch (choice) {
            case 0:
                return canceled ? this._resumeSubscription() : this._cancelSubscription();
            case 1:
                return this._updateSubscriptionDialog.show(this.org);
        }
    }
    _updatePlan() {
        this.org ? this._updateSubscriptionDialog.show(this.org) : this.dispatch("get-premium");
    }
    async _downgrade() {
        if (this.org) {
            throw "Can only downgrade subscription for private account!";
        }
        if (this._downgradeButton.state === "loading") {
            return;
        }
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to downgrade to the Free Plan?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Downgrade"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel"), { type: "destructive", title: "Downgrade" });
        if (!confirmed) {
            return;
        }
        this._downgradeButton.start();
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateBilling(new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.UpdateBillingParams({ planType: _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.PlanType.Free }));
            this._downgradeButton.success();
        }
        catch (e) {
            this._downgradeButton.fail();
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)(e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!"), { type: "warning" });
        }
    }
    async _updateBilling() {
        if (this._paymentButton.state === "loading") {
            return;
        }
        const billingInfo = this._billing;
        const params = await this._billingDialog.show({ billingInfo });
        if (params) {
            this._paymentButton.start();
            try {
                await _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateBilling(params);
                this._paymentButton.success();
            }
            catch (e) {
                this._paymentButton.fail();
                (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)(e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!"), { type: "warning" });
                throw e;
            }
        }
    }
    async _do(fn) {
        if (this._editButton.state === "loading") {
            return;
        }
        this._editButton.start();
        try {
            await fn();
            this._editButton.success();
        }
        catch (e) {
            this._editButton.fail();
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)(e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!"), { type: "warning" });
        }
    }
    async _cancelSubscription() {
        this._do(() => _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateBilling(new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.UpdateBillingParams({ org: (this.org && this.org.id) || undefined, cancel: true })));
    }
    async _resumeSubscription() {
        this._do(() => _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateBilling(new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.UpdateBillingParams({ org: (this.org && this.org.id) || undefined, cancel: false })));
    }
    async _authenticatePayment() {
        const stripePubKey = _globals__WEBPACK_IMPORTED_MODULE_5__.app.state.billingProvider && _globals__WEBPACK_IMPORTED_MODULE_5__.app.state.billingProvider.config.publicKey;
        if (!stripePubKey || this._authButton.state === "loading") {
            return;
        }
        this._authButton.start();
        let error = "";
        try {
            const Stripe = await (0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.loadScript)("https://js.stripe.com/v3/", "Stripe");
            const stripe = Stripe(stripePubKey);
            const result = await stripe.handleCardPayment(this._subscription.paymentRequiresAuth);
            error = result.error && result.error.message;
            await _globals__WEBPACK_IMPORTED_MODULE_5__.app.updateBilling(new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.UpdateBillingParams());
        }
        catch (e) {
            error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!");
        }
        if (error) {
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)(error);
            this._authButton.fail();
        }
        else {
            this._authButton.success();
        }
    }
    render() {
        if (!_globals__WEBPACK_IMPORTED_MODULE_5__.app.account) {
            return _base__WEBPACK_IMPORTED_MODULE_7__.html ``;
        }
        const account = _globals__WEBPACK_IMPORTED_MODULE_5__.app.account;
        const billing = this.org ? this.org.billing : account.billing;
        const sub = billing && billing.subscription;
        const trialDays = sub && sub.trialEnd
            ? Math.max(0, Math.ceil((sub.trialEnd.getTime() - Date.now()) / 1000 / 60 / 60 / 24))
            : 0;
        const periodDays = sub && sub.periodEnd
            ? Math.max(0, Math.ceil((sub.periodEnd.getTime() - Date.now()) / 1000 / 60 / 60 / 24))
            : 0;
        const privateItemQuota = _globals__WEBPACK_IMPORTED_MODULE_5__.app.getItemsQuota();
        const privateItemCount = (_globals__WEBPACK_IMPORTED_MODULE_5__.app.mainVault && _globals__WEBPACK_IMPORTED_MODULE_5__.app.mainVault.items.size) || 0;
        return _base__WEBPACK_IMPORTED_MODULE_7__.html `
            <div class="plan-name">
                ${(sub && sub.plan.name) || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("No Plan Selected")}
            </div>

            <div class="quota">
                ${this.org
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                          <div
                              class="quota-item"
                              ?warning=${this.org.quota.members !== -1 &&
                this.org.members.length >= this.org.quota.members}
                          >
                              <pl-icon icon="members"></pl-icon>

                              <div class="label">
                                  ${this.org.quota.members === -1
                ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unlimited")
                : `${this.org.members.length} / ${this.org.quota.members}`}
                              </div>
                          </div>

                          <div
                              class="quota-item"
                              ?warning=${this.org.quota.groups !== -1 &&
                this.org.groups.length >= this.org.quota.groups}
                          >
                              <pl-icon icon="group"></pl-icon>

                              <div class="label">
                                  ${this.org.quota.groups === -1
                ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unlimited")
                : `${this.org.groups.length} / ${this.org.quota.groups}`}
                              </div>
                          </div>

                          <div
                              class="quota-item"
                              ?warning=${this.org.quota.vaults !== -1 &&
                this.org.vaults.length >= this.org.quota.vaults}
                          >
                              <pl-icon icon="vaults"></pl-icon>

                              <div class="label">
                                  ${this.org.quota.vaults === -1
                ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unlimited")
                : `${this.org.vaults.length} / ${this.org.quota.vaults}`}
                              </div>
                          </div>

                          <div
                              class="quota-item"
                              ?warning=${this.org.quota.storage !== -1 &&
                this.org.usedStorage >= this.org.quota.storage * 1e9 - 5e6}
                          >
                              <pl-icon icon="storage"></pl-icon>

                              <div class="label">
                                  ${this.org.quota.storage === -1
                ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unlimited")
                : `${(0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.fileSize)(this.org.usedStorage)} / ${this.org.quota.storage} GB`}
                              </div>
                          </div>
                      `
            : _base__WEBPACK_IMPORTED_MODULE_7__.html `
                          <div
                              class="quota-item"
                              ?warning=${privateItemQuota !== -1 && privateItemCount >= privateItemQuota}
                          >
                              <pl-icon icon="list"></pl-icon>

                              <div class="label">
                                  ${privateItemQuota === -1
                ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unlimited")
                : `${privateItemCount} / ${privateItemQuota}`}
                              </div>
                          </div>

                          <div class="quota-item" ?warning=${account.usedStorage >= account.quota.storage * 1e9 - 5e6}>
                              <pl-icon icon="storage"></pl-icon>

                              <div class="label">
                                  ${(0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.fileSize)(account.usedStorage)} / ${account.quota.storage} GB
                              </div>
                          </div>
                      `}
                ${sub
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                          <div class="quota-item">
                              <pl-icon icon="dollar"></pl-icon>

                              <div class="label">
                                  ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} / Year", ((sub.members * sub.plan.cost) / 100).toFixed(2))}
                              </div>
                          </div>

                          ${sub.status === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.SubscriptionStatus.Canceled
                ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <div class="quota-item" warning>
                                        <pl-icon icon="time"></pl-icon>

                                        <div class="label">
                                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Canceled ({0} days left)", periodDays.toString())}
                                        </div>
                                    </div>
                                `
                : sub.status === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.SubscriptionStatus.Inactive
                    ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <div class="quota-item" warning>
                                        <pl-icon icon="error"></pl-icon>

                                        <div class="label">
                                            ${sub.paymentRequiresAuth ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Authentication Required") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Inactive")}
                                        </div>
                                    </div>
                                `
                    : sub.status === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.SubscriptionStatus.Trialing
                        ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                                    <div class="quota-item" ?warning=${trialDays < 3}>
                                        <pl-icon icon="time"></pl-icon>

                                        <div class="label">
                                            ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Trialing ({0} days left)", trialDays.toString())}
                                        </div>
                                    </div>
                                `
                        : _base__WEBPACK_IMPORTED_MODULE_7__.html ``}
                      `
            : ""}
            </div>

            ${sub && sub.paymentError
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                      <div class="error item">${sub.paymentError}</div>
                  `
            : ""}
            ${!sub
            ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                      <button class="premium-button primary tap" @click=${this._updatePlan}>
                          ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Choose Plan")}
                      </button>
                  `
            : sub.paymentRequiresAuth
                ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                      <pl-loading-button
                          id="authButton"
                          class="premium-button primary tap"
                          @click=${this._authenticatePayment}
                          >${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Complete Payment")}</pl-loading-button
                      >
                  `
                : sub.status === _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.SubscriptionStatus.Inactive
                    ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                      <pl-loading-button
                          id="paymentButton"
                          class="premium-button primary tap"
                          @click=${this._updateBilling}
                      >
                          ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Add Payment Method")}
                      </pl-loading-button>

                      <pl-loading-button id="downgradeButton" class="premium-button tap" @click=${this._downgrade} ?hidden=${!!this.org}>
                          ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Downgrade To Free Plan")}
                      </pl-loading-button>
                  `
                    : this.org || sub.plan.type !== _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.PlanType.Free
                        ? _base__WEBPACK_IMPORTED_MODULE_7__.html `
                      <pl-loading-button id="editButton" class="edit-button tap icon" @click=${this._update}>
                          <pl-icon icon="edit"></pl-icon>
                      </pl-loading-button>
                  `
                        : _base__WEBPACK_IMPORTED_MODULE_7__.html `
                      <button class="premium-button primary tap" @click=${this._update}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Get Premium")}</button>
                  `}
        `;
    }
};
OrgSubscription.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_2__.shared,
    _base__WEBPACK_IMPORTED_MODULE_7__.css `
            :host {
                display: block;
                position: relative;
                display: flex;
                flex-direction: column;
            }

            .quota {
                margin: 0 12px 12px 12px;
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
            }

            .quota-item {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                padding: 4px;
                font-weight: bold;
                text-align: center;
            }

            .quota-item[warning] {
                color: var(--color-negative);
            }

            .quota-item pl-icon {
                font-size: 150%;
            }

            .quota-item .label {
                font-size: var(--font-size-small);
            }

            .edit-button {
                position: absolute;
                top: 12px;
                right: 12px;
                z-index: 1;
            }

            .missing {
                opacity: 0.7;
                cursor: pointer;
            }

            .plan-name {
                font-size: 150%;
                font-weight: bold;
                margin: 16px 8px;
                text-align: center;
            }

            button {
                font-weight: bold;
            }

            .premium-button {
                margin: 0 12px 12px 12px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.property)(),
    __metadata("design:type", Object)
], OrgSubscription.prototype, "org", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.dialog)("pl-update-subscription-dialog"),
    __metadata("design:type", _update_subscription_dialog__WEBPACK_IMPORTED_MODULE_10__.UpdateSubscriptionDialog)
], OrgSubscription.prototype, "_updateSubscriptionDialog", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.dialog)("pl-billing-dialog"),
    __metadata("design:type", _billing_dialog__WEBPACK_IMPORTED_MODULE_11__.BillingDialog)
], OrgSubscription.prototype, "_billingDialog", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#editButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_9__.LoadingButton)
], OrgSubscription.prototype, "_editButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#paymentButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_9__.LoadingButton)
], OrgSubscription.prototype, "_paymentButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#authButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_9__.LoadingButton)
], OrgSubscription.prototype, "_authButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.query)("#downgradeButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_9__.LoadingButton)
], OrgSubscription.prototype, "_downgradeButton", void 0);
OrgSubscription = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_7__.element)("pl-subscription")
], OrgSubscription);



/***/ }),

/***/ "../app/src/elements/tags-input.ts":
/*!*****************************************!*\
  !*** ../app/src/elements/tags-input.ts ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "TagsInput": () => (/* binding */ TagsInput)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};






let TagsInput = class TagsInput extends _base__WEBPACK_IMPORTED_MODULE_3__.BaseElement {
    constructor() {
        super(...arguments);
        this.editing = false;
        this.vault = null;
        this.tags = [];
        this._showResults = false;
        this._focusTimeout = 0;
    }
    render() {
        const { tags, editing, vault, _showResults } = this;
        const { value } = this._input || { value: "" };
        const results = _globals__WEBPACK_IMPORTED_MODULE_1__.app.state.tags.filter(([t]) => !this.tags.includes(t) && t !== value && t.toLowerCase().startsWith(value))
            .map(([t]) => t);
        if (value) {
            results.push(value);
        }
        return _base__WEBPACK_IMPORTED_MODULE_3__.html `
            <div class="tags small wrapper">
                <div class="tag highlight tap" @click=${() => this._vaultClicked()}>
                    <pl-icon icon="vault"></pl-icon>

                    <div class="tag-name">${vault}</div>
                </div>

                ${tags.map(tag => _base__WEBPACK_IMPORTED_MODULE_3__.html `
                        <div class="tag tap" @click=${() => this._tagClicked(tag)}>
                            <pl-icon icon="tag"></pl-icon>

                            <div>${tag}</div>

                            <pl-icon icon="cancel" ?hidden=${!editing}></pl-icon>
                        </div>
                    `)}

                <div class="add-tag" ?hidden=${!editing}>
                    <div class="input-wrapper tap" @click=${() => this._input.focus()}>
                        <pl-icon icon="add"></pl-icon>

                        <pl-input
                            .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Add Tag")}
                            @enter=${() => this._addTag(value)}
                            @input=${() => this.requestUpdate()}
                            @focus=${() => this._focusChanged()}
                            @blur=${() => this._focusChanged()}
                        >
                        </pl-input>
                    </div>

                    <div class="tags small results" ?hidden=${!_showResults}>
                        ${results.map(res => _base__WEBPACK_IMPORTED_MODULE_3__.html `
                                <div class="tag tap" @click=${() => this._addTag(res)}>
                                    <pl-icon icon="tag"></pl-icon>

                                    <div>${res}</div>
                                </div>
                            `)}
                    </div>
                </div>
            </div>
        `;
    }
    _addTag(tag) {
        if (!tag || this.tags.includes(tag)) {
            return;
        }
        this.tags.push(tag);
        this._input.value = "";
        this._showResults = false;
        this.requestUpdate();
    }
    _tagClicked(tag) {
        if (this.editing) {
            this.tags = this.tags.filter(t => t !== tag);
        }
    }
    _vaultClicked() {
        this.dispatch("move");
    }
    _focusChanged() {
        clearTimeout(this._focusTimeout);
        setTimeout(() => (this._showResults = this._input.focused), this._input.focused ? 0 : 200);
    }
};
TagsInput.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_2__.shared,
    _base__WEBPACK_IMPORTED_MODULE_3__.css `
            :host {
                display: block;
                position: relative;
                z-index: 1;
                overflow: visible;
                font-size: var(--font-size-small);
                overflow: visible;
            }

            .wrapper {
                flex-wrap: wrap;
                overflow: visible;
                margin-top: -6px;
            }

            .wrapper > * {
                margin-top: 6px;
            }

            .tags.small .tag {
                padding: 5px 7px;
            }

            .results {
                padding: 0;
                border-radius: 8px;
                margin-top: 0;
                flex-direction: column;
                align-items: flex-start;
            }

            .results .tag {
                padding: 6px 8px;
                margin-top: 6px;
            }

            .input-wrapper {
                font-size: var(--font-size-micro);
                padding: 0 4px;
                height: 24px;
                line-height: 24px;
                background: var(--color-tertiary);
                border: solid 1px var(--color-shade-4);
                border-radius: 8px;
                align-self: stretch;
                position: relative;
                min-width: 80px;
                overflow: hidden;
            }

            .input-wrapper pl-input {
                font-size: inherit;
                position: absolute;
                height: 100%;
                width: 100%;
                box-sizing: border-box;
                padding-left: 20px;
                top: 0;
                font-weight: bold;
                pointer-events: none;
            }

            .add-tag {
                height: 26px;
                overflow: visible;
            }

            .add-tag .input-wrapper pl-icon {
                height: 25px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Boolean)
], TagsInput.prototype, "editing", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Object)
], TagsInput.prototype, "vault", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Array)
], TagsInput.prototype, "tags", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.property)(),
    __metadata("design:type", Boolean)
], TagsInput.prototype, "_showResults", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.query)("pl-input"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_4__.Input)
], TagsInput.prototype, "_input", void 0);
TagsInput = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_3__.element)("pl-tags-input")
], TagsInput);



/***/ }),

/***/ "../app/src/elements/textarea.ts":
/*!***************************************!*\
  !*** ../app/src/elements/textarea.ts ***!
  \***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Textarea": () => (/* binding */ Textarea)
/* harmony export */ });
/* harmony import */ var autosize_src_autosize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! autosize/src/autosize */ "../app/node_modules/autosize/src/autosize.js");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _base_input__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base-input */ "../app/src/elements/base-input.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
// @ts-ignore



let Textarea = class Textarea extends _base_input__WEBPACK_IMPORTED_MODULE_2__.BaseInput {
    constructor() {
        super(...arguments);
        this.autosize = false;
    }
    updated() {
        if (this.autosize) {
            setTimeout(() => (0,autosize_src_autosize__WEBPACK_IMPORTED_MODULE_0__["default"])(this._inputElement));
        }
    }
    _renderInput() {
        const { placeholder, readonly, noTab, disabled, autocapitalize, required } = this;
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <textarea
                class="input-element"
                .placeholder=${placeholder}
                .tabIndex=${noTab ? "-1" : ""}
                ?readonly=${readonly}
                ?disabled=${disabled}
                ?required=${required}
                autocapitalize=${autocapitalize}
                autocomplete="off"
                spellcheck="false"
                autocorrect="off"
                rows="1"
                @focus=${this._focused}
                @blur=${this._blurred}
                @change=${this._changeHandler}
                @touchend=${this._touchend}
            ></textarea>
        `;
    }
};
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Boolean)
], Textarea.prototype, "autosize", void 0);
Textarea = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-textarea")
], Textarea);



/***/ }),

/***/ "../app/src/elements/toggle-button.ts":
/*!********************************************!*\
  !*** ../app/src/elements/toggle-button.ts ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ToggleButton": () => (/* binding */ ToggleButton)
/* harmony export */ });
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _toggle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./toggle */ "../app/src/elements/toggle.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};



let ToggleButton = class ToggleButton extends _base__WEBPACK_IMPORTED_MODULE_1__.BaseElement {
    constructor() {
        super(...arguments);
        this.active = false;
        this.reverse = false;
        this.label = "";
    }
    render() {
        const { active, label } = this;
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
        <button @click=${() => this.toggle()}>

            <pl-toggle .active=${active} @change=${() => (this.active = this._toggle.active)}"></pl-toggle>

            <div>
                ${label}
                <slot></slot>
            </div>

        </button>
`;
    }
    toggle() {
        this._toggle.toggle();
    }
};
ToggleButton.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_0__.shared,
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            :host {
                display: block;
                font-size: inherit;
                padding: 12px 15px;
            }

            button {
                background: transparent;
                display: flex;
                width: 100%;
                align-items: center;
                height: 100%;
                padding: 0;
                line-height: normal;
                text-align: left;
            }

            button > div {
                flex: 1;
                ${_styles__WEBPACK_IMPORTED_MODULE_0__.mixins.ellipsis()}
            }

            :host(:not([reverse])) button > div {
                padding-left: 0.5em;
            }

            :host([reverse]) button > div {
                padding-right: 0.5em;
            }

            :host([reverse]) button {
                flex-direction: row-reverse;
            }

            pl-toggle {
                display: inline-block;
                pointer-events: none;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Boolean)
], ToggleButton.prototype, "active", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], ToggleButton.prototype, "reverse", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", String)
], ToggleButton.prototype, "label", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.query)("pl-toggle"),
    __metadata("design:type", _toggle__WEBPACK_IMPORTED_MODULE_2__.Toggle)
], ToggleButton.prototype, "_toggle", void 0);
ToggleButton = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-toggle-button")
], ToggleButton);



/***/ }),

/***/ "../app/src/elements/toggle.ts":
/*!*************************************!*\
  !*** ../app/src/elements/toggle.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Toggle": () => (/* binding */ Toggle)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};


let Toggle = class Toggle extends _base__WEBPACK_IMPORTED_MODULE_0__.BaseElement {
    constructor() {
        super(...arguments);
        this.active = false;
        this.notap = false;
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_0__.html `
            <div class="knob"></div>
        `;
    }
    _click() {
        if (!this.notap) {
            this.toggle();
        }
    }
    toggle() {
        this.active = !this.active;
        this.dispatch("change", { value: this.active, prevValue: !this.active }, true, true);
    }
};
Toggle.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_1__.shared,
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            :host {
                --width: var(--toggle-width, 36px);
                --height: var(--toggle-height, 24px);
                --gutter-width: var(--toggle-gutter-width, 2px);
                --color-off: var(--toggle-color-off, var(--color-foreground));
                --color-on: var(--toggle-color-on, var(--color-highlight));
                --color-knob: var(--toggle-color-knob, var(--color-background));

                display: inline-block;
                width: var(--width);
                height: var(--height);
                background: var(--color-off);
                border-radius: var(--height);

                transition: background 0.5s ease;
            }

            .knob {
                --size: calc(var(--height) - 2 * var(--gutter-width));
                display: block;
                height: var(--size);
                width: var(--size);
                margin: var(--gutter-width);
                background: var(--color-knob);
                border-radius: var(--size);

                transition: transform 0.5s cubic-bezier(1, -0.5, 0, 1.5) -0.2s, background 0.5s, opacity 0.5s;
            }

            :host([active]) {
                background: var(--color-on);
            }

            :host([active]) .knob {
                --dx: calc(var(--width) - var(--height));
                transform: translate(var(--dx), 0);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)({ reflect: true }),
    __metadata("design:type", Boolean)
], Toggle.prototype, "active", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", Boolean)
], Toggle.prototype, "notap", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.listen)("click"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], Toggle.prototype, "_click", null);
Toggle = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.element)("pl-toggle")
], Toggle);



/***/ }),

/***/ "../app/src/elements/totp.ts":
/*!***********************************!*\
  !*** ../app/src/elements/totp.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "TOTPElement": () => (/* binding */ TOTPElement)
/* harmony export */ });
/* harmony import */ var lit_html_directives_style_map_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/style-map.js */ "../app/node_modules/lit-html/directives/style-map.js");
/* harmony import */ var _padloc_core_src_otp__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/otp */ "../core/src/otp.ts");
/* harmony import */ var _padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/encoding */ "../core/src/encoding.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};







let TOTPElement = class TOTPElement extends _base__WEBPACK_IMPORTED_MODULE_5__.BaseElement {
    constructor() {
        super(...arguments);
        this.secret = "";
        this.interval = 30;
        this.token = "";
        this._error = "";
        this._age = 0;
        this._counter = 0;
        this._updateTimeout = -1;
    }
    async _update(updInt = 2000) {
        window.clearTimeout(this._updateTimeout);
        if (!this.secret) {
            this.token = "";
            this._age = 0;
            return;
        }
        const time = Date.now();
        const counter = Math.floor(time / 1000 / this.interval);
        if (counter !== this._counter) {
            try {
                this.token = await (0,_padloc_core_src_otp__WEBPACK_IMPORTED_MODULE_1__.hotp)((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_2__.base32ToBytes)(this.secret), counter);
                this._error = "";
            }
            catch (e) {
                this.token = "";
                this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_3__.translate)("Invalid Code");
                this._age = 0;
                return;
            }
            this._counter = counter;
        }
        this._age = ((Date.now() / 1000) % this.interval) / this.interval;
        if (updInt) {
            this._updateTimeout = window.setTimeout(() => this._update(updInt), updInt);
        }
    }
    connectedCallback() {
        super.connectedCallback();
        this._update();
    }
    disconnectedCallback() {
        super.disconnectedCallback();
        window.clearTimeout(this._updateTimeout);
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            ${this._error
            ? _base__WEBPACK_IMPORTED_MODULE_5__.html `
                      <span class="error">${this._error}</span>
                  `
            : _base__WEBPACK_IMPORTED_MODULE_5__.html `
                      <span>
                          ${this.token.substring(0, 3)}&nbsp;${this.token.substring(3, 6)}
                      </span>
                  `}
            ${_base__WEBPACK_IMPORTED_MODULE_5__.svg `
                <svg class="countdown" viewBox="0 0 10 10" ?hidden=${!this.token}>
                    <circle cx="5" cy="5" r="4" class="bg" />
                    <circle
                        cx="5"
                        cy="5"
                        r="4"
                        style=${(0,lit_html_directives_style_map_js__WEBPACK_IMPORTED_MODULE_0__.styleMap)({ strokeDashoffset: Math.floor(this._age * -25).toString() })}
                    />
                </svg>
            `}
        `;
    }
};
TOTPElement.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_4__.shared,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            :host {
                display: flex;
                align-items: center;
                user-select: text;
                -webkit-user-select: text;
                font: inherit;
                white-space: normal !important;
            }

            .countdown {
                width: 1em;
                height: 1em;
                margin-left: 0.3em;
                border-radius: 100%;
            }

            .countdown circle {
                transform-origin: center center;
                transform: rotate(-90deg);
                fill: none;
                stroke: currentColor;
                stroke-width: 8;
                stroke-dasharray: 25;
                transition: stroke-dashoffset 1s linear;
            }

            .countdown circle.bg {
                opacity: 0.2;
            }

            .error {
                color: var(--color-negative);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], TOTPElement.prototype, "secret", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], TOTPElement.prototype, "interval", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], TOTPElement.prototype, "token", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], TOTPElement.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], TOTPElement.prototype, "_age", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.observe)("secret"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], TOTPElement.prototype, "_update", null);
TOTPElement = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.element)("pl-totp")
], TOTPElement);



/***/ }),

/***/ "../app/src/elements/unlock.ts":
/*!*************************************!*\
  !*** ../app/src/elements/unlock.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Unlock": () => (/* binding */ Unlock)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _start_form__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./start-form */ "../app/src/elements/start-form.ts");
/* harmony import */ var _password_input__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./password-input */ "../app/src/elements/password-input.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _logo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./logo */ "../app/src/elements/logo.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};











let Unlock = class Unlock extends _start_form__WEBPACK_IMPORTED_MODULE_6__.StartForm {
    constructor() {
        super(...arguments);
        this._failedCount = 0;
    }
    async reset() {
        if (!this._passwordInput) {
            return;
        }
        this._passwordInput.value = "";
        this._errorMessage = "";
        this._unlockButton.stop();
        this._failedCount = 0;
        super.reset();
        if (!(0,_lib_util__WEBPACK_IMPORTED_MODULE_4__.isTouch)()) {
            setTimeout(() => this._passwordInput.focus(), 100);
        }
        if (_globals__WEBPACK_IMPORTED_MODULE_3__.app.account &&
            _globals__WEBPACK_IMPORTED_MODULE_3__.app.account.locked &&
            _globals__WEBPACK_IMPORTED_MODULE_3__.app.supportsBiometricUnlock &&
            _globals__WEBPACK_IMPORTED_MODULE_3__.app.remembersMasterKey &&
            !("nobio" in _globals__WEBPACK_IMPORTED_MODULE_3__.router.params)) {
            this._bioAuth();
        }
        setTimeout(() => {
            this._bioauthButton.classList.toggle("show", _globals__WEBPACK_IMPORTED_MODULE_3__.app.supportsBiometricUnlock);
        }, 1000);
    }
    render() {
        const email = _globals__WEBPACK_IMPORTED_MODULE_3__.app.account && _globals__WEBPACK_IMPORTED_MODULE_3__.app.account.email;
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <div flex></div>

            <form>
                <pl-logo class="animate"></pl-logo>

                <div class="account animate">
                    <pl-input .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Logged In As")} .value="${email}" readonly></pl-input>
                    <pl-icon icon="more" class="tap" @click=${this._showMenu}></pl-icon>
                </div>

                <pl-password-input
                    id="passwordInput"
                    required
                    .label=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Enter Master Password")}
                    class="animate"
                    select-on-focus
                    @enter=${() => this._submit()}
                >
                </pl-password-input>

                <pl-loading-button id="unlockButton" class="tap animate" @click=${() => this._submit()}>
                    ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unlock")}
                </pl-loading-button>

                <div class="error note" ?hidden=${!this._errorMessage}>${this._errorMessage}</div>
            </form>

            <div flex></div>

            <pl-loading-button class="bioauth-button icon tap" id="bioauthButton" @click=${this._bioAuth}>
                <pl-icon icon="fingerprint"></pl-icon>
            </pl-loading-button>
        `;
    }
    async _submit() {
        if (this._unlockButton.state === "loading") {
            return;
        }
        this._passwordInput.blur();
        if (!this._passwordInput.value) {
            this._errorMessage = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter your master password!");
            this.rumble();
            this._passwordInput.focus();
            return;
        }
        this._errorMessage = "";
        this._unlockButton.start();
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.unlock(this._passwordInput.value);
            this._unlockButton.success();
            this.done();
        }
        catch (e) {
            this._unlockButton.fail();
            if (e.code !== _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.DECRYPTION_FAILED) {
                throw e;
            }
            this._errorMessage = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Wrong password! Please try again.");
            this.rumble();
            this._failedCount++;
            if (this._failedCount > 2) {
                const recover = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Can't remember your master password?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Recover Account"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Try Again"));
                if (recover) {
                    _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("recover", { email: _globals__WEBPACK_IMPORTED_MODULE_3__.app.account.email });
                }
            }
            else {
                this._passwordInput.focus();
            }
        }
    }
    async _showMenu() {
        const choice = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.choose)("", [(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Logout / Switch Account"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Forgot Password")]);
        switch (choice) {
            case 0:
                this._logout();
                break;
            case 1:
                _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("recover", { email: _globals__WEBPACK_IMPORTED_MODULE_3__.app.account.email });
                break;
        }
    }
    async _logout() {
        const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Are you sure you want to log out of this account?"));
        if (confirmed) {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.logout();
            _globals__WEBPACK_IMPORTED_MODULE_3__.router.go("login");
        }
    }
    async _bioAuth() {
        if (this._bioauthButton.state === "loading") {
            return;
        }
        this._bioauthButton.start();
        try {
            if (_globals__WEBPACK_IMPORTED_MODULE_3__.app.remembersMasterKey) {
                const authenticated = await (0,_padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_2__.biometricAuth)();
                if (!authenticated) {
                    this._bioauthButton.fail();
                    return;
                }
                try {
                    await _globals__WEBPACK_IMPORTED_MODULE_3__.app.unlockWithRememberedMasterKey();
                }
                catch (e) {
                    this.dispatch("enable-biometric-auth", {
                        message: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Biometric unlock expired. Complete setup to reeneable.")
                    });
                }
                this._bioauthButton.success();
            }
            else {
                this.dispatch("enable-biometric-auth");
                this._bioauthButton.stop();
            }
        }
        catch (error) {
            this._bioauthButton.fail();
            (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_9__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Biometric unlock failed! Reason: {0}", error.message), {
                title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Failed To Unlock"),
                type: "warning"
            });
        }
    }
    _focused() {
        setTimeout(() => {
            if (_globals__WEBPACK_IMPORTED_MODULE_3__.app.state.locked && this.classList.contains("showing") && document.visibilityState !== "hidden") {
                this._passwordInput && this._passwordInput.focus();
            }
        }, 100);
    }
};
Unlock.styles = [
    ..._start_form__WEBPACK_IMPORTED_MODULE_6__.StartForm.styles,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            .current-account {
                font-size: var(--font-size-tiny);
                margin: 30px;
            }

            .logout {
                text-decoration: underline;
                cursor: pointer;
            }

            .account {
                position: relative;
            }

            .account pl-icon {
                position: absolute;
                right: 5px;
                top: 6px;
            }

            .bioauth-button {
                background: transparent;
                width: 50px;
                transition: transform 0.5s cubic-bezier(1, -0.3, 0, 1.3), opacity 0.5s;
                position: absolute;
                bottom: 12px;
                left: 0;
                right: 0;
                margin: auto;
            }

            .bioauth-button:not(.show) {
                opacity: 0;
                transform: scale(0);
            }

            .bioauth-button pl-icon {
                font-size: 140%;
                width: 50px;
                height: 50px;
            }

            @supports (-webkit-overflow-scrolling: touch) {
                .bioauth-button {
                    bottom: max(env(safe-area-inset-bottom), 12px);
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], Unlock.prototype, "_errorMessage", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#passwordInput"),
    __metadata("design:type", _password_input__WEBPACK_IMPORTED_MODULE_7__.PasswordInput)
], Unlock.prototype, "_passwordInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#unlockButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_8__.LoadingButton)
], Unlock.prototype, "_unlockButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#bioauthButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_8__.LoadingButton)
], Unlock.prototype, "_bioauthButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.listen)("visibilitychange", document),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], Unlock.prototype, "_focused", null);
Unlock = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.element)("pl-unlock")
], Unlock);



/***/ }),

/***/ "../app/src/elements/update-subscription-dialog.ts":
/*!*********************************************************!*\
  !*** ../app/src/elements/update-subscription-dialog.ts ***!
  \*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "UpdateSubscriptionDialog": () => (/* binding */ UpdateSubscriptionDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/billing */ "../core/src/billing.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _card_input__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./card-input */ "../app/src/elements/card-input.ts");
/* harmony import */ var _choose_plan_dialog__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./choose-plan-dialog */ "../app/src/elements/choose-plan-dialog.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};










let UpdateSubscriptionDialog = class UpdateSubscriptionDialog extends _dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog {
    constructor() {
        super(...arguments);
        this.org = null;
        this.plan = null;
        this.quantity = 1;
        this._error = "";
    }
    async show(org) {
        const promise = super.show();
        this._error = "";
        this.org = org;
        const sub = org.billing && org.billing.subscription;
        if (sub) {
            this.plan = sub.plan;
            this.quantity = sub.members;
        }
        else {
            this._changePlan();
        }
        return promise;
    }
    async _submit() {
        if (this._submitButton.state === "loading") {
            return;
        }
        this._error = "";
        this._submitButton.start();
        const params = new _padloc_core_src_billing__WEBPACK_IMPORTED_MODULE_1__.UpdateBillingParams({
            plan: this.plan.id,
            members: this.quantity,
            org: this.org.id
        });
        try {
            await _globals__WEBPACK_IMPORTED_MODULE_3__.app.updateBilling(params);
            this._submitButton.success();
            this.done();
        }
        catch (e) {
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Something went wrong. Please try again later!");
            this._submitButton.fail();
        }
    }
    async _updateQuantity() {
        const quantity = parseInt(this._quantityInput.value);
        const { min, max } = this.plan;
        if (!isNaN(quantity) && quantity >= min && quantity <= max) {
            this.quantity = quantity;
        }
    }
    async _changePlan() {
        this.open = false;
        const plan = await this._choosePlanDialog.show(this.org || undefined);
        if (plan) {
            this.plan = plan;
            this.quantity = plan.min;
        }
        this.open = true;
    }
    renderContent() {
        const plan = this.plan;
        if (!plan) {
            return _base__WEBPACK_IMPORTED_MODULE_4__.html ``;
        }
        const color = plan.color;
        const monthlyPrice = Math.round((this.quantity * plan.cost) / 12);
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <div style=${`--color-highlight: ${color}; --color-highlight-text: var(--color-tertiary);`}>
                <h1>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Update Subscription")}</h1>

                <div class="plan item">
                    <pl-icon class="tap edit-plan-icon" icon="edit" @click=${this._changePlan}></pl-icon>

                    <div class="plan-name">
                        ${plan.name}
                    </div>

                    <div class="plan-price">
                        <div class="plan-price-currency">$</div>
                        <div class="plan-price-dollars">
                            ${Math.floor(monthlyPrice / 100)}
                        </div>
                        <div class="plan-price-cents">
                            .${(monthlyPrice % 100).toString().padEnd(2, "0")}
                        </div>
                    </div>

                    <div class="plan-unit">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("per month")}
                    </div>

                    <div class="plan-fineprint">
                        (${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("USD, billed annually")})
                    </div>

                    <div class="flex"></div>
                </div>

                <div class="quantity-wrapper" ?hidden=${plan.max < 2}>
                    <div class="quantity-minmax flex">
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} min", plan.min.toString())}</div>
                        <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("{0} max", plan.max.toString())}</div>
                    </div>
                    <pl-input
                        id="quantityInput"
                        class="quantity-input item"
                        type="number"
                        .value=${this.quantity}
                        .min=${plan.min}
                        .max=${plan.max}
                        @input=${this._updateQuantity}
                        @blur=${() => (this._quantityInput.value = this.quantity.toString())}
                    ></pl-input>
                    <div class="quantity-label flex">
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Seats")}
                    </div>
                </div>

                <div class="error item" ?hidden="${!this._error}">
                    ${this._error}
                </div>

                <div class="actions">
                    <pl-loading-button id="submitButton" class="tap primary" @click=${this._submit}>
                        ${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Update")}
                    </pl-loading-button>

                    <button class="tap" @click=${() => this.done()}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel")}</button>
                </div>
            </div>
        `;
    }
};
UpdateSubscriptionDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            .inner {
                background: transparent;
                box-shadow: none;
                background: var(--color-quaternary);
                text-align: center;
            }

            .plan {
                text-align: center;
                padding: 20px;
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                display: flex;
                flex-direction: column;
                position: relative;
            }

            .plan-name {
                font-size: 1.7rem;
                margin-bottom: 8px;
                font-weight: bold;
            }

            .plan-price {
                letter-spacing: 0.1em;
                display: flex;
                align-items: flex-start;
                justify-content: center;
                font-weight: bold;
                font-size: 1rem;
                margin: 5px;
            }

            .plan-price-currency {
                line-height: 1em;
                margin-top: 0.4em;
            }

            .plan-price-dollars {
                font-size: 3em;
                line-height: 1em;
            }

            .plan-price-cents {
                font-size: 1.5em;
                line-height: 1em;
                margin-top: 0.2em;
            }

            .plan-unit {
                font-size: var(--font-size-small);
            }

            .plan-fineprint {
                font-size: var(--font-size-tiny);
                opacity: 0.7;
                margin: 4px 0 -4px 0;
            }

            pl-loading-button {
                font-weight: bold;
            }

            pl-loading-button.primary {
                background: var(--color-highlight);
                color: var(--color-highlight-text);
                font-weight: bold;
                border-bottom: solid 3px var(--color-shade-2);
            }

            .quantity-wrapper {
                display: flex;
                align-items: center;
                justify-content: center;
                margin: 8px;
            }

            .quantity-label {
                font-weight: bold;
                padding: 12px;
                font-size: 1.2em;
                text-align: left;
            }

            .quantity-input {
                width: 60px;
                margin: 0;
                font-weight: bold;
                font-size: 1.5rem;
            }

            .quantity-minmax {
                font-size: var(--font-size-micro);
                opacity: 0.5;
                text-align: right;
                padding: 12px;
            }

            .edit-plan-icon {
                position: absolute;
                top: 8px;
                right: 8px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], UpdateSubscriptionDialog.prototype, "org", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], UpdateSubscriptionDialog.prototype, "plan", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Number)
], UpdateSubscriptionDialog.prototype, "quantity", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], UpdateSubscriptionDialog.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#quantityInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_9__.Input)
], UpdateSubscriptionDialog.prototype, "_quantityInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#submitButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_6__.LoadingButton)
], UpdateSubscriptionDialog.prototype, "_submitButton", void 0);
__decorate([
    (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.dialog)("pl-choose-plan-dialog"),
    __metadata("design:type", _choose_plan_dialog__WEBPACK_IMPORTED_MODULE_8__.ChoosePlanDialog)
], UpdateSubscriptionDialog.prototype, "_choosePlanDialog", void 0);
UpdateSubscriptionDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-update-subscription-dialog")
], UpdateSubscriptionDialog);



/***/ }),

/***/ "../app/src/elements/upload-dialog.ts":
/*!********************************************!*\
  !*** ../app/src/elements/upload-dialog.ts ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "UploadDialog": () => (/* binding */ UploadDialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/util */ "../app/src/lib/util.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};









let UploadDialog = class UploadDialog extends _dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog {
    constructor() {
        super(...arguments);
        this.file = null;
        this.itemId = null;
        this.preventDismiss = true;
        this._progress = null;
        this._error = "";
    }
    get _item() {
        const found = (this.itemId && _globals__WEBPACK_IMPORTED_MODULE_2__.app.getItem(this.itemId)) || null;
        return found && found.item;
    }
    get _vault() {
        const found = (this.itemId && _globals__WEBPACK_IMPORTED_MODULE_2__.app.getItem(this.itemId)) || null;
        return found && found.vault;
    }
    show({ item, file }) {
        this._error = "";
        this._progress = null;
        this.file = file;
        this.itemId = item;
        return super.show();
    }
    async upload() {
        if (this._uploadButton.state === "loading") {
            return;
        }
        this._progress = null;
        this._error = "";
        if (!this._nameInput.value) {
            this._error = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Please enter a name!");
            return;
        }
        this._uploadButton.start();
        const att = await _globals__WEBPACK_IMPORTED_MODULE_2__.app.createAttachment(this.itemId, this.file, this._nameInput.value);
        const upload = att.uploadProgress;
        const handler = () => (this._progress = upload.progress);
        upload.addEventListener("progress", handler);
        try {
            await upload.completed;
        }
        catch (e) { }
        upload.removeEventListener("progress", handler);
        this._progress = null;
        if (upload.error) {
            this._uploadButton.fail();
            this._error =
                upload.error.code === _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.STORAGE_QUOTA_EXCEEDED
                    ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Storage limit exceeded!")
                    : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Upload failed! Please try again!");
        }
        else {
            this._uploadButton.success();
            this.done(att);
        }
    }
    renderContent() {
        if (!this.file) {
            return _base__WEBPACK_IMPORTED_MODULE_4__.html ``;
        }
        return _base__WEBPACK_IMPORTED_MODULE_4__.html `
            <div class="file-info">
                <pl-icon .icon=${(0,_lib_util__WEBPACK_IMPORTED_MODULE_3__.fileIcon)(this.file.type)}></pl-icon>

                <div class="flex">
                    <h1>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Upload Attachment")}</h1>

                    <pl-input class="name" id="nameInput" .value=${this.file.name}></pl-input>

                    <div class="size">
                        ${this._progress
            ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("uploading... {0}/{1}", (0,_lib_util__WEBPACK_IMPORTED_MODULE_3__.fileSize)(this._progress.loaded), (0,_lib_util__WEBPACK_IMPORTED_MODULE_3__.fileSize)(this._progress.total))
            : (this.file.type || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Unkown File Type")) + " - " + (0,_lib_util__WEBPACK_IMPORTED_MODULE_3__.fileSize)(this.file.size)}
                    </div>

                    <div class="error" ?hidden=${!this._error}>${this._error}</div>
                </div>
            </div>

            <div class="actions">
                <pl-loading-button id="uploadButton" class="primary tap" @click="${this.upload}}">
                    <div>${this._error ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Retry Upload") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Upload")}</div>
                </pl-loading-button>

                <button class="tap" @click=${() => this.done()} ?disabled=${!!this._progress}>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel")}</button>
            </div>
        `;
    }
};
UploadDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_4__.css `
            h1 {
                margin: 0 0 8px 0;
            }

            .file-info {
                display: flex;
                margin: 12px 0;
                align-items: center;
            }

            .file-info pl-icon {
                width: 80px;
                height: 80px;
                font-size: 60px;
                margin: 4px;
            }

            .name {
                font-weight: bold;
                height: auto;
                padding: 8px 12px;
                margin-right: 12px;
                margin-left: -6px;
            }

            .size,
            .error {
                margin-top: 8px;
                font-weight: bold;
                font-size: var(--font-size-small);
            }

            .error {
                color: var(--color-negative);
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], UploadDialog.prototype, "file", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], UploadDialog.prototype, "itemId", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], UploadDialog.prototype, "_progress", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.property)(),
    __metadata("design:type", Object)
], UploadDialog.prototype, "_error", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#nameInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], UploadDialog.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.query)("#uploadButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], UploadDialog.prototype, "_uploadButton", void 0);
UploadDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_4__.element)("pl-upload-dialog")
], UploadDialog);



/***/ }),

/***/ "../app/src/elements/vault-dialog.ts":
/*!*******************************************!*\
  !*** ../app/src/elements/vault-dialog.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "VaultDialog": () => (/* binding */ VaultDialog)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/org */ "../core/src/org.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _dialog__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dialog */ "../app/src/elements/dialog.ts");
/* harmony import */ var _loading_button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./loading-button */ "../app/src/elements/loading-button.ts");
/* harmony import */ var _input__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./input */ "../app/src/elements/input.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
/* harmony import */ var _group_item__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./group-item */ "../app/src/elements/group-item.ts");
/* harmony import */ var _member_item__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./member-item */ "../app/src/elements/member-item.ts");
/* harmony import */ var _toggle__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./toggle */ "../app/src/elements/toggle.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};













let VaultDialog = class VaultDialog extends _dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog {
    constructor() {
        super(...arguments);
        this.org = null;
        this.vault = null;
        this._filterString = "";
        this._error = "";
        this._members = new Map();
        this._groups = new Map();
    }
    _getCurrentMembers() {
        const members = new Map();
        if (!this.org) {
            return members;
        }
        for (const member of this.org.members) {
            const v = this.vault && member.vaults.find(v => v.id === this.vault.id);
            members.set(member.id, {
                read: !!v,
                write: !!v && !v.readonly
            });
        }
        return members;
    }
    _getCurrentGroups() {
        const groups = new Map();
        if (!this.org) {
            return groups;
        }
        for (const group of this.org.groups) {
            const v = this.vault && group.vaults.find(v => v.id === this.vault.id);
            groups.set(group.name, {
                read: !!v,
                write: !!v && !v.readonly
            });
        }
        return groups;
    }
    get _hasChanged() {
        if (!this.org || !this._nameInput) {
            return false;
        }
        const currentGroups = this._getCurrentGroups();
        const groupsChanged = this.org.groups.some(({ name }) => {
            const c = currentGroups.get(name);
            const s = this._groups.get(name);
            return c.read !== s.read || c.write !== s.write;
        });
        const currentMembers = this._getCurrentMembers();
        const membersChanged = this.org.members.some(({ id }) => {
            const c = currentMembers.get(id);
            const s = this._members.get(id);
            return c.read !== s.read || c.write !== s.write;
        });
        const nameChanged = this.vault ? this.vault.name !== this._nameInput.value : !!this._nameInput.value;
        return ((this._groups.size || this._members.size) &&
            this._nameInput.value &&
            (groupsChanged || membersChanged || nameChanged));
    }
    async show({ vault, org }) {
        this._error = "";
        this.vault = vault;
        this.org = org;
        this._members = this._getCurrentMembers();
        this._groups = this._getCurrentGroups();
        await this.updateComplete;
        this._nameInput.value = this.vault ? this.vault.name : "";
        return super.show();
    }
    _toggle(obj) {
        if (obj instanceof _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.Group) {
            const { read } = this._groups.get(obj.name);
            this._groups.set(obj.name, read ? { read: false, write: false } : { read: true, write: true });
        }
        else {
            const { read } = this._members.get(obj.id);
            this._members.set(obj.id, read ? { read: false, write: false } : { read: true, write: true });
        }
        this.requestUpdate();
    }
    _toggleRead(obj, event) {
        if (event) {
            event.stopImmediatePropagation();
        }
        const sel = obj instanceof _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.Group ? this._groups.get(obj.name) : this._members.get(obj.id);
        sel.read = !sel.read;
        if (!sel.read) {
            sel.write = false;
        }
        this.requestUpdate();
    }
    _toggleWrite(obj, event) {
        if (event) {
            event.stopImmediatePropagation();
        }
        const sel = obj instanceof _padloc_core_src_org__WEBPACK_IMPORTED_MODULE_0__.Group ? this._groups.get(obj.name) : this._members.get(obj.id);
        sel.write = !sel.write;
        if (sel.write) {
            sel.read = true;
        }
        this.requestUpdate();
    }
    // _toggleReadonly(group: Group) {
    //     this._selection.get(group.id)!.readonly = !this._selection.get(group.id)!.readonly;
    // }
    async _save() {
        this._error = "";
        const groups = [...this._groups.entries()]
            .filter(([, { read }]) => read)
            .map(([name, { write }]) => ({ name, readonly: !write }));
        const members = [...this._members.entries()]
            .filter(([, { read }]) => read)
            .map(([id, { write }]) => ({ id, readonly: !write }));
        if (!members.length && !groups.length) {
            this._error = "You have to assign at least one member or group!";
            return;
        }
        if (this._saveButton.state === "loading") {
            return;
        }
        this._saveButton.start();
        try {
            if (this.vault) {
                await _globals__WEBPACK_IMPORTED_MODULE_3__.app.updateVaultAccess(this.org.id, this.vault.id, this._nameInput.value, members, groups);
            }
            else {
                await _globals__WEBPACK_IMPORTED_MODULE_3__.app.createVault(this._nameInput.value, this.org, members, groups);
            }
            this._saveButton.success();
            this.done();
        }
        catch (e) {
            this._saveButton.fail();
            this._error = e.message || (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Something went wrong. Please try again later!");
            throw e;
        }
        this.requestUpdate();
    }
    async _deleteVault() {
        this.open = false;
        const deleted = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_4__.prompt)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Are you sure you want to delete this vault? " +
            "All the data stored in it will be lost! " +
            "This action can not be undone."), {
            type: "destructive",
            title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Delete Vault"),
            confirmLabel: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Delete"),
            placeholder: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Type 'DELETE' to confirm"),
            validate: async (val) => {
                if (val !== "DELETE") {
                    throw (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Type 'DELETE' to confirm");
                }
                await _globals__WEBPACK_IMPORTED_MODULE_3__.app.deleteVault(this.vault.id);
                return val;
            }
        });
        if (deleted) {
            this.done();
        }
        else {
            this.open = true;
        }
    }
    _updateFilter() {
        this._filterString = this._filterInput.value;
    }
    _clearFilter() {
        this._filterString = this._filterInput.value = "";
    }
    shouldUpdate() {
        return !!this.org;
    }
    renderContent() {
        const org = this.org;
        const isAdmin = org.isAdmin(_globals__WEBPACK_IMPORTED_MODULE_3__.app.account);
        const filter = this._filterString.toLowerCase();
        const members = filter
            ? org.members.filter(({ name, email }) => email.toLowerCase().includes(filter) || name.toLowerCase().includes(filter))
            : org.members;
        const groups = filter ? org.groups.filter(({ name }) => name.toLowerCase().includes(filter)) : org.groups;
        return _base__WEBPACK_IMPORTED_MODULE_5__.html `
            <header>
                <pl-icon icon="vault"></pl-icon>
                <pl-input
                    id="nameInput"
                    class="flex"
                    .placeholder=${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Enter Vault Name")}
                    .readonly=${!isAdmin}
                    @input=${() => this.requestUpdate()}
                ></pl-input>
                <pl-icon
                    icon="delete"
                    class="delete-button tap"
                    ?hidden=${!isAdmin || !this.vault}
                    @click=${this._deleteVault}
                ></pl-icon>
            </header>

            <div class="content">
                <div class="search-wrapper item">
                    <pl-icon icon="search"></pl-icon>
                    <pl-input id="filterInput" placeholder="${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Search...")}" @input=${this._updateFilter}></pl-input>
                    <pl-icon icon="cancel" class="tap" @click=${this._clearFilter}></pl-icon>
                </div>

                <div class="subheader" ?hidden=${!groups.length}>
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Groups")}</div>
                    <div class="flex"></div>
                    <div class="permission">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("read")}</div>
                    <div class="permission">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("write")}</div>
                </div>

                ${groups.map(group => _base__WEBPACK_IMPORTED_MODULE_5__.html `
                        <div class="item tap" @click=${() => this._toggle(group)} ?disabled=${!isAdmin}>
                            <pl-group-item .group=${group} class="flex"></pl-group-item>
                            <pl-toggle
                                .active=${this._groups.get(group.name).read}
                                @click=${(e) => this._toggleRead(group, e)}
                            ></pl-toggle>
                            <pl-toggle
                                .active=${this._groups.get(group.name).write}
                                @click=${(e) => this._toggleWrite(group, e)}
                            ></pl-toggle>
                        </div>
                    `)}

                <div class="subheader" ?hidden=${!members.length}>
                    <div>${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Members")}</div>
                    <div class="flex"></div>
                    <div class="permission">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("read")}</div>
                    <div class="permission">${(0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("write")}</div>
                </div>

                ${members.map(member => _base__WEBPACK_IMPORTED_MODULE_5__.html `
                        <div class="item tap" @click=${() => this._toggle(member)} ?disabled=${!isAdmin}>
                            <pl-member-item hideRole .member=${member} class="flex"></pl-member-item>
                            <pl-toggle
                                .active=${this._members.get(member.id).read}
                                @click=${(e) => this._toggleRead(member, e)}
                            ></pl-toggle>
                            <pl-toggle
                                .active=${this._members.get(member.id).write}
                                @click=${(e) => this._toggleWrite(member, e)}
                            ></pl-toggle>
                        </div>
                    `)}

                <div class="error item" ?hidden="${!this._error}">
                    ${this._error}
                </div>
            </div>

            <div class="footer">
                <div class="actions">
                    <pl-loading-button
                        class="tap primary"
                        id="saveButton"
                        ?disabled=${!isAdmin || !this._hasChanged}
                        @click=${this._save}
                    >
                        ${this.vault ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Save") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Create Vault")}
                    </pl-loading-button>

                    <button class="transparent tap" @click=${this.dismiss}>
                        ${this._hasChanged ? (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Cancel") : (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Close")}
                    </button>
                </div>
            </div>
        `;
    }
};
VaultDialog.styles = [
    ..._dialog__WEBPACK_IMPORTED_MODULE_6__.Dialog.styles,
    _base__WEBPACK_IMPORTED_MODULE_5__.css `
            .inner {
                background: var(--color-quaternary);
            }

            .delete-button {
                color: var(--color-negative);
                font-size: var(--font-size-default);
            }

            .subheader {
                margin: 8px;
                font-weight: bold;
                display: flex;
                align-items: flex-end;
                padding: 0 8px;
                font-size: var(--font-size-small);
            }

            .subheader .permission {
                width: 50px;
                text-align: center;
                font-size: var(--font-size-tiny);
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.ellipsis()}
            }

            .item {
                display: flex;
                align-items: center;
            }

            .item pl-toggle {
                margin-right: 14px;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], VaultDialog.prototype, "org", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", Object)
], VaultDialog.prototype, "vault", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#nameInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], VaultDialog.prototype, "_nameInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#saveButton"),
    __metadata("design:type", _loading_button__WEBPACK_IMPORTED_MODULE_7__.LoadingButton)
], VaultDialog.prototype, "_saveButton", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.query)("#filterInput"),
    __metadata("design:type", _input__WEBPACK_IMPORTED_MODULE_8__.Input)
], VaultDialog.prototype, "_filterInput", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], VaultDialog.prototype, "_filterString", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.property)(),
    __metadata("design:type", String)
], VaultDialog.prototype, "_error", void 0);
VaultDialog = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_5__.element)("pl-vault-dialog")
], VaultDialog);



/***/ }),

/***/ "../app/src/elements/vault-item.ts":
/*!*****************************************!*\
  !*** ../app/src/elements/vault-item.ts ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "VaultItem": () => (/* binding */ VaultItem)
/* harmony export */ });
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./icon */ "../app/src/elements/icon.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};



let VaultItem = class VaultItem extends _base__WEBPACK_IMPORTED_MODULE_1__.BaseElement {
    constructor() {
        super(...arguments);
        this.groups = 0;
        this.members = 0;
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <pl-icon class="icon" icon="vault"></pl-icon>

            <div class="vault-info">
                <div class="vault-name ellipsis">${this.vault.name}</div>

                <div class="tags small">
                    <div class="tag">
                        <pl-icon icon="group"></pl-icon>

                        <div>${this.groups}</div>
                    </div>

                    <div class="tag">
                        <pl-icon icon="user"></pl-icon>

                        <div>${this.members}</div>
                    </div>
                </div>
            </div>
        `;
    }
};
VaultItem.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_0__.shared,
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            :host {
                display: flex;
                align-items: center;
                padding: 4px 0;
            }

            .icon {
                font-size: 120%;
                margin: 8px;
                background: #eee;
                border: solid 1px #ddd;
                width: 45px;
                height: 45px;
            }

            .tags {
                margin: 4px 0;
            }

            .vault-name {
                font-weight: bold;
                margin-bottom: 4px;
            }

            .vault-info {
                flex: 1;
                width: 0;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Object)
], VaultItem.prototype, "vault", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Number)
], VaultItem.prototype, "groups", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Number)
], VaultItem.prototype, "members", void 0);
VaultItem = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-vault-item")
], VaultItem);



/***/ }),

/***/ "../app/src/elements/view.ts":
/*!***********************************!*\
  !*** ../app/src/elements/view.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "View": () => (/* binding */ View)
/* harmony export */ });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};


class View extends _base__WEBPACK_IMPORTED_MODULE_0__.BaseElement {
    constructor() {
        super(...arguments);
        this.active = false;
    }
    _activeChanged() {
        if (this.active) {
            this._activated();
        }
        else {
            this._deactivated();
        }
    }
    _activated() { }
    _deactivated() { }
}
View.styles = [
    _styles__WEBPACK_IMPORTED_MODULE_1__.shared,
    _base__WEBPACK_IMPORTED_MODULE_0__.css `
            @supports (-webkit-overflow-scrolling: touch) {
                header {
                    padding-top: max(env(safe-area-inset-top), 8px);
                }

                .fabs {
                    margin: calc(env(safe-area-inset-bottom) / 3);
                }
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.property)(),
    __metadata("design:type", Boolean)
], View.prototype, "active", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_0__.observe)("active"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], View.prototype, "_activeChanged", null);


/***/ }),

/***/ "../app/src/elements/virtual-list.ts":
/*!*******************************************!*\
  !*** ../app/src/elements/virtual-list.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "VirtualList": () => (/* binding */ VirtualList),
/* harmony export */   "VirtualListTest": () => (/* binding */ VirtualListTest)
/* harmony export */ });
/* harmony import */ var lit_html_directives_guard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-html/directives/guard */ "../app/node_modules/lit-html/directives/guard.js");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ "../app/src/elements/base.ts");
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../styles */ "../app/src/styles/index.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};



let VirtualList = class VirtualList extends _base__WEBPACK_IMPORTED_MODULE_1__.BaseElement {
    constructor() {
        super(...arguments);
        this.data = [];
        this.buffer = 1;
        this._elements = [];
    }
    get firstIndex() {
        return this._firstIndex;
    }
    get lastIndex() {
        return this._lastIndex;
    }
    connectedCallback() {
        super.connectedCallback();
        this.addEventListener("scroll", () => this._updateIndizes(), { passive: true });
        this._updateBounds();
    }
    _updateBounds() {
        const { width, height } = getComputedStyle(this);
        this._width = parseInt(width);
        this._height = parseInt(height);
        this._itemsPerRow = Math.floor(this._width / (this.minItemWidth || this._width));
        this._itemWidth = this._width / this._itemsPerRow;
        const rowCount = Math.ceil(this.data.length / this._itemsPerRow);
        this._canvasHeight = rowCount * this.itemHeight;
        const elementCount = Math.ceil(this._height / this.itemHeight + 2 * this.buffer) * this._itemsPerRow;
        const els = [];
        for (let i = 0; i < elementCount; i++) {
            els.push({ data: null, x: 0, y: 0 });
        }
        this._elements = els;
        this._updateIndizes();
        this._updateElements();
    }
    _updateIndizes() {
        const oldFirstIndex = this._firstIndex;
        const oldLastIndex = this._lastIndex;
        this._firstIndex = Math.max(Math.floor(this.scrollTop / this.itemHeight - this.buffer) * this._itemsPerRow, 0);
        this._lastIndex = Math.min(this._firstIndex + this._elements.length, this.data.length) - 1;
        if (this._firstIndex !== oldFirstIndex || this._lastIndex !== oldLastIndex) {
            this._updateElements();
        }
    }
    _updateElements() {
        for (let i = this._firstIndex; i <= this._lastIndex; i++) {
            const elIndex = i % this._elements.length;
            Object.assign(this._elements[elIndex], {
                data: this.data[i],
                x: (i % this._itemsPerRow) * this._itemWidth,
                y: Math.floor(i / this._itemsPerRow) * this.itemHeight
            });
        }
        this.requestUpdate();
    }
    createRenderRoot() {
        return this;
    }
    render() {
        const { _itemWidth: w, itemHeight: h } = this;
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <div class="content" style="position: relative; height: ${this._canvasHeight}px">
                ${this._elements.map(({ x, y, data }) => {
            const render = () => {
                return data !== null
                    ? _base__WEBPACK_IMPORTED_MODULE_1__.html `
                                  <div
                                      class="cell"
                                      style="position: absolute; will-change: transform; width: ${w}px; height: ${h}px; transform: translate3d(${x}px, ${y}px, 0)"
                                  >
                                      ${this.renderItem(data)}
                                  </div>
                              `
                    : _base__WEBPACK_IMPORTED_MODULE_1__.html ``;
            };
            const deps = [x, y, data, w, h];
            this.guard && data && deps.push(...this.guard(data));
            return this.guard ? (0,lit_html_directives_guard__WEBPACK_IMPORTED_MODULE_0__.guard)(deps, render) : render();
        })}
            </div>
        `;
    }
};
VirtualList.styles = [
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            :host {
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.scroll()}
                overflow-y: auto !important;
                overflow-x: hidden !important;
            }

            ::slotted(.content) {
                position: relative;
            }

            ::slotted(.cell) {
                position: absolute;
                will-change: transform;
                transition: transform 0.5s;
            }
        `
];
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Array)
], VirtualList.prototype, "data", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Number)
], VirtualList.prototype, "minItemWidth", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Number)
], VirtualList.prototype, "itemHeight", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Function)
], VirtualList.prototype, "renderItem", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Number)
], VirtualList.prototype, "buffer", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.property)(),
    __metadata("design:type", Function)
], VirtualList.prototype, "guard", void 0);
__decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.observe)("data", "itemMinWidth", "minItemWidth", "itemHeight"),
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.listen)("resize", window),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], VirtualList.prototype, "_updateBounds", null);
VirtualList = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("pl-virtual-list")
], VirtualList);

let VirtualListTest = class VirtualListTest extends _base__WEBPACK_IMPORTED_MODULE_1__.BaseElement {
    constructor() {
        super();
        this.data = [];
        for (let i = 0; i < 10000; i++) {
            this.data.push({ i });
        }
    }
    render() {
        return _base__WEBPACK_IMPORTED_MODULE_1__.html `
            <pl-virtual-list
                .data=${this.data}
                .minItemWidth=${200}
                .itemHeight=${100}
                .renderItem=${(item) => _base__WEBPACK_IMPORTED_MODULE_1__.html `
                        <div class="item">${item.i}</div>
                    `}
            ></pl-virtual-list>
        `;
    }
};
VirtualListTest.styles = [
    _base__WEBPACK_IMPORTED_MODULE_1__.css `
            pl-virtual-list {
                ${_styles__WEBPACK_IMPORTED_MODULE_2__.mixins.fullbleed()}
                overflow-y: auto;
            }

            .item {
                border: solid 1px;
                margin: 5px;
                text-align: center;
                line-height: 90px;
            }
        `
];
VirtualListTest = __decorate([
    (0,_base__WEBPACK_IMPORTED_MODULE_1__.element)("virtual-list-test"),
    __metadata("design:paramtypes", [])
], VirtualListTest);



/***/ }),

/***/ "../app/src/globals.ts":
/*!*****************************!*\
  !*** ../app/src/globals.ts ***!
  \*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "app": () => (/* binding */ app),
/* harmony export */   "router": () => (/* binding */ router)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/app */ "../core/src/app.ts");
/* harmony import */ var _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/platform */ "../core/src/platform.ts");
/* harmony import */ var _lib_route__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/route */ "../app/src/lib/route.ts");
/* harmony import */ var _lib_ajax__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/ajax */ "../app/src/lib/ajax.ts");




const sender = new _lib_ajax__WEBPACK_IMPORTED_MODULE_3__.AjaxSender("http://0.0.0.0:3000");
const app = (window.app = new _padloc_core_src_app__WEBPACK_IMPORTED_MODULE_0__.App(sender));
const router = (window.router = new _lib_route__WEBPACK_IMPORTED_MODULE_2__.Router());
window.getPlatform = _padloc_core_src_platform__WEBPACK_IMPORTED_MODULE_1__.getPlatform;


/***/ }),

/***/ "../app/src/lib/ajax.ts":
/*!******************************!*\
  !*** ../app/src/lib/ajax.ts ***!
  \******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "request": () => (/* binding */ request),
/* harmony export */   "AjaxSender": () => (/* binding */ AjaxSender)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/encoding */ "../core/src/encoding.ts");
/* harmony import */ var _padloc_core_src_transport__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/transport */ "../core/src/transport.ts");



async function request(method, url, body, headers, progress) {
    let req = new XMLHttpRequest();
    return new Promise((resolve, reject) => {
        req.onreadystatechange = () => {
            if (req.readyState === 4) {
                if (!req.status) {
                    reject(new _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.Err(_padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.FAILED_CONNECTION));
                }
                else {
                    resolve(req);
                }
            }
        };
        try {
            req.open(method, url, true);
            if (headers) {
                headers.forEach((value, key) => req.setRequestHeader(key, value));
            }
            if (progress) {
                req.onprogress = (pg) => (progress.downloadProgress = pg);
                req.upload.onprogress = (pg) => (progress.uploadProgress = pg);
            }
            req.send(body);
        }
        catch (e) {
            reject(new _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.Err(_padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.FAILED_CONNECTION));
        }
    });
}
class AjaxSender {
    constructor(url) {
        this.url = url;
    }
    async send(req, progress) {
        const body = (0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_1__.marshal)(req.toRaw());
        const res = await request("POST", this.url, body, new Map([["Content-Type", "application/json"], ["Accept", "application/json"]]), progress);
        try {
            return new _padloc_core_src_transport__WEBPACK_IMPORTED_MODULE_2__.Response().fromRaw((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_1__.unmarshal)(res.responseText));
        }
        catch (e) {
            throw new _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.Err(_padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.SERVER_ERROR);
        }
    }
}


/***/ }),

/***/ "../app/src/lib/animation.ts":
/*!***********************************!*\
  !*** ../app/src/lib/animation.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "animateElement": () => (/* binding */ animateElement),
/* harmony export */   "animateCascade": () => (/* binding */ animateCascade)
/* harmony export */ });
const defaults = {
    animation: "slideIn",
    duration: 500,
    easing: "ease",
    delay: 0,
    fill: "backwards",
    initialDelay: 0,
    fullDuration: 1000,
    clear: false,
    direction: "normal"
};
const clearAnimation = new Map();
function animateElement(el, opts = {}) {
    const { animation, duration, direction, easing, delay, fill, clear } = Object.assign({}, defaults, opts);
    clearTimeout(clearAnimation.get(el));
    el.style.animation = "";
    el.offsetLeft;
    el.style.animation = `${animation} ${direction} ${duration}ms ${easing} ${delay}ms ${fill}`;
    if (clear) {
        const clearDelay = typeof clear === "number" ? clear : 0;
        clearAnimation.set(el, window.setTimeout(() => (el.style.animation = ""), delay + duration + clearDelay));
    }
    return new Promise(resolve => setTimeout(resolve, delay + duration));
}
function animateCascade(nodes, opts = {}) {
    const els = Array.from(nodes);
    const { fullDuration, duration, initialDelay } = Object.assign({}, defaults, opts);
    const dt = Math.max(30, Math.floor((fullDuration - duration) / els.length));
    const promises = [];
    for (const [i, e] of els.entries()) {
        promises.push(animateElement(e, Object.assign(opts, { delay: initialDelay + i * dt })));
    }
    return Promise.all(promises);
}


/***/ }),

/***/ "../app/src/lib/clipboard.ts":
/*!***********************************!*\
  !*** ../app/src/lib/clipboard.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "setClipboard": () => (/* binding */ setClipboard),
/* harmony export */   "clearClipboard": () => (/* binding */ clearClipboard)
/* harmony export */ });
/* harmony import */ var _elements_clipboard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../elements/clipboard */ "../app/src/elements/clipboard.ts");
/* harmony import */ var _singleton__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./singleton */ "../app/src/lib/singleton.ts");


async function setClipboard(item, field, duration) {
    const singleton = (0,_singleton__WEBPACK_IMPORTED_MODULE_1__.getSingleton)("pl-clipboard");
    return singleton.set(item, field, duration);
}
function clearClipboard() {
    const singleton = (0,_singleton__WEBPACK_IMPORTED_MODULE_1__.getSingleton)("pl-clipboard");
    singleton.clear();
}


/***/ }),

/***/ "../app/src/lib/dialog.ts":
/*!********************************!*\
  !*** ../app/src/lib/dialog.ts ***!
  \********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "getDialog": () => (/* binding */ getDialog),
/* harmony export */   "lineUpDialog": () => (/* binding */ lineUpDialog),
/* harmony export */   "alert": () => (/* binding */ alert),
/* harmony export */   "confirm": () => (/* binding */ confirm),
/* harmony export */   "prompt": () => (/* binding */ prompt),
/* harmony export */   "choose": () => (/* binding */ choose),
/* harmony export */   "generate": () => (/* binding */ generate),
/* harmony export */   "clearDialogs": () => (/* binding */ clearDialogs),
/* harmony export */   "dialog": () => (/* binding */ dialog)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _elements_generator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../elements/generator */ "../app/src/elements/generator.ts");
/* harmony import */ var _elements_alert_dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/alert-dialog */ "../app/src/elements/alert-dialog.ts");
/* harmony import */ var _elements_prompt_dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/prompt-dialog */ "../app/src/elements/prompt-dialog.ts");
/* harmony import */ var _elements_export_dialog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../elements/export-dialog */ "../app/src/elements/export-dialog.ts");
/* harmony import */ var _singleton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./singleton */ "../app/src/lib/singleton.ts");






let lastDialogPromise = Promise.resolve();
let currentDialog;
const getDialog = _singleton__WEBPACK_IMPORTED_MODULE_5__.getSingleton;
function lineUpDialog(d, fn) {
    const dialog = typeof d === "string" ? (0,_singleton__WEBPACK_IMPORTED_MODULE_5__.getSingleton)(d) : d;
    const promise = lastDialogPromise.then(() => {
        currentDialog = dialog;
        return fn(dialog);
    });
    lastDialogPromise = promise;
    return promise;
}
function alert(message, options, instant = false) {
    options = options || {};
    options.message = message;
    return instant
        ? getDialog("pl-alert-dialog").show(options)
        : lineUpDialog("pl-alert-dialog", (dialog) => dialog.show(options));
}
function confirm(message, confirmLabel = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Confirm"), cancelLabel = (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Cancel"), options = {}, instant) {
    options.options = [confirmLabel, cancelLabel];
    options.type = options.type || "question";
    options.horizontal = typeof options.horizontal !== "undefined" ? options.horizontal : true;
    return alert(message, options, instant).then(choice => choice === 0);
}
function prompt(message, opts = {}, instant = false) {
    opts.message = message;
    return instant
        ? getDialog("pl-prompt-dialog").show(opts)
        : lineUpDialog("pl-prompt-dialog", (dialog) => dialog.show(opts));
}
function choose(message, options, opts = {}) {
    opts.options = options;
    return alert(message, {
        ...opts,
        options,
        type: "choice",
        vertical: true
    });
}
function generate() {
    return lineUpDialog("pl-generator", dialog => dialog.show());
}
function clearDialogs() {
    if (currentDialog) {
        currentDialog.open = false;
    }
    lastDialogPromise = Promise.resolve();
}
function dialog(name) {
    return (prototype, propertyName) => {
        Object.defineProperty(prototype, propertyName, {
            get() {
                return getDialog(name);
            },
            enumerable: true,
            configurable: true
        });
    };
}


/***/ }),

/***/ "../app/src/lib/export.ts":
/*!********************************!*\
  !*** ../app/src/lib/export.ts ***!
  \********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "supportedFormats": () => (/* binding */ supportedFormats),
/* harmony export */   "CSV": () => (/* reexport safe */ _import__WEBPACK_IMPORTED_MODULE_2__.CSV),
/* harmony export */   "PBES2": () => (/* reexport safe */ _import__WEBPACK_IMPORTED_MODULE_2__.PBES2),
/* harmony export */   "asCSV": () => (/* binding */ asCSV),
/* harmony export */   "asPBES2Container": () => (/* binding */ asPBES2Container)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_container__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/container */ "../core/src/container.ts");
/* harmony import */ var _padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/encoding */ "../core/src/encoding.ts");
/* harmony import */ var _import__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./import */ "../app/src/lib/import.ts");



const supportedFormats = [_import__WEBPACK_IMPORTED_MODULE_2__.CSV, _import__WEBPACK_IMPORTED_MODULE_2__.PBES2];

function itemsToTable(items) {
    // Array of column names
    let cols = ["name", "tags"];
    // Column indizes associated with field/column names
    let colInds = {};
    // Two dimensional array, starting with column names
    let table = [cols];
    // Fill up columns array with distinct field names
    for (let item of items) {
        for (let field of item.fields) {
            if (!colInds[field.name]) {
                colInds[field.name] = cols.length;
                cols.push(field.name);
            }
        }
    }
    // Creates an array of empty strings with the length of the `cols` array
    function emptyRow() {
        var l = cols.length;
        var row = [];
        while (l--) {
            row.push("");
        }
        return row;
    }
    // Add a row for each item
    items.forEach(function (item) {
        // Create an empty row to be filled with item name, category and field values
        var row = emptyRow();
        // VaultItem name and category are always the first and second column respectively
        row[0] = item.name;
        row[1] = item.tags.join(",");
        // Fill up columns with corrensponding field values if the fields exist on the item. All
        // other columns remain empty
        item.fields.forEach(function (item) {
            row[colInds[item.name]] = item.value;
        });
        // Add row to table
        table.push(row);
    });
    return table;
}
async function asCSV(items) {
    const papa = await (0,_import__WEBPACK_IMPORTED_MODULE_2__.loadPapa)();
    return papa.unparse(itemsToTable(items));
}
async function asPBES2Container(items, password) {
    for (const item of items) {
        item.attachments = [];
    }
    const container = new _padloc_core_src_container__WEBPACK_IMPORTED_MODULE_0__.PBES2Container();
    await container.unlock(password);
    await container.setData((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_1__.stringToBytes)((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_1__.marshal)({ items: items.map((item) => item.toRaw()) })));
    return container.toJSON();
}


/***/ }),

/***/ "../app/src/lib/import.ts":
/*!********************************!*\
  !*** ../app/src/lib/import.ts ***!
  \********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "CSV": () => (/* binding */ CSV),
/* harmony export */   "PADLOCK_LEGACY": () => (/* binding */ PADLOCK_LEGACY),
/* harmony export */   "LASTPASS": () => (/* binding */ LASTPASS),
/* harmony export */   "PBES2": () => (/* binding */ PBES2),
/* harmony export */   "supportedFormats": () => (/* binding */ supportedFormats),
/* harmony export */   "loadPapa": () => (/* binding */ loadPapa),
/* harmony export */   "fromTable": () => (/* binding */ fromTable),
/* harmony export */   "isCSV": () => (/* binding */ isCSV),
/* harmony export */   "asCSV": () => (/* binding */ asCSV),
/* harmony export */   "isPadlockV1": () => (/* binding */ isPadlockV1),
/* harmony export */   "asPadlockLegacy": () => (/* binding */ asPadlockLegacy),
/* harmony export */   "importLegacyContainer": () => (/* binding */ importLegacyContainer),
/* harmony export */   "isPBES2Container": () => (/* binding */ isPBES2Container),
/* harmony export */   "asPBES2Container": () => (/* binding */ asPBES2Container),
/* harmony export */   "asLastPass": () => (/* binding */ asLastPass),
/* harmony export */   "isLastPass": () => (/* binding */ isLastPass),
/* harmony export */   "guessFormat": () => (/* binding */ guessFormat)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/encoding */ "../core/src/encoding.ts");
/* harmony import */ var _padloc_core_src_container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/core/src/container */ "../core/src/container.ts");
/* harmony import */ var _padloc_core_src_legacy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @padloc/core/src/legacy */ "../core/src/legacy.ts");
/* harmony import */ var _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @padloc/core/src/item */ "../core/src/item.ts");
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _padloc_core_src_util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @padloc/core/src/util */ "../core/src/util.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");







const CSV = {
    format: "csv",
    toString() {
        return "CSV";
    }
};
const PADLOCK_LEGACY = {
    format: "padlock-legacy",
    toString() {
        return "Padlock (v2)";
    }
};
const LASTPASS = {
    format: "lastpass",
    toString() {
        return "LastPass";
    }
};
const PBES2 = {
    format: "padloc",
    toString() {
        return "Encrypted Container";
    }
};
const supportedFormats = [CSV, PADLOCK_LEGACY, LASTPASS, PBES2];
function loadPapa() {
    return __webpack_require__.e(/*! import() | papaparse */ "papaparse").then(__webpack_require__.t.bind(__webpack_require__, /*! papaparse */ "../app/node_modules/papaparse/papaparse.min.js", 23));
}
/**
 * Takes a data table (represented by a two-dimensional array) and converts it
 * into an array of items
 * @param  Array    data         Two-dimensional array containing tabular item data; The first 'row'
 *                               should contain field names. All other rows represent items, containing
 *                               the item name, field values and optionally a list of tags.
 * @param  Integer  nameColIndex Index of the column containing the item names. Defaults to 0
 * @param  Integer  tagsColIndex  Index of the column containing the item categories. If left empty
 *                               no categories will be used
 */
async function fromTable(data, nameColIndex, tagsColIndex) {
    // Use first row for column names
    const colNames = data[0];
    if (nameColIndex === undefined) {
        const i = colNames.indexOf("name");
        nameColIndex = i !== -1 ? i : 0;
    }
    if (tagsColIndex === undefined) {
        tagsColIndex = colNames.indexOf("tags");
        if (tagsColIndex === -1) {
            tagsColIndex = colNames.indexOf("category");
        }
    }
    // All subsequent rows should contain values
    let items = data.slice(1).map(function (row) {
        // Construct an array of field object from column names and values
        let fields = [];
        for (let i = 0; i < row.length; i++) {
            // Skip name column, category column (if any) and empty fields
            if (i != nameColIndex && i != tagsColIndex && row[i]) {
                const name = colNames[i];
                const value = row[i];
                fields.push(new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.Field().fromRaw({
                    name,
                    value
                }));
            }
        }
        const name = row[nameColIndex];
        const tags = row[tagsColIndex];
        return (0,_padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.createVaultItem)(name, fields, (tags && tags.split(",")) || []);
    });
    return Promise.all(items);
}
async function isCSV(data) {
    const papa = await loadPapa();
    return papa.parse(data).errors.length === 0;
}
async function asCSV(data, nameColIndex, tagsColIndex) {
    const papa = await loadPapa();
    const parsed = papa.parse(data);
    if (parsed.errors.length) {
        throw new _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_4__.Err(_padloc_core_src_error__WEBPACK_IMPORTED_MODULE_4__.ErrorCode.INVALID_CSV);
    }
    return fromTable(parsed.data, nameColIndex, tagsColIndex);
}
/**
 * Checks if a given string represents a Padlock enrypted backup
 */
function isPadlockV1(data) {
    try {
        return (0,_padloc_core_src_legacy__WEBPACK_IMPORTED_MODULE_2__.validateLegacyContainer)((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.unmarshal)(data));
    }
    catch (e) {
        return false;
    }
}
async function asPadlockLegacy(data, password) {
    const container = (0,_padloc_core_src_legacy__WEBPACK_IMPORTED_MODULE_2__.parseLegacyContainer)((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.unmarshal)(data));
    await container.unlock(password);
    return importLegacyContainer(container);
}
async function importLegacyContainer(container) {
    const records = (0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.unmarshal)((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.bytesToString)(await container.getData()));
    const items = records
        .filter(({ removed }) => !removed)
        .map(async ({ name = "Unnamed", fields = [], tags, category, updated }) => {
        return new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.VaultItem().fromRaw({
            id: await (0,_padloc_core_src_util__WEBPACK_IMPORTED_MODULE_5__.uuid)(),
            name,
            fields,
            tags: tags || [category],
            updated,
            updatedBy: "",
            attachments: []
        });
    });
    return Promise.all(items);
}
function isPBES2Container(data) {
    try {
        new _padloc_core_src_container__WEBPACK_IMPORTED_MODULE_1__.PBES2Container().fromRaw((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.unmarshal)(data));
        return true;
    }
    catch (e) {
        return false;
    }
}
async function asPBES2Container(data, password) {
    const container = new _padloc_core_src_container__WEBPACK_IMPORTED_MODULE_1__.PBES2Container().fromRaw((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.unmarshal)(data));
    await container.unlock(password);
    const raw = (0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.unmarshal)((0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.bytesToString)(await container.getData()));
    const items = raw.items.map((item) => {
        // Due to a bug in < v1.3.4 items were not serialized properly, so we may
        // need this additional step
        if (typeof item === "string") {
            try {
                item = (0,_padloc_core_src_encoding__WEBPACK_IMPORTED_MODULE_0__.unmarshal)(item);
            }
            catch (e) { }
        }
        return new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.VaultItem().fromRaw(item);
    });
    return items;
}
/*
 * Lastpass secure notes are exported by putting non-standard fields into the 'extra' column. Every line
 * represents a field in the following format:
 *
 *     field_name:data
 *
 * We're parsing that information to retrieve the individual fields
 */
function lpParseNotes(str) {
    let lines = str.split("\n");
    let fields = lines
        .filter(line => !!line)
        .map(line => {
        let split = line.indexOf(":");
        return new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.Field({
            name: line.substring(0, split),
            value: line.substring(split + 1),
            type: _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.FieldType.Text
        });
    });
    return fields;
}
/*
 * Parses a single row in a LastPass CSV file. Apart from extracting the default fields, we also parse
 * the 'extra' column for 'special notes' and remove any special fields that are not needed outside of
 * LastPass
 */
async function lpParseRow(row) {
    const nameIndex = 4;
    const categoryIndex = 5;
    const urlIndex = 0;
    const usernameIndex = 1;
    const passwordIndex = 2;
    const notesIndex = 3;
    let fields = [
        new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.Field({ name: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_6__.translate)("Username"), value: row[usernameIndex], type: _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.FieldType.Username }),
        new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.Field({ name: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_6__.translate)("Password"), value: row[passwordIndex], type: _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.FieldType.Password }),
        new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.Field({ name: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_6__.translate)("URL"), value: row[urlIndex], type: _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.FieldType.Url })
    ];
    let notes = row[notesIndex];
    if (row[urlIndex] === "http://sn") {
        // The 'http://sn' url indicates that this line represents a 'secure note', which means
        // we'll have to parse the 'extra' column to retrieve the individual fields
        fields.push(...lpParseNotes(notes));
        // In case of 'secure notes' we don't want the url and NoteType field
        fields = fields.filter(f => f.name != "url" && f.name != "NoteType");
    }
    else {
        // We've got a regular 'site' item, so the 'extra' column simply contains notes
        fields.push(new _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.Field({ name: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_6__.translate)("Notes"), value: notes, type: _padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.FieldType.Note }));
    }
    const dir = row[categoryIndex];
    // Create a basic item using the standard fields
    return (0,_padloc_core_src_item__WEBPACK_IMPORTED_MODULE_3__.createVaultItem)(row[nameIndex], fields, dir ? [dir] : []);
}
async function asLastPass(data) {
    const papa = await loadPapa();
    let items = papa
        .parse(data)
        .data // Remove first row as it only contains field names
        .slice(1)
        // Filter out empty rows
        .filter((row) => row.length > 1)
        .map(lpParseRow);
    return Promise.all(items);
}
/**
 * Checks if a given string represents a LastPass CSV file
 */
function isLastPass(data) {
    return data.split("\n")[0] === "url,username,password,extra,name,grouping,fav";
}
function guessFormat(data) {
    return isPBES2Container(data)
        ? PBES2
        : isPadlockV1(data)
            ? PADLOCK_LEGACY
            : isLastPass(data)
                ? LASTPASS
                : isCSV(data)
                    ? CSV
                    : null;
}


/***/ }),

/***/ "../app/src/lib/route.ts":
/*!*******************************!*\
  !*** ../app/src/lib/route.ts ***!
  \*******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Router": () => (/* binding */ Router)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_event_target__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/event-target */ "../core/src/event-target.ts");

class Router extends _padloc_core_src_event_target__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {
    constructor(basePath = "/") {
        super();
        this.basePath = basePath;
        this.history = [];
        window.addEventListener("popstate", () => {
            this._pathChanged();
        });
        this._pathChanged();
    }
    _pathChanged() {
        const index = (history.state && history.state.historyIndex) || 0;
        const path = this.path;
        const direction = this.history.length - 1 < index ? "forward" : "backward";
        if (this.history.length === index) {
            this.history.push(path);
        }
        else
            while (this.history.length - 1 > index) {
                this.history.pop();
            }
        this.dispatch("route-changed", { path, direction });
    }
    get path() {
        return window.location.pathname.replace(new RegExp("^" + this.basePath), "");
    }
    get params() {
        const params = {};
        for (const [key, value] of new URLSearchParams(window.location.search)) {
            params[key] = value;
        }
        return params;
    }
    set params(params) {
        history.replaceState({ historyIndex: this.history.length - 1 }, "", this.basePath + this.path + "?" + new URLSearchParams(params).toString());
        this.dispatch("params-changed", { params });
    }
    get canGoBack() {
        return this.history.length > 1;
    }
    go(path, params, replace = false) {
        params = params || this.params;
        // Clean out properties with value undefined
        for (const [key, value] of Object.entries(params)) {
            if (typeof value === "undefined") {
                delete params[key];
            }
        }
        const queryString = new URLSearchParams(params).toString();
        if (path !== this.path || queryString !== window.location.search) {
            let url = this.basePath + path;
            if (queryString) {
                url += "?" + queryString;
            }
            if (replace) {
                history.replaceState({ historyIndex: this.history.length - 1 }, "", url);
            }
            else {
                history.pushState({ historyIndex: this.history.length }, "", url);
            }
            this._pathChanged();
        }
    }
    forward() {
        history.forward();
    }
    back(alternate = "") {
        if (this.canGoBack) {
            history.back();
        }
        else {
            this.go(alternate);
        }
    }
}


/***/ }),

/***/ "../app/src/lib/singleton.ts":
/*!***********************************!*\
  !*** ../app/src/lib/singleton.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "getSingleton": () => (/* binding */ getSingleton)
/* harmony export */ });
const singletons = {};
let container;
function getSingleton(elName) {
    if (!container) {
        container = document.querySelector("[singleton-container]");
    }
    let el = singletons[elName];
    if (!el) {
        singletons[elName] = el = document.createElement(elName);
        container.appendChild(el);
    }
    return el;
}


/***/ }),

/***/ "../app/src/lib/util.ts":
/*!******************************!*\
  !*** ../app/src/lib/util.ts ***!
  \******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "loadScript": () => (/* binding */ loadScript),
/* harmony export */   "formatDateFromNow": () => (/* binding */ formatDateFromNow),
/* harmony export */   "passwordStrength": () => (/* binding */ passwordStrength),
/* harmony export */   "toggleAttribute": () => (/* binding */ toggleAttribute),
/* harmony export */   "mediaType": () => (/* binding */ mediaType),
/* harmony export */   "fileIcon": () => (/* binding */ fileIcon),
/* harmony export */   "fileSize": () => (/* binding */ fileSize),
/* harmony export */   "mask": () => (/* binding */ mask),
/* harmony export */   "isTouch": () => (/* binding */ isTouch)
/* harmony export */ });
const loaded = new Map();
function loadScript(src, global) {
    if (loaded.has(src)) {
        return loaded.get(src);
    }
    const s = document.createElement("script");
    s.src = src;
    s.type = "text/javascript";
    const p = new Promise((resolve, reject) => {
        s.onload = () => resolve(global ? window[global] : undefined);
        s.onerror = (e) => reject(e);
        document.head.appendChild(s);
    });
    loaded.set(src, p);
    return p;
}
async function formatDateFromNow(date, addSuffix = true) {
    const { distanceInWordsToNow } = await __webpack_require__.e(/*! import() | date-fns */ "date-fns").then(__webpack_require__.t.bind(__webpack_require__, /*! date-fns */ "../app/node_modules/date-fns/index.js", 23));
    return distanceInWordsToNow(date, { addSuffix });
}
async function passwordStrength(pwd) {
    // @ts-ignore
    const { default: zxcvbn } = await __webpack_require__.e(/*! import() | zxcvbn */ "zxcvbn").then(__webpack_require__.t.bind(__webpack_require__, /*! zxcvbn */ "../app/node_modules/zxcvbn/lib/main.js", 23));
    return zxcvbn(pwd);
}
function toggleAttribute(el, attr, on) {
    if (on) {
        el.setAttribute(attr, "");
    }
    else {
        el.removeAttribute(attr);
    }
}
function mediaType(mimeType) {
    const match = mimeType.match(/(.*)\/(.*)/);
    const [, type, subtype] = match || ["", "", ""];
    switch (type) {
        case "video":
            return "video";
        case "audio":
            return "audio";
        case "image":
            return "image";
        case "text":
            switch (subtype) {
                case "csv":
                // return "csv";
                case "plain":
                    return "text";
                default:
                    return "code";
            }
        case "application":
            switch (subtype) {
                case "pdf":
                    return "pdf";
                case "json":
                    return "code";
                case "pkcs8":
                case "pkcs10":
                case "pkix-cert":
                case "pkix-crl":
                case "pkcs7-mime":
                case "x-x509-ca-cert":
                case "x-x509-user-cert":
                case "x-pkcs12":
                case "x-pkcs7-certificates":
                case "x-pkcs7-mime":
                case "x-pkcs7-crl":
                case "x-pem-file":
                case "x-pkcs12":
                case "x-pkcs7-certreqresp":
                    return "certificate";
                case "zip":
                case "x-7z-compressed":
                case "x-freearc":
                case "x-bzip":
                case "x-bzip2":
                case "java-archive":
                case "x-rar-compressed":
                case "x-tar":
                    return "archive";
            }
        default:
            return "";
    }
}
function fileIcon(mimeType) {
    const mType = mediaType(mimeType);
    return mType ? `file-${mType}` : "file";
}
function fileSize(size = 0) {
    return size < 1e6 ? Math.ceil(size / 10) / 100 + " KB" : Math.ceil(size / 10000) / 100 + " MB";
}
function mask(value) {
    return value && value.replace(/[^\n]/g, "\u2022");
}
function isTouch() {
    return window.matchMedia("(hover: none)").matches;
}


/***/ }),

/***/ "../app/src/mixins/auto-lock.ts":
/*!**************************************!*\
  !*** ../app/src/mixins/auto-lock.ts ***!
  \**************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AutoLock": () => (/* binding */ AutoLock)
/* harmony export */ });
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");

function AutoLock(baseClass) {
    return class extends baseClass {
        constructor(...args) {
            super(...args);
            this._pausedAt = null;
            document.addEventListener("click", () => this._startTimer());
            document.addEventListener("keydown", () => this._startTimer());
            document.addEventListener("pause", () => this._pause());
            document.addEventListener("resume", () => this._resume());
        }
        get _lockDelay() {
            return _globals__WEBPACK_IMPORTED_MODULE_0__.app.settings.autoLockDelay * 60 * 1000;
        }
        _cancelAutoLock() {
            this._pausedAt = null;
            if (this._lockTimeout) {
                clearTimeout(this._lockTimeout);
            }
            // if (this._lockNotificationTimeout) {
            //     clearTimeout(this._lockNotificationTimeout);
            // }
        }
        // Handler for cordova `pause` event. Records the current time for auto locking when resuming
        _pause() {
            this._pausedAt = new Date();
        }
        // Handler for cordova `resume` event. If auto lock is enabled and the specified time has passed
        // since the app was paused, locks the app
        _resume() {
            if (_globals__WEBPACK_IMPORTED_MODULE_0__.app.settings.autoLock &&
                !_globals__WEBPACK_IMPORTED_MODULE_0__.app.state.locked &&
                this._pausedAt &&
                new Date().getTime() - this._pausedAt.getTime() > this._lockDelay) {
                this._doLock();
            }
            this._startTimer();
        }
        _doLock() {
            // if app is currently syncing restart the timer
            if (_globals__WEBPACK_IMPORTED_MODULE_0__.app.state.syncing) {
                this._startTimer();
                return;
            }
            _globals__WEBPACK_IMPORTED_MODULE_0__.app.lock();
        }
        _startTimer() {
            this._cancelAutoLock();
            if (_globals__WEBPACK_IMPORTED_MODULE_0__.app.settings.autoLock && !_globals__WEBPACK_IMPORTED_MODULE_0__.app.state.locked) {
                this._lockTimeout = window.setTimeout(() => this._doLock(), this._lockDelay);
                // this._lockNotificationTimeout = setTimeout(() => {
                //     if (!this.locked && !this._pausedAt) {
                //         this.notify($l("Auto-lock in 10 seconds"), "info", 3000);
                //     }
                // }, this._lockDelay - 10000);
            }
        }
    };
}


/***/ }),

/***/ "../app/src/mixins/auto-sync.ts":
/*!**************************************!*\
  !*** ../app/src/mixins/auto-sync.ts ***!
  \**************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AutoSync": () => (/* binding */ AutoSync)
/* harmony export */ });
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");

function AutoSync(baseClass) {
    return class extends baseClass {
        constructor(...args) {
            super(...args);
            _globals__WEBPACK_IMPORTED_MODULE_0__.app.loaded.then(() => this.startPeriodicSync());
        }
        startPeriodicSync() {
            setTimeout(async () => {
                if (_globals__WEBPACK_IMPORTED_MODULE_0__.app.state.loggedIn && !_globals__WEBPACK_IMPORTED_MODULE_0__.app.state.locked) {
                    try {
                        await _globals__WEBPACK_IMPORTED_MODULE_0__.app.synchronize();
                    }
                    catch (e) {
                        await this.handleError(e);
                    }
                }
                this.startPeriodicSync();
            }, _globals__WEBPACK_IMPORTED_MODULE_0__.app.settings.syncInterval * 60 * 1000);
        }
    };
}


/***/ }),

/***/ "../app/src/mixins/error-handling.ts":
/*!*******************************************!*\
  !*** ../app/src/mixins/error-handling.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ErrorHandling": () => (/* binding */ ErrorHandling)
/* harmony export */ });
/* harmony import */ var _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/core/src/error */ "../core/src/error.ts");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");




function ErrorHandling(baseClass) {
    return class extends baseClass {
        constructor(...args) {
            super(...args);
            window.addEventListener("error", (e) => this.handleError(e.error));
            window.addEventListener("unhandledrejection", (e) => this.handleError(e.reason));
        }
        async handleError(error) {
            error =
                error instanceof _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.Err
                    ? error
                    : error instanceof Error
                        ? new _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.Err(_padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.UNKNOWN_ERROR, error.message, { error })
                        : new _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.Err(_padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.UNKNOWN_ERROR, error.toString());
            switch (error.code) {
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.FAILED_CONNECTION:
                    // A failed connection is interpreted as the user simply being offline,
                    // which is indicated in another place in the UI
                    return true;
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.INVALID_SESSION:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.SESSION_EXPIRED:
                    await _globals__WEBPACK_IMPORTED_MODULE_2__.app.logout();
                    await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Your session has expired. Please log in again!"), { preventAutoClose: true });
                    _globals__WEBPACK_IMPORTED_MODULE_2__.router.go("login");
                    return true;
                // These are expected to occur during a user lifecycle and can be ingored.
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.ACCOUNT_EXISTS:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.MFA_REQUIRED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.MFA_FAILED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.MFA_TRIES_EXCEEDED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.ORG_FROZEN:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.ORG_QUOTA_EXCEEDED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.MEMBER_QUOTA_EXCEEDED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.GROUP_QUOTA_EXCEEDED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.VAULT_QUOTA_EXCEEDED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.STORAGE_QUOTA_EXCEEDED:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.BILLING_ERROR:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.OUTDATED_REVISION:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.MISSING_ACCESS:
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.INVALID_CREDENTIALS:
                    return true;
                case _padloc_core_src_error__WEBPACK_IMPORTED_MODULE_0__.ErrorCode.UNSUPPORTED_VERSION:
                    await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_3__.alert)(error.message ||
                        (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Some data associated with your account was saved with a newer version of " +
                            "Padloc and cannot be decoded. Please install the latest version Padloc!"), { title: (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Update Required"), type: "warning" });
                default:
                    _globals__WEBPACK_IMPORTED_MODULE_2__.app.state._errors.push(error);
                    _globals__WEBPACK_IMPORTED_MODULE_2__.app.publish();
            }
            return false;
        }
    };
}


/***/ }),

/***/ "../app/src/mixins/service-worker.ts":
/*!*******************************************!*\
  !*** ../app/src/mixins/service-worker.ts ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "ServiceWorker": () => (/* binding */ ServiceWorker)
/* harmony export */ });
/* harmony import */ var workbox_window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! workbox-window */ "../app/node_modules/workbox-window/build/workbox-window.prod.es5.mjs");
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _lib_dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/dialog */ "../app/src/lib/dialog.ts");



function ServiceWorker(baseClass) {
    return class extends baseClass {
        constructor(...args) {
            super(...args);
            if (true) {
                this.initSW();
            }
        }
        async _updateReady() {
            const confirmed = await (0,_lib_dialog__WEBPACK_IMPORTED_MODULE_2__.confirm)((0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("A new update is ready to install! Do you want to install it now?"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Install & Reload"), (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_1__.translate)("Later"), { preventAutoClose: true });
            if (confirmed) {
                // set up a listener that will reload the page as soon as the
                // previously waiting service worker has taken control.
                this._wb.addEventListener("controlling", () => {
                    window.location.reload();
                });
                // Send a message telling the service worker to skip waiting.
                // This will trigger the `controlling` event handler above.
                this._wb.messageSW({ type: "INSTALL_UPDATE" });
            }
        }
        initSW() {
            if (!("serviceWorker" in navigator)) {
                return;
            }
            this._wb = new workbox_window__WEBPACK_IMPORTED_MODULE_0__.Workbox("/sw.js");
            // Add an event listener to detect when the registered
            // service worker has installed but is waiting to activate.
            this._wb.addEventListener("waiting", () => {
                setTimeout(() => {
                    this._updateReady();
                }, 1000);
            });
            this._wb.register();
        }
        checkForUpdates() {
            this._wb.register();
        }
    };
}


/***/ }),

/***/ "../app/src/mixins/state.ts":
/*!**********************************!*\
  !*** ../app/src/mixins/state.ts ***!
  \**********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "StateMixin": () => (/* binding */ StateMixin)
/* harmony export */ });
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../globals */ "../app/src/globals.ts");

const StateMixin = (baseElement) => class extends baseElement {
    constructor() {
        super(...arguments);
        this._stateHandler = this.stateChanged.bind(this);
    }
    get app() {
        return _globals__WEBPACK_IMPORTED_MODULE_0__.app;
    }
    get state() {
        return _globals__WEBPACK_IMPORTED_MODULE_0__.app.state;
    }
    connectedCallback() {
        super.connectedCallback();
        _globals__WEBPACK_IMPORTED_MODULE_0__.app.subscribe(this._stateHandler);
        this.stateChanged();
    }
    disconnectedCallback() {
        _globals__WEBPACK_IMPORTED_MODULE_0__.app.unsubscribe(this._stateHandler);
        super.disconnectedCallback();
    }
    /**
     * The `stateChanged()` method will be called when the state is updated.
     */
    stateChanged() {
        this.requestUpdate();
    }
};


/***/ }),

/***/ "../app/src/styles/config.ts":
/*!***********************************!*\
  !*** ../app/src/styles/config.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "narrowWidth": () => (/* binding */ narrowWidth),
/* harmony export */   "wideWidth": () => (/* binding */ wideWidth),
/* harmony export */   "cssVars": () => (/* binding */ cssVars)
/* harmony export */ });
/* harmony import */ var lit_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-element */ "../app/node_modules/lit-element/lit-element.js");

const narrowWidth = 700;
const wideWidth = 1200;
const cssVars = lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    :host {
        --font-family: "Nunito";
        --font-family-fallback: sans-serif;
        --font-family-mono: "Inconsolata";

        --font-size-micro: 12px;
        --font-size-tiny: 14px;
        --font-size-small: 16px;
        --font-size-default: 18px;
        --font-weight-thin: 100;
        --font-weight-light: 300;
        --font-weight-regular: 400;
        --font-weight-bold: 700;

        --color-primary: #3bb7f9;
        --color-secondary: #444;
        --color-tertiary: #ffffff;
        --color-quaternary: #fafafa;
        /* --color-negative: #D7322D; */
        --color-negative: #ff6666;

        --color-background: var(--color-tertiary);
        --color-foreground: var(--color-secondary);
        --color-highlight: var(--color-primary);
        --color-error: var(--color-negative);

        --color-shade-1: rgba(0, 0, 0, 0.05);
        --color-shade-2: rgba(0, 0, 0, 0.1);
        --color-shade-3: rgba(0, 0, 0, 0.15);
        --color-shade-4: rgba(0, 0, 0, 0.2);

        --color-gradient-highlight-from: rgb(7, 124, 185);
        --color-gradient-highlight-to: rgb(89, 198, 255);
        --color-gradient-warning-from: #f25b00;
        --color-gradient-warning-to: #f49300;
        --color-gradient-dark-from: #222;
        --color-gradient-dark-to: #555;

        --color-scrim: rgba(255, 255, 255, 0.9);

        --color-btn-front: var(--color-foreground);
        --color-btn-back: var(--shade-3-color);

        --row-height: 50px;

        --gutter-size: 8px;
        --border-radius: 8px;
        --border-color: rgba(0, 0, 0, 0.1);

        --toaster-easing: cubic-bezier(1, -0.3, 0, 1.3);

        --shade-1-color: transparent;
        --shade-2-color: var(--color-shade-1);
        --shade-3-color: var(--color-shade-2);
        --shade-4-color: var(--color-shade-3);
        --shade-5-color: var(--color-shade-4);

        --narrow-width: 700px;
        --wide-width: 1200px;
    }
`;


/***/ }),

/***/ "../app/src/styles/index.ts":
/*!**********************************!*\
  !*** ../app/src/styles/index.ts ***!
  \**********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "mixins": () => (/* reexport module object */ _mixins__WEBPACK_IMPORTED_MODULE_0__),
/* harmony export */   "config": () => (/* reexport module object */ _config__WEBPACK_IMPORTED_MODULE_1__),
/* harmony export */   "shared": () => (/* reexport safe */ _shared__WEBPACK_IMPORTED_MODULE_2__.shared)
/* harmony export */ });
/* harmony import */ var _mixins__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mixins */ "../app/src/styles/mixins.ts");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./config */ "../app/src/styles/config.ts");
/* harmony import */ var _shared__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shared */ "../app/src/styles/shared.ts");






/***/ }),

/***/ "../app/src/styles/mixins.ts":
/*!***********************************!*\
  !*** ../app/src/styles/mixins.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "unselectable": () => (/* binding */ unselectable),
/* harmony export */   "positionSticky": () => (/* binding */ positionSticky),
/* harmony export */   "fullbleed": () => (/* binding */ fullbleed),
/* harmony export */   "scroll": () => (/* binding */ scroll),
/* harmony export */   "ellipsis": () => (/* binding */ ellipsis),
/* harmony export */   "absoluteCenter": () => (/* binding */ absoluteCenter),
/* harmony export */   "shade1": () => (/* binding */ shade1),
/* harmony export */   "shade2": () => (/* binding */ shade2),
/* harmony export */   "shade3": () => (/* binding */ shade3),
/* harmony export */   "shade4": () => (/* binding */ shade4),
/* harmony export */   "shade5": () => (/* binding */ shade5),
/* harmony export */   "card": () => (/* binding */ card),
/* harmony export */   "gradientHighlight": () => (/* binding */ gradientHighlight),
/* harmony export */   "gradientWarning": () => (/* binding */ gradientWarning),
/* harmony export */   "gradientDark": () => (/* binding */ gradientDark),
/* harmony export */   "textShadow": () => (/* binding */ textShadow)
/* harmony export */ });
/* harmony import */ var lit_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-element */ "../app/node_modules/lit-element/lit-element.js");

const unselectable = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    cursor: default;
    user-select: none;
`;
const positionSticky = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    position: -webkit-sticky;
    position: -moz-sticky;
    position: -o-sticky;
    position: -ms-sticky;
    position: sticky;
`;
const fullbleed = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
`;
const scroll = (direction) => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    ${direction === "vertical" ? lit_element__WEBPACK_IMPORTED_MODULE_0__.css `overflow-y` : direction === "horizontal" ? lit_element__WEBPACK_IMPORTED_MODULE_0__.css `overflow-x` : lit_element__WEBPACK_IMPORTED_MODULE_0__.css `overflow`}: auto;
    -webkit-overflow-scrolling: touch;
`;
const ellipsis = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
`;
const absoluteCenter = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    ${fullbleed()};
    margin: auto;
`;
const shade1 = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: var(--shade-1-color);
`;
const shade2 = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: var(--shade-2-color);
`;
const shade3 = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: var(--shade-3-color);
`;
const shade4 = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: var(--shade-4-color);
`;
const shade5 = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: var(--shade-5-color);
`;
const card = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: var(--color-background);
    /* box-shadow: rgba(0, 0, 0, 0.2) 0 0 1px; */
    border-radius: var(--border-radius);
    border: solid 1px rgba(0, 0, 0, 0.1);
    border-bottom-width: 2px;
    overflow: hidden;
`;
const gradientHighlight = (horizontal = false) => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: linear-gradient(
        ${horizontal ? lit_element__WEBPACK_IMPORTED_MODULE_0__.css `90deg` : lit_element__WEBPACK_IMPORTED_MODULE_0__.css `0`},
        var(--color-gradient-highlight-from) 0%,
        var(--color-gradient-highlight-to) 100%
    );
`;
const gradientWarning = (horizontal = false) => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: linear-gradient(
        ${horizontal ? lit_element__WEBPACK_IMPORTED_MODULE_0__.css `90deg` : lit_element__WEBPACK_IMPORTED_MODULE_0__.css `0`},
        var(--color-gradient-warning-from) 0%,
        var(--color-gradient-warning-to) 100%
    );
`;
const gradientDark = (horizontal = false) => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    background: linear-gradient(
        ${horizontal ? lit_element__WEBPACK_IMPORTED_MODULE_0__.css `90deg` : lit_element__WEBPACK_IMPORTED_MODULE_0__.css `0`},
        var(--color-gradient-dark-from) 0%,
        var(--color-gradient-dark-to) 100%
    );
`;
const textShadow = () => lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    text-shadow: rgba(0, 0, 0, 0.2) 0px 2px 0px;
`;


/***/ }),

/***/ "../app/src/styles/shared.ts":
/*!***********************************!*\
  !*** ../app/src/styles/shared.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "shared": () => (/* binding */ shared)
/* harmony export */ });
/* harmony import */ var lit_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lit-element */ "../app/node_modules/lit-element/lit-element.js");
/* harmony import */ var _mixins__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mixins */ "../app/src/styles/mixins.ts");


const shared = lit_element__WEBPACK_IMPORTED_MODULE_0__.css `
    :host {
        user-select: none;
        -webkit-user-select: none;
    }

    input,
    textarea {
        user-select: auto;
        -webkit-user-select: auto;
    }

    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }

    :host,
    html,
    button,
    input,
    textarea {
        font-family: var(--font-family), var(--font-family-fallback);
        font-weight: var(--font-weight-regular);
        font-size: var(--font-size-default);
        -webkit-font-smoothing: antialiased;
        -webkit-tap-highlight-color: transparent;
    }

    ::selection {
        background: var(--color-secondary);
        color: var(--color-tertiary);
    }

    a {
        text-decoration: underline;
        color: inherit;
    }

    button,
    a.button {
        display: inline-block;
        color: inherit;
        font-family: inherit;
        font-size: inherit;
        font-weight: inherit;
        border: none;
        margin: 0;
        padding: 12px 15px;
        cursor: pointer;
        text-align: center;
        text-shadow: inherit;
    }

    button.icon {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    button.icon pl-icon {
        width: 30px;
        height: 20px;
        margin-left: -8px;
        font-size: 90%;
    }

    button.arrow,
    a.button.arrow {
        padding-right: 30px;
    }

    button.arrow::before,
    a.button.arrow::before {
        font-family: "FontAwesome";
        content: "\\f054";
        display: block;
        position: absolute;
        top: 0;
        right: 15px;
        bottom: 0;
    }

    button,
    pl-loading-button,
    pl-toggle-button,
    a.button {
        background: var(--color-btn-back);
        border-radius: var(--border-radius);
    }

    button.primary,
    pl-loading-button.primary,
    a.button.primary {
        background: var(--color-highlight);
        color: var(--color-tertiary);
        font-weight: bold;
    }

    button.negative,
    pl-loading-button.negative,
    a.button.negative {
        background: var(--color-negative);
        color: var(--color-tertiary);
        font-weight: bold;
    }

    button.transparent {
        background: none;
    }

    button.light {
        color: var(--color-tertiary);
    }

    input,
    select {
        border: none;
        -webkit-appearance: none;
        -mox-appearance: none;
        appearance: none;
        font-family: inherit;
        font-size: inherit;
        font-weight: inherit;
        text-shadow: inherit;
        color: inherit;
        border-radius: 0;
        background: transparent;
        margin: 0;
        padding: 0;
    }

    textarea {
        font-weight: inherit;
        font-family: inherit;
        font-size: inherit;
        color: inherit;
        border: none;
        background: transparent;
        margin: 0;
        display: block;
        padding: 0;
        border-radius: 0;
        appearance: none;
        resize: none;
    }

    textarea[nowrap] {
        white-space: pre;
        word-wrap: normal;
        overflow-x: scroll;
    }

    strong {
        font-weight: var(--font-weight-bold);
    }

    h1,
    h2 {
        font-weight: normal;
    }

    h1 {
        font-size: 150%;
        margin: 20px;
    }

    h2 {
        font-size: 120%;
        margin: 10px 20px 5px 20px;
    }

    ::-webkit-search-cancel-button {
        display: none;
    }

    *:focus {
        outline: none;
    }

    ::-webkit-input-placeholder {
        text-shadow: inherit;
        color: inherit;
        opacity: 0.6;
    }

    ::-webkit-scrollbar {
        display: none;
    }

    [hidden] {
        display: none !important;
    }

    [invisible] {
        opacity: 0;
    }

    [disabled] {
        opacity: 0.5;
        pointer-events: none !important;
    }

    section {
        margin: 10px 5px;
    }

    section > button {
        width: 100%;
    }

    header {
        display: flex;
        font-size: 120%;
        padding: 10px;
        background: var(--color-tertiary);
        border-bottom: solid 3px var(--color-shade-1);
        align-items: center;
        font-weight: bold;
        min-height: 40px;
    }

    header pl-input {
        height: auto;
        background: transparent;
        padding: 0 5px;
    }

    header .title {
        padding: 0 5px;
        text-align: center;
    }

    main {
        flex: 1;
        box-sizing: border-box;
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.scroll()}
        overflow-x: hidden;
        position: relative;
    }

    ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .item {
        border-radius: var(--border-radius);
        background: var(--color-tertiary);
        border: solid 1px var(--color-shade-1);
        border-bottom-width: 3px;
        margin: var(--gutter-size);
        /*box-shadow: 0px 5px 5px -5px var(--color-shade-2), 0 0 2px var(--color-shade-1);*/
    }

    .item.error {
        background: var(--color-negative);
        color: var(--color-tertiary);
        padding: 8px;
        text-align: center;
    }

    .item.padded {
        padding: 8px;
    }

    code {
        font-family: var(--font-family-mono);
    }

    pre {
        font: inherit;
        margin: 0;
    }

    pl-dialog .message {
        padding: 15px;
        text-align: center;
    }

    pl-dialog button,
    pl-dialog pl-loading-button {
        width: 100%;
        box-sizing: border-box;
        font-weight: bold;
    }

    .layout {
        display: flex;
    }

    .layout.vertical {
        flex-direction: column;
    }

    .layout.align-center {
        align-items: center;
    }

    .layout.justify-center {
        justify-content: center;
    }

    .spacer,
    .flex,
    [flex] {
        flex: 1;
    }

    .tap {
        position: relative;
        cursor: pointer;
    }

    .tap::after {
        content: "";
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: currentColor;
        opacity: 0;
        transition: opacity 1s;
        pointer-events: none;
        border-radius: inherit;
    }

    .tap:active::after {
        opacity: 0.3;
        transition: none;
    }

    .tap::before {
        content: "";
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: currentColor;
        opacity: 0;
        pointer-events: none;
        border-radius: inherit;
    }

    .tap:not(:active):hover::before {
        opacity: 0.1;
    }

    .tiles > :nth-child(8n + 1),
    .tiles-1 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade1()}
    }

    .tiles > :nth-child(8n + 2),
    .tiles-2 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade2()}
    }

    .tiles > :nth-child(8n + 3),
    .tiles-3 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade3()}
    }

    .tiles > :nth-child(8n + 4),
    .tiles-4 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade4()}
    }

    .tiles > :nth-child(8n + 5),
    .tiles-5 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade5()}
    }

    .tiles > :nth-child(8n + 6),
    .tiles-6 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade4()}
    }

    .tiles > :nth-child(8n + 7),
    .tiles-7 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade3()}
    }

    .tiles > :nth-child(8n + 8),
    .tiles-8 {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.shade2()}
    }

    .ellipsis {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.ellipsis()}
    }

    pl-icon[spin] {
        animation: spin 1s infinite;
        transform-origin: center 49%;
    }

    .info {
        display: flex;
        align-items: center;
    }

    .info-icon {
        width: 80px;
        height: 80px;
        font-size: 46px;
        margin: 10px 0 10px 10px;
    }

    .info-body {
        padding: 20px 15px 20px 10px;
        flex: 1;
        width: 0;
    }

    .info-title {
        font-size: 120%;
        font-weight: bold;
        margin-bottom: 5px;
    }

    .info-text {
        font-size: var(--font-size-small);
    }

    .tags {
        display: flex;
        overflow-x: auto;
        margin: 8px 0;
        align-items: center;
        -webkit-overflow-scrolling: touch;
    }

    .tags::after {
        content: "";
        display: block;
        width: 1px;
        flex: none;
    }

    .tag {
        color: var(--color-tertiary);
        /*text-shadow: rgba(0, 0, 0, 0.2) 0 1px 0;*/
        font-weight: bold;
        border-radius: var(--border-radius);
        font-size: var(--font-size-tiny);
        padding: 5px 8px;
        line-height: normal;
        text-align: center;
        background: var(--color-secondary);
    }

    .tag:not(:last-child) {
        margin-right: 6px;
    }

    .tag > * {
        display: inline-block;
        vertical-align: top;
    }

    .tag pl-icon {
        width: 20px;
        height: 20px;
    }

    .tag pl-icon:first-child {
        margin-left: -2px;
    }

    .tag pl-icon:last-child {
        margin-right: -2px;
    }

    .tag.ghost {
        border: dashed 1px;
        background: transparent;
        color: var(--color-foreground);
    }

    .tag.highlight {
        background: var(--color-highlight);
    }

    .tag.warning {
        background: var(--color-negative);
    }

    .tags.tiny .tag {
        font-size: 12px;
        padding: 4px 6px;
        line-height: 14px;
        border-radius: 6px;
    }

    .tags.tiny pl-icon {
        font-size: 10px;
        width: 14px;
        height: 14px;
    }

    .tags.small .tag {
        font-size: var(--font-size-micro);
        padding: 4px 6px;
        line-height: 16px;
    }

    .tags.small pl-icon {
        font-size: 10px;
        width: 16px;
        height: 16px;
    }

    .record-tag.store-tag {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.gradientDark(true)}
        text-shadow: rgba(0, 0, 0, 0.1) 0 1px 0;
    }

    .fabs {
        position: absolute;
        z-index: 2;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: none;
        display: flex;
        align-items: center;
    }

    .fab {
        pointer-events: auto;
        border-radius: 45px;
        margin: 12px;
        box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
        color: var(--color-tertiary);
        width: 45px;
        height: 45px;
        text-shadow: rgba(0, 0, 0, 0.2) 0 2px 0px;
        background: var(--color-secondary);
    }

    button.fab {
        width: auto;
        padding: 4px 20px;
        font-weight: bold;
    }

    .fab.primary {
        background: var(--color-primary);
    }

    .fab.light {
        background: var(--color-tertiary);
        color: var(--color-secondary);
        text-shadow: none;
    }

    .fab:not(:last-child) {
        margin-right: 0;
    }

    .fab.destructive {
        background: var(--color-negative);
    }

    .centering {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .empty-placeholder {
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.fullbleed()}
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 20px;
    }

    .empty-placeholder pl-icon {
        width: 100px;
        height: 100px;
        font-size: 50px;
    }

    .empty-placeholder > div {
        width: 300px;
        margin-bottom: 20px;
    }

    .input-wrapper {
        display: flex;
        align-items: center;
        padding: 0 10px;
    }

    .input-wrapper pl-input {
        padding: 0;
        background: transparent;
    }

    .tabs {
        display: flex;
        margin: 0 auto;
        width: auto;
        ${_mixins__WEBPACK_IMPORTED_MODULE_1__.scroll("horizontal")}
        font-size: var(--font-size-default);
        font-weight: bold;
    }

    .tabs > * {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 15px;
        border-bottom: solid 3px var(--color-shade-1);
    }

    .tabs > * > pl-icon {
        margin-left: -10px;
        font-size: 90%;
        width: 35px;
        height: 35px;
    }

    .tabs > *[active] {
        color: var(--color-highlight);
        border-color: var(--color-highlight);
    }

    .search-wrapper {
        display: flex;
        align-items: center;
        position: sticky;
        top: var(--gutter-size);
        z-index: 5;
    }

    .search-wrapper pl-icon {
        opacity: 0.5;
        margin-left: 5px;
    }

    .search-wrapper pl-input {
        font-size: var(--font-size-small);
        height: auto;
        flex: 1;
        background: transparent;
        padding-left: 5px;
    }

    .note {
        padding: 0;
        font-size: var(--font-size-small);
        font-weight: bold;
        padding: 8px;
        box-shadow: rgba(0, 0, 0, 0.3) 0 0 3px 0;
        text-shadow: rgba(0, 0, 0, 0.2) 0 2px 0;
        background: var(--color-primary);
    }

    .note.error {
        background: var(--color-negative);
    }

    @keyframes spin {
        to {
            transform: rotate(360deg);
        }
    }

    @keyframes slideIn {
        from {
            transform: translate(0, 50px);
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }

    @keyframes rumble {
        25% {
            transform: translate(5px, 0);
        }
        50% {
            transform: translate(-5px, -3px);
        }
        75% {
            transform: translate(5px, 2px);
        }
    }

    @keyframes bounce {
        from,
        20%,
        40%,
        to {
            animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        }

        0% {
            transform: scale3d(0.5, 0.5, 0.5);
        }

        33% {
            transform: scale3d(1.05, 1.05, 1.05);
        }

        66% {
            transform: scale3d(0.98, 0.98, 0.98);
        }

        to {
            transform: scale3d(1, 1, 1);
        }
    }

    @media (min-width: 701px) {
        .menu-button {
            visibility: hidden;
        }

        .narrow {
            display: none !important;
        }
    }

    @media (max-width: 700px) {
        .wide {
            display: none;
        }
    }
`;


/***/ }),

/***/ "../core/src/account.ts":
/*!******************************!*\
  !*** ../core/src/account.ts ***!
  \******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AccountSecrets": () => (/* binding */ AccountSecrets),
/* harmony export */   "Account": () => (/* binding */ Account)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");
/* harmony import */ var _session__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./session */ "../core/src/session.ts");
/* harmony import */ var _quota__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./quota */ "../core/src/quota.ts");
/* harmony import */ var _billing__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./billing */ "../core/src/billing.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};








class AccountSecrets extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor({ signingKey, privateKey, favorites } = {}) {
        super();
        this.favorites = new Set();
        Object.assign(this, { signingKey, privateKey, favorites });
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], AccountSecrets.prototype, "signingKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], AccountSecrets.prototype, "privateKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSet)(),
    __metadata("design:type", Object)
], AccountSecrets.prototype, "favorites", void 0);
/**
 * The `Account` object represents an individual Padloc user and holds general
 * account information as well as cryptographic keys necessary for accessing
 * [[Vaults]] and signing/verifying [[Org]]anization details.
 *
 * The [[privateKey]] and [[signingKey]] properties are considered secret and
 * therefore need to be encrypted at rest. For this, the [[Account]] object
 * serves as a [[PBESContainer]] which is unlocked by the users **master
 * password**.
 */
class Account extends _container__WEBPACK_IMPORTED_MODULE_4__.PBES2Container {
    constructor() {
        super(...arguments);
        /** Unique account ID */
        this.id = "";
        /** The users email address */
        this.email = "";
        /** The users display name */
        this.name = "";
        /** When the account was created */
        this.created = new Date();
        /** when the account was last updated */
        this.updated = new Date();
        /** List of currently active sessions */
        this.sessions = [];
        /** ID of the accounts main or "private" [[Vault]]. */
        this.mainVault = { id: "" };
        /** IDs of all organizations this account is a member of */
        this.orgs = [];
        /**
         * Revision id used for ensuring continuity when synchronizing the account
         * object between client and server
         */
        this.revision = "";
        this.quota = new _quota__WEBPACK_IMPORTED_MODULE_6__.AccountQuota();
        this.billingDisabled = false;
        this.usedStorage = 0;
        this.favorites = new Set();
    }
    /**
     * Whether or not this Account object is current "locked" or, in other words,
     * whether the `privateKey` and `signingKey` properties have been decrypted.
     */
    get locked() {
        return !this.privateKey;
    }
    get masterKey() {
        return this._key;
    }
    set masterKey(key) {
        this._key = key;
    }
    /**
     * Generates the accounts [[privateKey]], [[publicKey]] and [[signingKey]] and
     * encrypts [[privateKey]] and [[singingKey]] using the master password.
     */
    async initialize(password) {
        const { publicKey, privateKey } = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().generateKey(new _crypto__WEBPACK_IMPORTED_MODULE_1__.RSAKeyParams());
        this.publicKey = publicKey;
        this.privateKey = privateKey;
        this.signingKey = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().generateKey(new _crypto__WEBPACK_IMPORTED_MODULE_1__.HMACKeyParams());
        await this.setPassword(password);
    }
    /** Updates the master password by reencrypting the [[privateKey]] and [[signingKey]] properties */
    async setPassword(password) {
        await super.unlock(password);
        await this._commitSecrets();
        this.updated = new Date();
    }
    /**
     * "Unlocks" the account by decrypting and extracting [[privateKey]] and
     * [[signingKey]] from [[encryptedData]]
     */
    async unlock(password) {
        await super.unlock(password);
        await this._loadSecrets();
    }
    /**
     * Unlocks the account by providing the encryption key directly rather than
     * deriving it fro the master password
     */
    async unlockWithMasterKey(key) {
        this._key = key;
        await this._loadSecrets();
    }
    /**
     * "Locks" the account by deleting all sensitive data from the object
     */
    lock() {
        super.lock();
        delete this.privateKey;
        delete this.signingKey;
        delete this.favorites;
    }
    clone() {
        const clone = super.clone();
        clone.copySecrets(this);
        return clone;
    }
    toString() {
        return this.name || this.email;
    }
    /**
     * Creates a signature that can be used later to verify an organizations id and public key
     */
    async signOrg({ id, publicKey }) {
        return (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().sign(this.signingKey, (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.concatBytes)([(0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(id), publicKey], 0x00), new _crypto__WEBPACK_IMPORTED_MODULE_1__.HMACParams());
    }
    /**
     * Verifies an organizations id an public key, using the signature stored
     * in the [[Member]] object associated with the account.
     */
    async verifyOrg(org) {
        if (!this.signingKey) {
            throw "Account needs to be unlocked first";
        }
        const member = org.getMember(this);
        if (!member) {
            throw new _error__WEBPACK_IMPORTED_MODULE_3__.Err(_error__WEBPACK_IMPORTED_MODULE_3__.ErrorCode.VERIFICATION_ERROR, "Account is not a member.");
        }
        const verified = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().verify(this.signingKey, member.orgSignature, (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.concatBytes)([(0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(org.id), org.publicKey], 0x00), new _crypto__WEBPACK_IMPORTED_MODULE_1__.HMACParams());
        if (!verified) {
            throw new _error__WEBPACK_IMPORTED_MODULE_3__.Err(_error__WEBPACK_IMPORTED_MODULE_3__.ErrorCode.VERIFICATION_ERROR, `Failed to verify public key of ${org.name}!`);
        }
    }
    async toggleFavorite(id, favorite) {
        favorite ? this.favorites.add(id) : this.favorites.delete(id);
        await this._commitSecrets();
    }
    copySecrets(account) {
        this.privateKey = account.privateKey;
        this.signingKey = account.signingKey;
        this.favorites = account.favorites;
        this._key = account._key;
    }
    async _loadSecrets() {
        const secrets = new AccountSecrets().fromBytes(await this.getData());
        if (!secrets.favorites) {
            secrets.favorites = new Set();
        }
        Object.assign(this, secrets);
    }
    async _commitSecrets() {
        const secrets = new AccountSecrets(this);
        await this.setData(secrets.toBytes());
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Object)
], Account.prototype, "created", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Object)
], Account.prototype, "updated", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Object)
], Account.prototype, "publicKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.Exclude)(),
    __metadata("design:type", Object)
], Account.prototype, "privateKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.Exclude)(),
    __metadata("design:type", Object)
], Account.prototype, "signingKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_session__WEBPACK_IMPORTED_MODULE_5__.SessionInfo),
    __metadata("design:type", Array)
], Account.prototype, "sessions", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_quota__WEBPACK_IMPORTED_MODULE_6__.AccountQuota),
    __metadata("design:type", _quota__WEBPACK_IMPORTED_MODULE_6__.AccountQuota)
], Account.prototype, "quota", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_billing__WEBPACK_IMPORTED_MODULE_7__.BillingInfo),
    __metadata("design:type", _billing__WEBPACK_IMPORTED_MODULE_7__.BillingInfo)
], Account.prototype, "billing", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.Exclude)(),
    __metadata("design:type", Object)
], Account.prototype, "favorites", void 0);


/***/ }),

/***/ "../core/src/api.ts":
/*!**************************!*\
  !*** ../core/src/api.ts ***!
  \**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "CreateAccountParams": () => (/* binding */ CreateAccountParams),
/* harmony export */   "RecoverAccountParams": () => (/* binding */ RecoverAccountParams),
/* harmony export */   "RequestEmailVerificationParams": () => (/* binding */ RequestEmailVerificationParams),
/* harmony export */   "CompleteEmailVerificationParams": () => (/* binding */ CompleteEmailVerificationParams),
/* harmony export */   "RequestMFACodeParams": () => (/* binding */ RequestMFACodeParams),
/* harmony export */   "RetrieveMFATokenParams": () => (/* binding */ RetrieveMFATokenParams),
/* harmony export */   "RetrieveMFATokenResponse": () => (/* binding */ RetrieveMFATokenResponse),
/* harmony export */   "InitAuthParams": () => (/* binding */ InitAuthParams),
/* harmony export */   "InitAuthResponse": () => (/* binding */ InitAuthResponse),
/* harmony export */   "CreateSessionParams": () => (/* binding */ CreateSessionParams),
/* harmony export */   "GetInviteParams": () => (/* binding */ GetInviteParams),
/* harmony export */   "GetAttachmentParams": () => (/* binding */ GetAttachmentParams),
/* harmony export */   "DeleteAttachmentParams": () => (/* binding */ DeleteAttachmentParams),
/* harmony export */   "GetLegacyDataParams": () => (/* binding */ GetLegacyDataParams),
/* harmony export */   "API": () => (/* binding */ API)
/* harmony export */ });
/* harmony import */ var _session__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./session */ "../core/src/session.ts");
/* harmony import */ var _account__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./account */ "../core/src/account.ts");
/* harmony import */ var _auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./auth */ "../core/src/auth.ts");
/* harmony import */ var _vault__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vault */ "../core/src/vault.ts");
/* harmony import */ var _org__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./org */ "../core/src/org.ts");
/* harmony import */ var _invite__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./invite */ "../core/src/invite.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _attachment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./attachment */ "../core/src/attachment.ts");
/* harmony import */ var _billing__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./billing */ "../core/src/billing.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");
/* harmony import */ var _mfa__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./mfa */ "../core/src/mfa.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};












/**
 * Api parameters for creating a new Account to be used with [[API.createAccount]].
 */
class CreateAccountParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /**
         * The verification token obtained from [[API.completeEmailVerification]].
         */
        this.verify = "";
        /**
         * The corresponding [[InviteID]] and [[OrgID]] if signup was initiated
         * through an invite link.
         *
         * @optional
         */
        this.invite = undefined;
        props && Object.assign(this, props);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsSerializable)(_account__WEBPACK_IMPORTED_MODULE_1__.Account),
    __metadata("design:type", _account__WEBPACK_IMPORTED_MODULE_1__.Account)
], CreateAccountParams.prototype, "account", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsSerializable)(_auth__WEBPACK_IMPORTED_MODULE_2__.Auth),
    __metadata("design:type", _auth__WEBPACK_IMPORTED_MODULE_2__.Auth)
], CreateAccountParams.prototype, "auth", void 0);
/**
 * Parameters for initiating account recovery to be used with [[API.recoverAccount]]
 */
class RecoverAccountParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** An email verification token obtained from [[API.completeEmailVerification]] */
        this.verify = "";
        props && Object.assign(this, props);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsSerializable)(_account__WEBPACK_IMPORTED_MODULE_1__.Account),
    __metadata("design:type", _account__WEBPACK_IMPORTED_MODULE_1__.Account)
], RecoverAccountParams.prototype, "account", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsSerializable)(_auth__WEBPACK_IMPORTED_MODULE_2__.Auth),
    __metadata("design:type", _auth__WEBPACK_IMPORTED_MODULE_2__.Auth)
], RecoverAccountParams.prototype, "auth", void 0);
/**
 * Parameters for requesting email verfication through [[API.requestEmailVerification]]
 * @deprecated since v3.1.0
 */
class RequestEmailVerificationParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The email address to be verified */
        this.email = "";
        /** The purpose of the email verification */
        this.purpose = _mfa__WEBPACK_IMPORTED_MODULE_11__.MFAPurpose.Signup;
        props && Object.assign(this, props);
    }
}
/**
 * Parameters for completing email verification through [[API.completeEmailVerification]]
 * @deprecated since v3.1.0
 */
class CompleteEmailVerificationParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The email address to be verified */
        this.email = "";
        /** The verification code received via email after calling [[API.requestEmailVerification]] */
        this.code = "";
        props && Object.assign(this, props);
    }
}
/**
 * Parameters for requesting Multi-Factor Authenticatino via [[API.requestMFACode]]
 */
class RequestMFACodeParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The accounts email address */
        this.email = "";
        /** The purpose of the email verification */
        this.purpose = _mfa__WEBPACK_IMPORTED_MODULE_11__.MFAPurpose.Login;
        this.type = _mfa__WEBPACK_IMPORTED_MODULE_11__.MFAType.Email;
        props && Object.assign(this, props);
    }
}
/**
 * Parameters for retrieving MFA token via [[API.retrieveMFAToken]]
 */
class RetrieveMFATokenParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The email address to be verified */
        this.email = "";
        /** The verification code received via email after calling [[API.requestEmailVerification]] */
        this.code = "";
        this.purpose = _mfa__WEBPACK_IMPORTED_MODULE_11__.MFAPurpose.Login;
        props && Object.assign(this, props);
    }
}
class RetrieveMFATokenResponse extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The verification token which can be used to authenticate certain requests */
        this.token = "";
        /** Whether the user already has an account */
        this.hasAccount = false;
        /** Whether the user has a legacy account */
        this.hasLegacyAccount = false;
        /** Token for getting legacy data. */
        this.legacyToken = undefined;
        props && Object.assign(this, props);
    }
}
/**
 * Parameters for initiating authentication through [[API.initAuth]]
 */
class InitAuthParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The email address of the [[Account]] in question */
        this.email = "";
        /**
         * The verification token obtained from [[API.completeEmailVerification]].
         */
        this.verify = undefined;
        props && Object.assign(this, props);
    }
}
/**
 * The response object received from [[API.initAuth]]
 */
class InitAuthResponse extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The account id */
        this.account = "";
        /** The key derivation parameters used for authentication */
        this.keyParams = new _crypto__WEBPACK_IMPORTED_MODULE_9__.PBKDF2Params();
        props && Object.assign(this, props);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_9__.PBKDF2Params),
    __metadata("design:type", _crypto__WEBPACK_IMPORTED_MODULE_9__.PBKDF2Params)
], InitAuthResponse.prototype, "keyParams", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], InitAuthResponse.prototype, "B", void 0);
/**
 * Parameters for creating a new [[Session]] through [[API.createSession]]
 */
class CreateSessionParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The id of the [[Account]] to create the session for */
        this.account = "";
        props && Object.assign(this, props);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], CreateSessionParams.prototype, "M", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_6__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], CreateSessionParams.prototype, "A", void 0);
/**
 * Parameters for fetching an [[Invite]]
 */
class GetInviteParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The organization id */
        this.org = "";
        /** The invite id */
        this.id = "";
        props && Object.assign(this, props);
    }
}
/**
 * Parameters for fetching an [[Attachment]]
 */
class GetAttachmentParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(props) {
        super();
        /** The vault id */
        this.vault = "";
        /** The attachment id */
        this.id = "";
        props && Object.assign(this, props);
    }
}
class DeleteAttachmentParams extends GetAttachmentParams {
}
class GetLegacyDataParams extends _encoding__WEBPACK_IMPORTED_MODULE_6__.Serializable {
    constructor(vals = {}) {
        super();
        this.email = "";
        this.verify = undefined;
        Object.assign(this, vals);
    }
}
/**
 * Decorator for defining request handler methods
 */
function Handler(input, output) {
    return (proto, method) => {
        if (!proto.handlerDefinitions) {
            proto.handlerDefinitions = [];
        }
        proto.handlerDefinitions.push({
            method,
            input: input === String ? undefined : input,
            output: output === String ? undefined : output
        });
    };
}
/**
 * Transport-agnostic interface defining communication
 * between [[Client]] and [[Server]] instances.
 */
class API {
    /**
     * Request verification of a given email address. This will send a verification code
     * to the email in question which can then be exchanged for a verification token via
     * [[completeEmailVerification]].
     * @deprecated since v3.1.0
     */
    requestEmailVerification(_params) {
        throw "Not implemented";
    }
    /**
     * Complete the email verification process by providing a verification code received
     * via email. Returns a verification token that can be used in other api calls like
     * [[createAccount]] or [[recoverAccount]].
     * @deprecated since v3.1.0
     */
    completeEmailVerification(_params) {
        throw "Not implemented";
    }
    /**
     * Request verification of a given email address. This will send a verification code
     * to the email in question which can then be exchanged for a verification token via
     * [[completeEmailVerification]].
     */
    requestMFACode(_params) {
        throw "Not implemented";
    }
    /**
     * Complete the email verification process by providing a verification code received
     * via email. Returns a verification token that can be used in other api calls like
     * [[createAccount]] or [[recoverAccount]].
     */
    retrieveMFAToken(_params) {
        throw "Not implemented";
    }
    /**
     * Initiate the login procedure for a given account by requesting the authentication params
     * which are required for proceeding with [[createSession]].
     */
    initAuth(_params) {
        throw "Not implemented";
    }
    /**
     * Update the authentication params stored on the server. This is usually used
     * in case a users master password has changed.
     */
    updateAuth(_params) {
        throw "Not implemented";
    }
    /**
     * Create new [[Session]] which can be used to authenticate future request
     */
    createSession(_params) {
        throw "Not implemented";
    }
    /**
     * Revoke a [[Session]], effectively logging out any client authenticated with it
     */
    revokeSession(_id) {
        throw "Not implemented";
    }
    /**
     * Create a new [[Account]]
     */
    createAccount(_params) {
        throw "Not implemented";
    }
    /**
     * Get the [[Account]] associated with the current session
     *
     * @authentication_required
     */
    getAccount() {
        throw "Not implemented";
    }
    /**
     * Update the [[Account]] associated with the current session.
     *
     * @authentication_required
     */
    updateAccount(_account) {
        throw "Not implemented";
    }
    /**
     * Initiate account recovery
     */
    recoverAccount(_params) {
        throw "Not implemented";
    }
    /**
     * Delete current account
     */
    deleteAccount() {
        throw "Not implemented";
    }
    /**
     * Create a new [[Org]]
     *
     * @authentication_required
     */
    createOrg(_params) {
        throw "Not implemented";
    }
    /**
     * Get the [[Org]] for a given `id`.
     *
     * @authentication_required
     *
     * Requires the authenticated account to be a member of the given organization
     */
    getOrg(_id) {
        throw "Not implemented";
    }
    /**
     * Updates a given [[Org]]
     *
     * @authentication_required
     *
     * Updating members, organization name or pubic/private keys requires the [[OrgRole.Owner]]
     * role, while any other changes require the [[OrgRole.Admin]] role.
     */
    updateOrg(_org) {
        throw "Not implemented";
    }
    deleteOrg(_id) {
        throw "Not implemented";
    }
    /**
     * Create a new vault
     *
     * @authentication_required
     *
     * Requires the [[OrgRole.Admin]] role on the associated organization
     */
    createVault(_vault) {
        throw "Not implemented";
    }
    /**
     * Get the [[Vault]] with the given `id`
     *
     * @authentiation_required
     *
     * If the vault belongs to an organization, the authenticated account needs to
     * be assigned to the given vault either directly or through a [[Group]].
     * Otherwise, only access to the accounts private vault is allowed.
     */
    getVault(_id) {
        throw "Not implemented";
    }
    /**
     * Update the given [[Vault]]
     *
     * @authentiation_required
     *
     * If vault belongs to an organization, the authenticated account needs to
     * be be assigned to the given vault either directly or through a [[Group]]
     * and have explicit write access. Otherwise, only access to the accounts
     * private vault is allowed.
     */
    updateVault(_vault) {
        throw "Not implemented";
    }
    /**
     * Delete the [[Vault]] with the given `id`
     *
     * @authentication_required
     *
     * Requires at least the [[OrgRole.Admin]] role on the organization the vault
     * belongs to. Private vaults cannot be deleted.
     */
    deleteVault(_id) {
        throw "Not implemented";
    }
    /**
     * Get an [[Invite]].
     *
     * @authentication_required
     *
     * Requires the authenticated account to either be an [[OrgRole.Owner]] of
     * the associated organization or the recipient of the invite.
     */
    getInvite(_params) {
        throw "Not implemented";
    }
    /**
     * Accept an [[Invite]]
     *
     * @authentication_required
     *
     * Requires the authenticated account to be the recipient of the invite.
     */
    acceptInvite(_invite) {
        throw "Not implemented";
    }
    createAttachment(_attachment) {
        throw "Not implemented";
    }
    getAttachment(_attachment) {
        throw "Not implemented";
    }
    deleteAttachment(_attachment) {
        throw "Not implemented";
    }
    updateBilling(_params) {
        throw "Not implemented";
    }
    getBillingProviders() {
        throw "Not implemented";
    }
    getLegacyData(_params) {
        throw "Not implemented";
    }
    deleteLegacyAccount() {
        throw "Not implemented";
    }
}
__decorate([
    Handler(RequestEmailVerificationParams, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RequestEmailVerificationParams]),
    __metadata("design:returntype", Object)
], API.prototype, "requestEmailVerification", null);
__decorate([
    Handler(CompleteEmailVerificationParams, String),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [CompleteEmailVerificationParams]),
    __metadata("design:returntype", Object)
], API.prototype, "completeEmailVerification", null);
__decorate([
    Handler(RequestMFACodeParams, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RequestMFACodeParams]),
    __metadata("design:returntype", Object)
], API.prototype, "requestMFACode", null);
__decorate([
    Handler(RetrieveMFATokenParams, RetrieveMFATokenResponse),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RetrieveMFATokenParams]),
    __metadata("design:returntype", Object)
], API.prototype, "retrieveMFAToken", null);
__decorate([
    Handler(InitAuthParams, InitAuthResponse),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [InitAuthParams]),
    __metadata("design:returntype", Object)
], API.prototype, "initAuth", null);
__decorate([
    Handler(_auth__WEBPACK_IMPORTED_MODULE_2__.Auth, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_auth__WEBPACK_IMPORTED_MODULE_2__.Auth]),
    __metadata("design:returntype", Object)
], API.prototype, "updateAuth", null);
__decorate([
    Handler(CreateSessionParams, _session__WEBPACK_IMPORTED_MODULE_0__.Session),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [CreateSessionParams]),
    __metadata("design:returntype", Object)
], API.prototype, "createSession", null);
__decorate([
    Handler(String, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Object)
], API.prototype, "revokeSession", null);
__decorate([
    Handler(CreateAccountParams, _account__WEBPACK_IMPORTED_MODULE_1__.Account),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [CreateAccountParams]),
    __metadata("design:returntype", Object)
], API.prototype, "createAccount", null);
__decorate([
    Handler(undefined, _account__WEBPACK_IMPORTED_MODULE_1__.Account),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Object)
], API.prototype, "getAccount", null);
__decorate([
    Handler(_account__WEBPACK_IMPORTED_MODULE_1__.Account, _account__WEBPACK_IMPORTED_MODULE_1__.Account),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_account__WEBPACK_IMPORTED_MODULE_1__.Account]),
    __metadata("design:returntype", Object)
], API.prototype, "updateAccount", null);
__decorate([
    Handler(RecoverAccountParams, _account__WEBPACK_IMPORTED_MODULE_1__.Account),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RecoverAccountParams]),
    __metadata("design:returntype", Object)
], API.prototype, "recoverAccount", null);
__decorate([
    Handler(undefined, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Object)
], API.prototype, "deleteAccount", null);
__decorate([
    Handler(_org__WEBPACK_IMPORTED_MODULE_4__.Org, _org__WEBPACK_IMPORTED_MODULE_4__.Org),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_org__WEBPACK_IMPORTED_MODULE_4__.Org]),
    __metadata("design:returntype", Object)
], API.prototype, "createOrg", null);
__decorate([
    Handler(undefined, _org__WEBPACK_IMPORTED_MODULE_4__.Org),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Object)
], API.prototype, "getOrg", null);
__decorate([
    Handler(_org__WEBPACK_IMPORTED_MODULE_4__.Org, _org__WEBPACK_IMPORTED_MODULE_4__.Org),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_org__WEBPACK_IMPORTED_MODULE_4__.Org]),
    __metadata("design:returntype", Object)
], API.prototype, "updateOrg", null);
__decorate([
    Handler(String, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Object)
], API.prototype, "deleteOrg", null);
__decorate([
    Handler(_vault__WEBPACK_IMPORTED_MODULE_3__.Vault, _vault__WEBPACK_IMPORTED_MODULE_3__.Vault),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_vault__WEBPACK_IMPORTED_MODULE_3__.Vault]),
    __metadata("design:returntype", Object)
], API.prototype, "createVault", null);
__decorate([
    Handler(String, _vault__WEBPACK_IMPORTED_MODULE_3__.Vault),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Object)
], API.prototype, "getVault", null);
__decorate([
    Handler(_vault__WEBPACK_IMPORTED_MODULE_3__.Vault, _vault__WEBPACK_IMPORTED_MODULE_3__.Vault),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_vault__WEBPACK_IMPORTED_MODULE_3__.Vault]),
    __metadata("design:returntype", Object)
], API.prototype, "updateVault", null);
__decorate([
    Handler(String, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Object)
], API.prototype, "deleteVault", null);
__decorate([
    Handler(GetInviteParams, _invite__WEBPACK_IMPORTED_MODULE_5__.Invite),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetInviteParams]),
    __metadata("design:returntype", Object)
], API.prototype, "getInvite", null);
__decorate([
    Handler(_invite__WEBPACK_IMPORTED_MODULE_5__.Invite, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_invite__WEBPACK_IMPORTED_MODULE_5__.Invite]),
    __metadata("design:returntype", Object)
], API.prototype, "acceptInvite", null);
__decorate([
    Handler(_attachment__WEBPACK_IMPORTED_MODULE_7__.Attachment, String),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_attachment__WEBPACK_IMPORTED_MODULE_7__.Attachment]),
    __metadata("design:returntype", Object)
], API.prototype, "createAttachment", null);
__decorate([
    Handler(GetAttachmentParams, _attachment__WEBPACK_IMPORTED_MODULE_7__.Attachment),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetAttachmentParams]),
    __metadata("design:returntype", Object)
], API.prototype, "getAttachment", null);
__decorate([
    Handler(DeleteAttachmentParams, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [DeleteAttachmentParams]),
    __metadata("design:returntype", Object)
], API.prototype, "deleteAttachment", null);
__decorate([
    Handler(_billing__WEBPACK_IMPORTED_MODULE_8__.UpdateBillingParams, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [_billing__WEBPACK_IMPORTED_MODULE_8__.UpdateBillingParams]),
    __metadata("design:returntype", Object)
], API.prototype, "updateBilling", null);
__decorate([
    Handler(undefined, _billing__WEBPACK_IMPORTED_MODULE_8__.BillingProviderInfo),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Object)
], API.prototype, "getBillingProviders", null);
__decorate([
    Handler(GetLegacyDataParams, _container__WEBPACK_IMPORTED_MODULE_10__.PBES2Container),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetLegacyDataParams]),
    __metadata("design:returntype", Object)
], API.prototype, "getLegacyData", null);
__decorate([
    Handler(undefined, undefined),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Object)
], API.prototype, "deleteLegacyAccount", null);


/***/ }),

/***/ "../core/src/app.ts":
/*!**************************!*\
  !*** ../core/src/app.ts ***!
  \**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Stats": () => (/* binding */ Stats),
/* harmony export */   "Settings": () => (/* binding */ Settings),
/* harmony export */   "Index": () => (/* binding */ Index),
/* harmony export */   "AppState": () => (/* binding */ AppState),
/* harmony export */   "App": () => (/* binding */ App)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./storage */ "../core/src/storage.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _invite__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./invite */ "../core/src/invite.ts");
/* harmony import */ var _vault__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vault */ "../core/src/vault.ts");
/* harmony import */ var _org__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./org */ "../core/src/org.ts");
/* harmony import */ var _item__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./item */ "../core/src/item.ts");
/* harmony import */ var _account__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./account */ "../core/src/account.ts");
/* harmony import */ var _auth__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./auth */ "../core/src/auth.ts");
/* harmony import */ var _session__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./session */ "../core/src/session.ts");
/* harmony import */ var _api__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./api */ "../core/src/api.ts");
/* harmony import */ var _client__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./client */ "../core/src/client.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./util */ "../core/src/util.ts");
/* harmony import */ var _srp__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./srp */ "../core/src/srp.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
/* harmony import */ var _attachment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./attachment */ "../core/src/attachment.ts");
/* harmony import */ var _billing__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./billing */ "../core/src/billing.ts");
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




















/** Various usage stats */
class Stats extends _encoding__WEBPACK_IMPORTED_MODULE_2__.Serializable {
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsDate)(),
    __metadata("design:type", Date)
], Stats.prototype, "lastSync", void 0);
/** Various application settings */
class Settings extends _encoding__WEBPACK_IMPORTED_MODULE_2__.Serializable {
    constructor() {
        super(...arguments);
        /** Whether to lock app automatically after a certain period of inactivity */
        this.autoLock = true;
        /** Duration after which auto-lock is triggered, in minutes */
        this.autoLockDelay = 5;
        /** Interval for automatic sync, in minutes */
        this.syncInterval = 1;
        /** Time threshold used for filtering "recent" items, in days */
        this.recentLimit = 7;
    }
}
class Index extends _encoding__WEBPACK_IMPORTED_MODULE_2__.Serializable {
    constructor() {
        super(...arguments);
        this.hashParams = new _crypto__WEBPACK_IMPORTED_MODULE_19__.PBKDF2Params({ iterations: 1 });
        this.items = [];
    }
    async fromItems(items) {
        const crypto = (0,_platform__WEBPACK_IMPORTED_MODULE_12__.getCryptoProvider)();
        if (!this.hashParams.salt.length) {
            this.hashParams.salt = await crypto.randomBytes(16);
        }
        this.items = (await Promise.all(items.map(async (item) => ({
            hosts: (await Promise.all(item.fields
                .filter(f => f.type === "url")
                .map(async (f) => {
                // try to parse host from url. if url is not valid,
                // assume the url field contains just the domain.
                let host = f.value;
                try {
                    host = new URL(f.value).host;
                }
                catch (e) { }
                if (!host) {
                    return null;
                }
                const hashedHost = await crypto.deriveKey((0,_encoding__WEBPACK_IMPORTED_MODULE_2__.stringToBytes)(host), this.hashParams);
                return (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.bytesToBase64)(hashedHost);
            }))).filter(h => h !== null)
        })))).filter(item => item.hosts.length);
    }
    async matchHost(host) {
        const hashedHost = (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.bytesToBase64)(await (0,_platform__WEBPACK_IMPORTED_MODULE_12__.getCryptoProvider)().deriveKey((0,_encoding__WEBPACK_IMPORTED_MODULE_2__.stringToBytes)(host), this.hashParams));
        return this.items.filter(item => item.hosts.some(h => h === hashedHost)).length;
    }
    async fuzzyMatchHost(host) {
        // Try exact match first, then try to add/remove "www."
        return ((await this.matchHost(host)) ||
            (host.startsWith("www.") ? this.matchHost(host.slice(4)) : this.matchHost("www." + host)));
    }
    async matchUrl(url) {
        try {
            const { host } = new URL(url);
            return this.fuzzyMatchHost(host);
        }
        catch (e) {
            return 0;
        }
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_19__.PBKDF2Params),
    __metadata("design:type", Object)
], Index.prototype, "hashParams", void 0);
/** Application state */
class AppState extends _storage__WEBPACK_IMPORTED_MODULE_1__.Storable {
    constructor() {
        super(...arguments);
        this.id = "app-state";
        /** Application Settings */
        this.settings = new Settings();
        /** Usage data */
        this.stats = new Stats();
        /** Info about current device */
        this.device = new _platform__WEBPACK_IMPORTED_MODULE_12__.DeviceInfo();
        /** Current [[Session]] */
        this.session = null;
        /** Currently logged in [[Account]] */
        this.account = null;
        /** All organizations the current [[account]] is a member of. */
        this.orgs = [];
        /** All vaults the current [[account]] has access to. */
        this.vaults = [];
        /** Whether a sync is currently in process. */
        this.syncing = false;
        /** Whether the app has an internet connection at the moment */
        this.online = true;
        this.rememberedMasterKey = null;
        this.billingProvider = null;
        this.currentHost = "";
        this.index = new Index();
        /** IDs of most recently used items. The most recently used item is last */
        this.lastUsed = new Map();
        this._errors = [];
    }
    /** All [[Tag]]s found within the users [[Vault]]s */
    get tags() {
        const tags = new Map();
        for (const vault of this.vaults) {
            for (const item of vault.items) {
                for (const tag of item.tags) {
                    if (!tags.has(tag)) {
                        tags.set(tag, 0);
                    }
                    tags.set(tag, tags.get(tag) + 1);
                }
            }
        }
        return [...tags.entries()];
    }
    /** Whether the app is in "locked" state */
    get locked() {
        return !this.account || this.account.locked;
    }
    /** Whether a user is logged in */
    get loggedIn() {
        return !!this.session;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(Settings),
    __metadata("design:type", Object)
], AppState.prototype, "settings", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(Stats),
    __metadata("design:type", Object)
], AppState.prototype, "stats", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_platform__WEBPACK_IMPORTED_MODULE_12__.DeviceInfo),
    __metadata("design:type", Object)
], AppState.prototype, "device", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_session__WEBPACK_IMPORTED_MODULE_9__.Session),
    __metadata("design:type", Object)
], AppState.prototype, "session", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_account__WEBPACK_IMPORTED_MODULE_7__.Account),
    __metadata("design:type", Object)
], AppState.prototype, "account", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_org__WEBPACK_IMPORTED_MODULE_5__.Org),
    __metadata("design:type", Array)
], AppState.prototype, "orgs", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_vault__WEBPACK_IMPORTED_MODULE_4__.Vault),
    __metadata("design:type", Array)
], AppState.prototype, "vaults", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_container__WEBPACK_IMPORTED_MODULE_18__.SimpleContainer),
    __metadata("design:type", Object)
], AppState.prototype, "rememberedMasterKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(_billing__WEBPACK_IMPORTED_MODULE_17__.BillingProviderInfo),
    __metadata("design:type", Object)
], AppState.prototype, "billingProvider", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsSerializable)(Index),
    __metadata("design:type", Index)
], AppState.prototype, "index", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.Serialize)({
        arrayDeserializeIndividually: false,
        fromRaw: (raw) => new Map(raw.map(([id, date]) => [id, new Date(date)])),
        toRaw: (val) => [...val]
    }),
    __metadata("design:type", Object)
], AppState.prototype, "lastUsed", void 0);
/**
 * The `App` class is *the* user-facing top level component encapsulating all
 * functionality of the Padloc client app. It is responsible for managing
 * state, client-side persistence and synchronization with the [[Server]] and
 * exposes methods for manipulating a users [[Account]], [[Org]]anizations and
 * [[Vault]]s.
 *
 * [[App]] is completely platform-agnostic and can be used in any environment
 * capable of running JavaScript. It does however rely on platform-specific
 * providers for a number of features like storage and encryption which can
 * be "plugged in" as needed.
 *
 * ### Encryption
 *
 * The `@padloc/core` module does not provide or depend on any specific
 * implementation of cryptographic primitives but instead relies on
 * the [[CryptoProvider]] interface to provide those.
 *
 * Users of the [[App]] class (and of the `@padloc/core` package in general)
 * are responsible for ensuring that a secure implemenation of the
 * [[CryptoProvider]] interface is available before using any methods that
 * require cryptographic functionality. This is done through the
 * `crypto.setProvider` function (see example below).
 *
 * ### Platform API
 *
 * Certain functionality requires access to some platform APIs. For this,
 * an implementation of the [[Platform]] interface can be provided via
 * `platform.setPlatform`.
 *
 * ### Persistent Storage
 *
 * Persistent storage is provided by an implementation of the [[Storage]]
 * interface.
 *
 * ### Data Transport
 *
 * The [[Sender]] interface handles communication with the [[Server]] instance
 * through a RPC [[Request]]-[[Response]] cycle. The implementation provided
 * should match the [[Receiver]] implementation used in the [[Server]]
 * instance.
 *
 * ### Initialization Example
 *
 * ```ts
 * @import { setProvider } from "@padloc/core/src/crypto";
 * @import { setPlatform } from "@padloc/core/src/platform";
 *
 * setProvider(new NodeCryptoProvider());
 * setPlatform(new NodePlatform());
 *
 * const app = new App(new LevelDBStorage(), new HTTPSender());
 *
 * app.loaded.then(() => console.log("app ready!");
 * ```
 */
class App {
    constructor(
    /** Data transport provider */
    sender, storage = (0,_platform__WEBPACK_IMPORTED_MODULE_12__.getStorage)()) {
        /** App version */
        this.version = "3.0";
        /** Application state */
        this.state = new AppState();
        this._queuedSyncPromises = new Map();
        this._activeSyncPromises = new Map();
        this._subscriptions = [];
        this._cachedAuthInfo = new Map();
        /**
         * Notifies all subscribers of a [[state]] change
         */
        this.publish = (0,_util__WEBPACK_IMPORTED_MODULE_13__.throttle)(() => {
            for (const fn of this._subscriptions) {
                fn(this.state);
            }
        }, 1000);
        this.storage = storage;
        this.api = new _client__WEBPACK_IMPORTED_MODULE_11__.Client(this.state, sender, (_req, _res, err) => {
            const online = !err || err.code !== _error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.FAILED_CONNECTION;
            if (online !== this.state.online) {
                this.setState({ online });
            }
        });
        this.loaded = this.load();
    }
    /** Promise that resolves once all current synchronization processes are complete */
    get syncComplete() {
        return Promise.all([...this._activeSyncPromises.values(), ...this._queuedSyncPromises.values()]);
    }
    /** Current account */
    get account() {
        return this.state.account;
    }
    /** Current session */
    get session() {
        return this.state.session;
    }
    /** The current accounts organizations */
    get orgs() {
        return this.state.orgs.sort();
    }
    /** The current accounts vaults */
    get vaults() {
        return this.state.vaults.sort();
    }
    /** Application settings */
    get settings() {
        return this.state.settings;
    }
    /** The current users main, or "private" [[Vault]] */
    get mainVault() {
        return (this.account && this.getVault(this.account.mainVault.id)) || null;
    }
    get online() {
        return this.state.online;
    }
    get supportsBiometricUnlock() {
        return this.state.device.supportsBioAuth && this.state.device.supportsKeyStore;
    }
    get remembersMasterKey() {
        return !!this.state.rememberedMasterKey;
    }
    get billingEnabled() {
        return !!this.state.billingProvider && !(this.state.account && this.state.account.billingDisabled);
    }
    get count() {
        const count = {
            favorites: 0,
            attachments: 0,
            recent: 0,
            total: 0,
            currentHost: this.state.currentHost ? this.getItemsForHost(this.state.currentHost).length : 0
        };
        const recentThreshold = new Date(Date.now() - this.settings.recentLimit * 24 * 60 * 60 * 1000);
        for (const vault of this.vaults) {
            for (const item of vault.items) {
                count.total++;
                if (this.account && this.account.favorites.has(item.id)) {
                    count.favorites++;
                }
                if (item.attachments.length) {
                    count.attachments++;
                }
                if (this.state.lastUsed.has(item.id) && this.state.lastUsed.get(item.id) > recentThreshold) {
                    count.recent++;
                }
            }
        }
        return count;
    }
    /** Save application state to persistent storage */
    async save() {
        await this.loaded;
        if (!this.state.locked) {
            await this.state.index.fromItems(this.state.vaults.reduce((items, v) => [...items, ...v.items], []));
        }
        await this.storage.save(this.state);
    }
    /** Load application state from persistent storage */
    async load() {
        // Try to load app state from persistent storage.
        try {
            this.setState(await this.storage.get(AppState, this.state.id));
        }
        catch (e) { }
        // Update device info
        const { id, ...rest } = await (0,_platform__WEBPACK_IMPORTED_MODULE_12__.getDeviceInfo)();
        Object.assign(this.state.device, rest);
        try {
            await (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.loadLanguage)(this.state.device.locale);
        }
        catch (e) {
            // Failed to load language, so we'll fallback to default (English)
        }
        // If no device id has been set yet, generate a new one
        if (!this.state.device.id) {
            this.state.device.id = await (0,_util__WEBPACK_IMPORTED_MODULE_13__.uuid)();
        }
        // Save back to storage
        await this.storage.save(this.state);
        this.loadBillingProvider();
        // Notify state change
        this.publish();
    }
    async reload() {
        const masterKey = this.account && this.account.masterKey;
        await this.load();
        if (masterKey) {
            await this.unlockWithMasterKey(masterKey);
        }
    }
    /**
     * Unlocks the current [[Account]] and all available [[Vaults]].
     */
    async unlock(password) {
        if (!this.account) {
            throw "Unlocking only works if the user is logged in!";
        }
        // Unlock account using the master password
        await this.account.unlock(password);
        await this._unlocked();
    }
    /**
     * Locks the app and wipes all sensitive information from memory.
     */
    async lock() {
        [this.account, ...this.state.orgs, ...this.state.vaults].forEach(each => each.lock());
        this.publish();
    }
    /**
     * Synchronizes the current account and all of the accounts organizations
     * and vaults
     */
    async synchronize() {
        this.setState({ syncing: true });
        await this.fetchAccount();
        await this.fetchOrgs();
        await this.syncVaults();
        await this.save();
        this.setStats({ lastSync: new Date() });
        this.publish();
    }
    /**
     * Notifies of changes to the app [[state]] via the provided function
     *
     * @returns A unsubscribe function
     */
    subscribe(fn) {
        this._subscriptions.push(fn);
        return () => this.unsubscribe(fn);
    }
    /**
     * Unsubscribes a function previously subscribed through [[subscribe]].
     */
    unsubscribe(fn) {
        this._subscriptions = this._subscriptions.filter(f => f === fn);
    }
    /**
     * Updates the app [[state]]
     */
    setState(state) {
        Object.assign(this.state, state);
        this.publish();
    }
    /** Update usage data */
    async setStats(obj) {
        Object.assign(this.state.stats, obj);
        await this.save();
        this.publish();
    }
    /** Update application settings */
    async setSettings(obj) {
        Object.assign(this.state.settings, obj);
        await this.save();
        this.publish();
    }
    /*
     * ===============================
     *  ACCOUNT & SESSION MANGAGEMENT
     * ===============================
     */
    /** Request email verification for a given `email`. */
    async requestMFACode(email, purpose) {
        return this.api.requestMFACode(new _api__WEBPACK_IMPORTED_MODULE_10__.RequestMFACodeParams({ email, purpose }));
    }
    /** Complete email with the given `code` */
    async retrieveMFAToken(email, code, purpose) {
        return this.api.retrieveMFAToken(new _api__WEBPACK_IMPORTED_MODULE_10__.RetrieveMFATokenParams({ email, code, purpose }));
    }
    /**
     * Creates a new Padloc [[Account]] and signs in the user.
     */
    async signup({ 
    /** The desired email address */
    email, 
    /** The users master password */
    password, 
    /** The desired display name */
    name, 
    /** Verification token obtained trough [[completeEmailVerification]] */
    verify, 
    /** Information about the [[Invite]] object if signup was initiated through invite link */
    invite }) {
        // Inialize account object
        const account = new _account__WEBPACK_IMPORTED_MODULE_7__.Account();
        account.email = email;
        account.name = name;
        await account.initialize(password);
        // Initialize auth object
        const auth = new _auth__WEBPACK_IMPORTED_MODULE_8__.Auth(email);
        const authKey = await auth.getAuthKey(password);
        // Calculate verifier
        const srp = new _srp__WEBPACK_IMPORTED_MODULE_14__.Client();
        await srp.initialize(authKey);
        auth.verifier = srp.v;
        // Send off request to server
        await this.api.createAccount(new _api__WEBPACK_IMPORTED_MODULE_10__.CreateAccountParams({
            account,
            auth,
            verify,
            invite
        }));
        // Sign into new account
        await this.login(email, password);
    }
    /**
     * Log in user, creating a new [[Session]], loading [[Account]] info and
     * fetching all of the users [[Org]]anizations and [[Vault]]s.
     */
    async login(email, password, verify) {
        if (!this._cachedAuthInfo.has(email)) {
            // Fetch authentication info
            this._cachedAuthInfo.set(email, await this.api.initAuth(new _api__WEBPACK_IMPORTED_MODULE_10__.InitAuthParams({ email, verify })));
        }
        const { account: accId, keyParams, B } = this._cachedAuthInfo.get(email);
        const auth = new _auth__WEBPACK_IMPORTED_MODULE_8__.Auth(email);
        auth.keyParams = keyParams;
        // Generate auth secret
        const authKey = await auth.getAuthKey(password);
        // Initialize SRP object
        const srp = new _srp__WEBPACK_IMPORTED_MODULE_14__.Client();
        await srp.initialize(authKey);
        await srp.setB(B);
        // Create session object
        const session = await this.api.createSession(new _api__WEBPACK_IMPORTED_MODULE_10__.CreateSessionParams({ account: accId, A: srp.A, M: srp.M1 }));
        // Apply session key and update state
        session.key = srp.K;
        this.setState({ session });
        // Fetch and unlock account object
        const account = await this.api.getAccount();
        await account.unlock(password);
        this.setState({ account });
        // Save application state
        await this.save();
        // Load organizations and vaults
        await this.synchronize();
    }
    /**
     * Logs out user and clears all sensitive information
     */
    async logout() {
        await this._logout();
        this.publish();
    }
    async deleteAccount() {
        await this.api.deleteAccount();
        await this._logout();
    }
    async _logout() {
        this._cachedAuthInfo.clear();
        if (await this.canRememberMasterKey()) {
            await this.forgetMasterKey();
        }
        // Revoke session
        try {
            await this.api.revokeSession(this.state.session.id);
        }
        catch (e) { }
        // Reset application state
        this.setState({
            account: null,
            session: null,
            vaults: [],
            orgs: [],
            index: new Index()
        });
        await this.save();
    }
    /**
     * Updates the users master password
     */
    async changePassword(password) {
        // TODO: Add option to rotate keys
        await this.updateAccount(async (account) => {
            // Update account object
            await account.setPassword(password);
            // Update auth object
            const auth = new _auth__WEBPACK_IMPORTED_MODULE_8__.Auth(account.email);
            auth.account = account.id;
            const authKey = await auth.getAuthKey(password);
            const srp = new _srp__WEBPACK_IMPORTED_MODULE_14__.Client();
            await srp.initialize(authKey);
            auth.verifier = srp.v;
            await this.api.updateAuth(auth);
        });
        if (await this.canRememberMasterKey()) {
            await this.forgetMasterKey();
        }
    }
    /**
     * Fetches the users [[Account]] info from the [[Server]]
     */
    async fetchAccount() {
        const account = await this.api.getAccount();
        // Copy over secret properties so we don't have to
        // unlock the account object again.
        if (this.account) {
            account.copySecrets(this.account);
        }
        // Update and save state
        this.setState({ account });
        await this.save();
    }
    /**
     * Updates the users [[Account]] information
     * @param transform A function applying the changes to the account
     */
    async updateAccount(transform) {
        if (!this.account) {
            throw "User needs to be logged in in order to update their account!";
        }
        // Create a clone of the current account to prevent inconsistencies in
        // case something goes wrong.
        let account = this.account.clone();
        // Apply changes
        await transform(account);
        // Send request to server
        try {
            account = await this.api.updateAccount(account);
        }
        catch (e) {
            // If account has been updated since last fetch,
            // get the current version and then retry
            if (e.code === _error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.OUTDATED_REVISION) {
                await this.fetchAccount();
                await this.updateAccount(transform);
            }
            else {
                throw e;
            }
        }
        // Copy over secret properties so we don't have to unlock the
        // account object again.
        account.copySecrets(this.account);
        // Update and save state
        this.setState({ account });
        await this.save();
    }
    /**
     * Revokes the given [[Session]]
     */
    async revokeSession({ id }) {
        await this.api.revokeSession(id);
        await this.fetchAccount();
    }
    /**
     * Initiates account recovery allowing a user to regain control of their
     * account in case they forget their master password. This results in the
     * following:
     *
     * - All of the accounts cryptographic keys are rotated.
     * - The accounts sensitive data is encrypted with the new master password.
     * - The accounts authentication info is updated to reflect the password change.
     * - The accounts private vault is reset (and the data within it lost).
     * - The cryptographic keys of all [[Org]]anizations owned by the account will be
     *   rotated and all members suspended until reconfirmed.
     * - The accounts memberships to any [[Org]]ganizations not owned by it will be
     *   suspended until reconfirmed.
     *
     * The user will automatically get logged in during this process
     * so a separate login is not necessary.
     */
    async recoverAccount({ 
    /** Account email */
    email, 
    /** New master password */
    password, 
    /** Verification token obtained trough [[completeEmailVerification]] */
    verify }) {
        // Log out user (if logged in)
        await this._logout();
        // Initialize account with new password
        let account = new _account__WEBPACK_IMPORTED_MODULE_7__.Account();
        account.email = email;
        await account.initialize(password);
        // Initialize auth object with new password
        const auth = new _auth__WEBPACK_IMPORTED_MODULE_8__.Auth(email);
        const authKey = await auth.getAuthKey(password);
        const srp = new _srp__WEBPACK_IMPORTED_MODULE_14__.Client();
        await srp.initialize(authKey);
        auth.verifier = srp.v;
        // Send account recovery request to the server, updating account and
        // authentication info. This will also suspend the accounts membership
        // to any organizations not owned by them.
        await this.api.recoverAccount(new _api__WEBPACK_IMPORTED_MODULE_10__.RecoverAccountParams({
            account,
            auth,
            verify
        }));
        // Sign in user using the new password
        await this.login(email, password);
        // Rotate keys of all owned organizations. Suspend all other members
        // and create invites to reconfirm the membership.
        for (const org of this.state.orgs.filter(o => o.isOwner(account))) {
            await this.rotateOrgKeys(org);
        }
    }
    async rotateOrgKeys(org) {
        const account = this.account;
        return this.updateOrg(org.id, async (org) => {
            // Rotate org encryption key
            delete org.encryptedData;
            await org.updateAccessors([account]);
            // Rotate other cryptographic keys
            await org.generateKeys();
            org.invites = [];
            // Suspend members and create confirmation invites
            for (const member of org.members.filter(m => m.id !== account.id)) {
                member.role = _org__WEBPACK_IMPORTED_MODULE_5__.OrgRole.Suspended;
                const invite = new _invite__WEBPACK_IMPORTED_MODULE_3__.Invite(member.email, "confirm_membership");
                await invite.initialize(org, this.account);
                org.invites.push(invite);
            }
            // Update own membership
            await org.addOrUpdateMember({
                id: account.id,
                email: account.email,
                name: account.name,
                publicKey: account.publicKey,
                orgSignature: await account.signOrg(org),
                role: _org__WEBPACK_IMPORTED_MODULE_5__.OrgRole.Owner
            });
        });
    }
    canRememberMasterKey() {
        return (0,_platform__WEBPACK_IMPORTED_MODULE_12__.isKeyStoreAvailable)();
    }
    async rememberMasterKey() {
        if (!this.account || this.account.locked) {
            throw "App needs to be unlocked first";
        }
        const key = await (0,_platform__WEBPACK_IMPORTED_MODULE_12__.getCryptoProvider)().generateKey(new _crypto__WEBPACK_IMPORTED_MODULE_19__.AESKeyParams());
        await (0,_platform__WEBPACK_IMPORTED_MODULE_12__.keyStoreSet)("master_key_encryption_key", (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.bytesToBase64)(key));
        const container = new _container__WEBPACK_IMPORTED_MODULE_18__.SimpleContainer();
        await container.unlock(key);
        await container.setData(this.account.masterKey);
        this.setState({ rememberedMasterKey: container });
        await this.save();
    }
    async forgetMasterKey() {
        try {
            await (0,_platform__WEBPACK_IMPORTED_MODULE_12__.keyStoreDelete)("master_key_encryption_key");
        }
        catch (e) { }
        this.setState({ rememberedMasterKey: null });
        await this.save();
    }
    async unlockWithRememberedMasterKey() {
        const encryptedMasterKey = this.state.rememberedMasterKey;
        const key = (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.base64ToBytes)(await (0,_platform__WEBPACK_IMPORTED_MODULE_12__.keyStoreGet)("master_key_encryption_key"));
        await encryptedMasterKey.unlock(key);
        const masterKey = await encryptedMasterKey.getData();
        await this.unlockWithMasterKey(masterKey);
    }
    async unlockWithMasterKey(key) {
        await this.account.unlockWithMasterKey(key);
        await this._unlocked();
    }
    /**
     * ==================
     *  VAULT MANAGEMENT
     * ==================
     */
    /** Get the [[Vault]] with the given `id` */
    getVault(id) {
        return this.state.vaults.find(vault => vault.id === id);
    }
    /** Locally update the given `vault` object */
    putVault(vault) {
        this.setState({
            vaults: [...this.state.vaults.filter(v => v.id !== vault.id), vault]
        });
    }
    isMainVault(vault) {
        return vault && this.account && this.account.mainVault.id === vault.id;
    }
    /** Create a new [[Vault]] */
    async createVault(name, org, members = [], groups = []) {
        let vault = new _vault__WEBPACK_IMPORTED_MODULE_4__.Vault();
        vault.name = name;
        vault.org = { id: org.id, name: org.name };
        vault = await this.api.createVault(vault);
        await this.fetchOrg(org);
        await this.updateOrg(org.id, async (org) => {
            groups.forEach(({ name, readonly }) => {
                const group = org.getGroup(name);
                if (!group) {
                    setTimeout(() => {
                        throw `Group not found: ${name}`;
                    });
                    return;
                }
                group.vaults.push({ id: vault.id, readonly });
            });
            members.forEach(({ id, readonly }) => {
                const member = org.getMember({ id });
                if (!member) {
                    setTimeout(() => {
                        throw `Member not found: ${id}`;
                    });
                    return;
                }
                member.vaults.push({ id: vault.id, readonly });
            });
        });
        await this.synchronize();
        return vault;
    }
    /** Update [[Vault]] name and access (not the vaults contents) */
    async updateVaultAccess(
    /** Organization owning the vault */
    orgId, 
    /** The vault id */
    id, 
    /** The new vault name */
    name, 
    /** Organization members that should have access to the vault */
    members = [], 
    /** Groups that should have access to the vault */
    groups = []) {
        if (!members.length && !groups.length) {
            throw new Error("You have to assign at least one member or group!");
        }
        await this.updateOrg(orgId, async (org) => {
            // Update name (the name of the actual [[Vault]] name will be
            // updated in the background)
            org.vaults.find(v => v.id === id).name = name;
            // Update group access
            for (const group of org.groups) {
                // remove previous vault entry
                group.vaults = group.vaults.filter(v => v.id !== id);
                // update vault entry
                const selection = groups.find(g => g.name === group.name);
                if (selection) {
                    group.vaults.push({ id, readonly: selection.readonly });
                }
            }
            // Update member access
            for (const member of org.members) {
                // remove previous vault entry
                member.vaults = member.vaults.filter(v => v.id !== id);
                // update vault entry
                const selection = members.find(m => m.id === member.id);
                if (selection) {
                    member.vaults.push({ id, readonly: selection.readonly });
                }
            }
        });
        this.synchronize();
    }
    /** Commit changes to vault object and save locally */
    async saveVault(vault) {
        await vault.commit();
        this.putVault(vault);
        await this.save();
    }
    /** Delete [[Vault]] */
    async deleteVault(id) {
        await this.api.deleteVault(id);
        await this.synchronize();
    }
    /** Synchronize the given [[Vault]] */
    async syncVault(vault) {
        return this._queueSync(vault, (vault) => this._syncVault(vault));
    }
    /** Synchronize all vaults the current user has access to. */
    async syncVaults() {
        if (!this.account) {
            return;
        }
        // Sync private vault
        const promises = [this.syncVault(this.account.mainVault)];
        // Sync vaults assigned to through organizations
        for (const org of this.state.orgs) {
            // Sync all vaults for this organization
            for (const vault of org.getVaultsForMember(this.account)) {
                promises.push(this.syncVault(vault));
            }
        }
        // clean up vaults the user no longer has access to
        const removeVaults = new Set();
        for (const vault of this.state.vaults) {
            const org = vault.org && this.getOrg(vault.org.id);
            if (vault.id !== this.account.mainVault.id &&
                (!org || !org.vaults.find(v => v.id === vault.id) || !org.canRead(vault, this.account))) {
                removeVaults.add(vault.id);
            }
        }
        await this.setState({
            vaults: this.state.vaults.filter(v => !removeVaults.has(v.id))
        });
        await Promise.all(promises);
    }
    async fetchVault({ id, revision }) {
        if (!this.account) {
            console.error("need to be logged in to fetch vault!");
            return null;
        }
        let localVault = this.getVault(id);
        if (localVault && revision && localVault.revision === revision) {
            return localVault;
        }
        let remoteVault = null;
        let result;
        try {
            // Fetch and unlock remote vault
            remoteVault = await this.api.getVault(id);
        }
        catch (e) {
            if (localVault && e.code !== _error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.FAILED_CONNECTION) {
                localVault.error = e;
            }
        }
        if (!remoteVault) {
            return null;
        }
        try {
            await remoteVault.unlock(this.account);
        }
        catch (e) {
            if (localVault) {
                localVault.error = e;
                return localVault;
            }
            else {
                remoteVault.error = e;
                this.putVault(remoteVault);
                return remoteVault;
            }
        }
        // Merge changes
        if (localVault) {
            result = this.getVault(id);
            try {
                await result.unlock(this.account);
                result.merge(remoteVault);
            }
            catch (e) {
                result = remoteVault;
            }
        }
        else {
            result = remoteVault;
        }
        // Migrate favorites from "old" favoriting mechanism
        for (const item of result.items) {
            if (item.favorited && item.favorited.includes(this.account.id)) {
                this.account.favorites.add(item.id);
                item.favorited = item.favorited.filter(acc => acc !== this.account.id);
                result.items.update(item);
            }
        }
        await this.saveVault(result);
        return result;
    }
    async updateVault({ id }, tries = 0) {
        if (!this.account) {
            throw "need to be logged in to update vault!";
        }
        let vault = this.getVault(id);
        const org = vault.org && this.getOrg(vault.org.id);
        const accessors = (org ? org.getAccessors(vault) : [this.account]);
        const accessorsChanged = vault.accessors.length !== accessors.length ||
            accessors.some(a => vault.accessors.some(b => a.id !== b.id));
        if ((org && org.isSuspended(this.account)) || (!vault.items.hasChanges && !accessorsChanged)) {
            // No changes - skipping update
            return vault;
        }
        if (org && !org.canWrite(vault, this.account)) {
            // User does'nt have write access; dismiss changes and bail out;
            vault.items.clearChanges();
            return vault;
        }
        const updateStarted = new Date();
        vault = vault.clone();
        vault.items.clearChanges();
        await vault.commit();
        try {
            // // Make sure the organization revision matches the one the vault is based on
            if (vault.org && (!org || org.revision !== vault.org.revision)) {
                if (tries > 3) {
                    throw new _error__WEBPACK_IMPORTED_MODULE_15__.Err(_error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.OUTDATED_REVISION, (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Local changes to this vault could not be synchronized because there was a problem " +
                        "retrieving information for this vaults organization. If this problem persists " +
                        "please contact customer support!"));
                }
                // Get the latest organization and vault info, then try again
                await this.fetchOrg({ id: vault.org.id });
                await this.fetchVault({ id });
                return this.updateVault(vault, tries + 1);
            }
        }
        catch (e) {
            this.getVault(vault.id).error = e;
            return null;
        }
        // Update accessors
        if (org) {
            try {
                if (org.frozen) {
                    throw new _error__WEBPACK_IMPORTED_MODULE_15__.Err(_error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.ORG_FROZEN, (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Synching local changes failed because the organization this vault belongs to is frozen."));
                }
                if (!org.canWrite(vault, this.account)) {
                    throw new _error__WEBPACK_IMPORTED_MODULE_15__.Err(_error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.INSUFFICIENT_PERMISSIONS, (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Synching local changes failed because you don't have write permissions for this vault."));
                }
                // Look up which members should have access to this vault
                const accessors = org.getAccessors(vault);
                // Verify member details
                await this.account.verifyOrg(org);
                await org.verifyAll(accessors);
                // Update accessors
                await vault.updateAccessors(accessors);
            }
            catch (e) {
                this.getVault(vault.id).error = e;
                return null;
            }
        }
        else {
            await vault.updateAccessors([this.account]);
        }
        // Push updated vault object to [[Server]]
        try {
            vault = await this.api.updateVault(vault);
            await vault.unlock(this.account);
            const existing = this.getVault(vault.id);
            // Clear changes that happened before the sync started (retaining any changes made while
            // the sync was in progress)
            existing.items.clearChanges(updateStarted);
            // Merge changes back into existing vault (also updating revisision etc.)
            existing.merge(vault);
            // Comit changes and update local state
            await existing.commit();
            this.putVault(existing);
            if (org) {
                org.revision = vault.org.revision;
                org.vaults.find(v => v.id === vault.id).revision = vault.revision;
                this.putOrg(org);
                this.account.orgs.find(o => o.id === org.id).revision = org.revision;
            }
            else {
                this.account.mainVault.revision = vault.revision;
            }
            await this.save();
            return existing;
        }
        catch (e) {
            // The server will reject the update if the vault revision does
            // not match the current revision on the server, in which case we'll
            // have to fetch the current vault version and try again.
            if (e.code === _error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.OUTDATED_REVISION) {
                await this.fetchVault({ id });
                return this.updateVault({ id });
            }
            if (e.code !== _error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.FAILED_CONNECTION) {
                this.getVault(vault.id).error = e;
            }
            return vault;
        }
    }
    /** Whether the current user has write permissions to the given `vault`. */
    hasWritePermissions(vault) {
        // No organization means its the users private vault so they naturally have write access
        if (!vault.org) {
            return true;
        }
        const org = this.getOrg(vault.org.id);
        return org.canWrite(vault, this.account);
    }
    async _syncVault(vault) {
        await this.fetchVault(vault);
        return this.updateVault(vault);
    }
    /**
     * =======================
     *  Vault Item Management
     * =======================
     */
    /** Get the [[VaultItem]] and [[Vault]] for the given item `id` */
    getItem(id) {
        for (const vault of this.state.vaults) {
            const item = vault.items.get(id);
            if (item) {
                return { item, vault };
            }
        }
        return null;
    }
    /** Adds a number of `items` to the given `vault` */
    async addItems(items, { id }) {
        const vault = this.getVault(id);
        vault.items.update(...items);
        await this.saveVault(vault);
        this.syncVault(vault);
    }
    /** Creates a new [[VaultItem]] */
    async createItem(name, vault, fields, tags) {
        const item = await (0,_item__WEBPACK_IMPORTED_MODULE_6__.createVaultItem)(name || "", fields, tags);
        if (this.account) {
            item.updatedBy = this.account.id;
        }
        await this.addItems([item], vault);
        return item;
    }
    /** Update a given [[VaultItem]]s name, fields, tags and attachments */
    async updateItem(item, upd) {
        const { vault } = this.getItem(item.id);
        vault.items.update(new _item__WEBPACK_IMPORTED_MODULE_6__.VaultItem({ ...item, ...upd, updatedBy: this.account.id }));
        await this.saveVault(vault);
        await this.syncVault(vault);
    }
    async toggleFavorite(id, favorite) {
        await this.updateAccount(acc => acc.toggleFavorite(id, favorite));
    }
    async updateLastUsed(item) {
        this.state.lastUsed.set(item.id, new Date());
        this.publish();
    }
    /** Delete a number of `items` */
    async deleteItems(items) {
        const attachments = [];
        // Group items by vault
        const grouped = new Map();
        for (const item of items) {
            const { vault } = this.getItem(item.id);
            if (!grouped.has(vault)) {
                grouped.set(vault, []);
            }
            grouped.get(vault).push(item);
            attachments.push(...item.attachments);
        }
        const promises = [];
        // Delete all attachments for this item
        promises.push(...attachments.map(att => this.api.deleteAttachment(new _api__WEBPACK_IMPORTED_MODULE_10__.DeleteAttachmentParams(att))));
        // Remove items from their respective vaults
        for (const [vault, items] of grouped.entries()) {
            promises.push((async () => {
                vault.items.remove(...items);
                await this.saveVault(vault);
                await this.syncVault(vault);
            })());
        }
        await Promise.all(promises);
    }
    /** Move `items` from their current vault to the `target` vault */
    async moveItems(items, target) {
        if (items.some(item => !!item.attachments.length)) {
            throw "Items with attachments cannot be moved!";
        }
        const newItems = await Promise.all(items.map(async (item) => new _item__WEBPACK_IMPORTED_MODULE_6__.VaultItem({ ...item, id: await (0,_util__WEBPACK_IMPORTED_MODULE_13__.uuid)() })));
        await this.addItems(newItems, target);
        await this.deleteItems(items);
        return newItems;
    }
    getItemsForHost(host) {
        const items = [];
        for (const vault of this.vaults) {
            for (const item of vault.items) {
                if (item.fields.some(field => {
                    if (field.type !== "url") {
                        return false;
                    }
                    // Try to parse host from url. If field value is not a valid URL,
                    // assume its the bare host name
                    let h = field.value;
                    try {
                        h = new URL(field.value).host;
                    }
                    catch (e) { }
                    // If host doesn't match exactly, try with/without "www."
                    return h === host || (host.startsWith("www.") ? host.slice(4) === h : "www." + host === h);
                })) {
                    items.push({ vault, item });
                }
            }
        }
        return items;
    }
    getItemsForUrl(url) {
        try {
            const { host } = new URL(url);
            return this.getItemsForHost(host);
        }
        catch (e) {
            return [];
        }
    }
    /*
     * =========================
     *  ORGANIZATION MANAGEMENT
     * =========================
     */
    /** Get the organization with the given `id` */
    getOrg(id) {
        return this.state.orgs.find(org => org.id === id);
    }
    /** Update the given organization locally */
    putOrg(org) {
        this.setState({
            orgs: [...this.state.orgs.filter(v => v.id !== org.id), org]
        });
    }
    /** Create a new [[Org]]ganization */
    async createOrg(name, type = _org__WEBPACK_IMPORTED_MODULE_5__.OrgType.Business) {
        let org = new _org__WEBPACK_IMPORTED_MODULE_5__.Org();
        org.name = name;
        org.type = type;
        org = await this.api.createOrg(org);
        await org.initialize(this.account);
        org = await this.api.updateOrg(org);
        await this.fetchAccount();
        return this.fetchOrg(org);
    }
    /** Fetch all organizations the current account is a member of */
    async fetchOrgs() {
        if (!this.account) {
            return;
        }
        try {
            await Promise.all(this.account.orgs.map(org => this.fetchOrg(org)));
        }
        catch (e) { }
        // Remove orgs that the account is no longer a member of
        this.setState({ orgs: this.state.orgs.filter(org => this.account.orgs.some(o => o.id === org.id)) });
    }
    /** Fetch the [[Org]]anization object with the given `id` */
    async fetchOrg({ id, revision }) {
        const existing = this.getOrg(id);
        if (existing && existing.revision === revision) {
            return existing;
        }
        const org = await this.api.getOrg(id);
        // Verify that the updated organization object has a `minMemberUpdated`
        // property equal to or higher than the previous (local) one.
        if (existing && org.minMemberUpdated < existing.minMemberUpdated) {
            throw new _error__WEBPACK_IMPORTED_MODULE_15__.Err(_error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.VERIFICATION_ERROR, "'minMemberUpdated' property may not decrease!");
        }
        this.putOrg(org);
        await this.save();
        return org;
    }
    /**
     * Update the organization with the given `id`.
     *
     * @param transform Function applying the changes
     */
    async updateOrg(id, transform) {
        // Create a clone of the existing org object
        let org = this.getOrg(id).clone();
        // Apply changes
        await transform(org);
        try {
            org = await this.api.updateOrg(org);
        }
        catch (e) {
            // If organizaton has been updated since last fetch,
            // get the current version and then retry
            if (e.code === _error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.OUTDATED_REVISION) {
                await this.fetchOrg({ id });
                return this.updateOrg(id, transform);
            }
            else {
                throw e;
            }
        }
        // Update and save app state
        this.putOrg(org);
        await this.save();
        return org;
    }
    async deleteOrg(id) {
        await this.api.deleteOrg(id);
        await this.synchronize();
    }
    /** Creates a new [[Group]] in the given `org` */
    async createGroup(org, name, members) {
        const group = new _org__WEBPACK_IMPORTED_MODULE_5__.Group();
        group.name = name;
        group.members = members.map(({ id }) => ({ id }));
        await this.updateOrg(org.id, async (org) => {
            if (org.getGroup(name)) {
                throw "A group with this name already exists!";
            }
            org.groups.push(group);
        });
        return group;
    }
    /**
     * Updates a [[Group]]s name and members
     */
    async updateGroup(org, { name }, members, newName) {
        await this.updateOrg(org.id, async (org) => {
            const group = org.getGroup(name);
            if (!group) {
                throw "Group not found!";
            }
            if (newName && newName !== name && org.getGroup(newName)) {
                throw "Another group with this name already exists!";
            }
            if (newName) {
                group.name = newName;
            }
            group.members = members.map(({ id }) => ({ id }));
        });
    }
    /**
     * Update a members assigned [[Vault]]s, [[Group]]s and [[OrgRole]].
     */
    async updateMember(org, { id }, { vaults, groups, role }) {
        await this.updateOrg(org.id, async (org) => {
            const member = org.getMember({ id });
            // Update assigned vaults
            if (vaults) {
                member.vaults = vaults;
            }
            // Update assigned groups
            if (groups) {
                // Remove member from all groups
                for (const group of org.groups) {
                    group.members = group.members.filter(m => m.id !== id);
                }
                // Add them back to the assigned groups
                for (const name of groups) {
                    const group = org.getGroup(name);
                    group.members.push({ id });
                }
            }
            // Update member role
            if (role && member.role !== role) {
                await org.unlock(this.account);
                await org.addOrUpdateMember({ ...member, role });
            }
        });
        return this.getOrg(org.id).getMember({ id });
    }
    /**
     * Removes a member from the given `org`
     */
    async removeMember(org, member) {
        await this.updateOrg(org.id, async (org) => {
            await org.unlock(this.account);
            await org.removeMember(member);
        });
    }
    /*
     * ===================
     *  INVITE MANAGEMENT
     * ===================
     */
    /**
     * Create a new [[Invite]]
     */
    async createInvites({ id }, emails, purpose) {
        let invites = [];
        await this.updateOrg(id, async (org) => {
            await org.unlock(this.account);
            invites = [];
            for (const email of emails) {
                const invite = new _invite__WEBPACK_IMPORTED_MODULE_3__.Invite(email, purpose);
                await invite.initialize(org, this.account);
                invites.push(invite);
            }
            org.invites = [...org.invites.filter(a => !invites.some(b => a.email === b.email)), ...invites];
        });
        return invites;
    }
    /**
     * Get an [[Invite]] based on the organization id and invite id.
     */
    async getInvite(orgId, id) {
        let invite = null;
        try {
            invite = await this.api.getInvite(new _api__WEBPACK_IMPORTED_MODULE_10__.GetInviteParams({ org: orgId, id }));
        }
        catch (e) { }
        return invite;
    }
    /**
     * Accept an [[Invite]]
     *
     * @param secret The secret confirmation code, provided to the user by the organization owner
     */
    async acceptInvite(invite, secret) {
        const success = await invite.accept(this.account, secret);
        if (success) {
            await this.api.acceptInvite(invite);
        }
        return success;
    }
    /**
     * Confirm an [[Invite]] after it has been accepted by the invitee.
     * This will verify the invitees information and then add them to
     * the organization.
     *
     * @returns The newly created member object.
     */
    async confirmInvite(invite) {
        // Verify invitee information
        if (!(await invite.verifyInvitee())) {
            throw new _error__WEBPACK_IMPORTED_MODULE_15__.Err(_error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.VERIFICATION_ERROR, "Failed to verify invitee information!");
        }
        // Add member and update organization
        await this.updateOrg(invite.org.id, async (org) => {
            await org.unlock(this.account);
            await org.addOrUpdateMember(invite.invitee);
            org.removeInvite(invite);
        });
        return this.getOrg(invite.org.id).getMember({ id: invite.invitee.id });
    }
    /**
     * Deletes an [[Invite]]
     */
    async deleteInvite(invite) {
        await this.updateOrg(invite.org.id, async (org) => (org.invites = org.invites.filter(inv => inv.id !== invite.id)));
    }
    /**
     * =============
     *  ATTACHMENTS
     * =============
     */
    async createAttachment(itemId, file, name) {
        const { vault, item } = this.getItem(itemId);
        const att = new _attachment__WEBPACK_IMPORTED_MODULE_16__.Attachment({ vault: vault.id });
        await att.fromFile(file);
        if (name) {
            att.name = name;
        }
        const promise = this.api.createAttachment(att);
        att.uploadProgress = promise.progress;
        promise.then(id => {
            att.id = id;
            this.updateItem(item, { attachments: [...item.attachments, att.info] });
            promise.progress.complete();
        });
        return att;
    }
    async downloadAttachment(att) {
        const attachment = new _attachment__WEBPACK_IMPORTED_MODULE_16__.Attachment(att);
        const promise = this.api.getAttachment(new _api__WEBPACK_IMPORTED_MODULE_10__.GetAttachmentParams({ id: att.id, vault: att.vault }));
        attachment.downloadProgress = promise.progress;
        promise.then(att => {
            attachment.fromRaw(att.toRaw());
            attachment.type = att.type;
            attachment.name = att.name;
            promise.progress.complete();
        });
        return attachment;
    }
    async deleteAttachment(itemId, att) {
        const { item } = this.getItem(itemId);
        try {
            await this.api.deleteAttachment(new _api__WEBPACK_IMPORTED_MODULE_10__.DeleteAttachmentParams(att));
        }
        catch (e) {
            if (e.code !== _error__WEBPACK_IMPORTED_MODULE_15__.ErrorCode.NOT_FOUND) {
                throw e;
            }
        }
        await this.updateItem(item, { attachments: item.attachments.filter(a => a.id !== att.id) });
    }
    /**
     * =========
     *  BILLING
     * =========
     */
    async updateBilling(params) {
        params.provider = (this.state.billingProvider && this.state.billingProvider.type) || "";
        await this.api.updateBilling(params);
        params.org ? await this.fetchOrg({ id: params.org }) : await this.fetchAccount();
    }
    async loadBillingProvider() {
        const providers = await this.api.getBillingProviders();
        this.setState({ billingProvider: providers[0] || null });
    }
    getItemsQuota(vault = this.mainVault) {
        return this.isMainVault(vault) && !this.orgs.some(org => !org.frozen) ? this.account.quota.items : -1;
    }
    /**
     * ================
     *  HELPER METHODS
     * ================
     */
    async _queueSync(obj, fn) {
        let queued = this._queuedSyncPromises.get(obj.id);
        let active = this._activeSyncPromises.get(obj.id);
        if (queued) {
            // There is already a queued sync promise, so just return that one
            return queued;
        }
        if (active) {
            // There is already a synchronization in process. wait for the current sync to finish
            // before starting a new one.
            const next = () => {
                this._queuedSyncPromises.delete(obj.id);
                return this._queueSync(obj, fn);
            };
            queued = active.then(next, next);
            this._queuedSyncPromises.set(obj.id, queued);
            return queued;
        }
        active = fn(obj).then((result) => {
            this._activeSyncPromises.delete(obj.id);
            this.setState({ syncing: !!this._activeSyncPromises.size });
            return result;
        }, e => {
            this._activeSyncPromises.delete(obj.id);
            this.setState({ syncing: !!this._activeSyncPromises.size });
            throw e;
        });
        this._activeSyncPromises.set(obj.id, active);
        this.setState({ syncing: !!this._activeSyncPromises.size });
        return active;
    }
    async _unlocked() {
        // Unlock all vaults
        await Promise.all(this.state.vaults.map(async (vault) => {
            try {
                await vault.unlock(this.account);
            }
            catch (e) {
                vault.error = e;
            }
        }));
        // Notify state change
        this.publish();
        // Trigger sync
        this.synchronize();
    }
}


/***/ }),

/***/ "../core/src/attachment.ts":
/*!*********************************!*\
  !*** ../core/src/attachment.ts ***!
  \*********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AttachmentInfo": () => (/* binding */ AttachmentInfo),
/* harmony export */   "Attachment": () => (/* binding */ Attachment),
/* harmony export */   "MemoryAttachmentStorage": () => (/* binding */ MemoryAttachmentStorage)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




function readFile(blob) {
    return new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onload = () => {
            const result = new Uint8Array(reader.result);
            resolve(result);
        };
        reader.onerror = e => {
            reader.abort();
            reject(e);
        };
        reader.readAsArrayBuffer(blob);
    });
}
function readAsText(blob) {
    return new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onload = () => {
            resolve(reader.result);
        };
        reader.onerror = e => {
            reader.abort();
            reject(e);
        };
        reader.readAsText(blob);
    });
}
function readFileAsDataURL(blob) {
    return new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onload = () => {
            resolve(reader.result);
        };
        reader.onerror = e => {
            reader.abort();
            reject(e);
        };
        reader.readAsDataURL(blob);
    });
}
class AttachmentInfo extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(vals = {}) {
        super();
        this.id = "";
        this.vault = "";
        this.name = "";
        this.size = 0;
        this.type = "";
        Object.assign(this, vals);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], AttachmentInfo.prototype, "key", void 0);
class Attachment extends _container__WEBPACK_IMPORTED_MODULE_1__.SimpleContainer {
    constructor({ key, ...info } = {}) {
        super();
        this.id = "";
        this.vault = "";
        this.name = "";
        this.size = 0;
        this.type = "";
        Object.assign(this, {
            _key: key,
            ...info
        });
    }
    get info() {
        return new AttachmentInfo({
            id: this.id,
            vault: this.vault,
            name: this.name,
            type: this.type,
            size: this.size,
            key: this._key
        });
    }
    get loaded() {
        return !!this.encryptedData;
    }
    async fromFile(file) {
        this.type = file.type;
        this.size = file.size;
        this.name = file.name;
        const data = await readFile(file);
        this._key = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().generateKey({
            algorithm: "AES",
            keySize: this.encryptionParams.keySize
        });
        await this.setData(data);
        return this;
    }
    async toFile() {
        const data = await this.getData();
        return new File([data], this.name, { type: this.type });
    }
    async toDataURL() {
        const file = await this.toFile();
        return readFileAsDataURL(file);
    }
    async toObjectURL() {
        const file = await this.toFile();
        return URL.createObjectURL(file);
    }
    async toText() {
        const file = await this.toFile();
        return readAsText(file);
    }
    validate() {
        return typeof this.id === "string" && typeof this.vault === "string" && typeof this.size === "number";
    }
}
class MemoryAttachmentStorage {
    constructor() {
        this._storage = new Map();
    }
    async put(a) {
        this._storage.set(`${a.vault}_${a.id}`, a);
    }
    async get(vault, id) {
        const att = this._storage.get(`${vault}_${id}`);
        if (!att) {
            throw new _error__WEBPACK_IMPORTED_MODULE_3__.Err(_error__WEBPACK_IMPORTED_MODULE_3__.ErrorCode.NOT_FOUND);
        }
        return att;
    }
    async delete(vault, id) {
        this._storage.delete(`${vault}_${id}`);
    }
    async deleteAll(vault) {
        for (const key of this._storage.keys()) {
            if (key.startsWith(vault)) {
                this._storage.delete(key);
            }
        }
    }
    async getUsage(vault) {
        let size = 0;
        for (const [key, att] of this._storage.entries()) {
            if (key.startsWith(vault)) {
                size += att.size;
            }
        }
        return size;
    }
}


/***/ }),

/***/ "../core/src/auth.ts":
/*!***************************!*\
  !*** ../core/src/auth.ts ***!
  \***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Auth": () => (/* binding */ Auth)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




/**
 * Contains authentication data needed for SRP session negotiation
 */
class Auth extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(email = "") {
        super();
        this.email = email;
        /** Id of the [[Account]] the authentication data belongs to */
        this.account = "";
        /**
         * Key derivation params used by the client to compute session key from the
         * users master password
         * */
        this.keyParams = new _crypto__WEBPACK_IMPORTED_MODULE_1__.PBKDF2Params();
        this.trustedDevices = [];
    }
    get id() {
        return this.email;
    }
    /**
     * Generate the session key from the users master `password`
     */
    async getAuthKey(password) {
        // If no salt is set yet (i.e. during initialization),
        // generate a random value
        if (!this.keyParams.salt.length) {
            this.keyParams.salt = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().randomBytes(16);
        }
        return (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().deriveKey((0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(password), this.keyParams);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], Auth.prototype, "verifier", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_1__.PBKDF2Params),
    __metadata("design:type", Object)
], Auth.prototype, "keyParams", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_platform__WEBPACK_IMPORTED_MODULE_2__.DeviceInfo),
    __metadata("design:type", Array)
], Auth.prototype, "trustedDevices", void 0);


/***/ }),

/***/ "../core/src/billing.ts":
/*!******************************!*\
  !*** ../core/src/billing.ts ***!
  \******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "PlanType": () => (/* binding */ PlanType),
/* harmony export */   "Plan": () => (/* binding */ Plan),
/* harmony export */   "PaymentMethod": () => (/* binding */ PaymentMethod),
/* harmony export */   "SubscriptionStatus": () => (/* binding */ SubscriptionStatus),
/* harmony export */   "Subscription": () => (/* binding */ Subscription),
/* harmony export */   "BillingAddress": () => (/* binding */ BillingAddress),
/* harmony export */   "Discount": () => (/* binding */ Discount),
/* harmony export */   "BillingInfo": () => (/* binding */ BillingInfo),
/* harmony export */   "UpdateBillingParams": () => (/* binding */ UpdateBillingParams),
/* harmony export */   "BillingProviderInfo": () => (/* binding */ BillingProviderInfo)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};

var PlanType;
(function (PlanType) {
    PlanType[PlanType["Free"] = 0] = "Free";
    PlanType[PlanType["Premium"] = 1] = "Premium";
    PlanType[PlanType["Family"] = 2] = "Family";
    PlanType[PlanType["Team"] = 3] = "Team";
    PlanType[PlanType["Business"] = 4] = "Business";
})(PlanType || (PlanType = {}));
class Plan extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.id = "";
        this.type = PlanType.Free;
        this.name = "Free";
        this.description = "";
        this.items = -1;
        this.storage = 0;
        this.groups = 0;
        this.vaults = 0;
        this.min = 0;
        this.max = 0;
        this.available = false;
        this.cost = 0;
        this.features = [];
        this.default = false;
        this.color = "";
    }
}
class PaymentMethod extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.id = "";
        this.name = "";
    }
}
var SubscriptionStatus;
(function (SubscriptionStatus) {
    SubscriptionStatus["Trialing"] = "trialing";
    SubscriptionStatus["Active"] = "active";
    SubscriptionStatus["Inactive"] = "inactive";
    SubscriptionStatus["Canceled"] = "canceled";
})(SubscriptionStatus || (SubscriptionStatus = {}));
class Subscription extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.id = "";
        this.account = "";
        this.org = "";
        this.status = SubscriptionStatus.Active;
        this.items = -1;
        this.storage = 0;
        this.groups = 0;
        this.vaults = 0;
        this.members = 0;
        this.paymentError = undefined;
        this.paymentRequiresAuth = undefined;
        this.currentInvoice = "";
        this.periodEnd = new Date(0);
        this.plan = new Plan();
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Date)
], Subscription.prototype, "periodEnd", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Date)
], Subscription.prototype, "trialEnd", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(Plan),
    __metadata("design:type", Plan)
], Subscription.prototype, "plan", void 0);
class BillingAddress extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(params) {
        super();
        this.name = "";
        this.street = "";
        this.postalCode = "";
        this.city = "";
        this.country = "";
        if (params) {
            Object.assign(this, params);
        }
    }
}
class Discount extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.name = "";
        this.coupon = "";
    }
}
class BillingInfo extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.customerId = "";
        this.account = "";
        this.org = "";
        this.email = "";
        this.subscription = null;
        this.paymentMethod = null;
        this.address = new BillingAddress();
        this.discount = null;
    }
    get trialDaysLeft() {
        const daysSinceFirstTrial = this.firstTrialStarted
            ? Math.floor((Date.now() - this.firstTrialStarted.getTime()) / 24 / 60 / 60 / 1000)
            : 0;
        return Math.max(0, 30 - daysSinceFirstTrial);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(Subscription),
    __metadata("design:type", Object)
], BillingInfo.prototype, "subscription", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(PaymentMethod),
    __metadata("design:type", Object)
], BillingInfo.prototype, "paymentMethod", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(BillingAddress),
    __metadata("design:type", BillingAddress)
], BillingInfo.prototype, "address", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(Discount),
    __metadata("design:type", Object)
], BillingInfo.prototype, "discount", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Date)
], BillingInfo.prototype, "firstTrialStarted", void 0);
class UpdateBillingParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(params) {
        super();
        this.provider = "";
        this.account = undefined;
        this.org = undefined;
        this.email = undefined;
        this.plan = undefined;
        this.planType = undefined;
        this.members = undefined;
        this.paymentMethod = undefined;
        this.coupon = undefined;
        this.cancel = undefined;
        if (params) {
            Object.assign(this, params);
        }
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(BillingAddress),
    __metadata("design:type", BillingAddress)
], UpdateBillingParams.prototype, "address", void 0);
class BillingProviderInfo extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.type = "";
        this.config = {};
        this.plans = [];
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(Plan),
    __metadata("design:type", Array)
], BillingProviderInfo.prototype, "plans", void 0);
//
// const stubPlans: Plan[] = [
//     {
//         id: "personal",
//         name: "Personal",
//         description: "Basic Setup For Personal Use",
//         storage: -1,
//         available: true,
//         default: true
//     },
//     {
//         id: "shared",
//         name: "Shared",
//         description: "Basic Setup For Sharing",
//         storage: -1,
//         vaults: -1,
//         available: true,
//         orgType: 1
//     },
//     {
//         id: "advanced",
//         name: "Advanced",
//         description: "Advanced Setup For Sharing",
//         storage: -1,
//         groups: -1,
//         vaults: -1,
//         available: true,
//         orgType: 2
//     }
// ].map(p => {
//     const plan = new Plan();
//     Object.assign(plan, p);
//     return plan;
// });


/***/ }),

/***/ "../core/src/client.ts":
/*!*****************************!*\
  !*** ../core/src/client.ts ***!
  \*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Client": () => (/* binding */ Client)
/* harmony export */ });
/* harmony import */ var _api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./api */ "../core/src/api.ts");
/* harmony import */ var _transport__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./transport */ "../core/src/transport.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");




/**
 * Client-side interface for Client-Server communication. Manages serialization,
 * authentication and some state like current session and account.
 */
class Client extends _api__WEBPACK_IMPORTED_MODULE_0__.API {
    constructor(
    /** Object for storing state */
    state, 
    /** [[Sender]] implementation used for sending/receiving requests */
    sender, hook) {
        super();
        this.state = state;
        this.sender = sender;
        this.hook = hook;
        this.online = true;
        for (const { method, output } of this.handlerDefinitions) {
            this[method] = (input) => {
                const progress = new _transport__WEBPACK_IMPORTED_MODULE_1__.RequestProgress();
                const promise = this.call(method, typeof input === "undefined" ? [] : [input instanceof _encoding__WEBPACK_IMPORTED_MODULE_3__.Serializable ? input.toRaw() : input], progress).then(res => {
                    return output
                        ? Array.isArray(res.result)
                            ? res.result.map(each => new output().fromRaw(each))
                            : new output().fromRaw(res.result)
                        : res.result;
                });
                promise.progress = progress;
                return promise;
            };
        }
    }
    /** The current session */
    get session() {
        return this.state.session;
    }
    /** Generic method for making an RPC call */
    async call(method, params, progress) {
        const { session } = this.state;
        const req = new _transport__WEBPACK_IMPORTED_MODULE_1__.Request();
        req.method = method;
        req.params = params;
        req.device = this.state.device;
        if (session) {
            await session.authenticate(req);
        }
        let res;
        try {
            res = await this.sender.send(req, progress);
        }
        catch (e) {
            if (progress) {
                progress.error = e;
            }
            this.hook && this.hook(req, null, e);
            throw e;
        }
        if (res.error) {
            const err = new _error__WEBPACK_IMPORTED_MODULE_2__.Err(res.error.code, res.error.message);
            if (progress) {
                progress.error = err;
            }
            this.hook && this.hook(req, res, err);
            throw err;
        }
        if (session && !(await session.verify(res))) {
            const err = new _error__WEBPACK_IMPORTED_MODULE_2__.Err(_error__WEBPACK_IMPORTED_MODULE_2__.ErrorCode.INVALID_RESPONSE);
            if (progress) {
                progress.error = err;
            }
            this.hook && this.hook(req, res, err);
            throw err;
        }
        this.hook && this.hook(req, res, null);
        return res;
    }
}


/***/ }),

/***/ "../core/src/collection.ts":
/*!*********************************!*\
  !*** ../core/src/collection.ts ***!
  \*********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "VaultItemCollection": () => (/* binding */ VaultItemCollection)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _item__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./item */ "../core/src/item.ts");


/**
 * A collection of vault items items, used for consolidating changes made independently
 * across multiple instances through "merging".
 */
class VaultItemCollection extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(items = []) {
        super();
        this._changes = new Map();
        this._items = new Map(items.map(item => [item.id, item]));
    }
    /** Number of items in this VaultItemCollection */
    get size() {
        return this._items.size;
    }
    get hasChanges() {
        return !!this._changes.size;
    }
    /** Aggregated list of tags assigned to the items in this collection */
    get tags() {
        const tags = new Set();
        for (const r of this) {
            for (const t of r.tags) {
                tags.add(t);
            }
        }
        return [...tags];
    }
    /** Get an item with a given `id` */
    get(id) {
        return this._items.get(id) || null;
    }
    /**
     * Updates one or more items based on their id. If no item with the same id
     * exists, the item will be added to the collection
     */
    update(...items) {
        for (const item of items) {
            item.updated = new Date();
            this._items.set(item.id, item);
            this._changes.set(item.id, item.updated);
        }
    }
    /**
     * Removes one or more items based on their id.
     */
    remove(...items) {
        for (const item of items) {
            this._items.delete(item.id);
            this._changes.set(item.id, new Date());
        }
    }
    /**
     * Merges in changes from another [[VaultItemCollection]] instance.
     */
    merge(coll) {
        // Delete any items from this collection that don't
        // exist in the other collection and haven't been changed recently
        for (const item of this) {
            if (!this._changes.has(item.id) && !coll.get(item.id)) {
                this._items.delete(item.id);
            }
        }
        // Get changes items from other collection (but only if they haven't recently changed locally)
        for (const item of coll) {
            if (!this._changes.has(item.id)) {
                this._items.set(item.id, item);
            }
        }
    }
    clearChanges(before) {
        for (const [id, changed] of this._changes.entries()) {
            if (!before || changed <= before) {
                this._changes.delete(id);
            }
        }
    }
    _toRaw(version) {
        return {
            items: Array.from(this).map(item => item.toRaw(version)),
            changes: [...this._changes]
        };
    }
    _fromRaw({ items, changes }) {
        this._items = new Map(items.map((item) => [item.id, new _item__WEBPACK_IMPORTED_MODULE_1__.VaultItem().fromRaw(item)]));
        this._changes = new Map(changes && changes.map(([id, date]) => [id, new Date(date)]));
    }
    [Symbol.iterator]() {
        return this._items.values();
    }
}


/***/ }),

/***/ "../core/src/container.ts":
/*!********************************!*\
  !*** ../core/src/container.ts ***!
  \********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "BaseContainer": () => (/* binding */ BaseContainer),
/* harmony export */   "SimpleContainer": () => (/* binding */ SimpleContainer),
/* harmony export */   "PBES2Container": () => (/* binding */ PBES2Container),
/* harmony export */   "Accessor": () => (/* binding */ Accessor),
/* harmony export */   "SharedContainer": () => (/* binding */ SharedContainer)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




/**
 * Base class for all **Container** implementations. In general, a **Container** is
 * an object for holding data encrypted using a symmetric cipher. Implementations
 * vary mostly in how the encryption key is generated. Sub classes must implement
 * the [[unlock]] method and may likely also want to augment [[lock]], [[validate]],
 * [[_fromRaw]] and [[_toRaw]].
 */
class BaseContainer extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        /** Parameters used for encryption of content data */
        this.encryptionParams = new _crypto__WEBPACK_IMPORTED_MODULE_2__.AESEncryptionParams();
    }
    /**
     * Encrypts the provided `data` and stores it in the container
     */
    async setData(data) {
        if (!this._key) {
            throw new _error__WEBPACK_IMPORTED_MODULE_1__.Err(_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.ENCRYPTION_FAILED, "No encryption key provided!");
        }
        // Generate random initialization vector
        this.encryptionParams.iv = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().randomBytes(16);
        // Generate additional authenticated data.
        // Note: Without knowing anything about the nature of the encrypted data,
        // we can't really choose a meaningful value for this. In the future,
        // we may want to provide the option to pass this as an argument but for now
        // a random value should be sufficient.
        this.encryptionParams.additionalData = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().randomBytes(16);
        // Encrypt the data and store it.
        this.encryptedData = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().encrypt(this._key, data, this.encryptionParams);
    }
    /**
     * Decrypts and extracts the plain text data from the container. This will
     * usually require unlocking the container first.
     */
    async getData() {
        if (!this.encryptedData || !this._key) {
            throw new _error__WEBPACK_IMPORTED_MODULE_1__.Err(_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.DECRYPTION_FAILED);
        }
        return await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().decrypt(this._key, this.encryptedData, this.encryptionParams);
    }
    /**
     * Locks the container, removing the possibility to extract the plain text data
     * via [[getData]] until the container is unlocked again. Subclasses extending
     * this class must take care to delete any keys or other sensitive data
     * that may have been stored temporarily after unlocking the container.
     */
    lock() {
        delete this._key;
    }
    clone() {
        const clone = super.clone();
        clone._key = this._key;
        return clone;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_2__.AESEncryptionParams),
    __metadata("design:type", _crypto__WEBPACK_IMPORTED_MODULE_2__.AESEncryptionParams)
], BaseContainer.prototype, "encryptionParams", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], BaseContainer.prototype, "encryptedData", void 0);
/**
 * Most basic **Container** implementation where the encryption key is
 * simply passed explicitly.
 */
class SimpleContainer extends BaseContainer {
    async unlock(key) {
        this._key = key;
    }
}
/**
 * Password-based **Container** that uses the
 * [PBES2](https://tools.ietf.org/html/rfc2898#section-6.2) encryption scheme,
 * deriving the encryption key from a user-provided passphrase.
 */
class PBES2Container extends BaseContainer {
    constructor() {
        super(...arguments);
        /** Parameters used for key derivation */
        this.keyParams = new _crypto__WEBPACK_IMPORTED_MODULE_2__.PBKDF2Params();
    }
    /**
     * Unlocks the container using the given **password**
     */
    async unlock(password) {
        if (!this.keyParams.salt.length) {
            this.keyParams.salt = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().randomBytes(16);
        }
        this._key = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().deriveKey((0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(password), this.keyParams);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_2__.PBKDF2Params),
    __metadata("design:type", _crypto__WEBPACK_IMPORTED_MODULE_2__.PBKDF2Params)
], PBES2Container.prototype, "keyParams", void 0);
/**
 * Represents an individual with access to a [[SharedContainer]]. Each accessor is mapped
 * to an entity owning a public/private key pair via their `id`.
 */
class Accessor extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        /**
         * Identifier used to map an `Accessor` to the owner of the public key used to encrypt the shared key.
         */
        this.id = "";
        /** Shared key encrypted with the public key of the entity associated with the `Accessor` object */
        this.encryptedKey = new Uint8Array();
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], Accessor.prototype, "encryptedKey", void 0);
/**
 * The `SharedContainer` is used to securely share data between a number of
 * accessors using a shared-key encryption scheme where the content data is
 * encrypted using a randomly generated shared key that is then encrypted with
 * each accessors public key and stored along the encrypted data. Accessors can
 * then retrieve the shared key by decrypting it using their private key and
 * use it to recover the original data.
 */
class SharedContainer extends BaseContainer {
    constructor() {
        super(...arguments);
        /** Parameters used to wrap the shared encryption key */
        this.keyParams = new _crypto__WEBPACK_IMPORTED_MODULE_2__.RSAEncryptionParams();
        /** The ids and encrypted keys of all accessors */
        this.accessors = [];
    }
    /**
     * Unlocks the container using the id and private key of a given accessor.
     * The id is used to look up the corresponding encrypted key while the
     * private key is used to decrypt it.
     */
    async unlock({ id, privateKey }) {
        if (this._key) {
            // Container is already unlocked, no need to unlock it again
            return;
        }
        // Find accessor object with the same id
        const accessor = this.accessors.find(a => a.id === id);
        if (!accessor || !accessor.encryptedKey) {
            // No corresponding accessor found.
            throw new _error__WEBPACK_IMPORTED_MODULE_1__.Err(_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.MISSING_ACCESS, "You no longer have access to this vault.");
        }
        // Decrypt shared key using provided private key
        this._key = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().decrypt(privateKey, accessor.encryptedKey, this.keyParams);
    }
    /**
     * Updates the containers accessors, generating a new shared key and encrypting
     * it with the public keys of the provided **subjects**. Non-empty containers
     * need to be unlocked first.
     */
    async updateAccessors(subjects) {
        // Get existing data so we can reencrypt it after rotating the key
        let data = null;
        // If the container already contains data, we need to reencrypt it after generating a new key
        if (this.encryptedData) {
            if (!this._key) {
                throw "Non-empty containers need to be unlocked before accessors can be updated!";
            }
            data = await this.getData();
        }
        // Updating the accessors also requires generating a new shared key
        this._key = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().generateKey(new _crypto__WEBPACK_IMPORTED_MODULE_2__.AESKeyParams());
        // Reencrypt data with new key
        if (data) {
            await this.setData(data);
        }
        // Encrypt the shared key with the public key of each accessor and store it along with their id
        this.accessors = await Promise.all(subjects.map(async ({ id, publicKey }) => {
            const accessor = new Accessor();
            accessor.id = id;
            accessor.encryptedKey = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().encrypt(publicKey, this._key, this.keyParams);
            return accessor;
        }));
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_2__.RSAEncryptionParams),
    __metadata("design:type", _crypto__WEBPACK_IMPORTED_MODULE_2__.RSAEncryptionParams)
], SharedContainer.prototype, "keyParams", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(Accessor),
    __metadata("design:type", Array)
], SharedContainer.prototype, "accessors", void 0);


/***/ }),

/***/ "../core/src/crypto.ts":
/*!*****************************!*\
  !*** ../core/src/crypto.ts ***!
  \*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "PBKDF2_ITER_DEFAULT": () => (/* binding */ PBKDF2_ITER_DEFAULT),
/* harmony export */   "PBKDF2_ITER_MAX": () => (/* binding */ PBKDF2_ITER_MAX),
/* harmony export */   "AESEncryptionParams": () => (/* binding */ AESEncryptionParams),
/* harmony export */   "AESKeyParams": () => (/* binding */ AESKeyParams),
/* harmony export */   "HMACKeyParams": () => (/* binding */ HMACKeyParams),
/* harmony export */   "RSAKeyParams": () => (/* binding */ RSAKeyParams),
/* harmony export */   "PBKDF2Params": () => (/* binding */ PBKDF2Params),
/* harmony export */   "RSAEncryptionParams": () => (/* binding */ RSAEncryptionParams),
/* harmony export */   "RSASigningParams": () => (/* binding */ RSASigningParams),
/* harmony export */   "HMACParams": () => (/* binding */ HMACParams),
/* harmony export */   "HashParams": () => (/* binding */ HashParams)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};

// Default number of pbkdf2 iterations
const PBKDF2_ITER_DEFAULT = 5e4;
// Maximum number of pbkdf2 iterations
const PBKDF2_ITER_MAX = 1e7;
class AESEncryptionParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.algorithm = "AES-GCM";
        this.tagSize = 128;
        this.keySize = 256;
        this.iv = new Uint8Array();
        this.additionalData = new Uint8Array();
    }
    validate() {
        return (["AES-GCM", "AES-CCM"].includes(this.algorithm) &&
            [64, 96, 128].includes(this.tagSize) &&
            [256].includes(this.keySize));
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], AESEncryptionParams.prototype, "iv", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Object)
], AESEncryptionParams.prototype, "additionalData", void 0);
class AESKeyParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.algorithm = "AES";
        this.keySize = 256;
    }
    validate() {
        return this.algorithm === "AES" && this.keySize === 256;
    }
}
class HMACKeyParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.algorithm = "HMAC";
        this.keySize = 256;
    }
    validate() {
        return this.algorithm === "HMAC" && this.keySize === 256;
    }
}
class RSAKeyParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.algorithm = "RSA";
        this.modulusLength = 2048;
        this.hash = "SHA-256";
        this.publicExponent = new Uint8Array([0x01, 0x00, 0x01]);
    }
    validate() {
        return (this.algorithm === "RSA" &&
            this.modulusLength === 2048 &&
            this.hash === "SHA-256" &&
            this.publicExponent instanceof Uint8Array);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], RSAKeyParams.prototype, "publicExponent", void 0);
class PBKDF2Params extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(props) {
        super();
        this.algorithm = "PBKDF2";
        this.hash = "SHA-256";
        this.keySize = 256;
        this.iterations = PBKDF2_ITER_DEFAULT;
        this.salt = new Uint8Array();
        props && Object.assign(this, props);
    }
    validate() {
        return (this.algorithm === "PBKDF2" &&
            this.hash === "SHA-256" &&
            this.keySize === 256 &&
            typeof this.iterations === "number" &&
            this.iterations < PBKDF2_ITER_MAX &&
            this.salt instanceof Uint8Array);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], PBKDF2Params.prototype, "salt", void 0);
class RSAEncryptionParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.algorithm = "RSA-OAEP";
        this.hash = "SHA-256";
    }
    validate() {
        return this.algorithm === "RSA-OAEP" && this.hash === "SHA-256";
    }
}
class RSASigningParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        this.algorithm = "RSA-PSS";
        this.hash = "SHA-256";
        this.saltLength = 32;
    }
    validate() {
        return this.algorithm === "RSA-PSS" && this.hash === "SHA-256" && this.saltLength === 32;
    }
}
class HMACParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(props) {
        super();
        this.algorithm = "HMAC";
        this.hash = "SHA-256";
        this.keySize = 256;
        props && Object.assign(this, props);
    }
    validate() {
        return this.algorithm === "HMAC" && this.hash === "SHA-256" && this.keySize === 256;
    }
}
class HashParams extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(props) {
        super();
        this.algorithm = "SHA-256";
        props && Object.assign(this, props);
    }
    validate() {
        return ["SHA-1", "SHA-256"].includes(this.algorithm);
    }
}


/***/ }),

/***/ "../core/src/diceware.ts":
/*!*******************************!*\
  !*** ../core/src/diceware.ts ***!
  \*******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AVAILABLE_LANGUAGES": () => (/* reexport safe */ _padloc_locale_src_wordlists__WEBPACK_IMPORTED_MODULE_0__.AVAILABLE_LANGUAGES),
/* harmony export */   "generatePassphrase": () => (/* binding */ generatePassphrase)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_wordlists__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/wordlists */ "../locale/src/wordlists.ts");
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util */ "../core/src/util.ts");



/**
 * Generates a passphrase consisting of a number of words randomly selected
 * from a word list. Motivated by http://world.std.com/~reinhold/diceware.html
 */
async function generatePassphrase(nWords = 4, separator = "-", languages = ["en"]) {
    const words = [];
    const list = [];
    for (const lang of languages) {
        list.push(...(await (0,_padloc_locale_src_wordlists__WEBPACK_IMPORTED_MODULE_0__.getWordList)(lang)));
    }
    // Fall back to englisch if no word lists were found for provided languages
    if (!list.length) {
        list.push(...(await (0,_padloc_locale_src_wordlists__WEBPACK_IMPORTED_MODULE_0__.getWordList)("en")));
    }
    for (let i = 0; i < nWords; i++) {
        words.push(list[await (0,_util__WEBPACK_IMPORTED_MODULE_1__.randomNumber)(0, list.length - 1)]);
    }
    return words.join(separator);
}


/***/ }),

/***/ "../core/src/event-target.ts":
/*!***********************************!*\
  !*** ../core/src/event-target.ts ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "EventEmitter": () => (/* binding */ EventEmitter)
/* harmony export */ });
class EventEmitter {
    constructor() {
        this._listeners = new Map();
    }
    addEventListener(eventName, listener) {
        if (!this._listeners.has(eventName)) {
            this._listeners.set(eventName, new Set());
        }
        this._listeners.get(eventName).add(listener);
    }
    removeEventListener(eventName, listener) {
        const listeners = this._listeners.get(eventName);
        if (listeners) {
            listeners.delete(listener);
        }
    }
    dispatchEvent(e) {
        const listeners = this._listeners.get(e.type);
        if (listeners) {
            for (const listener of listeners) {
                if (typeof listener === "function") {
                    listener(e);
                }
                else {
                    listener.handle(e);
                }
            }
        }
    }
    dispatch(type, detail) {
        this.dispatchEvent({ type, detail });
    }
}


/***/ }),

/***/ "../core/src/invite.ts":
/*!*****************************!*\
  !*** ../core/src/invite.ts ***!
  \*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Invite": () => (/* binding */ Invite)
/* harmony export */ });
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ "../core/src/util.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};






class OrgInfo extends _encoding__WEBPACK_IMPORTED_MODULE_3__.Serializable {
    constructor(vals) {
        super();
        this.id = "";
        this.name = "";
        Object.assign(this, vals);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], OrgInfo.prototype, "publicKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], OrgInfo.prototype, "signature", void 0);
class InviteeInfo extends _encoding__WEBPACK_IMPORTED_MODULE_3__.Serializable {
    constructor(vals) {
        super();
        this.id = "";
        this.name = "";
        this.email = "";
        Object.assign(this, vals);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], InviteeInfo.prototype, "publicKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], InviteeInfo.prototype, "signature", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], InviteeInfo.prototype, "orgSignature", void 0);
/**
 * The `Invite` class encapsules most of the logic and information necessary to
 * perform a key exchange between an [[Org]] and [[Account]] before adding the
 * [[Account]] as a member. A secret HMAC key is used to sign and verify the public keys
 * of both invitee and organization. This key is derived from a [[secret]], which
 * needs to be communicated between the organization owner and invitee directly.
 *
 * The invite flow generally works as follows:
 *
 * ```ts
 * // ORG OWNER
 *
 * const invite = new Invite("bob@example.com", "add_member");
 *
 * // Generates random secret and signs organization details
 * await invite.intialize(org, orgOwnerAccount);
 *
 * console.log("invite secret: ", invite.secret);
 *
 * // => Invite object is send to server, which sends an email to the invitee
 *
 * // INVITEE
 * // => Invitee fetches `invite` object from server, asks org owner for `secret` (in person)
 *
 * // Verifies organization info and signs own public key
 *
 * const success = await invite.accept(inviteeAccount, secret);
 *
 * if (!success) {
 *     throw "Verification failed! Incorrect secret?";
 * }
 *
 * // => Sends updated invite object to server
 *
 * // ORG OWNER
 *
 * // => Fetches updated invite object
 *
 * // Verify invitee details.
 * if (!(await invite.verifyInvitee())) {
 *     throw "Failed to verify invitee details!";
 * }
 *
 * // DONE!
 * await org.addOrUpdateMember(invite.invitee);
 * ```
 */
class Invite extends _container__WEBPACK_IMPORTED_MODULE_2__.SimpleContainer {
    constructor(
    /** invitee email */
    email = "", 
    /** purpose of the invite */
    purpose = "join_org") {
        super();
        this.email = email;
        this.purpose = purpose;
        /** Unique identfier */
        this.id = "";
        /** Time of creation */
        this.created = new Date();
        /**
         * Expiration time used to limit invite procedure to a certain time
         * window. This property is also stored in [[encryptedData]] along
         * with the invite secret to prevent tempering.
         */
        this.expires = new Date();
        /** Info about who created the invite. */
        this.invitedBy = undefined;
        this._secret = "";
        this._signingKey = null;
        /** Key derivation paramaters used for deriving the HMAC signing key from [[secret]]. */
        this.signingKeyParams = new _crypto__WEBPACK_IMPORTED_MODULE_0__.PBKDF2Params({
            iterations: 1e6
        });
        /**
         * Parameters used for signing organization and initee details.
         */
        this.signingParams = new _crypto__WEBPACK_IMPORTED_MODULE_0__.HMACParams();
    }
    /**
     * Random secret used for deriving the HMAC key that is used to sign and
     * verify organization and invitee details. It is encrypted at rest with an
     * AES key only available to organization admins. The invitee does not have
     * access to this property directly but needs to request it from the
     * organization owner directly.
     *
     * @secret
     * **IMPORTANT**: This property is considered **secret**
     * and should never stored or transmitted in plain text
     */
    set secret(s) {
        this._secret = s;
        this._signingKey = null;
    }
    get secret() {
        return this._secret;
    }
    /** Whether this invite has expired */
    get expired() {
        return new Date() > new Date(this.expires);
    }
    /** Whether this invite has been accepted by the invitee */
    get accepted() {
        return !!this.invitee;
    }
    /**
     * Initializes the invite by generating a random [[secret]] and [[id]] and
     * signing and storing the organization details.
     *
     * @param org The organization this invite is for
     * @param invitor Account creating the invite
     * @param duration Number of hours until this invite expires
     */
    async initialize(org, invitor, duration = 12) {
        this.id = await (0,_util__WEBPACK_IMPORTED_MODULE_4__.uuid)();
        this.invitedBy = { id: invitor.id, email: invitor.email, name: invitor.name };
        // Generate secret
        this.secret = (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.bytesToHex)(await (0,_platform__WEBPACK_IMPORTED_MODULE_1__.getCryptoProvider)().randomBytes(4));
        // Set expiration time (12 hours from now)
        this.expires = new Date(Date.now() + 1000 * 60 * 60 * duration);
        // Encrypt secret and expiration date (the expiration time is also stored/transmitted
        // in plain text, encrypting it will allow verifying it wasn't tempered with later)
        this._key = org.invitesKey;
        await this.setData((0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)((0,_encoding__WEBPACK_IMPORTED_MODULE_3__.marshal)({ secret: this.secret, expires: this.expires })));
        // Initialize signing params
        this.signingKeyParams.salt = await (0,_platform__WEBPACK_IMPORTED_MODULE_1__.getCryptoProvider)().randomBytes(16);
        // Create org signature using key derived from secret (see `_getSigningKey`)
        this.org = new OrgInfo({
            id: org.id,
            name: org.name,
            publicKey: org.publicKey,
            signature: await this._sign((0,_encoding__WEBPACK_IMPORTED_MODULE_3__.concatBytes)([(0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)(org.id), org.publicKey], 0x00))
        });
    }
    /**
     * "Unlocks" the invite with the dedicated key (owned by the respective [[Org]]).
     * This grants access to the [[secret]] property and verfies that [[expires]] has
     * not been tempered with.
     */
    async unlock(key) {
        await super.unlock(key);
        const { secret, expires } = (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.unmarshal)((0,_encoding__WEBPACK_IMPORTED_MODULE_3__.bytesToString)(await this.getData()));
        this.secret = secret;
        // Verify that expiration time has not been tempered with
        if (this.expires.getTime() !== new Date(expires).getTime()) {
            throw new _error__WEBPACK_IMPORTED_MODULE_5__.Err(_error__WEBPACK_IMPORTED_MODULE_5__.ErrorCode.VERIFICATION_ERROR);
        }
    }
    lock() {
        super.lock();
        delete this.secret;
        delete this._signingKey;
    }
    /**
     * Accepts the invite by verifying the organization details and, if successful,
     * signing and storing the invitees own information. Throws if verification
     * is unsuccessful.
     */
    async accept(account, secret) {
        this.secret = secret;
        // Verify org signature
        if (!(await this.verifyOrg())) {
            this.secret = "";
            return false;
        }
        this.invitee = new InviteeInfo({
            id: account.id,
            name: account.name,
            email: account.email,
            publicKey: account.publicKey,
            // this is used by the organization owner to verify the invitees public key
            signature: await this._sign((0,_encoding__WEBPACK_IMPORTED_MODULE_3__.concatBytes)([(0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)(account.id), (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)(account.email), account.publicKey], 0x00)),
            // this is used by member later to verify the organization public key
            orgSignature: await account.signOrg(this.org)
        });
        return true;
    }
    /** Verifies the organization information. */
    async verifyOrg() {
        if (!this.org) {
            throw "Invite needs to be initialized first!";
        }
        return (this.expires > new Date() &&
            this._verify(this.org.signature, (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.concatBytes)([(0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)(this.org.id), this.org.publicKey], 0x00)));
    }
    /** Verifies the invitee information. */
    async verifyInvitee() {
        if (!this.invitee) {
            throw "Invite needs to be accepted first!";
        }
        return (this.expires > new Date() &&
            this._verify(this.invitee.signature, (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.concatBytes)([(0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)(this.invitee.id), (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)(this.invitee.email), this.invitee.publicKey], 0x00)));
    }
    async _getSigningKey() {
        if (!this._signingKey) {
            this._signingKey = (await (0,_platform__WEBPACK_IMPORTED_MODULE_1__.getCryptoProvider)().deriveKey((0,_encoding__WEBPACK_IMPORTED_MODULE_3__.stringToBytes)(this.secret), this.signingKeyParams));
        }
        return this._signingKey;
    }
    async _sign(val) {
        return (0,_platform__WEBPACK_IMPORTED_MODULE_1__.getCryptoProvider)().sign(await this._getSigningKey(), val, this.signingParams);
    }
    async _verify(sig, val) {
        return await (0,_platform__WEBPACK_IMPORTED_MODULE_1__.getCryptoProvider)().verify(await this._getSigningKey(), sig, val, this.signingParams);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsDate)(),
    __metadata("design:type", Object)
], Invite.prototype, "created", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsDate)(),
    __metadata("design:type", Object)
], Invite.prototype, "expires", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsSerializable)(OrgInfo),
    __metadata("design:type", OrgInfo)
], Invite.prototype, "org", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsSerializable)(InviteeInfo),
    __metadata("design:type", InviteeInfo)
], Invite.prototype, "invitee", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_0__.PBKDF2Params),
    __metadata("design:type", Object)
], Invite.prototype, "signingKeyParams", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_3__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_0__.HMACParams),
    __metadata("design:type", Object)
], Invite.prototype, "signingParams", void 0);


/***/ }),

/***/ "../core/src/item.ts":
/*!***************************!*\
  !*** ../core/src/item.ts ***!
  \***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "FieldType": () => (/* binding */ FieldType),
/* harmony export */   "FIELD_DEFS": () => (/* binding */ FIELD_DEFS),
/* harmony export */   "Field": () => (/* binding */ Field),
/* harmony export */   "normalizeTag": () => (/* binding */ normalizeTag),
/* harmony export */   "VaultItem": () => (/* binding */ VaultItem),
/* harmony export */   "createVaultItem": () => (/* binding */ createVaultItem),
/* harmony export */   "guessFieldType": () => (/* binding */ guessFieldType),
/* harmony export */   "ITEM_TEMPLATES": () => (/* binding */ ITEM_TEMPLATES)
/* harmony export */ });
/* harmony import */ var _padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @padloc/locale/src/translate */ "../locale/src/translate.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _otp__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./otp */ "../core/src/otp.ts");
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./util */ "../core/src/util.ts");
/* harmony import */ var _attachment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./attachment */ "../core/src/attachment.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





var FieldType;
(function (FieldType) {
    FieldType["Username"] = "username";
    FieldType["Password"] = "password";
    FieldType["Url"] = "url";
    FieldType["Email"] = "email";
    FieldType["Date"] = "date";
    FieldType["Month"] = "month";
    FieldType["Credit"] = "credit";
    FieldType["Phone"] = "phone";
    FieldType["Pin"] = "pin";
    FieldType["Totp"] = "totp";
    FieldType["Note"] = "note";
    FieldType["Text"] = "text";
})(FieldType || (FieldType = {}));
/** Available field types and respective meta data */
const FIELD_DEFS = {
    [FieldType.Username]: {
        type: FieldType.Username,
        pattern: ".*",
        mask: false,
        multiline: false,
        icon: "user",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Username");
        }
    },
    [FieldType.Password]: {
        type: FieldType.Password,
        pattern: ".*",
        mask: true,
        multiline: true,
        icon: "lock",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Password");
        },
        format(value, masked) {
            return masked ? value.replace(/./g, "\u2022") : value;
        }
    },
    [FieldType.Url]: {
        type: FieldType.Url,
        pattern: ".*",
        mask: false,
        multiline: false,
        icon: "web",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("URL");
        }
    },
    [FieldType.Email]: {
        type: FieldType.Email,
        pattern: ".*",
        mask: false,
        multiline: false,
        icon: "email",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Email Address");
        }
    },
    [FieldType.Date]: {
        type: FieldType.Date,
        pattern: "\\d\\d\\d\\d-\\d\\d-\\d\\d",
        mask: false,
        multiline: false,
        icon: "date",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Date");
        },
        format(value) {
            return new Date(value).toLocaleDateString();
        }
    },
    [FieldType.Month]: {
        type: FieldType.Month,
        pattern: "\\d\\d\\d\\d-\\d\\d",
        mask: false,
        multiline: false,
        icon: "month",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Month");
        }
    },
    [FieldType.Credit]: {
        type: FieldType.Credit,
        pattern: "\\d*",
        mask: true,
        multiline: false,
        icon: "credit",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Credit Card Number");
        },
        format(value, masked) {
            const parts = [];
            for (let i = 0; i < value.length; i += 4) {
                const part = value.slice(i, i + 4);
                parts.push(masked && i < value.length - 4 ? part.replace(/./g, "\u2022") : part);
            }
            return parts.join(" ");
        }
    },
    [FieldType.Phone]: {
        type: FieldType.Phone,
        pattern: ".*",
        mask: false,
        multiline: false,
        icon: "phone",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Phone Number");
        }
    },
    [FieldType.Pin]: {
        type: FieldType.Pin,
        pattern: "\\d*",
        mask: true,
        multiline: false,
        icon: "lock",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("PIN");
        },
        format(value, masked) {
            return masked ? value.replace(/./g, "\u2022") : value;
        }
    },
    [FieldType.Totp]: {
        type: FieldType.Totp,
        pattern: ".*",
        mask: false,
        multiline: false,
        icon: "totp",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("2FA Token");
        },
        async transform(value) {
            return await (0,_otp__WEBPACK_IMPORTED_MODULE_2__.totp)((0,_encoding__WEBPACK_IMPORTED_MODULE_1__.base32ToBytes)(value));
        }
    },
    [FieldType.Note]: {
        type: FieldType.Note,
        pattern: ".*",
        mask: false,
        multiline: true,
        icon: "note",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Note");
        }
    },
    [FieldType.Text]: {
        type: FieldType.Text,
        pattern: ".*",
        mask: false,
        multiline: false,
        icon: "text",
        get name() {
            return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Other");
        }
    }
};
class Field extends _encoding__WEBPACK_IMPORTED_MODULE_1__.Serializable {
    constructor(vals = {}) {
        super();
        /**
         * field type, determining meta data via the corresponding field definition
         * in [[FIELD_DEFS]]
         */
        this.type = FieldType.Text;
        /** field name */
        this.name = "";
        /** field content */
        this.value = "";
        Object.assign(this, vals);
    }
    get def() {
        return FIELD_DEFS[this.type] || FIELD_DEFS[FieldType.Text];
    }
    get icon() {
        return this.def.icon;
    }
    async transform() {
        return this.def.transform ? await this.def.transform(this.value) : this.value;
    }
    format(masked) {
        return this.def.format ? this.def.format(this.value, masked) : this.value;
    }
    _fromRaw(raw) {
        if (!raw.type) {
            raw.type = guessFieldType(raw);
        }
        return super._fromRaw(raw);
    }
}
/** Normalizes a tag value by removing invalid characters */
function normalizeTag(tag) {
    return tag.replace(",", "");
}
/** Represents an entry within a vault */
class VaultItem extends _encoding__WEBPACK_IMPORTED_MODULE_1__.Serializable {
    constructor(vals = {}) {
        super();
        /** unique identfier */
        this.id = "";
        /** item name */
        this.name = "";
        /** item fields */
        this.fields = [];
        /** array of tags assigned with this item */
        this.tags = [];
        /** Date and time of last update */
        this.updated = new Date();
        /** [[Account]] the item was last updated by */
        this.updatedBy = "";
        /**
         * @DEPRECATED
         * Accounts that have favorited this item
         */
        this.favorited = [];
        /** attachments associated with this item */
        this.attachments = [];
        Object.assign(this, vals);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsSerializable)(Field),
    __metadata("design:type", Array)
], VaultItem.prototype, "fields", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Date)
], VaultItem.prototype, "updated", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsSerializable)(_attachment__WEBPACK_IMPORTED_MODULE_4__.AttachmentInfo),
    __metadata("design:type", Array)
], VaultItem.prototype, "attachments", void 0);
/** Creates a new vault item */
async function createVaultItem(name, fields = [], tags = []) {
    return new VaultItem({
        name,
        fields,
        tags,
        id: await (0,_util__WEBPACK_IMPORTED_MODULE_3__.uuid)()
    });
}
const matchUsername = /username/i;
const matchPassword = /password/i;
const matchUrl = /url/i;
const matchNote = /\n/;
/** Guesses the most appropriate field type based on field name and value */
function guessFieldType({ name = "", value = "", masked }) {
    return masked || name.match(matchPassword)
        ? FieldType.Password
        : name.match(matchUsername)
            ? FieldType.Username
            : name.match(matchUrl)
                ? FieldType.Url
                : value.match(matchNote)
                    ? FieldType.Note
                    : FieldType.Text;
}
const ITEM_TEMPLATES = [
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Website / App"),
        icon: "web",
        fields: [
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Username");
                },
                type: FieldType.Username
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Password");
                },
                type: FieldType.Password
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("URL");
                },
                type: FieldType.Url
            }
        ]
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Computer"),
        icon: "desktop",
        fields: [
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Username");
                },
                type: FieldType.Username
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Password");
                },
                type: FieldType.Password
            }
        ]
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Credit Card"),
        icon: "credit",
        fields: [
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Card Number");
                },
                type: FieldType.Credit
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Card Owner");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Valid Until");
                },
                type: FieldType.Month
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("CVC");
                },
                type: FieldType.Pin
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("PIN");
                },
                type: FieldType.Pin
            }
        ]
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Bank Account"),
        icon: "bank",
        fields: [
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Account Owner");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("IBAN");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("BIC");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Card PIN");
                },
                type: FieldType.Pin
            }
        ]
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("WIFI Password"),
        icon: "wifi",
        fields: [
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Name");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Password");
                },
                type: FieldType.Password
            }
        ]
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Passport"),
        icon: "passport",
        fields: [
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Full Name");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Passport Number");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Country");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Birthdate");
                },
                type: FieldType.Date
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Birthplace");
                },
                type: FieldType.Text
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Issued On");
                },
                type: FieldType.Date
            },
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Expires");
                },
                type: FieldType.Date
            }
        ]
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Note"),
        icon: "note",
        fields: [
            {
                get name() {
                    return (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Note");
                },
                type: FieldType.Note
            }
        ]
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Document"),
        icon: "attachment",
        fields: [],
        attachment: true
    },
    {
        toString: () => (0,_padloc_locale_src_translate__WEBPACK_IMPORTED_MODULE_0__.translate)("Custom"),
        icon: "custom",
        fields: []
    }
];


/***/ }),

/***/ "../core/src/legacy.ts":
/*!*****************************!*\
  !*** ../core/src/legacy.ts ***!
  \*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "validateLegacyContainer": () => (/* binding */ validateLegacyContainer),
/* harmony export */   "parseLegacyContainer": () => (/* binding */ parseLegacyContainer)
/* harmony export */ });
/* harmony import */ var _vendor_sjcl__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vendor/sjcl */ "../core/vendor/sjcl.js");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");




/**
 * Validates legacy container structure
 */
function validateLegacyContainer(obj) {
    return (typeof obj === "object" &&
        (obj.version === undefined || obj.version === 1) && // has a valid version
        [128, 192, 256].includes(obj.keySize) &&
        typeof obj.iter == "number" && // valid PBKDF2 iteration count
        obj.iter <= _crypto__WEBPACK_IMPORTED_MODULE_2__.PBKDF2_ITER_MAX && // sane pbkdf2 iteration count
        typeof obj.salt == "string" &&
        ["aes"].includes(obj.cipher) && // valid cipher
        ["ccm", "ocb2"].includes(obj.mode) && // exiting mode
        typeof obj.iv == "string" && // valid initialisation vector
        typeof obj.ct == "string" && // valid cipher text
        typeof obj.adata == "string" && // valid authorisation data
        [64, 96, 128].includes(obj.ts) // valid authorisation tag length
    );
}
/**
 * Transforms a legacy container object into an instance of [[PBES2Container]]
 */
function parseLegacyContainer(raw) {
    if (!validateLegacyContainer(raw)) {
        throw new _error__WEBPACK_IMPORTED_MODULE_1__.Err(_error__WEBPACK_IMPORTED_MODULE_1__.ErrorCode.ENCODING_ERROR);
    }
    if (raw.version === undefined) {
        // Legacy versions of Padlock had a bug where the base64-encoded
        // `adata` value was not converted to a BitArray before being
        // passed to `sjcl.mode.ccm.encrypt/decrypt` and the raw string was
        // passed instead. This went unnoticed as the functions in question
        // quietly accepted the string and simply treated it as an array.
        // So in order to successfully decrypt legacy containers we have to
        // perfom this conversion first.
        raw.adata = _vendor_sjcl__WEBPACK_IMPORTED_MODULE_0__.sjcl.codec.base64.fromBits(raw.adata);
    }
    return new _container__WEBPACK_IMPORTED_MODULE_3__.PBES2Container().fromRaw({
        encryptionParams: {
            algorithm: "AES-CCM",
            tagSize: raw.ts,
            keySize: raw.keySize,
            iv: raw.iv,
            additionalData: raw.adata
        },
        keyParams: {
            algorithm: "PBKDF2",
            hash: "SHA-256",
            keySize: raw.keySize,
            iterations: raw.iter,
            salt: raw.salt
        },
        encryptedData: raw.ct
    });
}


/***/ }),

/***/ "../core/src/mfa.ts":
/*!**************************!*\
  !*** ../core/src/mfa.ts ***!
  \**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "MFAPurpose": () => (/* binding */ MFAPurpose),
/* harmony export */   "MFAType": () => (/* binding */ MFAType),
/* harmony export */   "MFARequest": () => (/* binding */ MFARequest)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util */ "../core/src/util.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};



var MFAPurpose;
(function (MFAPurpose) {
    MFAPurpose[MFAPurpose["Signup"] = 0] = "Signup";
    MFAPurpose[MFAPurpose["Login"] = 1] = "Login";
    MFAPurpose[MFAPurpose["Recover"] = 2] = "Recover";
    MFAPurpose[MFAPurpose["GetLegacyData"] = 3] = "GetLegacyData";
})(MFAPurpose || (MFAPurpose = {}));
var MFAType;
(function (MFAType) {
    MFAType[MFAType["Email"] = 0] = "Email";
})(MFAType || (MFAType = {}));
/**
 * Class for storing email verification data. Email verificatiion is used
 * to prove ownership of the email address in question and as a authentication
 * mechanism.
 */
class MFARequest extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(
    /** The email to be verified */
    email, 
    /** The verification purpose */
    purpose, type = MFAType.Email) {
        super();
        this.email = email;
        this.purpose = purpose;
        this.type = type;
        /** Time of creation */
        this.created = new Date();
        /**
         * MFA verification code. This code is sent to the user via email
         * through [[API.requestMFACode]]
         */
        this.code = "";
        /**
         * MFA token that can be exchanged for the MFA code via [[API.retrieveMFAToken]]
         */
        this.token = "";
        /**
         * Number of failed tries
         */
        this.tries = 0;
    }
    get id() {
        return `${this.email}_${this.purpose}`;
    }
    async init() {
        const len = 6;
        // Create random 6-digit verification code
        this.code = (await (0,_util__WEBPACK_IMPORTED_MODULE_2__.randomNumber)(0, Math.pow(10, len) - 1)).toString().padStart(len, "0");
        // Create random 16-byte verification token
        this.token = (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.bytesToBase64)(await (0,_platform__WEBPACK_IMPORTED_MODULE_1__.getCryptoProvider)().randomBytes(16));
        this.tries = 0;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Object)
], MFARequest.prototype, "created", void 0);


/***/ }),

/***/ "../core/src/org.ts":
/*!**************************!*\
  !*** ../core/src/org.ts ***!
  \**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "OrgRole": () => (/* binding */ OrgRole),
/* harmony export */   "OrgMember": () => (/* binding */ OrgMember),
/* harmony export */   "Group": () => (/* binding */ Group),
/* harmony export */   "OrgType": () => (/* binding */ OrgType),
/* harmony export */   "OrgSecrets": () => (/* binding */ OrgSecrets),
/* harmony export */   "Org": () => (/* binding */ Org)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
/* harmony import */ var _invite__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./invite */ "../core/src/invite.ts");
/* harmony import */ var _quota__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./quota */ "../core/src/quota.ts");
/* harmony import */ var _billing__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./billing */ "../core/src/billing.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};








/** Role of a member within an organization, each associated with certain priviliges */
var OrgRole;
(function (OrgRole) {
    /**
     * Organization owner. Can manage members, groups and vaults.  Owners have
     * access to the secret [[Org.privateKey]] and [[Org.invitesKey]]
     * properties.
     */
    OrgRole[OrgRole["Owner"] = 0] = "Owner";
    /**
     * Organization admin. Can manage groups and vaults.
     */
    OrgRole[OrgRole["Admin"] = 1] = "Admin";
    /**
     * Basic organization member. Can read public organization data and read/write
     * certain [[Vault]]s they have been assigned to directly or via [[Group]]s.
     */
    OrgRole[OrgRole["Member"] = 2] = "Member";
    /**
     * Suspended members can read public organization data and access [[Vaults]] they
     * have been assigned to, but are excluded from any updates to those vaults.
     * Member information (like public key and email address) of suspended members
     * are considered unverified, and need to be updated and verified via a
     * membership confirmation [[Invite]].
     */
    OrgRole[OrgRole["Suspended"] = 3] = "Suspended";
})(OrgRole || (OrgRole = {}));
/**
 * Represents an [[Account]]s membership to an [[Org]]
 */
class OrgMember extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor({ id, name, email, publicKey, signature, orgSignature, role, updated } = {}) {
        super();
        /** id of the corresponding [[Account]] */
        this.id = "";
        /** name of the corresponding [[Account]] */
        this.name = "";
        /** email address of the corresponding [[Account]] */
        this.email = "";
        /** vaults assigned to this member */
        this.vaults = [];
        /** the members organization role */
        this.role = OrgRole.Member;
        /** time the member was last updated */
        this.updated = new Date(0);
        Object.assign(this, { id, name, email, publicKey, signature, orgSignature, updated });
        this.role = typeof role !== "undefined" && role in OrgRole ? role : OrgRole.Member;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Object)
], OrgMember.prototype, "publicKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], OrgMember.prototype, "signature", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], OrgMember.prototype, "orgSignature", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Object)
], OrgMember.prototype, "updated", void 0);
/**
 * A group of members, used to manage [[Vault]] access for multiple members at once.
 */
class Group extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(vals = {}) {
        super();
        /** display name */
        this.name = "";
        /** members assigned to this group */
        this.members = [];
        /** [[Vault]]s assigned to this group */
        this.vaults = [];
        Object.assign(this, vals);
    }
}
var OrgType;
(function (OrgType) {
    OrgType[OrgType["Basic"] = 0] = "Basic";
    OrgType[OrgType["Team"] = 1] = "Team";
    OrgType[OrgType["Business"] = 2] = "Business";
})(OrgType || (OrgType = {}));
class OrgSecrets extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor({ invitesKey, privateKey } = {}) {
        super();
        Object.assign(this, { invitesKey, privateKey });
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], OrgSecrets.prototype, "invitesKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], OrgSecrets.prototype, "privateKey", void 0);
/**
 * Organizations are the central component of Padlocs secure data sharing architecture.
 *
 * All shared [[Vault]]s are provisioned and managed in the context of an organization,
 * while the [[Org]] class itself is responsible for managing, signing and verifying
 * public keys, identities and priviliges for all of it's members.
 *
 * Vaults can be assigned to members direcly or indirectly through [[Group]]s. In both
 * cases, this access can be declared *readonly*.
 *
 * Before being added to an organization, members need to go throug a key exchange
 * procedure designed to allow verification of organization and member details
 * by both parties. See [[Invite]] class for details.
 *
 * The [[privateKey]] and [[invitesKey]] properties are considered secret and are only
 * accessible to members with the [[OrgRole.Owner]] role. To protect this information
 * from unauthorized access, [[Org]] extends the [[SharedContainer]] class, encrypting
 * this data at rest.
 *
 * #### Organization Structure
 * ```
 * ┌──────────────┐            ┌──────────────┐            ┌──────────────┐
 * │              │           ╱│              │╲           │              │
 * │   Account    │┼─────────○─│  Membership  │──┼────────┼│ Organization │
 * │              │           ╲│              │╱           │              │
 * └──────────────┘            └───┬──────┬───┘            └──────────────┘
 *                                ╲│╱    ╲│╱                       ┼
 *                                 ○      ○                        ○
 *                                 │      │                       ╱│╲
 *                                 │      │                ┌──────────────┐
 *                                 │      │               ╱│              │
 *                                 │      └──────────────○─│    Group     │
 *                                 │                      ╲│              │
 *                                 ○                       └──────────────┘
 *                                ╱│╲                             ╲│╱
 *                         ┌──────────────┐                        ○
 *                         │              │╲                       │
 *                         │ Shared Vault │─○──────────────────────┘
 *                         │              │╱
 *                         └──────────────┘
 * ```
 */
class Org extends _container__WEBPACK_IMPORTED_MODULE_3__.SharedContainer {
    constructor() {
        super(...arguments);
        /** Unique identier */
        this.id = "";
        this.type = OrgType.Basic;
        /** [[Account]] which created this organization */
        this.owner = "";
        /** Organization name */
        this.name = "";
        /** Creation date */
        this.created = new Date();
        /** Last updated */
        this.updated = new Date();
        /**
         * Minimum accepted update time for organization members.
         * Any members with a [[OrgMember.updated]] value lower than
         * this should be considered invalid.
         *
         * In order to prevent an attacker from rolling back this value, all
         * clients should verify that updated organization object always have a
         * [[Org.minMemberUpdated]] value equal to or higher than the previous one.
         */
        this.minMemberUpdated = new Date();
        /** Parameters for creating member signatures */
        this.signingParams = new _crypto__WEBPACK_IMPORTED_MODULE_1__.RSASigningParams();
        /** Array of organization members */
        this.members = [];
        /** This organizations [[Group]]s. */
        this.groups = [];
        /** Shared [[Vault]]s owned by this organization */
        this.vaults = [];
        /** Pending [[Invite]]s */
        this.invites = [];
        /**
         * Revision id used for ensuring continuity when synchronizing the account
         * object between client and server
         */
        this.revision = "";
        /**
         * Whether the organization is in "frozen" state. If an organization is
         * frozen, groups, members and vaults assoziated with the Organization can
         * not be updated.
         */
        this.frozen = false;
        this.quota = new _quota__WEBPACK_IMPORTED_MODULE_6__.OrgQuota();
        this.usedStorage = 0;
    }
    /** Whether the given [[Account]] is an [[OrgRole.Owner]] */
    isOwner(m) {
        const member = this.getMember(m);
        return !!member && member.role <= OrgRole.Owner;
    }
    /** Whether the given [[Account]] is an [[OrgRole.Admin]] */
    isAdmin(m) {
        const member = this.getMember(m);
        return !!member && member.role <= OrgRole.Admin;
    }
    /** Whether the given [[Account]] is currently suspended */
    isSuspended(m) {
        const member = this.getMember(m);
        return !!member && member.role === OrgRole.Suspended;
    }
    /** Get the [[OrgMember]] object for this [[Account]] */
    getMember({ id }) {
        return this.members.find(m => m.id === id);
    }
    /** Whether the given [[Account]] is an organization member */
    isMember(acc) {
        return !!this.getMember(acc);
    }
    /** Get group with the given `name` */
    getGroup(name) {
        return [...this.groups].find(g => g.name === name);
    }
    /** Get all members of a given `group` */
    getMembersForGroup(group) {
        return group.members
            .map(m => this.getMember(m))
            // Filter out undefined members
            .filter(m => !!m);
    }
    /** Get all [[Group]]s the given [[Account]] is a member of */
    getGroupsForMember({ id }) {
        return this.groups.filter(g => g.members.some(m => m.id === id));
    }
    /** Get all groups assigned to a given [[Vault]] */
    getGroupsForVault({ id }) {
        return this.groups.filter(group => group.vaults.some(v => v.id === id));
    }
    /** Get all members directly assigned to a given [[Vault]] */
    getMembersForVault({ id }) {
        return this.members.filter(member => member.role !== OrgRole.Suspended && member.vaults.some(v => v.id === id));
    }
    /** Get all membes that have acess to a given `vault`, either directly or through a [[Group]] */
    getAccessors(vault) {
        const results = new Set(this.getMembersForVault(vault));
        for (const group of this.getGroupsForVault(vault)) {
            for (const m of group.members) {
                const member = this.getMember(m);
                if (member && member.role !== OrgRole.Suspended) {
                    results.add(member);
                }
            }
        }
        return [...results];
    }
    /** Get all vaults the given member has access to */
    getVaultsForMember(acc) {
        const member = this.getMember(acc);
        if (!member) {
            throw "A member with this id does not exist!";
        }
        const results = new Set(member.vaults.map(v => v.id));
        for (const group of this.getGroupsForMember(member)) {
            for (const vault of group.vaults) {
                results.add(vault.id);
            }
        }
        return this.vaults.filter(v => results.has(v.id));
    }
    /** Check whether the given `account` has read access to a `vault` */
    canRead(vault, account) {
        const member = this.getMember(account);
        return (member &&
            [member, ...this.getGroupsForMember(member)].some(({ vaults }) => vaults.some(v => v.id === vault.id)));
    }
    /** Check whether the given `account` has write access to a `vault` */
    canWrite(vault, acc) {
        const member = this.getMember(acc);
        return (member &&
            member.role !== OrgRole.Suspended &&
            [member, ...this.getGroupsForMember(member)].some(({ vaults }) => vaults.some(v => v.id === vault.id && !v.readonly)));
    }
    /** Get the invite with the given `id` */
    getInvite(id) {
        return this.invites.find(inv => inv.id === id);
    }
    /** Remove an invite */
    removeInvite({ id }) {
        this.invites = this.invites.filter(inv => inv.id !== id);
    }
    /**
     * Initializes the organization, generating [[publicKey]], [[privateKey]],
     * and [[invitesKey]] and adding the given `account` as the organization
     * owner.
     */
    async initialize(account) {
        // Update access to keypair
        await this.updateAccessors([account]);
        // Generate cryptographic keys
        await this.generateKeys();
        // Set minimum date for member update times
        this.minMemberUpdated = new Date();
        const orgSignature = await account.signOrg(this);
        const member = await this.sign(new OrgMember({
            id: account.id,
            name: account.name,
            email: account.email,
            publicKey: account.publicKey,
            orgSignature,
            role: OrgRole.Owner,
            updated: new Date()
        }));
        this.members.push(member);
    }
    /**
     * Generates a new [[publicKey]], [[privateKey]] and [[invitesKey]] and
     * encrypts the latter two
     */
    async generateKeys() {
        this.invitesKey = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().generateKey(new _crypto__WEBPACK_IMPORTED_MODULE_1__.AESKeyParams());
        const { privateKey, publicKey } = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().generateKey(new _crypto__WEBPACK_IMPORTED_MODULE_1__.RSAKeyParams());
        this.privateKey = privateKey;
        this.publicKey = publicKey;
        await this.setData(new OrgSecrets(this).toBytes());
    }
    /**
     * Regenerates all cryptographic keys and updates all member signatures
     */
    async rotateKeys(force = false) {
        if (!force) {
            // Verify members and groups with current public key
            await this.verifyAll();
        }
        // Rotate Org key pair
        await this.generateKeys();
        // Rotate org encryption key
        delete this.encryptedData;
        await this.updateAccessors(this.members.filter(m => m.role === OrgRole.Owner));
        // Re-sign all members
        await Promise.all(this.members.filter(m => m.role !== OrgRole.Suspended).map(m => this.addOrUpdateMember(m)));
    }
    /**
     * "Unlocks" the organization, granting access to the organizations
     * [[privateKey]] and [[invitesKey]] properties.
     */
    async unlock(account) {
        await super.unlock(account);
        if (this.encryptedData) {
            const secrets = new OrgSecrets().fromBytes(await this.getData());
            Object.assign(this, secrets);
        }
    }
    lock() {
        super.lock();
        delete this.privateKey;
        delete this.invitesKey;
        this.invites.forEach(invite => invite.lock);
    }
    /**
     * Signs the `member`s public key, id, role and email address so they can be verified later
     */
    async sign(member) {
        if (!this.privateKey) {
            throw "Organisation needs to be unlocked first.";
        }
        member.signature = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().sign(this.privateKey, (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.concatBytes)([
            (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(member.id),
            (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(member.email),
            new Uint8Array([member.role]),
            member.publicKey,
            (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(member.updated.toISOString())
        ], 0x00), this.signingParams);
        return member;
    }
    /**
     * Verifies the `member`s public key, id, role and email address.
     * Throws if verification fails.
     */
    async verify(member) {
        if (!member.signature) {
            throw new _error__WEBPACK_IMPORTED_MODULE_4__.Err(_error__WEBPACK_IMPORTED_MODULE_4__.ErrorCode.VERIFICATION_ERROR, "No signed public key provided!");
        }
        const verified = member.updated >= this.minMemberUpdated &&
            (await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().verify(this.publicKey, member.signature, (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.concatBytes)([
                (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(member.id),
                (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(member.email),
                new Uint8Array([member.role]),
                member.publicKey,
                (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(member.updated.toISOString())
            ], 0x00), this.signingParams));
        if (!verified) {
            throw new _error__WEBPACK_IMPORTED_MODULE_4__.Err(_error__WEBPACK_IMPORTED_MODULE_4__.ErrorCode.VERIFICATION_ERROR, `Failed to verify public key of ${member.name}!`);
        }
    }
    /**
     * Verify all provided `members`, throws if verification fails for any of them.
     */
    async verifyAll(members = this.members.filter(m => m.role !== OrgRole.Suspended)) {
        // Verify public keys for members and groups
        await Promise.all(members.map(async (obj) => this.verify(obj)));
    }
    /**
     * Adds a member to the organization, or updates the existing member with the same id.
     */
    async addOrUpdateMember({ id, name, email, publicKey, orgSignature, role }) {
        if (!this.privateKey) {
            throw "Organisation needs to be unlocked first.";
        }
        role = typeof role !== "undefined" ? role : OrgRole.Member;
        const existing = this.members.find(m => m.id === id);
        const updated = new Date();
        if (existing) {
            Object.assign(existing, { name, email, publicKey, orgSignature, role, updated });
            await this.sign(existing);
        }
        else {
            this.members.push(await this.sign(new OrgMember({ id, name, email, publicKey, orgSignature, role, updated })));
        }
    }
    /**
     * Removes a member from the organization
     */
    async removeMember(member) {
        if (!this.privateKey) {
            throw "Organisation needs to be unlocked first.";
        }
        // Remove member from all groups
        for (const group of this.getGroupsForMember(member)) {
            group.members = group.members.filter(m => m.id !== member.id);
        }
        // Remove member
        this.members = this.members.filter(m => m.id !== member.id);
        // Verify remaining members (since we're going to re-sign them)
        await this.verifyAll();
        // Bump minimum update date
        this.minMemberUpdated = new Date();
        // Re-sign all members
        await Promise.all(this.members.filter(m => m.role !== OrgRole.Suspended).map(m => this.addOrUpdateMember(m)));
    }
    toString() {
        return this.name;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Date)
], Org.prototype, "created", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Date)
], Org.prototype, "updated", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Object)
], Org.prototype, "publicKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.Exclude)(),
    __metadata("design:type", Object)
], Org.prototype, "privateKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.Exclude)(),
    __metadata("design:type", Object)
], Org.prototype, "invitesKey", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Date)
], Org.prototype, "minMemberUpdated", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_crypto__WEBPACK_IMPORTED_MODULE_1__.RSASigningParams),
    __metadata("design:type", Object)
], Org.prototype, "signingParams", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(OrgMember),
    __metadata("design:type", Array)
], Org.prototype, "members", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(Group),
    __metadata("design:type", Array)
], Org.prototype, "groups", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_invite__WEBPACK_IMPORTED_MODULE_5__.Invite),
    __metadata("design:type", Array)
], Org.prototype, "invites", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_quota__WEBPACK_IMPORTED_MODULE_6__.OrgQuota),
    __metadata("design:type", _quota__WEBPACK_IMPORTED_MODULE_6__.OrgQuota)
], Org.prototype, "quota", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_billing__WEBPACK_IMPORTED_MODULE_7__.BillingInfo),
    __metadata("design:type", _billing__WEBPACK_IMPORTED_MODULE_7__.BillingInfo)
], Org.prototype, "billing", void 0);


/***/ }),

/***/ "../core/src/otp.ts":
/*!**************************!*\
  !*** ../core/src/otp.ts ***!
  \**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "hotp": () => (/* binding */ hotp),
/* harmony export */   "totp": () => (/* binding */ totp),
/* harmony export */   "parseURL": () => (/* binding */ parseURL)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");




function getToken(hmac, digits = 6) {
    const offset = hmac[hmac.length - 1] & 0xf;
    const bin = new Uint8Array([hmac[offset] & 0x7f, hmac[offset + 1], hmac[offset + 2], hmac[offset + 3]]);
    const num = (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.bytesToNum)(bin);
    return (num % 10 ** digits).toString().padStart(digits, "0");
}
async function hotp(secret, counter, { hash, digits } = { digits: 6, hash: "SHA-1" }) {
    const hmac = await (0,_platform__WEBPACK_IMPORTED_MODULE_2__.getCryptoProvider)().sign(secret, (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.numToBytes)(counter), new _crypto__WEBPACK_IMPORTED_MODULE_1__.HMACParams({ hash, keySize: secret.length * 8 }));
    return getToken(hmac, digits);
}
async function totp(secret, time = Date.now(), { interval, ...opts } = { interval: 30, digits: 6, hash: "SHA-1" }) {
    const counter = Math.floor(time / interval / 1000);
    return hotp(secret, counter, opts);
}
function parseURL(data) {
    const url = new URL(data);
    const params = new URLSearchParams(url.search);
    const secret = params.get("secret");
    if (!secret || !(0,_encoding__WEBPACK_IMPORTED_MODULE_0__.base32ToBytes)(secret).length) {
        throw "Invalid secret";
    }
    return { secret };
}


/***/ }),

/***/ "../core/src/quota.ts":
/*!****************************!*\
  !*** ../core/src/quota.ts ***!
  \****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "AccountQuota": () => (/* binding */ AccountQuota),
/* harmony export */   "OrgQuota": () => (/* binding */ OrgQuota)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");

class AccountQuota extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(vals) {
        super();
        this.items = -1;
        this.storage = -1;
        this.orgs = -1;
        if (vals) {
            Object.assign(this, vals);
        }
    }
}
class OrgQuota extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(vals) {
        super();
        this.members = -1;
        this.groups = -1;
        this.vaults = -1;
        this.storage = -1;
        if (vals) {
            Object.assign(this, vals);
        }
    }
}


/***/ }),

/***/ "../core/src/randomart.ts":
/*!********************************!*\
  !*** ../core/src/randomart.ts ***!
  \********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "defaults": () => (/* binding */ defaults),
/* harmony export */   "getValues": () => (/* binding */ getValues),
/* harmony export */   "randomArt": () => (/* binding */ randomArt)
/* harmony export */ });
/** Default options */
const defaults = {
    height: 9,
    width: 17,
    symbols: [" ", ".", "o", "+", "=", "*", "B", "O", "X", "@", "%", "&", "#", "/", "^", "S", "E"]
};
// Converts a buffer to a binary moves array
function getMoves(bytes) {
    const moves = [];
    for (const b of bytes) {
        let str = b.toString(2);
        while (str.length < 8) {
            str = "0" + str;
        }
        moves.push(str.slice(6, 8), str.slice(4, 6), str.slice(2, 4), str.slice(0, 2));
    }
    return moves;
}
// Gets the steps from a set of moves and the box's height and width
function getSteps(moves, width, height) {
    let pos = [(width - 1) / 2, (height - 1) / 2];
    const steps = [pos];
    for (const move of moves) {
        let [x, y] = pos;
        switch (move) {
            case "00":
                x--, y--;
                break;
            case "01":
                x++, y--;
                break;
            case "10":
                x--, y++;
                break;
            case "11":
                x++, y++;
                break;
        }
        pos = [Math.max(0, Math.min(width - 1, x)), Math.max(0, Math.min(height - 1, y))];
        steps.push(pos);
    }
    return steps;
}
// Renders the randomart image from a given fingerprint
function getValues(fingerprint, opts = {}) {
    const { width, height } = Object.assign({}, defaults, opts);
    if (height % 2 !== 1 || width % 2 !== 1) {
        throw "The height and width options must be odd numbers";
    }
    if (fingerprint.length % 2 !== 0) {
        throw "The fingerprint length must be an even number";
    }
    const moves = getMoves(fingerprint);
    const steps = getSteps(moves, width, height);
    const grid = [];
    for (let i = 0; i < height; i++) {
        grid.push(new Array(width).fill(0));
    }
    for (const [x, y] of steps) {
        grid[y][x]++;
    }
    const [x0, y0] = steps[0];
    const [x1, y1] = steps[steps.length - 1];
    grid[y0][x0] = 15;
    grid[y1][x1] = 16;
    return grid;
}
/**
 * Generates a visualisation of a "fingerprint" similar to the ascii-based
 * visualization method used by OpenSSH. Generates a "heat map" of values on a
 * grid of a given width and height using the "drunken bishop" algorithm
 * desribed in [this paper](http://www.dirk-loss.de/sshvis/drunken_bishop.pdf).
 */
function randomArt(fingerprint, opts = {}) {
    const options = Object.assign({}, defaults, opts);
    const vals = getValues(fingerprint, options);
    const symbols = opts.symbols || defaults.symbols;
    return {
        width: options.width,
        height: options.height,
        values: vals,
        symbols: vals.map(line => line.map(val => symbols[val]))
    };
}


/***/ }),

/***/ "../core/src/session.ts":
/*!******************************!*\
  !*** ../core/src/session.ts ***!
  \******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "SessionInfo": () => (/* binding */ SessionInfo),
/* harmony export */   "Session": () => (/* binding */ Session)
/* harmony export */ });
/* harmony import */ var _transport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transport */ "../core/src/transport.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};





/** Public session info (used for display purposes) */
class SessionInfo extends _encoding__WEBPACK_IMPORTED_MODULE_1__.Serializable {
    constructor() {
        super(...arguments);
        this.id = "";
        this.account = "";
        this.created = new Date(0);
        this.updated = new Date(0);
        this.lastUsed = new Date(0);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Date)
], SessionInfo.prototype, "created", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Date)
], SessionInfo.prototype, "updated", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Date)
], SessionInfo.prototype, "lastUsed", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Date)
], SessionInfo.prototype, "expires", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsSerializable)(_platform__WEBPACK_IMPORTED_MODULE_3__.DeviceInfo),
    __metadata("design:type", _platform__WEBPACK_IMPORTED_MODULE_3__.DeviceInfo)
], SessionInfo.prototype, "device", void 0);
/**
 * A session represents a trusted connection between a [[Server]] and [[Client]]
 * which can be used to authenticate requests, allowing both parties to verify
 * the other parties identity and check the request/response bodies integrity.
 * The authentication flow usually works as follows:
 *
 * ```ts
 * // CLIENT
 *
 * const request = createRequest();
 * await this.session.authenticate(request);
 *
 * // SERVER
 *
 * if (!(await context.session.verify(request))) {
 *     throw "Failed to verify request!";
 * }
 *
 * const response = processRequest(request);
 * await context.session.authenticate(response);
 *
 * // CLIENT
 *
 * if (!(await context.session.verify(response))) {
 *     throw "Failed to verify response!";
 * }
 *
 * processResponse(response);
 * ```
 *
 * ```
 *                        ┌──────────┐     ┌──────────┐
 *                        │Client (C)│     │Server (S)│
 *                        └─────┬────┘     └────┬─────┘
 * ┌──────────────────────────┐ │               │
 * │req = [request body]      │ │   req, sid,   │
 * │t1 = [timestamp]          │ │   t1, sig1    │ ┌──────────────────────────┐
 * │sig1 = HMAC(K, sid|t1|req)│ │──────────────▶│ │=> verify sig1            │
 * └──────────────────────────┘ │               │ │res = [response body]     │
 *                              │               │ │t2 = [timestamp]          │
 *             ┌──────────────┐ │ res, t2, sig2 │ │sig2 = HMAC(K, sid|t2|res)│
 *             │=> verify sig2│ │◁ ─ ─ ─ ─ ─ ─ ─│ └──────────────────────────┘
 *             └──────────────┘ │               │
 *                              │               │
 *                              ▼               ▼
 * ```
 */
class Session extends _encoding__WEBPACK_IMPORTED_MODULE_1__.Serializable {
    constructor() {
        super(...arguments);
        /** Unique identifier */
        this.id = "";
        /** Associated [[Account]] */
        this.account = "";
        /** Time of creation */
        this.created = new Date(0);
        /** Time of last update */
        this.updated = new Date(0);
        /** When this session was last used to authenticate a request */
        this.lastUsed = new Date(0);
    }
    /**
     * Public session info
     */
    get info() {
        return new SessionInfo().fromRaw({
            id: this.id,
            account: this.account,
            created: this.created,
            updated: this.updated,
            lastUsed: this.lastUsed,
            expires: this.expires,
            device: this.device && this.device.toRaw()
        });
    }
    /**
     * Authenticates a [[Request]] or [[Response]] by signing the session id,
     * timestamp and request/response body using the session [[key]].
     */
    async authenticate(r) {
        const data = r.params || r.result;
        r.auth = await this._sign(data);
    }
    /**
     * Verifies session id, timestamp and request/response body of a given
     * [[Request]] or [[Response]] using the session [[key]].
     */
    async verify(r) {
        if (!r.auth) {
            return false;
        }
        const data = r.params || r.result;
        return this._verify(r.auth, data);
    }
    async _sign(data) {
        const time = new Date();
        const session = this.id;
        const message = `${session}_${time.toISOString()}_${(0,_encoding__WEBPACK_IMPORTED_MODULE_1__.marshal)(data)}`;
        const signature = await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().sign(this.key, (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.stringToBytes)(message), new _crypto__WEBPACK_IMPORTED_MODULE_2__.HMACParams());
        return new _transport__WEBPACK_IMPORTED_MODULE_0__.RequestAuthentication({
            session,
            time,
            signature
        });
    }
    async _verify(auth, data) {
        const { signature, time } = auth;
        const message = `${this.id}_${time.toISOString()}_${(0,_encoding__WEBPACK_IMPORTED_MODULE_1__.marshal)(data)}`;
        return await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().verify(this.key, signature, (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.stringToBytes)(message), new _crypto__WEBPACK_IMPORTED_MODULE_2__.HMACParams());
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Object)
], Session.prototype, "created", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Object)
], Session.prototype, "updated", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Object)
], Session.prototype, "lastUsed", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsDate)(),
    __metadata("design:type", Date)
], Session.prototype, "expires", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], Session.prototype, "key", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.AsSerializable)(_platform__WEBPACK_IMPORTED_MODULE_3__.DeviceInfo),
    __metadata("design:type", _platform__WEBPACK_IMPORTED_MODULE_3__.DeviceInfo)
], Session.prototype, "device", void 0);


/***/ }),

/***/ "../core/src/srp.ts":
/*!**************************!*\
  !*** ../core/src/srp.ts ***!
  \**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Client": () => (/* binding */ Client),
/* harmony export */   "Server": () => (/* binding */ Server),
/* harmony export */   "Core": () => (/* binding */ Core)
/* harmony export */ });
/* harmony import */ var _vendor_jsbn__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vendor/jsbn */ "../core/vendor/jsbn.js");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto */ "../core/src/crypto.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/**
 * This module implements version 6a of the [Secure Remote
 * Password](http://srp.stanford.edu/design.html) protocol.
 *
 * The [[Client]] and [[Server]] classes are the high-level interfaces to be
 * used on the client and server side, respectively. The SRP key negotiation
 * flow usually happens as follows:
 *
 * #### First signup
 *
 * ```ts
 * // CLIENT
 *
 * const u = [username/email];
 * const p = [user password];
 * const i = [iteration count];
 * const s = [random salt];
 *
 * const x =  PBKDF2(p, s, i);
 *
 * const client = new Client();
 * await client.initialize(x);
 * const v = client.v;
 *
 * => Send u, v, s, i to server
 * ```
 *
 * #### Login / create session
 *
 * ```ts
 * // CLIENT => request login for `u`
 *
 * // SERVER
 *
 * const { v, s, i } = getAuthInfo(u);
 *
 * const server = new Server();
 * await server.initialize(v);
 * const B = server.B;
 *
 * // => Send s, i, B to client
 *
 * // CLIENT
 *
 * const x =  PBKDF2(p, s, i);
 *
 * const client = new Client();
 * await client.initialize(x);
 * await client.setB(B);
 *
 * const A = client.A;
 * const M1 = client.M1;
 *
 * // Common session key
 * const K = client.K;
 *
 * // => Send A, M1 to server
 *
 * // SERVER
 *
 * await server.setA(A);
 * if (server.M1 !== M1) {
 *     throw "Invalid credentials!";
 * }
 *
 * // Common session key
 * const K = server.K;
 *
 * // => Success!
 *
 * // [OPTIONAL] (This step is usually not required since even without
 * // verifying M2, the client will notice something is wrong as soon as they try
 * // to verify an authenticated response from the server.)
 *
 * M2 = server.M2;
 * // => Send M2 to client
 *
 * // CLIENT
 * if (client.M2 !== M2) {
 *     throw "Something is fishy!";
 * }
 * ```
 *
 * #### Overview:
 *
 * ```
 *                     ┌──────────┐     ┌──────────┐
 *                     │Client (C)│     │Server (S)│
 *                     └─────┬────┘     └────┬─────┘
 *     ┌───────────────────┐ │               │
 *     │u = [email address]│ │     u, A      │
 *     │a, A = [random*]   │ │──────────────▶│
 *     └───────────────────┘ │               │ ┌────────────────┐
 *                           │               │ │b, B = [random*]│
 * ┌───────────────────────┐ │    s, i, B    │ └────────────────┘
 * │p = [master password]  │ │◁ ─ ─ ─ ─ ─ ─ ─│
 * │x = PBKDF2(p,s,i)      │ │               │
 * │K = K_client(x, a, B)* │ │               │
 * │M = M(A, B, K)*        │ │       M       │ ┌───────────────────────┐
 * └───────────────────────┘ │──────────────▶│ │K' = K_server(v, b, A)*│
 *                           │               │ │M' = M(A, B, K')       │
 *                           │               │ │=> verify M == M'      │
 *         ┌───────────────┐ │      sid      │ │S = [session id]       │
 *         │=> store sid, K│ │◀ ─ ─ ─ ─ ─ ─ ─│ │=> store sid, K        │
 *         └───────────────┘ │               │ └───────────────────────┘
 *                           │               │
 *                           ▼               ▼
 * ```
 */




async function digest(hash = "SHA-256", ...input) {
    return (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().hash((0,_encoding__WEBPACK_IMPORTED_MODULE_1__.concatBytes)(input), new _crypto__WEBPACK_IMPORTED_MODULE_2__.HashParams({ algorithm: hash }));
}
function i2b(i) {
    let hex = i.toString(16);
    if (hex.length % 2) {
        hex = "0" + hex;
    }
    return (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.hexToBytes)(hex);
}
function b2i(b) {
    return new _vendor_jsbn__WEBPACK_IMPORTED_MODULE_0__.BigInteger((0,_encoding__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)(b), 16);
}
/**
 * High-level interface for the client side
 */
class Client {
    constructor(length = 4096) {
        this._srp = new Core(length);
    }
    /** Verifier value, available after calling [[initialize]] */
    get v() {
        return this._v ? i2b(this._v) : null;
    }
    /** Client-side random initializer, available after calling [[initialize]] */
    get A() {
        return this._A ? i2b(this._A) : null;
    }
    /** Common session key, available after calling [[initialize]] and [[setB]] */
    get K() {
        return this._K ? i2b(this._K) : null;
    }
    /**
     * First value used to verify a successful key exchange, available after
     * calling [[initialize]] and [[setB]]
     */
    get M1() {
        return this._M1 ? i2b(this._M1) : null;
    }
    /**
     * Second value used to verify a successful key exchange, available after
     * calling [[initialize]] and [[setB]]
     */
    get M2() {
        return this._M2 ? i2b(this._M2) : null;
    }
    /** Initialize client using the given secret `x`, generating [[v]] and [[A]] */
    async initialize(x) {
        this._x = b2i(x);
        this._v = this._srp.v(this._x);
        this._a = b2i(await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().randomBytes(32));
        this._A = this._srp.A(this._a);
    }
    /**
     * Apply [[Server.B]] value, calculating [[K]], [[M1]] and [[M2]].
     * Should only be called after [[initialize]] has been called.
     */
    async setB(B) {
        if (!this._x || !this._a || !this._A) {
            throw "not initialized";
        }
        this._B = b2i(B);
        this._K = await this._getKey();
        this._M1 = await this._srp.M1(this._A, this._B, this._K);
        this._M2 = await this._srp.M2(this._A, this._M1, this._K);
    }
    async _getKey() {
        if (!this._x || !this._a || !this._A || !this._B) {
            throw "not initialized";
        }
        if (this._srp.isZeroWhenModN(this._B)) {
            throw "Invalid B value";
        }
        const u = await this._srp.u(this._A, this._B);
        const S = await this._srp.clientS(this._B, this._x, this._a, u);
        const K = await this._srp.K(S);
        return K;
    }
}
class Server {
    constructor(length = 4096) {
        this._srp = new Core(length);
    }
    /** Server-side random initializer, available after calling [[initialize]] */
    get B() {
        return this._B ? i2b(this._B) : null;
    }
    /** Common session key, available after calling [[initialize]] and [[setA]] */
    get K() {
        return this._K ? i2b(this._K) : null;
    }
    /**
     * First value used to verify a successful key exchange, available after
     * calling [[initialize]] and [[setA]]
     */
    get M1() {
        return this._M1 ? i2b(this._M1) : null;
    }
    /**
     * Second value used to verify a successful key exchange, available after
     * calling [[initialize]] and [[setA]]
     */
    get M2() {
        return this._M2 ? i2b(this._M2) : null;
    }
    /** Initialize server using the given verfifier `v`. Generates [[B]]. */
    async initialize(v) {
        this._v = b2i(v);
        this._b = b2i(await (0,_platform__WEBPACK_IMPORTED_MODULE_3__.getCryptoProvider)().randomBytes(32));
        this._B = await this._srp.B(this._v, this._b);
    }
    /**
     * Apply [[Client.A]] value, calculating [[K]], [[M1]] and [[M2]].
     * Should only be called after [[initialize]] has been called.
     */
    async setA(A) {
        if (!this._v || !this._b || !this._B) {
            throw "not initialized";
        }
        this._A = b2i(A);
        this._K = await this._getKey();
        this._M1 = await this._srp.M1(this._A, this._B, this._K);
        this._M2 = await this._srp.M2(this._A, this._M1, this._K);
    }
    async _getKey() {
        if (!this._v || !this._b || !this._B || !this._A) {
            throw "not initialized";
        }
        if (this._srp.isZeroWhenModN(this._A)) {
            throw "Invalid A value";
        }
        const u = await this._srp.u(this._A, this._B);
        const S = this._srp.serverS(this._A, this._v, u, this._b);
        const K = await this._srp.K(S);
        return K;
    }
}
/**
 * Implements various formulas defined in the [SRP
 * specification](http://srp.stanford.edu/design.html), used by [[Client]] and
 * [[Server]] classes.
 */
class Core {
    constructor(length) {
        this._params = getParams(length);
        if (!this._params) {
            throw "Invalid group length!";
        }
    }
    /** Creates a hash of all arguments, concatenated */
    async H(...inp) {
        const hash = await digest(this._params.hash, ...inp.map(i => i2b(i)));
        return b2i(hash);
    }
    /**
     * Calculates verifier `v` from secret `x` according to the formula
     * ```
     * v = g ^ x % N
     * ```
     */
    v(x) {
        return this._params.g.modPow(x, this._params.N);
    }
    /** Calculates `A` from random value `a`, according to the formula
     * ```
     * A = g ^ a % N
     * ```
     */
    A(a) {
        return this._params.g.modPow(a, this._params.N);
    }
    /**
     * Calculates `B` from `v` and the random value `b` according to the formula
     * ```
     * B = (k * v + g ^ b % N) % N
     * ```
     */
    async B(v, b) {
        const k = await this.k();
        return k
            .multiply(v)
            .add(this._params.g.modPow(b, this._params.N))
            .mod(this._params.N);
    }
    /**
     * Calculates `u` from `A` and `B` according to the formula
     * ```
     * u = H(A | B)
     * ```
     */
    async u(A, B) {
        return await this.H(A, B);
    }
    /**
     * Calculates `S` from `B`, `x`, `a` and `u` according to the formula
     * ```
     * S = (B - k * (g ^ x % N)) ^ (a + u * x) % N
     * ```
     */
    async clientS(B, x, a, u) {
        const k = await this.k();
        return B.subtract(k.multiply(this._params.g.modPow(x, this._params.N))).modPow(a.add(u.multiply(x)), this._params.N);
    }
    /**
     * Calculates `S` from `A`, `v`, `b` and `u` according to the formula
     * ```
     * S = (A * v ^ u % N) ^ b % N
     * ```
     */
    serverS(A, v, u, b) {
        return A.multiply(v.modPow(u, this._params.N)).modPow(b, this._params.N);
    }
    /**
     * Calculates the multiplier `k = H(N | g)` according to the SRP-6a specification
     */
    async k() {
        return this.H(this._params.N, this._params.g);
    }
    /**
     * Calculates the shared key `K = H(S)`
     */
    async K(S) {
        return this.H(S);
    }
    /**
     * Calculates the first verification value `M1 = H(A | B | K)`
     */
    async M1(A, B, K) {
        return await this.H(A, B, K);
    }
    /**
     * Calculates the second verification value `M2 = H(A | M1 | K)`
     */
    async M2(A, M1, K) {
        return await this.H(A, M1, K);
    }
    /**
     * This is used to ensure that values are not zero when mod N.
     */
    isZeroWhenModN(n) {
        return n.mod(this._params.N).equals(_vendor_jsbn__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO);
    }
}
function h2i(hex) {
    return new _vendor_jsbn__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hex.replace(" ", ""), 16);
}
function getParams(length) {
    switch (length) {
        case 3072:
            return {
                length: 3072,
                hash: "SHA-256",
                g: h2i("05"),
                N: h2i("FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F 83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D 670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9 DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510 15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64 ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7 ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31 43DB5BFC E0FD108E 4B82D120 A93AD2CA FFFFFFFF FFFFFFFF")
            };
        case 4096:
            return {
                length: 4096,
                hash: "SHA-256",
                g: h2i("05"),
                N: h2i("FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F 83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D 670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9 DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510 15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64 ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7 ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31 43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7 88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA 2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6 287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED 1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9 93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34063199 FFFFFFFF FFFFFFFF")
            };
        case 6144:
            return {
                length: 6144,
                hash: "SHA-256",
                g: h2i("05"),
                N: h2i("FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F 83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D 670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9 DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510 15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64 ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7 ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31 43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7 88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA 2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6 287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED 1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9 93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492 36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD F8FF9406 AD9E530E E5DB382F 413001AE B06A53ED 9027D831 179727B0 865A8918 DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B DB7F1447 E6CC254B 33205151 2BD7AF42 6FB8F401 378CD2BF 5983CA01 C64B92EC F032EA15 D1721D03 F482D7CE 6E74FEF6 D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F BEC7E8F3 23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328 06A1D58B B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C DA56C9EC 2EF29632 387FE8D7 6E3C0468 043E8F66 3F4860EE 12BF2D5B 0B7474D6 E694F91E 6DCC4024 FFFFFFFF FFFFFFFF")
            };
        case 8192:
            return {
                length: 8192,
                hash: "SHA-256",
                g: h2i("13"),
                N: h2i("FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F 83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D 670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9 DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510 15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64 ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7 ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31 43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7 88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA 2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6 287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED 1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9 93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492 36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD F8FF9406 AD9E530E E5DB382F 413001AE B06A53ED 9027D831 179727B0 865A8918 DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B DB7F1447 E6CC254B 33205151 2BD7AF42 6FB8F401 378CD2BF 5983CA01 C64B92EC F032EA15 D1721D03 F482D7CE 6E74FEF6 D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F BEC7E8F3 23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328 06A1D58B B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C DA56C9EC 2EF29632 387FE8D7 6E3C0468 043E8F66 3F4860EE 12BF2D5B 0B7474D6 E694F91E 6DBE1159 74A3926F 12FEE5E4 38777CB6 A932DF8C D8BEC4D0 73B931BA 3BC832B6 8D9DD300 741FA7BF 8AFC47ED 2576F693 6BA42466 3AAB639C 5AE4F568 3423B474 2BF1C978 238F16CB E39D652D E3FDB8BE FC848AD9 22222E04 A4037C07 13EB57A8 1A23F0C7 3473FC64 6CEA306B 4BCBC886 2F8385DD FA9D4B7F A2C087E8 79683303 ED5BDD3A 062B3CF5 B3A278A6 6D2A13F8 3F44F82D DF310EE0 74AB6A36 4597E899 A0255DC1 64F31CC5 0846851D F9AB4819 5DED7EA1 B1D510BD 7EE74D73 FAF36BC3 1ECFA268 359046F4 EB879F92 4009438B 481C6CD7 889A002E D5EE382B C9190DA6 FC026E47 9558E447 5677E9AA 9E3050E2 765694DF C81F56E8 80B96E71 60C980DD 98EDD3DF FFFFFFFF FFFFFFFF")
            };
        default:
            throw "invalid group length";
    }
}


/***/ }),

/***/ "../core/src/transport.ts":
/*!********************************!*\
  !*** ../core/src/transport.ts ***!
  \********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "RequestAuthentication": () => (/* binding */ RequestAuthentication),
/* harmony export */   "Request": () => (/* binding */ Request),
/* harmony export */   "Response": () => (/* binding */ Response),
/* harmony export */   "DirectSender": () => (/* binding */ DirectSender),
/* harmony export */   "RequestProgress": () => (/* binding */ RequestProgress)
/* harmony export */ });
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _event_target__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./event-target */ "../core/src/event-target.ts");
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./util */ "../core/src/util.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




/** Authentication data */
class RequestAuthentication extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor(vals = {}) {
        super();
        /** The id of the [[Session]] used for authentication */
        this.session = "";
        Object.assign(this, vals);
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsDate)(),
    __metadata("design:type", Date)
], RequestAuthentication.prototype, "time", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsBytes)(),
    __metadata("design:type", Uint8Array)
], RequestAuthentication.prototype, "signature", void 0);
/** RPC request object */
class Request extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        /** Name of the method call */
        this.method = "";
        /** Arguments for the method */
        this.params = undefined;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(RequestAuthentication),
    __metadata("design:type", RequestAuthentication)
], Request.prototype, "auth", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(_platform__WEBPACK_IMPORTED_MODULE_1__.DeviceInfo),
    __metadata("design:type", _platform__WEBPACK_IMPORTED_MODULE_1__.DeviceInfo)
], Request.prototype, "device", void 0);
/** RPC response object */
class Response extends _encoding__WEBPACK_IMPORTED_MODULE_0__.Serializable {
    constructor() {
        super(...arguments);
        /** The result of the RPC call */
        this.result = null;
        /** Error info, if an error occurred while processing the request */
        this.error = undefined;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_0__.AsSerializable)(RequestAuthentication),
    __metadata("design:type", RequestAuthentication)
], Response.prototype, "auth", void 0);
/**
 * Stub implementation of the [[Sender]] interface, passing requests directly
 * into a [[Server]] instance.  this is useful for testing, where client and
 * server instances are managed by the same process
 */
class DirectSender {
    constructor(server) {
        this.server = server;
    }
    async send(req) {
        await (0,_util__WEBPACK_IMPORTED_MODULE_3__.wait)(10);
        return this.server.handle(req);
    }
}
class RequestProgress extends _event_target__WEBPACK_IMPORTED_MODULE_2__.EventEmitter {
    constructor() {
        super(...arguments);
        this.completed = new Promise((resolve, reject) => {
            this._resolveCompleted = resolve;
            this._rejectCompleted = reject;
        });
        this._uploadProgress = { loaded: 0, total: 0 };
        this._downloadProgress = { loaded: 0, total: 0 };
    }
    get uploadProgress() {
        return this._uploadProgress;
    }
    set uploadProgress(progress) {
        this._uploadProgress = progress;
        this.dispatch("upload-progress", progress);
        this.dispatch("progress", this.progress);
    }
    get downloadProgress() {
        return this._downloadProgress;
    }
    set downloadProgress(progress) {
        this._downloadProgress = progress;
        this.dispatch("download-progress", progress);
        this.dispatch("progress", this.progress);
    }
    get progress() {
        return {
            loaded: this.uploadProgress.loaded + this.downloadProgress.loaded,
            total: this.uploadProgress.total + this.downloadProgress.total
        };
    }
    set error(error) {
        this._error = error;
        if (error) {
            this.dispatch("error", { error });
            this.uploadProgress = this.downloadProgress = { loaded: 0, total: 0 };
            this._rejectCompleted(error);
        }
    }
    get error() {
        return this._error;
    }
    complete() {
        this._resolveCompleted();
    }
}


/***/ }),

/***/ "../core/src/util.ts":
/*!***************************!*\
  !*** ../core/src/util.ts ***!
  \***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "uuid": () => (/* binding */ uuid),
/* harmony export */   "chars": () => (/* binding */ chars),
/* harmony export */   "charSets": () => (/* binding */ charSets),
/* harmony export */   "randomString": () => (/* binding */ randomString),
/* harmony export */   "randomNumber": () => (/* binding */ randomNumber),
/* harmony export */   "debounce": () => (/* binding */ debounce),
/* harmony export */   "throttle": () => (/* binding */ throttle),
/* harmony export */   "wait": () => (/* binding */ wait),
/* harmony export */   "resolveLanguage": () => (/* binding */ resolveLanguage),
/* harmony export */   "applyMixins": () => (/* binding */ applyMixins),
/* harmony export */   "escapeRegex": () => (/* binding */ escapeRegex)
/* harmony export */ });
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./platform */ "../core/src/platform.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");


/** Generates a random UUID v4 */
async function uuid() {
    const bytes = await (0,_platform__WEBPACK_IMPORTED_MODULE_0__.getCryptoProvider)().randomBytes(16);
    // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
    bytes[6] = (bytes[6] & 0x0f) | 0x40;
    bytes[8] = (bytes[8] & 0x3f) | 0x80;
    // Canonical representation
    // XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
    return [
        (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)(bytes.slice(0, 4)),
        "-",
        (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)(bytes.slice(4, 6)),
        "-",
        (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)(bytes.slice(6, 8)),
        "-",
        (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)(bytes.slice(8, 10)),
        "-",
        (0,_encoding__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)(bytes.slice(10, 16))
    ].join("");
}
/** Caracters, by category */
const chars = {
    numbers: "0123456789",
    lower: "abcdefghijklmnopqrstuvwxyz",
    upper: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
    other: "/+()%\"=&-!:'*#?;,_.@`~$^[{]}\\|<>"
};
/** Predefined char sets for generating randing strings */
const charSets = {
    full: chars.numbers + chars.upper + chars.lower + chars.other,
    alphanum: chars.numbers + chars.upper + chars.lower,
    alpha: chars.lower + chars.upper,
    num: chars.numbers,
    hexa: chars.numbers + "abcdef"
};
/** Creates a random string with a given `length`, with characters chosen from a given `charSet` */
async function randomString(length = 32, charSet = charSets.full) {
    const provider = (0,_platform__WEBPACK_IMPORTED_MODULE_0__.getCryptoProvider)();
    let str = "";
    while (str.length < length) {
        const [rnd] = await provider.randomBytes(1);
        // Prevent modulo bias by rejecting values larger than the highest muliple of `charSet.length`
        if (rnd > 255 - (256 % charSet.length)) {
            continue;
        }
        str += charSet[rnd % charSet.length];
    }
    return str;
}
/**
 * Generates a random number between `min` and `max`.
 * Taken from https://github.com/EFForg/OpenWireless/blob/master/app/js/diceware.js
 */
async function randomNumber(min = 0, max = 10) {
    if (max < min) {
        throw "Upper bound must be greater than or equal to lower bound!";
    }
    let rval = 0;
    const range = max - min + 1;
    const bitsNeeded = Math.ceil(Math.log2(range));
    if (bitsNeeded > 53) {
        throw new Error("We cannot generate numbers larger than 53 bits.");
    }
    const bytesNeeded = Math.ceil(bitsNeeded / 8);
    const mask = Math.pow(2, bitsNeeded) - 1;
    // Fill a byte array with N random numbers
    const byteArray = await (0,_platform__WEBPACK_IMPORTED_MODULE_0__.getCryptoProvider)().randomBytes(bytesNeeded);
    let p = (bytesNeeded - 1) * 8;
    for (let i = 0; i < bytesNeeded; i++) {
        rval += byteArray[i] * Math.pow(2, p);
        p -= 8;
    }
    // Use & to apply the mask and reduce the number of recursive lookups
    // tslint:disable-next-line
    rval = rval & mask;
    if (rval >= range) {
        // Integer out of acceptable range
        return randomNumber(min, max);
    }
    // Return an integer that falls within the range
    return min + rval;
}
/**
 * "Debounces" a function, making sure it is only called once within a certain
 * time window
 */
function debounce(fn, delay) {
    let timeout;
    return function (...args) {
        clearTimeout(timeout);
        timeout = window.setTimeout(() => fn(...args), delay);
    };
}
// export function throttle(fn: (...args: any[]) => any, delay: number) {
//     let throttling = false;
//     let lastCall = args: any[];
//
//     return function(...args: any[]) {
//         if (!throttling) {
//             fn(...args);
//             throttling = true;
//             setTimeout(() => (throttling = false), delay);
//         }
//     };
// }
function throttle(fn, delay) {
    let lastCall;
    let lastRan;
    return (...args) => {
        if (!lastRan) {
            fn(...args);
            lastRan = Date.now();
        }
        else {
            clearTimeout(lastCall);
            lastCall = setTimeout(() => {
                if (Date.now() - lastRan >= delay) {
                    fn(...args);
                    lastRan = Date.now();
                }
            }, delay - (Date.now() - lastRan));
        }
    };
}
/** Returns a promise that resolves after a given `delay`. */
function wait(delay) {
    return new Promise(resolve => setTimeout(resolve, delay));
}
/**
 * Resolves a given locale string to the approprivate available language
 */
function resolveLanguage(locale, supportedLanguages) {
    const localeParts = locale.toLowerCase().split("-");
    while (localeParts.length) {
        const l = localeParts.join("-");
        if (supportedLanguages[l]) {
            return l;
        }
        localeParts.pop();
    }
    return Object.keys(supportedLanguages)[0];
}
/**
 * Applies a number of class `mixins` to a `baseClass`
 */
function applyMixins(baseClass, ...mixins) {
    return mixins.reduce((cls, mixin) => mixin(cls), baseClass);
}
/**
 * Escapes all regex special characters within a given string.
 */
function escapeRegex(str) {
    return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}


/***/ }),

/***/ "../core/src/vault.ts":
/*!****************************!*\
  !*** ../core/src/vault.ts ***!
  \****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Vault": () => (/* binding */ Vault)
/* harmony export */ });
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./container */ "../core/src/container.ts");
/* harmony import */ var _collection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collection */ "../core/src/collection.ts");
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./encoding */ "../core/src/encoding.ts");
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./error */ "../core/src/error.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};




/**
 * Container for securely storing a collection of [[VaultItem]]s. Vaults can be owned by a single
 * user ("private" vaults) or shared between multiple users ("shared" vaults). Shared vaults are
 * provisioned and managed through [[Org]]s.
 */
class Vault extends _container__WEBPACK_IMPORTED_MODULE_0__.SharedContainer {
    constructor() {
        super(...arguments);
        /** unique identifier */
        this.id = "";
        /** The [[Org]] this vault belongs to (if a shared vault) */
        this.org = undefined;
        /** Vault name */
        this.name = "";
        /** The vault owner (the [[Account]] that created this vault) */
        this.owner = "";
        /** Time of creation */
        this.created = new Date(0);
        /** Time of last update */
        this.updated = new Date(0);
        /**
         * Revision id used for ensuring continuity when synchronizing the vault
         * object between client and server
         */
        this.revision = "";
        /**
         * A collection [[VaultItem]]s representing the senstive data store in this vault
         *
         * @secret
         *
         * **IMPORTANT**: This property is considered **secret**
         * and should never stored or transmitted in plain text
         */
        this.items = new _collection__WEBPACK_IMPORTED_MODULE_1__.VaultItemCollection();
    }
    /**
     * Unlocks the vault with the given `account`, decrypting the data stored in the vault
     * and populating the [[items]] property. For this to be successful, the `account` object
     * needs to be unlocked and the account must have access to this vault.
     */
    async unlock(account) {
        if (!this.accessors.length) {
            await this.updateAccessors([account]);
            await this.commit();
        }
        else {
            await super.unlock(account);
            this.items.fromBytes(await this.getData());
        }
    }
    async lock() {
        await super.lock();
        this.items = new _collection__WEBPACK_IMPORTED_MODULE_1__.VaultItemCollection();
    }
    /**
     * Commit changes to `items` by reencrypting the data.
     */
    async commit() {
        await this.setData(this.items.toBytes());
    }
    /**
     * Merges in changes from another `vault`. This requires both vaults to be unlocked.
     *
     * @returns `true` if there have been any "forward changes", i.e. if there
     * have been any changes in this vault that may need to be applied to other
     * instances. Specifically, this can be used during synchronization with a [[Server]]
     * to determine whether an update needs to be pushed back.
     */
    merge(vault) {
        this.items.merge(vault.items);
        this.name = vault.name;
        this.revision = vault.revision;
        this.org = vault.org;
        this.updated = vault.updated;
    }
    toString() {
        return this.org ? `${this.org.name} / ${this.name}` : this.name;
    }
    clone() {
        const clone = super.clone();
        clone.items = this.items.clone();
        return clone;
    }
}
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsDate)(),
    __metadata("design:type", Object)
], Vault.prototype, "created", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.AsDate)(),
    __metadata("design:type", Object)
], Vault.prototype, "updated", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.Exclude)(),
    __metadata("design:type", Object)
], Vault.prototype, "items", void 0);
__decorate([
    (0,_encoding__WEBPACK_IMPORTED_MODULE_2__.Exclude)(),
    __metadata("design:type", _error__WEBPACK_IMPORTED_MODULE_3__.Err)
], Vault.prototype, "error", void 0);


/***/ }),

/***/ "../locale/src/countries.ts":
/*!**********************************!*\
  !*** ../locale/src/countries.ts ***!
  \**********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "countries": () => (/* binding */ countries)
/* harmony export */ });
const countries = [
    { code: "AF", name: "Afghanistan" },
    { code: "AX", name: "Åland Islands" },
    { code: "AL", name: "Albania" },
    { code: "DZ", name: "Algeria" },
    { code: "AD", name: "Andorra" },
    { code: "AO", name: "Angola" },
    { code: "AI", name: "Anguilla" },
    { code: "AQ", name: "Antarctica" },
    { code: "AG", name: "Antigua &amp; Barbuda" },
    { code: "AR", name: "Argentina" },
    { code: "AM", name: "Armenia" },
    { code: "AW", name: "Aruba" },
    { code: "AC", name: "Ascension Island" },
    { code: "AU", name: "Australia" },
    { code: "AT", name: "Austria" },
    { code: "AZ", name: "Azerbaijan" },
    { code: "BS", name: "Bahamas" },
    { code: "BH", name: "Bahrain" },
    { code: "BD", name: "Bangladesh" },
    { code: "BB", name: "Barbados" },
    { code: "BY", name: "Belarus" },
    { code: "BE", name: "Belgium" },
    { code: "BZ", name: "Belize" },
    { code: "BJ", name: "Benin" },
    { code: "BM", name: "Bermuda" },
    { code: "BT", name: "Bhutan" },
    { code: "BO", name: "Bolivia" },
    { code: "BA", name: "Bosnia &amp; Herzegovina" },
    { code: "BW", name: "Botswana" },
    { code: "BV", name: "Bouvet Island" },
    { code: "BR", name: "Brazil" },
    { code: "IO", name: "British Indian Ocean Territory" },
    { code: "VG", name: "British Virgin Islands" },
    { code: "BN", name: "Brunei" },
    { code: "BG", name: "Bulgaria" },
    { code: "BF", name: "Burkina Faso" },
    { code: "BI", name: "Burundi" },
    { code: "KH", name: "Cambodia" },
    { code: "CM", name: "Cameroon" },
    { code: "CA", name: "Canada" },
    { code: "CV", name: "Cape Verde" },
    { code: "BQ", name: "Caribbean Netherlands" },
    { code: "KY", name: "Cayman Islands" },
    { code: "CF", name: "Central African Republic" },
    { code: "TD", name: "Chad" },
    { code: "CL", name: "Chile" },
    { code: "CN", name: "China" },
    { code: "CO", name: "Colombia" },
    { code: "KM", name: "Comoros" },
    { code: "CG", name: "Congo - Brazzaville" },
    { code: "CD", name: "Congo - Kinshasa" },
    { code: "CK", name: "Cook Islands" },
    { code: "CR", name: "Costa Rica" },
    { code: "CI", name: "Côte d’Ivoire" },
    { code: "HR", name: "Croatia" },
    { code: "CW", name: "Curaçao" },
    { code: "CY", name: "Cyprus" },
    { code: "CZ", name: "Czechia" },
    { code: "DK", name: "Denmark" },
    { code: "DJ", name: "Djibouti" },
    { code: "DM", name: "Dominica" },
    { code: "DO", name: "Dominican Republic" },
    { code: "EC", name: "Ecuador" },
    { code: "EG", name: "Egypt" },
    { code: "SV", name: "El Salvador" },
    { code: "GQ", name: "Equatorial Guinea" },
    { code: "ER", name: "Eritrea" },
    { code: "EE", name: "Estonia" },
    { code: "ET", name: "Ethiopia" },
    { code: "FK", name: "Falkland Islands" },
    { code: "FO", name: "Faroe Islands" },
    { code: "FJ", name: "Fiji" },
    { code: "FI", name: "Finland" },
    { code: "FR", name: "France" },
    { code: "GF", name: "French Guiana" },
    { code: "PF", name: "French Polynesia" },
    { code: "TF", name: "French Southern Territories" },
    { code: "GA", name: "Gabon" },
    { code: "GM", name: "Gambia" },
    { code: "GE", name: "Georgia" },
    { code: "DE", name: "Germany" },
    { code: "GH", name: "Ghana" },
    { code: "GI", name: "Gibraltar" },
    { code: "GR", name: "Greece" },
    { code: "GL", name: "Greenland" },
    { code: "GD", name: "Grenada" },
    { code: "GP", name: "Guadeloupe" },
    { code: "GU", name: "Guam" },
    { code: "GT", name: "Guatemala" },
    { code: "GG", name: "Guernsey" },
    { code: "GN", name: "Guinea" },
    { code: "GW", name: "Guinea-Bissau" },
    { code: "GY", name: "Guyana" },
    { code: "HT", name: "Haiti" },
    { code: "HN", name: "Honduras" },
    { code: "HK", name: "Hong Kong SAR China" },
    { code: "HU", name: "Hungary" },
    { code: "IS", name: "Iceland" },
    { code: "IN", name: "India" },
    { code: "ID", name: "Indonesia" },
    { code: "IR", name: "Iran" },
    { code: "IQ", name: "Iraq" },
    { code: "IE", name: "Ireland" },
    { code: "IM", name: "Isle of Man" },
    { code: "IL", name: "Israel" },
    { code: "IT", name: "Italy" },
    { code: "JM", name: "Jamaica" },
    { code: "JP", name: "Japan" },
    { code: "JE", name: "Jersey" },
    { code: "JO", name: "Jordan" },
    { code: "KZ", name: "Kazakhstan" },
    { code: "KE", name: "Kenya" },
    { code: "KI", name: "Kiribati" },
    { code: "XK", name: "Kosovo" },
    { code: "KW", name: "Kuwait" },
    { code: "KG", name: "Kyrgyzstan" },
    { code: "LA", name: "Laos" },
    { code: "LV", name: "Latvia" },
    { code: "LB", name: "Lebanon" },
    { code: "LS", name: "Lesotho" },
    { code: "LR", name: "Liberia" },
    { code: "LY", name: "Libya" },
    { code: "LI", name: "Liechtenstein" },
    { code: "LT", name: "Lithuania" },
    { code: "LU", name: "Luxembourg" },
    { code: "MO", name: "Macau SAR China" },
    { code: "MK", name: "Macedonia" },
    { code: "MG", name: "Madagascar" },
    { code: "MW", name: "Malawi" },
    { code: "MY", name: "Malaysia" },
    { code: "MV", name: "Maldives" },
    { code: "ML", name: "Mali" },
    { code: "MT", name: "Malta" },
    { code: "MQ", name: "Martinique" },
    { code: "MR", name: "Mauritania" },
    { code: "MU", name: "Mauritius" },
    { code: "YT", name: "Mayotte" },
    { code: "MX", name: "Mexico" },
    { code: "MD", name: "Moldova" },
    { code: "MC", name: "Monaco" },
    { code: "MN", name: "Mongolia" },
    { code: "ME", name: "Montenegro" },
    { code: "MS", name: "Montserrat" },
    { code: "MA", name: "Morocco" },
    { code: "MZ", name: "Mozambique" },
    { code: "MM", name: "Myanmar (Burma)" },
    { code: "NA", name: "Namibia" },
    { code: "NR", name: "Nauru" },
    { code: "NP", name: "Nepal" },
    { code: "NL", name: "Netherlands" },
    { code: "NC", name: "New Caledonia" },
    { code: "NZ", name: "New Zealand" },
    { code: "NI", name: "Nicaragua" },
    { code: "NE", name: "Niger" },
    { code: "NG", name: "Nigeria" },
    { code: "NU", name: "Niue" },
    { code: "NO", name: "Norway" },
    { code: "OM", name: "Oman" },
    { code: "PK", name: "Pakistan" },
    { code: "PS", name: "Palestinian Territories" },
    { code: "PA", name: "Panama" },
    { code: "PG", name: "Papua New Guinea" },
    { code: "PY", name: "Paraguay" },
    { code: "PE", name: "Peru" },
    { code: "PH", name: "Philippines" },
    { code: "PN", name: "Pitcairn Islands" },
    { code: "PL", name: "Poland" },
    { code: "PT", name: "Portugal" },
    { code: "PR", name: "Puerto Rico" },
    { code: "QA", name: "Qatar" },
    { code: "RE", name: "Réunion" },
    { code: "RO", name: "Romania" },
    { code: "RU", name: "Russia" },
    { code: "RW", name: "Rwanda" },
    { code: "WS", name: "Samoa" },
    { code: "SM", name: "San Marino" },
    { code: "ST", name: "São Tomé &amp; Príncipe" },
    { code: "SA", name: "Saudi Arabia" },
    { code: "SN", name: "Senegal" },
    { code: "RS", name: "Serbia" },
    { code: "SC", name: "Seychelles" },
    { code: "SL", name: "Sierra Leone" },
    { code: "SG", name: "Singapore" },
    { code: "SX", name: "Sint Maarten" },
    { code: "SK", name: "Slovakia" },
    { code: "SI", name: "Slovenia" },
    { code: "SB", name: "Solomon Islands" },
    { code: "SO", name: "Somalia" },
    { code: "ZA", name: "South Africa" },
    { code: "GS", name: "South Georgia &amp; South Sandwich Islands" },
    { code: "KR", name: "South Korea" },
    { code: "SS", name: "South Sudan" },
    { code: "ES", name: "Spain" },
    { code: "LK", name: "Sri Lanka" },
    { code: "BL", name: "St. Barthélemy" },
    { code: "SH", name: "St. Helena" },
    { code: "KN", name: "St. Kitts &amp; Nevis" },
    { code: "LC", name: "St. Lucia" },
    { code: "MF", name: "St. Martin" },
    { code: "PM", name: "St. Pierre &amp; Miquelon" },
    { code: "VC", name: "St. Vincent &amp; Grenadines" },
    { code: "SR", name: "Suriname" },
    { code: "SJ", name: "Svalbard &amp; Jan Mayen" },
    { code: "SZ", name: "Swaziland" },
    { code: "SE", name: "Sweden" },
    { code: "CH", name: "Switzerland" },
    { code: "TW", name: "Taiwan" },
    { code: "TJ", name: "Tajikistan" },
    { code: "TZ", name: "Tanzania" },
    { code: "TH", name: "Thailand" },
    { code: "TL", name: "Timor-Leste" },
    { code: "TG", name: "Togo" },
    { code: "TK", name: "Tokelau" },
    { code: "TO", name: "Tonga" },
    { code: "TT", name: "Trinidad &amp; Tobago" },
    { code: "TA", name: "Tristan da Cunha" },
    { code: "TN", name: "Tunisia" },
    { code: "TR", name: "Turkey" },
    { code: "TM", name: "Turkmenistan" },
    { code: "TC", name: "Turks &amp; Caicos Islands" },
    { code: "TV", name: "Tuvalu" },
    { code: "UG", name: "Uganda" },
    { code: "UA", name: "Ukraine" },
    { code: "AE", name: "United Arab Emirates" },
    { code: "GB", name: "United Kingdom" },
    { code: "US", name: "United States" },
    { code: "UY", name: "Uruguay" },
    { code: "UZ", name: "Uzbekistan" },
    { code: "VU", name: "Vanuatu" },
    { code: "VA", name: "Vatican City" },
    { code: "VE", name: "Venezuela" },
    { code: "VN", name: "Vietnam" },
    { code: "WF", name: "Wallis &amp; Futuna" },
    { code: "EH", name: "Western Sahara" },
    { code: "YE", name: "Yemen" },
    { code: "ZM", name: "Zambia" },
    { code: "ZW", name: "Zimbabwe" }
];


/***/ }),

/***/ "../locale/src/wordlists.ts":
/*!**********************************!*\
  !*** ../locale/src/wordlists.ts ***!
  \**********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "getWordList": () => (/* binding */ getWordList),
/* harmony export */   "AVAILABLE_LANGUAGES": () => (/* binding */ AVAILABLE_LANGUAGES)
/* harmony export */ });
const loadWordListPromises = new Map();
async function getWordList(lang) {
    lang = lang.toLowerCase();
    if (loadWordListPromises.has(lang)) {
        return loadWordListPromises.get(lang);
    }
    const promise = (async () => {
        try {
            const { default: words } = await __webpack_require__("../locale/res/wordlists lazy recursive ^\\.\\/.*\\.json$")(`./${lang}.json`);
            return words;
        }
        catch (e) {
            const dashIndex = lang.lastIndexOf("-");
            if (dashIndex !== -1) {
                return getWordList(lang.substring(0, dashIndex));
            }
            else {
                return [];
            }
        }
    })();
    loadWordListPromises.set(lang, promise);
    return promise;
}
const AVAILABLE_LANGUAGES = [
    { value: "en", toString: () => "English" },
    { value: "de", toString: () => "Deutsch" },
    { value: "es", toString: () => "Español" },
    { value: "pt", toString: () => "Português" },
    { value: "fr", toString: () => "Français" }
];


/***/ })

}]);
//# sourceMappingURL=app_src_elements_app_ts.chunk.js.map