"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__, {
    AtomicSmartSnippetFeedbackModal: ()=>AtomicSmartSnippetFeedbackModal
});
require("../../common/atomic-modal/atomic-modal.cjs");
const headless_namespaceObject = require("@coveo/headless");
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const keyed_js_namespaceObject = require("lit/directives/keyed.js");
const ref_js_namespaceObject = require("lit/directives/ref.js");
const export_parts_cjs_namespaceObject = require("../../common/atomic-modal/export-parts.cjs");
const feedback_options_cjs_namespaceObject = require("../../common/smart-snippets/atomic-smart-snippet-feedback-modal/feedback-options.cjs");
const modal_body_cjs_namespaceObject = require("../../common/smart-snippets/atomic-smart-snippet-feedback-modal/modal-body.cjs");
const modal_details_cjs_namespaceObject = require("../../common/smart-snippets/atomic-smart-snippet-feedback-modal/modal-details.cjs");
const modal_footer_cjs_namespaceObject = require("../../common/smart-snippets/atomic-smart-snippet-feedback-modal/modal-footer.cjs");
const modal_header_cjs_namespaceObject = require("../../common/smart-snippets/atomic-smart-snippet-feedback-modal/modal-header.cjs");
const modal_option_cjs_namespaceObject = require("../../common/smart-snippets/atomic-smart-snippet-feedback-modal/modal-option.cjs");
const modal_options_cjs_namespaceObject = require("../../common/smart-snippets/atomic-smart-snippet-feedback-modal/modal-options.cjs");
const boolean_converter_cjs_namespaceObject = require("../../../converters/boolean-converter.cjs");
const binding_guard_cjs_namespaceObject = require("../../../decorators/binding-guard.cjs");
const bindings_cjs_namespaceObject = require("../../../decorators/bindings.cjs");
const error_guard_cjs_namespaceObject = require("../../../decorators/error-guard.cjs");
const with_tailwind_styles_cjs_namespaceObject = require("../../../decorators/with-tailwind-styles.cjs");
const replace_breakpoint_utils_cjs_namespaceObject = require("../../../utils/replace-breakpoint-utils.cjs");
const utils_cjs_namespaceObject = require("../../../utils/utils.cjs");
const external_atomic_smart_snippet_feedback_modal_tw_css_cjs_namespaceObject = require("./atomic-smart-snippet-feedback-modal.tw.css.cjs");
var external_atomic_smart_snippet_feedback_modal_tw_css_cjs_default = /*#__PURE__*/ __webpack_require__.n(external_atomic_smart_snippet_feedback_modal_tw_css_cjs_namespaceObject);
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 AtomicSmartSnippetFeedbackModal extends external_lit_namespaceObject.LitElement {
    initialize() {
        this.smartSnippet = (0, headless_namespaceObject.buildSmartSnippet)(this.bindings.engine);
    }
    updated(changedProperties) {
        if (changedProperties.has('isOpen') && this.isOpen && this.smartSnippet) {
            this.smartSnippet.openFeedbackModal();
            this.currentAnswer = void 0;
        }
    }
    render() {
        (0, replace_breakpoint_utils_cjs_namespaceObject.updateBreakpoints)(this);
        return (0, external_lit_namespaceObject.html)`
      <atomic-modal
        .source=${this.source}
        .container=${this}
        .isOpen=${this.isOpen}
        .close=${()=>this.close()}
        exportparts=${export_parts_cjs_namespaceObject.ATOMIC_MODAL_EXPORT_PARTS}
      >
        ${(0, modal_header_cjs_namespaceObject.renderModalHeader)({
            props: {
                i18n: this.bindings.i18n
            }
        })}
        ${(0, modal_body_cjs_namespaceObject.renderModalBody)({
            props: {
                formId: this.formId,
                onSubmit: (e)=>this.sendFeedback(e)
            }
        })((0, external_lit_namespaceObject.html)`
          ${(0, modal_options_cjs_namespaceObject.renderModalOptions)({
            props: {
                i18n: this.bindings.i18n
            }
        })((0, external_lit_namespaceObject.html)`${feedback_options_cjs_namespaceObject.feedbackOptions.map(({ id, localeKey, correspondingAnswer })=>(0, keyed_js_namespaceObject.keyed)(id, (0, modal_option_cjs_namespaceObject.renderModalOption)({
                props: {
                    correspondingAnswer,
                    currentAnswer: this.currentAnswer,
                    i18n: this.bindings.i18n,
                    id,
                    localeKey,
                    onChange: ()=>{
                        this.currentAnswer = correspondingAnswer;
                    }
                }
            })))}`)}
          ${(0, modal_details_cjs_namespaceObject.renderModalDetails)({
            props: {
                currentAnswer: this.currentAnswer,
                i18n: this.bindings.i18n,
                detailsInputRef: this.detailsInputRef
            }
        })}
        `)}
        ${(0, modal_footer_cjs_namespaceObject.renderModalFooter)({
            props: {
                formId: this.formId,
                i18n: this.bindings.i18n,
                onClick: ()=>this.close()
            }
        })}
      </atomic-modal>
    `;
    }
    close() {
        this.isOpen = false;
        this.smartSnippet.closeFeedbackModal();
    }
    sendFeedback(e) {
        e.preventDefault();
        if ('other' === this.currentAnswer) this.smartSnippet.sendDetailedFeedback(this.detailsInputRef.value.value);
        else this.smartSnippet.sendFeedback(this.currentAnswer);
        this.dispatchEvent(new Event('feedbackSent'));
        this.isOpen = false;
    }
    constructor(...args){
        super(...args), this.isOpen = false, this.detailsInputRef = (0, ref_js_namespaceObject.createRef)(), this.formId = (0, utils_cjs_namespaceObject.randomID)('atomic-smart-snippet-feedback-modal-form-');
    }
}
AtomicSmartSnippetFeedbackModal.styles = external_atomic_smart_snippet_feedback_modal_tw_css_cjs_default();
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Bindings ? Object : Bindings)
], AtomicSmartSnippetFeedbackModal.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicSmartSnippetFeedbackModal.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object,
        attribute: false
    }),
    _ts_metadata("design:type", "u" < typeof HTMLElement ? Object : HTMLElement)
], AtomicSmartSnippetFeedbackModal.prototype, "source", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Boolean,
        reflect: true,
        attribute: 'is-open',
        converter: boolean_converter_cjs_namespaceObject.booleanConverter
    })
], AtomicSmartSnippetFeedbackModal.prototype, "isOpen", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", Object)
], AtomicSmartSnippetFeedbackModal.prototype, "currentAnswer", void 0);
_ts_decorate([
    (0, error_guard_cjs_namespaceObject.errorGuard)(),
    (0, binding_guard_cjs_namespaceObject.bindingGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicSmartSnippetFeedbackModal.prototype, "render", null);
AtomicSmartSnippetFeedbackModal = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-smart-snippet-feedback-modal'),
    (0, bindings_cjs_namespaceObject.bindings)(),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles
], AtomicSmartSnippetFeedbackModal);
exports.AtomicSmartSnippetFeedbackModal = __webpack_exports__.AtomicSmartSnippetFeedbackModal;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicSmartSnippetFeedbackModal"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
