"use strict";(globalThis.webpackChunk_elliemae_pui_app_sdk=globalThis.webpackChunk_elliemae_pui_app_sdk||[]).push([[5974],{"./lib/view/fields/form-layout-block-item/index.tsx":(W,k,e)=>{e.d(k,{B:()=>m});var a=e("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/objectWithoutProperties.js"),r=e.n(a),x=e("./node_modules/.pnpm/@elliemae+ds-form-layout-blocks@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-form-layout-blocks/dist/esm/form-layout-block-item/DSFormLayoutBlockItem.js"),b=e("./node_modules/.pnpm/react-hook-form@7.63.0_react@18.3.1/node_modules/react-hook-form/dist/index.esm.mjs"),n=e("./node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js"),c=["inputID","label"],m=function(u){var i=u.inputID,y=u.label,M=r()(u,c),g=(0,b.lN)({name:i}),d=g.errors,f=(0,b.Jt)(d,i),P=!!f,v=f?.message;return(0,n.jsx)(x.U,Object.assign({inputID:i,label:y,hasError:P,validationMessage:v},M))};m.displayName="FormLayoutBlockItem"},"./lib/view/fields/masked-input-text/index.tsx":(W,k,e)=>{e.d(k,{B:()=>g});var a=e("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/jsx.js"),r=e.n(a),x=e("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/slicedToArray.js"),b=e.n(x),n=e("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/objectWithoutProperties.js"),c=e.n(n),m=e("./node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),u=e("./node_modules/.pnpm/@elliemae+ds-form-input-text@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-form-input-text/dist/esm/DSInputText.js"),i=e("./node_modules/.pnpm/react-hook-form@7.63.0_react@18.3.1/node_modules/react-hook-form/dist/index.esm.mjs"),y=e("./node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js"),M=["name","defaultValue","rules","useMask","maskOpts"],g=function(d){var f=d.name,P=d.defaultValue,v=P===void 0?"":P,C=d.rules,L=C===void 0?{}:C,Z=d.useMask,H=d.maskOpts,R=c()(d,M),q=m.useState(v),Q=b()(q,2),ee=Q[1],w=(0,i.xW)(),Y=w.setValue,ne=m.useMemo(function(){return Object.assign({},H,{onChange:function(K,V){return Y(f,V,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},valueSetter:ee})},[H,f,Y]),te=Z(ne);return r()(i.xI,{name:f,defaultValue:v,rules:L,render:function(K){var V=K.field,U=K.fieldState.error;return(0,y.jsx)(u.B,Object.assign({hasError:!!U},R,V,te))}})};g.displayName="MaskedInputText"},"./lib/view/fields/masked-input-text/with-money-mask.stories.tsx":(W,k,e)=>{e.r(k),e.d(k,{WithMoneyMask:()=>v,__namedExportsOrder:()=>C,default:()=>f});var a=e("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/jsx.js"),r=e.n(a),x=e("./node_modules/.pnpm/@elliemae+ds-grid@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-grid/dist/esm/Grid.js"),b=e("./node_modules/.pnpm/@elliemae+ds-legacy-button-v2@1.0.16_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-legacy-button-v2/dist/esm/DSButtonV2.js"),n=e("./node_modules/.pnpm/@elliemae+ds-form-helpers-mask-hooks@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-form-helpers-mask-hooks/dist/esm/hooks/useNumberMask.js"),c=e("./lib/view/form/index.tsx"),m=e("./lib/view/fields/masked-input-text/index.tsx"),u=e("./lib/view/fields/form-layout-block-item/index.tsx"),i=e("./lib/view/fields/watch-value.tsx"),y=e("./node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js"),M,g=`
    
    // @ts-nocheck
    // @ts-ignore
    var __STORY__ = "import { Story, Meta } from '@storybook/react';\\nimport { Grid } from '@elliemae/ds-grid';\\n// import '@elliemae/ds-form-input-text';\\nimport { DSButtonV2 } from '@elliemae/ds-button';\\nimport { useNumberMask } from '@elliemae/ds-controlled-form';\\nimport { Form } from '../../form/index.js';\\nimport { InputTextProps } from '../input-text/index.js';\\nimport { MaskedInputText } from './index.js';\\nimport { FormLayoutBlockItem } from '../form-layout-block-item/index.js';\\nimport { WatchValue } from '../watch-value.js';\\n\\nexport default {\\n  title: 'Components/Form/Controls/MaskedInputText',\\n  component: MaskedInputText,\\n} as Meta;\\n\\nconst Template: Story<InputTextProps & { labelText: string }> = (args) => (\\n  <Grid p=\\"m\\">\\n    <Form>\\n      <FormLayoutBlockItem inputID=\\"money\\" label=\\"Money\\" required>\\n        <MaskedInputText\\n          {...args}\\n          useMask={useNumberMask}\\n          maskOpts={{\\n            decimalPlaces: 2,\\n            prefix: '$',\\n            allowNegative: true,\\n            suffix: '',\\n            includeThousandsSeparator: true,\\n            decimalRequired: false,\\n          }}\\n        />\\n      </FormLayoutBlockItem>\\n      <DSButtonV2>Submit</DSButtonV2>\\n      <WatchValue label=\\"Money\\" {...args} />\\n    </Form>\\n  </Grid>\\n);\\n\\nexport const WithMoneyMask = Template.bind({});\\n\\nWithMoneyMask.args = {\\n  id: 'money',\\n  name: 'money',\\n  placeholder: '$10,000',\\n  rules: {\\n    required: { value: true, message: 'Please enter money' },\\n  },\\n};\\n";
    // @ts-ignore
    var __LOCATIONS_MAP__ = {"WithMoneyMask":{"startLoc":{"col":64,"line":17},"endLoc":{"col":1,"line":38},"startBody":{"col":64,"line":17},"endBody":{"col":1,"line":38}}};
    
import { Story, Meta } from '@storybook/react';
import { Grid } from '@elliemae/ds-grid';
// import '@elliemae/ds-form-input-text';
import { DSButtonV2 } from '@elliemae/ds-button';
import { useNumberMask } from '@elliemae/ds-controlled-form';
import { Form } from '../../form/index.js';
import { InputTextProps } from '../input-text/index.js';
import { MaskedInputText } from './index.js';
import { FormLayoutBlockItem } from '../form-layout-block-item/index.js';
import { WatchValue } from '../watch-value.js';

export default {parameters: {"storySource":{"source":"import { Story, Meta } from '@storybook/react';\\nimport { Grid } from '@elliemae/ds-grid';\\n// import '@elliemae/ds-form-input-text';\\nimport { DSButtonV2 } from '@elliemae/ds-button';\\nimport { useNumberMask } from '@elliemae/ds-controlled-form';\\nimport { Form } from '../../form/index.js';\\nimport { InputTextProps } from '../input-text/index.js';\\nimport { MaskedInputText } from './index.js';\\nimport { FormLayoutBlockItem } from '../form-layout-block-item/index.js';\\nimport { WatchValue } from '../watch-value.js';\\n\\nexport default {\\n  title: 'Components/Form/Controls/MaskedInputText',\\n  component: MaskedInputText,\\n} as Meta;\\n\\nconst Template: Story<InputTextProps & { labelText: string }> = (args) => (\\n  <Grid p=\\"m\\">\\n    <Form>\\n      <FormLayoutBlockItem inputID=\\"money\\" label=\\"Money\\" required>\\n        <MaskedInputText\\n          {...args}\\n          useMask={useNumberMask}\\n          maskOpts={{\\n            decimalPlaces: 2,\\n            prefix: '$',\\n            allowNegative: true,\\n            suffix: '',\\n            includeThousandsSeparator: true,\\n            decimalRequired: false,\\n          }}\\n        />\\n      </FormLayoutBlockItem>\\n      <DSButtonV2>Submit</DSButtonV2>\\n      <WatchValue label=\\"Money\\" {...args} />\\n    </Form>\\n  </Grid>\\n);\\n\\nexport const WithMoneyMask = Template.bind({});\\n\\nWithMoneyMask.args = {\\n  id: 'money',\\n  name: 'money',\\n  placeholder: '$10,000',\\n  rules: {\\n    required: { value: true, message: 'Please enter money' },\\n  },\\n};\\n","locationsMap":{"with-money-mask":{"startLoc":{"col":64,"line":17},"endLoc":{"col":1,"line":38},"startBody":{"col":64,"line":17},"endBody":{"col":1,"line":38}}}},},
  title: 'Components/Form/Controls/MaskedInputText',
  component: MaskedInputText,
} as Meta;

const Template: Story<InputTextProps & { labelText: string }> = (args) => (
  <Grid p="m">
    <Form>
      <FormLayoutBlockItem inputID="money" label="Money" required>
        <MaskedInputText
          {...args}
          useMask={useNumberMask}
          maskOpts={{
            decimalPlaces: 2,
            prefix: '$',
            allowNegative: true,
            suffix: '',
            includeThousandsSeparator: true,
            decimalRequired: false,
          }}
        />
      </FormLayoutBlockItem>
      <DSButtonV2>Submit</DSButtonV2>
      <WatchValue label="Money" {...args} />
    </Form>
  </Grid>
);

export const WithMoneyMask = Template.bind({});

WithMoneyMask.args = {
  id: 'money',
  name: 'money',
  placeholder: '$10,000',
  rules: {
    required: { value: true, message: 'Please enter money' },
  },
};
`,d={WithMoneyMask:{startLoc:{col:64,line:25},endLoc:{col:1,line:46},startBody:{col:64,line:25},endBody:{col:1,line:46}}},g=`import { Story, Meta } from '@storybook/react';
import { Grid } from '@elliemae/ds-grid';
// import '@elliemae/ds-form-input-text';
import { DSButtonV2 } from '@elliemae/ds-button';
import { useNumberMask } from '@elliemae/ds-controlled-form';
import { Form } from '../../form/index.js';
import { InputTextProps } from '../input-text/index.js';
import { MaskedInputText } from './index.js';
import { FormLayoutBlockItem } from '../form-layout-block-item/index.js';
import { WatchValue } from '../watch-value.js';

export default {
  title: 'Components/Form/Controls/MaskedInputText',
  component: MaskedInputText,
} as Meta;

const Template: Story<InputTextProps & { labelText: string }> = (args) => (
  <Grid p="m">
    <Form>
      <FormLayoutBlockItem inputID="money" label="Money" required>
        <MaskedInputText
          {...args}
          useMask={useNumberMask}
          maskOpts={{
            decimalPlaces: 2,
            prefix: '$',
            allowNegative: true,
            suffix: '',
            includeThousandsSeparator: true,
            decimalRequired: false,
          }}
        />
      </FormLayoutBlockItem>
      <DSButtonV2>Submit</DSButtonV2>
      <WatchValue label="Money" {...args} />
    </Form>
  </Grid>
);

export const WithMoneyMask = Template.bind({});

WithMoneyMask.args = {
  id: 'money',
  name: 'money',
  placeholder: '$10,000',
  rules: {
    required: { value: true, message: 'Please enter money' },
  },
};
`,d={WithMoneyMask:{startLoc:{col:64,line:17},endLoc:{col:1,line:38},startBody:{col:64,line:17},endBody:{col:1,line:38}}};const f={parameters:{storySource:{source:`
    
    // @ts-nocheck
    // @ts-ignore
    var __STORY__ = "import { Story, Meta } from '@storybook/react';\\nimport { Grid } from '@elliemae/ds-grid';\\n// import '@elliemae/ds-form-input-text';\\nimport { DSButtonV2 } from '@elliemae/ds-button';\\nimport { useNumberMask } from '@elliemae/ds-controlled-form';\\nimport { Form } from '../../form/index.js';\\nimport { InputTextProps } from '../input-text/index.js';\\nimport { MaskedInputText } from './index.js';\\nimport { FormLayoutBlockItem } from '../form-layout-block-item/index.js';\\nimport { WatchValue } from '../watch-value.js';\\n\\nexport default {\\n  title: 'Components/Form/Controls/MaskedInputText',\\n  component: MaskedInputText,\\n} as Meta;\\n\\nconst Template: Story<InputTextProps & { labelText: string }> = (args) => (\\n  <Grid p=\\"m\\">\\n    <Form>\\n      <FormLayoutBlockItem inputID=\\"money\\" label=\\"Money\\" required>\\n        <MaskedInputText\\n          {...args}\\n          useMask={useNumberMask}\\n          maskOpts={{\\n            decimalPlaces: 2,\\n            prefix: '$',\\n            allowNegative: true,\\n            suffix: '',\\n            includeThousandsSeparator: true,\\n            decimalRequired: false,\\n          }}\\n        />\\n      </FormLayoutBlockItem>\\n      <DSButtonV2>Submit</DSButtonV2>\\n      <WatchValue label=\\"Money\\" {...args} />\\n    </Form>\\n  </Grid>\\n);\\n\\nexport const WithMoneyMask = Template.bind({});\\n\\nWithMoneyMask.args = {\\n  id: 'money',\\n  name: 'money',\\n  placeholder: '$10,000',\\n  rules: {\\n    required: { value: true, message: 'Please enter money' },\\n  },\\n};\\n";
    // @ts-ignore
    var __LOCATIONS_MAP__ = {"WithMoneyMask":{"startLoc":{"col":64,"line":17},"endLoc":{"col":1,"line":38},"startBody":{"col":64,"line":17},"endBody":{"col":1,"line":38}}};
    
import { Story, Meta } from '@storybook/react';
import { Grid } from '@elliemae/ds-grid';
// import '@elliemae/ds-form-input-text';
import { DSButtonV2 } from '@elliemae/ds-button';
import { useNumberMask } from '@elliemae/ds-controlled-form';
import { Form } from '../../form/index.js';
import { InputTextProps } from '../input-text/index.js';
import { MaskedInputText } from './index.js';
import { FormLayoutBlockItem } from '../form-layout-block-item/index.js';
import { WatchValue } from '../watch-value.js';

export default {parameters: {"storySource":{"source":"import { Story, Meta } from '@storybook/react';\\nimport { Grid } from '@elliemae/ds-grid';\\n// import '@elliemae/ds-form-input-text';\\nimport { DSButtonV2 } from '@elliemae/ds-button';\\nimport { useNumberMask } from '@elliemae/ds-controlled-form';\\nimport { Form } from '../../form/index.js';\\nimport { InputTextProps } from '../input-text/index.js';\\nimport { MaskedInputText } from './index.js';\\nimport { FormLayoutBlockItem } from '../form-layout-block-item/index.js';\\nimport { WatchValue } from '../watch-value.js';\\n\\nexport default {\\n  title: 'Components/Form/Controls/MaskedInputText',\\n  component: MaskedInputText,\\n} as Meta;\\n\\nconst Template: Story<InputTextProps & { labelText: string }> = (args) => (\\n  <Grid p=\\"m\\">\\n    <Form>\\n      <FormLayoutBlockItem inputID=\\"money\\" label=\\"Money\\" required>\\n        <MaskedInputText\\n          {...args}\\n          useMask={useNumberMask}\\n          maskOpts={{\\n            decimalPlaces: 2,\\n            prefix: '$',\\n            allowNegative: true,\\n            suffix: '',\\n            includeThousandsSeparator: true,\\n            decimalRequired: false,\\n          }}\\n        />\\n      </FormLayoutBlockItem>\\n      <DSButtonV2>Submit</DSButtonV2>\\n      <WatchValue label=\\"Money\\" {...args} />\\n    </Form>\\n  </Grid>\\n);\\n\\nexport const WithMoneyMask = Template.bind({});\\n\\nWithMoneyMask.args = {\\n  id: 'money',\\n  name: 'money',\\n  placeholder: '$10,000',\\n  rules: {\\n    required: { value: true, message: 'Please enter money' },\\n  },\\n};\\n","locationsMap":{"with-money-mask":{"startLoc":{"col":64,"line":17},"endLoc":{"col":1,"line":38},"startBody":{"col":64,"line":17},"endBody":{"col":1,"line":38}}}},},
  title: 'Components/Form/Controls/MaskedInputText',
  component: MaskedInputText,
} as Meta;

const Template: Story<InputTextProps & { labelText: string }> = (args) => (
  <Grid p="m">
    <Form>
      <FormLayoutBlockItem inputID="money" label="Money" required>
        <MaskedInputText
          {...args}
          useMask={useNumberMask}
          maskOpts={{
            decimalPlaces: 2,
            prefix: '$',
            allowNegative: true,
            suffix: '',
            includeThousandsSeparator: true,
            decimalRequired: false,
          }}
        />
      </FormLayoutBlockItem>
      <DSButtonV2>Submit</DSButtonV2>
      <WatchValue label="Money" {...args} />
    </Form>
  </Grid>
);

export const WithMoneyMask = Template.bind({});

WithMoneyMask.args = {
  id: 'money',
  name: 'money',
  placeholder: '$10,000',
  rules: {
    required: { value: true, message: 'Please enter money' },
  },
};
`,locationsMap:{"with-money-mask":{startLoc:{col:64,line:25},endLoc:{col:1,line:46},startBody:{col:64,line:25},endBody:{col:1,line:46}}}},storySource:{source:`import { Story, Meta } from '@storybook/react';
import { Grid } from '@elliemae/ds-grid';
// import '@elliemae/ds-form-input-text';
import { DSButtonV2 } from '@elliemae/ds-button';
import { useNumberMask } from '@elliemae/ds-controlled-form';
import { Form } from '../../form/index.js';
import { InputTextProps } from '../input-text/index.js';
import { MaskedInputText } from './index.js';
import { FormLayoutBlockItem } from '../form-layout-block-item/index.js';
import { WatchValue } from '../watch-value.js';

export default {
  title: 'Components/Form/Controls/MaskedInputText',
  component: MaskedInputText,
} as Meta;

const Template: Story<InputTextProps & { labelText: string }> = (args) => (
  <Grid p="m">
    <Form>
      <FormLayoutBlockItem inputID="money" label="Money" required>
        <MaskedInputText
          {...args}
          useMask={useNumberMask}
          maskOpts={{
            decimalPlaces: 2,
            prefix: '$',
            allowNegative: true,
            suffix: '',
            includeThousandsSeparator: true,
            decimalRequired: false,
          }}
        />
      </FormLayoutBlockItem>
      <DSButtonV2>Submit</DSButtonV2>
      <WatchValue label="Money" {...args} />
    </Form>
  </Grid>
);

export const WithMoneyMask = Template.bind({});

WithMoneyMask.args = {
  id: 'money',
  name: 'money',
  placeholder: '$10,000',
  rules: {
    required: { value: true, message: 'Please enter money' },
  },
};
`,locationsMap:{"with-money-mask":{startLoc:{col:64,line:17},endLoc:{col:1,line:38},startBody:{col:64,line:17},endBody:{col:1,line:38}}}}},title:"Components/Form/Controls/MaskedInputText",component:m.B};var P=function(L){return r()(x.Ay,{p:"m"},void 0,r()(c.l,{},void 0,r()(u.B,{inputID:"money",label:"Money",required:!0},void 0,(0,y.jsx)(m.B,Object.assign({},L,{useMask:n.XF,maskOpts:{decimalPlaces:2,prefix:"$",allowNegative:!0,suffix:"",includeThousandsSeparator:!0,decimalRequired:!1}}))),M||(M=r()(b.e,{},void 0,"Submit")),(0,y.jsx)(i.n,Object.assign({label:"Money"},L))))};P.displayName="Template";var v=P.bind({});v.args={id:"money",name:"money",placeholder:"$10,000",rules:{required:{value:!0,message:"Please enter money"}}};var C=["WithMoneyMask"]},"./lib/view/fields/watch-value.tsx":(W,k,e)=>{e.d(k,{n:()=>i});var a=e("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/jsx.js"),r=e.n(a),x=e("./node_modules/.pnpm/styled-components@5.3.11_react-dom@18.3.1_react@18.3.1/node_modules/styled-components/dist/styled-components.browser.esm.js"),b=e("./node_modules/.pnpm/@elliemae+ds-grid@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-grid/dist/esm/Grid.js"),n=e("./node_modules/.pnpm/react-hook-form@7.63.0_react@18.3.1/node_modules/react-hook-form/dist/index.esm.mjs"),c,m=x.Ay.section.withConfig({componentId:"sc-1va6d9p-0"})(["margin-top:10px;border-top:2px blue dotted;width:100%;"]),u=x.Ay.div.withConfig({componentId:"sc-1va6d9p-1"})(["display:flex;flex-direction:column;padding-left:10px;align-items:flex-start;"]),i=function(y){var M=y.name,g=y.label,d=(0,n.xW)(),f=d.watch,P=f(M,!1)||"";return r()(b.Ay,{},void 0,r()(m,{},void 0,c||(c=r()("h4",{},void 0,"Form Data:")),r()(u,{},void 0,r()("div",{},void 0,g," : ",r()("strong",{},void 0,JSON.stringify(P))))))};i.displayName="WatchValue"},"./lib/view/form/index.tsx":(W,k,e)=>{e.d(k,{l:()=>n});var a=e("./node_modules/.pnpm/styled-components@5.3.11_react-dom@18.3.1_react@18.3.1/node_modules/styled-components/dist/styled-components.browser.esm.js"),r=e("./node_modules/.pnpm/react-hook-form@7.63.0_react@18.3.1/node_modules/react-hook-form/dist/index.esm.mjs"),x=e("./node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js"),b=a.Ay.form.withConfig({componentId:"sc-1pyjvv3-0"})(["width:100%;"]),n=function(c){var m=c.classname,u=c.reactHookFormProps,i=u===void 0?{mode:"onBlur"}:u,y=c.children,M=c.onSubmit,g=(0,r.mN)(i),d={};M&&(d.onSubmit=g.handleSubmit(M));var f=Object.assign(g,{formProps:i});return(0,x.jsx)(r.Op,Object.assign({},f,{children:(0,x.jsx)(b,Object.assign({className:m},d,{children:y}))}))};n.displayName="Form"},"./node_modules/.pnpm/@elliemae+ds-form-helpers-mask-hooks@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-form-helpers-mask-hooks/dist/esm/hooks/useNumberMask.js":(W,k,e)=>{e.d(k,{XF:()=>X});var a=e("./node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),r=e("./node_modules/.pnpm/@elliemae+ds-props-helpers@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-props-helpers/dist/esm/defaultProps/useMemoMergePropsWithDefault.js"),x=e("./node_modules/.pnpm/@elliemae+ds-props-helpers@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-props-helpers/dist/esm/validation/typescriptValidator.js"),b=e("./node_modules/.pnpm/@elliemae+ds-props-helpers@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-props-helpers/dist/esm/propTypes/describe.js"),n=e("./node_modules/.pnpm/@elliemae+ds-props-helpers@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-props-helpers/dist/esm/propTypes/PropTypes.js");const c=(_=!1)=>{const p=(0,a.useRef)(null);return(0,a.useMemo)(()=>_?a.useLayoutEffect:a.useEffect,[_])(()=>{p.current?.(),p.current=null}),S=>{p.current=S}},m=(_,p)=>{_.setSelectionRange(p,p,"forward")},u={onChange:()=>null,onKeyDown:()=>null,onBlur:()=>null},i={valueSetter:n.A.func.description("React set state function for the value").isRequired,onChange:n.A.func.description("Callback for onChange"),onKeyDown:n.A.func.description("Callback for onKeyDown")},y={...u,suffix:"",prefix:"",decimalPlaces:2,allowNegative:!1,includeThousandsSeparator:!0,decimalRequired:!1},M={...i,suffix:n.A.string.description("String will be added at the end of the input value").defaultValue(""),prefix:n.A.string.description("String will be added at the start of the input value").defaultValue(""),decimalPlaces:n.A.number.description("Number of decimals allowed").defaultValue(2),allowNegative:n.A.bool.description("Wether the input allows negative number").defaultValue(!1),includeThousandsSeparator:n.A.bool.description("Wether the integer part will be separated by thousands").defaultValue(!0),decimalRequired:n.A.bool.description("Wether decimal part is mandatory").defaultValue(!1),max:n.A.number.description("Maximum value allowed"),min:n.A.number.description("Minimum value allowed")},g={...u,isInternational:!1},d={...i,isInternational:n.A.bool.description("Use or not internaltional phone mask number").defaultValue(!1)},f={...u,filledMask:!1},P={...i,regExp:n.A.arrayOf(n.A.oneOfType([n.A.string,n.A.instanceOf(RegExp)])).description("Array with regexp or special chars per character").isRequired,filledMask:n.A.bool.description("Show blank chars positions").defaultValue(!1)},v={onChange:()=>null,onKeyDown:()=>null,onBlur:()=>null},C={...v,isInternational:!1},L={...v,filledMask:!1,regExp:[]},Z={...v},H={...v,suffix:"",prefix:"",decimalPlaces:2,allowNegative:!1,includeThousandsSeparator:!0,decimalRequired:!1},R={valueSetter:n.A.func.description("React set state function for the value").isRequired,onChange:n.A.func.description("Callback for onChange"),onKeyDown:n.A.func.description("Callback for onKeyDown")},q={...R,regExp:n.A.arrayOf(n.A.oneOfType([n.A.string,n.A.instanceOf(RegExp)])).description("Array with regexp or special chars per character").isRequired,filledMask:n.A.bool.description("Show blank chars positions").defaultValue(!1)},Q={...R,isInternational:n.A.bool.description("Use or not internaltional phone mask number").defaultValue(!1)},ee={...R,suffix:n.A.string.description("String will be added at the end of the input value").defaultValue(""),prefix:n.A.string.description("String will be added at the start of the input value").defaultValue(""),decimalPlaces:n.A.number.description("Number of decimals allowed").defaultValue(2),allowNegative:n.A.bool.description("Wether the input allows negative number").defaultValue(!1),includeThousandsSeparator:n.A.bool.description("Wether the integer part will be separated by thousands").defaultValue(!0),decimalRequired:n.A.bool.description("Wether decimal part is mandatory").defaultValue(!1)},w="useNumberMask",Y="usePhoneMask",ne="useRegExpMask",te="useSSNMask",K="useZipCodeMask",V=(_,p)=>_.replace(/\B(?=(\d{3})+(?!\d))/g,p),U=(_,p,h,S)=>{const{includeThousandsSeparator:F=!0,allowNegative:N=!1,prefix:s="",suffix:$="",decimalPlaces:E=2,decimalRequired:z=!1}=S,G=",";let D=-1,j=[s?.length,0].includes(_.indexOf("-"))&&N?"-":"",t=String(_).split("").filter((T,J)=>{const A=T>="0"&&T<="9"||T==="."&&D===-1&&E;return T==="."&&A&&(D=J),A});for(s&&t.length&&(j+=s);t.length>=2&&t[0]==="0"&&t[1]!==".";)t=t.splice(1);D=t.findIndex(T=>T===".");let o=t.slice(0,D!==-1?D:t.length);const I=t.slice(D,D+E+1);F&&(o=V(o.join(""),G).split(""));let O=!1;D!==-1&&!(h==="Backspace"&&I.length===1)?o.length?t=[...o,...I]:(t=["0",...I],O=!0):t=z&&o.length?[...o,"."]:o,h==="Backspace"&&t.length===0&&(j="");let l=0;t[l]==="0"&&p===1+s.length&&(l+=1),O&&(l+=1);for(let T=0;T<p;T+=1)t[l]===G&&(l+=1),t[l]===_[T]&&(l+=1);l+=j.length;const B=t.length?$:"";return[j+t.join("")+B,l]},X=_=>{const p=(0,r.b)(_,y);(0,x.D)(p,M,w);const{valueSetter:h,onChange:S,onKeyDown:F,onBlur:N,...s}=p,$=(0,a.useRef)("Unidentified"),E=c(!0),[,z]=(0,a.useState)(0),G=(0,a.useCallback)(t=>{const o=t.target.value,{decimalRequired:I=!0,decimalPlaces:O=2,suffix:l=""}=s,B=o.indexOf("."),se=o.indexOf("-"),T=l.length?o.indexOf(l):-1;if(I){if(B>-1){const J=o.slice(B+1,l.length?-l.length:o.length);let A="";for(;J.length+A.length!==O;)A+="0";h((l.length?o.slice(0,T):o)+A+l)}}else o.length-l.length-1===B?h(o.replace(".","")):o.length-1===se&&h(o.replace("-",""));N&&N(t)},[N,h,s]),D=(0,a.useCallback)(t=>{$.current=t.code,F&&F(t)},[F]),j=(0,a.useCallback)(t=>{const[o,I]=U(t.target.value,t.target.selectionEnd??0,$.current,s),O=Number(o.replace(s.prefix,"").replace(s.suffix,"").replace(/,/g,""));if(s.min!==void 0&&O<s.min){h(`${s.prefix}${s.min}${s.suffix}`),E(()=>m(t.target,I));return}if(s.max!==void 0&&O>s.max){h(`${s.prefix}${s.max}${s.suffix}`),E(()=>m(t.target,I));return}h(l=>(o===l&&z(B=>B+1),o)),S&&S(t,o),E(()=>m(t.target,I))},[h,E,S,s]);return{onKeyDown:D,onChange:j,onBlur:G}},re=(_,p)=>{const[h]=U(_,_.length-1,"",p);return h};X.displayName=w;const oe=(0,b.A)(X);oe.propTypes=M,oe.returnType={onKeyDown:n.A.func.description("On key down event for input").isRequired,onChange:n.A.func.description("On change event for input").isRequired,onBlur:n.A.func.description("On blur event for input").isRequired}}}]);
