var __awaiter=this&&this.__awaiter||function(e,t,n,o){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function a(e){try{s(o.next(e))}catch(e){r(e)}}function c(e){try{s(o["throw"](e))}catch(e){r(e)}}function s(e){e.done?n(e.value):i(e.value).then(a,c)}s((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(e){return function(t){return s([e,t])}}function s(a){if(o)throw new TypeError("Generator is already executing.");while(n)try{if(o=1,i&&(r=a[0]&2?i["return"]:a[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;if(i=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];i=0}finally{o=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-5e377a26.system.js"],(function(e){"use strict";var t,n,o,i;return{setters:[function(e){t=e.r;n=e.c;o=e.h;i=e.H}],execute:function(){var r="dvn-rich-editor-heading-block{display:block;-ms-flex:1;flex:1}dvn-rich-editor-heading-block h1{font-size:2rem;margin:0;display:block}dvn-rich-editor-heading-block h2{font-size:1.6rem;margin:0;display:block}dvn-rich-editor-heading-block h3{font-size:1.2rem;margin:0;display:block}";var a=e("dvn_rich_editor_heading_block",function(){function e(e){var o=this;t(this,e);this.change=n(this,"change",7);this.enterKeyDown=n(this,"enterKeyDown",7);this.lastBackspaceKeyDown=n(this,"lastBackspaceKeyDown",7);this.arrowDown=n(this,"arrowDown",7);this.arrowUp=n(this,"arrowUp",7);this.isContentCleared=false;this.lastCursorPosition=0;this.retainPosition=function(e){o.lastCursorPosition=s(e.target)}}e.prototype.componentShouldUpdate=function(e){return this.input.innerHTML!==e.text};e.prototype.focusOnInput=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.input.focus();c(this.input,this.lastCursorPosition);return[2]}))}))};e.prototype.render=function(){var e=this;var t=this.type||"h1";return o(i,null,o(t,{ref:function(t){return e.input=t},id:"".concat(t,"-").concat(this.id),key:"".concat(t,"-").concat(this.id),contenteditable:true,onInput:function(t){e.retainPosition(t);var n=t.target.innerHTML;e.change.emit({id:e.id,value:{text:n}});if(n.length===0){setTimeout((function(){return e.isContentCleared=true}),100)}},onKeyDown:function(t){if(t.key==="Enter"){t.preventDefault();e.enterKeyDown.emit(t)}else if(t.key==="Backspace"&&e.isContentCleared){e.lastBackspaceKeyDown.emit(t)}else if(t.key==="ArrowDown"){if(e.value.text.length===window.getSelection().getRangeAt(0).endOffset){e.arrowDown.emit(t)}}else if(t.key==="ArrowUp"){if(window.getSelection().getRangeAt(0).endOffset===0){e.arrowUp.emit(t)}}}},this.value.text))};return e}());function c(e,t){e.focus();if(typeof window.getSelection!="undefined"&&typeof document.createRange!="undefined"){var n=document.createRange();n.selectNodeContents(e);if(t!==0){n.setStart(e.childNodes[0],t)}n.collapse(true);var o=window.getSelection();o.removeAllRanges();o.addRange(n)}else if(typeof document.body.createTextRange!="undefined"){var i=document.body.createTextRange();i.moveToElementText(e);i.collapse(false);i.select()}}function s(e){var t=0;var n=e.ownerDocument||e.document;var o=n.defaultView||n.parentWindow;var i;if(typeof o.getSelection!="undefined"){i=o.getSelection();if(i.rangeCount>0){var r=o.getSelection().getRangeAt(0);var a=r.cloneRange();a.selectNodeContents(e);a.setEnd(r.endContainer,r.endOffset);t=a.toString().length}}else if((i=n.selection)&&i.type!="Control"){var c=i.createRange();var s=n.body.createTextRange();s.moveToElementText(e);s.setEndPoint("EndToEnd",c);t=s.text.length}return t}a.style=r}}}));