"use client";var D=Object.create;var L=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var W=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Z=(t,e,l,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of U(e))!G.call(t,n)&&n!==l&&L(t,n,{get:()=>e[n],enumerable:!(u=K(e,n))||u.enumerable});return t};var R=(t,e,l)=>(l=t!=null?D(A(t)):{},Z(e||!t||!t.__esModule?L(l,"default",{value:t,enumerable:!0}):l,t));var x=W((_,v)=>{(function(){"use strict";var t={}.hasOwnProperty;function e(){for(var n="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(n=u(n,l(a)))}return n}function l(n){if(typeof n=="string"||typeof n=="number")return n;if(typeof n!="object")return"";if(Array.isArray(n))return e.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var o="";for(var a in n)t.call(n,a)&&n[a]&&(o=u(o,a));return o}function u(n,o){return o?n?n+" "+o:n+o:n}typeof v<"u"&&v.exports?(e.default=e,v.exports=e):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return e}):window.classNames=e})()});import M from"react";var m=R(x());import i,{useState as C}from"react";import{useEffect as q,useRef as z}from"react";function y(t){let e=z(null);return q(()=>{t&&(typeof t=="function"?t(e.current):t.current=e.current)},[e,t]),e}import p from"react";function h({opened:t,...e}){return p.createElement("svg",{viewBox:"0 0 32 32",fill:"none",...e},!t&&p.createElement("g",{className:"closed"},p.createElement("circle",{cx:"16",cy:"18",r:"3",fill:"currentColor"}),p.createElement("path",{d:"M4 17C4 13 8 8 16 8C24 8 28 13 28 17",stroke:"currentColor",strokeWidth:"2"})),t&&p.createElement("g",{className:"opened"},p.createElement("path",{d:"M2 28L11 22M30 3C30 3 27 9 23 13",stroke:"currentColor",strokeWidth:"2"}),p.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16 27C19 27 26 24 26 17C26 11 26 7 16 7C6 7 6 11 6 17C6 24 13 27 16 27ZM11.2929 13.7071L14.5858 17L11.2929 20.2929L12.7071 21.7071L16 18.4142L19.2929 21.7071L20.7071 20.2929L17.4142 17L20.7071 13.7071L19.2929 12.2929L16 15.5858L12.7071 12.2929L11.2929 13.7071Z",fill:"currentColor"})))}var I=i.forwardRef(function({label:e,clearable:l=!0,errorMessage:u,onChange:n,onValueChange:o,onEnter:a,...s},c){let f=y(c),[d,N]=C(E(s.value)),[F,g]=C(!1),[w,P]=C(!1);function E(r){return r!==""&&r!==void 0}function T(r){let b=r.currentTarget.value;f.current&&(f.current.value=b),n?.(r),o?.(b),N(E(r.target.value))}function S(r){s.onFocus?.(r),g(!0)}function V(r){s.onBlur?.(r),g(!1)}function H(r){s.onKeyDown?.(r),r.key==="Enter"&&a?.(r.currentTarget.value)}function k(){O("")}function O(r){if(!f.current)return;Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(f.current,r);let j=new Event("input",{bubbles:!0});f.current.dispatchEvent(j)}let B=l&&d&&!s.disabled&&!s.readOnly;return i.createElement("div",{className:(0,m.default)("leaf-input-container","leaf-password-input",{filled:d,focused:F,error:!!u,disabled:s.disabled})},i.createElement("div",{className:"leaf-label-area"},e&&i.createElement("label",{className:"leaf-label"},e)),i.createElement("div",{className:(0,m.default)("leaf-input-area")},i.createElement("input",{type:w?"text":"password",...s,className:(0,m.default)("leaf-input",{clearable:l},s.className),ref:f,onChange:T,onFocus:S,onBlur:V,onKeyDown:H}),!s.disabled&&!s.readOnly&&i.createElement("button",{type:"button",className:"leaf-password-eye",onClick:()=>P(r=>!r),tabIndex:-1},i.createElement(h,{opened:w})),B&&i.createElement("button",{type:"button",className:"leaf-clear-button",onClick:k,tabIndex:-1})),i.createElement("div",{className:"leaf-extra-area"},u&&i.createElement("p",{className:(0,m.default)("leaf-error-message","leaf-desc")},u)))});import{Controller as J}from"react-hook-form";function Q(t){let{name:e,rules:l,defaultValue:u,control:n,shouldUnregister:o,...a}=t,s={name:e,rules:l,defaultValue:u,shouldUnregister:o};return n&&(s.control=n),M.createElement(J,{...s,render:({field:c,fieldState:f})=>M.createElement(I,{...a,name:c.name,value:c.value,ref:c.ref,onValueChange:d=>{c.onChange(d),a.onValueChange?.(d)},onBlur:d=>{c.onBlur(),a.onBlur?.(d)},errorMessage:f.error?.message})})}export{Q 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
  *)
*/
