"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AtomicIcon: ()=>AtomicIcon
});
const external_dompurify_namespaceObject = require("dompurify");
var external_dompurify_default = /*#__PURE__*/ __webpack_require__.n(external_dompurify_namespaceObject);
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const guard_js_namespaceObject = require("lit/directives/guard.js");
const unsafe_svg_js_namespaceObject = require("lit/directives/unsafe-svg.js");
const binding_guard_cjs_namespaceObject = require("../../../decorators/binding-guard.cjs");
const error_guard_cjs_namespaceObject = require("../../../decorators/error-guard.cjs");
const watch_cjs_namespaceObject = require("../../../decorators/watch.cjs");
const bindings_mixin_cjs_namespaceObject = require("../../../mixins/bindings-mixin.cjs");
const light_dom_cjs_namespaceObject = require("../../../mixins/light-dom.cjs");
const asset_path_utils_cjs_namespaceObject = require("../../../utils/asset-path-utils.cjs");
const external_fetch_icon_cjs_namespaceObject = require("./fetch-icon.cjs");
function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) 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;
}
function _ts_metadata(k, v) {
    if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
}
class AtomicIcon extends (0, light_dom_cjs_namespaceObject.LightDomMixin)((0, bindings_mixin_cjs_namespaceObject.InitializeBindingsMixin)(external_lit_namespaceObject.LitElement)) {
    async fetchIcon(url) {
        try {
            return await (0, external_fetch_icon_cjs_namespaceObject.fetchIcon)(url);
        } catch (e) {
            this.error = e;
            this.requestUpdate();
            return null;
        }
    }
    validateSVG(svg) {
        if (!/^<svg[\s\S]+<\/svg>$/gm.test(svg)) this.bindings.engine.logger.warn('The inline "icon" prop is not an svg element. You may encounter rendering issues.');
    }
    async getIcon() {
        if (!this.bindings) return null;
        const url = (0, asset_path_utils_cjs_namespaceObject.parseAssetURL)(this.icon, this.bindings.store.state.iconAssetsPath);
        const svg = url ? await this.fetchIcon(url) : this.icon;
        if (svg) this.validateSVG(svg);
        const sanitizedSvg = svg ? external_dompurify_default().sanitize(svg, {
            USE_PROFILES: {
                svg: true,
                svgFilters: true
            }
        }) : null;
        return sanitizedSvg;
    }
    async updateIcon() {
        const svgPromise = this.getIcon();
        this.svg = await svgPromise;
    }
    async initialize() {
        await this.updateIcon();
    }
    render() {
        this.ariaHidden = 'true';
        return (0, external_lit_namespaceObject.svg)`${(0, guard_js_namespaceObject.guard)([
            this.svg
        ], ()=>(0, unsafe_svg_js_namespaceObject.unsafeSVG)(this.svg))}`;
    }
    constructor(...args){
        super(...args), this.svg = null;
    }
}
AtomicIcon.styles = (0, external_lit_namespaceObject.css)`
    @layer components {
      atomic-icon {
        display: inline-block;
        fill: currentColor;
        aspect-ratio: 1 / 1;
        height: auto;

        @supports not (aspect-ratio: 1 / 1) {
          height: auto;
        }

        > svg {
          width: 100%;
          max-height: 100%;
          aspect-ratio: 1 / 1;
          height: auto;
        }
      }
    }
  `;
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: String,
        reflect: true
    }),
    _ts_metadata("design:type", String)
], AtomicIcon.prototype, "icon", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof AnyBindings ? Object : AnyBindings)
], AtomicIcon.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicIcon.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", Object)
], AtomicIcon.prototype, "svg", void 0);
_ts_decorate([
    (0, watch_cjs_namespaceObject.watch)('icon'),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", Promise)
], AtomicIcon.prototype, "updateIcon", null);
_ts_decorate([
    (0, binding_guard_cjs_namespaceObject.bindingGuard)(),
    (0, error_guard_cjs_namespaceObject.errorGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicIcon.prototype, "render", null);
AtomicIcon = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-icon')
], AtomicIcon);
exports.AtomicIcon = __webpack_exports__.AtomicIcon;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicIcon"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
