import { h } from "@stencil/core";
export class InternalMessageInput {
    placeholder = '输入消息...';
    disabled = false;
    maxLength = 1000;
    multiline = false;
    showCharCount = true;
    sendButtonText = '发送';
    inputValue = '';
    isComposing = false;
    messageSend;
    inputChange;
    inputFocus;
    inputBlur;
    handleInput = (event) => {
        const target = event.target;
        this.inputValue = target.value;
        this.inputChange.emit(this.inputValue);
    };
    handleKeyDown = (event) => {
        if (event.key === 'Enter') {
            if (this.multiline) {
                if (event.shiftKey) {
                    // Shift+Enter 换行
                    return;
                }
                else {
                    // Enter 发送
                    event.preventDefault();
                    this.handleSend();
                }
            }
            else {
                // 单行模式 Enter 发送
                event.preventDefault();
                this.handleSend();
            }
        }
    };
    handleCompositionStart = () => {
        this.isComposing = true;
    };
    handleCompositionEnd = () => {
        this.isComposing = false;
        this.handleInput({ target: { value: this.inputValue } });
    };
    handleSend = () => {
        const content = this.inputValue.trim();
        if (content && !this.disabled && !this.isComposing) {
            const timestamp = Date.now();
            this.messageSend.emit({ content, timestamp });
            this.inputValue = '';
        }
    };
    handleFocus = () => {
        this.inputFocus.emit();
    };
    handleBlur = () => {
        this.inputBlur.emit();
    };
    render() {
        const isSendDisabled = this.disabled || !this.inputValue.trim();
        return (h("div", { key: '0c753069338af0ac9e02da2e6bd481218bca5eb8', class: "message-input-container" }, h("div", { key: '53a5e153f282ce0f9e62d84f70657f95dec28974', class: "input-wrapper" }, this.multiline ? (h("textarea", { class: "message-input", placeholder: this.placeholder, disabled: this.disabled, maxLength: this.maxLength, rows: 3, value: this.inputValue, onInput: this.handleInput, onKeyDown: this.handleKeyDown, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, onFocus: this.handleFocus, onBlur: this.handleBlur })) : (h("input", { type: "text", class: "message-input", placeholder: this.placeholder, disabled: this.disabled, maxLength: this.maxLength, value: this.inputValue, onInput: this.handleInput, onKeyDown: this.handleKeyDown, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, onFocus: this.handleFocus, onBlur: this.handleBlur })), h("button", { key: '16b1bdf1ecd3b7b6632990681cee811af465254f', class: "send-button", disabled: isSendDisabled, onClick: this.handleSend }, this.sendButtonText)), this.showCharCount && (h("div", { key: 'b35e43619d230d69152c1af52f12a66955f952b5', class: "char-count" }, this.inputValue.length, "/", this.maxLength))));
    }
    static get is() { return "internal-message-input"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["message-input.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["message-input.css"]
        };
    }
    static get properties() {
        return {
            "placeholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "placeholder",
                "defaultValue": "'\u8F93\u5165\u6D88\u606F...'"
            },
            "disabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "disabled",
                "defaultValue": "false"
            },
            "maxLength": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "max-length",
                "defaultValue": "1000"
            },
            "multiline": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "multiline",
                "defaultValue": "false"
            },
            "showCharCount": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-char-count",
                "defaultValue": "true"
            },
            "sendButtonText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "send-button-text",
                "defaultValue": "'\u53D1\u9001'"
            }
        };
    }
    static get states() {
        return {
            "inputValue": {},
            "isComposing": {}
        };
    }
    static get events() {
        return [{
                "method": "messageSend",
                "name": "messageSend",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "{ content: string; timestamp: number }",
                    "resolved": "{ content: string; timestamp: number; }",
                    "references": {}
                }
            }, {
                "method": "inputChange",
                "name": "inputChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                }
            }, {
                "method": "inputFocus",
                "name": "inputFocus",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }, {
                "method": "inputBlur",
                "name": "inputBlur",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
}
//# sourceMappingURL=message-input.js.map
