var R=Object.create;var E=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var D=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var K=(t,n,o,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of V(n))!B.call(t,e)&&e!==o&&E(t,e,{get:()=>n[e],enumerable:!(u=O(n,e))||u.enumerable});return t};var A=(t,n,o)=>(o=t!=null?R(j(t)):{},K(n||!t||!t.__esModule?E(o,"default",{value:t,enumerable:!0}):o,t));var h=D((J,d)=>{(function(){"use strict";var t={}.hasOwnProperty;function n(){for(var e="",a=0;a<arguments.length;a++){var s=arguments[a];s&&(e=u(e,o(s)))}return e}function o(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var a="";for(var s in e)t.call(e,s)&&e[s]&&(a=u(a,s));return a}function u(e,a){return a?e?e+" "+a:e+a:e}typeof d<"u"&&d.exports?(n.default=n,d.exports=n):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return n}):window.classNames=n})()});var c=A(h());import i,{useState as I}from"react";import{useEffect as k,useRef as q}from"react";function m(t){let n=q(null);return k(()=>{t&&(typeof t=="function"?t(n.current):t.current=n.current)},[n,t]),n}var _=i.forwardRef(function({label:n,clearable:o=!0,errorMessage:u,onChange:e,onValueChange:a,onEnter:s,...l},T){let f=m(T),[v,w]=I(y(l.value)),[g,b]=I(!1);function y(r){return r!==""&&r!==void 0}function x(r){let p=r.currentTarget.value;f.current&&(f.current.value=p),e?.(r),a?.(p),w(y(r.target.value))}function N(r){l.onFocus?.(r),b(!0)}function F(r){l.onBlur?.(r),b(!1)}function H(r){l.onKeyDown?.(r),r.key==="Enter"&&s?.(r.currentTarget.value)}function L(){S("")}function S(r){if(!f.current)return;Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(f.current,r);let M=new Event("input",{bubbles:!0});f.current.dispatchEvent(M)}let C=o&&v&&!l.disabled&&!l.readOnly;return i.createElement("div",{className:(0,c.default)("leaf-input-container","leaf-text-input",{filled:v,focused:g,error:!!u,disabled:l.disabled})},i.createElement("div",{className:"leaf-label-area"},n&&i.createElement("label",{className:"leaf-label"},n)),i.createElement("div",{className:(0,c.default)("leaf-input-area")},i.createElement("input",{...l,className:(0,c.default)("leaf-input",{clearable:o},l.className),ref:f,onChange:x,onFocus:N,onBlur:F,onKeyDown:H}),C&&i.createElement("button",{type:"button",className:"leaf-clear-button",onClick:L,tabIndex:-1})),i.createElement("div",{className:"leaf-extra-area"},u&&i.createElement("p",{className:(0,c.default)("leaf-error-message","leaf-desc")},u)))});export{_ as default};
/*! Bundled license information:

classnames/index.js:
  (*!
  	Copyright (c) 2018 Jed Watson.
  	Licensed under the MIT License (MIT), see
  	http://jedwatson.github.io/classnames
  *)
*/
