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AQ,UAAY,KAAK,QAAQ,MAAM,UAAU,EAAG,GAG3B,UAA1B,KAAK,QAAQ,WACf,KAAK,QAAQ,UAAY,KAAK,QAAQ,UAAU,QAAQ,MAAO,MAEjE,KAAK,SAAS,UAAY,KAAK,QAAQ,MAAM,UAAU,IAAkB,IACzE,IAAI,EAAQ,KAAK,KAAK,WAAa,SAAS,KAAK,SAA0B,gBAAG,IAa9E,OAVI,GAAS,IACX,EAAQ,KAAK,IAAI,YAAc,SAAS,KAAK,SAA0B,gBAAG,KAG1D,CAChB,IAAK,KAAK,KAAK,UAAY,SAAS,KAAK,SAAyB,eAAG,IACrE,KAAM,EACN,MAAO,EAIX,EAEA,OAAO,QAAU","file":"/npm/textarea-caret-position@0.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/textarea-caret-position@0.1.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* jshint browser: true */\n\n// The properties that we copy into a mirrored div.\n// Note that some browsers, such as Firefox,\n// do not concatenate properties, i.e. padding-top, bottom etc. -> padding,\n// so we have to do every single property specifically.\nvar properties = [\n  'direction',  // RTL support\n  'boxSizing',\n  'width',  // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does\n  'height',\n  'overflowX',\n  'overflowY',  // copy the scrollbar for IE\n\n  'borderTopWidth',\n  'borderRightWidth',\n  'borderBottomWidth',\n  'borderLeftWidth',\n\n  'paddingTop',\n  'paddingRight',\n  'paddingBottom',\n  'paddingLeft',\n\n  // https://developer.mozilla.org/en-US/docs/Web/CSS/font\n  'fontStyle',\n  'fontVariant',\n  'fontWeight',\n  'fontStretch',\n  'fontSize',\n  'fontSizeAdjust',\n  'lineHeight',\n  'fontFamily',\n\n  'textAlign',\n  'textTransform',\n  'textIndent',\n  'textDecoration',  // might not make a difference, but better be safe\n\n  'letterSpacing',\n  'wordSpacing'\n];\n\nfunction CaretCoordinates(element) {\n  var self = this;\n\n  this.element = element;\n\n  // mirrored div\n  this.div = document.createElement('div');\n  // this.div.id = 'input-textarea-caret-position-mirror-div';\n  element.parentNode.insertBefore(this.div, element);\n\n  var style = this.div.style;\n  this.computed = window.getComputedStyle? getComputedStyle(element) : element.currentStyle;  // currentStyle for IE < 9\n\n  // default textarea styles\n  style.whiteSpace = 'pre-wrap';\n  if (element.nodeName !== 'INPUT')\n    style.wordWrap = 'break-word';  // only for textarea-s\n\n  // position off-screen\n  style.position = 'absolute';  // required to return coordinates properly\n  style.visibility = 'hidden';  // not 'display: none' because we want rendering\n\n  // transfer the element's properties to the div\n  properties.forEach(function (prop) {\n    style[prop] = self.computed[prop];\n  });\n\n  style.overflow = 'hidden';  // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'\n\n  this.divText = document.createTextNode('');\n  this.div.appendChild(this.divText);\n  this.span = document.createElement('span');\n  this.spanText = document.createTextNode('');\n  this.span.appendChild(this.spanText);\n  this.div.appendChild(this.span);\n\n  function resize() {\n    style.width = self.computed.width;\n  }\n\n  window.addEventListener('resize', resize);\n}\n\n\nCaretCoordinates.prototype.get = function(positionLeft, positionRight) {\n  // calculate left offset\n  this.divText.nodeValue = this.element.value.substring(0, positionLeft);\n\n  // the second special handling for input type=\"text\" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037\n  if (this.element.nodeName === 'INPUT')\n    this.divText.nodeValue = this.divText.nodeValue.replace(/\\s/g, \"\\u00a0\");\n\n  // Wrapping must be replicated *exactly*, including when a long word gets\n  // onto the next line, with whitespace at the end of the line before (#7).\n  // The  *only* reliable way to do that is to copy the *entire* rest of the\n  // textarea's content into the <span> created at the caret position.\n  // for inputs, just '.' would be enough, but why bother?\n  this.spanText.nodeValue = this.element.value.substring(positionLeft) || '.';  // || because a completely empty faux span doesn't render at all\n\n  var left = this.span.offsetLeft + parseInt(this.computed['borderLeftWidth'], 10);\n\n  // calculate right offset\n  this.divText.nodeValue = this.element.value.substring(0, positionRight);\n\n  // the second special handling for input type=\"text\" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037\n  if (this.element.nodeName === 'INPUT')\n    this.divText.nodeValue = this.divText.nodeValue.replace(/\\s/g, \"\\u00a0\");\n\n  this.spanText.nodeValue = this.element.value.substring(positionRight) || '.';  // || because a completely empty faux span doesn't render at all\n  var right = this.span.offsetLeft + parseInt(this.computed['borderLeftWidth'], 10);\n\n  // special case where right position is not be calculated correctly (full line selected)\n  if (right <= left) {\n    right = this.div.offsetWidth + parseInt(this.computed['borderLeftWidth'], 10);\n  }\n\n  var coordinates = {\n    top: this.span.offsetTop + parseInt(this.computed['borderTopWidth'], 10),\n    left: left,\n    right: right\n  };\n\n  return coordinates;\n};\n\nmodule.exports = CaretCoordinates;\n\n"]}