"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__, {
    AtomicResultIcon: ()=>AtomicResultIcon
});
const headless_namespaceObject = require("@coveo/headless");
const bg_standard_common_namespaceObject = require("@salesforce-ux/design-system/design-tokens/dist/bg-standard.common");
var bg_standard_common_default = /*#__PURE__*/ __webpack_require__.n(bg_standard_common_namespaceObject);
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const when_js_namespaceObject = require("lit/directives/when.js");
require("../../common/atomic-icon/atomic-icon.cjs");
const result_context_controller_cjs_namespaceObject = require("../result-template-component-utils/context/result-context-controller.cjs");
const bindings_cjs_namespaceObject = require("../../../decorators/bindings.cjs");
const error_guard_cjs_namespaceObject = require("../../../decorators/error-guard.cjs");
const utils_cjs_namespaceObject = require("../../../utils/utils.cjs");
const external_file_type_icons_cjs_namespaceObject = require("./file-type-icons.cjs");
const external_object_type_icons_cjs_namespaceObject = require("./object-type-icons.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 AtomicResultIcon extends external_lit_namespaceObject.LitElement {
    initialize() {}
    get result() {
        const item = this.resultController.item;
        if (!item) return null;
        if ('result' in item) return item.result;
        return item;
    }
    get icon() {
        if (!this.result) return null;
        const fileTypeValue = headless_namespaceObject.ResultTemplatesHelpers.getResultProperty(this.result, 'filetype');
        const objectTypeValue = headless_namespaceObject.ResultTemplatesHelpers.getResultProperty(this.result, 'objecttype');
        const fileType = external_file_type_icons_cjs_namespaceObject.fileTypeIcons[fileTypeValue?.toLowerCase()];
        const objectType = external_object_type_icons_cjs_namespaceObject.objectTypeIcons[objectTypeValue?.toLowerCase()];
        return objectType ?? fileType ?? null;
    }
    renderIcon() {
        const icon = this.icon || 'document';
        const backgroundColor = bg_standard_common_default()[(0, utils_cjs_namespaceObject.snakeToCamel)(icon)] || 'transparent';
        return (0, external_lit_namespaceObject.html)`
      <atomic-icon
        icon=${`assets://${icon}`}
        class=${icon}
        title=${icon}
        style="background-color: ${backgroundColor}"
      ></atomic-icon>
    `;
    }
    render() {
        if (this.resultController.hasError) return external_lit_namespaceObject.nothing;
        return (0, when_js_namespaceObject.when)(this.icon, ()=>this.renderIcon(), ()=>(0, external_lit_namespaceObject.html)`<slot>${this.renderIcon()}</slot>`);
    }
    constructor(...args){
        super(...args), this.license = "Salesforce's specific icons originally from lightning design system (https://www.lightningdesignsystem.com/icons/). Icons licensed under Creative Commons Attribution-NoDerivatives 4.0 (https://github.com/salesforce-ux/design-system).", this.resultController = (0, result_context_controller_cjs_namespaceObject.createResultContextController)(this);
    }
}
AtomicResultIcon.styles = (0, external_lit_namespaceObject.css)`
    :host {
      display: inline-block;
      width: 100%;
      height: auto;
    }

    atomic-icon {
      width: 100%;
    }
  `;
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Bindings ? Object : Bindings)
], AtomicResultIcon.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicResultIcon.prototype, "error", void 0);
_ts_decorate([
    (0, error_guard_cjs_namespaceObject.errorGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicResultIcon.prototype, "render", null);
AtomicResultIcon = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-result-icon'),
    (0, bindings_cjs_namespaceObject.bindings)()
], AtomicResultIcon);
exports.AtomicResultIcon = __webpack_exports__.AtomicResultIcon;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicResultIcon"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
