var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './core-8e73947d.js';
import { c as createCommonjsModule, u as unwrapExports, a as commonjsGlobal } from './_commonjsHelpers-97e6d7b1.js';
import { d as dist_9, a as dist_6 } from './index-b6097e3d.js';
var crypto_browser = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.crypto = window.crypto;
});
unwrapExports(crypto_browser);
var TextEncoder_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var TextEncoder = /** @class */ (function () {
        function TextEncoder() {
            this.encoding = "utf-8";
        }
        TextEncoder.prototype.encode = function (data) {
            return Uint8Array.from(unescape(encodeURIComponent(data)).split(""), function (c) { return c.charCodeAt(0); });
        };
        return TextEncoder;
    }());
    exports.TextEncoder = TextEncoder;
});
unwrapExports(TextEncoder_1);
var Base64 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var tables = {
        standard: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
        url: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
    };
    function encode(value, standard, padding) {
        if (standard === void 0) { standard = "standard"; }
        if (padding === void 0) { padding = ""; }
        if (typeof (value) == "string")
            value = new TextEncoder_1.TextEncoder().encode(value);
        var table = tables[standard];
        var result = [];
        for (var c = 0; c < value.length; c += 3) {
            var c0 = value[c];
            var c1 = c + 1 < value.length ? value[c + 1] : 0;
            var c2 = c + 2 < value.length ? value[c + 2] : 0;
            result.push(table[c0 >>> 2]);
            result.push(table[(c0 & 3) << 4 | (c1 >>> 4)]);
            result.push(table[((c1 & 15) << 2) | (c2 >>> 6)]);
            result.push(table[c2 & 63]);
        }
        var length = Math.ceil(value.length / 3 * 4);
        return result.join("").substr(0, length) + padding.repeat(result.length - length);
    }
    exports.encode = encode;
    function decode(value, standard) {
        if (standard === void 0) { standard = "standard"; }
        while (value.endsWith("=") && value.length > 0)
            value = value.substr(0, value.length - 1);
        var table = tables[standard];
        var data = value.split("").map(function (c) { return table.indexOf(c); });
        var result = new Uint8Array(Math.floor(data.length / 4 * 3));
        for (var c = 0; c < result.length; c += 3) {
            var d0 = data.shift() || 0;
            var d1 = data.shift() || 0;
            var d2 = data.shift() || 0;
            var d3 = data.shift() || 0;
            result[c] = (d0 << 2) | (d1 >>> 4);
            result[c + 1] = ((d1 & 15) << 4) | (d2 >>> 2);
            result[c + 2] = ((d2 & 3) << 6) | d3;
        }
        return result;
    }
    exports.decode = decode;
});
unwrapExports(Base64);
var TextDecoder_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var TextDecoder = /** @class */ (function () {
        function TextDecoder() {
            this.encoding = "utf-8";
        }
        TextDecoder.prototype.decode = function (view, options) {
            return !view ? "" : decodeURIComponent(escape(Array.from(new Uint8Array(view.buffer, view.byteOffset, view.byteLength), function (c) { return String.fromCharCode(c); }).join("")));
        };
        return TextDecoder;
    }());
    exports.TextDecoder = TextDecoder;
});
unwrapExports(TextDecoder_1);
var PropertyCrypto_1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var PropertyCrypto = /** @class */ (function () {
        function PropertyCrypto(secret) {
            var properties = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                properties[_i - 1] = arguments[_i];
            }
            this.secret = secret;
            this.encoder = new TextEncoder_1.TextEncoder();
            this.decoder = new TextDecoder_1.TextDecoder();
            this.properties = properties.map(function (p) { return p.split("."); });
        }
        PropertyCrypto.prototype.encrypt = function (payload) {
            var _this = this;
            return this.process(payload, function (value) { return _this.encoder.encode(JSON.stringify(value)); }, function (value) { return Base64.encode(value, "url"); });
        };
        PropertyCrypto.prototype.decrypt = function (payload) {
            var _this = this;
            return this.process(payload, function (value) { return typeof (value) == "string" ? Base64.decode(value, "url") : new Uint8Array(); }, function (value) { return JSON.parse(_this.decoder.decode(value)); });
        };
        PropertyCrypto.prototype.process = function (payload, preprocess, postprocess) {
            return __awaiter(this, void 0, void 0, function () {
                var secret, _i, _b, property;
                return __generator(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            secret = this.secret + payload.sub + payload.iat;
                            _i = 0, _b = this.properties;
                            _c.label = 1;
                        case 1:
                            if (!(_i < _b.length)) return [3 /*break*/, 4];
                            property = _b[_i];
                            return [4 /*yield*/, this.processProperty(payload, property, secret + property.join("."), preprocess, postprocess)];
                        case 2:
                            payload = _c.sent();
                            _c.label = 3;
                        case 3:
                            _i++;
                            return [3 /*break*/, 1];
                        case 4: return [2 /*return*/, payload];
                    }
                });
            });
        };
        PropertyCrypto.prototype.processProperty = function (payload, property, secret, preprocess, postprocess) {
            return __awaiter(this, void 0, void 0, function () {
                var result, data, key, _b, processed, index, _c, _d;
                return __generator(this, function (_e) {
                    switch (_e.label) {
                        case 0:
                            result = Object.assign({}, payload);
                            if (!result[property[0]]) return [3 /*break*/, 4];
                            if (!(property.length == 1)) return [3 /*break*/, 2];
                            data = preprocess(payload[property[0]]);
                            _b = Uint8Array.bind;
                            return [4 /*yield*/, crypto_browser.crypto.subtle.digest("SHA-512", this.encoder.encode(secret))];
                        case 1:
                            key = new (_b.apply(Uint8Array, [void 0, _e.sent()]))();
                            processed = new Uint8Array(data.length);
                            for (index = 0; index < data.length; index++)
                                processed[index] = data[index] ^ key[index];
                            result[property[0]] = postprocess(processed);
                            return [3 /*break*/, 4];
                        case 2:
                            _c = result;
                            _d = property[0];
                            return [4 /*yield*/, this.processProperty(result[property[0]], property.slice(1), secret, preprocess, postprocess)];
                        case 3:
                            _c[_d] = _e.sent();
                            _e.label = 4;
                        case 4: return [2 /*return*/, result];
                    }
                });
            });
        };
        PropertyCrypto.create = function (secret) {
            var properties = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                properties[_i - 1] = arguments[_i];
            }
            return secret && new (PropertyCrypto.bind.apply(PropertyCrypto, __spreadArrays([void 0, secret], properties)))() || undefined;
        };
        return PropertyCrypto;
    }());
    exports.PropertyCrypto = PropertyCrypto;
});
unwrapExports(PropertyCrypto_1);
var Actor_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var Actor = /** @class */ (function () {
        function Actor(id) {
            this.id = id;
            this.cryptos = [];
        }
        Actor.prototype.add = function (secret) {
            var _b;
            var properties = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                properties[_i - 1] = arguments[_i];
            }
            var crypto = (_b = PropertyCrypto_1.PropertyCrypto).create.apply(_b, __spreadArrays([secret], properties));
            if (crypto)
                this.cryptos.push(crypto);
            return this;
        };
        return Actor;
    }());
    exports.Actor = Actor;
});
unwrapExports(Actor_1);
var Symmetric_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var Symmetric;
    (function (Symmetric) {
        function is(value) {
            return value == "HS256" ||
                value == "HS384" ||
                value == "HS512";
        }
        Symmetric.is = is;
    })(Symmetric = exports.Symmetric || (exports.Symmetric = {}));
});
unwrapExports(Symmetric_1);
var Asymmetric_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var Asymmetric;
    (function (Asymmetric) {
        function is(value) {
            return value == "RS256" ||
                value == "RS384" ||
                value == "RS512" ||
                value == "ES256" ||
                value == "ES384" ||
                value == "ES512" ||
                value == "PS256" ||
                value == "PS384" ||
                value == "PS512";
        }
        Asymmetric.is = is;
    })(Asymmetric = exports.Asymmetric || (exports.Asymmetric = {}));
});
unwrapExports(Asymmetric_1);
var Name_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var Name;
    (function (Name) {
        function is(value) {
            return value == "none" || Symmetric_1.Symmetric.is(value) || Asymmetric_1.Asymmetric.is(value);
        }
        Name.is = is;
        var Symmetric;
        (function (Symmetric) {
            Symmetric.is = Symmetric_1.Symmetric.is;
        })(Symmetric = Name.Symmetric || (Name.Symmetric = {}));
        var Asymmetric;
        (function (Asymmetric) {
            Asymmetric.is = Asymmetric_1.Asymmetric.is;
        })(Asymmetric = Name.Asymmetric || (Name.Asymmetric = {}));
    })(Name = exports.Name || (exports.Name = {}));
});
unwrapExports(Name_1);
var Algorithm_1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var Algorithm = /** @class */ (function () {
        function Algorithm() {
        }
        Algorithm.prototype.sign = function (data) {
            return __awaiter(this, void 0, void 0, function () {
                var _b, _c, _d;
                return __generator(this, function (_e) {
                    switch (_e.label) {
                        case 0:
                            if (!(typeof (data) == "string")) return [3 /*break*/, 2];
                            _d = (_c = Base64).encode;
                            return [4 /*yield*/, this.signBinary(new TextEncoder_1.TextEncoder().encode(data))];
                        case 1:
                            _b = _d.apply(_c, [_e.sent(), "url"]);
                            return [3 /*break*/, 3];
                        case 2:
                            _b = this.signBinary(data);
                            _e.label = 3;
                        case 3: return [2 /*return*/, _b];
                    }
                });
            });
        };
        Algorithm.prototype.verify = function (data, signature) {
            if (typeof (signature) == "string")
                signature = Base64.decode(signature, "url");
            return typeof (data) == "string" ? this.verifyBinary(new TextEncoder_1.TextEncoder().encode(data), signature) : this.verifyBinary(data, signature);
        };
        Algorithm.create = function (name, publicKey, privateKey) {
            var create = algorithms[name];
            return create && create([publicKey, privateKey]);
        };
        Algorithm.none = function () {
            return Algorithm.create("none");
        };
        Algorithm.HS256 = function (key) {
            return Algorithm.create("HS256", key);
        };
        Algorithm.HS384 = function (key) {
            return Algorithm.create("HS384", key);
        };
        Algorithm.HS512 = function (key) {
            return Algorithm.create("HS512", key);
        };
        Algorithm.RS256 = function (publicKey, privateKey) {
            return Algorithm.create("RS256", publicKey, privateKey);
        };
        Algorithm.RS384 = function (publicKey, privateKey) {
            return Algorithm.create("RS384", publicKey, privateKey);
        };
        Algorithm.RS512 = function (publicKey, privateKey) {
            return Algorithm.create("RS512", publicKey, privateKey);
        };
        Algorithm.ES256 = function (publicKey, privateKey) {
            return Algorithm.create("ES256", publicKey, privateKey);
        };
        Algorithm.ES384 = function (publicKey, privateKey) {
            return Algorithm.create("ES384", publicKey, privateKey);
        };
        Algorithm.ES512 = function (publicKey, privateKey) {
            return Algorithm.create("ES512", publicKey, privateKey);
        };
        Algorithm.PS256 = function (publicKey, privateKey) {
            return Algorithm.create("PS256", publicKey, privateKey);
        };
        Algorithm.PS384 = function (publicKey, privateKey) {
            return Algorithm.create("PS384", publicKey, privateKey);
        };
        Algorithm.PS512 = function (publicKey, privateKey) {
            return Algorithm.create("PS512", publicKey, privateKey);
        };
        return Algorithm;
    }());
    exports.Algorithm = Algorithm;
    var algorithms = {};
    function register(name, create) {
        algorithms[name] = create;
    }
    exports.register = register;
    (function (Algorithm) {
        var Name;
        (function (Name) {
            Name.is = Name_1.Name.is;
            var Symmetric;
            (function (Symmetric) {
                Symmetric.is = Name_1.Name.Symmetric.is;
            })(Symmetric = Name.Symmetric || (Name.Symmetric = {}));
            var Asymmetric;
            (function (Asymmetric) {
                Asymmetric.is = Name_1.Name.Asymmetric.is;
            })(Asymmetric = Name.Asymmetric || (Name.Asymmetric = {}));
        })(Name = Algorithm.Name || (Algorithm.Name = {}));
    })(Algorithm = exports.Algorithm || (exports.Algorithm = {}));
});
unwrapExports(Algorithm_1);
var Symmetric_1$1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var Symmetric = /** @class */ (function (_super) {
        __extends(Symmetric, _super);
        function Symmetric() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Symmetric.prototype.verifyBinary = function (data, signature) {
            return __awaiter(this, void 0, void 0, function () {
                var _b, _c;
                return __generator(this, function (_d) {
                    switch (_d.label) {
                        case 0:
                            _c = (_b = Base64).encode;
                            return [4 /*yield*/, this.signBinary(data)];
                        case 1: return [2 /*return*/, _c.apply(_b, [_d.sent(), "url"]) == Base64.encode(signature, "url")];
                    }
                });
            });
        };
        return Symmetric;
    }(Algorithm_1.Algorithm));
    exports.Symmetric = Symmetric;
});
unwrapExports(Symmetric_1$1);
var None_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var None = /** @class */ (function (_super) {
        __extends(None, _super);
        function None() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Object.defineProperty(None.prototype, "name", {
            get: function () { return "none"; },
            enumerable: true,
            configurable: true
        });
        None.prototype.signBinary = function (_) { return Promise.resolve(new Uint8Array(0)); };
        return None;
    }(Symmetric_1$1.Symmetric));
    exports.None = None;
    Algorithm_1.register("none", function (_) { return new None(); });
});
unwrapExports(None_1);
var HS_1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var HS = /** @class */ (function (_super) {
        __extends(HS, _super);
        function HS(length, key) {
            var _this = _super.call(this) || this;
            _this.length = length;
            if (typeof (key) == "string")
                key = Base64.decode(key, "url");
            _this.key = crypto_browser.crypto.subtle.importKey("raw", key, { name: "HMAC", hash: { name: "SHA-" + _this.length } }, false, ["sign", "verify"]);
            return _this;
        }
        Object.defineProperty(HS.prototype, "name", {
            get: function () { return "HS" + this.length; },
            enumerable: true,
            configurable: true
        });
        HS.prototype.signBinary = function (data) {
            return __awaiter(this, void 0, void 0, function () {
                var _b, _c, _d, _e;
                return __generator(this, function (_f) {
                    switch (_f.label) {
                        case 0:
                            _b = Uint8Array.bind;
                            _d = (_c = crypto_browser.crypto.subtle).sign;
                            _e = ["HMAC"];
                            return [4 /*yield*/, this.key];
                        case 1: return [4 /*yield*/, _d.apply(_c, _e.concat([_f.sent(), data]))];
                        case 2: return [2 /*return*/, new (_b.apply(Uint8Array, [void 0, _f.sent()]))()];
                    }
                });
            });
        };
        return HS;
    }(Symmetric_1$1.Symmetric));
    exports.HS = HS;
    Algorithm_1.register("HS256", function (keys) { return keys[0] && new HS("256", keys[0]) || undefined; });
    Algorithm_1.register("HS384", function (keys) { return keys[0] && new HS("384", keys[0]) || undefined; });
    Algorithm_1.register("HS512", function (keys) { return keys[0] && new HS("512", keys[0]) || undefined; });
});
unwrapExports(HS_1);
var RS_1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var RS = /** @class */ (function (_super) {
        __extends(RS, _super);
        function RS(length, publicKey, privateKey) {
            var _this = _super.call(this) || this;
            _this.length = length;
            if (publicKey) {
                if (typeof (publicKey) == "string")
                    publicKey = Base64.decode(publicKey);
                _this.publicKey = crypto_browser.crypto.subtle.importKey("spki", publicKey, { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-" + _this.length } }, false, ["verify"]);
            }
            if (privateKey) {
                if (typeof (privateKey) == "string")
                    privateKey = Base64.decode(privateKey);
                _this.privateKey = crypto_browser.crypto.subtle.importKey("pkcs8", privateKey, { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-" + _this.length } }, true, ["sign", "verify"]);
            }
            return _this;
        }
        Object.defineProperty(RS.prototype, "name", {
            get: function () { return "RS" + this.length; },
            enumerable: true,
            configurable: true
        });
        RS.prototype.signBinary = function (data) {
            return __awaiter(this, void 0, void 0, function () {
                var _b, _c, _d, _e;
                return __generator(this, function (_f) {
                    switch (_f.label) {
                        case 0:
                            _b = Uint8Array.bind;
                            _d = (_c = crypto_browser.crypto.subtle).sign;
                            _e = ["RSASSA-PKCS1-v1_5"];
                            return [4 /*yield*/, this.privateKey];
                        case 1: return [4 /*yield*/, _d.apply(_c, _e.concat([_f.sent(), data]))];
                        case 2: return [2 /*return*/, new (_b.apply(Uint8Array, [void 0, _f.sent()]))()];
                    }
                });
            });
        };
        RS.prototype.verifyBinary = function (data, signature) {
            return __awaiter(this, void 0, void 0, function () {
                var _b, _c, _d;
                return __generator(this, function (_e) {
                    switch (_e.label) {
                        case 0:
                            _c = (_b = crypto_browser.crypto.subtle).verify;
                            _d = ["RSASSA-PKCS1-v1_5"];
                            return [4 /*yield*/, this.publicKey];
                        case 1: return [2 /*return*/, _c.apply(_b, _d.concat([_e.sent(), signature, data]))];
                    }
                });
            });
        };
        return RS;
    }(Algorithm_1.Algorithm));
    exports.RS = RS;
    Algorithm_1.register("RS256", function (keys) { return new RS("256", keys[0], keys[1]); });
    Algorithm_1.register("RS384", function (keys) { return new RS("384", keys[0], keys[1]); });
    Algorithm_1.register("RS512", function (keys) { return new RS("512", keys[0], keys[1]); });
});
unwrapExports(RS_1);
var Algorithm = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.Algorithm = Algorithm_1.Algorithm;
});
unwrapExports(Algorithm);
var Issuer_1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var Issuer = /** @class */ (function (_super) {
        __extends(Issuer, _super);
        function Issuer(issuer, algorithm) {
            var _this = _super.call(this, issuer) || this;
            _this.algorithm = algorithm;
            return _this;
        }
        Object.defineProperty(Issuer.prototype, "header", {
            get: function () {
                return {
                    alg: this.algorithm.name,
                    typ: "JWT",
                };
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Issuer.prototype, "payload", {
            get: function () {
                var result = { iss: this.id, iat: Issuer.issuedAt };
                if (this.audience)
                    result.aud = this.audience;
                if (this.duration && result.iat)
                    result.exp = result.iat + this.duration;
                return result;
            },
            enumerable: true,
            configurable: true
        });
        Issuer.prototype.sign = function (payload, issuedAt) {
            return __awaiter(this, void 0, void 0, function () {
                var data, _b;
                var _this = this;
                return __generator(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            payload = Object.assign(Object.assign({}, this.payload), payload);
                            if (issuedAt)
                                payload.iat = typeof (issuedAt) == "number" ? issuedAt : issuedAt.getTime();
                            return [4 /*yield*/, this.cryptos.reduce(function (p, c) { return __awaiter(_this, void 0, void 0, function () { var _b, _c; return __generator(this, function (_d) {
                                    switch (_d.label) {
                                        case 0:
                                            _c = (_b = c).encrypt;
                                            return [4 /*yield*/, p];
                                        case 1: return [2 /*return*/, _c.apply(_b, [_d.sent()])];
                                    }
                                }); }); }, Promise.resolve(payload))];
                        case 1:
                            payload = _c.sent();
                            data = Base64.encode(new TextEncoder_1.TextEncoder().encode(JSON.stringify(this.header))) + "." + Base64.encode(new TextEncoder_1.TextEncoder().encode(JSON.stringify(payload)));
                            _b = data + ".";
                            return [4 /*yield*/, this.algorithm.sign(data)];
                        case 2: return [2 /*return*/, _b + (_c.sent())];
                    }
                });
            });
        };
        Object.defineProperty(Issuer, "issuedAt", {
            get: function () {
                return Issuer.defaultIssuedAt == undefined ? Date.now() :
                    typeof (Issuer.defaultIssuedAt) == "number" ? Issuer.defaultIssuedAt :
                        Issuer.defaultIssuedAt.getTime();
            },
            enumerable: true,
            configurable: true
        });
        Issuer.create = function (issuer, algorithm) {
            return algorithm && new Issuer(issuer, algorithm) || undefined;
        };
        return Issuer;
    }(Actor_1.Actor));
    exports.Issuer = Issuer;
});
unwrapExports(Issuer_1);
var Password_1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var Password;
    (function (Password) {
        function is(value) {
            return typeof (value) == "string" || (typeof (value) == "object" &&
                typeof (value.hash) == "string" &&
                typeof (value.salt) == "string");
        }
        Password.is = is;
        function hash(algorithm, password, salt) {
            return __awaiter(this, void 0, void 0, function () {
                var _b;
                return __generator(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            if (!salt)
                                salt = Base64.encode(crypto_browser.crypto.getRandomValues(new Uint8Array(64)));
                            _b = {};
                            return [4 /*yield*/, algorithm.sign(salt + password)];
                        case 1: return [2 /*return*/, (_b.hash = _c.sent(),
                                _b.salt = salt,
                                _b)];
                    }
                });
            });
        }
        Password.hash = hash;
        function verify(algorithm, hash, password) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_b) {
                    switch (_b.label) {
                        case 0: return [4 /*yield*/, Password.hash(algorithm, password, hash.salt)];
                        case 1: return [2 /*return*/, (_b.sent()).hash == hash.hash];
                    }
                });
            });
        }
        Password.verify = verify;
        var Hashed;
        (function (Hashed) {
            function is(value) {
                return typeof (value) == "object" &&
                    typeof (value.hash) == "string" &&
                    typeof (value.salt) == "string";
            }
            Hashed.is = is;
        })(Hashed = Password.Hashed || (Password.Hashed = {}));
    })(Password = exports.Password || (exports.Password = {}));
});
unwrapExports(Password_1);
var Token_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var Token;
    (function (Token) {
        function is(value) {
            return typeof (value) == "string" && /^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/.test(value);
        }
        Token.is = is;
    })(Token = exports.Token || (exports.Token = {}));
});
unwrapExports(Token_1);
var Verifier_1 = createCommonjsModule(function (module, exports) {
    var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    var Verifier = /** @class */ (function (_super) {
        __extends(Verifier, _super);
        function Verifier(audience) {
            var algorithms = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                algorithms[_i - 1] = arguments[_i];
            }
            var _this = _super.call(this, audience) || this;
            if (algorithms.length > 0) {
                _this.algorithms = {};
                for (var _b = 0, algorithms_1 = algorithms; _b < algorithms_1.length; _b++) {
                    var algorithm = algorithms_1[_b];
                    _this.algorithms[algorithm.name] = algorithm;
                }
            }
            else
                _this.algorithms = undefined;
            return _this;
        }
        Verifier.prototype.verify = function (token) {
            return __awaiter(this, void 0, void 0, function () {
                var result, splitted, header, algorithm, _b, _a_1, now;
                var _this = this;
                return __generator(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            if (!token) return [3 /*break*/, 9];
                            splitted = token.split(".", 3);
                            if (!(splitted.length < 2)) return [3 /*break*/, 1];
                            result = undefined;
                            return [3 /*break*/, 7];
                        case 1:
                            _c.trys.push([1, 5, , 6]);
                            header = JSON.parse(new TextDecoder_1.TextDecoder().decode(Base64.decode(splitted[0])));
                            result = JSON.parse(new TextDecoder_1.TextDecoder().decode(Base64.decode(splitted[1])));
                            if (!this.algorithms) return [3 /*break*/, 4];
                            algorithm = this.algorithms[header.alg];
                            _b = splitted.length == 3 && algorithm;
                            if (!_b) return [3 /*break*/, 3];
                            return [4 /*yield*/, algorithm.verify(splitted[0] + "." + splitted[1], splitted[2])];
                        case 2:
                            _b = (_c.sent());
                            _c.label = 3;
                        case 3:
                            result = _b ? result : undefined;
                            _c.label = 4;
                        case 4: return [3 /*break*/, 6];
                        case 5:
                            _a_1 = _c.sent();
                            result = undefined;
                            return [3 /*break*/, 6];
                        case 6:
                            now = Date.now();
                            result = result &&
                                (result.exp == undefined || result.exp > now) &&
                                (result.iat == undefined || result.iat <= now) &&
                                this.verifyAudience(result.aud) ?
                                result : undefined;
                            _c.label = 7;
                        case 7:
                            if (!result) return [3 /*break*/, 9];
                            return [4 /*yield*/, this.cryptos.reduce(function (p, c) { return __awaiter(_this, void 0, void 0, function () { var _b, _c; return __generator(this, function (_d) {
                                    switch (_d.label) {
                                        case 0:
                                            _c = (_b = c).decrypt;
                                            return [4 /*yield*/, p];
                                        case 1: return [2 /*return*/, _c.apply(_b, [_d.sent()])];
                                    }
                                }); }); }, Promise.resolve(result))];
                        case 8:
                            result = _c.sent();
                            _c.label = 9;
                        case 9: return [2 /*return*/, result];
                    }
                });
            });
        };
        Verifier.prototype.verifyAudience = function (audience) {
            var _this = this;
            return audience == undefined || typeof (audience) == "string" && audience == this.id || Array.isArray(audience) && audience.some(function (a) { return a == _this.id; });
        };
        Verifier.prototype.authenticate = function (authorization) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_b) {
                    return [2 /*return*/, authorization && authorization.startsWith("Bearer ") ? this.verify(authorization.substr(7)) : undefined];
                });
            });
        };
        Verifier.create = function (audience) {
            var algorithms = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                algorithms[_i - 1] = arguments[_i];
            }
            return (algorithms.length == 0 || algorithms.some(function (a) { return !!a; })) && new (Verifier.bind.apply(Verifier, __spreadArrays([void 0, audience], algorithms.filter(function (a) { return !!a; }))))() || undefined;
        };
        return Verifier;
    }(Actor_1.Actor));
    exports.Verifier = Verifier;
});
unwrapExports(Verifier_1);
var Identifier_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    var Identifier;
    (function (Identifier) {
        function is(value) {
            return typeof (value) == "string" && Array.from(value).every(function (c) { return c >= "0" && c <= "9" || c >= "A" && c <= "Z" || c >= "a" && c <= "z" || c == "-" || c == "_"; });
        }
        Identifier.is = is;
        function fromBinary(identifier) {
            return Base64.encode(identifier, "url");
        }
        Identifier.fromBinary = fromBinary;
        function toBinary(identifier) {
            return Base64.decode(identifier, "url");
        }
        Identifier.toBinary = toBinary;
        function generate(length) {
            return fromBinary(crypto_browser.crypto.getRandomValues(new Uint8Array(length / 4 * 3)));
        }
        Identifier.generate = generate;
        function fromHexadecimal(identifier) {
            if (identifier.length % 2 == 1)
                identifier += "0";
            var result = new Uint8Array(identifier.length / 2);
            for (var index = 0; index < result.length; index++)
                result[index] = Number.parseInt(identifier[index * 2], 16) * 16 + Number.parseInt(identifier[index * 2 + 1], 16);
            return fromBinary(result);
        }
        Identifier.fromHexadecimal = fromHexadecimal;
        function toHexadecimal(identifier, length) {
            var data = Base64.decode(identifier, "url");
            var result = [];
            for (var index = 0; index < data.length; index++)
                result.push(Math.floor(data[index] / 16).toString(16), (data[index] % 16).toString(16));
            if (length)
                result = result.slice(0, length);
            return result.join("");
        }
        Identifier.toHexadecimal = toHexadecimal;
        Identifier.lengths = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128];
        var Lengths;
        (function (Lengths) {
            function is(value) {
                return typeof (value) == "number" &&
                    value >= 4 &&
                    value <= 128 &&
                    (value & 252) == value;
            }
            Lengths.is = is;
        })(Lengths = Identifier.Lengths || (Identifier.Lengths = {}));
    })(Identifier = exports.Identifier || (exports.Identifier = {}));
});
unwrapExports(Identifier_1);
var dist = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.Actor = Actor_1.Actor;
    exports.Algorithm = Algorithm.Algorithm;
    exports.Base64 = Base64;
    exports.Issuer = Issuer_1.Issuer;
    exports.Password = Password_1.Password;
    exports.PropertyCrypto = PropertyCrypto_1.PropertyCrypto;
    exports.TextDecoder = TextDecoder_1.TextDecoder;
    exports.TextEncoder = TextEncoder_1.TextEncoder;
    exports.Token = Token_1.Token;
    exports.Verifier = Verifier_1.Verifier;
    exports.Identifier = Identifier_1.Identifier;
});
unwrapExports(dist);
var dist_10 = dist.Verifier;
var Form = /** @class */ (function () {
    function class_1(hostRef) {
        registerInstance(this, hostRef);
        this.state = "created";
        this.changed = createEvent(this, "changed", 7);
    }
    class_1.prototype.componentWillLoad = function () {
        var _this = this;
        dist_10.create("public").verify(this.apiKey).then(function (payload) { return _this.payload = payload; });
        var styleLink = document.querySelector("link[rel=stylesheet][href^='https://theme.payfunc.com/']");
        if (styleLink) {
            var themeLink = styleLink.href.substring(26);
            this.theme = themeLink.substring(0, themeLink.indexOf("/"));
        }
    };
    class_1.prototype.handleTrigger = function (event) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_b) {
                if (event.detail.value && event.detail.value.status == 400 && event.detail.value.type == "missing property" && event.detail.value.content && event.detail.value.content.property == "pares") {
                    this.verify = { pareq: event.detail.value.content.pareq, url: event.detail.value.content.url, issuer: this.payload ? this.payload.iss ? this.payload.iss : "" : "" };
                }
                else if (event.detail.name == "pares") {
                    this.verify = undefined;
                    if (this.authorization)
                        this.frame.send("card", { name: "submit", value: { authorization: this.authorization, key: this.apiKey, parent: window.location.origin } });
                }
                else {
                    this.changed.emit(this.value = event.detail.value);
                    this.state = event.detail.name == "cardPaymentSuccess" ? "succeeded" : "failed";
                    if (this.received) {
                        this.received(this.state, event.detail.value);
                        this.received = undefined;
                    }
                }
                return [2 /*return*/];
            });
        });
    };
    class_1.prototype.submit = function (authorization) {
        var _this = this;
        this.authorization = authorization;
        return new Promise(function (callback) {
            if (_this.frame) {
                _this.received = function (_, response) { return callback(response); };
                _this.frame.send("card", { name: "submit", value: { authorization: authorization, key: _this.apiKey, parent: window.location.origin } });
                _this.state = "processing";
            }
        });
    };
    class_1.prototype.render = function () {
        var _this = this;
        return [
            this.payload ? h("smoothly-frame", { url: this.payload.iss + "/ui/web-app/" + (this.theme ? "?theme=" + this.theme : ""), name: "card", ref: function (element) { return _this.frame = element; } }) : [],
            this.verify ?
                h("smoothly-dialog", { closable: true }, h("smoothly-frame", { url: this.verify.issuer + "/redirect/post?target=" + this.verify.url + "&PaReq=" + this.verify.pareq + "&MD=MD&TermUrl=" + this.verify.issuer + "/emv3d/done?parent=" + window.location.origin, name: "parent", style: { height: "90vh" } })) :
                [],
        ];
    };
    Object.defineProperty(class_1, "style", {
        get: function () { return ":host{display:block;height:calc(5em - 3px);overflow:hidden;width:100%}:host[hidden]{display:none}"; },
        enumerable: true,
        configurable: true
    });
    return class_1;
}());
var SmoothlyDialog = /** @class */ (function () {
    function SmoothlyDialog(hostRef) {
        registerInstance(this, hostRef);
        this.open = true;
        this.closable = false;
    }
    SmoothlyDialog.prototype.TriggerListener = function (event) {
        if (dist_9.is(event.detail) && event.detail.name == "close")
            this.open = false;
    };
    SmoothlyDialog.prototype.hostData = function () {
        return {
            style: {
                display: this.open ? "block" : "none",
            },
        };
    };
    SmoothlyDialog.prototype.__stencil_render = function () {
        return [
            h("header", null, this.closable ? h("smoothly-trigger", { fill: "clear", name: "close" }, h("smoothly-icon", { name: "close-circle", fill: "solid", color: this.color })) : [], this.header ? h("h1", null, this.header) : h("slot", { name: "header" })),
            h("main", null, h("slot", null))
        ];
    };
    SmoothlyDialog.prototype.render = function () { return h(Host, this.hostData(), this.__stencil_render()); };
    Object.defineProperty(SmoothlyDialog, "style", {
        get: function () { return ".sc-smoothly-dialog-h{display:block;position:fixed;left:0;top:0;width:100%;height:100%;z-index:1;background:rgba(var(--smoothly-default-color),var(--smoothly-semitransparent))!important}[hidden].sc-smoothly-dialog-h{display:none}.sc-smoothly-dialog-h > header.sc-smoothly-dialog{border-top-left-radius:8px;border-top-right-radius:8px;margin-top:2em;color:rgb(var(--smoothly-primary-contrast));background:rgb(var(--smoothly-primary-color))}.sc-smoothly-dialog-h > *.sc-smoothly-dialog{position:relative;color:rgb(var(--smoothly-default-contrast));background-color:rgb(var(--smoothly-default-color));border-color:rgb(var(--smoothly-color));border-width:1px;border-style:solid;max-width:40em;width:calc(100vw - 4em - 2px);max-height:calc(100vh - 6em - 2px);height:auto;margin-left:auto;margin-right:auto;border-collapse:collapse}.sc-smoothly-dialog-h > main.sc-smoothly-dialog{border-bottom-left-radius:8px;border-bottom-right-radius:8px;margin-bottom:2em}.sc-smoothly-dialog-h > *.sc-smoothly-dialog > smoothly-trigger.sc-smoothly-dialog{position:absolute;right:-2em;top:-2em}.sc-smoothly-dialog-h > *.sc-smoothly-dialog > *.sc-smoothly-dialog{margin:10px}"; },
        enumerable: true,
        configurable: true
    });
    return SmoothlyDialog;
}());
var SmoothlyFrame = /** @class */ (function () {
    function class_2(hostRef) {
        registerInstance(this, hostRef);
        this.trigger = createEvent(this, "trigger", 7);
        this.message = createEvent(this, "message", 7);
    }
    Object.defineProperty(class_2.prototype, "contentWindow", {
        get: function () {
            var iframe = this.element && this.element.firstElementChild ? this.element.firstElementChild : undefined;
            return iframe && iframe.contentWindow || undefined;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(class_2.prototype, "urlOrigin", {
        get: function () {
            var match = this.url.match(/^(([a-z]+\+)*[a-z]+:\/\/)?[^\/^\n]+/);
            return match ? match[0] : "*";
        },
        enumerable: true,
        configurable: true
    });
    class_2.prototype.componentDidLoad = function () {
        var _this = this;
        if (this.contentWindow)
            dist_6.listen(this.urlOrigin, function (destination, content) {
                if (destination == _this.name)
                    if (dist_9.is(content))
                        _this.trigger.emit(content);
                    else
                        _this.message.emit({ destination: destination, content: content });
            }, window);
    };
    class_2.prototype.send = function (message, content) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_b) {
                if (typeof (message) == "string")
                    dist_6.send(this.urlOrigin + "#" + message, content, this.contentWindow);
                else if (dist_6.is(message) && this.contentWindow)
                    dist_6.send({ destination: this.urlOrigin + "#" + message.destination, content: message.destination }, this.contentWindow);
                return [2 /*return*/];
            });
        });
    };
    class_2.prototype.render = function () {
        return h("iframe", { src: this.url + "#" + window.location.origin, height: "100%", width: "100%" });
    };
    Object.defineProperty(class_2.prototype, "element", {
        get: function () { return getElement(this); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(class_2, "style", {
        get: function () { return ".sc-smoothly-frame-h{display:block;width:100%;height:100%}[hidden].sc-smoothly-frame-h{display:none}.sc-smoothly-frame-h > iframe.sc-smoothly-frame{border:none;padding:none;margin:none}"; },
        enumerable: true,
        configurable: true
    });
    return class_2;
}());
var SmoothlyIcon = /** @class */ (function () {
    function class_3(hostRef) {
        registerInstance(this, hostRef);
        this.fill = "solid";
        this.size = "medium";
    }
    class_3.prototype.loadDocument = function () {
        return __awaiter(this, void 0, void 0, function () {
            var url, response, _b, _c;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        if (!this.name) return [3 /*break*/, 5];
                        url = "https://unpkg.com/ionicons@5.0.0/dist/svg/" + this.name + ".svg";
                        return [4 /*yield*/, fetch(url)];
                    case 1:
                        response = _d.sent();
                        _b = this;
                        if (!response.ok) return [3 /*break*/, 3];
                        return [4 /*yield*/, response.text()];
                    case 2:
                        _c = _d.sent();
                        return [3 /*break*/, 4];
                    case 3:
                        _c = undefined;
                        _d.label = 4;
                    case 4:
                        _b.document = _c;
                        _d.label = 5;
                    case 5: return [2 /*return*/];
                }
            });
        });
    };
    class_3.prototype.componentWillLoad = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0: return [4 /*yield*/, this.loadDocument()];
                    case 1:
                        _b.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    class_3.prototype.hostData = function () {
        return {
            innerHTML: this.document ? this.document.replace(" width=\"512\" height=\"512\"", "") : undefined,
        };
    };
    class_3.prototype.__stencil_render = function () {
        return [];
    };
    Object.defineProperty(class_3, "watchers", {
        get: function () {
            return {
                "name": ["loadDocument"]
            };
        },
        enumerable: true,
        configurable: true
    });
    class_3.prototype.render = function () { return h(Host, this.hostData(), this.__stencil_render()); };
    Object.defineProperty(class_3, "style", {
        get: function () { return ".sc-smoothly-icon-h{display:block;background:none!important}[hidden].sc-smoothly-icon-h{display:none}[size=small].sc-smoothly-icon-h{width:1.4em;height:1.4em}[size=medium].sc-smoothly-icon-h{width:1.8em;height:1.8em}[size=large].sc-smoothly-icon-h{width:2.8em;height:2.8em}[size=xlarge].sc-smoothly-icon-h{width:4em;height:4em}"; },
        enumerable: true,
        configurable: true
    });
    return class_3;
}());
var SmoothlyTrigger = /** @class */ (function () {
    function SmoothlyTrigger(hostRef) {
        registerInstance(this, hostRef);
        this.disabled = false;
        this.trigger = createEvent(this, "trigger", 7);
    }
    SmoothlyTrigger.prototype.onClick = function (e) {
        this.trigger.emit({ name: this.name, value: this.value });
        e.stopPropagation();
        e.preventDefault();
    };
    SmoothlyTrigger.prototype.render = function () {
        return h("button", { disabled: this.disabled, name: this.name }, h("slot", null));
    };
    Object.defineProperty(SmoothlyTrigger, "style", {
        get: function () { return ".sc-smoothly-trigger-h{display:block;border-style:solid;border-width:1px;border-radius:3px}[hidden].sc-smoothly-trigger-h{display:none}[disabled].sc-smoothly-trigger-h{opacity:.5}button.sc-smoothly-trigger{border-color:transparent;padding:.2em .3em;font-size:110%;font-weight:400}.sc-smoothly-trigger-h:not([processing]):not([disabled]):active, .sc-smoothly-trigger-h:not([processing]):not([disabled]):focus, .sc-smoothly-trigger-h:not([processing]):not([disabled]):hover{border-color:var(--smoothly-trigger-border)}[expand=block].sc-smoothly-trigger-h > button.sc-smoothly-trigger, [expand=fill].sc-smoothly-trigger-h > button.sc-smoothly-trigger{width:100%}[expand=fill].sc-smoothly-trigger-h{border-left:none;border-right:none}"; },
        enumerable: true,
        configurable: true
    });
    return SmoothlyTrigger;
}());
export { Form as cardfunc_element, SmoothlyDialog as smoothly_dialog, SmoothlyFrame as smoothly_frame, SmoothlyIcon as smoothly_icon, SmoothlyTrigger as smoothly_trigger };
