{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.calculateNewValue = calculateNewValue;\nvar _selectionRange = require(\"./selectionRange\");\nvar _getValue2 = require(\"./getValue\");\nvar _isValidDateValue = require(\"./isValidDateValue\");\nvar _isValidInputTimeValue = require(\"./isValidInputTimeValue\");\nfunction calculateNewValue(newEntry, element, value = (() => {\n  var _getValue;\n  return (_getValue = (0, _getValue2.getValue)(element)) != null ? _getValue : /* istanbul ignore next */\n  '';\n})(), selectionRange = (0, _selectionRange.getSelectionRange)(element), deleteContent) {\n  const selectionStart = selectionRange.selectionStart === null ? value.length : selectionRange.selectionStart;\n  const selectionEnd = selectionRange.selectionEnd === null ? value.length : selectionRange.selectionEnd;\n  const prologEnd = Math.max(0, selectionStart === selectionEnd && deleteContent === 'backward' ? selectionStart - 1 : selectionStart);\n  const prolog = value.substring(0, prologEnd);\n  const epilogStart = Math.min(value.length, selectionStart === selectionEnd && deleteContent === 'forward' ? selectionEnd + 1 : selectionEnd);\n  const epilog = value.substring(epilogStart, value.length);\n  let newValue = `${prolog}${newEntry}${epilog}`;\n  const newSelectionStart = prologEnd + newEntry.length;\n  if (element.type === 'date' && !(0, _isValidDateValue.isValidDateValue)(element, newValue)) {\n    newValue = value;\n  }\n  if (element.type === 'time' && !(0, _isValidInputTimeValue.isValidInputTimeValue)(element, newValue)) {\n    if ((0, _isValidInputTimeValue.isValidInputTimeValue)(element, newEntry)) {\n      newValue = newEntry;\n    } else {\n      newValue = value;\n    }\n  }\n  return {\n    newValue,\n    newSelectionStart\n  };\n}","map":{"version":3,"names":["Object","defineProperty","exports","value","calculateNewValue","_selectionRange","require","_getValue2","_isValidDateValue","_isValidInputTimeValue","newEntry","element","_getValue","getValue","selectionRange","getSelectionRange","deleteContent","selectionStart","length","selectionEnd","prologEnd","Math","max","prolog","substring","epilogStart","min","epilog","newValue","newSelectionStart","type","isValidDateValue","isValidInputTimeValue"],"sources":["C:/Users/user/Desktop/000newport/node_modules/@testing-library/user-event/dist/utils/edit/calculateNewValue.js"],"sourcesContent":["\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.calculateNewValue = calculateNewValue;\n\nvar _selectionRange = require(\"./selectionRange\");\n\nvar _getValue2 = require(\"./getValue\");\n\nvar _isValidDateValue = require(\"./isValidDateValue\");\n\nvar _isValidInputTimeValue = require(\"./isValidInputTimeValue\");\n\nfunction calculateNewValue(newEntry, element, value = (() => {\n  var _getValue;\n\n  return (_getValue = (0, _getValue2.getValue)(element)) != null ? _getValue :\n  /* istanbul ignore next */\n  '';\n})(), selectionRange = (0, _selectionRange.getSelectionRange)(element), deleteContent) {\n  const selectionStart = selectionRange.selectionStart === null ? value.length : selectionRange.selectionStart;\n  const selectionEnd = selectionRange.selectionEnd === null ? value.length : selectionRange.selectionEnd;\n  const prologEnd = Math.max(0, selectionStart === selectionEnd && deleteContent === 'backward' ? selectionStart - 1 : selectionStart);\n  const prolog = value.substring(0, prologEnd);\n  const epilogStart = Math.min(value.length, selectionStart === selectionEnd && deleteContent === 'forward' ? selectionEnd + 1 : selectionEnd);\n  const epilog = value.substring(epilogStart, value.length);\n  let newValue = `${prolog}${newEntry}${epilog}`;\n  const newSelectionStart = prologEnd + newEntry.length;\n\n  if (element.type === 'date' && !(0, _isValidDateValue.isValidDateValue)(element, newValue)) {\n    newValue = value;\n  }\n\n  if (element.type === 'time' && !(0, _isValidInputTimeValue.isValidInputTimeValue)(element, newValue)) {\n    if ((0, _isValidInputTimeValue.isValidInputTimeValue)(element, newEntry)) {\n      newValue = newEntry;\n    } else {\n      newValue = value;\n    }\n  }\n\n  return {\n    newValue,\n    newSelectionStart\n  };\n}"],"mappings":"AAAA,YAAY;;AAEZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAC3CC,KAAK,EAAE;AACT,CAAC,CAAC;AACFD,OAAO,CAACE,iBAAiB,GAAGA,iBAAiB;AAE7C,IAAIC,eAAe,GA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