'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-5aa5c817.js');

/**
 * 表单输入组件共享基础
 * 统一 size / disabled / clearable / modelValue 这一组在 Input / Select / Cascader /
 * DatePicker / InputNumber / TimePicker 等组件中重复出现的包装模式。
 *
 * 设计原则：纯函数 + 类型导出，不引入基类继承，避免 Stencil 装饰器在继承链上的隐式行为。
 * 组件按需 import 对应工具，渲染时调用即可。
 */
/** 全部合法尺寸，用于运行期校验 */
const COMPONENT_SIZES = ['large', 'default', 'small'];
/**
 * 生成尺寸 class 名：buildSizeClass('hb-input', 'large') -> 'hb-input--large'
 * 用于替代各组件 render 中重复的 `[`hb-input--${this.size}`]: true` 模板字面量。
 */
function buildSizeClass(base, size) {
    const normalized = size && COMPONENT_SIZES.includes(size) ? size : 'default';
    return `${base}--${normalized}`;
}
/**
 * 判定清空按钮是否应显示。
 * 抽取自 Input/Select/Cascader 中重复的 `clearable && !disabled && !readonly && hasValue`。
 */
function isClearVisible(options) {
    return Boolean(options.clearable && !options.disabled && !options.readonly && options.hasValue);
}
/**
 * 判定一个值是否「非空」（用于清空按钮显隐）。
 * 兼容字符串、数字、数组（多选）。
 */
function hasInputValue(value) {
    if (value === null || value === undefined)
        return false;
    if (typeof value === 'string')
        return value.length > 0;
    if (typeof value === 'number')
        return !Number.isNaN(value);
    if (Array.isArray(value))
        return value.length > 0;
    return true;
}
/**
 * 尺寸 class 集合生成器：返回包含 base 与 size class 的对象，可直接展开进 JSX class 绑定。
 * 例：sizeClassMap('hb-input', 'large', this.size) -> { 'hb-input': true, 'hb-input--large': true }
 */
function sizeClassMap(base, size) {
    return { [base]: true, [buildSizeClass(base, size)]: true };
}

const inputCss = "/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);line-height:1.5;tab-size:4;-webkit-tap-highlight-color:transparent}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.resize{resize:both}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}} /*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;:host{--hb-input-font-size:14px;--hb-input-font-size-large:16px;--hb-input-font-size-small:12px;--hb-input-height:32px;--hb-input-height-large:40px;--hb-input-height-small:24px;--hb-input-border-color:var(--hb-border-color,#dcdfe6);--hb-input-border-color-hover:var(--hb-color-primary);--hb-input-bg-color:var(--hb-color-white,#fff);--hb-input-text-color:var(--hb-color-text-regular,#606266);--hb-input-placeholder-color:var(--hb-color-text-placeholder,#c0c4cc);--hb-input-disabled-color:var(--hb-color-text-disabled,#c0c4cc);--hb-input-disabled-bg-color:var(--hb-fill-color-light,#f5f7fa);display:inline-block;position:relative}.hb-input{font-size:var(--hb-input-font-size);position:relative}.hb-input,.hb-input__inner{display:inline-block;width:100%}.hb-input__inner{-webkit-appearance:none;background-color:var(--hb-input-bg-color);background-image:none;border:1px solid var(--hb-input-border-color);border-radius:4px;box-sizing:border-box;color:var(--hb-input-text-color);font-size:inherit;height:var(--hb-input-height);line-height:var(--hb-input-height);outline:none;padding:0 15px;transition:border-color .2s cubic-bezier(.645,.045,.355,1)}.hb-input__inner::placeholder{color:var(--hb-input-placeholder-color)}.hb-input__inner:focus,.hb-input__inner:hover:not(:disabled){border-color:var(--hb-input-border-color-hover)}.hb-input__inner:disabled{background-color:var(--hb-input-disabled-bg-color);border-color:var(--hb-input-border-color);color:var(--hb-input-disabled-color);cursor:not-allowed}.hb-input__inner[readonly]{background-color:var(--hb-input-disabled-bg-color);cursor:default}.hb-input--small .hb-input__inner{font-size:var(--hb-input-font-size-small);height:var(--hb-input-height-small);line-height:var(--hb-input-height-small);padding:0 12px}.hb-input--large .hb-input__inner{font-size:var(--hb-input-font-size-large);height:var(--hb-input-height-large);line-height:var(--hb-input-height-large);padding:0 18px}.hb-input__prefix,.hb-input__suffix{align-items:center;color:var(--hb-input-placeholder-color);display:flex;height:100%;position:absolute;text-align:center;top:0;transition:all .3s}.hb-input__prefix{left:5px}.hb-input__suffix{right:5px}.hb-input__suffix-inner{align-items:center;cursor:pointer;display:flex;-webkit-user-select:none;user-select:none}.hb-input__clear{color:var(--hb-input-placeholder-color);font-size:16px;transition:color .2s}.hb-input__clear:hover{color:var(--hb-input-text-color)}.hb-input__password{cursor:pointer;font-size:16px}.hb-input__inner[type=textarea]{line-height:1.5;min-height:60px;padding:5px 15px;resize:vertical;vertical-align:bottom}.hb-input__count{bottom:5px;color:var(--hb-input-placeholder-color);font-size:12px;position:absolute;right:10px}.hb-input__count-inner{background-color:var(--hb-input-bg-color);padding:0 4px}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}";
const HbInputStyle0 = inputCss;

