/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/react-input-verification-code@1.0.2/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=require("react"),styled=require("styled-components"),styled__default=_interopDefault(styled);function _taggedTemplateLiteralLoose(e,t){return t||(t=e.slice(0)),e.raw=t,e}function _templateObject4(){var e=_taggedTemplateLiteralLoose(["\n  width: var(--ReactInputVerificationCode-itemWidth);\n  height: var(--ReactInputVerificationCode-itemHeight);\n  padding: 0;\n  border-radius: 4px;\n  font-size: 1.5rem;\n  font-weight: 800;\n  line-height: var(--ReactInputVerificationCode-itemHeight);\n  text-align: center;\n  border: 0;\n  box-shadow: inset 0 0 0 1px #ccc;\n  transition: box-shadow 0.2s ease-out;\n\n  &.is-active {\n    box-shadow: inset 0 0 0 2px #888;\n  }\n"]);return _templateObject4=function(){return e},e}function _templateObject3(){var e=_taggedTemplateLiteralLoose(["\n  position: absolute;\n  top: 0;\n  left: ",";\n  opacity: 0;\n  width: var(--ReactInputVerificationCode-itemWidth);\n  height: var(--ReactInputVerificationCode-itemHeight);\n"]);return _templateObject3=function(){return e},e}function _templateObject2(){var e=_taggedTemplateLiteralLoose(["\n  display: flex;\n  position: relative;\n  justify-content: space-between;\n  width: ",";\n"]);return _templateObject2=function(){return e},e}function _templateObject(){var e=_taggedTemplateLiteralLoose(["\n  :root {\n    --ReactInputVerificationCode-itemWidth: 4.5rem;\n    --ReactInputVerificationCode-itemHeight: 5rem;\n    --ReactInputVerificationCode-itemSpacing: 1rem;\n  }\n"]);return _templateObject=function(){return e},e}var GlobalStyle=styled.createGlobalStyle(_templateObject()),Container=styled__default.div(_templateObject2(),(function(e){var t=e.itemsCount;return"calc(\n      var(--ReactInputVerificationCode-itemWidth) * "+t+"\n      + var(--ReactInputVerificationCode-itemSpacing) * ("+t+" - 1)\n    )"})),Input=styled__default.input(_templateObject3(),(function(e){var t=e.activeIndex;return"calc(\n      var(--ReactInputVerificationCode-itemWidth) * "+t+"\n      + var(--ReactInputVerificationCode-itemSpacing) * "+t+"\n    )"})),Item=styled__default.div(_templateObject4()),KEY_CODE={BACKSPACE:8,ARROW_LEFT:37,ARROW_RIGHT:39,DELETE:46},ReactInputVerificationCode=function(e){var t=e.autoFocus,n=void 0!==t&&t,i=e.length,a=void 0===i?4:i,o=e.onChange,r=void 0===o?function(){}:o,c=e.onCompleted,u=void 0===c?function(){}:c,l=e.placeholder,d=void 0===l?"·":l,f=e.value,p=e.dataCy,s=void 0===p?"verification-code":p,v=e.type,m=void 0===v?"text":v,R=e.passwordMask,_=void 0===R?"•":R,C=new Array(a).fill(d),g=React.useState(-1),b=g[0],h=g[1],y=React.useState(f?f.split(""):C),E=y[0],I=y[1],j=React.createRef(),O=React.useMemo((function(){return new Array(a).fill(null).map((function(){return React.createRef()}))}),[a]),V=new RegExp("^[0-9]{"+a+"}$"),x=function(e){var t;return null===(t=O[e])||void 0===t?void 0:t.current},L=function(e){var t;return null===(t=x(e))||void 0===t?void 0:t.focus()},w=function(e){var t;return null===(t=x(e))||void 0===t?void 0:t.blur()};React.useEffect((function(){n&&O[0].current&&O[0].current.focus()}),[]),React.useEffect((function(){var e=j.current;if(e){var t=function(e){var t;e.preventDefault();var n=null===(t=e.clipboardData)||void 0===t?void 0:t.getData("text");n&&(/^\d+$/.test(n)&&I(n.split("").slice(0,a)))};return e.addEventListener("paste",t),function(){return e.removeEventListener("paste",t)}}}),[]),React.useEffect((function(){var e=E.join("");e.length===a&&e!==C.join("")&&u(e),r(e)}),[E,a]),React.useEffect((function(){"string"==typeof f&&(""===f&&E.join("")===C.join("")||f!==E.join("")&&I(f.split("")))}),[f]);return React.createElement(React.Fragment,null,React.createElement(GlobalStyle,null),React.createElement(Container,{className:"ReactInputVerificationCode__container",itemsCount:a},React.createElement(Input,{ref:j,className:"ReactInputVerificationCode__input",autoComplete:"one-time-code",type:"text",inputMode:"decimal",id:"one-time-code",onChange:function(e){var t=e.target.value;V.test(t)&&(I(t.split("")),w(b))},onKeyUp:function(e){var t=e.key,n=e.keyCode,i=[].concat(E),o=b+1,r=b-1,c=j.current,u=x(b),l=o===a;if(n===KEY_CODE.DELETE||n===KEY_CODE.BACKSPACE)return i[b]=d,I(i),void(b>0&&(h(r),L(r)));if(!Number.isNaN(+t)){if(c&&(c.value=""),i[b]=t,I(i),!l)return h(o),void L(o);c&&c.blur(),u&&u.blur(),h(-1)}},onBlur:function(){-1!==b&&(w(b),h(-1))},activeIndex:b,"data-cy":s+"-otc-input"}),O.map((function(e,t){return React.createElement(Item,{key:t,ref:e,role:"button",tabIndex:0,className:"ReactInputVerificationCode__item "+(E[t]!==d?"is-filled":"")+" "+(t===b?"is-active":""),onFocus:(i=t,function(){h(i),j.current&&j.current.focus()}),"data-cy":s+"-"+t+"-item"},(n=E[t])===d?d:"password"===m?_:n);var n,i}))))};module.exports=ReactInputVerificationCode;
//# sourceMappingURL=/sm/126d2c274af6b0d500748408b6c2d151307cef03db25cc6912327fdee9c96280.map