var __decorate = (this && this.__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 IgcInputBaseComponent_1;
import { LitElement, html, nothing } from 'lit';
import { property, query, queryAssignedElements } from 'lit/decorators.js';
import { getThemeController, themes } from '../../theming/theming-decorator.js';
import { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
import { FormAssociatedRequiredMixin } from '../common/mixins/forms/associated-required.js';
import { createCounter, partNameMap } from '../common/util.js';
import IgcValidationContainerComponent from '../validation-container/validation-container.js';
import { styles } from './themes/input.base.css.js';
import { styles as shared } from './themes/shared/input.common.css.js';
import { all } from './themes/themes.js';
let IgcInputBaseComponent = IgcInputBaseComponent_1 = class IgcInputBaseComponent extends FormAssociatedRequiredMixin(EventEmitterMixin(LitElement)) {
    constructor() {
        super(...arguments);
        this.inputId = `input-${IgcInputBaseComponent_1.increment()}`;
        this.outlined = false;
        this.readOnly = false;
    }
    get _isMaterial() {
        return getThemeController(this)?.theme === 'material';
    }
    createRenderRoot() {
        const root = super.createRenderRoot();
        root.addEventListener('slotchange', () => this.requestUpdate());
        return root;
    }
    focus(options) {
        this.input.focus(options);
    }
    blur() {
        this.input.blur();
    }
    renderValidatorContainer() {
        return IgcValidationContainerComponent.create(this);
    }
    resolvePartNames(base) {
        return {
            [base]: true,
            prefixed: this.prefixes.length > 0,
            suffixed: this.suffixes.length > 0,
            filled: !!this.value,
        };
    }
    renderFileParts() {
        return nothing;
    }
    setSelectionRange(start, end, direction = 'none') {
        this.input.setSelectionRange(start, end, direction);
    }
    setRangeText(replacement, start, end, selectMode = 'preserve') {
        this.input.setRangeText(replacement, start, end, selectMode);
    }
    renderPrefix() {
        return html `<div part="prefix">
      <slot name="prefix"></slot>
    </div>`;
    }
    renderSuffix() {
        return html `<div part="suffix">
      <slot name="suffix"></slot>
    </div>`;
    }
    renderLabel() {
        return this.label
            ? html `<label part="label" for=${this.inputId}> ${this.label} </label>`
            : nothing;
    }
    renderMaterial() {
        return html `
      <div
        part=${partNameMap({
            ...this.resolvePartNames('container'),
            labelled: this.label,
        })}
      >
        <div part="start">${this.renderPrefix()}</div>
        ${this.renderInput()} ${this.renderFileParts()}
        <div part="notch">${this.renderLabel()}</div>
        <div part="filler"></div>
        <div part="end">${this.renderSuffix()}</div>
      </div>
      ${this.renderValidatorContainer()}
    `;
    }
    renderStandard() {
        return html `${this.renderLabel()}
      <div part=${partNameMap(this.resolvePartNames('container'))}>
        ${this.renderPrefix()} ${this.renderFileParts()} ${this.renderInput()}
        ${this.renderSuffix()}
      </div>
      ${this.renderValidatorContainer()}`;
    }
    render() {
        return this._isMaterial ? this.renderMaterial() : this.renderStandard();
    }
};
IgcInputBaseComponent.shadowRootOptions = {
    ...LitElement.shadowRootOptions,
    delegatesFocus: true,
};
IgcInputBaseComponent.styles = [styles, shared];
IgcInputBaseComponent.increment = createCounter();
__decorate([
    query('input')
], IgcInputBaseComponent.prototype, "input", void 0);
__decorate([
    queryAssignedElements({ slot: 'helper-text' })
], IgcInputBaseComponent.prototype, "_helperText", void 0);
__decorate([
    queryAssignedElements({
        slot: 'prefix',
        selector: '[slot="prefix"]:not([hidden])',
    })
], IgcInputBaseComponent.prototype, "prefixes", void 0);
__decorate([
    queryAssignedElements({
        slot: 'suffix',
        selector: '[slot="suffix"]:not([hidden])',
    })
], IgcInputBaseComponent.prototype, "suffixes", void 0);
__decorate([
    property({ reflect: true, type: Boolean })
], IgcInputBaseComponent.prototype, "outlined", void 0);
__decorate([
    property({ type: Boolean, reflect: true, attribute: 'readonly' })
], IgcInputBaseComponent.prototype, "readOnly", void 0);
__decorate([
    property()
], IgcInputBaseComponent.prototype, "placeholder", void 0);
__decorate([
    property()
], IgcInputBaseComponent.prototype, "label", void 0);
IgcInputBaseComponent = IgcInputBaseComponent_1 = __decorate([
    blazorDeepImport,
    themes(all, { exposeController: true })
], IgcInputBaseComponent);
export { IgcInputBaseComponent };
//# sourceMappingURL=input-base.js.map