const Input = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.hbChange = index.createEvent(this, "hbChange", 7);
        this.hbInput = index.createEvent(this, "hbInput", 7);
        this.hbFocus = index.createEvent(this, "hbFocus", 7);
        this.hbBlur = index.createEvent(this, "hbBlur", 7);
        this.hbClear = index.createEvent(this, "hbClear", 7);
    }
    get el() { return index.getElement(this); }
    /**
     * 绑定值
     */
    modelValue = '';
    /**
     * 输入框类型
     */
    type = 'text';
    /**
     * 输入框尺寸
     */
    size = 'default';
    /**
     * 是否禁用
     * @default false
     */
    disabled = false;
    /**
     * 是否只读
     * @default false
     */
    readonly = false;
    /**
     * 输入框占位文本
     */
    placeholder;
    /**
     * 是否可清空
     * @default false
     */
    clearable = false;
    /**
     * 是否显示密码可见性切换
     * @default false
     */
    showPassword = false;
    /**
     * 是否显示字数统计
     * @default false
     */
    showWordLimit = false;
    /**
     * 最大输入长度
     */
    maxlength;
    /**
     * 最小输入长度
     */
    minlength;
    /**
     * 原生 name 属性
     */
    name;
    /**
     * 原生 id 属性
     */
    inputId;
    /**
     * 原生 autocomplete 属性
     */
    autocomplete;
    /**
     * 原生 autofocus 属性
     */
    autofocus = false;
    /**
     * 输入框头部图标
     */
    prefixIcon;
    /**
     * 输入框尾部图标
     */
    suffixIcon;
    /**
     * 输入框行数，仅 type 为 'textarea' 时有效
     */
    rows = 2;
    /**
     * 是否自适应内容高度，仅 type 为 'textarea' 时有效
     */
    autosize = false;
    /**
     * 是否调整 textarea 大小
     */
    resize;
    isFocused = false;
    showClear = false;
    passwordVisible = false;
    inputValue = '';
    inputRef;
    /**
     * 值改变事件
     */
    hbChange;
    /**
     * 输入事件
     */
    hbInput;
    /**
     * 聚焦事件
     */
    hbFocus;
    /**
     * 失焦事件
     */
    hbBlur;
    /**
     * 清空事件
     */
    hbClear;
    handleValueChange() {
        this.inputValue = this.modelValue;
        this.updateClearVisible();
    }
    componentDidLoad() {
        this.inputValue = this.modelValue;
        this.updateClearVisible();
    }
    updateClearVisible() {
        this.showClear = isClearVisible({
            clearable: this.clearable,
            disabled: this.disabled,
            readonly: this.readonly,
            hasValue: hasInputValue(this.inputValue),
        });
    }
    handleInput = (e) => {
        const target = e.target;
        this.inputValue = target.value;
        this.modelValue = target.value;
        this.updateClearVisible();
        this.hbInput.emit(target.value);
    };
    handleChange = (e) => {
        const target = e.target;
        this.hbChange.emit(target.value);
    };
    handleFocus = (e) => {
        this.isFocused = true;
        this.updateClearVisible();
        this.hbFocus.emit(e);
    };
    handleBlur = (e) => {
        this.isFocused = false;
        this.updateClearVisible();
        this.hbBlur.emit(e);
    };
    handleClear = (e) => {
        e.stopPropagation();
        this.inputValue = '';
        this.modelValue = '';
        this.updateClearVisible();
        this.hbClear.emit();
        this.hbChange.emit('');
        if (this.inputRef) {
            this.inputRef.focus();
        }
    };
    togglePasswordVisible = () => {
        this.passwordVisible = !this.passwordVisible;
    };
    getInputType() {
        if (this.type === 'password' && this.showPassword) {
            return this.passwordVisible ? 'text' : 'password';
        }
        return this.type;
    }
    render() {
        const isTextarea = this.type === 'textarea';
        const InputTag = isTextarea ? 'textarea' : 'input';
        return (index.h("div", { key: '22b51bd1c9e0c3086ed167eea57f3b5818685785', class: {
                ...sizeClassMap('hb-input', this.size),
                'hb-input--disabled': this.disabled,
                'hb-input--focused': this.isFocused,
            } }, this.prefixIcon && (index.h("span", { key: 'ef3b02d947c45ac282814a0e2e4909f8473469eb', class: "hb-input__prefix" }, index.h("i", { key: '88f95312bf9aa489d5d27a1f701b2eadc794d7cf', class: this.prefixIcon }))), index.h(InputTag, { key: 'fe5de1f3dcf5441aebb5bcc943c64d59221211d7', ref: (el) => (this.inputRef = el), type: isTextarea ? undefined : this.getInputType(), id: this.inputId, name: this.name, class: "hb-input__inner", placeholder: this.placeholder, value: this.inputValue, disabled: this.disabled, readonly: this.readonly, autocomplete: this.autocomplete, autofocus: this.autofocus, maxlength: this.maxlength, minlength: this.minlength, rows: isTextarea ? this.rows : undefined, style: isTextarea && this.resize ? { resize: this.resize } : undefined, onInput: this.handleInput, onChange: this.handleChange, onFocus: this.handleFocus, onBlur: this.handleBlur }), (this.showClear || this.suffixIcon || (this.type === 'password' && this.showPassword)) && (index.h("span", { key: 'db106e66989483c48171aad758cd5a443ef7670a', class: "hb-input__suffix" }, this.showClear && (index.h("span", { key: '3fa676f9860aa3018247c9d61bad432afdea4345', class: "hb-input__suffix-inner hb-input__clear", onClick: this.handleClear }, "\u00D7")), this.type === 'password' && this.showPassword && (index.h("span", { key: '8911301b65aa3435f7f3b933b9b8de1b055c266e', class: "hb-input__suffix-inner hb-input__password", onClick: this.togglePasswordVisible }, this.passwordVisible ? '👁️' : '👁️‍🗨️')), this.suffixIcon && (index.h("span", { key: '14fa885ec429419525ea5cd550fc7d9cec9f3ee4', class: "hb-input__suffix-inner" }, index.h("i", { key: '36995c1f4e5d2c258170e7ad8a012e586d905e62', class: this.suffixIcon }))))), this.showWordLimit && this.maxlength && (index.h("span", { key: '383d7d25fbbb77dad3df3ebbbf4e0b1fc504a4b4', class: "hb-input__count" }, index.h("span", { key: '564d4a6ac0feae0be61378f52aae3b22872566fb', class: "hb-input__count-inner" }, this.inputValue.length, " / ", this.maxlength)))));
    }
    static get watchers() { return {
        "modelValue": ["handleValueChange"]
    }; }
};
Input.style = HbInputStyle0;

exports.hb_input = Input;

//# sourceMappingURL=hb-input.cjs.entry.js.map