import{D as f,r as i,P as T,O as c,c as I}from"./app-BZJf8lgN.js";import{C as B,u as R,T as C}from"./button.esm-D_cwsnQR.js";import{u as M}from"./hooks.esm-UVLztt_0.js";function P(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function N(t){if(Array.isArray(t))return P(t)}function F(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function k(t,e){if(t){if(typeof t=="string")return P(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?P(t,e):void 0}}function U(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function L(t){return N(t)||F(t)||k(t)||U()}var p={DEFAULT_MASKS:{pint:/[\d]/,int:/[\d\-]/,pnum:/[\d\.]/,money:/[\d\.\s,]/,num:/[\d\-\.]/,hex:/[0-9a-f]/i,email:/[a-z0-9_\.\-@]/i,alpha:/[a-z_]/i,alphanum:/[a-z0-9_]/i},getRegex:function(e){return p.DEFAULT_MASKS[e]?p.DEFAULT_MASKS[e]:e},onBeforeInput:function(e,n,o){o||!f.isAndroid()||this.validateKey(e,e.data,n)},onKeyPress:function(e,n,o){o||f.isAndroid()||e.ctrlKey||e.altKey||e.metaKey||this.validateKey(e,e.key,n)},onPaste:function(e,n,o){if(!o){var r=this.getRegex(n),l=e.clipboardData.getData("text");L(l).forEach(function(d){if(!r.test(d))return e.preventDefault(),!1})}},validateKey:function(e,n,o){if(n!=null){var r=n.length<=2;if(r){var l=this.getRegex(o);l.test(n)||e.preventDefault()}}},validate:function(e,n){var o=e.target.value,r=!0,l=this.getRegex(n);return o&&!l.test(o)&&(r=!1),r}};function v(){return v=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},v.apply(null,arguments)}function y(t){"@babel/helpers - typeof";return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(t)}function z(t,e){if(y(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var o=n.call(t,e);if(y(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function H(t){var e=z(t,"string");return y(e)=="symbol"?e:e+""}function $(t,e,n){return(e=H(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var V={root:function(e){var n=e.props,o=e.isFilled,r=e.context;return I("p-inputtext p-component",{"p-disabled":n.disabled,"p-filled":o,"p-invalid":n.invalid,"p-variant-filled":n.variant?n.variant==="filled":r&&r.inputStyle==="filled"})}},m=B.extend({defaultProps:{__TYPE:"InputText",__parentMetadata:null,children:void 0,className:null,invalid:!1,variant:null,keyfilter:null,onBeforeInput:null,onInput:null,onKeyDown:null,onPaste:null,tooltip:null,tooltipOptions:null,validateOnly:!1,iconPosition:null},css:{classes:V}});function x(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,o)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x(Object(n),!0).forEach(function(o){$(t,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(n,o))})}return t}var W=i.memo(i.forwardRef(function(t,e){var n=M(),o=i.useContext(T),r=m.getProps(t,o),l=m.setMetaData(h(h({props:r},r.__parentMetadata),{},{context:{disabled:r.disabled,iconPosition:r.iconPosition}})),d=l.ptm,S=l.cx,K=l.isUnstyled;R(m.css.styles,K,{name:"inputtext",styled:!0});var u=i.useRef(e),_=function(a){r.onKeyDown&&r.onKeyDown(a),r.keyfilter&&p.onKeyPress(a,r.keyfilter,r.validateOnly)},j=function(a){r.onBeforeInput&&r.onBeforeInput(a),r.keyfilter&&p.onBeforeInput(a,r.keyfilter,r.validateOnly)},w=function(a){var g=a.target,O=!0;r.keyfilter&&r.validateOnly&&(O=p.validate(a,r.keyfilter)),r.onInput&&r.onInput(a,O),c.isNotEmpty(g.value)?f.addClass(g,"p-filled"):f.removeClass(g,"p-filled")},D=function(a){r.onPaste&&r.onPaste(a),r.keyfilter&&p.onPaste(a,r.keyfilter,r.validateOnly)};i.useEffect(function(){c.combinedRefs(u,e)},[u,e]);var b=i.useMemo(function(){return c.isNotEmpty(r.value)||c.isNotEmpty(r.defaultValue)},[r.value,r.defaultValue]),A=c.isNotEmpty(r.tooltip);i.useEffect(function(){var s;b||(s=u.current)!==null&&s!==void 0&&s.value?f.addClass(u.current,"p-filled"):f.removeClass(u.current,"p-filled")},[r.disabled,b]);var E=n({className:I(r.className,S("root",{context:o,isFilled:b})),onBeforeInput:j,onInput:w,onKeyDown:_,onPaste:D},m.getOtherProps(r),d("root"));return i.createElement(i.Fragment,null,i.createElement("input",v({ref:u},E)),A&&i.createElement(C,v({target:u,content:r.tooltip,pt:d("tooltip")},r.tooltipOptions)))}));W.displayName="InputText";export{W as I};
//# sourceMappingURL=inputtext.esm-B1lZn37a.js.map
