((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).autosize=t()})(this,function(){var a=new Map;function o(n){var i,l,e,t,o;function s(e){var t,o=e.restoreTextAlign,o=void 0===o?null:o,e=e.testForHeightReduction,e=void 0===e||e,r=l.overflowY;0===n.scrollHeight||("vertical"===l.resize?n.style.resize="none":"both"===l.resize&&(n.style.resize="horizontal"),e&&(t=(e=>{for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push([e.parentNode,e.parentNode.scrollTop]),e=e.parentNode;return function(){return t.forEach(function(e){var t=e[0],e=e[1];t.style.scrollBehavior="auto",t.scrollTop=e,t.style.scrollBehavior=null})}})(n),n.style.height=""),e="content-box"===l.boxSizing?n.scrollHeight-(parseFloat(l.paddingTop)+parseFloat(l.paddingBottom)):n.scrollHeight+parseFloat(l.borderTopWidth)+parseFloat(l.borderBottomWidth),"none"!==l.maxHeight&&e>parseFloat(l.maxHeight)?("hidden"===l.overflowY&&(n.style.overflow="scroll"),e=parseFloat(l.maxHeight)):"hidden"!==l.overflowY&&(n.style.overflow="hidden"),n.style.height=e+"px",o&&(n.style.textAlign=o),t&&t(),i!==e&&(n.dispatchEvent(new Event("autosize:resized",{bubbles:!0})),i=e),r===l.overflow)||o||(t=l.textAlign,"hidden"===l.overflow&&(n.style.textAlign="start"===t?"end":"start"),s({restoreTextAlign:t,testForHeightReduction:!0}))}function r(){s({testForHeightReduction:!0,restoreTextAlign:null})}n&&n.nodeName&&"TEXTAREA"===n.nodeName&&!a.has(n)&&(i=null,l=window.getComputedStyle(n),t=n.value,e=function(){s({testForHeightReduction:""===t||!n.value.startsWith(t),restoreTextAlign:null}),t=n.value},o=function(t){n.removeEventListener("autosize:destroy",o),n.removeEventListener("autosize:update",r),n.removeEventListener("input",e),window.removeEventListener("resize",r),Object.keys(t).forEach(function(e){return n.style[e]=t[e]}),a.delete(n)}.bind(n,{height:n.style.height,resize:n.style.resize,textAlign:n.style.textAlign,overflowY:n.style.overflowY,overflowX:n.style.overflowX,wordWrap:n.style.wordWrap}),n.addEventListener("autosize:destroy",o),n.addEventListener("autosize:update",r),n.addEventListener("input",e),window.addEventListener("resize",r),n.style.overflowX="hidden",n.style.wordWrap="break-word",a.set(n,{destroy:o,update:r}),r())}function t(e){e=a.get(e);e&&e.destroy()}function r(e){e=a.get(e);e&&e.update()}var e=null;return"undefined"==typeof window?((e=function(e){return e}).destroy=function(e){return e},e.update=function(e){return e}):((e=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],t),e},e.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],r),e}),e}),(()=>{var e=document.querySelectorAll("textarea:not(.code)");e.length&&autosize(e)})();