import{j as n}from"./fields-wnm5Jtc6.js";import{a as j,R as y}from"./vendor-D21mNUGX.js";import{P as e}from"./index-pmrLY__j.js";import{g as N}from"./index.esm-DCQn2FO4.js";const T=({id:t,defaultValue:r,description:i,validate:s,onChangeCapture:a,register:o,errors:u})=>{const l=N(u,t),[m,g]=j.useState(r);return n.jsxs(y.Fragment,{children:[n.jsxs("div",{className:"flex-column s-8",children:[n.jsxs("div",{className:"acpt-color-picker",children:[n.jsx("label",{htmlFor:t,className:"acpt-color-picker-label",style:{backgroundColor:m},children:n.jsx("input",{id:t,"data-cy":`input-${t}`,name:t,type:"color",defaultValue:r,onChangeCapture:c=>{g(c.target.value),a&&a(c)},"aria-invalid":l?"true":"false",className:`${l?"has-errors":""}`,...o(t,s)})}),n.jsx("span",{className:"color-value",children:m})]}),l&&n.jsx("div",{className:"invalid-feedback",children:l.message})]}),i&&n.jsx("div",{className:"form-description",children:i}),l&&n.jsx("div",{className:"invalid-feedback",children:l.message})]})};T.propTypes={id:e.string.isRequired,description:e.string,defaultValue:e.string,onChangeCapture:e.func,validate:e.func,register:e.func.isRequired,errors:e.array.isRequired};function P(t,r,i){var s,a,o,u,l,m=function(){var c=x()-a;r>c?s=setTimeout(m,r-c):(s=null,u=t.apply(l,o),s||(o=l=null))},g=k(function(c){return l=this,o=c,a=x(),s||(s=setTimeout(m,r)),u});return g.cancel=function(){clearTimeout(s),s=o=l=null},g}function x(){return new Date().getTime()}function k(t,r){return r=r==null?t.length-1:+r,function(){for(var i=Math.max(arguments.length-r,0),s=Array(i),a=0;a<i;a++)s[a]=arguments[a+r];switch(r){case 0:return t.call(this,s);case 1:return t.call(this,arguments[0],s);case 2:return t.call(this,arguments[0],arguments[1],s)}var o=Array(r+1);for(a=0;a<r;a++)o[a]=arguments[a];return o[r]=s,t.apply(this,o)}}const q=({size:t="default",placeholder:r,id:i,defaultValue:s,description:a,readOnly:o,onChangeCapture:u,validate:l,register:m,errors:g,rows:c=8,disabled:b=!1,characterLimit:f=null})=>{const p=N(g,i),[d,C]=j.useState(s),R=()=>{if(!f||!d)return"";const h=(d==null?void 0:d.length)??0,v=f-h;return v<=3?"color-danger":v<=10?"color-warning":""};return n.jsxs(y.Fragment,{children:[n.jsxs("div",{className:"acpt-textarea",children:[n.jsx("textarea",{rows:c||8,id:i,"data-cy":`textarea-${i}`,name:i,disabled:b,defaultValue:s,placeholder:r,onChangeCapture:h=>{C(h.target.value),u&&u(h)},readOnly:o,maxLength:f,"aria-invalid":p?"true":"false",className:`form-control ${t} ${p?"has-errors":""}`,...m(i,l)}),f&&n.jsxs("div",{className:"acpt-character-limit mt-4",children:[n.jsx("span",{className:R(),children:(d==null?void 0:d.length)??0}),n.jsx("span",{children:"/"}),n.jsx("span",{children:f})]})]}),p&&n.jsx("div",{className:"invalid-feedback",children:p.message}),a&&n.jsx("div",{className:"form-description",children:a})]})};q.propTypes={id:e.string.isRequired,size:e.oneOf(["default","sm"]),innerRef:e.func,placeholder:e.string,defaultValue:e.string,description:e.string,readOnly:e.bool,onChangeCapture:e.func,validate:e.func,register:e.func.isRequired,errors:e.array.isRequired,disabled:e.bool,rows:e.number,characterLimit:e.number};export{T as C,q as T,P as d};
