From 25f65bbc252a4b68926a3616f76c7f7b8ffffa49 Mon Sep 17 00:00:00 2001 From: JiHong88 <0125ses@hanmail.net> Date: Wed, 12 Dec 2018 15:51:30 +0900 Subject: [PATCH] version up: 2.9.2 --- bower.json | 2 +- dist/suneditor.min.js | 2 +- package-lock.json | 10 +++------- package.json | 2 +- sample/build/suneditor.customize.js | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/bower.json b/bower.json index 722018bad..83a3da704 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "suneditor", - "version": "2.9.1", + "version": "2.9.2", "description": "Pure JavaScript based WYSIWYG web editor", "main": "src/suneditor.js", "keywords": [ diff --git a/dist/suneditor.min.js b/dist/suneditor.min.js index 8391a6d5b..0f19f958c 100644 --- a/dist/suneditor.min.js +++ b/dist/suneditor.min.js @@ -1 +1 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s="XJR1")}({"0A7J":function(module,__webpack_exports__,__webpack_require__){"use strict";var _lib_util__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("8e1d"),_modules_colorPicker__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("EjF6");__webpack_exports__.a={name:"fontColor",add:function(core,targetElement){core.addModule([_modules_colorPicker__WEBPACK_IMPORTED_MODULE_1__.a]);const context=core.context;context.fontColor={previewEl:null,colorInput:null};let listDiv=eval(this.setSubmenu(context.colorPicker.colorListHTML));context.fontColor.colorInput=listDiv.getElementsByClassName("sun-editor-id-submenu-color-input")[0],context.fontColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(core)),listDiv.getElementsByClassName("sun-editor-id-submenu-color-submit")[0].addEventListener("click",this.submit.bind(core)),listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickup.bind(core)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");return t.className="layer_editor",t.style.display="none",t.innerHTML=e,t},on:function(){const e=this.context.colorPicker;e._colorInput=this.context.fontColor.colorInput,e._defaultColor="#000000",e._styleProperty="color",this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,"#"+e.target.value)},submit:function(){this.plugins.fontColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){if(e.preventDefault(),e.stopPropagation(),!/^BUTTON$/i.test(e.target.tagName))return!1;this.plugins.fontColor.applyColor.call(this,e.target.getAttribute("data-value"))},applyColor:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("SPAN");t.style.color=e,this.nodeChange(t,["color"]),this.submenuOff(),this.focus()}}},"1kvd":function(e,t,i){"use strict";var n=i("8e1d");t.a={name:"dialog",add:function(e){const t=e.context;t.dialog={};let i=n.a.createElement("DIV");i.className="sun-editor-id-dialogBox sun-editor-common";let o=n.a.createElement("DIV");o.className="modal-dialog-background sun-editor-id-dialog-back",o.style.display="none";let l=n.a.createElement("DIV");l.className="modal-dialog sun-editor-id-dialog-modal",l.style.display="none",i.appendChild(o),i.appendChild(l),t.dialog.modalArea=i,t.dialog.back=o,t.dialog.modal=l,t.dialog.modal.addEventListener("click",this.onClick_dialog.bind(e)),t.element.relative.appendChild(i),i=null,o=null,l=null},onClick_dialog:function(e){e.stopPropagation(),(/modal-dialog/.test(e.target.className)||/close/.test(e.target.getAttribute("data-command")))&&this.plugins.dialog.close.call(this)},open:function(e,t){if(this.modalForm)return!1;this.context.dialog.updateModal=t,"full"===this.context.option.popupDisplay?this.context.dialog.modalArea.style.position="fixed":this.context.dialog.modalArea.style.position="absolute",this.context.dialog.kind=e,this.modalForm=this.context[e].modal;const i=this.context[e].focusElement;this.context.dialog.modalArea.style.display="block",this.context.dialog.back.style.display="block",this.context.dialog.modal.style.display="block",this.modalForm.style.display="block",i&&i.focus()},close:function(){this.modalForm.style.display="none",this.context.dialog.back.style.display="none",this.context.dialog.modalArea.style.display="none",this.modalForm=null,this.context.dialog.updateModal=!1,this.plugins[this.context.dialog.kind].init.call(this)}}},"3FqI":function(e,t,i){},"50IV":function(module,__webpack_exports__,__webpack_require__){"use strict";var _lib_util__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("8e1d");__webpack_exports__.a={name:"font",add:function(core,targetElement){let listDiv=eval(this.setSubmenu(core.context.option));listDiv.getElementsByClassName("list_family")[0].addEventListener("click",this.pickup.bind(core)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");let i,n,o,l;t.className="layer_editor",t.style.display="none";let a=e.font?e.font:["Arial","Comic Sans MS","Courier New,Courier","Impact,Charcoal,sans-serif","Georgia","tahoma","Trebuchet MS,Helvetica","Verdana"],s='
",s+="
",t.innerHTML=s,t},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=e.target;_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.changeTxt(this.context.tool.font,t.getAttribute("data-txt"));const i=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("SPAN");i.style.fontFamily=t.getAttribute("data-value"),this.nodeChange(i,["font-family"]),this.submenuOff(),this.focus()}}},"8e1d":function(e,t,i){"use strict";const n={_d:document,_w:window,zeroWidthSpace:"​",getXMLHttpRequest:function(){if(!this._w.ActiveXObject)return this._w.XMLHttpRequest?new XMLHttpRequest:null;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){return null}}},copyObj:function(e){const t={};for(let i in e)t[i]=e[i];return t},createElement:function(e){return this._d.createElement(e)},createTextNode:function(e){return this._d.createTextNode(e||"")},getIncludePath:function(e,t){let i="";const n=[],o="js"===t?"script":"link",l="js"===t?"src":"href";let a="(?:";for(let t=0,i=e.length;t0?n[0][l]:""),-1===i.indexOf(":/")&&"//"!==i.slice(0,2)&&(i=0===i.indexOf("/")?location.href.match(/^.*?:\/\/[^\/]*/)[0]+i:location.href.match(/^[^\?]*\/(?:)/)[0]+i),!i)throw"[SUNEDITOR.util.getIncludePath.fail] The SUNEDITOR installation path could not be automatically detected. (name: +"+name+", extension: "+t+")";return i},convertContentsForEditor:function(e){let t,i,n="";e=e.trim();for(let o=0,l=(t=this._d.createRange().createContextualFragment(e).childNodes).length;o0&&(n+="

"+t+"

")}else n+=i;const o={"&":"&"," ":" ","'":""","<":"<",">":">"};return e=e.replace(/&|\u00A0|'|<|>/g,function(e){return"string"==typeof o[e]?o[e]:e}),0===n.length&&(n="

"+(e.length>0?e:this.zeroWidthSpace)+"

"),n},convertHTMLForCodeView:function(e){return e.replace(/\s*<(?:li|td)\s*(?:[a-z\-]+)?\s*(?:="?[^>]*"?)?\s*>/gi,this._insertIndent).replace(/<\/?(?:blockquote|hr|ol|ul|table|tbody|thead|th|tr)\s*(?:[a-z\-]+)?\s*(?:="?[^>]*"?)?\s*>(?=[^\n])/gi,this._insertLineBreak).replace(/<\/(?:p|div|h[1-6]|li|td|pre)>(?=[^\n])/gi,this._insertLineBreak)},_insertIndent:function(e){return" "+e.trim()},_insertLineBreak:function(e){return e+"\n"},isWysiwygDiv:function(e){return!(!e||1!==e.nodeType||!this.hasClass(e,"sun-editor-id-wysiwyg"))},isFormatElement:function(e){return!(!e||1!==e.nodeType||!/^(?:P|DIV|H[1-6]|LI|CODE)$/i.test(e.nodeName)||/sun-editor-id-comp/.test(e.className))},isRangeFormatElement:function(e){return!(!e||1!==e.nodeType||!/^(?:BLOCKQUOTE|TABLE|THEAD|TBODY|TH|TR|TD|OL|UL|PRE|FIGCAPTION)$/i.test(e.nodeName))},getFormatElement:function(e){if(!e)return null;for(;!this.isFormatElement(e)&&!this.isWysiwygDiv(e.parentNode);)e=e.parentNode;if(this.isWysiwygDiv(e)||this.isRangeFormatElement(e)){return this.getListChildren(e,function(e){return this.isFormatElement(e)}.bind(this))[0]}return e},getRangeFormatElement:function(e){if(!e)return null;for(;!this.isRangeFormatElement(e)&&!this.isWysiwygDiv(e);)e=e.parentNode;return this.isWysiwygDiv(e)?null:e},getArrayIndex:function(e,t){let i=-1;for(let n=0,o=e.length;n]*"?)?\s*/gi,"").replace(/<\/?(?:span|font)\s*(?:[a-z\-]+)?\s*(?:="?[^>]*"?)?\s*>/gi,"").replace(/<\/?[a-z]+:[a-z]+\s*(?:[a-z\-]+)?\s*(?:="?[^>]*"?)?\s*>/gi,""):n+=i[e].textContent;return n||e}};t.a=n},EjF6:function(e,t,i){"use strict";var n=i("8e1d");t.a={name:"colorPicker",add:function(e){const t=e.context;t.colorPicker={colorListHTML:"",_colorInput:"",_defaultColor:"#000",_styleProperty:"color",_currentColor:""};let i=this.createColorList(e.context.option,e.lang);t.colorPicker.colorListHTML=i,i=null},createColorList:function(e,t){const i=e.colorList?e.colorList:["#ff0000","#ff5e00","#ffe400","#abf200","#00d8ff","#0055ff","#6600ff","#ff00dd","#000000","#ffd8d8","#fae0d4","#faf4c0","#e4f7ba","#d4f4fa","#d9e5ff","#e8d9ff","#ffd9fa","#ffffff","#ffa7a7","#ffc19e","#faed7d","#cef279","#b2ebf4","#b2ccff","#d1b2ff","#ffb2f5","#bdbdbd","#f15f5f","#f29661","#e5d85c","#bce55c","#5cd1e5","#6699ff","#a366ff","#f261df","#8c8c8c","#980000","#993800","#998a00","#6b9900","#008299","#003399","#3d0099","#990085","#353535","#670000","#662500","#665c00","#476600","#005766","#002266","#290066","#660058","#222222"];let n='
    ';for(let e=0,t=i.length;e '}return n+='
"},init:function(e,t){const i=this.plugins.colorPicker;let n=t||(i.getColorInNode.call(this,e)||this.context.colorPicker._defaultColor);n=i.isHexColor(n)?n:i.rgb2hex(n),i.setInputText.call(this,n)},setCurrentColor:function(e){this.context.colorPicker._currentColor=e,this.context.colorPicker._colorInput.style.borderColor=e},setInputText:function(e){this.context.colorPicker._colorInput.value=e.replace("#",""),this.plugins.colorPicker.setCurrentColor.call(this,e)},getColorInNode:function(e){let t="";const i=this.context.colorPicker._styleProperty;for(;!n.a.isWysiwygDiv(e)&&0===t.length;)1===e.nodeType&&e.style[i]&&(t=e.style[i]),e=e.parentNode;return t},isHexColor:function(e){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(e)},rgb2hex:function(e){return(e=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===e.length?"#"+("0"+parseInt(e[1],10).toString(16)).slice(-2)+("0"+parseInt(e[2],10).toString(16)).slice(-2)+("0"+parseInt(e[3],10).toString(16)).slice(-2):""}}},KKur:function(module,__webpack_exports__,__webpack_require__){"use strict";var _lib_util__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("8e1d"),_modules_dialog__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("1kvd"),_modules_resizing__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("ee5k"),_modules_notice__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("PAX9");__webpack_exports__.a={name:"image",add:function(core){core.addModule([_modules_dialog__WEBPACK_IMPORTED_MODULE_1__.a,_modules_resizing__WEBPACK_IMPORTED_MODULE_2__.a,_modules_notice__WEBPACK_IMPORTED_MODULE_3__.a]);const context=core.context;context.image={_linkElement:null,_container:null,_cover:null,_element:null,_element_w:1,_element_h:1,_element_l:0,_element_t:0,_origin_w:"auto"===context.option.imageWidth?"":context.option.imageWidth,_origin_h:"",_altText:"",_caption:null,captionCheckEl:null,_linkValue:"",_align:"none",_captionChecked:!1,_proportionChecked:!0,_floatClassRegExp:"float\\-[a-z]+",_xmlHttp:null,_resizing:context.option.imageResizing,_defaultAuto:"auto"===context.option.imageWidth};let image_dialog=eval(this.setDialog(core.context.option,core.lang));context.image.modal=image_dialog,context.image.imgUrlFile=image_dialog.getElementsByClassName("sun-editor-id-image-url")[0],context.image.imgInputFile=context.image.focusElement=image_dialog.getElementsByClassName("sun-editor-id-image-file")[0],context.image.altText=image_dialog.getElementsByClassName("sun-editor-id-image-alt")[0],context.image.imgLink=image_dialog.getElementsByClassName("sun-editor-id-image-link")[0],context.image.imgLinkNewWindowCheck=image_dialog.getElementsByClassName("sun-editor-id-linkCheck")[0],context.image.captionCheckEl=image_dialog.getElementsByClassName("suneditor-id-image-check-caption")[0],context.image.modal.getElementsByClassName("sun-editor-tab-button")[0].addEventListener("click",this.openTab.bind(core)),context.image.modal.getElementsByClassName("btn-primary")[0].addEventListener("click",this.submit.bind(core)),context.image.imageX={},context.image.imageY={},context.option.imageResizing&&(context.image.proportion=image_dialog.getElementsByClassName("suneditor-id-image-check-proportion")[0],context.image.imageX=image_dialog.getElementsByClassName("sun-editor-id-image-x")[0],context.image.imageY=image_dialog.getElementsByClassName("sun-editor-id-image-y")[0],context.image.imageX.value=context.option.imageWidth,context.image.imageX.addEventListener("change",this.setInputSize.bind(core,"x")),context.image.imageY.addEventListener("change",this.setInputSize.bind(core,"y")),image_dialog.getElementsByClassName("sun-editor-id-image-revert-button")[0].addEventListener("click",this.sizeRevert.bind(core))),context.dialog.modal.appendChild(image_dialog),image_dialog=null},setDialog:function(e,t){const i=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");i.className="modal-content sun-editor-id-dialog-image",i.style.display="none";let n='
",i.innerHTML=n,i},openTab:function(e){const t=this.context.image.modal,i="init"===e?t.getElementsByClassName("sun-editor-id-tab-link")[0]:e.target;if(!/^BUTTON$/i.test(i.tagName))return!1;const n=i.getAttribute("data-tab-link");let o,l,a;for(l=t.getElementsByClassName("sun-editor-id-tab-content"),o=0;o0){const t=this.context.option.imageUploadUrl,i=this.context.dialog.updateModal?1:e.length;if(null!==t&&t.length>0){const n=new FormData;for(let t=0;t0?1:s.length;a0){const n=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("A");return n.href=/^https?:\/\//.test(t)?t:"http://"+t,n.target=i?"_blank":"",n.setAttribute("data-image-link","image"),e.setAttribute("data-image-link",t),n.appendChild(e),n}return e},setInputSize:function(e){this.context.dialog.updateModal&&this.context.image.proportion.checked&&("x"===e?this.context.image.imageY.value=Math.round(this.context.image._element_h/this.context.image._element_w*this.context.image.imageX.value):this.context.image.imageX.value=Math.round(this.context.image._element_w/this.context.image._element_h*this.context.image.imageY.value))},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation(),this.context.image._linkValue=this.context.image.imgLink.value,this.context.image._altText=this.context.image.altText.value,this.context.image._align=this.context.image.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,this.context.image._captionChecked=this.context.image.captionCheckEl.checked,this.context.image._resizing&&(this.context.image._proportionChecked=this.context.image.proportion.checked);try{this.context.dialog.updateModal&&this.plugins.image.update_image.call(this),this.context.image.imgInputFile&&this.context.image.imgInputFile.files.length>0?this.plugins.image.onRender_imgInput.call(this):this.context.image.imgUrlFile&&this.context.image.imgUrlFile.value.trim().length>0?this.plugins.image.onRender_imgUrl.call(this):this.closeLoading()}catch(e){throw this.closeLoading(),_modules_notice__WEBPACK_IMPORTED_MODULE_3__.a.open.call(this,'[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"'),Error('[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},_onload_image:function(e,t){if(/\d+/.test(e.style.width)&&(e.style.height=e.offsetHeight+"px"),e.setAttribute("origin-size",e.naturalWidth+","+e.naturalHeight),e.setAttribute("data-origin",e.offsetWidth+","+e.offsetHeight),!t)return;let i=e.getAttribute("data-index");if(i){const t=this._variable._imagesInfo[i];t.name=e.getAttribute("data-file-name"),t.size=1*e.getAttribute("data-file-size")}else i=this._variable._imageIndex,e.setAttribute("data-index",i),this._variable._imagesInfo[i]={index:i,name:t.name,size:t.size,select:function(){const t=this.plugins.resizing.call_controller_resize.call(this,e,"image");this.plugins.image.onModifyMode.call(this,e,t),e.scrollIntoView()}.bind(this),delete:this.plugins.image.destroy.bind(this,e)},this._variable._imageIndex++,e.setAttribute("data-file-name",t.name),e.setAttribute("data-file-size",t.size);this._imageUpload(e,i,!1)},create_image:function(e,t,i,n,o,l,a,s){if(l)return void(a.src=e);const r=this.context.image;let d=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("IMG");d.addEventListener("load",this.plugins.image._onload_image.bind(this,d,s)),d.src=e,d.setAttribute("data-align",o),d.alt=r._altText,(d=this.plugins.image.onRender_link(d,t,i)).setAttribute("data-rotate","0"),r._resizing&&(/\d+/.test(n)&&(d.style.width=n),d.setAttribute("data-proportion",r._proportionChecked));const c=this.plugins.resizing.set_cover.call(this,d),_=this.plugins.resizing.set_container.call(this,c,"sun-editor-id-image-container");r._captionChecked&&(r._caption=this.plugins.resizing.create_caption.call(this),r._caption.setAttribute("contenteditable",!1),c.appendChild(r._caption)),c.style.margin="none"!==o?"auto":"0",_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeClass(_,r._floatClassRegExp),_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.addClass(_,"float-"+o),r._resizing&&/\d+/.test(n)||(this.context.resizing._resize_plugin="image",r._element=d,r._cover=c,r._container=_,this.plugins.image.setAutoSize.call(this)),this.insertNode(_,_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getFormatElement(this.getSelectionNode())),this.appendFormatTag(_)},update_image:function(){const e=this.context.image,t=e._linkValue;let i=e._element,n=e._cover,o=e._container,l=!1;const a=1*e.imageX.value!==i.offsetWidth||1*e.imageY.value!==i.offsetHeight;if(null===n&&(l=!0,i=e._element.cloneNode(!0),n=this.plugins.resizing.set_cover.call(this,i)),null===o&&(n=n.cloneNode(!0),l=!0,o=this.plugins.resizing.set_container.call(this,n,"sun-editor-id-image-container")),l&&(o.innerHTML="",o.appendChild(n)),i.alt=e._altText,e._resizing&&(i.setAttribute("data-proportion",e._proportionChecked),a&&this.plugins.image.setSize.call(this,e.imageX.value,e.imageY.value)),e._captionChecked?e._caption||(e._caption=this.plugins.resizing.create_caption.call(this),n.appendChild(e._caption)):e._caption&&(_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeItem(e._caption),e._caption=null),e._align&&"none"!==e._align?n.style.margin="auto":n.style.margin="0",_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeClass(o,this.context.image._floatClassRegExp),_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.addClass(o,"float-"+e._align),i.setAttribute("data-align",e._align),t.trim().length>0)if(null!==e._linkElement)e._linkElement.href=t,e._linkElement.target=e.imgLinkNewWindowCheck.checked?"_blank":"",i.setAttribute("data-image-link",t);else{let o=this.plugins.image.onRender_link(i,t,this.context.image.imgLinkNewWindowCheck.checked);n.insertBefore(o,e._caption)}else if(null!==e._linkElement){const t=i;t.setAttribute("data-image-link","");let o=t.cloneNode(!0);n.removeChild(e._linkElement),n.insertBefore(o,e._caption),i=o}if(l){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getFormatElement(e._element);t.parentNode.insertBefore(o,t),_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeItem(t)}(e._resizing&&a||this.context.resizing._rotateVertical&&e._captionChecked)&&this.plugins.resizing.setTransformSize.call(this,i)},sizeRevert:function(){const e=this.context.image;e._origin_w&&(e.imageX.value=e._element_w=e._origin_w,e.imageY.value=e._element_h=e._origin_h)},onModifyMode:function(e,t){const i=this.context.image;i._linkElement=/^A$/i.test(e.parentNode.nodeName)?e.parentNode:null,i._element=e,i._cover=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getParentElement(e,".sun-editor-figure-cover"),i._container=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getParentElement(e,".sun-editor-id-image-container"),i._caption=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getChildElement(i._cover,"FIGCAPTION"),i._align=e.getAttribute("data-align")||"none",i._element_w=t.w,i._element_h=t.h,i._element_t=t.t,i._element_l=t.l;let n=i._element.getAttribute("data-origin");n?(n=n.split(","),i._origin_w=1*n[0],i._origin_h=1*n[1]):(i._origin_w=t.w,i._origin_h=t.h,i._element.setAttribute("data-origin",t.w+","+t.h))},openModify:function(e){const t=this.context.image;t.imgUrlFile.value=t._element.src,t.altText.value=t._element.alt,t.imgLink.value=null===t._linkElement?"":t._linkElement.href,t.imgLinkNewWindowCheck.checked=t._linkElement&&"_blank"===t._linkElement.target,t.modal.querySelector('input[name="suneditor_image_radio"][value="'+t._align+'"]').checked=!0,t._captionChecked=t.captionCheckEl.checked=!!t._caption,t._resizing&&(t.proportion.checked=t._proportionChecked="true"===t._element.getAttribute("data-proportion"),t.imageX.value=t._element.offsetWidth,t.imageY.value=t._element.offsetHeight,t.imageX.disabled=!1,t.imageY.disabled=!1,t.proportion.disabled=!1),e||this.plugins.dialog.open.call(this,"image",!0)},setSize:function(e,t){const i=this.context.image;i._element.style.width=e+"px",i._element.style.height=t+"px"},setAutoSize:function(){const e=this.context.image;this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this),e._element.style.maxWidth="100%",e._element.style.width="",e._element.style.height="",e._cover.style.width="",e._cover.style.height=""},setPercentSize:function(e){const t=this.context.image;t._container.style.width=e,t._container.style.height="",t._cover.style.width="100%",t._cover.style.height="",t._element.style.width="100%",t._element.style.height="",/100/.test(e)&&(_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeClass(t._container,this.context.image._floatClassRegExp),_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.addClass(t._container,"float-center"))},cancelPercentAttr:function(){const e=this.context.image;e._element.style.maxWidth="none",e._cover.style.width="",e._cover.style.height="",e._container.style.width="",e._container.style.height="",_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeClass(e._container,this.context.image._floatClassRegExp),_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.addClass(e._container,"float-"+e._align)},resetAlign:function(){const e=this.context.image;e._element.setAttribute("data-align",""),e._align="none",e._cover.style.margin="0",_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeClass(e._container,e._floatClassRegExp)},destroy:function(e){const t=e||this.context.image._element,i=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getParentElement(t,".sun-editor-id-image-container")||t,n=t.getAttribute("data-index");_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeItem(i),this.plugins.image.init.call(this),this.controllersOff(),n&&(delete this._variable._imagesInfo[n],this._imageUpload(t,n,!0))},init:function(){const e=this.context.image;if(e.imgInputFile&&(e.imgInputFile.value=""),e.imgUrlFile&&(e.imgUrlFile.value=""),e.altText.value="",e.imgLink.value="",e.imgLinkNewWindowCheck.checked=!1,e.modal.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,e.captionCheckEl.checked=!1,e._element=null,this.plugins.image.openTab.call(this,"init"),e._resizing){const t="auto"===this.context.option.imageWidth;e.proportion.checked=!1,e.imageX.value=t?"":this.context.option.imageWidth,e.imageY.value="",e.imageX.disabled=t,e.imageY.disabled=!0,e.proportion.disabled=!0}}}},MIhV:function(module,__webpack_exports__,__webpack_require__){"use strict";var _lib_util__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("8e1d");__webpack_exports__.a={name:"fontSize",add:function(core,targetElement){let listDiv=eval(this.setSubmenu(core.context.option));listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickup.bind(core)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");t.className="layer_editor layer_size",t.style.display="none";const i=e.fontSize?e.fontSize:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72];let n='
    ';for(let e=0,t=i.length;e"}return n+="
",t.innerHTML=n,t},pickup:function(e){if(e.preventDefault(),e.stopPropagation(),!/^BUTTON$/i.test(e.target.tagName))return!1;_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.changeTxt(this.context.tool.fontSize,e.target.getAttribute("data-value"));const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("SPAN");t.style.fontSize=e.target.getAttribute("data-value")+"px",this.nodeChange(t,["font-size"]),this.submenuOff(),this.focus()}}},PAX9:function(e,t,i){"use strict";var n=i("8e1d");t.a={name:"notice",add:function(e){const t=e.context;t.notice={};let i=n.a.createElement("DIV"),o=n.a.createElement("SPAN"),l=n.a.createElement("BUTTON");i.className="sun-editor-id-notice",l.className="close",l.setAttribute("aria-label","Close"),l.setAttribute("title",e.lang.dialogBox.close),l.innerHTML='',i.appendChild(o),i.appendChild(l),t.notice.modal=i,t.notice.message=o,l.addEventListener("click",this.onClick_cancel.bind(e)),t.element.editorArea.insertBefore(i,t.element.wysiwyg),i=null},onClick_cancel:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.notice.close.call(this)},open:function(e){this.context.notice.message.textContent=e,this.context.notice.modal.style.display="block"},close:function(){this.context.notice.modal.style.display="none"}}},Rp48:function(module,__webpack_exports__,__webpack_require__){"use strict";var _lib_util__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("8e1d"),_modules_dialog__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("1kvd");__webpack_exports__.a={name:"link",add:function(core){core.addModule([_modules_dialog__WEBPACK_IMPORTED_MODULE_1__.a]);const context=core.context;context.link={};let link_dialog=eval(this.setDialog(core.lang));context.link.modal=link_dialog,context.link.focusElement=link_dialog.getElementsByClassName("sun-editor-id-link-url")[0],context.link.linkAnchorText=link_dialog.getElementsByClassName("sun-editor-id-link-text")[0],context.link.linkNewWindowCheck=link_dialog.getElementsByClassName("sun-editor-id-link-check")[0];let link_button=eval(this.setController_LinkButton(core.lang));context.link.linkBtn=link_button,context.link._linkAnchor=null,link_dialog.getElementsByClassName("btn-primary")[0].addEventListener("click",this.submit.bind(core)),link_button.addEventListener("click",this.onClick_linkBtn.bind(core)),context.dialog.modal.appendChild(link_dialog),context.element.relative.appendChild(link_button),link_dialog=null,link_button=null},setDialog:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");return t.className="modal-content sun-editor-id-dialog-link",t.style.display="none",t.innerHTML='",t},setController_LinkButton:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");return t.className="sun-editor-id-link-btn",t.style.display="none",t.innerHTML='
',t},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();const t=function(){if(0===this.context.link.focusElement.value.trim().length)return!1;const e=this.context.link.focusElement.value,t=this.context.link.linkAnchorText,i=0===t.value.length?e:t.value;if(this.context.dialog.updateModal)this.context.link._linkAnchor.href=e,this.context.link._linkAnchor.textContent=i,this.context.link._linkAnchor.target=this.context.link.linkNewWindowCheck.checked?"_blank":"",this.setRange(this.context.link._linkAnchor.childNodes[0],0,this.context.link._linkAnchor.childNodes[0],this.context.link._linkAnchor.textContent.length);else{const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("A");t.href=e,t.textContent=i,t.target=this.context.link.linkNewWindowCheck.checked?"_blank":"",this.insertNode(t),this.setRange(t.childNodes[0],0,t.childNodes[0],t.textContent.length)}this.context.link.focusElement.value="",this.context.link.linkAnchorText.value=""}.bind(this);try{t()}finally{this.plugins.dialog.close.call(this),this.closeLoading(),this.focus()}return!1},call_controller_linkButton:function(e){this.editLink=this.context.link._linkAnchor=e;const t=this.context.link.linkBtn;t.getElementsByTagName("A")[0].href=e.href,t.getElementsByTagName("A")[0].textContent=e.textContent;const i=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getOffset(e);t.style.left=i.left-this.context.element.wysiwyg.scrollLeft+"px",t.style.top=i.top+e.offsetHeight+10+"px",t.style.display="block",this.controllerArray=[t]},onClick_linkBtn:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");t&&(e.preventDefault(),/update/.test(t)?(this.context.link.focusElement.value=this.context.link._linkAnchor.href,this.context.link.linkAnchorText.value=this.context.link._linkAnchor.textContent,this.context.link.linkNewWindowCheck.checked=!!/_blank/i.test(this.context.link._linkAnchor.target),this.plugins.dialog.open.call(this,"link",!0)):(_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeItem(this.context.link._linkAnchor),this.context.link._linkAnchor=null,this.focus()),this.controllersOff())},init:function(){const e=this.context.link;e.linkBtn.style.display="none",e._linkAnchor=null,e.focusElement.value="",e.linkAnchorText.value="",e.linkNewWindowCheck.checked=!1}}},VquE:function(module,__webpack_exports__,__webpack_require__){"use strict";var _lib_util__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("8e1d");__webpack_exports__.a={name:"table",add:function(core,targetElement){const context=core.context;context.table={_element:null,_tdElement:null,_trElement:null,_trElements:null,_tdIndex:0,_trIndex:0,_tdCnt:0,_trCnt:0,_tableXY:[]};let listDiv=eval(this.setSubmenu()),tablePicker=listDiv.getElementsByClassName("sun-editor-id-table-picker")[0];context.table.tableHighlight=listDiv.getElementsByClassName("sun-editor-id-table-highlighted")[0],context.table.tableUnHighlight=listDiv.getElementsByClassName("sun-editor-id-table-unhighlighted")[0],context.table.tableDisplay=listDiv.getElementsByClassName("sun-editor-table-display")[0];let resizeDiv=eval(this.setController_tableEditor(core.lang));context.table.resizeDiv=resizeDiv,tablePicker.addEventListener("mousemove",this.onMouseMove_tablePicker.bind(core)),tablePicker.addEventListener("click",this.appendTable.bind(core)),resizeDiv.addEventListener("click",this.onClick_resizeDiv.bind(core)),targetElement.parentNode.appendChild(listDiv),context.element.relative.appendChild(resizeDiv),listDiv=null,tablePicker=null,resizeDiv=null},setSubmenu:function(){const e=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");return e.className="table-content",e.style.display="none",e.innerHTML='
1 x 1
',e},setController_tableEditor:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");return t.className="sun-editor-id-table-edit",t.style.display="none",t.innerHTML='
',t},appendTable:function(){const e=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("TABLE");let t=this.context.table._tableXY[0],i=this.context.table._tableXY[1],n="";for(;i>0;){n+="";let e=t;for(;e>0;)n+="
"+_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.zeroWidthSpace+"
",--e;n+="",--i}n+="",e.innerHTML=n;const o=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getFormatElement(this.getSelectionNode());this.insertNode(e,/^LI$/i.test(o.nodeName)?_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getRangeFormatElement(o):o),this.appendFormatTag(e),this.focus(),this.plugins.table.reset_table_picker.call(this)},onMouseMove_tablePicker:function(e){e.stopPropagation();let t=Math.ceil(e.offsetX/18),i=Math.ceil(e.offsetY/18);t=t<1?1:t,i=i<1?1:i,this.context.table.tableHighlight.style.width=t+"em",this.context.table.tableHighlight.style.height=i+"em";let n=t<5?5:t>9?10:t+1,o=i<5?5:i>9?10:i+1;this.context.table.tableUnHighlight.style.width=n+"em",this.context.table.tableUnHighlight.style.height=o+"em",_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.changeTxt(this.context.table.tableDisplay,t+" x "+i),this.context.table._tableXY=[t,i]},reset_table_picker:function(){if(!this.context.table.tableHighlight)return;const e=this.context.table.tableHighlight.style,t=this.context.table.tableUnHighlight.style;e.width="1em",e.height="1em",t.width="5em",t.height="5em",_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.changeTxt(this.context.table.tableDisplay,"1 x 1"),this.submenuOff()},init:function(){const e=this.context.table;e._tdElement&&_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeClass(e._tdElement,"sun-editor-selected-cell"),e._element=null,e._tdElement=null,e._trElement=null,e._trElements=0,e._tdIndex=0,e._trIndex=0,e._trCnt=0,e._tdCnt=0,e._tableXY=[]},call_controller_tableEdit:function(e){const t=this.context.table.resizeDiv;this.plugins.table.setPositionControllerDiv.call(this,e,!1),t.style.display="block",this.controllerArray=[t],this.controllerFunction=[this.plugins.table.init.bind(this)]},setPositionControllerDiv:function(e,t){const i=this.context.table,n=i.resizeDiv;let o=i._element;if(!o){for(o=e;!/^TABLE$/i.test(o.nodeName);)o=o.parentNode;i._element=o}i._tdElement!==e&&(i._tdElement&&_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.removeClass(i._tdElement,"sun-editor-selected-cell"),_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.addClass(e,"sun-editor-selected-cell"),i._tdElement=e,i._trElement=e.parentNode),(t||0===i._trCnt)&&(i._trElements=o.rows,i._tdIndex=e.cellIndex,i._trIndex=i._trElement.rowIndex,i._trCnt=o.rows.length,i._tdCnt=i._trElement.cells.length);const l=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.getOffset(e);n.style.left=l.left-this.context.element.wysiwyg.scrollLeft+"px",n.style.top=l.top+e.offsetHeight+12+"px"},insertRowCell:function(e,t){const i=this.context.table;if("row"===e){const e="up"===t?i._trIndex:i._trIndex+1;let n="";for(let e=0,t=i._tdCnt;e
"+_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.zeroWidthSpace+"
";i._element.insertRow(e).innerHTML=n}else{const e=i._trElements,n="left"===t?i._tdIndex:i._tdIndex+1;let o=null;for(let t=0,l=i._trCnt;t"+_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.zeroWidthSpace+""}this.plugins.table.setPositionControllerDiv.call(this,i._tdElement,!0)},deleteRowCell:function(e){const t=this.context.table;if("row"===e)t._element.deleteRow(t._trIndex);else{const e=t._trElements,i=t._tdIndex;for(let n=0,o=t._trCnt;n'+e.toolbar.alignLeft+'
  • ",t},pickup:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,i=null;for(;!i&&!/UL/i.test(t.tagName);)i=t.getAttribute("data-command"),t=t.parentNode;this.focus(),this.execCommand(i,!1,null),this.submenuOff()}}},WUQj:function(e,t,i){},WzUB:function(module,__webpack_exports__,__webpack_require__){"use strict";var _lib_util__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("8e1d");__webpack_exports__.a={name:"formatBlock",add:function(core,targetElement){let listDiv=eval(this.setSubmenu(core.lang));listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickUp.bind(core)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement("DIV");return t.className="layer_editor layer_block",t.style.display="none",t.innerHTML='
    ",t},pickUp:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,i=null,n=null;for(;!i&&!/UL/i.test(t.tagName);)i=t.getAttribute("data-command"),n=t.getAttribute("data-value"),t=t.parentNode;if("range"===i){const e=_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.createElement(n);this.wrapToTags(e),this.setRange(e.firstChild,0,e.firstChild,0),this.appendFormatTag(e,_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.isCell(this.getSelectionNode())?"DIV":"")}else this.execCommand("formatBlock",!1,n),_lib_util__WEBPACK_IMPORTED_MODULE_0__.a.changeTxt(this.commandMap.FORMAT,n);this.submenuOff(),this.focus()}}},XJR1:function(e,t,i){"use strict";i.r(t);i("3FqI"),i("WUQj");var n=i("WRt5"),o=i("50IV"),l=i("MIhV"),a=i("0A7J"),s=i("s0fJ"),r=i("g4XY"),d=i("gMuy"),c=i("VquE"),_=i("WzUB"),u=i("Rp48"),g=i("KKur"),m=i("hlhS"),h={align:n.a,font:o.a,fontSize:l.a,fontColor:a.a,hiliteColor:s.a,horizontalRule:r.a,list:d.a,table:c.a,formatBlock:_.a,link:u.a,image:g.a,video:m.a},p=i("8e1d"),f=i("PAX9");var b=function(e,t,i){const n=document,o=window,l={context:e,plugins:{},initPlugins:{},lang:i,dialogForm:null,submenu:null,submenuActiveButton:null,controllerArray:[],controllerFunction:[],codeViewDisabledButtons:e.element.toolbar.querySelectorAll('.sun-editor-id-toolbar button:not([class~="code-view-enabled"])'),_isInline:/inline/i.test(e.option.mode),_isBalloon:/balloon/i.test(e.option.mode),_inlineToolbarAttr:{width:0,height:0,isShow:!1},_imageUpload:function(e,t,i){s.onImageUpload&&s.onImageUpload(e,t,i)},commandMap:{FORMAT:e.tool.format,FONT:e.tool.font,SIZE:e.tool.fontSize,B:e.tool.bold,U:e.tool.underline,I:e.tool.italic,STRIKE:e.tool.strike,SUB:e.tool.subscript,SUP:e.tool.superscript},_variable:{selectionNode:null,range:null,wysiwygActive:!0,isFullScreen:!1,innerHeight_fullScreen:0,resizeClientY:0,tabSize:4,minResizingSize:65,currentNodes:[],_originCssText:e.element.topArea.style.cssText,_bodyOverflow:"",_editorAreaOriginCssText:"",_wysiwygOriginCssText:"",_codeOriginCssText:"",_sticky:!1,_imagesInfo:[],_imageIndex:0},callPlugin:function(e,t){if(!this.plugins[e])throw Error('[SUNEDITOR.core.callPlugin.fail] The called plugin does not exist or is in an invalid format. (pluginName:"'+e+'")');this.initPlugins[e]||(this.plugins[e].add(this,this.plugins[e].buttonElement),this.initPlugins[e]=!0),t()},addModule:function(e){let t="";for(let i=0,n=e.length;i0){for(let t=0;t0){for(let e=0;e":i)},focus:function(){if("none"===e.element.wysiwyg.style.display)return;const t=p.a.getParentElement(this.getSelectionNode(),"figcaption");t?t.focus():e.element.wysiwyg.focus(),this._setEditorRange(),a._findButtonEffectTag()},_setEditorRange:function(){const e=o.getSelection();let t=null;t=e.rangeCount>0?e.getRangeAt(0):this._createDefaultRange(),this._variable.range=t,t.collapsed?this.setSelectionNode(t.commonAncestorContainer):this.setSelectionNode(e.extentNode||e.anchorNode)},_createDefaultRange:function(){const t=n.createRange();return t.setStart(e.element.wysiwyg.firstChild,0),t.setEnd(e.element.wysiwyg.firstChild,0),t},setRange:function(e,t,i,l){const a=n.createRange();a.setStart(e,t),a.setEnd(i,l);const s=o.getSelection();s.removeAllRanges&&s.removeAllRanges(),s.addRange(a),this._variable.range=a,this._setEditorRange()},getRange:function(){return this._variable.range||this._createDefaultRange()},setSelectionNode:function(e){this._variable.selectionNode=e},getSelectionNode:function(){return this._variable.selectionNode?this._variable.selectionNode:e.element.wysiwyg.firstChild},getSelectedFormatElements:function(){let t=this.getRange();if(p.a.isWysiwygDiv(t.startContainer)){const i=e.element.wysiwyg.children;this.setRange(i[0],0,i[i.length-1],i[i.length-1].textContent.length),t=this.getRange()}const i=t.startContainer,n=t.endContainer,o=t.commonAncestorContainer,l=[];if(!p.a.isWysiwygDiv(o)&&!p.a.isRangeFormatElement(o))return[p.a.getFormatElement(o)];const a=p.a.getListChildren(o,function(e){return p.a.isFormatElement(e)});if(i===n)return a[0];let s=p.a.getFormatElement(i),r=p.a.getFormatElement(n),d=0,c=0;for(let e=0,t=a.length;e=0;e--)r[e]===n.parentNode&&r[e].firstChild===n&&0===i&&(d=e,n=n.parentNode);for(let e=c-1,t=n;e>d;e--)r[e]===t.parentNode&&1===r[e].nodeType&&(r.splice(e,1),t=t.parentNode,--c);for(let e=d;e<=c;e++){const l=r[e];0===l.length||3===l.nodeType&&void 0===l.data?p.a.removeItem(l):l!==t?l!==n?p.a.removeItem(l):(s=1===n.nodeType?p.a.createTextNode(n.textContent):p.a.createTextNode(n.substringData(o,n.length-o))).length>0?n.data=s.data:p.a.removeItem(n):(a=1===t.nodeType?p.a.createTextNode(t.textContent):p.a.createTextNode(t.substringData(0,i))).length>0?t.data=a.data:p.a.removeItem(t)}},wrapToTags:function(e){const t=this.getRange(),i=this.getSelectedFormatElements();if(!i){const t=p.a.createElement(p.a.isCell(this.getSelectionNode())?"DIV":"P");return t.innerHTML=p.a.zeroWidthSpace,e.appendChild(t),void this.getSelectionNode().appendChild(e)}let n,o,l,a=i[i.length-1];n=p.a.isRangeFormatElement(a)||p.a.isFormatElement(a)?a:p.a.getRangeFormatElement(a)||p.a.getFormatElement(a),p.a.isCell(n)?(o=null,l=n):(o=n.nextSibling,l=n.parentNode);let s=null,r=null,d="";for(let t=0,n=i.length;t=t.length)return}}if(o=i.startContainer,l=i.startOffset,1===o.nodeType&&o.childNodes.length>0)for(;o&&!p.a.isBreak(o)&&1===o.nodeType;){s=[];for(let e=0,t=(a=o.childNodes).length;e0){for(;o&&!p.a.isBreak(o)&&1===o.nodeType;){s=[];for(let e=0,t=(a=o.childNodes).length;e0&&(t=e.style.cssText.replace(h,"").trim()),(t.length>0||e.nodeName!==g)&&(e.style.cssText.length>0&&(e.style.cssText=t),!0)};if(p.a.isWysiwygDiv(u)||p.a.isRangeFormatElement(u)){const t=this.getSelectedFormatElements(),i=t.length-1;m=e.cloneNode(!1),f=this._nodeChange_startLine(t[0],m,v,r,d,n);for(let o=1;o0?(m=e.cloneNode(!1),b=this._nodeChange_endLine(t[i],m,v,c,_,n)):b=f}else{m=e.cloneNode(!1);const t=this._nodeChange_oneLine(p.a.getFormatElement(u),m,v,r,d,c,_,n,i.collapsed);f.container=t.startContainer,f.offset=t.startOffset,b.container=t.endContainer,b.offset=t.endOffset}this.setRange(f.container,f.offset,b.container,b.offset)},_nodeChange_oneLine:function(e,t,i,n,o,l,a,s,r){const d=e,c=e.cloneNode(!1),_=n===l;let u,g,m,h,f=n,b=o,v=l,y=a,E=!1,x=!1;function C(e){const t=new RegExp("(?:;|^|\\s)(?:"+h+"null)\\s*:[^;]*\\s*(?:;|$)","ig");let i="";return t&&e.style.cssText.length>0&&(i=t.test(e.style.cssText)),!i}return function e(n,o){const l=n.childNodes;for(let n=0,a=l.length;nb?y-b:b-y));for(e.data.length>0&&o.appendChild(e),g=k,u=[],h="";g!==c&&g!==d&&null!==g;)i(g)&&1===g.nodeType&&C(g)&&(u.push(g.cloneNode(!1)),h+=g.style.cssText.substr(0,g.style.cssText.indexOf(":"))+"|"),g=g.parentNode;const l=u.pop()||n;for(m=g=l;u.length>0;)g=u.pop(),m.appendChild(g),m=g;if(t.appendChild(l),c.appendChild(t),f=n,b=0,E=!0,g!==n&&g.appendChild(f),!_)continue}if(x||k!==v){if(E){if(1===k.nodeType&&!p.a.isBreak(k)){e(k,k);continue}for(g=k,u=[],h="";null!==g.parentNode&&g!==d&&g!==t;)1===g.nodeType&&!p.a.isBreak(k)&&(x||i(g))&&C(g)&&(u.push(g.cloneNode(!1)),h+=g.style.cssText.substr(0,g.style.cssText.indexOf(":"))+"|"),g=g.parentNode;const n=u.pop()||k;for(m=g=n;u.length>0;)g=u.pop(),m.appendChild(g),m=g;n===k?o=x?c:t:x?(c.appendChild(n),o=g):(t.appendChild(n),o=g)}a=k.cloneNode(!1),o.appendChild(a),1!==k.nodeType||p.a.isBreak(k)||(w=a),e(k,w)}else{const e=p.a.createTextNode(1===v.nodeType?"":v.substringData(y,v.length-y)),n=p.a.createTextNode(_||1===v.nodeType?"":v.substringData(0,y));if(e.data.length>0){for(g=k,h="",u=[];g!==c&&g!==d&&null!==g;)1===g.nodeType&&C(g)&&(u.push(g.cloneNode(!1)),h+=g.style.cssText.substr(0,g.style.cssText.indexOf(":"))+"|"),g=g.parentNode;for(a=m=g=u.pop()||e;u.length>0;)g=u.pop(),m.appendChild(g),m=g;c.appendChild(a),g.textContent=e.data}for(g=k,u=[],h="";g!==c&&g!==d&&null!==g;)i(g)&&1===g.nodeType&&C(g)&&(u.push(g.cloneNode(!1)),h+=g.style.cssText.substr(0,g.style.cssText.indexOf(":"))+"|"),g=g.parentNode;const o=u.pop()||n;for(m=g=o;u.length>0;)g=u.pop(),m.appendChild(g),m=g;t.appendChild(o),v=n,y=n.data.length,x=!0,!s&&r&&(t=n,n.textContent=p.a.zeroWidthSpace),g!==n&&g.appendChild(v)}}}(e,c),s?(f=p.a.createTextNode(r?p.a.zeroWidthSpace:t.textContent),c.insertBefore(f,t),c.removeChild(t),r&&(b=1)):r&&(f=v=t,b=1,y=1),p.a.removeEmptyNode(c),e.parentNode.insertBefore(c,e),p.a.removeItem(e),{startContainer:f,startOffset:b,endContainer:s||!v.textContent?f:v,endOffset:s||!v.textContent?f.textContent.length:y}},_nodeChange_middleLine:function(e,t,i,n){n?t=p.a.createTextNode(e.textContent?e.textContent:p.a.zeroWidthSpace):function e(t,n){const o=t.childNodes;for(let t=0,l=o.length;t0){const e=r.pop();for(c=d=e;r.length>0;)d=r.pop(),c.appendChild(d),c=d;t.appendChild(e),o=d}else o=t}if(g||m!==_){if(!g||i(m)){const e=m.cloneNode(!1);o.appendChild(e),1!==m.nodeType||p.a.isBreak(m)||(h=e)}e(m,h)}else{const e=p.a.createTextNode(1===_.nodeType?"":_.substringData(0,u)),n=p.a.createTextNode(1===_.nodeType?"":_.substringData(u,_.length-u));for(e.data.length>0&&o.appendChild(e),d=o,r=[];d!==s&&null!==d;)1===d.nodeType&&i(d)&&r.push(d.cloneNode(!1)),d=d.parentNode;const l=r.pop()||o;for(c=d=l;r.length>0;)d=r.pop(),c.appendChild(d),c=d;l!==o?(t.appendChild(l),o=d):o=t,p.a.isBreak(m)&&t.appendChild(m.cloneNode(!1)),s.appendChild(t),_=n,u=0,g=!0,o.appendChild(_)}}}(e,s),l&&(_=p.a.createTextNode(t.textContent),s.insertBefore(_,t),s.removeChild(t)),l||0!==s.children.length?(p.a.removeEmptyNode(s),e.parentNode.insertBefore(s,e),p.a.removeItem(e)):e.childNodes?_=e.childNodes[0]:(_=p.a.createTextNode(p.a.zeroWidthSpace),e.appendChild(_)),{container:_,offset:u}},_nodeChange_endLine:function(e,t,i,n,o,l){const a=e,s=e.cloneNode(!1);let r,d,c,_=n,u=o,g=!1;return function e(n,o){const l=n.childNodes;for(let n=l.length-1;0<=n;n--){const m=l[n];let h=o;if(g&&!p.a.isBreak(m)){if(1===m.nodeType){e(m,m);continue}for(d=m,r=[];null!==d.parentNode&&d!==a&&d!==t;)i(d)&&1===d.nodeType&&r.push(d.cloneNode(!1)),d=d.parentNode;if(r.length>0){const e=r.pop();for(c=d=e;r.length>0;)d=r.pop(),c.appendChild(d),c=d;t.insertBefore(e,t.firstChild),o=d}else o=t}if(g||m!==_){if(!g||i(m)){const e=m.cloneNode(!1);o.insertBefore(e,o.firstChild),1!==m.nodeType||p.a.isBreak(m)||(h=e)}e(m,h)}else{const e=p.a.createTextNode(1===_.nodeType?"":_.substringData(u,_.length-u)),n=p.a.createTextNode(1===_.nodeType?"":_.substringData(0,u));for(e.data.length>0&&o.insertBefore(e,o.firstChild),d=o,r=[];d!==s&&null!==d;)i(d)&&1===d.nodeType&&r.push(d.cloneNode(!1)),d=d.parentNode;const l=r.pop()||o;for(c=d=l;r.length>0;)d=r.pop(),c.appendChild(d),c=d;l!==o?(t.insertBefore(l,t.firstChild),o=d):o=t,p.a.isBreak(m)&&t.appendChild(m.cloneNode(!1)),s.insertBefore(t,s.firstChild),_=n,u=n.data.length,g=!0,o.insertBefore(_,o.firstChild)}}}(e,s),l&&(_=p.a.createTextNode(t.textContent),u=_.textContent.length,s.insertBefore(_,t),s.removeChild(t)),l||0!==s.childNodes.length?(p.a.removeEmptyNode(s),e.parentNode.insertBefore(s,e),p.a.removeItem(e)):e.childNodes?_=e.childNodes[0]:(_=p.a.createTextNode(p.a.zeroWidthSpace),e.appendChild(_)),{container:_,offset:u}},commandHandler:function(t,i){switch(i){case"codeView":this.controllersOff(),this.toggleCodeView(),p.a.toggleClass(t,"on");break;case"fullScreen":this.controllersOff(),this.toggleFullScreen(t),p.a.toggleClass(t,"on");break;case"indent":case"outdent":this.indent(i);break;case"redo":case"undo":this.execCommand(i,!1,null);break;case"removeFormat":this.removeFormat();break;case"preview":case"print":this.openWindowContents(i);break;case"showBlocks":this.toggleDisplayBlocks(),p.a.toggleClass(t,"on");break;case"subscript":p.a.hasClass(e.tool.superscript,"on")&&(this.execCommand("superscript",!1,null),p.a.removeClass(e.tool.superscript,"on")),this.execCommand(i,!1,null),p.a.toggleClass(t,"on");break;case"superscript":p.a.hasClass(e.tool.subscript,"on")&&(this.execCommand("subscript",!1,null),p.a.removeClass(e.tool.subscript,"on")),this.execCommand(i,!1,null),p.a.toggleClass(t,"on");break;default:this.execCommand(i,!1,t.getAttribute("data-value")),p.a.toggleClass(t,"on")}this.focus()},removeFormat:function(){this.nodeChange(p.a.createElement("REMOVENODE"))},indent:function(e){const t=this.getSelectedFormatElements();let i,n;for(let o=0,l=t.length;o0?e.element.code.scrollHeight+"px":"auto"),this._variable.wysiwygActive=!1,e.element.code.focus();else{const t=e.element.code.value.trim();e.element.wysiwyg.innerHTML=t.length>0?p.a.convertContentsForEditor(t):"

    "+p.a.zeroWidthSpace+"

    ",e.element.wysiwyg.scrollTop=0,e.element.code.style.display="none",e.element.wysiwyg.style.display="block","auto"===e.option.height&&(e.element.code.style.height="0px"),this._variable.wysiwygActive=!0,this.focus()}},toggleFullScreen:function(t){this._variable.isFullScreen?(this._variable.isFullScreen=!1,e.element.code.style.cssText=this._variable._codeOriginCssText,e.element.wysiwyg.style.cssText=this._variable._wysiwygOriginCssText,e.element.toolbar.style.cssText="",e.element.editorArea.style.cssText=this._variable._editorAreaOriginCssText,e.element.topArea.style.cssText=this._variable._originCssText,n.body.style.overflow=this._variable._bodyOverflow,e.option.stickyToolbar>-1&&(p.a.removeClass(e.element.toolbar,"sun-editor-sticky"),a.onScroll_window()),p.a.removeClass(t.firstElementChild,"icon-reduction"),p.a.addClass(t.firstElementChild,"icon-expansion")):(this._variable.isFullScreen=!0,e.element.topArea.style.position="fixed",e.element.topArea.style.top="0",e.element.topArea.style.left="0",e.element.topArea.style.width="100%",e.element.topArea.style.height="100%",e.element.topArea.style.zIndex="2147483647",this._variable._bodyOverflow=n.body.style.overflow,n.body.style.overflow="hidden",this._variable._editorAreaOriginCssText=e.element.editorArea.style.cssText,this._variable._wysiwygOriginCssText=e.element.wysiwyg.style.cssText,this._variable._codeOriginCssText=e.element.code.style.cssText,e.element.editorArea.style.cssText=e.element.toolbar.style.cssText=e.element.wysiwyg.style.cssText=e.element.code.style.cssText="",e.element.toolbar.style.width=e.element.wysiwyg.style.height=e.element.code.style.height="100%",e.element.toolbar.style.position="relative",this._variable.innerHeight_fullScreen=o.innerHeight-e.element.toolbar.offsetHeight,e.element.editorArea.style.height=this._variable.innerHeight_fullScreen+"px",p.a.removeClass(t.firstElementChild,"icon-expansion"),p.a.addClass(t.firstElementChild,"icon-reduction"))},openWindowContents:function(t){const n="print"===t,l=o.open("","_blank");l.mimeType="text/html",l.document.write(''+(n?i.toolbar.print:i.toolbar.preview)+'
    '+this.getContents()+"
    "+(n?"' : '') + '' + '');\n },\n\n /**\r\n * @description Gets the current contents\r\n * @returns {Object}\r\n */\n getContents: function () {\n let contents = '';\n if (context.element.wysiwyg.innerText.trim().length === 0) return contents;\n\n if (editor._variable.wysiwygActive) {\n contents = context.element.wysiwyg.innerHTML;\n } else {\n contents = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertContentsForEditor(context.element.code.value);\n }\n\n const renderHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement('DIV');\n renderHTML.innerHTML = contents;\n const figcaptions = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildren(renderHTML, function (current) {\n return /FIGCAPTION/i.test(current.nodeName);\n });\n\n for (let i = 0, len = figcaptions.length; i < len; i++) {\n figcaptions[i].outerHTML = figcaptions[i].outerHTML.replace(/(?!^]*>)/i, '');\n }\n\n return renderHTML.innerHTML;\n }\n };\n /**\r\n * @description event function\r\n */\n\n const event = {\n _shortcutKeyCode: {\n 66: ['bold', 'B'],\n 83: ['strikethrough', 'STRIKE'],\n 85: ['underline', 'U'],\n 73: ['italic', 'I'],\n 89: ['redo'],\n 90: ['undo'],\n 219: ['outdent'],\n 221: ['indent']\n },\n _directionKeyKeyCode: new RegExp('^(?:8|13|32|46|33|34|35|36|37|38|39|40|98|100|102|104)$'),\n _changeButtonClassTagCheck: new RegExp('^(?:B|U|I|STRIKE|SUB|SUP)$'),\n _findButtonEffectTag: function () {\n const commandMap = editor.commandMap;\n const classOnCheck = this._changeButtonClassTagCheck;\n const commandMapNodes = [];\n const currentNodes = [];\n let findFormat = true,\n findFont = true,\n findSize = true,\n findA = true;\n let findB = true,\n findI = true,\n findU = true,\n findS = true;\n let cssText = '',\n nodeName = '';\n\n for (let selectionParent = editor.getSelectionNode(); !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionParent); selectionParent = selectionParent.parentNode) {\n if (!selectionParent) break;\n if (selectionParent.nodeType !== 1) continue;\n nodeName = selectionParent.nodeName.toUpperCase();\n currentNodes.push(nodeName);\n /** Format */\n\n if (findFormat && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(selectionParent)) {\n commandMapNodes.push('FORMAT');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap.FORMAT, nodeName);\n findFormat = false;\n continue;\n }\n /** Font */\n\n\n if (findFont && (selectionParent.style.fontFamily.length > 0 || selectionParent.face && selectionParent.face.length > 0)) {\n commandMapNodes.push('FONT');\n const selectFont = (selectionParent.style.fontFamily || selectionParent.face || lang.toolbar.font).replace(/[\"']/g, '');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap.FONT, selectFont);\n findFont = false;\n }\n /** A */\n\n\n if (findA && /^A$/.test(nodeName) && selectionParent.getAttribute('data-image-link') === null) {\n if (!context.link || editor.controllerArray[0] !== context.link.linkBtn) {\n editor.callPlugin('link', function () {\n editor.plugins.link.call_controller_linkButton.call(editor, selectionParent);\n });\n }\n\n findA = false;\n } else if (findA && context.link && editor.controllerArray[0] === context.link.linkBtn) {\n editor.controllersOff();\n }\n /** SPAN */\n\n\n if (findSize && /^SPAN$/.test(nodeName)) {\n /** font size */\n if (selectionParent.style.fontSize.length > 0) {\n commandMapNodes.push('SIZE');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap.SIZE, selectionParent.style.fontSize.match(/\\d+/)[0]);\n findSize = false;\n }\n }\n /** command map */\n\n\n cssText = selectionParent.style.cssText;\n\n if (findB && /font\\-weight\\s*:\\s*(?:\\d+|bold|bolder)(?:;|\\s|)/.test(cssText)) {\n commandMapNodes.push('B');\n findB = false;\n }\n\n if (findI && /font\\-style\\s*:\\s*(?:italic|oblique)(?:;|\\s)/.test(cssText)) {\n commandMapNodes.push('I');\n findI = false;\n }\n\n if (findU && /text\\-decoration(?:\\-line)?\\s*:\\s*underline(?:;|\\s|)/.test(cssText)) {\n commandMapNodes.push('U');\n findU = false;\n }\n\n if (findS && /text\\-decoration(?:\\-line)?\\s*:\\s*line-through(?:;|\\s|)/.test(cssText)) {\n commandMapNodes.push('STRIKE');\n findS = false;\n }\n\n commandMapNodes.push(/^STRONG$/.test(nodeName) ? 'B' : /^EM$/.test(nodeName) ? 'I' : nodeName);\n }\n /** A Tag edit controller off */\n\n\n if (findA) editor.controllersOff();\n /** toggle class on */\n\n for (let i = 0; i < commandMapNodes.length; i++) {\n nodeName = commandMapNodes[i];\n\n if (classOnCheck.test(nodeName)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(commandMap[nodeName], 'on');\n }\n }\n /** remove class, display text */\n\n\n for (let key in commandMap) {\n if (commandMapNodes.indexOf(key) > -1) continue;\n\n if (/^FONT/i.test(key)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap[key], lang.toolbar.font);\n } else if (/^SIZE$/i.test(key)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap[key], lang.toolbar.fontSize);\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(commandMap[key], 'on');\n }\n }\n /** save current nodes */\n\n\n editor._variable.currentNodes = currentNodes.reverse();\n /** Displays the current node structure to resizingBar */\n\n if (context.option.showPathLabel) context.element.navigation.textContent = editor._variable.currentNodes.join(' > ');\n },\n _cancelCaptionEdit: function () {\n this.setAttribute('contenteditable', false);\n this.removeEventListener('blur', event._cancelCaptionEdit);\n },\n onClick_toolbar: function (e) {\n e.preventDefault();\n e.stopPropagation();\n let target = e.target;\n let display = target.getAttribute('data-display');\n let command = target.getAttribute('data-command');\n let className = target.className;\n\n while (!command && !/editor_tool/.test(className) && !/sun-editor-id-toolbar/.test(className)) {\n target = target.parentNode;\n command = target.getAttribute('data-command');\n display = target.getAttribute('data-display');\n className = target.className;\n }\n\n if (!command && !display) return;\n if (target.disabled) return;\n /** Dialog, Submenu */\n\n if (display) {\n if (/submenu/.test(display) && (target.nextElementSibling === null || target !== editor.submenuActiveButton)) {\n editor.submenuOff();\n editor.callPlugin(command, function () {\n editor.submenuOn(target);\n });\n return;\n } else if (/dialog/.test(display)) {\n editor.callPlugin(command, function () {\n editor.plugins.dialog.open.call(editor, command, false);\n });\n }\n\n editor.submenuOff();\n return;\n }\n\n editor.submenuOff();\n /** default command */\n\n if (command) {\n editor.focus();\n editor.commandHandler(target, command);\n }\n },\n onClick_wysiwyg: function (e) {\n e.stopPropagation();\n const targetElement = e.target;\n editor.submenuOff();\n\n if (/^IMG$/i.test(targetElement.nodeName)) {\n e.preventDefault();\n editor.callPlugin('image', function () {\n const size = editor.plugins.resizing.call_controller_resize.call(editor, targetElement, 'image');\n editor.plugins.image.onModifyMode.call(editor, targetElement, size);\n\n if (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(targetElement, '.sun-editor-id-image-container')) {\n editor.plugins.image.openModify.call(editor, true);\n editor.plugins.image.update_image.call(editor);\n editor.controllersOff();\n }\n });\n return;\n }\n\n if (/sun-editor-id-iframe-inner-resizing-cover/i.test(targetElement.className)) {\n e.preventDefault();\n editor.callPlugin('video', function () {\n const iframe = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getChildElement(targetElement.parentNode, 'iframe');\n const size = editor.plugins.resizing.call_controller_resize.call(editor, iframe, 'video');\n editor.plugins.video.onModifyMode.call(editor, iframe, size);\n });\n return;\n }\n\n editor._setEditorRange();\n\n event._findButtonEffectTag();\n\n if (editor._isBalloon) {\n const range = editor.getRange();\n\n if (range.collapsed) {\n event._hideToolbar();\n } else {\n event._showToolbarBalloon(range);\n\n return;\n }\n }\n\n const figcaption = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(targetElement, 'FIGCAPTION');\n\n if (figcaption && figcaption.getAttribute('contenteditable') !== 'ture') {\n e.preventDefault();\n figcaption.setAttribute('contenteditable', true);\n figcaption.focus();\n\n if (editor._isInline && !editor._inlineToolbarAttr.isShow) {\n event._showToolbarInline();\n\n const hideToolbar = function () {\n event._hideToolbar();\n\n _d.removeEventListener('click', hideToolbar);\n };\n\n _d.addEventListener('click', hideToolbar);\n }\n } else {\n const td = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(targetElement, _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell);\n\n if (td) {\n if (editor.controllerArray.length === 0) {\n editor.callPlugin('table', editor.plugins.table.call_controller_tableEdit.bind(editor, td));\n }\n }\n }\n\n if (userFunction.onClick) userFunction.onClick(e);\n },\n _showToolbarBalloon: function (range) {\n const toolbar = context.element.toolbar;\n const childNodes = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildNodes(range.commonAncestorContainer);\n\n const selection = _w.getSelection();\n\n const isDirTop = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getArrayIndex(childNodes, selection.focusNode) < _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getArrayIndex(childNodes, selection.anchorNode);\n let rects = range.getClientRects();\n rects = rects[isDirTop ? 0 : rects.length - 1];\n toolbar.style.display = 'block';\n let l = (isDirTop ? rects.left : rects.right) - context.element.topArea.offsetLeft + _w.scrollX - toolbar.offsetWidth / 2;\n let t = (isDirTop ? rects.top - toolbar.offsetHeight - 11 : rects.bottom + 11) - context.element.topArea.offsetTop + _w.scrollY;\n toolbar.style.left = (l < 0 ? 20 : l) + 'px';\n toolbar.style.top = t + 'px';\n\n if (isDirTop) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(context.element._arrow, 'arrow-up');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(context.element._arrow, 'arrow-down');\n context.element._arrow.style.top = toolbar.offsetHeight + 'px';\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(context.element._arrow, 'arrow-down');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(context.element._arrow, 'arrow-up');\n context.element._arrow.style.top = '-11px';\n }\n\n const arrow_width = context.element._arrow.offsetWidth;\n const arrow_left = toolbar.offsetWidth / 2 + (l < 0 ? l - arrow_width : 0);\n context.element._arrow.style.left = (arrow_left < arrow_width / 2 ? arrow_width / 2 - 1 : arrow_left) + 'px';\n },\n _showToolbarInline: function () {\n const toolbar = context.element.toolbar;\n toolbar.style.display = 'block';\n editor._inlineToolbarAttr.width = toolbar.style.width = context.option.toolbarWidth;\n editor._inlineToolbarAttr.top = toolbar.style.top = -1 - toolbar.offsetHeight + 'px';\n event.onScroll_window();\n editor._inlineToolbarAttr.isShow = true;\n },\n _hideToolbar: function () {\n context.element.toolbar.style.display = 'none';\n editor._inlineToolbarAttr.isShow = false;\n },\n onKeyDown_wysiwyg: function (e) {\n const keyCode = e.keyCode;\n const shift = e.shiftKey;\n const ctrl = e.ctrlKey || e.metaKey;\n const alt = e.altKey;\n e.stopPropagation();\n\n if (editor._isBalloon) {\n event._hideToolbar();\n }\n\n function shortcutCommand(keyCode) {\n const key = event._shortcutKeyCode[keyCode];\n if (!key) return false;\n editor.commandHandler(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(editor.getSelectionNode()), key[0]);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(editor.commandMap[key[1]], 'on');\n return true;\n }\n /** Shortcuts */\n\n\n if (ctrl && !/^(?:16|17|18)$/.test(keyCode)) {\n if (!(shift && keyCode !== 83) && shortcutCommand(keyCode)) {\n e.preventDefault();\n return;\n }\n }\n /** default key action */\n\n\n const selectionNode = editor.getSelectionNode();\n\n switch (keyCode) {\n case 8:\n /**backspace key*/\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(selectionNode) && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode.parentNode) && selectionNode.previousSibling === null) {\n e.preventDefault();\n e.stopPropagation();\n selectionNode.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace;\n return false;\n }\n\n break;\n\n case 9:\n /**tab key*/\n e.preventDefault();\n if (ctrl || alt) break;\n editor.controllersOff();\n let currentNode = selectionNode || editor.getSelectionNode();\n\n while (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell(currentNode) && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(currentNode)) {\n currentNode = currentNode.parentNode;\n }\n\n if (currentNode && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell(currentNode)) {\n const table = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(currentNode, 'table');\n const cells = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildren(table, _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell);\n let idx = shift ? _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].prevIdx(cells, currentNode) : _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].nextIdx(cells, currentNode);\n if (idx === cells.length && !shift) idx = 0;\n if (idx === -1 && shift) idx = cells.length - 1;\n const moveCell = cells[idx];\n if (!moveCell) return false;\n editor.setRange(moveCell, 0, moveCell, 0);\n break;\n }\n /** format Tag */\n\n\n const lines = editor.getSelectedFormatElements();\n\n if (!shift) {\n const tabText = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(new Array(editor._variable.tabSize + 1).join('\\u00A0'));\n\n if (lines.length === 1) {\n editor.insertNode(tabText);\n editor.setRange(tabText, editor._variable.tabSize, tabText, editor._variable.tabSize);\n } else {\n for (let i = 0, len = lines.length; i < len; i++) {\n lines[i].insertBefore(tabText.cloneNode(false), lines[i].firstChild);\n }\n }\n } else {\n for (let i = 0, len = lines.length, child; i < len; i++) {\n child = lines[i].firstChild;\n\n if (/^\\s{1,4}$/.test(child.textContent)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(child);\n } else if (/^\\s{1,4}/.test(child.textContent)) {\n child.textContent = child.textContent.replace(/^\\s{1,4}/, '');\n }\n }\n }\n\n break;\n }\n\n if (userFunction.onKeyDown) userFunction.onKeyDown(e);\n },\n onKeyUp_wysiwyg: function (e) {\n editor._setEditorRange();\n\n editor.controllersOff();\n const selectionNode = editor.getSelectionNode();\n /** when format tag deleted */\n\n if (e.keyCode === 8 && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode) && context.element.wysiwyg.textContent.length === 0) {\n e.preventDefault();\n e.stopPropagation();\n const oFormatTag = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(editor._variable.currentNodes[0]) ? editor._variable.currentNodes[0] : 'P');\n oFormatTag.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace;\n selectionNode.appendChild(oFormatTag);\n editor.setSelectionNode(oFormatTag);\n editor.setRange(oFormatTag, 0, oFormatTag, 0);\n return;\n }\n\n if ((_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode.parentElement) || _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(selectionNode.parentElement)) && selectionNode.nodeType === 3) {\n editor.execCommand('formatBlock', false, _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode.parentElement) ? 'P' : 'DIV');\n\n editor._setEditorRange();\n\n event._findButtonEffectTag();\n\n return;\n }\n\n if (event._directionKeyKeyCode.test(e.keyCode)) {\n event._findButtonEffectTag();\n }\n\n if (userFunction.onKeyUp) userFunction.onKeyUp(e);\n },\n onScroll_wysiwyg: function (e) {\n editor.controllersOff();\n if (userFunction.onScroll) userFunction.onScroll(e);\n },\n onDrop_wysiwyg: function (e) {\n const files = e.dataTransfer.files;\n\n if (files.length > 0) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n editor.callPlugin('image', function () {\n context.image.imgInputFile.files = files;\n editor.plugins.image.onRender_imgInput.call(editor);\n context.image.imgInputFile.files = null;\n });\n }\n\n if (userFunction.onDrop) userFunction.onDrop(e);\n },\n onMouseDown_resizingBar: function (e) {\n e.stopPropagation();\n editor._variable.resizeClientY = e.clientY;\n context.element.resizeBackground.style.display = 'block';\n\n function closureFunc() {\n context.element.resizeBackground.style.display = 'none';\n\n _d.removeEventListener('mousemove', event._resize_editor);\n\n _d.removeEventListener('mouseup', closureFunc);\n }\n\n _d.addEventListener('mousemove', event._resize_editor);\n\n _d.addEventListener('mouseup', closureFunc);\n },\n _resize_editor: function (e) {\n const resizeInterval = context.element.editorArea.offsetHeight + (e.clientY - editor._variable.resizeClientY);\n context.element.wysiwyg.style.height = context.element.code.style.height = (resizeInterval < editor._variable.minResizingSize ? editor._variable.minResizingSize : resizeInterval) + 'px';\n editor._variable.resizeClientY = e.clientY;\n },\n onResize_window: function () {\n if (context.element.topArea.offsetWidth === 0) return;\n\n if (editor._variable.isFullScreen) {\n editor._variable.innerHeight_fullScreen += _w.innerHeight - context.element.toolbar.offsetHeight - editor._variable.innerHeight_fullScreen;\n context.element.editorArea.style.height = editor._variable.innerHeight_fullScreen + 'px';\n } else if (editor._variable._sticky) {\n context.element.toolbar.style.width = context.element.topArea.offsetWidth - 2 + 'px';\n event.onScroll_window();\n }\n\n editor.controllersOff();\n },\n onScroll_window: function () {\n if (editor._variable.isFullScreen || context.element.topArea.offsetWidth === 0) return;\n const element = context.element;\n const editorHeight = element.editorArea.offsetHeight;\n const editorTop = element.topArea.offsetTop - (editor._isInline ? element.toolbar.offsetHeight : 0);\n const y = (this.scrollY || _d.documentElement.scrollTop) + context.option.stickyToolbar;\n\n if (y < editorTop) {\n event._offStickyToolbar(element);\n } else if (y + editor._variable.minResizingSize >= editorHeight + editorTop) {\n if (!editor._variable._sticky) event._onStickyToolbar(element);\n element.toolbar.style.top = editorHeight + editorTop + context.option.stickyToolbar - y - editor._variable.minResizingSize + 'px';\n } else if (y >= editorTop) {\n event._onStickyToolbar(element);\n }\n },\n _onStickyToolbar: function (element) {\n if (!editor._isInline) {\n element._stickyDummy.style.height = element.toolbar.offsetHeight + 'px';\n element._stickyDummy.style.display = 'block';\n }\n\n element.toolbar.style.top = context.option.stickyToolbar + 'px';\n element.toolbar.style.width = editor._isInline ? editor._inlineToolbarAttr.width : element.toolbar.offsetWidth + 'px';\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(element.toolbar, 'sun-editor-sticky');\n editor._variable._sticky = true;\n },\n _offStickyToolbar: function (element) {\n element._stickyDummy.style.display = 'none';\n element.toolbar.style.top = editor._isInline ? editor._inlineToolbarAttr.top : '';\n element.toolbar.style.width = editor._isInline ? editor._inlineToolbarAttr.width : '';\n element.editorArea.style.marginTop = '';\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(element.toolbar, 'sun-editor-sticky');\n editor._variable._sticky = false;\n },\n _codeViewAutoScroll: function () {\n context.element.code.style.height = context.element.code.scrollHeight + 'px';\n },\n onPaste_wysiwyg: function (e) {\n if (!e.clipboardData.getData) return true;\n const cleanData = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cleanHTML(e.clipboardData.getData('text/html'));\n\n if (cleanData) {\n editor.execCommand('insertHTML', false, cleanData);\n e.stopPropagation();\n e.preventDefault();\n }\n }\n };\n /** add event listeners */\n\n /** toolbar event */\n\n context.element.toolbar.addEventListener('click', event.onClick_toolbar, false);\n context.element.toolbar.addEventListener('mousedown', function (e) {\n e.preventDefault();\n }, false);\n /** editor area */\n\n context.element.relative.addEventListener('click', editor.focus.bind(editor), false);\n context.element.wysiwyg.addEventListener('click', event.onClick_wysiwyg, false);\n context.element.wysiwyg.addEventListener('scroll', event.onScroll_wysiwyg, false);\n context.element.wysiwyg.addEventListener('keydown', event.onKeyDown_wysiwyg, false);\n context.element.wysiwyg.addEventListener('keyup', event.onKeyUp_wysiwyg, false);\n context.element.wysiwyg.addEventListener('drop', event.onDrop_wysiwyg, false);\n context.element.wysiwyg.addEventListener('paste', event.onPaste_wysiwyg, false);\n /** code view area auto line */\n\n if (context.option.height === 'auto') context.element.code.addEventListener('keyup', event._codeViewAutoScroll, false);\n /** resizingBar */\n\n if (context.element.resizingBar) {\n if (/\\d+/.test(context.option.height)) {\n context.element.resizingBar.addEventListener('mousedown', event.onMouseDown_resizingBar, false);\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(context.element.resizingBar, 'none-resize');\n }\n }\n /** inlineToolbar */\n\n\n if (editor._isInline) {\n context.element.wysiwyg.addEventListener('focus', event._showToolbarInline, false);\n }\n\n if (editor._isInline || editor._isBalloon) {\n context.element.wysiwyg.addEventListener('blur', event._hideToolbar, false);\n }\n /** window event */\n\n\n _w.addEventListener('resize', event.onResize_window, false);\n\n if (context.option.stickyToolbar > -1) _w.addEventListener('scroll', event.onScroll_window, false);\n /** add plugin to plugins object */\n\n if (plugins) {\n Object.keys(plugins).map(function (key) {\n let plugin = plugins[key];\n editor.plugins[plugin.name] = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].copyObj(plugin);\n });\n }\n /** User function */\n\n\n const userFunction = {\n /**\r\n * @description Event functions\r\n * @param {Object} event - Event Object\r\n */\n onScroll: null,\n onClick: null,\n onKeyDown: null,\n onKeyUp: null,\n onDrop: null,\n\n /**\r\n * @description Called when the image is uploaded or the uploaded image is deleted\r\n * @param {Element} targetImgElement - Current img element\r\n * @param {Number} index - Uploaded index\r\n * @param {Boolean} isDelete - Whether or not it was called after the delete operation\r\n */\n onImageUpload: null,\n\n /**\r\n * @description Open a notice area\r\n * @param {String} message - Notice message\r\n */\n noticeOpen: function (message) {\n editor.addModule([_plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"]]);\n _plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"].open.call(editor, message);\n },\n\n /**\r\n * @description Close a notice area\r\n */\n noticeClose: function () {\n editor.addModule([_plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"]]);\n _plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"].close.call(editor);\n },\n\n /**\r\n * @description Copying the contents of the editor to the original textarea\r\n */\n save: function () {\n context.element.originElement.value = editor.getContents();\n },\n\n /**\r\n * @description Gets the suneditor's context object. Contains settings, plugins, and cached element objects\r\n * @returns {Object}\r\n */\n getContext: function () {\n return context;\n },\n\n /**\r\n * @description Gets the contents of the suneditor\r\n * @returns {String}\r\n */\n getContents: function () {\n return editor.getContents();\n },\n\n /**\r\n * @description Gets uploaded images informations\r\n * @returns {Array}\r\n */\n getImagesInfo: function () {\n return editor._variable._imagesInfo;\n },\n\n /**\r\n * @description Inserts an HTML element or HTML string or plain string at the current cursor position\r\n * @param {Element|String} html - HTML Element or HTML string or plain string\r\n */\n insertHTML: function (html) {\n if (!html.nodeType || html.nodeType !== 1) {\n const template = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement('template');\n template.innerHTML = html;\n html = template.firstChild || template.content.firstChild;\n }\n\n editor.insertNode(html);\n editor.focus();\n },\n\n /**\r\n * @description Change the contents of the suneditor\r\n * @param {String} contents - Contents to Input\r\n */\n setContents: function (contents) {\n if (editor._variable.wysiwygActive) {\n context.element.wysiwyg.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertContentsForEditor(contents);\n } else {\n context.element.code.value = contents;\n }\n },\n\n /**\r\n * @description Add contents to the suneditor\r\n * @param {String} contents - Contents to Input\r\n */\n appendContents: function (contents) {\n if (editor._variable.wysiwygActive) {\n context.element.wysiwyg.innerHTML += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertContentsForEditor(contents);\n } else {\n context.element.code.value += contents;\n }\n },\n\n /**\r\n * @description Disable the suneditor\r\n */\n disabled: function () {\n context.tool.cover.style.display = 'block';\n context.element.wysiwyg.setAttribute('contenteditable', false);\n context.element.code.setAttribute('disabled', 'disabled');\n },\n\n /**\r\n * @description Enabled the suneditor\r\n */\n enabled: function () {\n context.tool.cover.style.display = 'none';\n context.element.wysiwyg.setAttribute('contenteditable', true);\n context.element.code.removeAttribute('disabled');\n },\n\n /**\r\n * @description Show the suneditor\r\n */\n show: function () {\n const topAreaStyle = context.element.topArea.style;\n if (topAreaStyle.display === 'none') topAreaStyle.display = context.option.display;\n },\n\n /**\r\n * @description Hide the suneditor\r\n */\n hide: function () {\n context.element.topArea.style.display = 'none';\n },\n\n /**\r\n * @description Destroy the suneditor\r\n */\n destroy: function () {\n /** remove window event listeners */\n _w.removeEventListener('resize', event.onResize_window);\n\n _w.removeEventListener('scroll', event.onScroll_window);\n /** remove element */\n\n\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(context.element.topArea);\n this.onScroll = null;\n this.onClick = null;\n this.onKeyDown = null;\n this.onKeyUp = null;\n this.onDrop = null;\n this.save = null;\n this.onImageUpload = null;\n this.noticeOpen = null;\n this.noticeClose = null;\n this.getContext = null;\n this.getContents = null;\n this.getImagesInfo = null;\n this.insertHTML = null;\n this.setContents = null;\n this.appendContents = null;\n this.disabled = null;\n this.enabled = null;\n this.show = null;\n this.hide = null;\n this.destroy = null;\n context = null;\n plugins = null;\n lang = null;\n }\n };\n return userFunction;\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (core);//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-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amVjdFxyXG4gICAgICogc2hvdWxkIGFsd2F5cyBiaW5kIHRoaXMgb2JqZWN0IHdoZW4gcmVnaXN0ZXJpbmcgYW4gZXZlbnQgaW4gdGhlIHBsdWctaW4uXHJcbiAgICAgKi9cclxuICAgIGNvbnN0IGVkaXRvciA9IHtcclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRWxlbWVudHMgYW5kIHVzZXIgb3B0aW9ucyBwYXJhbWV0ZXJzIG9mIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKi9cclxuICAgICAgICBjb250ZXh0OiBjb250ZXh0LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gbG9hZGVkIHBsdWdpbnNcclxuICAgICAgICAgKi9cclxuICAgICAgICBwbHVnaW5zOiB7fSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIFdoZXRoZXIgdGhlIHBsdWdpbiBpcyBpbml0aWFsaXplZFxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGluaXRQbHVnaW5zOiB7fSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIGxvYWRlZCBsYW5ndWFnZVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGxhbmc6IGxhbmcsXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBkaWFsb2cgZWxlbWVudFxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGRpYWxvZ0Zvcm06IG51bGwsXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBzdWJtZW51IGVsZW1lbnRcclxuICAgICAgICAgKi9cclxuICAgICAgICBzdWJtZW51OiBudWxsLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gYWN0aXZlIGJ1dHRvbiBlbGVtZW50IGluIHN1Ym1lbnVcclxuICAgICAgICAgKi9cclxuICAgICAgICBzdWJtZW51QWN0aXZlQnV0dG9uOiBudWxsLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gVGhlIGVsZW1lbnRzIGFycmF5IHRvIGJlIHByb2Nlc3NlZCB1bnZpc2libGUgd2hlbiB0aGUgY29udHJvbGxlcnNPZmYgZnVuY3Rpb24gaXMgZXhlY3V0ZWQgKHJlc2l6aW5nLCBsaW5rIG1vZGlmaWVkIGJ1dHRvbiwgdGFibGUgY29udHJvbGxlcilcclxuICAgICAgICAgKi9cclxuICAgICAgICBjb250cm9sbGVyQXJyYXk6IFtdLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gVGhlIGZ1bmN0aW9ucyBhcnJheSB0byBiZSBleGVjdXRlZCB3aGVuIHRoZSBjb250cm9sbGVyc09mZiBmdW5jdGlvbiBpcyBleGVjdXRlZCBleCkgaW5pdCBmdW5jdGlvbiBvZiB0YWJsZSBwbHVnaW5cclxuICAgICAgICAgKi9cclxuICAgICAgICBjb250cm9sbGVyRnVuY3Rpb246IFtdLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQW4gYXJyYXkgb2YgYnV0dG9ucyB3aG9zZSBjbGFzcyBuYW1lIGlzIG5vdCBcImNvZGUtdmlldy1lbmFibGVkXCJcclxuICAgICAgICAgKi9cclxuICAgICAgICBjb2RlVmlld0Rpc2FibGVkQnV0dG9uczogY29udGV4dC5lbGVtZW50LnRvb2xiYXIucXVlcnlTZWxlY3RvckFsbCgnLnN1bi1lZGl0b3ItaWQtdG9vbGJhciBidXR0b246bm90KFtjbGFzc349XCJjb2RlLXZpZXctZW5hYmxlZFwiXSknKSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIElzIGlubGluZSBtb2RlP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DtcclxuXHJcbiAgICAgICAgICAgIGlmIChsZW4gPiAwKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyQXJyYXlbaV0uc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHRoaXMuY29udHJvbGxlckFycmF5ID0gW107XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmIChmTGVuID4gMCkge1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBmTGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRyb2xsZXJGdW5jdGlvbltpXSgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyRnVuY3Rpb24gPSBbXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBqYXZhc2NyaXB0IGV4ZWNDb21tYW5kXHJcbiAgICAgICAgICogQHBhcmFtIHtTdHJpbmd9IGNvbW1hbmQgLSBqYXZhc2NyaXB0IGV4ZWNDb21tYW5kIGZ1bmN0aW9uIHByb3BlcnR5XHJcbiAgICAgICAgICogQHBhcmFtIHtCb29sZWFufSBzaG93RGVmYXVsdFVJIC0gamF2YXNjcmlwdCBleGVjQ29tbWFuZCBmdW5jdGlvbiBwcm9wZXJ0eVxyXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfSB2YWx1ZSAtIGphdmFzY3JpcHQgZXhlY0NvbW1hbmQgZnVuY3Rpb24gcHJvcGVydHlcclxuICAgICAgICAgKi9cclxuICAgICAgICBleGVjQ29tbWFuZDogZnVuY3Rpb24gKGNvbW1hbmQs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ICAqIEBwcml2YXRlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgX3NldEVkaXRvclJhbmdlOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHNlbGVjdGlvbiA9IF93LmdldFNlbGVjdGlvbigpO1xyXG4gICAgICAgICAgICBsZXQgcmFuZ2UgPSBudWxsO1xyXG5cclxuICAgICAgICAgICAgaWYgKHNlbGVjdGlvbi5yYW5nZUNvdW50ID4gMCkge1xyXG4gICAgICAgICAgICAgICAgcmFuZ2UgPSBzZWxlY3Rpb24uZ2V0UmFuZ2VBdCgwKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHJhbmdlID0gdGhpcy5fY3JlYXRlRGVmYXVsdFJhbmdlKCk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHRoaXMuX3ZhcmlhYmxlLnJhbmdlID0gcmFuZ2U7XHJcblxyXG4gICAgICAgICAgICBpZiAocmFuZ2UuY29sbGFwc2VkKSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnNldFNlbGVjdGlvbk5vZGUocmFuZ2UuY29tbW9uQW5jZXN0b3JDb250YWluZXIpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zZXRTZWxlY3Rpb25Ob2RlKHNlbGVjdGlvbi5leHRlbnROb2RlIHx8IHNlbGVjdGlvbi5hbmNob3JOb2RlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBSZXR1cm4gdGhlIHJhbmdlIG9iamVjdCBvZiBlZGl0b3IncyBmaXJzdCBjaGlsZCBub2RlXHJcbiAgICAgICAgICogQHJldHVybnMge09iamVjdH1cclxuICAgICAgICAgKiBAcHJpdmF0ZVxyXG4gICAgICAgICAqL1xyXG4gIC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XG4gICAgICAgICAqL1xyXG4gICAgICAgIHNldFNlbGVjdGlvbk5vZGU6IGZ1bmN0aW9uIChub2RlKSB7XHJcbiAgICAgICAgICAgIHRoaXMuX3ZhcmlhYmxlLnNlbGVjdGlvbk5vZGUgPSBub2RlO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBHZXQgY3VycmVudCBzZWxlY3Qgbm9kZVxyXG4gICAgICAgICAqIEByZXR1cm5zIHtOb2RlfVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGdldFNlbGVjdGlvbk5vZGU6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgaWYgKHRoaXMuX3ZhcmlhYmxlLnNlbGVjdGlvbk5vZGUpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl92YXJpYWJsZS5zZWxlY3Rpb25Ob2RlO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuZmlyc3RDaGlsZDtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gUmV0dXJucyBhIFwiZm9ybWF0RWxlbWVudFwiKFAsIERJViwgSFsxLTZdLCBMSSkgYXJyYXkgZnJvbSB0aGUgY3VycmVudGx5IHNlbGVjdGVkIHJhbmdlLlxyXG4gICAgICAgICAqIEByZXR1cm5zIHtBcnJheX1cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRTZWxlY3RlZEZvcm1hdEVsZW1lbnRzOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGxldCByYW5nZSA9IHRoaXMuZ2V0UmFuZ2UoKTtcclxuXHJcbiAgICAgICAgICAgIGlmICh1dGlsLmlzV3lzaXd5Z0RpdihyYW5nZS5zdGFydENvbnRhaW5lcikpIHtcclxuICAgICAgICAgICAgICA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pIHJldHVybiBsaW5lTm9kZXNbMF07XHJcblxyXG4gICAgICAgICAgICBsZXQgc3RhcnRMaW5lID0gdXRpbC5nZXRGb3JtYXRFbGVtZW50KHN0YXJ0Q29uKTtcclxuICAgICAgICAgICAgbGV0IGVuZExpbmUgPSB1dGlsLmdldEZvcm1hdEVsZW1lbnQoZW5kQ29uKTtcclxuICAgICAgICAgICAgbGV0IHN0YXJ0SWR4ID0gMDtcclxuICAgICAgICAgICAgbGV0IGVuZElkeCA9IDA7XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gbGluZU5vZGVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoc3RhcnRMaW5lID09PSBsaW5lTm9kZXNbaV0pIHtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydElkeCA9IGk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZW5kTGluZSA9PT0gbGluZU5vZGVzW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZW5kSWR4ID0gaTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IHN0YXJ0SWR4OyBpIDw9IGVuZElkeDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICByYW5nZUZvcm1hdEVsZW1lbnRzLnB1c2gobGluZU5vZGVzW2ldKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHJhbmdlRm9ybWF0RWxlbWVudHM7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIFJldHVybnMgYSBcInJhbmdlRm9ybWF0RWxlbWVudFwiKGJsb2NrcX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tb25Db25dO1xyXG4gICAgICAgICAgICBpZiAoIXV0aWwuaXNXeXNpd3lnRGl2KGNvbW1vbkNvbikpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGVsID0gdXRpbC5nZXRSYW5nZUZvcm1hdEVsZW1lbnQoY29tbW9uQ29uKTtcclxuICAgICAgICAgICAgICAgIHJldHVybiBlbCA/IFtlbF0gOiBbXTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLy8gZ2V0IHJhbmdlIEVsZW1lbnRzXHJcbiAgICAgICAgICAgIGNvbnN0IHJhbmdlRWxlbWVudHMgPSB1dGlsLmdldExpc3RDaGlsZHJlbihjb21tb25Db24sIGZ1bmN0aW9uIChjdXJyZW50KSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gdXRpbC5pc1JhbmdlRm9ybWF0RWxlbWVudChjdXJyZW50KTtcclxuICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICBpZiAoc3RhcnRDb24gPT09IGVuZENvbikgcmV0dXJuIHJhbmdlRWxlbWVudHNbMF07XHJcblxyXG4gICAgICAgICAgICBsZXQgc3RhcnRMaW5lID0gdXRpbC5nZXRSYW5nZUZvcm1hdEVsZW1lbnQoc3RhcnRDb24pO1xyXG4gICAgICAgICAgICBsZXQgZW5kTGluZSA9IHV0aWwuZ2V0UmFuZ2VGb3JtYXRFbGVtZW50KGVuZENvbik7XHJcbiAgICAgICAgICAgIGxldCBzdGFydElkeCA9IDA7XHJcbiAgICAgICAgICAgIGxldCBlbmRJZHggPSAwO1xyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IHJhbmdlRWxlbWVudHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgIGlmIChzdGFydExpbmUgPT09IHJhbmdlRWxlbWVudHNbaV0pIHtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydElkeCA9IGk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZW5kTGluZSA9PT0gcmFuZ2VFbGVtZW50c1tpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGVuZElkeCA9IGk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBzdGFydElkeDsgaSA8PSBlbmRJZHg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgaWYgKHJhbmdlRWxlbWVudHNbaV0pIHJhbmdlRm9ybWF0RWxlbWVudHMucHVzaChyYW5nZUVsZW1lbnRzW2ldKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHJhbmdlRm9ybWF0RWxlbWVudHM7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIERldGVybWluZSBpZiB0aGlzIG9mZnNldCBpcyB0aGUgZWRnZSBvZmZzZXQgb2YgY29udGFpbmVyXHJcbiAgICAgICAgICogQHBhcmFtIHtPYmplY3R9IGNvbnRhaW5lciAtIFRoZSBjb250YWluZXIgcHJvcGVydHkgb2YgdGhlIHNlbGVjdGlvbiBvYmplY3QuXHJcbiAgICAgICAgICogQHBhcmFtIHtOdW1iZXJ9IG9mZnNldCAtIFRoZSBvZmZzZXQgcHJvcGVydHkgb2YgdGhlIHNlbGVjdGlvbiBvYmplY3QuXHJcbiAgICAgICAgICogQHJldHVybnMge0Jvb2xlYW59XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgaXNFZGdlUG9pbnQ6IGZ1bmN0aW9uIChjb250YWluZXIsIG9mZnNldCkge1xyXG4gICAgICAgICAgICByZXR1cm4gKG9mZnNldCA9PT0gMCkgfHwgKG9mZnNldCA9PT0gY29udGFpbmVyLm5v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Lm5vZGVUeXBlID09PSAzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZSA9IHN0YXJ0Q29uLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIE5vIFNlbGVjdCByYW5nZSBub2RlICovXHJcbiAgICAgICAgICAgICAgICBpZiAocmFuZ2UuY29sbGFwc2VkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbW1vbkNvbi5ub2RlVHlwZSA9PT0gMykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByaWdodE5vZGUgPSBjb21tb25Db24uc3BsaXRUZXh0KGVuZE9mZik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyZW50Tm9kZS5sYXN0Q2hpbGQgIT09IG51bGwgJiYgdXRpbC5pc0JyZWFrKHBhcmVudE5vZGUubGFzdENoaWxkKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5yZW1vdmVDaGlsZChwYXJlbnROb2RlLmxhc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmlnaHROb2RlID0gbnVsbDtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAvKiogU2VsZWN0IHJhbmdlIG5vZGVzICovXHJcbiAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NhbWVDb250YWluZXIgPSBzdGFydENvbiA9PT0gZW5kQ29uO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoaXNTYW1lQ29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRWRnZVBvaW50KGVuZENvbiwgZW5kT2ZmKSkgcmlnaHROb2RlID0gZW5kQ29uLm5leHRTaWJsaW5nO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHJpZ2h0Tm9kZSA9IGVuZENvbi5zcGxpdFRleHQoZW5kT2ZmKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZW1vdmVOb2RlID0gc3RhcnRDb247XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VkZ2VQb2ludChzdGFydENvbiwgc3RhcnRPZmYpKSByZW1vdmVOb2RlID0gc3RhcnRDb24uc3BsaXRUZXh0KHN0YXJ0T2ZmKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudE5vZGUucmVtb3ZlQ2hpbGQocmVtb3ZlTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlbW92ZU5vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZSA9IGNvbW1vbkNvbjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmlnaHROb2RlID0gZW5kQ29uO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHJpZ2h0Tm9kZS5wYXJlbnROb2RlICE9PSBjb21tb25Db24pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IHJpZ2h0Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgcGFyZW50Tm9kZSA9IHJpZ2h0Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgcmlnaHROb2RlID0gcmlnaHROb2RlLm5leHRTaWJsaW5nO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUob05vZGUsIHJpZ2h0Tm9kZSk7XHJcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUuYXBwZW5kQ2hpbGQob05vZGUpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIERlbGV0ZSB0aGUgY3VycmVudGx5IHNlbGVjdGVkIG5vZGVcclxuICAgICAgICAgKi9cclxuICAgICAgICByZW1vdmVOb2RlOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHJhbmdlID0gdGhpcy5nZXRSYW5nZSgpO1xyXG5cclxuICAgICAgICAgICAgaWYgKHJhbmdlLmRlbGV0ZUNvbnRlbnRzKSB7XHJcbiAgICAgICAgICAgICAgICByYW5nZS5kZWxldGVDb250ZW50cygpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBjb25zdCBzdGFydENvbiA9IHJhbmdlLnN0YXJ0Q29udGFpbmVyO1xyXG4gICAgICAgICAgICBjb25zdCBzdGFydE9mZiA9IHJhbmdlLnN0YXJ0T2Zmc2V0O1xyXG4gICAgICAgICAgICBjb25zdCBlbmRDb24gPSByYW5nZS5lbmRDb250YWluZXI7XHJcbiAgICAgICAgICAgIGNvbnN0IGVuZE9mZiA9IHJhbmdlLmVuZE9mZnNldDtcclxuICAgICAgICAgICAgY29uc3QgY29tbW9uQ29uID0gcmFuZ2UuY29tbW9uQW5jZXN0b3JDb250YWluZXI7XHJcblxyXG4gICAgICAgICAgICBsZXQgYmVmb3JlTm9kZSA9IG51bGw7XHJcbiAgICAgICAgICAgIGxldCBhZnRlck5vZGUgPSBudWxsO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlcyA9IHV0aWwuZ2V0TGlzdENoaWxkTm9kZXMoY29tbW9uQ29uKTtcclxuICAgICAgICAgICAgbGV0IHN0YXJ0SW5kZXggPSB1dGlsLmdldEFycmF5SW5kZXgoY2hpbGROb2Rlcywgc3RhcnRDb24pO1xyXG4gICAgICAgICAgICBsZXQgZW5kSW5kZXggPSB1dGlsLmdldEFycmF5SW5kZXgoY2hpbGROb2RlcywgZW5kQ29uKTtcclxuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBzdGFydEluZGV4ICsgMSwgc3RhcnROb2RlID0gc3RhcnRDb247IGkgPj0gMDsgaS0tKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoY2hpbGROb2Rlc1tpXSA9PT0gc3RhcnROb2RlLnBhcmVudE5vZGUgJiYgY2hpbGROb2Rlc1tpXS5maXJzdENoaWxkID09PSBzdGFydE5vZGUgJiYgc3RhcnRPZmYgPT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaTtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydE5vZGUgPSBzdGFydE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IGVuZEluZGV4IC0gMSwgZW5kTm9kZSA9IGVuZENvbjsgaSA+IHN0YXJ0SW5kZXg7IGktLSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkTm9kZXNbaV0gPT09IGVuZE5vZGUucGFyZW50Tm9kZSAmJiBjaGlsZE5vZGVzW2ldLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY2hpbGROb2Rlcy5zcGxpY2UoaSwgMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZW5kTm9kZSA9IGVuZE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAtLWVuZEluZGV4O1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleDsgaSA8PSBlbmRJbmRleDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gY2hpbGROb2Rlc1tpXTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaXRlbS5sZW5ndGggPT09IDAgfHwgKGl0ZW0ubm9kZVR5cGUgPT09IDMgJiYgaXRlbS5kYXRhID09PSB1bmRlZmluZWQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGl0ZW0pO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpdGVtID09PSBzdGFydENvbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdGFydENvbi5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiZWZvcmVOb2RlID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShzdGFydENvbi50ZXh0Q29udGVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmVmb3JlTm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb24uc3Vic3RyaW5nRGF0YSgwLCBzdGFydE9mZikpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJlZm9yZU5vZGUubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbi5kYXRhID0gYmVmb3JlTm9kZS5kYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShzdGFydENvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaXRlbSA9PT0gZW5kQ29uKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVuZENvbi5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhZnRlck5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKGVuZENvbi50ZXh0Q29udGVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYWZ0ZXJOb2RlID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShlbmRDb24uc3Vic3RyaW5nRGF0YShlbmRPZmYsIChlbmRDb24ubGVuZ3RoIC0gZW5kT2ZmKSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFmdGVyTm9kZS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVuZENvbi5kYXRhID0gYWZ0ZXJOb2RlLmRhdGE7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGVuZENvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oaXRlbSk7XHJcbi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Vmb3JlVGFnLCBwRWxlbWVudDtcclxuXHJcbiAgICAgICAgICAgIGlmICh1dGlsLmlzUmFuZ2VGb3JtYXRFbGVtZW50KGxhc3QpIHx8IHV0aWwuaXNGb3JtYXRFbGVtZW50KGxhc3QpKSB7XHJcbiAgICAgICAgICAgICAgICBzdGFuZFRhZyA9IGxhc3Q7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBzdGFuZFRhZyA9IHV0aWwuZ2V0UmFuZ2VGb3JtYXRFbGVtZW50KGxhc3QpIHx8IHV0aWwuZ2V0Rm9ybWF0RWxlbWVudChsYXN0KTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKHV0aWwuaXNDZWxsKHN0YW5kVGFnKSkge1xyXG4gICAgICAgICAgICAgICAgYmVmb3JlVGFnID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIHBFbGVtZW50ID0gc3RhbmRUYWc7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBiZWZvcmVUYWcgPSBzdGFuZFRhZy5uZXh0U2libGluZztcclxuICAgICAgICAgICAgICAgIHBFbGVtZW50ID0gc3RhbmRUYWcucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgbGV0IGxpc3RQYXJlbnQgPSBudWxsO1xyXG4gICAgICAgICAgICBsZXQgbGluZSA9IG51bGw7XHJcbiAgICAgICAgICAgIGxldCBwcmV2Tm9kZU5hbWUgPSAnJztcclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSByYW5nZUxpbmVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBsaW5lID0gcmFuZ2VMaW5lc1tpXTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoL15MSSQvaS50ZXN0KGxpbmUubm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGxpc3RQYXJlbnQgPT09IG51bGwgfHwgIS9eTEkkL2kudGVzdChwcmV2Tm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RQYXJlbnQgPSB1dGlsLmNyZWF0ZUVsZW1lbnQobGluZS5wYXJlbnROb2RlLm5vZGVOYW1lKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxpc3RQYXJlbnQuYXBwZW5kQ2hpbGQobGluZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IGxlbiAtIDEgfHwgIS9eTEkkL2kudGVzdChyYW5nZUxpbmVzW2kgKyAxXS5ub2RlTmFtZSkpIHdyYXBUYWcuYXBwZW5kQ2hpbGQobGlzdFBhcmVudCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICB3cmFwVGFnLmFwcGVuZENoaWxkKGxpbmUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHByZXZOb2RlTmFtZSA9IGxpbmUubm9kZU5hbWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHBFbGVtZW50Lmluc2VydEJlZm9yZSh3cmFwVGFnLCBiZWZvcmVUYWcpO1xyXG4gICAgICAgICAgICBpZiAoIXJhbmdlLmNvbGxhcHNlZCAmJiAodXRpbC5pc1JhbmdlRm9ybWF0RWxlbWVudChyYW5nZS5zdGFydENvbnRhaW5lcikgfHwgdXRpbC5pc1JhbmdlRm9ybWF0RWxlbWVudChyYW5nZS5lbmRDb250YWluZXIpKSkgdXRpbC5yZW1vdmVFbXB0eU5vZGUocEVsZW1lbnQpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbi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9kZVR5cGUgPT09IDEgJiYgc05vZGUuc3R5bGVbY2hlY2tDU1NQcm9wZXJ0eUFycmF5W2ldXSA9PT0gYXBwZW5kTm9kZS5zdHlsZVtjaGVja0NTU1Byb3BlcnR5QXJyYXlbaV1dKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tDbnQrKztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNOb2RlID0gc05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgIFxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChjaGVja0NudCA+PSBjaGVja0NTU1Byb3BlcnR5QXJyYXkubGVuZ3RoKSByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qIGZpbmQgdGV4dCBub2RlICovXHJcbiAgICAgICAgICAgIHRlbXBDb24gPSByYW5nZS5zdGFydENvbnRhaW5lcjtcclxuICAgICAgICAgICAgdGVtcE9mZnNldCA9IHJhbmdlLnN0YXJ0T2Zmc2V0O1xyXG5cclxuICAgICAgICAgICAgaWYgKHRlbXBDb24ubm9kZVR5cGUgPT09IDEgJiYgdGVtcENvbi5jaGlsZE5vZGVzLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgIHdoaWxlICh0ZW1wQ29uICYmICF1dGlsLmlzQnJlYWsodGVtcENvbikgJiYgdGVtcENvbi5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRlbXBBcnJheSA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgIHRlbXBDaGlsZCA9IHRlbXBDb24uY2hpbGROb2RlcztcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gdGVtcENoaWxkLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRlbXBBcnJheS5wdXNoKHRlbXBDaGlsZFtpXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHRlbXBDb24gPSB0ZW1wQXJyYXlbdGVtcE9mZnNldF0gfHwgdGVtcENvbi5uZXh0RWxlbWVudFNpYmxpbmcgfHwgdGVtcENvbi5uZXh0U2libGluZztcclxuICAgICAgICAgICAgICAgICAgICB0ZW1wT2Zmc2V0ID0gMDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3Qgc3RhcnRDb24gPSB0ZW1wQ29uO1xyXG4gICAgICAgICAgICBjb25zdCBzdGFydE9mZiA9IHRlbXBPZmZzZXQ7XHJcblxyXG4gICAgICAgICAgICB0ZW1wQ29uID0gcmFuZ2UuZW5kQ29udGFpbmVyO1xyXG4gICAgICAgICAgICB0ZW1wT2Zmc2V0ID0gcmFuZ2UuZW5kT2Zmc2V0O1xyXG4gICAgICAgICAgICBpZiAodGVtcENvbi5ub2RlVHlwZSA9PT0gMSAmJiB0ZW1wQ29uLmNoaWxkTm9kZXMubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgd2hpbGUgKHRlbXBDb24gJiYgIXV0aWwuaXNCcmVhayh0ZW1wQ29uKSAmJiB0ZW1wQ29uLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGVtcEFycmF5ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgdGVtcENoaWxkID0gdGVtcENvbi5jaGlsZE5vZGVzO1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSB0ZW1wQ2hpbGQubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGVtcEFycmF5LnB1c2godGVtcENoaWxkW2ldKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgdGVtcENvbiA9IHRlbXBBcnJheVt0ZW1wT2Zmc2V0IC0gMV0gfHwgdGVtcEFycmF5WzBdIHx8IHRlbXBDb24ucHJldmlvdXNFbGVtZW50U2libGluZyB8fCB0ZW1wQ29uLnByZXZpb3VzU2libGluZyB8fCBzdGFydENvbjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHRlbXBPZmZzZXQgPSB0ZW1wQ29uLnRleHRDb250ZW50Lmxlbmd0aDtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3QgZW5kQ29uID0gdGVtcENvbjtcclxuICAgICAgICAgICAgY29uc3QgZW5kT2ZmID0gdGVtcE9mZnNldDtcclxuICAgICAgICAgICAgY29uc3QgY29tbW9uQ29uID0gcmFuZ2UuY29tbW9uQW5jZXN0b3JDb250YWluZXI7XHJcbiAgICAgICAgICAgIGNvbnN0IG5ld05vZGVOYW1lID0gYXBwZW5kTm9kZS5ub2RlTmFtZTtcclxuXHJcbiAgICAgICAgICAgIGxldCBzdGFydCA9IHt9LCBlbmQgPSB7fTtcclxuICAgICAgICAgICAgbGV0IG5ld05vZGUsIHJlZ0V4cDtcclxuXHJcbiAgICAgICAgICAgIGlmIChjaGVja0NTU1Byb3BlcnR5QXJyYXkpIHtcclxuICAgICAgICAgICAgICAgIHJlZ0V4cCA9ICcoPzo7fF58XFxcXHMpKD86JyArIGNoZWNrQ1NTUHJvcGVydHlBcnJheVswXTtcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgY2hlY2tDU1NQcm9wZXJ0eUFycmF5Lmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmVnRXhwICs9ICd8JyArIGNoZWNrQ1NTUHJvcGVydHlBcnJheVtpXTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHJlZ0V4cCArPSAnKVxcXFxzKjpbXjtdKlxcXFxzKig/Ojt8JCknO1xyXG4gICAgICAgICAgICAgICAgcmVnRXhwID0gbmV3IFJlZ0V4cChyZWdFeHAsICdpZycpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogdGFnIGNoZWNrIGZ1bmN0aW9uKi9cclxuICAgICAgICAgICAgY29uc3QgY2hlY2tDc3MgPSBmdW5jdGlvbiAodk5vZGUpIHtcclxuICAgICAgICAgICAgICAgIGlmIChpc1JlbW92ZUZvcm1hdCB8fCB2Tm9kZS5ub2RlVHlwZSA9PT0gMyB8fCB1dGlsLmlzQnJlYWsodk5vZGUpKSByZXR1cm4gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICBsZXQgc3R5bGUgPSAnJztcclxuICAgICAgICAgICAgICAgIGlmIChyZWdFeHAgJiYgdk5vZGUuc3R5bGUuY3NzVGV4dC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc3R5bGUgPSB2Tm9kZS5zdHlsZS5jc3NUZXh0LnJlcGxhY2UocmVnRXhwLCAnJykudHJpbSgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChzdHlsZS5sZW5ndGggPiAwIHx8IHZOb2RlLm5vZGVOYW1lICE9PSBuZXdOb2RlTmFtZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICh2Tm9kZS5zdHlsZS5jc3NUZXh0Lmxlbmd0aCA+IDApIHZOb2RlLnN0eWxlLmNzc1RleHQgPSBzdHlsZTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAvKiogb25lIGxpbmUgKi9cclxuICAgICAg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AgICAgICAgICAgICAgICBuZXdOb2RlID0gYXBwZW5kTm9kZS5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgc3RhcnQgPSB0aGlzLl9ub2RlQ2hhbmdlX3N0YXJ0TGluZShsaW5lTm9kZXNbMF0sIG5ld05vZGUsIGNoZWNrQ3NzLCBzdGFydENvbiwgc3RhcnRPZmYsIGlzUmVtb3ZlRm9ybWF0KTtcclxuXHJcbiAgICAgICAgICAgICAgICAvLyBtaWRcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgZW5kTGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gYXBwZW5kTm9kZS5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX25vZGVDaGFuZ2VfbWlkZGxlTGluZShsaW5lTm9kZXNbaV0sIG5ld05vZGUsIGNoZWNrQ3NzLCBpc1JlbW92ZUZvcm1hdCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLy8gZW5kQ29uXHJcbiAgICAgICAgICAgICAgICBpZiAoZW5kTGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBhcHBlbmROb2RlLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZW5kID0gdGhpcy5fbm9kZUNoYW5nZV9lbmRMaW5lKGxpbmVOb2Rlc1tlbmRMZW5ndGhdLCBuZXdOb2RlLCBjaGVja0NzcywgZW5kQ29uLCBlbmRPZmYsIGlzUmVtb3ZlRm9ybWF0KTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZW5kID0gc3RhcnQ7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8vIHNldCByYW5nZ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QsIG5ld05vZGUsIGFwcGVuZE5vZGUsIGNzc1RleHQ7XHJcblxyXG4gICAgICAgICAgICBmdW5jdGlvbiBjaGVja0NzcyAodk5vZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHJlZ0V4cCA9IG5ldyBSZWdFeHAoJyg/Ojt8XnxcXFxccykoPzonICsgY3NzVGV4dCArICdudWxsKVxcXFxzKjpbXjtdKlxcXFxzKig/Ojt8JCknLCAnaWcnKTtcclxuICAgICAgICAgICAgICAgIGxldCBzdHlsZSA9ICcnO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChyZWdFeHAgJiYgdk5vZGUuc3R5bGUuY3NzVGV4dC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc3R5bGUgPSByZWdFeHAudGVzdCh2Tm9kZS5zdHlsZS5jc3NUZXh0KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gIXN0eWxlO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAoZnVuY3Rpb24gcmVjdXJzaW9uRnVuYyhjdXJyZW50LCBub2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGVzID0gY3VycmVudC5jaGlsZE5vZGVzO1xyXG5cclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBjaGlsZE5vZGVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNoaWxkID0gY2hpbGROb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2xvbmVOb2RlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBzdGFydENvbnRhaW5lclxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghc3RhcnRQYXNzICYmIGNoaWxkID09PSBzdGFydENvbnRhaW5lcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcmV2Tm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb250YWluZXIubm9kZVR5cGUgPT09IDEgPyAnJyA6IHN0YXJ0Q29udGFpbmVyLnN1YnN0cmluZ0RhdGEoMCwgc3RhcnRPZmZzZXQpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dE5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKHN0YXJ0Q29udGFpbmVyLm5vZGVUeXBlID09PSAxID8gJycgOiBzdGFydENvbnRhaW5lci5zdWJzdHJpbmdEYXRhKHN0YXJ0T2Zmc2V0LCAoZW5kT2Zmc2V0ID4gc3RhcnRPZmZzZXQgPyBlbmRPZmZzZXQgLSBzdGFydE9mZnNldCA6IHN0YXJ0T2Zmc2V0IC0gZW5kT2Zmc2V0KSkpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByZXZOb2RlLmRhdGEubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hcHBlbmRDaGlsZChwcmV2Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBjaGlsZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY3NzVGV4dCA9ICcnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmV3Tm9kZSAhPT0gcE5vZGUgJiYgbmV3Tm9kZSAhPT0gZWwgJiYgbmV3Tm9kZSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24obmV3Tm9kZSkgJiYgbmV3Tm9kZS5ub2RlVHlwZSA9PT0gMSAmJiBjaGVja0NzcyhuZXdOb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50LnB1c2gobmV3Tm9kZS5jbG9uZU5vZGUoZmFsc2UpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjc3NUZXh0ICs9IG5ld05vZGUuc3R5bGUuY3NzVGV4dC5zdWJzdHIoMCwgbmV3Tm9kZS5zdHlsZS5jc3NUZXh0LmluZGV4T2YoJzonKSkgKyAnfCc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGUgPSBwQ3VycmVudC5wb3AoKSB8fCB0ZXh0Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBjaGlsZE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZS5hcHBlbmRDaGlsZChjaGlsZE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwTm9kZS5hcHBlbmRDaGlsZChuZXdJbm5lck5vZGUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb250YWluZXIgPSB0ZXh0Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRPZmZzZXQgPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydFBhc3MgPSB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5ld05vZGUgIT09IHRleHROb2RlKSBuZXdOb2RlLmFwcGVuZENoaWxkKHN0YXJ0Q29udGFpbmVyKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1NhbWVOb2RlKSBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIGVuZENvbnRhaW5lclxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghZW5kUGFzcyAmJiBjaGlsZCA9PT0gZW5kQ29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFmdGVyTm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoZW5kQ29udGFpbmVyLm5vZGVUeXBlID09PSAxID8gJycgOiBlbmRDb250YWluZXIuc3Vic3RyaW5nRGF0YShlbmRPZmZzZXQsIChlbmRDb250YWluZXIubGVuZ3RoIC0gZW5kT2Zmc2V0KSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0Tm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoaXNTYW1lTm9kZSB8fCBlbmRDb250YWluZXIubm9kZVR5cGUgPT09IDEgPyAnJyA6IGVuZENvbnRhaW5lci5zdWJzdHJpbmdEYXRhKDAsIGVuZE9mZnNldCkpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFmdGVyTm9kZS5kYXRhLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBjaGlsZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzc1RleHQgPSAnJztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmV3Tm9kZSAhPT0gcE5vZGUgJiYgbmV3Tm9kZSAhPT0gZWwgJiYgbmV3Tm9kZSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdOb2RlLm5vZGVUeXBlID09PSAxICYmIGNoZWNrQ3NzKG5ld05vZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50LnB1c2gobmV3Tm9kZS5jbG9uZU5vZGUoZmFsc2UpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzVGV4dCArPSBuZXdOb2RlLnN0eWxlLmNzc1RleHQuc3Vic3RyKDAsIG5ld05vZGUuc3R5bGUuY3NzVGV4dC5pbmRleE9mKCc6JykpICsgJ3wnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lTm9kZSA9IGFwcGVuZE5vZGUgPSBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCkgfHwgYWZ0ZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZS5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwTm9kZS5hcHBlbmRDaGlsZChjbG9uZU5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZS50ZXh0Q29udGVudCA9IGFmdGVyTm9kZS5kYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gY2hpbGQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNzc1RleHQgPSAnJztcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUgIT09IHBOb2RlICYmIG5ld05vZGUgIT09IGVsICYmIG5ld05vZGUgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKG5ld05vZGUpICYmIG5ld05vZGUubm9kZVR5cGUgPT09IDEgJiYgY2hlY2tDc3MobmV3Tm9kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzVGV4dCArPSBuZXdOb2RlLnN0eWxlLmNzc1RleHQuc3Vic3RyKDAsIG5ld05vZGUuc3R5bGUuY3NzVGV4dC5pbmRleE9mKCc6JykpICsgJ3wnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlID0gcEN1cnJlbnQucG9wKCkgfHwgdGV4dE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlID0gY2hpbGROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZS5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuYXBwZW5kQ2hpbGQoY2hpbGROb2RlKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVuZENvbnRhaW5lciA9IHRleHROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlbmRPZmZzZXQgPSB0ZXh0Tm9kZS5kYXRhLmxlbmd0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZW5kUGFzcyA9IHRydWU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzUmVtb3ZlRm9ybWF0ICYmIGNvbGxhcHNlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SW5uZXJOb2RlID0gdGV4dE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Tm9kZS50ZXh0Q29udGVudCA9IHV0aWwuemVyb1dpZHRoU3BhY2U7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdOb2RlICE9PSB0ZXh0Tm9kZSkgbmV3Tm9kZS5hcHBlbmRDaGlsZChlbmRDb250YWluZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIG90aGVyXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXJ0UGFzcykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEgJiYgIXV0aWwuaXNCcmVhayhjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gY2hpbGQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNzc1RleHQgPSAnJztcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUucGFyZW50Tm9kZSAhPT0gbnVsbCAmJiBuZXdOb2RlICE9PSBlbCAmJiBuZXdOb2RlICE9PSBuZXdJbm5lck5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdOb2RlLm5vZGVUeXBlID09PSAxICYmICF1dGlsLmlzQnJlYWsoY2hpbGQpICYmIChlbmRQYXNzIHx8IHZhbGlkYXRpb24obmV3Tm9kZSkpICYmIGNoZWNrQ3NzKG5ld05vZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQucHVzaChuZXdOb2RlLmNsb25lTm9kZShmYWxzZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzc1RleHQgKz0gbmV3Tm9kZS5zdHlsZS5jc3NUZXh0LnN1YnN0cigwLCBuZXdOb2RlLnN0eWxlLmNzc1RleHQuaW5kZXhPZignOicpKSArICd8JztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBuZXdOb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZSA9IHBDdXJyZW50LnBvcCgpIHx8IGNoaWxkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IGNoaWxkTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuYXBwZW5kQ2hpbGQobmV3Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkTm9kZSA9PT0gY2hpbGQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZW5kUGFzcykgbm9kZSA9IG5ld0lubmVyTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Ugbm9kZSA9IHBOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGVuZFBhc3MpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBOb2RlLmFwcGVuZENoaWxkKGNoaWxkTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZS5hcHBlbmRDaGlsZChjaGlsZE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgbm9kZS5hcHBlbmRDaGlsZChjbG9uZU5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSAmJiAhdXRpbC5pc0JyZWFrKGNoaWxkKSkgY292ZXJOb2RlID0gY2xvbmVOb2RlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjb3Zlck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KShlbGVtZW50LCBwTm9kZSk7XHJcblxyXG4gICAgICAgICAgICBpZiAoaXNSZW1vdmVGb3JtYXQpIHtcclxuICAgICAgICAgICAgICAgIHN0YXJ0Q29udGFpbmVyID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShjb2xsYXBzZWQgPyB1dGlsLnplcm9XaWR0aFNwYWNlIDogbmV3SW5uZXJOb2RlLnRleHRDb250ZW50KTtcclxuICAgICAgICAgICAgICAgIHBOb2RlLmluc2VydEJlZm9yZShzdGFydENvbnRhaW5lciwgbmV3SW5uZXJOb2RlKTtcclxuICAgICAgICAgICAgICAgIHBOb2RlLnJlbW92ZUNoaWxkKG5ld0lubmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICBpZiAoY29sbGFwc2VkKSBzdGFydE9mZnNldCA9IDE7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY29sbGFwc2VkKSB7XHJcbiAgICAgICAgICAgICAgICBzdGFydENvbnRhaW5lciA9IGVuZENvbnRhaW5lciA9IG5ld0lubmVyTm9kZTtcclxuICAgICAgICAgICAgICAgIHN0YXJ0T2Zmc2V0ID0gMTtcclxuICAgICAgICAgICAgICAgIGVuZE9mZnNldCA9IDE7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHV0aWwucmVtb3ZlRW1wdHlOb2RlKHBOb2RlKTtcclxuICAgICAgICAgICAgZWxlbWVudC5wYXJlbnROb2RlLmluc2VydEJlZm9yZShwTm9kZSwgZWxlbWVudCk7XHJcbiAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShlbGVtZW50KTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgICAgICBzdGFydENvbnRhaW5lcjogc3RhcnRDb250YWluZXIsXHJcbiAgICAgICAgICAgICAgICBzdGFydE9mZnNldDogc3RhcnRPZmZzZXQsXHJcbiAgICAgICAgICAgICAgICBlbmRDb250YWluZXI6IGlzUmVtb3ZlRm9ybWF0IHx8ICFlbmRDb250YWluZXIudGV4dENvbnRlbnQgPyBzdGFydENvbnRhaW5lciA6IGVuZENvbnRhaW5lcixcclxuICAgICAgICAgICAgICAgIGVuZE9mZnNldDogaXNSZW1vdmVGb3JtYXQgfHwgIWVuZENvbnRhaW5lci50ZXh0Q29udGVudCA/IHN0YXJ0Q29udGFpbmVyLnRleHRDb250ZW50Lmxlbmd0aCA6IGVuZE9mZnNldFxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgI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AgIGNvbnN0IGNoaWxkTm9kZXMgPSBjdXJyZW50LmNoaWxkTm9kZXM7XHJcbiAgICBcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gY2hpbGROb2Rlcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2hpbGQgPSBjaGlsZE5vZGVzW2ldO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24oY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2xvbmVOb2RlID0gY2hpbGQuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY2xvbmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSAmJiAhdXRpbC5pc0JyZWFrKGNoaWxkKSkgY292ZXJOb2RlID0gY2xvbmVOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNvdmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSkoZWxlbWVudCwgbmV3SW5uZXJOb2RlKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZWxlbWVudC5pbm5lckhUTUwgPSAnJztcclxuICAgICAgICAgICAgZWxlbWVudC5hcHBlbmRDaGlsZChuZXdJbm5lck5vZGUpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiB3cmFwcyBmaXJzdCBsaW5l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VsZW1lbnQuY2xvbmVOb2RlKGZhbHNlKTtcclxuXHJcbiAgICAgICAgICAgIGxldCBjb250YWluZXIgPSBzdGFydENvbjtcclxuICAgICAgICAgICAgbGV0IG9mZnNldCA9IHN0YXJ0T2ZmO1xyXG4gICAgICAgICAgICBsZXQgcGFzc05vZGUgPSBmYWxzZTtcclxuICAgICAgICAgICAgbGV0IHBDdXJyZW50LCBuZXdOb2RlLCBhcHBlbmROb2RlO1xyXG5cclxuICAgICAgICAgICAgKGZ1bmN0aW9uIHJlY3Vyc2lvbkZ1bmMoY3VycmVudCwgbm9kZSkge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlcyA9IGN1cnJlbnQuY2hpbGROb2RlcztcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBjaGlsZE5vZGVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGQgPSBjaGlsZE5vZGVzW2ldO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb3Zlck5vZGUgPSBub2RlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAocGFzc05vZGUgJiYgIXV0aWwuaXNCcmVhayhjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGNoaWxkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmV3Tm9kZS5wYXJlbnROb2RlICE9PSBudWxsICYmIG5ld05vZGUgIT09IGVsICYmIG5ld05vZGUgIT09IG5ld0lubmVyTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5ld05vZGUubm9kZVR5cGUgPT09IDEgJiYgdmFsaWRhdGlvbihuZXdOb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50LnB1c2gobmV3Tm9kZS5jbG9uZU5vZGUoZmFsc2UpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBuZXdOb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlID0gY2hpbGROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZS5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZS5hcHBlbmRDaGlsZChjaGlsZE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3SW5uZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBzdGFydENvbnRhaW5lclxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghcGFzc05vZGUgJiYgY2hpbGQgPT09IGNvbnRhaW5lcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcmV2Tm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoY29udGFpbmVyLm5vZGVUeXBlID09PSAxID8gJycgOiBjb250YWluZXIuc3Vic3RyaW5nRGF0YSgwLCBvZmZzZXQpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dE5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKGNvbnRhaW5lci5ub2RlVHlwZSA9PT0gMSA/ICcnIDogY29udGFpbmVyLnN1YnN0cmluZ0RhdGEob2Zmc2V0LCAoY29udGFpbmVyLmxlbmd0aCAtIG9mZnNldCkpKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2Tm9kZS5kYXRhLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQocHJldk5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUgIT09IHBOb2RlICYmIG5ld05vZGUgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdOb2RlLm5vZGVUeXBlID09PSAxICYmIHZhbGlkYXRpb24obmV3Tm9kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGUgPSBwQ3VycmVudC5wb3AoKSB8fCBub2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IGNoaWxkTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuYXBwZW5kQ2hpbGQobmV3Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkTm9kZSAhPT0gbm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SW5uZXJOb2RlLmFwcGVuZENoaWxkKGNoaWxkTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdJbm5lck5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1dGlsLmlzQnJlYWsoY2hpbGQpKSBuZXdJbm5lck5vZGUuYXBwZW5kQ2hpbGQoY2hpbGQuY2xvbmVOb2RlKGZhbHNlKSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwTm9kZS5hcHBlbmRDaGlsZChuZXdJbm5lck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIgPSB0ZXh0Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFzc05vZGUgPSB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hcHBlbmRDaGlsZChjb250YWluZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghcGFzc05vZGUgfHwgdmFsaWRhdGlvbihjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmVOb2RlID0gY2hpbGQuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hcHBlbmRDaGlsZChjbG9uZU5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEgJiYgIXV0aWwuaXNCcmVhayhjaGlsZCkpIGNvdmVyTm9kZSA9IGNsb25lTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNvdmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pKGVsZW1lbnQsIHBOb2RlKTtcclxuXHJcbiAgICAgICAgICAgIGlmIChpc1JlbW92ZUZvcm1hdCkge1xyXG4gICAgICAgICAgICAgICAgY29udGFpbmVyID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShuZXdJbm5lck5vZGUudGV4dENvbnRlbnQpO1xyXG4gICAgICAgICAgICAgICAgcE5vZGUuaW5zZXJ0QmVmb3JlKGNvbnRhaW5lciwgbmV3SW5uZXJOb2RlKTtcclxuICAgICAgICAgICAgICAgIHBOb2RlLnJlbW92ZUNoaWxkKG5ld0lubmVyTm9kZSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICghaXNSZW1vdmVGb3JtYXQgJiYgcE5vZGUuY2hpbGRyZW4ubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5jaGlsZE5vZGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gZWxlbWVudC5jaGlsZE5vZGVzWzBdO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBjb250YWluZXIgPSB1dGlsLmNyZWF0ZVRleHROb2RlKHV0aWwuemVyb1dpZHRoU3BhY2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYXBwZW5kQ2hpbGQoY29udGFpbmVyKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlRW1wdHlOb2RlKHBOb2RlKTtcclxuICAgICAgICAgICAgICAgIGVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocE5vZGUsIGVsZW1lbnQpO1xyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGVsZW1lbnQpO1xyXG4gICAgICAgICAgICB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ICAgKi9cclxuICAgICAgICBfbm9kZUNoYW5nZV9lbmRMaW5lOiBmdW5jdGlvbiAoZWxlbWVudCwgbmV3SW5uZXJOb2RlLCB2YWxpZGF0aW9uLCBlbmRDb24sIGVuZE9mZiwgaXNSZW1vdmVGb3JtYXQpIHtcclxuICAgICAgICAgICAgY29uc3QgZWwgPSBlbGVtZW50O1xyXG4gICAgICAgICAgICBjb25zdCBwTm9kZSA9IGVsZW1lbnQuY2xvbmVOb2RlKGZhbHNlKTtcclxuXHJcbiAgICAgICAgICAgIGxldCBjb250YWluZXIgPSBlbmRDb247XHJcbiAgICAgICAgICAgIGxldCBvZmZzZXQgPSBlbmRPZmY7XHJcbiAgICAgICAgICAgIGxldCBwYXNzTm9kZSA9IGZhbHNlO1xyXG4gICAgICAgICAgICBsZXQgcEN1cnJlbnQsIG5ld05vZGUsIGFwcGVuZE5vZGU7XHJcblxyXG4gICAgICAgICAgICAoZnVuY3Rpb24gcmVjdXJzaW9uRnVuYyhjdXJyZW50LCBub2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGVzID0gY3VycmVudC5jaGlsZE5vZGVzO1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IGNoaWxkTm9kZXMubGVuZ3RoIC0xOyAwIDw9IGk7IGktLSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGROb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhc3NOb2RlICYmICF1dGlsLmlzQnJlYWsoY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdXJzaW9uRnVuYyhjaGlsZCwgY2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBjaGlsZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUucGFyZW50Tm9kZSAhPT0gbnVsbCAmJiBuZXdOb2RlICE9PSBlbCAmJiBuZXdOb2RlICE9PSBuZXdJbm5lck5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKG5ld05vZGUpICYmIG5ld05vZGUubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IGNoaWxkTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuYXBwZW5kQ2hpbGQobmV3Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuaW5zZXJ0QmVmb3JlKGNoaWxkTm9kZSwgbmV3SW5uZXJOb2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3SW5uZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBlbmRDb250YWluZXJcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXBhc3NOb2RlICYmIGNoaWxkID09PSBjb250YWluZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWZ0ZXJOb2RlID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShjb250YWluZXIubm9kZVR5cGUgPT09IDEgPyAnJyA6IGNvbnRhaW5lci5zdWJzdHJpbmdEYXRhKG9mZnNldCwgKGNvbnRhaW5lci5sZW5ndGggLSBvZmZzZXQpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHROb2RlID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShjb250YWluZXIubm9kZVR5cGUgPT09IDEgPyAnJyA6IGNvbnRhaW5lci5zdWJzdHJpbmdEYXRhKDAsIG9mZnNldCkpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFmdGVyTm9kZS5kYXRhLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuaW5zZXJ0QmVmb3JlKGFmdGVyTm9kZSwgbm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChuZXdOb2RlICE9PSBwTm9kZSAmJiBuZXdOb2RlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGlvbihuZXdOb2RlKSAmJiBuZXdOb2RlLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQucHVzaChuZXdOb2RlLmNsb25lTm9kZShmYWxzZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlID0gcEN1cnJlbnQucG9wKCkgfHwgbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBjaGlsZE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZE5vZGUgIT09IG5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZS5pbnNlcnRCZWZvcmUoY2hpbGROb2RlLCBuZXdJbm5lck5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdJbm5lck5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1dGlsLmlzQnJlYWsoY2hpbGQpKSBuZXdJbm5lck5vZGUuYXBwZW5kQ2hpbGQoY2hpbGQuY2xvbmVOb2RlKGZhbHNlKSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwTm9kZS5pbnNlcnRCZWZvcmUobmV3SW5uZXJOb2RlLCBwTm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdGV4dE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldCA9IHRleHROb2RlLmRhdGEubGVuZ3RoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXNzTm9kZSA9IHRydWU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmluc2VydEJlZm9yZShjb250YWluZXIsIG5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXNzTm9kZSB8fCB2YWxpZGF0aW9uKGNoaWxkKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbG9uZU5vZGUgPSBjaGlsZC5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmluc2VydEJlZm9yZShjbG9uZU5vZGUsIG5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSAmJiAhdXRpbC5pc0JyZWFrKGNoaWxkKSkgY292ZXJOb2RlID0gY2xvbmVOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgcmVjdXJzaW9uRnVuYyhjaGlsZCwgY292ZXJOb2RlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSkoZWxlbWVudCwgcE5vZGUpO1xyXG5cclxuICAgICAgICAgICAgaWYgKGlzUmVtb3ZlRm9ybWF0KSB7XHJcbiAgICAgICAgICAgICAgICBjb250YWluZXIgPSB1dGlsLmNyZWF0ZVRleHROb2RlKG5ld0lubmVyTm9kZS50ZXh0Q29udGVudCk7XHJcbiAgICAgICAgICAgICAgICBvZmZzZXQgPSBjb250YWluZXIudGV4dENvbnRlbnQubGVuZ3RoO1xyXG4gICAgICAgICAgICAgICAgcE5vZGUuaW5zZXJ0QmVmb3JlKGNvbnRhaW5lciwgbmV3SW5uZXJOb2RlKTtcclxuICAgICAgICAgICAgICAgIHBOb2RlLnJlbW92ZUNoaWxkKG5ld0lubmVyTm9kZSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICghaXNSZW1vdmVGb3JtYXQgJiYgcE5vZGUuY2hpbGROb2Rlcy5sZW5ndGggPT09IDApIHtcclxuICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmNoaWxkTm9kZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb250YWluZXIgPSBlbGVtZW50LmNoaWxkTm9kZXNbMF07XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciA9IHV0aWwuY3JlYXRlVGV4dE5vZGUodXRpbC56ZXJvV2lkdGhTcGFjZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hcHBlbmRDaGlsZChjb250YWluZXIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVFbXB0eU5vZGUocE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgZWxlbWVudC5wYXJlbnROb2RlLmluc2VydEJlZm9yZShwTm9kZSwgZWxlbWVudCk7XHJcbiAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oZWxlbWVudCk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgICAgICBjb250YWluZXI6IGNvbnRhaW5lcixcclxuICAgICAgICAgICAgICAgIG9mZnNldDogb2Zmc2V0XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEV4ZWN1dGUgY29tbWFuZCBvZiBjb21tYW5kIGJ1dHRvbihBbGwgQnV0dG9ucyBleGNlcHQgc3VibWVudSBhbmQgZGlhbG9nKVxyXG4gICAgICAgICAqIChyZWRvLCB1bmRvLCBib2xkLCB1bmRlcmxpbmUsIGl0YWxpYywgc3RyaWtldGhyb3VnaCwgc3Vic2NyaXB0LCBzdXBlcnNjcmlwdCwgcmVtb3ZlRm9ybWF0LCBpbmRlbnQsIG91dGRlbnQsIGZ1bGxzY3JlZW4sIHNob3dCbG9ja3MsIGNvZGV2aWV3LCBwcmV2aWV3LCBwcmludClcclxuICAgICAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IHRhcmdldCAtIFRoZSBlbGVtZW50IG9mIGNvbW1hbmQgYnV0dG9uXHJcbiAgICAgICAgICogQHBhcmFtIHtTdHJpbmd9IGNvbW1hbmQgLSBQcm9wZXJ0eSBvZiBjb21tYW5kIGJ1dHRvbiAoZGF0YS12YWx1ZSlcclxuICAgICAgICAgKi9cclxuICAgICAgICBjb21tYW5kSGFuZGxlcjogZnVuY3Rpb24gKHRhcmdldCwgY29tbWFuZCkge1xyXG4gICAgICAgICAgICBzd2l0Y2ggKGNvbW1hbmQpIHtcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2NvZGVWaWV3JzpcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRyb2xsZXJzT2ZmKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50b2dnbGVDb2RlVmlldygpO1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3ModGFyZ2V0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2Z1bGxTY3JlZW4nOlxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29udHJvbGxlcnNPZmYoKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnRvZ2dsZUZ1bGxTY3JlZW4odGFyZ2V0KTtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKHRhcmdldCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICBjYXNlICdpbmRlbnQnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnb3V0ZGVudCc6XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5pbmRlbnQoY29tbWFuZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICBjYXNlICdyZWRvJzpcclxuICAgICAgICAgICAgICAgIGNhc2UgJ3VuZG8nOlxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY0NvbW1hbmQoY29tbWFuZCwgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAncmVtb3ZlRm9ybWF0JzpcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJlbW92ZUZvcm1hdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAncHJldmlldyc6XHJcbiAgICAgICAgICAgICAgICBjYXNlICdwcmludCc6XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVuV2luZG93Q29udGVudHMoY29tbWFuZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICBjYXNlICdzaG93QmxvY2tzJzpcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnRvZ2dsZURpc3BsYXlCbG9ja3MoKTtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKHRhcmdldCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICBjYXNlICdzdWJzY3JpcHQnOlxyXG4gICAgICAgICAgICAgICAgICAgIGlmICh1dGlsLmhhc0NsYXNzKGNvbnRleHQudG9vbC5zdXBlcnNjcmlwdCwgJ29uJykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjQ29tbWFuZCgnc3VwZXJzY3JpcHQnLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3MoY29udGV4dC50b29sLnN1cGVyc2NyaXB0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjQ29tbWFuZChjb21tYW5kLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnc3VwZXJzY3JpcHQnOlxyXG4gICAgICAgICAgICAgICAgICAgIGlmICh1dGlsLmhhc0NsYXNzKGNvbnRleHQudG9vbC5zdWJzY3JpcHQsICdvbicpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY0NvbW1hbmQoJ3N1YnNjcmlwdCcsIGZhbHNlLCBudWxsKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVDbGFzcyhjb250ZXh0LnRvb2wuc3Vic2NyaXB0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjQ29tbWFuZChjb21tYW5kLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgZGVmYXVsdCA6IC8vICdib2xkJywgJ3VuZGVybGluZScsICdpdGFsaWMnLCAnc3RyaWtlJ1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY0NvbW1hbmQoY29tbWFuZCwgZmFsc2UsIHRhcmdldC5nZXRBdHRyaWJ1dGUoJ2RhdGEtdmFsdWUnKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLmZvY3VzKCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2Nya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V3RGlzYWJsZWRCdXR0b25zO1xyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gZGlzQnV0dG9ucy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgZGlzQnV0dG9uc1tpXS5kaXNhYmxlZCA9IHd5c2l3eWdBY3RpdmU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICghd3lzaXd5Z0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgY29kZV9odG1sID0gY29udGV4dC5lbGVtZW50LmNvZGUudmFsdWUudHJpbSgpO1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MID0gY29kZV9odG1sLmxlbmd0aCA+IDAgPyB1dGlsLmNvbnZlcnRDb250ZW50c0ZvckVkaXRvcihjb2RlX2h0bWwpIDogJzxwPicgKyB1dGlsLnplcm9XaWR0aFNwYWNlICsgJzwvcD4nO1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuc2Nyb2xsVG9wID0gMDtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC5jb2RlLnN0eWxlLmRpc3BsYXkgPSAnbm9uZSc7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJztcclxuICAgICAgICAgICAgICAgIGlmIChjb250ZXh0Lm9wdGlvbi5oZWlnaHQgPT09ICdhdXRvJykgY29udGV4dC5lbGVtZW50LmNvZGUuc3R5bGUuaGVpZ2h0ID0gJzBweCc7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl92YXJpYWJsZS53eXNpd3lnQWN0aXZlID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgIHRoaXMuZm9jdXMoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgIC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AgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3MoZWxlbWVudC5maXJzdEVsZW1lbnRDaGlsZCwgJ2ljb24tcmVkdWN0aW9uJyk7XHJcbiAgICAgICAgICAgICAgICB1dGlsLmFkZENsYXNzKGVsZW1lbnQuZmlyc3RFbGVtZW50Q2hpbGQsICdpY29uLWV4cGFuc2lvbicpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIE9wZW4gdGhlIHByZXZpZXcgd2luZG93IG9yIG9wZW4gdGhlIHByaW50IHdpbmRvd1xyXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfSBtb2RlIC0gJ3ByZXZpZXcnIG9yICdwcmludCdcclxuICAgICAgICAgKi9cclxuICAgICAgICBvcGVuV2luZG93Q29udGVudHM6IGZ1bmN0aW9uIChtb2RlKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGlzUHJpbnQgPSBtb2RlID09PSAncHJpbnQnO1xyXG4gICAgICAgICAgICBjb25zdCB3aW5kb3dPYmplY3QgPSBfdy5vcGVuKCcnLCAnX2JsYW5rJyk7XHJcbiAgICAgICAgICAgIHdpbmRvd09iamVjdC5taW1lVHlwZSA9ICd0ZXh0L2h0bWwnO1xyXG4gICAgICAgICAgICB3aW5kb3dPYmplY3QuZG9jdW1lbnQud3JpdGUoJycgK1xyXG4gICAgICAgICAgICAgICAgJzwhZG9jdHlwZSBodG1sPjxodG1sPicgK1xyXG4gICAgICAgICAgICAgICAgJzxoZWFkPicgK1xyXG4gICAgICAgICAgICAgICAgJzxtZXRhIGNoYXJzZXQ9XCJ1dGYtOFwiIC8+JyArXHJcbiAgICAgICAgICAgICAgICAnPG1ldGEgbmFtZT1cInZpZXdwb3J0XCIgY29udGVudD1cIndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xXCI+JyArXHJcbiAgICAgICAgICAgICAgICAnPHRpdGxlPicgKyAoaXNQcmludCA/IGxhbmcudG9vbGJhci5wcmludCA6IGxhbmcudG9vbGJhci5wcmV2aWV3KSArICc8L3RpdGxlPicgK1xyXG4gICAgICAgICAgICAgICAgJzxsaW5rIHJlbD1cInN0eWxlc2hlZXRcIiB0eXBlPVwidGV4dC9jc3NcIiBocmVmPVwiJyArIHV0aWwuZ2V0SW5jbHVkZVBhdGgoWydzdW5lZGl0b3ItY29udGVudHMnLCAnc3VuZWRpdG9yJ10sICdjc3MnKSArICdcIj4nICtcclxuICAgICAgICAgICAgICAgICc8L2hlYWQ+JyArXHJcbiAgICAgICAgICAgICAgICAnPGJvZHk+JyArXHJcbiAgICAgICAgICAgICAgICAnPGRpdiBjbGFzcz1cInN1bi1lZGl0b3ItZWRpdGFibGVcIiBzdHlsZT1cIndpZHRoOicgKyBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5vZmZzZXRXaWR0aCArICdweDsgbWFyZ2luOmF1dG87XCI+JyArXHJcbiAgICAgICAgICAgICAgICB0aGlzLmdldENvbnRlbnRzKCkgKyAnPC9kaXY+JyArXHJcbiAgICAgICAgICAgICAgICAoaXNQcmludCA/ICc8c2NyaXB0Pl93LnByaW50KCk7PC9zY3JpcHQ+JyA6ICcnKSArICc8L2JvZHk+JyArXHJcbiAgICAgICAgICAgICAgICAnPC9odG1sPicpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBHZXRzIHRoZSBjdXJyZW50IGNvbnRlbnRzXHJcbiAgICAgICAgICogQHJldHVybnMge09iamVjdH1cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRDb250ZW50czogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBsZXQgY29udGVudHMgPSAnJztcclxuXHJcbiAgICAgICAgICAgIGlmIChjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5pbm5lclRleHQud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NrO1xyXG4gICAgICAgICAgICBjb25zdCBjb21tYW5kTWFwTm9kZXMgPSBbXTtcclxuICAgICAgICAgICAgY29uc3QgY3VycmVudE5vZGVzID0gW107XHJcblxyXG4gICAgICAgICAgICBsZXQgZmluZEZvcm1hdCA9IHRydWUsIGZpbmRGb250ID0gdHJ1ZSwgZmluZFNpemUgPSB0cnVlLCBmaW5kQSA9IHRydWU7XHJcbiAgICAgICAgICAgIGxldCBmaW5kQiA9IHRydWUsIGZpbmRJID0gdHJ1ZSwgZmluZFUgPSB0cnVlLCBmaW5kUyA9IHRydWU7XHJcbiAgICAgICAgICAgIGxldCBjc3NUZXh0ID0gJycsIG5vZGVOYW1lID0gJyc7XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBzZWxlY3Rpb25QYXJlbnQgPSBlZGl0b3IuZ2V0U2VsZWN0aW9uTm9kZSgpOyAhdXRpbC5pc1d5c2l3eWdEaXYoc2VsZWN0aW9uUGFyZW50KTsgc2VsZWN0aW9uUGFyZW50ID0gc2VsZWN0aW9uUGFyZW50LnBhcmVudE5vZGUpIHtcclxuICAgICAgICAgICAgICAgIGlmICghc2VsZWN0aW9uUGFyZW50KSBicmVhaztcclxuICAgICAgICAgICAgICAgIGlmIChzZWxlY3Rpb25QYXJlbnQubm9kZVR5cGUgIT09IDEpIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgbm9kZU5hbWUgPSBzZWxlY3Rpb25QYXJlbnQubm9kZU5hbWUudG9VcHBlckNhc2UoKTtcclxuICAgICAgICAgICAgICAgIGN1cnJlbnROb2Rlcy5wdXNoKG5vZGVOYW1lKTtcclxuXHJcbiAgICAgICAgICAgICAgICAvKiogRm9ybWF0ICovXHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEZvcm1hdCAmJiB1dGlsLmlzRm9ybWF0RWxlbWVudChzZWxlY3Rpb25QYXJlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ0ZPUk1BVCcpO1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwuY2hhbmdlVHh0KGNvbW1hbmRNYXAuRk9STUFULCBub2RlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEZvcm1hdCA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBGb250ICovXHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEZvbnQgJiYgKHNlbGVjdGlvblBhcmVudC5zdHlsZS5mb250RmFtaWx5Lmxlbmd0aCA+IDAgfHwgKHNlbGVjdGlvblBhcmVudC5mYWNlICYmIHNlbGVjdGlvblBhcmVudC5mYWNlLmxlbmd0aCA+IDApKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdGT05UJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2VsZWN0Rm9udCA9IChzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udEZhbWlseSB8fCBzZWxlY3Rpb25QYXJlbnQuZmFjZSB8fCBsYW5nLnRvb2xiYXIuZm9udCkucmVwbGFjZSgvW1wiJ10vZywnJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcC5GT05ULCBzZWxlY3RGb250KTtcclxuICAgICAgICAgICAgICAgICAgICBmaW5kRm9udCA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBBICovXHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEEgJiYgL15BJC8udGVzdChub2RlTmFtZSkgJiYgc2VsZWN0aW9uUGFyZW50LmdldEF0dHJpYnV0ZSgnZGF0YS1pbWFnZS1saW5rJykgPT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbnRleHQubGluayB8fCBlZGl0b3IuY29udHJvbGxlckFycmF5WzBdICE9PSBjb250ZXh0LmxpbmsubGlua0J0bikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbignbGluaycsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmxpbmsuY2FsbF9jb250cm9sbGVyX2xpbmtCdXR0b24uY2FsbChlZGl0b3IsIHNlbGVjdGlvblBhcmVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBmaW5kQSA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaW5kQSAmJiBjb250ZXh0LmxpbmsgJiYgZWRpdG9yLmNvbnRyb2xsZXJBcnJheVswXSA9PT0gY29udGV4dC5saW5rLmxpbmtCdG4pIHtcclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY29udHJvbGxlcnNPZmYoKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvKiogU1BBTiAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRTaXplICYmIC9eU1BBTiQvLnRlc3Qobm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgLyoqIGZvbnQgc2l6ZSAqL1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udFNpemUubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnU0laRScpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwLlNJWkUsIHNlbGVjdGlvblBhcmVudC5zdHlsZS5mb250U2l6ZS5tYXRjaCgvXFxkKy8pWzBdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZmluZFNpemUgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIGNvbW1hbmQgbWFwICovXHJcbiAgICAgICAgICAgICAgICBjc3NUZXh0ID0gc2VsZWN0aW9uUGFyZW50LnN0eWxlLmNzc1RleHQ7XHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEIgJiYgL2ZvbnRcXC13ZWlnaHRcXHMqOlxccyooPzpcXGQrfGJvbGR8Ym9sZGVyKSg/Ojt8XFxzfCkvLnRlc3QoY3NzVGV4dCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnQicpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRCID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEkgJiYgL2ZvbnRcXC1zdHlsZVxccyo6XFxzKig/Oml0YWxpY3xvYmxpcXVlKSg/Ojt8XFxzKS8udGVzdChjc3NUZXh0KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdJJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEkgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChmaW5kVSAmJiAvdGV4dFxcLWRlY29yYXRpb24oPzpcXC1saW5lKT9cXHMqOlxccyp1bmRlcmxpbmUoPzo7fFxcc3wpLy50ZXN0KGNzc1RleHQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ1UnKTtcclxuICAgICAgICAgICAgICAgICAgICBmaW5kVSA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRTICYmIC90ZXh0XFwtZGVjb3JhdGlvbig/OlxcLWxpbmUpP1xccyo6XFxzKmxpbmUtdGhyb3VnaCg/Ojt8XFxzfCkvLnRlc3QoY3NzVGV4dCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnU1RSSUtFJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZFMgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgoL15TVFJPTkckLy50ZXN0KG5vZGVOYW1lKSA/ICdCJyA6IC9eRU0kLy50ZXN0KG5vZGVOYW1lKSA/ICdJJyA6IG5vZGVOYW1lKSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiBBIFRhZyBlZGl0IGNvbnRyb2xsZXIgb2ZmICovXHJcbiAgICAgICAgICAgIGlmIChmaW5kQSkgZWRpdG9yLmNvbnRyb2xsZXJzT2ZmKCk7XHJcblxyXG4gICAgICAgICAgICAvKiogdG9nZ2xlIGNsYXNzIG9uICovXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tbWFuZE1hcE5vZGVzLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBub2RlTmFtZSA9IGNvbW1hbmRNYXBOb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgIGlmIChjbGFzc09uQ2hlY2sudGVzdChub2RlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmFkZENsYXNzKGNvbW1hbmRNYXBbbm9kZU5hbWVdLCAnb24nKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLyoqIHJlbW92ZSBjbGFzcywgZGlzcGxheSB0ZXh0ICovXHJcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBjb21tYW5kTWFwKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoY29tbWFuZE1hcE5vZGVzLmluZGV4T2Yoa2V5KSA+IC0xKSBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIGlmICgvXkZPTlQvaS50ZXN0KGtleSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwW2tleV0sIGxhbmcudG9vbGJhci5mb250KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKC9eU0laRSQvaS50ZXN0KGtleSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwW2tleV0sIGxhbmcudG9vbGJhci5mb250U2l6ZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKGNvbW1hbmRNYXBba2V5XSwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiBzYXZlIGN1cnJlbnQgbm9kZXMgKi9cclxuICAgICAgICAgICAgZWRpdG9yLl92YXJpYWJsZS5jdXJyZW50Tm9kZXMgPSBjdXJyZW50Tm9kZXMucmV2ZXJzZSgpO1xyXG5cclxuICAgICAgICAgICAgLyoqICBEaXNwbGF5cyB0aGUgY3VycmVudCBub2RlIHN0cnVjdHVyZSB0byByZXNpemluZ0JhciAqL1xyXG4gICAgICAgICAgICBpZiAoY29udGV4dC5vcHRpb24uc2hvd1BhdGhMYWJlbCkgY29udGV4dC5lbGVtZW50Lm5hdmlnYXRpb24udGV4dENvbnRlbnQgPSBlZGl0b3IuX3ZhcmlhYmxlLmN1cnJlbnROb2Rlcy5qb2luKCcgPiAnKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBfY2FuY2VsQ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gdGFyZ2V0LmNsYXNzTmFtZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKCFjb21tYW5kICYmICFkaXNwbGF5KSByZXR1cm47XHJcbiAgICAgICAgICAgIGlmICh0YXJnZXQuZGlzYWJsZWQpIHJldHVybjtcclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgIC8qKiBEaWFsb2csIFN1Ym1lbnUgKi9cclxuICAgICAgICAgICAgaWYgKGRpc3BsYXkpIHtcclxuICAgICAgICAgICAgICAgIGlmICgvc3VibWVudS8udGVzdChkaXNwbGF5KSAmJiAodGFyZ2V0Lm5leHRFbGVtZW50U2libGluZyA9PT0gbnVsbCB8fCB0YXJnZXQgIT09IGVkaXRvci5zdWJtZW51QWN0aXZlQnV0dG9uKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5zdWJtZW51T2ZmKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oY29tbWFuZCwgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9uKHRhcmdldCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoL2RpYWxvZy8udGVzdChkaXNwbGF5KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5jYWxsUGx1Z2luKGNvbW1hbmQsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnMuZGlhbG9nLm9wZW4uY2FsbChlZGl0b3IsIGNvbW1hbmQsIGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9mZigpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9mZigpO1xyXG5cclxuICAgICAgICAgICAgLyoqIGRlZmF1bHQgY29tbWFuZCAqL1xyXG4gICAgICAgICAgICBpZiAoY29tbWFuZCkge1xyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmZvY3VzKCk7XHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuY29tbWFuZEhhbmRsZXIodGFyZ2V0LCBjb21tYW5kKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIG9uQ2xpY2tfd3lzaXd5ZzogZnVuY3Rpb24gKGUpIHtcclxuICAgICAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKTtcclxuICAgICAgICAgICAgY29uc3QgdGFyZ2V0RWxlbWVudCA9IGUudGFyZ2V0O1xyXG4gICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9mZigpO1xyXG5cclxuICAgICAgICAgICAgaWYgKC9eSU1HJC9pLnRlc3QodGFyZ2V0RWxlbWVudC5ub2RlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIGVkaXRvci5jYWxsUGx1Z2luKCdpbWFnZScsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplID0gZWRpdG9yLnBsdWdpbnMucmVzaXppbmcuY2FsbF9jb250cm9sbGVyX3Jlc2l6ZS5jYWxsKGVkaXRvciwgdGFyZ2V0RWxlbWVudCwgJ2ltYWdlJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnMuaW1hZ2Uub25Nb2RpZnlNb2RlLmNhbGwoZWRpdG9yLCB0YXJnZXRFbGVtZW50LCBzaXplKTtcclxuICAgICAgICAgICAgICAgICAgICBcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXV0aWwuZ2V0UGFyZW50RWxlbWVudCh0YXJnZXRFbGVtZW50LCAnLnN1bi1lZGl0b3ItaWQtaW1hZ2UtY29udGFpbmVyJykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnMuaW1hZ2Uub3Blbk1vZGlmeS5jYWxsKGVkaXRvciwgdHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmltYWdlLnVwZGF0ZV9pbWFnZS5jYWxsKGVkaXRvcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb250cm9sbGVyc09mZigpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKC9zdW4tZWRpdG9yLWlkLWlmcmFtZS1pbm5lci1yZXNpemluZy1jb3Zlci9pLnRlc3QodGFyZ2V0RWxlbWVudC5jbGFzc05hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbigndmlkZW8nLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaWZyYW1lID0gdXRpbC5nZXRDaGlsZEVsZW1lbnQodGFyZ2V0RWxlbWVudC5wYXJlbnROb2RlLCAnaWZyYW1lJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGVkaXRvci5wbHVnaW5zLnJlc2l6aW5nLmNhbGxfY29udHJvbGxlcl9yZXNpemUuY2FsbChlZGl0b3IsIGlmcmFtZSwgJ3ZpZGVvJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnMudmlkZW8ub25Nb2RpZnlNb2RlLmNhbGwoZWRpdG9yLCBpZnJhbWUsIHNpemUpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBlZGl0b3IuX3NldEVkaXRvclJhbmdlKCk7XHJcbiAgICAgICAgICAgIGV2ZW50Ll9maW5kQnV0dG9uRWZmZWN0VGFnKCk7XHJcblxyXG4gICAgICAgICAgICBpZiAoZWRpdG9yLl9pc0JhbGxvb24pIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHJhbmdlID0gZWRpdG9yLmdldFJhbmdlKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKHJhbmdlLmNvbGxhcHNlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGV2ZW50Ll9oaWRlVG9vbGJhcigpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBldmVudC5fc2hvd1Rvb2xiYXJCYWxsb29uKHJhbmdlKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGZpZ2NhcHRpb24gPSB1dGlsLmdldFBhcmVudEVsZW1lbnQodGFyZ2V0RWxlbWVudCwgJ0ZJR0NBUFRJT04nKTtcclxuICAgICAgICAgICAgaWYgKGZpZ2NhcHRpb24gJiYgZmlnY2FwdGlvbi5nZXRBdHRyaWJ1dGUoJ2NvbnRlbnRlZGl0YWJsZScpICE9PSAndHVyZScpIHtcclxuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIGZpZ2NhcHRpb24uc2V0QXR0cmlidXRlKCdjb250ZW50ZWRpdGFibGUnLCB0cnVlKTtcclxuICAgICAgICAgICAgICAgIGZpZ2NhcHRpb24uZm9jdXMoKTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLl9pc0lubGluZSAmJiAhZWRpdG9yLl9pbmxpbmVUb29sYmFyQXR0ci5pc1Nob3cpIHtcclxuICAgICAgICAgICAgICAgICAgICBldmVudC5fc2hvd1Rvb2xiYXJJbmxpbmUoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkZVRvb2xiYXIgPSBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50Ll9oaWRlVG9vbGJhcigpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBfZC5yZW1vdmVFdmVudExpc3RlbmVyKCdjbGljaycsIGhpZGVUb29sYmFyKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIF9kLmFkZEV2ZW50TGlzdGVuZXIoJ2NsaWNrJywgaGlkZVRvb2xiYXIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgdGQgPSB1dGlsLmdldFBhcmVudEVsZW1lbnQodGFyZ2V0RWxlbWVudCwgdXRpbC5pc0NlbGwpO1xyXG4gICAgICAgICAgICAgICAgaWYgKHRkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvci5jb250cm9sbGVyQXJyYXkubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jYWxsUGx1Z2luKCd0YWJsZScsIGVkaXRvci5wbHVnaW5zLnRhYmxlLmNhbGxfY29udHJvbGxlcl90YWJsZUVkaXQuYmluZChlZGl0b3IsIHRkKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAodXNlckZ1bmN0aW9uLm9u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IC0gMTEgOiByZWN0cy5ib3R0b20gKyAxMSkgLSBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5vZmZzZXRUb3AgKyBfdy5zY3JvbGxZO1xyXG4gICAgICAgICAgICBcclxuICAgICAgICAgICAgdG9vbGJhci5zdHlsZS5sZWZ0ID0gKGwgPCAwID8gMjAgOiBsKSArICdweCc7XHJcbiAgICAgICAgICAgIHRvb2xiYXIuc3R5bGUudG9wID0gKHQpICsgJ3B4JztcclxuXHJcbiAgICAgICAgICAgIGlmIChpc0RpclRvcCkge1xyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVDbGFzcyhjb250ZXh0LmVsZW1lbnQuX2Fycm93LCAnYXJyb3ctdXAnKTtcclxuICAgICAgICAgICAgICAgIHV0aWwuYWRkQ2xhc3MoY29udGV4dC5lbGVtZW50Ll9hcnJvdywgJ2Fycm93LWRvd24nKTtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC5fYXJyb3cuc3R5bGUudG9wID0gKHRvb2xiYXIub2Zmc2V0SGVpZ2h0KSArICdweCc7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKGNvbnRleHQuZWxlbWVudC5fYXJyb3csICdhcnJvdy1kb3duJyk7XHJcbiAgICAgICAgICAgICAgICB1dGlsLmFkZENsYXNzKGNvbnRleHQuZWxlbWVudC5fYXJyb3csICdhcnJvdy11cCcpO1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Ll9hcnJvdy5zdHlsZS50b3AgPSAnLTExcHgnO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBjb25zdCBhcnJvd193aWR0aCA9IGNvbnRleHQuZWxlbWVudC5fYXJyb3cub2Zmc2V0V2lkdGg7XHJcbiAgICAgICAgICAgIGNvbnN0IGFycm93X2xlZnQgPSAodG9vbGJhci5vZmZzZXRXaWR0aCAvIDIgKyAob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l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGtleUNvZGUgPSBlLmtleUNvZGU7XHJcbiAgICAgICAgICAgIGNvbnN0IHNoaWZ0ID0gZS5zaGlmdEtleTtcclxuICAgICAgICAgICAgY29uc3QgY3RybCA9IGUuY3RybEtleSB8fCBlLm1ldGFLZXk7XHJcbiAgICAgICAgICAgIGNvbnN0IGFsdCA9IGUuYWx0S2V5O1xyXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG5cclxuICAgICAgICAgICAgaWYgKGVkaXRvci5faXNCYWxsb29uKSB7XHJcbiAgICAgICAgICAgICAgICBldmVudC5faGlkZVRvb2xiYXIoKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZnVuY3Rpb24gc2hvcnRjdXRDb21tYW5kKGtleUNvZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGV2ZW50Ll9zaG9ydGN1dEtleUNvZGVba2V5Q29kZV07XHJcbiAgICAgICAgICAgICAgICBpZiAoIWtleSkgcmV0dXJuIGZhbHNlO1xyXG5cclxuICAgICAgICAgICAgICAgIGVkaXRvci5jb21tYW5kSGFuZGxlcih1dGlsLmdldEZvcm1hdEVsZW1lbnQoZWRpdG9yLmdldFNlbGVjdGlvbk5vZGUoKSksIGtleVswXSk7XHJcbiAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKGVkaXRvci5jb21tYW5kTWFwW2tleVsxXV0sICdvbicpO1xyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogU2hvcnRjdXRzICovXHJcbiAgICAgICAgICAgIGlmIChjdHJsICYmICEvXig/OjE2fDE3fDE4KSQvLnRlc3Qoa2V5Q29kZSkpIHtcclxuICAgICAgICAgICAgICAgIGlmICghKHNoaWZ0ICYmIGtleUNvZGUgIT09IDgzKSAmJiBzaG9ydGN1dENvbW1hbmQoa2V5Q29kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogZGVmYXVsdCBrZXkgYWN0aW9uICovXHJcbiAgICAgICAgICAgIGNvbnN0IHNlbGVjdGlvbk5vZGUgPSBlZGl0b3IuZ2V0U2VsZWN0aW9uTm9kZSgpO1xyXG4gICAgICAgICAgICBzd2l0Y2ggKGtleUNvZGUpIHtcclxuICAgICAgICAgICAgICAgIGNhc2UgODogLyoqYmFja3NwYWNlIGtleSovXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHV0aWwuaXNGb3JtYXRFbGVtZW50KHNlbGVjdGlvbk5vZGUpICYmIHV0aWwuaXNXeXNpd3lnRGl2KHNlbGVjdGlvbk5vZGUucGFyZW50Tm9kZSkgJiYgc2VsZWN0aW9uTm9kZS5wcmV2aW91c1NpYmxpbmcgPT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3Rpb25Ob2RlLmlubmVySFRNTCA9IHV0aWwuemVyb1dpZHRoU3BhY2U7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICBjYXNlIDk6XHJcbiAgICAgICAgICAgICAgICAgICAgLyoqdGFiIGtleSovXHJcbiAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChjdHJsIHx8IGFsdCkgYnJlYWs7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb250cm9sbGVyc09mZigpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VycmVudE5vZGUgPSBzZWxlY3Rpb25Ob2RlIHx8IGVkaXRvci5nZXRTZWxlY3Rpb25Ob2RlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCF1dGlsLmlzQ2VsbChjdXJyZW50Tm9kZSkgJiYgIXV0aWwuaXNXeXNpd3lnRGl2KGN1cnJlbnROb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Tm9kZSA9IGN1cnJlbnROb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudE5vZGUgJiYgdXRpbC5pc0NlbGwoY3VycmVudE5vZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhYmxlID0gdXRpbC5nZXRQYXJlbnRFbGVtZW50KGN1cnJlbnROb2RlLCAndGFibGUnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2VsbHMgPSB1dGlsLmdldExpc3RDaGlsZHJlbih0YWJsZSwgdXRpbC5pc0NlbGwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgaWR4ID0gc2hpZnQgPyB1dGlsLnByZXZJZHgoY2VsbHMsIGN1cnJlbnROb2RlKSA6IHV0aWwubmV4dElkeChjZWxscywgY3VycmVudE5vZGUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkeCA9PT0gY2VsbHMubGVuZ3RoICYmICFzaGlmdCkgaWR4ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkeCA9PT0gLTEgJiYgc2hpZnQpIGlkeCA9IGNlbGxzLmxlbmd0aCAtIDE7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtb3ZlQ2VsbCA9IGNlbGxzW2lkeF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbW92ZUNlbGwpIHJldHVybiBmYWxzZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRSYW5nZShtb3ZlQ2VsbCwgMCwgbW92ZUNlbGwsIDApO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvKiogZm9ybWF0IFRhZyAqL1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVzID0gZWRpdG9yLmdldFNlbGVjdGVkRm9ybWF0RWxlbWVudHMoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzaGlmdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJUZXh0ID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShuZXcgQXJyYXkoZWRpdG9yLl92YXJpYWJsZS50YWJTaXplICsgMSkuam9pbignXFx1MDBBMCcpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpbmVzLmxlbmd0aCA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmluc2VydE5vZGUodGFiVGV4dCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UmFuZ2UodGFiVGV4dCwgZWRpdG9yLl92YXJpYWJsZS50YWJTaXplLCB0YWJUZXh0LCBlZGl0b3IuX3ZhcmlhYmxlLnRhYlNpemUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGxpbmVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZXNbaV0uaW5zZXJ0QmVmb3JlKHRhYlRleHQuY2xvbmVOb2RlKGZhbHNlKSwgbGluZXNbaV0uZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gbGluZXMubGVuZ3RoLCBjaGlsZDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZCA9IGxpbmVzW2ldLmZpcnN0Q2hpbGQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoL15cXHN7MSw0fSQvLnRlc3QoY2hpbGQudGV4dENvbnRlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGNoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoL15cXHN7MSw0fS8udGVzdChjaGlsZC50ZXh0Q29udGVudCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZC50ZXh0Q29udGVudCA9IGNoaWxkLnRleHRDb250ZW50LnJlcGxhY2UoL15cXHN7MSw0fS8sICcnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICh1c2VyRnVuY3Rpb24ub25LZX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pO1xyXG4gICAgICAgICAgICBpZiAodXNlckZ1bmN0aW9uLm9uU2Nyb2xsKSB1c2VyRnVuY3Rpb24ub25TY3JvbGwoZSk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgb25Ecm9wX3d5c2l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGZpbGVzID0gZS5kYXRhVHJhbnNmZXIuZmlsZXM7XHJcblxyXG4gICAgICAgICAgICBpZiAoZmlsZXMubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKTtcclxuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIFxyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmZvY3VzKCk7XHJcbiAgICBcclxuICAgICAgICAgICAgICAgIGVkaXRvci5jYWxsUGx1Z2luKCdpbWFnZScsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmltYWdlLmltZ0lucHV0RmlsZS5maWxlcyA9IGZpbGVzO1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmltYWdlLm9uUmVuZGVyX2ltZ0lucHV0LmNhbGwoZWRpdG9yKTtcclxuICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmltYWdlLmltZ0lucHV0RmlsZS5maWxlcyA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKHVzZXJGdW5jdGlvbi5vbkRyb3ApIHVzZXJGdW5jdGlvbi5vbkRyb3AoZSk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgb25Nb3VzZURvd25fcmVzaXppbmdCYXI6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcblxyXG4gICAgIC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50ZXJ2YWwgPCBlZGl0b3IuX3ZhcmlhYmxlLm1pblJlc2l6aW5nU2l6ZSA/IGVkaXRvci5fdmFyaWFibGUubWluUmVzaXppbmdTaXplIDogcmVzaXplSW50ZXJ2YWwpICsgJ3B4JztcclxuICAgICAgICAgICAgZWRpdG9yLl92YXJpYWJsZS5yZXNpemVDbGllbnRZID0gZS5jbGllbnRZO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIG9uUmVzaXplX3dpbmRvdzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBpZiAoY29udGV4dC5lbGVtZW50LnRvcEFyZWEub2Zmc2V0V2lkdGggPT09IDApIHJldHVybjtcclxuXHJcbiAgICAgICAgICAgIGlmIChlZGl0b3IuX3ZhcmlhYmxlLmlzRnVsbFNjcmVlbikge1xyXG4gICAgICAgICAgICAgICAgZWRpdG9yLl92YXJpYWJsZS5pbm5lckhlaWdodF9mdWxsU2NyZWVuICs9IChfdy5pbm5lckhlaWdodCAtIGNvbnRleHQuZWxlbWVudC50b29sYmFyLm9mZnNldEhlaWdodCkgLSBlZGl0b3IuX3ZhcmlhYmxlLmlubmVySGVpZ2h0X2Z1bGxTY3JlZW47XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQuZWRpdG9yQXJlYS5zdHlsZS5oZWlnaHQgPSBlZGl0b3IuX3ZhcmlhYmxlLmlubmVySGVpZ2h0X2Z1bGxTY3JlZW4gKyAncHgnO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2UgaWYgKGVkaXRvci5fdmFyaWFibGUuX3N0aWNreSkge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LnRvb2xiYXIuc3R5bGUud2lkdGggPSAoY29udGV4dC5lbGVtZW50LnRvcEFyZWEub2Zmc2V0V2lkdGggLSAyKSArICdweCc7XHJcbiAgICAgICAgICAgICAgICBldmVudC5vblNjcm9sbF93aW5kb3coKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZWRpdG9yLmNvbnRyb2xsZXJzT2ZmKCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgb25TY3JvbGxfd2luZG93OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGlmIChlZGl0b3IuX3ZhcmlhYmxlLmlzRnVsbFNjcmVlbiB8fCBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5vZmZzZXRXaWR0aCA9PT0gMCkgcmV0dXJuO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGNvbnRleHQuZWxlbWVudDtcclxuICAgICAgICAgICAgY29uc3QgZWRpdG9ySGVpZ2h0ID0gZWxlbWVudC5lZGl0b3JBcmVhLm9mZnNldEhlaWdodDtcclxuICAgICAgICAgICAgY29uc3QgZWRpdG9yVG9wID0gZWxlbWVudC50b3BBcmVhLm9mZnNldFRvcCAtIChlZGl0b3IuX2lzSW5saW5lID8gZWxlbWVudC50b29sYmFyLm9mZnNldEhlaWdodCA6IDApO1xyXG4gICAgICAgICAgICBjb25zdCB5ID0gKHRoaXMuc2Nyb2xsWSB8fCBfZC5kb2N1bWVudEVsZW1lbnQuc2Nyb2xsVG9wKSArIGNvbnRleHQub3B0aW9uLnN0aWNreVRvb2xiYXI7XHJcbiAgICAgICAgICAgIFxyXG4gICAgICAgICAgICBpZiAoeSA8IGVkaXRvclRvcCkge1xyXG4gICAgICAgICAgICAgICAgZXZlbnQuX29mZlN0aWNreVRvb2xiYXIoZWxlbWVudCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZWxzZSBpZiAoeSArIGVkaXRvci5fdmFyaWFibGUubWluUmVzaXppbmdTaXplID49IGVkaXRvckhlaWdodCArIGVkaXRvclRvcCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKCFlZGl0b3IuX3ZhcmlhYmxlLl9zdGlja3kpIGV2ZW50Ll9vblN0aWNreVRvb2xiYXIoZWxlbWVudCk7XHJcbiAgICAgICAgICAgICAgICBlbGVtZW50LnRvb2xiYXIuc3R5bGUudG9wID0gKGVkaXRvckhlaWdodCArIGVkaXRvclRvcCArIGNvbnRleHQub3B0aW9uLnN0aWNreVRvb2xiYXIgLXkgLSBlZGl0b3IuX3ZhcmlhYmxlLm1pblJlc2l6aW5nU2l6ZSkgKyAncHgnO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2UgaWYgKHkgPj0gZWRpdG9yVG9wKSB7XHJcbiAgICAgICAgICAgICAgICBldmVudC5fb25TdGlja3lUb29sYmFyKGVsZW1lbnQpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgX29uU3RpY2t5VG9vbGJhcjogZnVuY3Rpb24gKGVsZW1lbnQpIHtcclxuICAgICAgICAgICAgaWYgKCFlZGl0b3IuX2lzSW5saW5lKSB7XHJcbiAgICAgICAgICAgICAgICBlbGVtZW50Ll9zdGlja3lEdW1teS5zdHlsZS5oZWlnaHQgPSBlbGVtZW50LnRvb2xiYXIub2Zmc2V0SGVpZ2h0ICsgJ3B4JztcclxuICAgICAgICAgICAgICAgIGVsZW1lbnQuX3N0aWNreUR1bW15LnN0eWxlLmRpc3BsYXkgPSAnYmxvY2snO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBlbGVtZW50LnRvb2xiYXIuc3R5bGUudG9wID0gY29udGV4dC5vcHRpb24uc3RpY2t5VG9vbGJhciArICdweCc7XHJcbiAgICAgICAgICAgIGVsZW1lbnQudG9vbGJhci5zdHlsZS53aWR0aCA9IGVkaXRvci5faXNJbmxpbmUgPyBlZGl0b3IuX2lubGluZVRvb2xiYXJBdHRyLndpZHRoIDogZWxlbWVudC50b29sYmFyLm9mZnNldFdpZHRoICsgJ3B4JztcclxuICAgICAgICAgICAgdXRpbC5hZGRDbGFzcyhlbGVtZW50LnRvb2xiYXIsICdzdW4tZWRpdG9yLXN0aWNreScpO1xyX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Q29udGV4dDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICByZXR1cm4gY29udGV4dDtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gR2V0cyB0aGUgY29udGVudHMgb2YgdGhlIHN1bmVkaXRvclxyXG4gICAgICAgICAqIEByZXR1cm5zIHtTdHJpbmd9XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZ2V0Q29udGVudHM6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgcmV0dXJuIGVkaXRvci5nZXRDb250ZW50cygpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBHZXRzIHVwbG9hZGVkIGltYWdlcyBpbmZvcm1hdGlvbnNcclxuICAgICAgICAgKiBAcmV0dXJucyB7QXJyYXl9XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZ2V0SW1hZ2VzSW5mbzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICByZXR1cm4gZWRpdG9yLl92YXJpYWJsZS5faW1hZ2VzSW5mbztcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gSW5zZXJ0cyBhbiBIVE1MIGVsZW1lbnQgb3IgSFRNTCBzdHJpbmcgb3IgcGxhaW4gc3RyaW5nIGF0IHRoZSBjdXJyZW50IGN1cnNvciBwb3NpdGlvblxyXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudHxTdHJpbmd9IGh0bWwgLSBIVE1MIEVsZW1lbnQgb3IgSFRNTCBzdHJpbmcgb3IgcGxhaW4gc3RyaW5nXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgaW5zZXJ0SFRNTDogZnVuY3Rpb24gKGh0bWwpIHtcclxuICAgICAgICAgICAgaWYgKCFodG1sLm5vZGVUeXBlIHx8IGh0bWwubm9kZVR5cGUgIT09IDEpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHRlbXBsYXRlID0gdXRpbC5jcmVhdGVFbGVtZW50KCd0ZW1wbGF0ZScpO1xyXG4gICAgICAgICAgICAgICAgdGVtcGxhdGUuaW5uZXJIVE1MID0gaHRtbDtcclxuICAgICAgICAgICAgICAgIGh0bWwgPSB0ZW1wbGF0ZS5maXJzdENoaWxkIHx8IHRlbXBsYXRlLmNvbnRlbnQuZmlyc3RDaGlsZDtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZWRpdG9yLmluc2VydE5vZGUoaHRtbCk7XHJcbiAgICAgICAgICAgIGVkaXRvci5mb2N1cygpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBDaGFuZ2UgdGhlIGNvbnRlbnRzIG9mIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKiBAcGFyYW0ge1N0cmluZ30gY29udGVudHMgLSBDb250ZW50cyB0byBJbnB1dFxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIHNldENvbnRlbnRzOiBmdW5jdGlvbiAoY29udGVudHMpIHtcclxuICAgICAgICAgICAgaWYgKGVkaXRvci5fdmFyaWFibGUud3lzaXd5Z0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MID0gdXRpbC5jb252ZXJ0Q29udGVudHNGb3JFZGl0b3IoY29udGVudHMpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LmNvZGUudmFsdWUgPSBjb250ZW50cztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBBZGQgY29udGVudHMgdG8gdGhlIHN1bmVkaXRvclxyXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfSBjb250ZW50cyAtIENvbnRlbnRzIHRvIElucHV0XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgYXBwZW5kQ29udGVudHM6IGZ1bmN0aW9uIChjb250ZW50cykge1xyXG4gICAgICAgICAgICBpZiAoZWRpdG9yLl92YXJpYWJsZS53eXNpd3lnQWN0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5pbm5lckhUTUwgKz0gdXRpbC5jb252ZXJ0Q29udGVudHNGb3JFZGl0b3IoY29udGVudHMpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LmNvZGUudmFsdWUgKz0gY29udGVudHM7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRGlzYWJsZSB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZGlzYWJsZWQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29udGV4dC50b29sLmNvdmVyLnN0eWxlLmRpc3BsYXkgPSAnYmxvY2snO1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5zZXRBdHRyaWJ1dGUoJ2NvbnRlbnRlZGl0YWJsZScsIGZhbHNlKTtcclxuICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LmNvZGUuc2V0QXR0cmlidXRlKCdkaXNhYmxlZCcsICdkaXNhYmxlZCcpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBFbmFibGVkIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKi9cclxuICAgICAgICBlbmFibGVkOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGN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i9cclxuICAgICAgICAgICAgX3cucmVtb3ZlRXZlbnRMaXN0ZW5lcigncmVzaXplJywgZXZlbnQub25SZXNpemVfd2luZG93KTtcclxuICAgICAgICAgICAgX3cucmVtb3ZlRXZlbnRMaXN0ZW5lcignc2Nyb2xsJywgZXZlbnQub25TY3JvbGxfd2luZG93KTtcclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgIC8qKiByZW1vdmUgZWxlbWVudCAqL1xyXG4gICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oY29udGV4dC5lbGVtZW50LnRvcEFyZWEpO1xyXG5cclxuICAgICAgICAgICAgdGhpcy5vblNjcm9sbCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMub25DbGljayA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMub25LZXlEb3duID0gbnVsbDtcclxuICAgICAgICAgICAgdGhpcy5vbktleVVwID0gbnVsbDtcclxuICAgICAgICAgICAgdGhpcy5vbkRyb3AgPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLnNhdmUgPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLm9uSW1hZ2VVcGxvYWQgPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLm5vdGljZU9wZW4gPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLm5vdGljZUNsb3NlID0gbnVsbDtcclxuICAgICAgICAgICAgdGhpcy5nZXRDb250ZXh0ID0gbnVsbDtcclxuICAgICAgICAgICAgdGhpcy5nZXRDb250ZW50cyA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuZ2V0SW1hZ2VzSW5mbyA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuaW5zZXJ0SFRNTCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuc2V0Q29udGVudHMgPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLmFwcGVuZENvbnRlbnRzID0gbnVsbDtcclxuICAgICAgICAgICAgdGhpcy5kaXNhYmxlZ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7O0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7QUFHQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7QUFHQTtBQUNBO0FBQ0E7QUFDQTtBQUFBO0FBRUE7QUFDQTtBQUNBO0FBREE7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUE5S0E7QUFpTEE7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./src/lib/core.js\n"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./src/lib/util.js\");\n/* harmony import */ var _plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../plugins/modules/notice */ \"./src/plugins/modules/notice.js\");\n/*\r\n * wysiwyg web editor\r\n *\r\n * suneditor.js\r\n * Copyright 2017 JiHong Lee.\r\n * MIT license.\r\n */\n\n\n\n\n/**\r\n * @description SunEditor core closure\r\n * @param context\r\n * @param plugins\r\n * @param lang\r\n * @returns {{save: save, getContext: getContext, getContent: getContent, setContent: setContent, appendContent: appendContent, disabled: disabled, enabled: enabled, show: show, hide: hide, destroy: destroy}}\r\n */\n\nconst core = function (context, plugins, lang) {\n const _d = document;\n const _w = window;\n /**\r\n * @description editor core object\r\n * should always bind this object when registering an event in the plug-in.\r\n */\n\n const editor = {\n /**\r\n * @description Elements and user options parameters of the suneditor\r\n */\n context: context,\n\n /**\r\n * @description loaded plugins\r\n */\n plugins: {},\n\n /**\r\n * @description Whether the plugin is initialized\r\n */\n initPlugins: {},\n\n /**\r\n * @description loaded language\r\n */\n lang: lang,\n\n /**\r\n * @description dialog element\r\n */\n dialogForm: null,\n\n /**\r\n * @description submenu element\r\n */\n submenu: null,\n\n /**\r\n * @description active button element in submenu\r\n */\n submenuActiveButton: null,\n\n /**\r\n * @description The elements array to be processed unvisible when the controllersOff function is executed (resizing, link modified button, table controller)\r\n */\n controllerArray: [],\n\n /**\r\n * @description The functions array to be executed when the controllersOff function is executed ex) init function of table plugin\r\n */\n controllerFunction: [],\n\n /**\r\n * @description An array of buttons whose class name is not \"code-view-enabled\"\r\n */\n codeViewDisabledButtons: context.element.toolbar.querySelectorAll('.sun-editor-id-toolbar button:not([class~=\"code-view-enabled\"])'),\n\n /**\r\n * @description Is inline mode?\r\n * @private\r\n */\n _isInline: /inline/i.test(context.option.mode),\n\n /**\r\n * @description Is balloon mode?\r\n * @private\r\n */\n _isBalloon: /balloon/i.test(context.option.mode),\n\n /**\r\n * @description Required value when using inline mode to sticky toolbar\r\n * @private\r\n */\n _inlineToolbarAttr: {\n width: 0,\n height: 0,\n isShow: false\n },\n\n /**\r\n * @description An user event function when image uploaded success or remove image\r\n * @private\r\n */\n _imageUpload: function (targetImgElement, index, isDelete) {\n if (userFunction.onImageUpload) userFunction.onImageUpload(targetImgElement, index, isDelete);\n },\n\n /**\r\n * @description Elements that need to change text or className for each selection change\r\n * @property {Element} FORMAT - format button\r\n * @property {Element} FONT - font family button\r\n * @property {Element} SIZE - font size button\r\n * @property {Element} B - bold button\r\n * @property {Element} U - underline button\r\n * @property {Element} I - italic button\r\n * @property {Element} STRIKE - strike button\r\n * @property {Element} SUB - subscript button\r\n * @property {Element} SUP - superscript button\r\n */\n commandMap: {\n FORMAT: context.tool.format,\n FONT: context.tool.font,\n SIZE: context.tool.fontSize,\n B: context.tool.bold,\n U: context.tool.underline,\n I: context.tool.italic,\n STRIKE: context.tool.strike,\n SUB: context.tool.subscript,\n SUP: context.tool.superscript\n },\n\n /**\r\n * @description Variables used internally in editor operation\r\n * @property {(Element|null)} selectionNode - Contains selection node\r\n * @property {(Object|null)} range - The current range object\r\n * @property {Boolean} wysiwygActive - The wysiwyg frame or code view state\r\n * @property {Boolean} isFullScreen - State of full screen\r\n * @property {Number} innerHeight_fullScreen - InnerHeight in editor when in full screen\r\n * @property {Number} resizeClientY - Remember the vertical size of the editor before resizing the editor (Used when calculating during resize operation)\r\n * @property {Number} tabSize - Indented size when tab button clicked (4)\r\n * @property {Number} minResizingSize - Minimum size of editing area when resized (65)\r\n * @property {Array} currentNodes - An array of the current cursor's node structure\r\n * @private\r\n */\n _variable: {\n selectionNode: null,\n range: null,\n wysiwygActive: true,\n isFullScreen: false,\n innerHeight_fullScreen: 0,\n resizeClientY: 0,\n tabSize: 4,\n minResizingSize: 65,\n currentNodes: [],\n _originCssText: context.element.topArea.style.cssText,\n _bodyOverflow: '',\n _editorAreaOriginCssText: '',\n _wysiwygOriginCssText: '',\n _codeOriginCssText: '',\n _sticky: false,\n _imagesInfo: [],\n _imageIndex: 0\n },\n\n /**\r\n * @description If the plugin is not added, add the plugin and call the 'add' function.\r\n * If the plugin is added call callBack function.\r\n * @param {String} pluginName - The name of the plugin to call\r\n * @param {function} callBackFunction - Function to be executed immediately after module call\r\n */\n callPlugin: function (pluginName, callBackFunction) {\n if (!this.plugins[pluginName]) {\n throw Error('[SUNEDITOR.core.callPlugin.fail] The called plugin does not exist or is in an invalid format. (pluginName:\"' + pluginName + '\")');\n } else if (!this.initPlugins[pluginName]) {\n this.plugins[pluginName].add(this, this.plugins[pluginName].buttonElement);\n this.initPlugins[pluginName] = true;\n }\n\n callBackFunction();\n },\n\n /**\r\n * @description If the module is not added, add the module and call the 'add' function\r\n * @param {Array} moduleArray - module object's Array [dialog, resizing]\r\n */\n addModule: function (moduleArray) {\n let moduleName = '';\n\n for (let i = 0, len = moduleArray.length; i < len; i++) {\n moduleName = moduleArray[i].name;\n\n if (!this.plugins[moduleName]) {\n this.plugins[moduleName] = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].copyObj(moduleArray[i]);\n this.plugins[moduleName].add(this);\n }\n }\n },\n\n /**\r\n * @description Enabled submenu\r\n * @param {Element} element - Submenu element to call\r\n */\n submenuOn: function (element) {\n const submenuName = element.getAttribute('data-command');\n if (this.plugins[submenuName].on) this.plugins[submenuName].on.call(this);\n this.submenu = element.nextElementSibling;\n this.submenu.style.display = 'block';\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(element, 'on');\n this.submenuActiveButton = element;\n const overLeft = this.context.element.toolbar.offsetWidth - (element.parentElement.offsetLeft + this.submenu.offsetWidth);\n if (overLeft < 0) this.submenu.style.left = overLeft + 'px';else this.submenu.style.left = '1px';\n },\n\n /**\r\n * @description Disable submenu\r\n */\n submenuOff: function () {\n if (this.submenu) {\n this.submenu.style.display = 'none';\n this.submenu = null;\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(this.submenuActiveButton, 'on');\n this.submenuActiveButton = null;\n }\n\n this.controllersOff();\n },\n\n /**\r\n * @description Disable controller in editor area (link button, image resize button)\r\n */\n controllersOff: function () {\n const len = this.controllerArray.length;\n const fLen = this.controllerFunction.length;\n\n if (len > 0) {\n for (let i = 0; i < len; i++) {\n this.controllerArray[i].style.display = 'none';\n }\n\n this.controllerArray = [];\n }\n\n if (fLen > 0) {\n for (let i = 0; i < fLen; i++) {\n this.controllerFunction[i]();\n }\n\n this.controllerFunction = [];\n }\n },\n\n /**\r\n * @description javascript execCommand\r\n * @param {String} command - javascript execCommand function property\r\n * @param {Boolean} showDefaultUI - javascript execCommand function property\r\n * @param {String} value - javascript execCommand function property\r\n */\n execCommand: function (command, showDefaultUI, value) {\n _d.execCommand(command, showDefaultUI, command === 'formatBlock' ? '<' + value + '>' : value);\n },\n\n /**\r\n * @description Focus to wysiwyg area\r\n */\n focus: function () {\n if (context.element.wysiwyg.style.display === 'none') return;\n const caption = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(this.getSelectionNode(), 'figcaption');\n\n if (caption) {\n caption.focus();\n } else {\n context.element.wysiwyg.focus();\n }\n\n this._setEditorRange();\n\n event._findButtonEffectTag();\n },\n\n /**\r\n * @description Saving the range object and the currently selected node of editor\r\n * @private\r\n */\n _setEditorRange: function () {\n const selection = _w.getSelection();\n\n let range = null;\n\n if (selection.rangeCount > 0) {\n range = selection.getRangeAt(0);\n } else {\n range = this._createDefaultRange();\n }\n\n this._variable.range = range;\n\n if (range.collapsed) {\n this.setSelectionNode(range.commonAncestorContainer);\n } else {\n this.setSelectionNode(selection.extentNode || selection.anchorNode);\n }\n },\n\n /**\r\n * @description Return the range object of editor's first child node\r\n * @returns {Object}\r\n * @private\r\n */\n _createDefaultRange: function () {\n const range = _d.createRange();\n\n range.setStart(context.element.wysiwyg.firstChild, 0);\n range.setEnd(context.element.wysiwyg.firstChild, 0);\n return range;\n },\n\n /**\r\n * @description Set current editor's range object\r\n * @param {Element} startCon - The startContainer property of the selection object.\r\n * @param {Number} startOff - The startOffset property of the selection object.\r\n * @param {Element} endCon - The endContainer property of the selection object.\r\n * @param {Element} endOff - The endOffset property of the selection object.\r\n */\n setRange: function (startCon, startOff, endCon, endOff) {\n const range = _d.createRange();\n\n range.setStart(startCon, startOff);\n range.setEnd(endCon, endOff);\n\n const selection = _w.getSelection();\n\n if (selection.removeAllRanges) {\n selection.removeAllRanges();\n }\n\n selection.addRange(range);\n this._variable.range = range;\n\n this._setEditorRange();\n },\n\n /**\r\n * @description Get current editor's range object\r\n * @returns {Object}\r\n */\n getRange: function () {\n return this._variable.range || this._createDefaultRange();\n },\n\n /**\r\n * @description Set the selected node. (Used by getSelectionNode function)\r\n * @param {Node} node - node object\r\n */\n setSelectionNode: function (node) {\n this._variable.selectionNode = node;\n },\n\n /**\r\n * @description Get current select node\r\n * @returns {Node}\r\n */\n getSelectionNode: function () {\n if (this._variable.selectionNode) {\n return this._variable.selectionNode;\n }\n\n return context.element.wysiwyg.firstChild;\n },\n\n /**\r\n * @description Returns a \"formatElement\"(P, DIV, H[1-6], LI) array from the currently selected range.\r\n * @returns {Array}\r\n */\n getSelectedFormatElements: function () {\n let range = this.getRange();\n\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(range.startContainer)) {\n const children = context.element.wysiwyg.children;\n this.setRange(children[0], 0, children[children.length - 1], children[children.length - 1].textContent.length);\n range = this.getRange();\n }\n\n const startCon = range.startContainer;\n const endCon = range.endContainer;\n const commonCon = range.commonAncestorContainer;\n const rangeFormatElements = [];\n if (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(commonCon) && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(commonCon)) return [_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(commonCon)]; // get line nodes\n\n const lineNodes = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildren(commonCon, function (current) {\n return _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(current);\n });\n if (startCon === endCon) return lineNodes[0];\n let startLine = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(startCon);\n let endLine = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(endCon);\n let startIdx = 0;\n let endIdx = 0;\n\n for (let i = 0, len = lineNodes.length; i < len; i++) {\n if (startLine === lineNodes[i]) {\n startIdx = i;\n continue;\n }\n\n if (endLine === lineNodes[i]) {\n endIdx = i;\n break;\n }\n }\n\n for (let i = startIdx; i <= endIdx; i++) {\n rangeFormatElements.push(lineNodes[i]);\n }\n\n return rangeFormatElements;\n },\n\n /**\r\n * @description Returns a \"rangeFormatElement\"(blockquote, TABLE, TR, TD, OL, UL, PRE) array from the currently selected range.\r\n * @returns {Array}\r\n */\n getSelectedRangeFormatElements: function () {\n let range = this.getRange();\n\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(range.startContainer)) {\n const children = context.element.wysiwyg.children;\n this.setRange(children[0], 0, children[children.length - 1], children[children.length - 1].textContent.length);\n range = this.getRange();\n }\n\n const startCon = range.startContainer;\n const endCon = range.endContainer;\n const commonCon = range.commonAncestorContainer;\n const rangeFormatElements = [];\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(commonCon)) return [commonCon];\n\n if (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(commonCon)) {\n const el = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getRangeFormatElement(commonCon);\n return el ? [el] : [];\n } // get range Elements\n\n\n const rangeElements = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildren(commonCon, function (current) {\n return _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(current);\n });\n if (startCon === endCon) return rangeElements[0];\n let startLine = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getRangeFormatElement(startCon);\n let endLine = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getRangeFormatElement(endCon);\n let startIdx = 0;\n let endIdx = 0;\n\n for (let i = 0, len = rangeElements.length; i < len; i++) {\n if (startLine === rangeElements[i]) {\n startIdx = i;\n continue;\n }\n\n if (endLine === rangeElements[i]) {\n endIdx = i;\n break;\n }\n }\n\n for (let i = startIdx; i <= endIdx; i++) {\n if (rangeElements[i]) rangeFormatElements.push(rangeElements[i]);\n }\n\n return rangeFormatElements;\n },\n\n /**\r\n * @description Determine if this offset is the edge offset of container\r\n * @param {Object} container - The container property of the selection object.\r\n * @param {Number} offset - The offset property of the selection object.\r\n * @returns {Boolean}\r\n */\n isEdgePoint: function (container, offset) {\n return offset === 0 || offset === container.nodeValue.length;\n },\n\n /**\r\n * @description Show loading box\r\n */\n showLoading: function () {\n context.element.loading.style.display = 'block';\n },\n\n /**\r\n * @description Close loading box\r\n */\n closeLoading: function () {\n context.element.loading.style.display = 'none';\n },\n\n /**\r\n * @description Append format element to sibling node of argument element.\r\n * If the \"formatNodeName\" argument value is present, the tag of that argument value is inserted,\r\n * If not, the currently selected format tag is inserted.\r\n * @param {Element} element - Insert as siblings of that element\r\n * @param {String|null} formatNodeName - Node name to be inserted\r\n * @returns {Element}\r\n */\n appendFormatTag: function (element, formatNodeName) {\n const formatEl = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getRangeFormatElement(element) || _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(element);\n const currentFormatEl = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(this.getSelectionNode());\n const oFormatName = formatNodeName ? formatNodeName : _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(currentFormatEl) ? currentFormatEl.nodeName : 'P';\n const oFormat = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement(oFormatName);\n oFormat.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace;\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell(formatEl)) formatEl.insertBefore(oFormat, element.nextElementSibling);else formatEl.parentNode.insertBefore(oFormat, formatEl.nextElementSibling);\n return oFormat;\n },\n\n /**\r\n * @description Delete selected node and insert argument value node\r\n * @param {Element} oNode - Node to be inserted\r\n * @param {(Element|null)} rightNode - If the node exists, it is inserted after the node\r\n */\n insertNode: function (oNode, rightNode) {\n const range = this.getRange();\n let parentNode = null;\n\n if (!rightNode) {\n const startCon = range.startContainer;\n const startOff = range.startOffset;\n const endCon = range.endContainer;\n const endOff = range.endOffset;\n const commonCon = range.commonAncestorContainer;\n parentNode = startCon;\n\n if (startCon.nodeType === 3) {\n parentNode = startCon.parentNode;\n }\n /** No Select range node */\n\n\n if (range.collapsed) {\n if (commonCon.nodeType === 3) {\n rightNode = commonCon.splitText(endOff);\n } else {\n if (parentNode.lastChild !== null && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(parentNode.lastChild)) {\n parentNode.removeChild(parentNode.lastChild);\n }\n\n rightNode = null;\n }\n }\n /** Select range nodes */\n else {\n const isSameContainer = startCon === endCon;\n\n if (isSameContainer) {\n if (this.isEdgePoint(endCon, endOff)) rightNode = endCon.nextSibling;else rightNode = endCon.splitText(endOff);\n let removeNode = startCon;\n if (!this.isEdgePoint(startCon, startOff)) removeNode = startCon.splitText(startOff);\n parentNode.removeChild(removeNode);\n } else {\n this.removeNode();\n parentNode = commonCon;\n rightNode = endCon;\n\n while (rightNode.parentNode !== commonCon) {\n rightNode = rightNode.parentNode;\n }\n }\n }\n } else {\n parentNode = rightNode.parentNode;\n rightNode = rightNode.nextSibling;\n }\n\n try {\n parentNode.insertBefore(oNode, rightNode);\n } catch (e) {\n parentNode.appendChild(oNode);\n }\n },\n\n /**\r\n * @description Delete the currently selected node\r\n */\n removeNode: function () {\n const range = this.getRange();\n\n if (range.deleteContents) {\n range.deleteContents();\n return;\n }\n\n const startCon = range.startContainer;\n const startOff = range.startOffset;\n const endCon = range.endContainer;\n const endOff = range.endOffset;\n const commonCon = range.commonAncestorContainer;\n let beforeNode = null;\n let afterNode = null;\n const childNodes = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildNodes(commonCon);\n let startIndex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getArrayIndex(childNodes, startCon);\n let endIndex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getArrayIndex(childNodes, endCon);\n\n for (let i = startIndex + 1, startNode = startCon; i >= 0; i--) {\n if (childNodes[i] === startNode.parentNode && childNodes[i].firstChild === startNode && startOff === 0) {\n startIndex = i;\n startNode = startNode.parentNode;\n }\n }\n\n for (let i = endIndex - 1, endNode = endCon; i > startIndex; i--) {\n if (childNodes[i] === endNode.parentNode && childNodes[i].nodeType === 1) {\n childNodes.splice(i, 1);\n endNode = endNode.parentNode;\n --endIndex;\n }\n }\n\n for (let i = startIndex; i <= endIndex; i++) {\n const item = childNodes[i];\n\n if (item.length === 0 || item.nodeType === 3 && item.data === undefined) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(item);\n continue;\n }\n\n if (item === startCon) {\n if (startCon.nodeType === 1) {\n beforeNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(startCon.textContent);\n } else {\n beforeNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(startCon.substringData(0, startOff));\n }\n\n if (beforeNode.length > 0) {\n startCon.data = beforeNode.data;\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(startCon);\n }\n\n continue;\n }\n\n if (item === endCon) {\n if (endCon.nodeType === 1) {\n afterNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(endCon.textContent);\n } else {\n afterNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(endCon.substringData(endOff, endCon.length - endOff));\n }\n\n if (afterNode.length > 0) {\n endCon.data = afterNode.data;\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(endCon);\n }\n\n continue;\n }\n\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(item);\n }\n },\n\n /**\r\n * @description appended all selected format Element to the argument element and insert\r\n * @param {Element} wrapTag - Element of wrap the arguments\r\n */\n wrapToTags: function (wrapTag) {\n const range = this.getRange();\n const rangeLines = this.getSelectedFormatElements();\n\n if (!rangeLines) {\n const inner = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell(this.getSelectionNode()) ? 'DIV' : 'P');\n inner.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace;\n wrapTag.appendChild(inner);\n this.getSelectionNode().appendChild(wrapTag);\n return;\n }\n\n let last = rangeLines[rangeLines.length - 1];\n let standTag, beforeTag, pElement;\n\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(last) || _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(last)) {\n standTag = last;\n } else {\n standTag = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getRangeFormatElement(last) || _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(last);\n }\n\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell(standTag)) {\n beforeTag = null;\n pElement = standTag;\n } else {\n beforeTag = standTag.nextSibling;\n pElement = standTag.parentNode;\n }\n\n let listParent = null;\n let line = null;\n let prevNodeName = '';\n\n for (let i = 0, len = rangeLines.length; i < len; i++) {\n line = rangeLines[i];\n\n if (/^LI$/i.test(line.nodeName)) {\n if (listParent === null || !/^LI$/i.test(prevNodeName)) {\n listParent = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement(line.parentNode.nodeName);\n }\n\n listParent.appendChild(line);\n if (i === len - 1 || !/^LI$/i.test(rangeLines[i + 1].nodeName)) wrapTag.appendChild(listParent);\n } else {\n wrapTag.appendChild(line);\n }\n\n prevNodeName = line.nodeName;\n }\n\n pElement.insertBefore(wrapTag, beforeTag);\n if (!range.collapsed && (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(range.startContainer) || _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(range.endContainer))) _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeEmptyNode(pElement);\n },\n\n /**\r\n * @description Add the node received as an argument value to the selected area.\r\n * 1. When there is the same css value node in the selection area, the tag is stripped.\r\n * 2. If there is another css value other thanCss attribute values received as arguments on the node, removed only Css attribute values received as arguments\r\n * 3. If you pass an element whose node name is \"removenode\" as an argument value, it performs a type removal operation. ex) nodeChange(document.createElement('removenode'))\r\n * @param {Element} appendNode - The dom that will wrap the selected text area\r\n * @param {Array} checkCSSPropertyArray - The css attribute name Array to check (['font-size'], ['font-family', 'background-color', 'border']...])\r\n */\n nodeChange: function (appendNode, checkCSSPropertyArray) {\n const range = this.getRange();\n const isRemoveFormat = /removenode/i.test(appendNode.nodeName);\n let tempCon, tempOffset, tempChild, tempArray;\n /* checked same style property */\n\n if (range.startContainer === range.endContainer) {\n let sNode = range.startContainer;\n\n if (isRemoveFormat) {\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(sNode) === sNode.parentNode) return;\n } else {\n let checkCnt = 0;\n\n for (let i = 0; i < checkCSSPropertyArray.length; i++) {\n while (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(sNode) && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(sNode)) {\n if (sNode.nodeType === 1 && sNode.style[checkCSSPropertyArray[i]] === appendNode.style[checkCSSPropertyArray[i]]) {\n checkCnt++;\n }\n\n sNode = sNode.parentNode;\n }\n }\n\n if (checkCnt >= checkCSSPropertyArray.length) return;\n }\n }\n /* find text node */\n\n\n tempCon = range.startContainer;\n tempOffset = range.startOffset;\n\n if (tempCon.nodeType === 1 && tempCon.childNodes.length > 0) {\n while (tempCon && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(tempCon) && tempCon.nodeType === 1) {\n tempArray = [];\n tempChild = tempCon.childNodes;\n\n for (let i = 0, len = tempChild.length; i < len; i++) {\n tempArray.push(tempChild[i]);\n }\n\n tempCon = tempArray[tempOffset] || tempCon.nextElementSibling || tempCon.nextSibling;\n tempOffset = 0;\n }\n }\n\n const startCon = tempCon;\n const startOff = tempOffset;\n tempCon = range.endContainer;\n tempOffset = range.endOffset;\n\n if (tempCon.nodeType === 1 && tempCon.childNodes.length > 0) {\n while (tempCon && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(tempCon) && tempCon.nodeType === 1) {\n tempArray = [];\n tempChild = tempCon.childNodes;\n\n for (let i = 0, len = tempChild.length; i < len; i++) {\n tempArray.push(tempChild[i]);\n }\n\n tempCon = tempArray[tempOffset - 1] || tempArray[0] || tempCon.previousElementSibling || tempCon.previousSibling || startCon;\n }\n\n tempOffset = tempCon.textContent.length;\n }\n\n const endCon = tempCon;\n const endOff = tempOffset;\n const commonCon = range.commonAncestorContainer;\n const newNodeName = appendNode.nodeName;\n let start = {},\n end = {};\n let newNode, regExp;\n\n if (checkCSSPropertyArray) {\n regExp = '(?:;|^|\\\\s)(?:' + checkCSSPropertyArray[0];\n\n for (let i = 1; i < checkCSSPropertyArray.length; i++) {\n regExp += '|' + checkCSSPropertyArray[i];\n }\n\n regExp += ')\\\\s*:[^;]*\\\\s*(?:;|$)';\n regExp = new RegExp(regExp, 'ig');\n }\n /** tag check function*/\n\n\n const checkCss = function (vNode) {\n if (isRemoveFormat || vNode.nodeType === 3 || _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(vNode)) return true;\n let style = '';\n\n if (regExp && vNode.style.cssText.length > 0) {\n style = vNode.style.cssText.replace(regExp, '').trim();\n }\n\n if (style.length > 0 || vNode.nodeName !== newNodeName) {\n if (vNode.style.cssText.length > 0) vNode.style.cssText = style;\n return true;\n }\n\n return false;\n };\n /** one line */\n\n\n if (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(commonCon) && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(commonCon)) {\n newNode = appendNode.cloneNode(false);\n\n const newRange = this._nodeChange_oneLine(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(commonCon), newNode, checkCss, startCon, startOff, endCon, endOff, isRemoveFormat, range.collapsed);\n\n start.container = newRange.startContainer;\n start.offset = newRange.startOffset;\n end.container = newRange.endContainer;\n end.offset = newRange.endOffset;\n }\n /** multi line */\n else {\n // get line nodes\n const lineNodes = this.getSelectedFormatElements();\n const endLength = lineNodes.length - 1; // startCon\n\n newNode = appendNode.cloneNode(false);\n start = this._nodeChange_startLine(lineNodes[0], newNode, checkCss, startCon, startOff, isRemoveFormat); // mid\n\n for (let i = 1; i < endLength; i++) {\n newNode = appendNode.cloneNode(false);\n\n this._nodeChange_middleLine(lineNodes[i], newNode, checkCss, isRemoveFormat);\n } // endCon\n\n\n if (endLength > 0) {\n newNode = appendNode.cloneNode(false);\n end = this._nodeChange_endLine(lineNodes[endLength], newNode, checkCss, endCon, endOff, isRemoveFormat);\n } else {\n end = start;\n }\n } // set range\n\n\n this.setRange(start.container, start.offset, end.container, end.offset);\n },\n\n /**\r\n * @description wraps text nodes of line selected text.\r\n * @param {Element} element - The node of the line that contains the selected text node.\r\n * @param {Element} newInnerNode - The dom that will wrap the selected text area\r\n * @param {function} validation - Check if the node should be stripped.\r\n * @param {Element} startCon - The startContainer property of the selection object.\r\n * @param {Number} startOff - The startOffset property of the selection object.\r\n * @param {Element} endCon - The endContainer property of the selection object.\r\n * @param {Number} endOff - The endOffset property of the selection object.\r\n * @param {Boolean} isRemoveFormat - Is the remove format command ?\r\n * @param {Boolean} collapsed - range.collapsed\r\n * @returns {{startContainer: *, startOffset: *, endContainer: *, endOffset: *}}\r\n * @private\r\n */\n _nodeChange_oneLine: function (element, newInnerNode, validation, startCon, startOff, endCon, endOff, isRemoveFormat, collapsed) {\n const el = element;\n const pNode = element.cloneNode(false);\n const isSameNode = startCon === endCon;\n let startContainer = startCon;\n let startOffset = startOff;\n let endContainer = endCon;\n let endOffset = endOff;\n let startPass = false;\n let endPass = false;\n let pCurrent, newNode, appendNode, cssText;\n\n function checkCss(vNode) {\n const regExp = new RegExp('(?:;|^|\\\\s)(?:' + cssText + 'null)\\\\s*:[^;]*\\\\s*(?:;|$)', 'ig');\n let style = '';\n\n if (regExp && vNode.style.cssText.length > 0) {\n style = regExp.test(vNode.style.cssText);\n }\n\n return !style;\n }\n\n (function recursionFunc(current, node) {\n const childNodes = current.childNodes;\n\n for (let i = 0, len = childNodes.length; i < len; i++) {\n let child = childNodes[i];\n let coverNode = node;\n let cloneNode; // startContainer\n\n if (!startPass && child === startContainer) {\n const prevNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(startContainer.nodeType === 1 ? '' : startContainer.substringData(0, startOffset));\n const textNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(startContainer.nodeType === 1 ? '' : startContainer.substringData(startOffset, endOffset > startOffset ? endOffset - startOffset : startOffset - endOffset));\n\n if (prevNode.data.length > 0) {\n node.appendChild(prevNode);\n }\n\n newNode = child;\n pCurrent = [];\n cssText = '';\n\n while (newNode !== pNode && newNode !== el && newNode !== null) {\n if (validation(newNode) && newNode.nodeType === 1 && checkCss(newNode)) {\n pCurrent.push(newNode.cloneNode(false));\n cssText += newNode.style.cssText.substr(0, newNode.style.cssText.indexOf(':')) + '|';\n }\n\n newNode = newNode.parentNode;\n }\n\n const childNode = pCurrent.pop() || textNode;\n appendNode = newNode = childNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n newInnerNode.appendChild(childNode);\n pNode.appendChild(newInnerNode);\n startContainer = textNode;\n startOffset = 0;\n startPass = true;\n if (newNode !== textNode) newNode.appendChild(startContainer);\n if (!isSameNode) continue;\n } // endContainer\n\n\n if (!endPass && child === endContainer) {\n const afterNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(endContainer.nodeType === 1 ? '' : endContainer.substringData(endOffset, endContainer.length - endOffset));\n const textNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(isSameNode || endContainer.nodeType === 1 ? '' : endContainer.substringData(0, endOffset));\n\n if (afterNode.data.length > 0) {\n newNode = child;\n cssText = '';\n pCurrent = [];\n\n while (newNode !== pNode && newNode !== el && newNode !== null) {\n if (newNode.nodeType === 1 && checkCss(newNode)) {\n pCurrent.push(newNode.cloneNode(false));\n cssText += newNode.style.cssText.substr(0, newNode.style.cssText.indexOf(':')) + '|';\n }\n\n newNode = newNode.parentNode;\n }\n\n cloneNode = appendNode = newNode = pCurrent.pop() || afterNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n pNode.appendChild(cloneNode);\n newNode.textContent = afterNode.data;\n }\n\n newNode = child;\n pCurrent = [];\n cssText = '';\n\n while (newNode !== pNode && newNode !== el && newNode !== null) {\n if (validation(newNode) && newNode.nodeType === 1 && checkCss(newNode)) {\n pCurrent.push(newNode.cloneNode(false));\n cssText += newNode.style.cssText.substr(0, newNode.style.cssText.indexOf(':')) + '|';\n }\n\n newNode = newNode.parentNode;\n }\n\n const childNode = pCurrent.pop() || textNode;\n appendNode = newNode = childNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n newInnerNode.appendChild(childNode);\n endContainer = textNode;\n endOffset = textNode.data.length;\n endPass = true;\n\n if (!isRemoveFormat && collapsed) {\n newInnerNode = textNode;\n textNode.textContent = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace;\n }\n\n if (newNode !== textNode) newNode.appendChild(endContainer);\n continue;\n } // other\n\n\n if (startPass) {\n if (child.nodeType === 1 && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) {\n recursionFunc(child, child);\n continue;\n }\n\n newNode = child;\n pCurrent = [];\n cssText = '';\n\n while (newNode.parentNode !== null && newNode !== el && newNode !== newInnerNode) {\n if (newNode.nodeType === 1 && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child) && (endPass || validation(newNode)) && checkCss(newNode)) {\n pCurrent.push(newNode.cloneNode(false));\n cssText += newNode.style.cssText.substr(0, newNode.style.cssText.indexOf(':')) + '|';\n }\n\n newNode = newNode.parentNode;\n }\n\n const childNode = pCurrent.pop() || child;\n appendNode = newNode = childNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n if (childNode === child) {\n if (!endPass) node = newInnerNode;else node = pNode;\n } else if (endPass) {\n pNode.appendChild(childNode);\n node = newNode;\n } else {\n newInnerNode.appendChild(childNode);\n node = newNode;\n }\n }\n\n cloneNode = child.cloneNode(false);\n node.appendChild(cloneNode);\n if (child.nodeType === 1 && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) coverNode = cloneNode;\n recursionFunc(child, coverNode);\n }\n })(element, pNode);\n\n if (isRemoveFormat) {\n startContainer = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(collapsed ? _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace : newInnerNode.textContent);\n pNode.insertBefore(startContainer, newInnerNode);\n pNode.removeChild(newInnerNode);\n if (collapsed) startOffset = 1;\n } else if (collapsed) {\n startContainer = endContainer = newInnerNode;\n startOffset = 1;\n endOffset = 1;\n }\n\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeEmptyNode(pNode);\n element.parentNode.insertBefore(pNode, element);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(element);\n return {\n startContainer: startContainer,\n startOffset: startOffset,\n endContainer: isRemoveFormat || !endContainer.textContent ? startContainer : endContainer,\n endOffset: isRemoveFormat || !endContainer.textContent ? startContainer.textContent.length : endOffset\n };\n },\n\n /**\r\n * @description wraps mid lines selected text.\r\n * @param {Element} element - The node of the line that contains the selected text node.\r\n * @param {Element} newInnerNode - The dom that will wrap the selected text area\r\n * @param {function} validation - Check if the node should be stripped.\r\n * @param {Boolean} isRemoveFormat - Is the remove format command ?\r\n * @private\r\n */\n _nodeChange_middleLine: function (element, newInnerNode, validation, isRemoveFormat) {\n if (isRemoveFormat) {\n newInnerNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(element.textContent ? element.textContent : _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace);\n } else {\n (function recursionFunc(current, node) {\n const childNodes = current.childNodes;\n\n for (let i = 0, len = childNodes.length; i < len; i++) {\n let child = childNodes[i];\n let coverNode = node;\n\n if (validation(child)) {\n let cloneNode = child.cloneNode(false);\n node.appendChild(cloneNode);\n if (child.nodeType === 1 && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) coverNode = cloneNode;\n }\n\n recursionFunc(child, coverNode);\n }\n })(element, newInnerNode);\n }\n\n element.innerHTML = '';\n element.appendChild(newInnerNode);\n },\n\n /**\r\n * @description wraps first line selected text.\r\n * @param {Element} element - The node of the line that contains the selected text node.\r\n * @param {Element} newInnerNode - The dom that will wrap the selected text area\r\n * @param {function} validation - Check if the node should be stripped.\r\n * @param {Element} startCon - The startContainer property of the selection object.\r\n * @param {Number} startOff - The startOffset property of the selection object.\r\n * @param {Boolean} isRemoveFormat - Is the remove format command ?\r\n * @returns {{container: *, offset: *}}\r\n * @private\r\n */\n _nodeChange_startLine: function (element, newInnerNode, validation, startCon, startOff, isRemoveFormat) {\n const el = element;\n const pNode = element.cloneNode(false);\n let container = startCon;\n let offset = startOff;\n let passNode = false;\n let pCurrent, newNode, appendNode;\n\n (function recursionFunc(current, node) {\n const childNodes = current.childNodes;\n\n for (let i = 0, len = childNodes.length; i < len; i++) {\n const child = childNodes[i];\n let coverNode = node;\n\n if (passNode && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) {\n if (child.nodeType === 1) {\n recursionFunc(child, child);\n continue;\n }\n\n newNode = child;\n pCurrent = [];\n\n while (newNode.parentNode !== null && newNode !== el && newNode !== newInnerNode) {\n if (newNode.nodeType === 1 && validation(newNode)) {\n pCurrent.push(newNode.cloneNode(false));\n }\n\n newNode = newNode.parentNode;\n }\n\n if (pCurrent.length > 0) {\n const childNode = pCurrent.pop();\n appendNode = newNode = childNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n newInnerNode.appendChild(childNode);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n } // startContainer\n\n\n if (!passNode && child === container) {\n const prevNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(container.nodeType === 1 ? '' : container.substringData(0, offset));\n const textNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(container.nodeType === 1 ? '' : container.substringData(offset, container.length - offset));\n\n if (prevNode.data.length > 0) {\n node.appendChild(prevNode);\n }\n\n newNode = node;\n pCurrent = [];\n\n while (newNode !== pNode && newNode !== null) {\n if (newNode.nodeType === 1 && validation(newNode)) {\n pCurrent.push(newNode.cloneNode(false));\n }\n\n newNode = newNode.parentNode;\n }\n\n const childNode = pCurrent.pop() || node;\n appendNode = newNode = childNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n if (childNode !== node) {\n newInnerNode.appendChild(childNode);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) newInnerNode.appendChild(child.cloneNode(false));\n pNode.appendChild(newInnerNode);\n container = textNode;\n offset = 0;\n passNode = true;\n node.appendChild(container);\n continue;\n }\n\n if (!passNode || validation(child)) {\n const cloneNode = child.cloneNode(false);\n node.appendChild(cloneNode);\n if (child.nodeType === 1 && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) coverNode = cloneNode;\n }\n\n recursionFunc(child, coverNode);\n }\n })(element, pNode);\n\n if (isRemoveFormat) {\n container = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(newInnerNode.textContent);\n pNode.insertBefore(container, newInnerNode);\n pNode.removeChild(newInnerNode);\n }\n\n if (!isRemoveFormat && pNode.children.length === 0) {\n if (element.childNodes) {\n container = element.childNodes[0];\n } else {\n container = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace);\n element.appendChild(container);\n }\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeEmptyNode(pNode);\n element.parentNode.insertBefore(pNode, element);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(element);\n }\n\n return {\n container: container,\n offset: offset\n };\n },\n\n /**\r\n * @description wraps last line selected text.\r\n * @param {Element} element - The node of the line that contains the selected text node.\r\n * @param {Element} newInnerNode - The dom that will wrap the selected text area\r\n * @param {function} validation - Check if the node should be stripped.\r\n * @param {Element} endCon - The endContainer property of the selection object.\r\n * @param {Number} endOff - The endOffset property of the selection object.\r\n * @param {Boolean} isRemoveFormat - Is the remove format command ?\r\n * @returns {{container: *, offset: *}}\r\n * @private\r\n */\n _nodeChange_endLine: function (element, newInnerNode, validation, endCon, endOff, isRemoveFormat) {\n const el = element;\n const pNode = element.cloneNode(false);\n let container = endCon;\n let offset = endOff;\n let passNode = false;\n let pCurrent, newNode, appendNode;\n\n (function recursionFunc(current, node) {\n const childNodes = current.childNodes;\n\n for (let i = childNodes.length - 1; 0 <= i; i--) {\n const child = childNodes[i];\n let coverNode = node;\n\n if (passNode && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) {\n if (child.nodeType === 1) {\n recursionFunc(child, child);\n continue;\n }\n\n newNode = child;\n pCurrent = [];\n\n while (newNode.parentNode !== null && newNode !== el && newNode !== newInnerNode) {\n if (validation(newNode) && newNode.nodeType === 1) {\n pCurrent.push(newNode.cloneNode(false));\n }\n\n newNode = newNode.parentNode;\n }\n\n if (pCurrent.length > 0) {\n const childNode = pCurrent.pop();\n appendNode = newNode = childNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n newInnerNode.insertBefore(childNode, newInnerNode.firstChild);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n } // endContainer\n\n\n if (!passNode && child === container) {\n const afterNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(container.nodeType === 1 ? '' : container.substringData(offset, container.length - offset));\n const textNode = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(container.nodeType === 1 ? '' : container.substringData(0, offset));\n\n if (afterNode.data.length > 0) {\n node.insertBefore(afterNode, node.firstChild);\n }\n\n newNode = node;\n pCurrent = [];\n\n while (newNode !== pNode && newNode !== null) {\n if (validation(newNode) && newNode.nodeType === 1) {\n pCurrent.push(newNode.cloneNode(false));\n }\n\n newNode = newNode.parentNode;\n }\n\n const childNode = pCurrent.pop() || node;\n appendNode = newNode = childNode;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n appendNode = newNode;\n }\n\n if (childNode !== node) {\n newInnerNode.insertBefore(childNode, newInnerNode.firstChild);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) newInnerNode.appendChild(child.cloneNode(false));\n pNode.insertBefore(newInnerNode, pNode.firstChild);\n container = textNode;\n offset = textNode.data.length;\n passNode = true;\n node.insertBefore(container, node.firstChild);\n continue;\n }\n\n if (!passNode || validation(child)) {\n const cloneNode = child.cloneNode(false);\n node.insertBefore(cloneNode, node.firstChild);\n if (child.nodeType === 1 && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isBreak(child)) coverNode = cloneNode;\n }\n\n recursionFunc(child, coverNode);\n }\n })(element, pNode);\n\n if (isRemoveFormat) {\n container = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(newInnerNode.textContent);\n offset = container.textContent.length;\n pNode.insertBefore(container, newInnerNode);\n pNode.removeChild(newInnerNode);\n }\n\n if (!isRemoveFormat && pNode.childNodes.length === 0) {\n if (element.childNodes) {\n container = element.childNodes[0];\n } else {\n container = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace);\n element.appendChild(container);\n }\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeEmptyNode(pNode);\n element.parentNode.insertBefore(pNode, element);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(element);\n }\n\n return {\n container: container,\n offset: offset\n };\n },\n\n /**\r\n * @description Execute command of command button(All Buttons except submenu and dialog)\r\n * (redo, undo, bold, underline, italic, strikethrough, subscript, superscript, removeFormat, indent, outdent, fullscreen, showBlocks, codeview, preview, print)\r\n * @param {Element} target - The element of command button\r\n * @param {String} command - Property of command button (data-value)\r\n */\n commandHandler: function (target, command) {\n switch (command) {\n case 'codeView':\n this.controllersOff();\n this.toggleCodeView();\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(target, 'on');\n break;\n\n case 'fullScreen':\n this.controllersOff();\n this.toggleFullScreen(target);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(target, 'on');\n break;\n\n case 'indent':\n case 'outdent':\n this.indent(command);\n break;\n\n case 'redo':\n case 'undo':\n this.execCommand(command, false, null);\n break;\n\n case 'removeFormat':\n this.removeFormat();\n break;\n\n case 'preview':\n case 'print':\n this.openWindowContents(command);\n break;\n\n case 'showBlocks':\n this.toggleDisplayBlocks();\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(target, 'on');\n break;\n\n case 'subscript':\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].hasClass(context.tool.superscript, 'on')) {\n this.execCommand('superscript', false, null);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(context.tool.superscript, 'on');\n }\n\n this.execCommand(command, false, null);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(target, 'on');\n break;\n\n case 'superscript':\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].hasClass(context.tool.subscript, 'on')) {\n this.execCommand('subscript', false, null);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(context.tool.subscript, 'on');\n }\n\n this.execCommand(command, false, null);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(target, 'on');\n break;\n\n default:\n // 'bold', 'underline', 'italic', 'strike'\n this.execCommand(command, false, target.getAttribute('data-value'));\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(target, 'on');\n }\n\n this.focus();\n },\n\n /**\r\n * @description Remove format of the currently selected range (IE, Edge not working)\r\n */\n removeFormat: function () {\n this.nodeChange(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement('REMOVENODE'));\n },\n\n /**\r\n * @description This method implements indentation to selected range.\r\n * Setted \"margin-left\" to \"25px\" in the top \"P\" tag of the parameter node.\r\n * @param command {String} - Separator (\"indent\" or \"outdent\")\r\n */\n indent: function (command) {\n const rangeLines = this.getSelectedFormatElements();\n let p, margin;\n\n for (let i = 0, len = rangeLines.length; i < len; i++) {\n p = rangeLines[i];\n margin = /\\d+/.test(p.style.marginLeft) ? p.style.marginLeft.match(/\\d+/)[0] * 1 : 0;\n\n if ('indent' === command) {\n margin += 25;\n } else {\n margin -= 25;\n }\n\n p.style.marginLeft = (margin < 0 ? 0 : margin) + 'px';\n }\n },\n\n /**\r\n * @description Add or remove the class name of \"body\" so that the code block is visible\r\n */\n toggleDisplayBlocks: function () {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(context.element.wysiwyg, 'sun-editor-show-block');\n },\n\n /**\r\n * @description Changes to code view or wysiwyg view\r\n */\n toggleCodeView: function () {\n const wysiwygActive = this._variable.wysiwygActive;\n const disButtons = this.codeViewDisabledButtons;\n\n for (let i = 0, len = disButtons.length; i < len; i++) {\n disButtons[i].disabled = wysiwygActive;\n }\n\n if (!wysiwygActive) {\n const code_html = context.element.code.value.trim();\n context.element.wysiwyg.innerHTML = code_html.length > 0 ? _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertContentsForEditor(code_html) : '

    ' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace + '

    ';\n context.element.wysiwyg.scrollTop = 0;\n context.element.code.style.display = 'none';\n context.element.wysiwyg.style.display = 'block';\n if (context.option.height === 'auto') context.element.code.style.height = '0px';\n this._variable.wysiwygActive = true;\n this.focus();\n } else {\n context.element.code.value = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertHTMLForCodeView(context.element.wysiwyg.innerHTML.trim());\n context.element.wysiwyg.style.display = 'none';\n context.element.code.style.display = 'block';\n if (context.option.height === 'auto') context.element.code.style.height = context.element.code.scrollHeight > 0 ? context.element.code.scrollHeight + 'px' : 'auto';\n this._variable.wysiwygActive = false;\n context.element.code.focus();\n }\n },\n\n /**\r\n * @description Changes to full screen or default screen\r\n * @param {Element} element - full screen button\r\n */\n toggleFullScreen: function (element) {\n if (!this._variable.isFullScreen) {\n this._variable.isFullScreen = true;\n context.element.topArea.style.position = 'fixed';\n context.element.topArea.style.top = '0';\n context.element.topArea.style.left = '0';\n context.element.topArea.style.width = '100%';\n context.element.topArea.style.height = '100%';\n context.element.topArea.style.zIndex = '2147483647';\n this._variable._bodyOverflow = _d.body.style.overflow;\n _d.body.style.overflow = 'hidden';\n this._variable._editorAreaOriginCssText = context.element.editorArea.style.cssText;\n this._variable._wysiwygOriginCssText = context.element.wysiwyg.style.cssText;\n this._variable._codeOriginCssText = context.element.code.style.cssText;\n context.element.editorArea.style.cssText = context.element.toolbar.style.cssText = context.element.wysiwyg.style.cssText = context.element.code.style.cssText = '';\n context.element.toolbar.style.width = context.element.wysiwyg.style.height = context.element.code.style.height = '100%';\n context.element.toolbar.style.position = 'relative';\n this._variable.innerHeight_fullScreen = _w.innerHeight - context.element.toolbar.offsetHeight;\n context.element.editorArea.style.height = this._variable.innerHeight_fullScreen + 'px';\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(element.firstElementChild, 'icon-expansion');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(element.firstElementChild, 'icon-reduction');\n } else {\n this._variable.isFullScreen = false;\n context.element.code.style.cssText = this._variable._codeOriginCssText;\n context.element.wysiwyg.style.cssText = this._variable._wysiwygOriginCssText;\n context.element.toolbar.style.cssText = '';\n context.element.editorArea.style.cssText = this._variable._editorAreaOriginCssText;\n context.element.topArea.style.cssText = this._variable._originCssText;\n _d.body.style.overflow = this._variable._bodyOverflow;\n\n if (context.option.stickyToolbar > -1) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(context.element.toolbar, 'sun-editor-sticky');\n event.onScroll_window();\n }\n\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(element.firstElementChild, 'icon-reduction');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(element.firstElementChild, 'icon-expansion');\n }\n },\n\n /**\r\n * @description Open the preview window or open the print window\r\n * @param {String} mode - 'preview' or 'print'\r\n */\n openWindowContents: function (mode) {\n const isPrint = mode === 'print';\n\n const windowObject = _w.open('', '_blank');\n\n windowObject.mimeType = 'text/html';\n windowObject.document.write('' + '' + '' + '' + '' + '' + (isPrint ? lang.toolbar.print : lang.toolbar.preview) + '' + '' + '' + '' + '
    ' + this.getContents() + '
    ' + (isPrint ? '' : '') + '' + '');\n },\n\n /**\r\n * @description Gets the current contents\r\n * @returns {Object}\r\n */\n getContents: function () {\n let contents = '';\n if (context.element.wysiwyg.innerText.trim().length === 0) return contents;\n\n if (editor._variable.wysiwygActive) {\n contents = context.element.wysiwyg.innerHTML;\n } else {\n contents = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertContentsForEditor(context.element.code.value);\n }\n\n const renderHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement('DIV');\n renderHTML.innerHTML = contents;\n const figcaptions = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildren(renderHTML, function (current) {\n return /FIGCAPTION/i.test(current.nodeName);\n });\n\n for (let i = 0, len = figcaptions.length; i < len; i++) {\n figcaptions[i].outerHTML = figcaptions[i].outerHTML.replace(/(?!^]*>)/i, '');\n }\n\n return renderHTML.innerHTML;\n }\n };\n /**\r\n * @description event function\r\n */\n\n const event = {\n _shortcutKeyCode: {\n 66: ['bold', 'B'],\n 83: ['strikethrough', 'STRIKE'],\n 85: ['underline', 'U'],\n 73: ['italic', 'I'],\n 89: ['redo'],\n 90: ['undo'],\n 219: ['outdent'],\n 221: ['indent']\n },\n _directionKeyKeyCode: new RegExp('^(?:8|13|32|46|33|34|35|36|37|38|39|40|98|100|102|104)$'),\n _changeButtonClassTagCheck: new RegExp('^(?:B|U|I|STRIKE|SUB|SUP)$'),\n _findButtonEffectTag: function () {\n const commandMap = editor.commandMap;\n const classOnCheck = this._changeButtonClassTagCheck;\n const commandMapNodes = [];\n const currentNodes = [];\n let findFormat = true,\n findFont = true,\n findSize = true,\n findA = true;\n let findB = true,\n findI = true,\n findU = true,\n findS = true;\n let cssText = '',\n nodeName = '';\n\n for (let selectionParent = editor.getSelectionNode(); !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionParent); selectionParent = selectionParent.parentNode) {\n if (!selectionParent) break;\n if (selectionParent.nodeType !== 1) continue;\n nodeName = selectionParent.nodeName.toUpperCase();\n currentNodes.push(nodeName);\n /** Format */\n\n if (findFormat && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(selectionParent)) {\n commandMapNodes.push('FORMAT');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap.FORMAT, nodeName);\n findFormat = false;\n continue;\n }\n /** Font */\n\n\n if (findFont && (selectionParent.style.fontFamily.length > 0 || selectionParent.face && selectionParent.face.length > 0)) {\n commandMapNodes.push('FONT');\n const selectFont = (selectionParent.style.fontFamily || selectionParent.face || lang.toolbar.font).replace(/[\"']/g, '');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap.FONT, selectFont);\n findFont = false;\n }\n /** A */\n\n\n if (findA && /^A$/.test(nodeName) && selectionParent.getAttribute('data-image-link') === null) {\n if (!context.link || editor.controllerArray[0] !== context.link.linkBtn) {\n editor.callPlugin('link', function () {\n editor.plugins.link.call_controller_linkButton.call(editor, selectionParent);\n });\n }\n\n findA = false;\n } else if (findA && context.link && editor.controllerArray[0] === context.link.linkBtn) {\n editor.controllersOff();\n }\n /** SPAN */\n\n\n if (findSize && /^SPAN$/.test(nodeName)) {\n /** font size */\n if (selectionParent.style.fontSize.length > 0) {\n commandMapNodes.push('SIZE');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap.SIZE, selectionParent.style.fontSize.match(/\\d+/)[0]);\n findSize = false;\n }\n }\n /** command map */\n\n\n cssText = selectionParent.style.cssText;\n\n if (findB && /font\\-weight\\s*:\\s*(?:\\d+|bold|bolder)(?:;|\\s|)/.test(cssText)) {\n commandMapNodes.push('B');\n findB = false;\n }\n\n if (findI && /font\\-style\\s*:\\s*(?:italic|oblique)(?:;|\\s)/.test(cssText)) {\n commandMapNodes.push('I');\n findI = false;\n }\n\n if (findU && /text\\-decoration(?:\\-line)?\\s*:\\s*underline(?:;|\\s|)/.test(cssText)) {\n commandMapNodes.push('U');\n findU = false;\n }\n\n if (findS && /text\\-decoration(?:\\-line)?\\s*:\\s*line-through(?:;|\\s|)/.test(cssText)) {\n commandMapNodes.push('STRIKE');\n findS = false;\n }\n\n commandMapNodes.push(/^STRONG$/.test(nodeName) ? 'B' : /^EM$/.test(nodeName) ? 'I' : nodeName);\n }\n /** A Tag edit controller off */\n\n\n if (findA) editor.controllersOff();\n /** toggle class on */\n\n for (let i = 0; i < commandMapNodes.length; i++) {\n nodeName = commandMapNodes[i];\n\n if (classOnCheck.test(nodeName)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(commandMap[nodeName], 'on');\n }\n }\n /** remove class, display text */\n\n\n for (let key in commandMap) {\n if (commandMapNodes.indexOf(key) > -1) continue;\n\n if (/^FONT/i.test(key)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap[key], lang.toolbar.font);\n } else if (/^SIZE$/i.test(key)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].changeTxt(commandMap[key], lang.toolbar.fontSize);\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(commandMap[key], 'on');\n }\n }\n /** save current nodes */\n\n\n editor._variable.currentNodes = currentNodes.reverse();\n /** Displays the current node structure to resizingBar */\n\n if (context.option.showPathLabel) context.element.navigation.textContent = editor._variable.currentNodes.join(' > ');\n },\n _cancelCaptionEdit: function () {\n this.setAttribute('contenteditable', false);\n this.removeEventListener('blur', event._cancelCaptionEdit);\n },\n onClick_toolbar: function (e) {\n e.preventDefault();\n e.stopPropagation();\n let target = e.target;\n let display = target.getAttribute('data-display');\n let command = target.getAttribute('data-command');\n let className = target.className;\n\n while (!command && !/editor_tool/.test(className) && !/sun-editor-id-toolbar/.test(className)) {\n target = target.parentNode;\n command = target.getAttribute('data-command');\n display = target.getAttribute('data-display');\n className = target.className;\n }\n\n if (!command && !display) return;\n if (target.disabled) return;\n /** Dialog, Submenu */\n\n if (display) {\n if (/submenu/.test(display) && (target.nextElementSibling === null || target !== editor.submenuActiveButton)) {\n editor.submenuOff();\n editor.callPlugin(command, function () {\n editor.submenuOn(target);\n });\n return;\n } else if (/dialog/.test(display)) {\n editor.callPlugin(command, function () {\n editor.plugins.dialog.open.call(editor, command, false);\n });\n }\n\n editor.submenuOff();\n return;\n }\n\n editor.submenuOff();\n /** default command */\n\n if (command) {\n editor.focus();\n editor.commandHandler(target, command);\n }\n },\n onClick_wysiwyg: function (e) {\n e.stopPropagation();\n const targetElement = e.target;\n editor.submenuOff();\n\n if (/^IMG$/i.test(targetElement.nodeName)) {\n e.preventDefault();\n editor.callPlugin('image', function () {\n const size = editor.plugins.resizing.call_controller_resize.call(editor, targetElement, 'image');\n editor.plugins.image.onModifyMode.call(editor, targetElement, size);\n\n if (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(targetElement, '.sun-editor-id-image-container')) {\n editor.plugins.image.openModify.call(editor, true);\n editor.plugins.image.update_image.call(editor);\n editor.controllersOff();\n }\n });\n return;\n }\n\n if (/sun-editor-id-iframe-inner-resizing-cover/i.test(targetElement.className)) {\n e.preventDefault();\n editor.callPlugin('video', function () {\n const iframe = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getChildElement(targetElement.parentNode, 'iframe');\n const size = editor.plugins.resizing.call_controller_resize.call(editor, iframe, 'video');\n editor.plugins.video.onModifyMode.call(editor, iframe, size);\n });\n return;\n }\n\n editor._setEditorRange();\n\n event._findButtonEffectTag();\n\n if (editor._isBalloon) {\n if (editor.getRange().collapsed) {\n event._hideToolbar();\n } else {\n event._showToolbarBalloon();\n\n return;\n }\n }\n\n const figcaption = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(targetElement, 'FIGCAPTION');\n\n if (figcaption && figcaption.getAttribute('contenteditable') !== 'ture') {\n e.preventDefault();\n figcaption.setAttribute('contenteditable', true);\n figcaption.focus();\n\n if (editor._isInline && !editor._inlineToolbarAttr.isShow) {\n event._showToolbarInline();\n\n const hideToolbar = function () {\n event._hideToolbar();\n\n _d.removeEventListener('click', hideToolbar);\n };\n\n _d.addEventListener('click', hideToolbar);\n }\n } else {\n const td = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(targetElement, _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell);\n\n if (td) {\n if (editor.controllerArray.length === 0) {\n editor.callPlugin('table', editor.plugins.table.call_controller_tableEdit.bind(editor, td));\n }\n }\n }\n\n if (userFunction.onClick) userFunction.onClick(e);\n },\n _showToolbarBalloon: function () {\n const range = editor.getRange();\n const padding = 20;\n const toolbar = context.element.toolbar;\n\n const selection = _w.getSelection();\n\n let isDirTop;\n\n if (selection.focusNode === selection.anchorNode) {\n isDirTop = selection.focusOffset < selection.anchorOffset;\n } else {\n const childNodes = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildNodes(range.commonAncestorContainer);\n isDirTop = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getArrayIndex(childNodes, selection.focusNode) < _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getArrayIndex(childNodes, selection.anchorNode);\n }\n\n let rects = range.getClientRects();\n rects = rects[isDirTop ? 0 : rects.length - 1];\n toolbar.style.display = 'block';\n const toolbarWidth = toolbar.offsetWidth;\n const toolbarHeight = toolbar.offsetHeight;\n let l = (isDirTop ? rects.left : rects.right) - context.element.topArea.offsetLeft + (_w.scrollX || _d.documentElement.scrollLeft) - toolbarWidth / 2;\n let t = (isDirTop ? rects.top - toolbarHeight - 11 : rects.bottom + 11) - context.element.topArea.offsetTop + (_w.scrollY || _d.documentElement.scrollTop);\n const overRight = l + toolbarWidth - context.element.topArea.offsetWidth;\n toolbar.style.left = (l < 0 ? padding : overRight < 0 ? l : l - overRight - padding) + 'px';\n toolbar.style.top = t + 'px';\n\n if (isDirTop) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(context.element._arrow, 'arrow-up');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(context.element._arrow, 'arrow-down');\n context.element._arrow.style.top = toolbarHeight + 'px';\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(context.element._arrow, 'arrow-down');\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(context.element._arrow, 'arrow-up');\n context.element._arrow.style.top = '-11px';\n }\n\n const arrow_width = context.element._arrow.offsetWidth;\n const arrow_left = toolbarWidth / 2 + (l < 0 ? l - arrow_width : overRight < 0 ? 0 : overRight + arrow_width);\n const arrow_point_width = arrow_width / 2;\n context.element._arrow.style.left = (arrow_left < arrow_point_width ? arrow_point_width : arrow_left + arrow_point_width >= toolbarWidth ? arrow_left - arrow_point_width : arrow_left) + 'px';\n },\n _showToolbarInline: function () {\n const toolbar = context.element.toolbar;\n toolbar.style.display = 'block';\n editor._inlineToolbarAttr.width = toolbar.style.width = context.option.toolbarWidth;\n editor._inlineToolbarAttr.top = toolbar.style.top = -1 - toolbar.offsetHeight + 'px';\n event.onScroll_window();\n editor._inlineToolbarAttr.isShow = true;\n },\n _hideToolbar: function () {\n context.element.toolbar.style.display = 'none';\n editor._inlineToolbarAttr.isShow = false;\n },\n onKeyDown_wysiwyg: function (e) {\n const keyCode = e.keyCode;\n const shift = e.shiftKey;\n const ctrl = e.ctrlKey || e.metaKey;\n const alt = e.altKey;\n e.stopPropagation();\n\n if (editor._isBalloon) {\n event._hideToolbar();\n }\n\n function shortcutCommand(keyCode) {\n const key = event._shortcutKeyCode[keyCode];\n if (!key) return false;\n editor.commandHandler(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getFormatElement(editor.getSelectionNode()), key[0]);\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toggleClass(editor.commandMap[key[1]], 'on');\n return true;\n }\n /** Shortcuts */\n\n\n if (ctrl && !/^(?:16|17|18)$/.test(keyCode)) {\n if (!(!shift && keyCode === 83) && shortcutCommand(keyCode)) {\n e.preventDefault();\n return;\n }\n }\n /** default key action */\n\n\n const selectionNode = editor.getSelectionNode();\n\n switch (keyCode) {\n case 8:\n /**backspace key*/\n if (_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(selectionNode) && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode.parentNode) && selectionNode.previousSibling === null) {\n e.preventDefault();\n e.stopPropagation();\n selectionNode.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace;\n return false;\n }\n\n break;\n\n case 9:\n /**tab key*/\n e.preventDefault();\n if (ctrl || alt) break;\n editor.controllersOff();\n let currentNode = selectionNode || editor.getSelectionNode();\n\n while (!_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell(currentNode) && !_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(currentNode)) {\n currentNode = currentNode.parentNode;\n }\n\n if (currentNode && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell(currentNode)) {\n const table = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getParentElement(currentNode, 'table');\n const cells = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getListChildren(table, _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isCell);\n let idx = shift ? _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].prevIdx(cells, currentNode) : _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].nextIdx(cells, currentNode);\n if (idx === cells.length && !shift) idx = 0;\n if (idx === -1 && shift) idx = cells.length - 1;\n const moveCell = cells[idx];\n if (!moveCell) return false;\n editor.setRange(moveCell, 0, moveCell, 0);\n break;\n }\n /** format Tag */\n\n\n const lines = editor.getSelectedFormatElements();\n\n if (!shift) {\n const tabText = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createTextNode(new Array(editor._variable.tabSize + 1).join('\\u00A0'));\n\n if (lines.length === 1) {\n editor.insertNode(tabText);\n editor.setRange(tabText, editor._variable.tabSize, tabText, editor._variable.tabSize);\n } else {\n for (let i = 0, len = lines.length; i < len; i++) {\n lines[i].insertBefore(tabText.cloneNode(false), lines[i].firstChild);\n }\n }\n } else {\n for (let i = 0, len = lines.length, child; i < len; i++) {\n child = lines[i].firstChild;\n\n if (/^\\s{1,4}$/.test(child.textContent)) {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(child);\n } else if (/^\\s{1,4}/.test(child.textContent)) {\n child.textContent = child.textContent.replace(/^\\s{1,4}/, '');\n }\n }\n }\n\n break;\n }\n\n if (userFunction.onKeyDown) userFunction.onKeyDown(e);\n },\n onKeyUp_wysiwyg: function (e) {\n editor._setEditorRange();\n\n editor.controllersOff();\n const selectionNode = editor.getSelectionNode();\n\n if (editor._isBalloon && !editor.getRange().collapsed) {\n event._showToolbarBalloon();\n\n return;\n }\n /** when format tag deleted */\n\n\n if (e.keyCode === 8 && _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode) && context.element.wysiwyg.textContent.length === 0) {\n e.preventDefault();\n e.stopPropagation();\n const oFormatTag = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isFormatElement(editor._variable.currentNodes[0]) ? editor._variable.currentNodes[0] : 'P');\n oFormatTag.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].zeroWidthSpace;\n selectionNode.appendChild(oFormatTag);\n editor.setSelectionNode(oFormatTag);\n editor.setRange(oFormatTag, 0, oFormatTag, 0);\n return;\n }\n\n if ((_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode.parentElement) || _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isRangeFormatElement(selectionNode.parentElement)) && selectionNode.nodeType === 3) {\n editor.execCommand('formatBlock', false, _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isWysiwygDiv(selectionNode.parentElement) ? 'P' : 'DIV');\n\n editor._setEditorRange();\n\n event._findButtonEffectTag();\n\n return;\n }\n\n if (event._directionKeyKeyCode.test(e.keyCode)) {\n event._findButtonEffectTag();\n }\n\n if (userFunction.onKeyUp) userFunction.onKeyUp(e);\n },\n onScroll_wysiwyg: function (e) {\n editor.controllersOff();\n if (userFunction.onScroll) userFunction.onScroll(e);\n },\n onDrop_wysiwyg: function (e) {\n const files = e.dataTransfer.files;\n\n if (files.length > 0) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n editor.callPlugin('image', function () {\n context.image.imgInputFile.files = files;\n editor.plugins.image.onRender_imgInput.call(editor);\n context.image.imgInputFile.files = null;\n });\n }\n\n if (userFunction.onDrop) userFunction.onDrop(e);\n },\n onMouseDown_resizingBar: function (e) {\n e.stopPropagation();\n editor._variable.resizeClientY = e.clientY;\n context.element.resizeBackground.style.display = 'block';\n\n function closureFunc() {\n context.element.resizeBackground.style.display = 'none';\n\n _d.removeEventListener('mousemove', event._resize_editor);\n\n _d.removeEventListener('mouseup', closureFunc);\n }\n\n _d.addEventListener('mousemove', event._resize_editor);\n\n _d.addEventListener('mouseup', closureFunc);\n },\n _resize_editor: function (e) {\n const resizeInterval = context.element.editorArea.offsetHeight + (e.clientY - editor._variable.resizeClientY);\n context.element.wysiwyg.style.height = context.element.code.style.height = (resizeInterval < editor._variable.minResizingSize ? editor._variable.minResizingSize : resizeInterval) + 'px';\n editor._variable.resizeClientY = e.clientY;\n },\n onResize_window: function () {\n if (context.element.toolbar.offsetWidth === 0) return;\n\n if (editor._variable.isFullScreen) {\n editor._variable.innerHeight_fullScreen += _w.innerHeight - context.element.toolbar.offsetHeight - editor._variable.innerHeight_fullScreen;\n context.element.editorArea.style.height = editor._variable.innerHeight_fullScreen + 'px';\n } else if (editor._variable._sticky) {\n context.element.toolbar.style.width = context.element.topArea.offsetWidth - 2 + 'px';\n event.onScroll_window();\n }\n\n editor.controllersOff();\n },\n onScroll_window: function () {\n if (editor._variable.isFullScreen || context.element.toolbar.offsetWidth === 0) return;\n const element = context.element;\n const editorHeight = element.editorArea.offsetHeight;\n const editorTop = element.topArea.offsetTop - (editor._isInline ? element.toolbar.offsetHeight : 0);\n const y = (this.scrollY || _d.documentElement.scrollTop) + context.option.stickyToolbar;\n\n if (y < editorTop) {\n event._offStickyToolbar(element);\n } else if (y + editor._variable.minResizingSize >= editorHeight + editorTop) {\n if (!editor._variable._sticky) event._onStickyToolbar(element);\n element.toolbar.style.top = editorHeight + editorTop + context.option.stickyToolbar - y - editor._variable.minResizingSize + 'px';\n } else if (y >= editorTop) {\n event._onStickyToolbar(element);\n }\n },\n _onStickyToolbar: function (element) {\n if (!editor._isInline) {\n element._stickyDummy.style.height = element.toolbar.offsetHeight + 'px';\n element._stickyDummy.style.display = 'block';\n }\n\n element.toolbar.style.top = context.option.stickyToolbar + 'px';\n element.toolbar.style.width = editor._isInline ? editor._inlineToolbarAttr.width : element.toolbar.offsetWidth + 'px';\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(element.toolbar, 'sun-editor-sticky');\n editor._variable._sticky = true;\n },\n _offStickyToolbar: function (element) {\n element._stickyDummy.style.display = 'none';\n element.toolbar.style.top = editor._isInline ? editor._inlineToolbarAttr.top : '';\n element.toolbar.style.width = editor._isInline ? editor._inlineToolbarAttr.width : '';\n element.editorArea.style.marginTop = '';\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeClass(element.toolbar, 'sun-editor-sticky');\n editor._variable._sticky = false;\n },\n _codeViewAutoScroll: function () {\n context.element.code.style.height = context.element.code.scrollHeight + 'px';\n },\n onPaste_wysiwyg: function (e) {\n if (!e.clipboardData.getData) return true;\n const cleanData = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cleanHTML(e.clipboardData.getData('text/html'));\n\n if (cleanData) {\n editor.execCommand('insertHTML', false, cleanData);\n e.stopPropagation();\n e.preventDefault();\n }\n }\n };\n /** add event listeners */\n\n /** toolbar event */\n\n context.element.toolbar.addEventListener('click', event.onClick_toolbar, false);\n context.element.toolbar.addEventListener('mousedown', function (e) {\n e.preventDefault();\n }, false);\n /** editor area */\n\n context.element.relative.addEventListener('click', editor.focus.bind(editor), false);\n context.element.wysiwyg.addEventListener('click', event.onClick_wysiwyg, false);\n context.element.wysiwyg.addEventListener('scroll', event.onScroll_wysiwyg, false);\n context.element.wysiwyg.addEventListener('keydown', event.onKeyDown_wysiwyg, false);\n context.element.wysiwyg.addEventListener('keyup', event.onKeyUp_wysiwyg, false);\n context.element.wysiwyg.addEventListener('drop', event.onDrop_wysiwyg, false);\n context.element.wysiwyg.addEventListener('paste', event.onPaste_wysiwyg, false);\n /** code view area auto line */\n\n if (context.option.height === 'auto') context.element.code.addEventListener('keyup', event._codeViewAutoScroll, false);\n /** resizingBar */\n\n if (context.element.resizingBar) {\n if (/\\d+/.test(context.option.height)) {\n context.element.resizingBar.addEventListener('mousedown', event.onMouseDown_resizingBar, false);\n } else {\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].addClass(context.element.resizingBar, 'none-resize');\n }\n }\n /** inlineToolbar */\n\n\n if (editor._isInline) {\n context.element.wysiwyg.addEventListener('focus', event._showToolbarInline, false);\n }\n\n if (editor._isInline || editor._isBalloon) {\n context.element.wysiwyg.addEventListener('blur', event._hideToolbar, false);\n }\n /** window event */\n\n\n _w.addEventListener('resize', event.onResize_window, false);\n\n if (context.option.stickyToolbar > -1) _w.addEventListener('scroll', event.onScroll_window, false);\n /** add plugin to plugins object */\n\n if (plugins) {\n Object.keys(plugins).map(function (key) {\n let plugin = plugins[key];\n editor.plugins[plugin.name] = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].copyObj(plugin);\n });\n }\n /** User function */\n\n\n const userFunction = {\n /**\r\n * @description Event functions\r\n * @param {Object} event - Event Object\r\n */\n onScroll: null,\n onClick: null,\n onKeyDown: null,\n onKeyUp: null,\n onDrop: null,\n\n /**\r\n * @description Called when the image is uploaded or the uploaded image is deleted\r\n * @param {Element} targetImgElement - Current img element\r\n * @param {Number} index - Uploaded index\r\n * @param {Boolean} isDelete - Whether or not it was called after the delete operation\r\n */\n onImageUpload: null,\n\n /**\r\n * @description Open a notice area\r\n * @param {String} message - Notice message\r\n */\n noticeOpen: function (message) {\n editor.addModule([_plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"]]);\n _plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"].open.call(editor, message);\n },\n\n /**\r\n * @description Close a notice area\r\n */\n noticeClose: function () {\n editor.addModule([_plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"]]);\n _plugins_modules_notice__WEBPACK_IMPORTED_MODULE_1__[\"default\"].close.call(editor);\n },\n\n /**\r\n * @description Copying the contents of the editor to the original textarea\r\n */\n save: function () {\n context.element.originElement.value = editor.getContents();\n },\n\n /**\r\n * @description Gets the suneditor's context object. Contains settings, plugins, and cached element objects\r\n * @returns {Object}\r\n */\n getContext: function () {\n return context;\n },\n\n /**\r\n * @description Gets the contents of the suneditor\r\n * @returns {String}\r\n */\n getContents: function () {\n return editor.getContents();\n },\n\n /**\r\n * @description Gets uploaded images informations\r\n * @returns {Array}\r\n */\n getImagesInfo: function () {\n return editor._variable._imagesInfo;\n },\n\n /**\r\n * @description Inserts an HTML element or HTML string or plain string at the current cursor position\r\n * @param {Element|String} html - HTML Element or HTML string or plain string\r\n */\n insertHTML: function (html) {\n if (!html.nodeType || html.nodeType !== 1) {\n const template = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createElement('template');\n template.innerHTML = html;\n html = template.firstChild || template.content.firstChild;\n }\n\n editor.insertNode(html);\n editor.focus();\n },\n\n /**\r\n * @description Change the contents of the suneditor\r\n * @param {String} contents - Contents to Input\r\n */\n setContents: function (contents) {\n if (editor._variable.wysiwygActive) {\n context.element.wysiwyg.innerHTML = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertContentsForEditor(contents);\n } else {\n context.element.code.value = contents;\n }\n },\n\n /**\r\n * @description Add contents to the suneditor\r\n * @param {String} contents - Contents to Input\r\n */\n appendContents: function (contents) {\n if (editor._variable.wysiwygActive) {\n context.element.wysiwyg.innerHTML += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertContentsForEditor(contents);\n } else {\n context.element.code.value += contents;\n }\n },\n\n /**\r\n * @description Disable the suneditor\r\n */\n disabled: function () {\n context.tool.cover.style.display = 'block';\n context.element.wysiwyg.setAttribute('contenteditable', false);\n context.element.code.setAttribute('disabled', 'disabled');\n },\n\n /**\r\n * @description Enabled the suneditor\r\n */\n enabled: function () {\n context.tool.cover.style.display = 'none';\n context.element.wysiwyg.setAttribute('contenteditable', true);\n context.element.code.removeAttribute('disabled');\n },\n\n /**\r\n * @description Show the suneditor\r\n */\n show: function () {\n const topAreaStyle = context.element.topArea.style;\n if (topAreaStyle.display === 'none') topAreaStyle.display = context.option.display;\n },\n\n /**\r\n * @description Hide the suneditor\r\n */\n hide: function () {\n context.element.topArea.style.display = 'none';\n },\n\n /**\r\n * @description Destroy the suneditor\r\n */\n destroy: function () {\n /** remove window event listeners */\n _w.removeEventListener('resize', event.onResize_window);\n\n _w.removeEventListener('scroll', event.onScroll_window);\n /** remove element */\n\n\n _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeItem(context.element.topArea);\n this.onScroll = null;\n this.onClick = null;\n this.onKeyDown = null;\n this.onKeyUp = null;\n this.onDrop = null;\n this.save = null;\n this.onImageUpload = null;\n this.noticeOpen = null;\n this.noticeClose = null;\n this.getContext = null;\n this.getContents = null;\n this.getImagesInfo = null;\n this.insertHTML = null;\n this.setContents = null;\n this.appendContents = null;\n this.disabled = null;\n this.enabled = null;\n this.show = null;\n this.hide = null;\n this.destroy = null;\n context = null;\n plugins = null;\n lang = null;\n }\n };\n return userFunction;\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (core);//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvbGliL2NvcmUuanMuanMiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9zcmMvbGliL2NvcmUuanM/OGE4ZCJdLCJzb3VyY2VzQ29udGVudCI6WyIvKlxyXG4gKiB3eXNpd3lnIHdlYiBlZGl0b3JcclxuICpcclxuICogc3VuZWRpdG9yLmpzXHJcbiAqIENvcHlyaWdodCAyMDE3IEppSG9uZyBMZWUuXHJcbiAqIE1JVCBsaWNlbnNlLlxyXG4gKi9cclxuJ3VzZSBzdHJpY3QnO1xyXG5cclxuaW1wb3J0IHV0aWwgZnJvbSAnLi91dGlsJztcclxuaW1wb3J0IG5vdGljZSBmcm9tICcuLi9wbHVnaW5zL21vZHVsZXMvbm90aWNlJztcclxuXHJcbi8qKlxyXG4gKiBAZGVzY3JpcHRpb24gU3VuRWRpdG9yIGNvcmUgY2xvc3VyZVxyXG4gKiBAcGFyYW0gY29udGV4dFxyXG4gKiBAcGFyYW0gcGx1Z2luc1xyXG4gKiBAcGFyYW0gbGFuZ1xyXG4gKiBAcmV0dXJucyB7e3NhdmU6IHNhdmUsIGdldENvbnRleHQ6IGdldENvbnRleHQsIGdldENvbnR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0aW9uIGxvYWRlZCBsYW5ndWFnZVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGxhbmc6IGxhbmcsXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBkaWFsb2cgZWxlbWVudFxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGRpYWxvZ0Zvcm06IG51bGwsXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBzdWJtZW51IGVsZW1lbnRcclxuICAgICAgICAgKi9cclxuICAgICAgICBzdWJtZW51OiBudWxsLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gYWN0aXZlIGJ1dHRvbiBlbGVtZW50IGluIHN1Ym1lbnVcclxuICAgICAgICAgKi9cclxuICAgICAgICBzdWJtZW51QWN0aXZlQnV0dG9uOiBudWxsLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gVGhlIGVsZW1lbnRzIGFycmF5IHRvIGJlIHByb2Nlc3NlZCB1bnZpc2libGUgd2hlbiB0aGUgY29udHJvbGxlcnNPZmYgZnVuY3Rpb24gaXMgZXhlY3V0ZWQgKHJlc2l6aW5nLCBsaW5rIG1vZGlmaWVkIGJ1dHRvbiwgdGFibGUgY29udHJvbGxlcilcclxuICAgICAgICAgKi9cclxuICAgICAgICBjb250cm9sbGVyQXJyYXk6IFtdLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gVGhlIGZ1bmN0aW9ucyBhcnJheSB0byBiZSBleGVjdXRlZCB3aGVuIHRoZSBjb250cm9sbGVyc09mZiBmdW5jdGlvbiBpcyBleGVjdXRlZCBleCkgaW5pdCBmdW5jdGlvbiBvZiB0YWJsZSBwbHVnaW5cclxuICAgICAgICAgKi9cclxuICAgICAgICBjb250cm9sbGVyRnVuY3Rpb246IFtdLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQW4gYXJyYXkgb2YgYnV0dG9ucyB3aG9zZSBjbGFzcyBuYW1lIGlzIG5vdCBcImNvZGUtdmlldy1lbmFibGVkXCJcclxuICAgICAgICAgKi9cclxuICAgICAgICBjb2RlVmlld0Rpc2FibGVkQnV0dG9uczogY29udGV4dC5lbGVtZW50LnRvb2xiYXIucXVlcnlTZWxlY3RvckFsbCgnLnN1bi1lZGl0b3ItaWQtdG9vbGJhciBidXR0b246bm90KFtjbGFzc349XCJjb2RlLXZpZXctZW5hYmxlZFwiXSknKSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIElzIGlubGluZSBtb2RlP1xyXG4gICAgICAgICAqIEBwcml2YXRlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgX2lzSW5saW5lOiAvaW5saW5lL2kudGVzdChjb250ZXh0Lm9wdGlvbi5tb2RlKSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIElzIGJhbGxvb24gbW9kZT9cclxuICAgICAgICAgKiBAcHJpdmF0ZVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIF9pc0JhbGxvb246IC9iYWxsb29uL2kudGVzdChjb250ZXh0Lm9wdGlvbi5tb2RlKSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIFJlcXVpcmVkIHZhbHVlIHdoZW4gdXNpbmcgaW5saW5lIG1vZGUgdG8gc3RpY2t5IHRvb2xiYXJcclxuICAgICAgICAgKiBAcHJpdmF0ZVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIF9pbmxpbmVUb29sYmFyQXR0cjoge3dpZHRoOiAwLCBoZWlnaHQ6IDAsIGlzU2hvdzogZmFsc2V9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQW4gdXNlciBldm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bmc7XHJcbiAgICAgICAgICAgIHRoaXMuc3VibWVudS5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJztcclxuICAgICAgICAgICAgdXRpbC5hZGRDbGFzcyhlbGVtZW50LCAnb24nKTtcclxuICAgICAgICAgICAgdGhpcy5zdWJtZW51QWN0aXZlQnV0dG9uID0gZWxlbWVudDtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IG92ZXJMZWZ0ID0gdGhpcy5jb250ZXh0LmVsZW1lbnQudG9vbGJhci5vZmZzZXRXaWR0aCAtIChlbGVtZW50LnBhcmVudEVsZW1lbnQub2Zmc2V0TGVmdCArIHRoaXMuc3VibWVudS5vZmZzZXRXaWR0aCk7XHJcbiAgICAgICAgICAgIGlmIChvdmVyTGVmdCA8IDApIHRoaXMuc3VibWVudS5zdHlsZS5sZWZ0ID0gb3ZlckxlZnQgKyAncHgnO1xyXG4gICAgICAgICAgICBlbHNlIHRoaXMuc3VibWVudS5zdHlsZS5sZWZ0ID0gJzFweCc7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIERpc2FibGUgc3VibWVudVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIHN1Ym1lbnVPZmY6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgaWYgKHRoaXMuc3VibWVudSkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zdWJtZW51LnN0eWxlLmRpc3BsYXkgPSAnbm9uZSc7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnN1Ym1lbnUgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVDbGFzcyh0aGlzLnN1Ym1lbnVBY3RpdmVCdXR0b24sICdvbicpO1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zdWJtZW51QWN0aXZlQnV0dG9uID0gbnVsbDtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyc09mZigpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEaXNhYmxlIGNvbnRyb2xsZXIgaW4gZWRpdG9yIGFyZWEgKGxpbmsgYnV0dG9uLCBpbWFnZSByZXNpemUgYnV0dG9uKVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGNvbnRyb2xsZXJzT2ZmOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGxlbiA9IHRoaXMuY29udHJvbGxlckFycmF5Lmxlbmd0aDtcclxuICAgICAgICAgICAgY29uc3QgZkxlbiA9IHRoaXMuY29udHJvbGxlckZ1bmN0aW9uLmxlbmd0aDtcclxuXHJcbiAgICAgICAgICAgIGlmIChsZW4gPiAwKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyQXJyYXlbaV0uc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHRoaXMuY29udHJvbGxlckFycmF5ID0gW107XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmIChmTGVuID4gMCkge1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBmTGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRyb2xsZXJGdW5jdGlvbltpXSgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyRnVuY3Rpb24gPSBbXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBqYXZhc2NyaXB0IGV4ZWND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Uge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuZm9jdXMoKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5fc2V0RWRpdG9yUmFuZ2UoKTtcclxuICAgICAgICAgICAgZXZlbnQuX2ZpbmRCdXR0b25FZmZlY3RUYWcoKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gU2F2aW5nIHRoZSByYW5nZSBvYmplY3QgYW5kIHRoZSBjdXJyZW50bHkgc2VsZWN0ZWQgbm9kZSBvZiBlZGl0b3JcclxuICAgICAgICAgKiBAcHJpdmF0ZVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIF9zZXRFZGl0b3JSYW5nZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb25zdCBzZWxlY3Rpb24gPSBfdy5nZXRTZWxlY3Rpb24oKTtcclxuICAgICAgICAgICAgbGV0IHJhbmdlID0gbnVsbDtcclxuXHJcbiAgICAgICAgICAgIGlmIChzZWxlY3Rpb24ucmFuZ2VDb3VudCA+IDApIHtcclxuICAgICAgICAgICAgICAgIHJhbmdlID0gc2VsZWN0aW9uLmdldFJhbmdlQXQoMCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICByYW5nZSA9IHRoaXMuX2NyZWF0ZURlZmF1bHRSYW5nZSgpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLl92YXJpYWJsZS5yYW5nZSA9IHJhbmdlO1xyXG5cclxuICAgICAgICAgICAgaWYgKHJhbmdlLmNvbGxhcHNlZCkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zZXRTZWxlY3Rpb25Ob2RlKHJhbmdlLmNvbW1vbkFuY2VzdG9yQ29udGFpbmVyKTtcclxuICAgICAgICAgICAgfSBlbHNlIH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GNvbW1vbkNvbikpIHJldHVybiBbdXRpbC5nZXRGb3JtYXRFbGVtZW50KGNvbW1vbkNvbildO1xyXG5cclxuICAgICAgICAgICAgLy8gZ2V0IGxpbmUgbm9kZXNcclxuICAgICAgICAgICAgY29uc3QgbGluZU5vZGVzID0gdXRpbC5nZXRMaXN0Q2hpbGRyZW4oY29tbW9uQ29uLCBmdW5jdGlvbiAoY3VycmVudCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHV0aWwuaXNGb3JtYXRFbGVtZW50KGN1cnJlbnQpO1xyXG4gICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgIGlmIChzdGFydENvbiA9PT0gZW5kQ29uKSByZXR1cm4gbGluZU5vZGVzWzBdO1xyXG5cclxuICAgICAgICAgICAgbGV0IHN0YXJ0TGluZSA9IHV0aWwuZ2V0Rm9ybWF0RWxlbWVudChzdGFydENvbik7XHJcbiAgICAgICAgICAgIGxldCBlbmRMaW5lID0gdXRpbC5nZXRGb3JtYXRFbGVtZW50KGVuZENvbik7XHJcbiAgICAgICAgICAgIGxldCBzdGFydElkeCA9IDA7XHJcbiAgICAgICAgICAgIGxldCBlbmRJZHggPSAwO1xyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGxpbmVOb2Rlcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgaWYgKHN0YXJ0TGluZSA9PT0gbGluZU5vZGVzW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc3RhcnRJZHggPSBpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGVuZExpbmUgPT09IGxpbmVOb2Rlc1tpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGVuZElkeCA9IGk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICA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50KHN0YXJ0Q29uKTtcclxuICAgICAgICAgICAgbGV0IGVuZExpbmUgPSB1dGlsLmdldFJhbmdlRm9ybWF0RWxlbWVudChlbmRDb24pO1xyXG4gICAgICAgICAgICBsZXQgc3RhcnRJZHggPSAwO1xyXG4gICAgICAgICAgICBsZXQgZW5kSWR4ID0gMDtcclxuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSByYW5nZUVsZW1lbnRzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoc3RhcnRMaW5lID09PSByYW5nZUVsZW1lbnRzW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc3RhcnRJZHggPSBpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGVuZExpbmUgPT09IHJhbmdlRWxlbWVudHNbaV0pIHtcclxuICAgICAgICAgICAgICAgICAgICBlbmRJZHggPSBpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnRJZHg7IGkgPD0gZW5kSWR4OyBpKyspIHtcclxuICAgICAgICAgICAgICAgIGlmIChyYW5nZUVsZW1lbnRzW2ldKSByYW5nZUZvcm1hdEVsZW1lbnRzLnB1c2gocmFuZ2VFbGVtZW50c1tpXSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHJldHVybiByYW5nZUZvcm1hdEVsZW1lbnRzO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEZXRlcm1pbmUgaWYgdGhpcyBvZmZzZXQgaXMgdGhlIGVkZ2Ugb2Zmc2V0IG9mIGNvbnRhaW5lclx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IHJhbmdlLnN0YXJ0Q29udGFpbmVyO1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgc3RhcnRPZmYgPSByYW5nZS5zdGFydE9mZnNldDtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGVuZENvbiA9IHJhbmdlLmVuZENvbnRhaW5lcjtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGVuZE9mZiA9IHJhbmdlLmVuZE9mZnNldDtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkNvbiA9IHJhbmdlLmNvbW1vbkFuY2VzdG9yQ29udGFpbmVyO1xyXG5cclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUgPSBzdGFydENvbjtcclxuICAgICAgICAgICAgICAgIGlmIChzdGFydENvbi5ub2RlVHlwZSA9PT0gMykge1xyXG4gICAgICAgICAgICAgICAgICAgIHBhcmVudE5vZGUgPSBzdGFydENvbi5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBObyBTZWxlY3QgcmFuZ2Ugbm9kZSAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKHJhbmdlLmNvbGxhcHNlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb21tb25Db24ubm9kZVR5cGUgPT09IDMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmlnaHROb2RlID0gY29tbW9uQ29uLnNwbGl0VGV4dChlbmRPZmYpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudE5vZGUubGFzdENoaWxkICE9PSBudWxsICYmIHV0aWwuaXNCcmVhayhwYXJlbnROb2RlLmxhc3RDaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudE5vZGUucmVtb3ZlQ2hpbGQocGFyZW50Tm9kZS5sYXN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgLyoqIFNlbGVjdCByYW5nZSBub2RlcyAqL1xyXG4gICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNTYW1lQ29udGFpbmVyID0gc3RhcnRDb24gPT09IGVuZENvbjtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzU2FtZUNvbnRhaW5lcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0VkZ2VQb2ludChlbmRDb24sIGVuZE9mZikpIHJpZ2h0Tm9kZSA9IGVuZENvbi5uZXh0U2libGluZztcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSByaWdodE5vZGUgPSBlbmRDb24uc3BsaXRUZXh0KGVuZE9mZik7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVtb3ZlTm9kZSA9IHN0YXJ0Q29uO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNFZGdlUG9pbnQoc3RhcnRDb24sIHN0YXJ0T2ZmKSkgcmVtb3ZlTm9kZSA9IHN0YXJ0Q29uLnNwbGl0VGV4dChzdGFydE9mZik7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnROb2RlLnJlbW92ZUNoaWxkKHJlbW92ZU5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVOb2RlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudE5vZGUgPSBjb21tb25Db247XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IGVuZENvbjtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChyaWdodE5vZGUucGFyZW50Tm9kZSAhPT0gY29tbW9uQ29uKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByaWdodE5vZGUgPSByaWdodE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUgPSByaWdodE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IHJpZ2h0Tm9kZS5uZXh0U2libGluZztcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKG9Ob2RlLCByaWdodE5vZGUpO1xyXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XHJcbiAgICAgICAgICAgICAgICBwYXJlbnROb2RlLmFwcGVuZENoaWxkKG9Ob2RlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEZWxldGUgdGhlIGN1cnJlbnRseSBzZWxlY3RlZCBub2RlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgcmVtb3ZlTm9kZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb25zdCByYW5nZSA9IHRoaXMuZ2V0UmFuZ2UoKTtcclxuXHJcbiAgICAgICAgICAgIGlmIChyYW5nZS5kZWxldGVDb250ZW50cykge1xyXG4gICAgICAgICAgICAgICAgcmFuZ2UuZGVsZXRlQ29udGVudHMoKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3Qgc3RhcnRDb24gPSByYW5nZS5zdGFydENvbnRhaW5lcjtcclxuICAgICAgICAgICAgY29uc3Qgc3RhcnRPZmYgPSByYW5nZS5zdGFydE9mZnNldDtcclxuICAgICAgICAgICAgY29uc3QgZW5kQ29uID0gcmFuZ2UuZW5kQ29udGFpbmVyO1xyXG4gICAgICAgICAgICBjb25zdCBlbmRPZmYgPSByYW5nZS5lbmRPZmZzZXQ7XHJcbiAgICAgICAgICAgIGNvbnN0IGNvbW1vbkNvbiA9IHJhbmdlLmNvbW1vbkFuY2VzdG9yQ29udGFpbmVyO1xyXG5cclxuICAgICAgICAgICAgbGV0IGJlZm9yZU5vZGUgPSBudWxsO1xyXG4gICAgICAgICAgICBsZXQgYWZ0ZXJOb2RlID0gbnVsbDtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZXMgPSB1dGlsLmdldExpc3RDaGlsZE5vZGVzKGNvbW1vbkNvbik7XHJcbiAgICAgICAgICAgIGxldCBzdGFydEluZGV4ID0gdXRpbC5nZXRBcnJheUluZGV4KGNoaWxkTm9kZXMsIHN0YXJ0Q29uKTtcclxuICAgICAgICAgICAgbGV0IGVuZEluZGV4ID0gdXRpbC5nZXRBcnJheUluZGV4KGNoaWxkTm9kZXMsIGVuZENvbik7XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleCArIDEsIHN0YXJ0Tm9kZSA9IHN0YXJ0Q29uOyBpID49IDA7IGktLSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkTm9kZXNbaV0gPT09IHN0YXJ0Tm9kZS5wYXJlbnROb2RlICYmIGNoaWxkTm9kZXNbaV0uZmlyc3RDaGlsZCA9PT0gc3RhcnROb2RlICYmIHN0YXJ0T2ZmID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc3RhcnRJbmRleCA9IGk7XHJcbiAgICAgICAgICAgICAgICAgICAgc3RhcnROb2RlID0gc3RhcnROb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBlbmRJbmRleCAtIDEsIGVuZE5vZGUgPSBlbmRDb247IGkgPiBzdGFydEluZGV4OyBpLS0pIHtcclxuICAgICAgICAgICAgICAgIGlmIChjaGlsZE5vZGVzW2ldID09PSBlbmROb2RlLnBhcmVudE5vZGUgJiYgY2hpbGROb2Rlc1tpXS5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZXMuc3BsaWNlKGksIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVuZE5vZGUgPSBlbmROb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgLS1lbmRJbmRleDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IHN0YXJ0SW5kZXg7IGkgPD0gZW5kSW5kZXg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGNoaWxkTm9kZXNbaV07XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0ubGVuZ3RoID09PSAwIHx8IChpdGVtLm5vZGVUeXBlID09PSAzICYmIGl0ZW0uZGF0YSA9PT0gdW5kZWZpbmVkKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShpdGVtKTtcclxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaXRlbSA9PT0gc3RhcnRDb24pIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc3RhcnRDb24ubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmVmb3JlTm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb24udGV4dENvbnRlbnQpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJlZm9yZU5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKHN0YXJ0Q29uLnN1YnN0cmluZ0RhdGEoMCwgc3RhcnRPZmYpKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChiZWZvcmVOb2RlLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb24uZGF0YSA9IGJlZm9yZU5vZGUuZGF0YTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oc3RhcnRDb24pO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0gPT09IGVuZENvbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChlbmRDb24ubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYWZ0ZXJOb2RlID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShlbmRDb24udGV4dENvbnRlbnQpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFmdGVyTm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoZW5kQ29uLnN1YnN0cmluZ0RhdGEoZW5kT2ZmLCAoZW5kQ29uLmxlbmd0aCAtIGVuZE9mZikpKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhZnRlck5vZGUubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlbmRDb24uZGF0YSA9IGFmdGVyTm9kZS5kYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShlbmRDb24pO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGl0ZW0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIGFwcGVuZGVkIGFsbCBzZWxlY3RlZCBmb3JtYXQgRWxlbWVudCB0byB0aGUgYXJndW1lbnQgZWxlbWVudCBhbmQgaW5zZXJ0XHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSB3cmFwVGFnIC0gRWxlbWVudCBvZiB3cmFwIHRoZSBhcmd1bWVudHNcclxuICAgICAgICAgKi9cclxuICAgICAgICB3cmFwVG9UYWdzOiBmdW5jdGlvbiAod3JhcFRhZykge1xyXG4gICAgICAgICAgICBjb25zdCByYW5nZSA9IHRoaXMuZ2V0UmFuZ2UoKTtcclxuICAgICAgICAgICAgY29uc3QgcmFuZ2VMaW5lcyA9IHRoaXMuZ2V0U2VsZWN0ZWRGb3JtYXRFbGVtZW50cygpO1xyXG5cclxuICAgICAgICAgICAgaWYgKCFyYW5nZUxpbmVzKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBpbm5lciA9IHV0aWwuY3JlYXRlRWxlbWVudCh1dGlsLmlzQ2VsbCh0aGlzLmdldFNlbGVjdGlvbk5vZGUoKSkgPyAnRElWJyA6ICdQJyk7XHJcbiAgICAgICAgICAgICAgICBpbm5lci5pbm5lckhUTUwgPSB1dGlsLnplcm9XaWR0aFNwYWNlO1xyXG4gICAgICAgICAgICAgICAgd3JhcFRhZy5hcHBlbmRDaGlsZChpbm5lcik7XHJcbiAgICAgICAgICAgICAgICB0aGlzLmdldFNlbGVjdGlvbk5vZGUoKS5hcHBlbmRDaGlsZCh3cmFwVGFnKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgbGV0IGxhc3QgID0gcmFuZ2VMaW5lc1tyYW5nZUxpbmVzLmxlbmd0aCAtIDFdO1xyXG4gICAgICAgICAgICBsZXQgc3RhbmRUYWcsIGJlZm9yZVRhZywgcEVsZW1lbnQ7XHJcblxyXG4gICAgICAgICAgICBpZiAodXRpbC5pc1JhbmdlRm9ybWF0RWxlbWVudChsYXN0KSB8fCB1dGlsLmlzRm9ybWF0RWxlbWVudChsYXN0KSkge1xyXG4gICAgICAgICAgICAgICAgc3RhbmRUYWcgPSBsYXN0O1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgc3RhbmRUYWcgPSB1dGlsLmdldFJhbmdlRm9ybWF0RWxlbWVudChsYXN0KSB8fCB1dGlsLmdldEZvcm1hdEVsZW1lbnQobGFzdCk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICh1dGlsLmlzQ2VsbChzdGFuZFRhZykpIHtcclxuICAgICAgICAgICAgICAgIGJlZm9yZVRhZyA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICBwRWxlbWVudCA9IHN0YW5kVGFnO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgYmVmb3JlVGFnID0gc3RhbmRUYWcubmV4dFNpYmxpbmc7XHJcbiAgICAgICAgICAgICAgICBwRWxlbWVudCA9IHN0YW5kVGFnLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGxldCBsaXN0UGFyZW50ID0gbnVsbDtcclxuICAgICAgICAgICAgbGV0IGxpbmUgPSBudWxsO1xyXG4gICAgICAgICAgICBsZXQgcHJldk5vZGVOYW1lID0gJyc7XHJcbiAgICAgICAgICAgIFxyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gcmFuZ2VMaW5lcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgbGluZSA9IHJhbmdlTGluZXNbaV07XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKC9eTEkkL2kudGVzdChsaW5lLm5vZGVOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChsaXN0UGFyZW50ID09PSBudWxsIHx8ICEvXkxJJC9pLnRlc3QocHJldk5vZGVOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0UGFyZW50ID0gdXRpbC5jcmVhdGVFbGVtZW50KGxpbmUucGFyZW50Tm9kZS5ub2RlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBsaXN0UGFyZW50LmFwcGVuZENoaWxkKGxpbmUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChpID09PSBsZW4gLSAxIHx8ICEvXkxJJC9pLnRlc3QocmFuZ2VMaW5lc1tpICsgMV0ubm9kZU5hbWUpKSB3cmFwVGFnLmFwcGVuZENoaWxkKGxpc3RQYXJlbnQpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgd3JhcFRhZy5hcHBlbmRDaGlsZChsaW5lKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBwcmV2Tm9kZU5hbWUgPSBsaW5lLm5vZGVOYW1lO1xyXG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vdmVub2RlJykpXHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSBhcHBlbmROb2RlIC0gVGhlIGRvbSB0aGF0IHdpbGwgd3JhcCB0aGUgc2VsZWN0ZWQgdGV4dCBhcmVhXHJcbiAgICAgICAgICogQHBhcmFtIHtBcnJheX0gY2hlY2tDU1NQcm9wZXJ0eUFycmF5IC0gVGhlIGNzcyBhdHRyaWJ1dGUgbmFtZSBBcnJheSB0byBjaGVjayAoWydmb250LXNpemUnXSwgWydmb250LWZhbWlseScsICdiYWNrZ3JvdW5kLWNvbG9yJywgJ2JvcmRlciddLi4uXSlcclxuICAgICAgICAgKi9cclxuICAgICAgICBub2RlQ2hhbmdlOiBmdW5jdGlvbiAoYXBwZW5kTm9kZSwgY2hlY2tDU1NQcm9wZXJ0eUFycmF5KSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHJhbmdlID0gdGhpcy5nZXRSYW5nZSgpO1xyXG4gICAgICAgICAgICBjb25zdCBpc1JlbW92ZUZvcm1hdCA9IC9yZW1vdmVub2RlL2kudGVzdChhcHBlbmROb2RlLm5vZGVOYW1lKTtcclxuICAgICAgICAgICAgbGV0IHRlbXBDb24sIHRlbXBPZmZzZXQsIHRlbXBDaGlsZCwgdGVtcEFycmF5O1xyXG5cclxuICAgICAgICAgICAgLyogY2hlY2tlZCBzYW1lIHN0eWxlIHByb3BlcnR5ICovXHJcbiAgICAgICAgICAgIGlmIChyYW5nZS5zdGFydENvbnRhaW5lciA9PT0gcmFuZ2UuZW5kQ29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgc05vZGUgPSByYW5nZS5zdGFydENvbnRhaW5lcjtcclxuICAgICAgICAgICAgICAgIGlmIChpc1JlbW92ZUZvcm1hdCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICh1dGlsLmdldEZvcm1hdEVsZW1lbnQoc05vZGUpID09PSBzTm9kZS5wYXJlbnROb2RlKSByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjaGVja0NudCA9IDA7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY2hlY2tDU1NQcm9wZXJ0eUFycmF5Lmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlKCF1dGlsLmlzRm9ybWF0RWxlbWVudChzTm9kZSkgJiYgIXV0aWwuaXNXeXNpd3lnRGl2KHNOb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNOb2RlLm5vZGVUeXBlID09PSAxICYmIHNOb2RlLnN0eWxlW2NoZWNrQ1NTUHJvcGVydHlBcnJheVtpXV0gPT09IGFwcGVuZE5vZGUuc3R5bGVbY2hlY2tDU1NQcm9wZXJ0eUFycmF5W2ldXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrQ250Kys7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzTm9kZSA9IHNOb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICBcclxuICAgICAgICAgICAgICAgICAgICBpZiAoY2hlY2tDbnQgPj0gY2hlY2tDU1NQcm9wZXJ0eUFycmF5Lmxlbmd0aCkgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiBmaW5kIHRleHQgbm9kZSAqL1xyXG4gICAgICAgICAgICB0ZW1wQ29uID0gcmFuZ2Uuc3RhcnRDb250YWluZXI7XHJcbiAgICAgICAgICAgIHRlbXBPZmZzZXQgPSByYW5nZS5zdGFydE9mZnNldDtcclxuXHJcbiAgICAgICAgICAgIGlmICh0ZW1wQ29uLm5vZGVUeXBlID09PSAxICYmIHRlbXBDb24uY2hpbGROb2Rlcy5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICB3aGlsZSAodGVtcENvbiAmJiAhdXRpbC5pc0JyZWFrKHRlbXBDb24pICYmIHRlbXBDb24ubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICB0ZW1wQXJyYXkgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICB0ZW1wQ2hpbGQgPSB0ZW1wQ29uLmNoaWxkTm9kZXM7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IHRlbXBDaGlsZC5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0ZW1wQXJyYXkucHVzaCh0ZW1wQ2hpbGRbaV0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB0ZW1wQ29uID0gdGVtcEFycmF5W3RlbXBPZmZzZXRdIHx8IHRlbXBDb24ubmV4dEVsZW1lbnRTaWJsaW5nIHx8IHRlbXBDb24ubmV4dFNpYmxpbmc7XHJcbiAgICAgICAgICAgICAgICAgICAgdGVtcE9mZnNldCA9IDA7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IHN0YXJ0Q29uID0gdGVtcENvbjtcclxuICAgICAgICAgICAgY29uc3Qgc3RhcnRPZmYgPSB0ZW1wT2Zmc2V0O1xyXG5cclxuICAgICAgICAgICAgdGVtcENvbiA9IHJhbmdlLmVuZENvbnRhaW5lcjtcclxuICAgICAgICAgICAgdGVtcE9mZnNldCA9IHJhbmdlLmVuZE9mZnNldDtcclxuICAgICAgICAgICAgaWYgKHRlbXBDb24ubm9kZVR5cGUgPT09IDEgJiYgdGVtcENvbi5jaGlsZE5vZGVzLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgIHdoaWxlICh0ZW1wQ29uICYmICF1dGlsLmlzQnJlYWsodGVtcENvbikgJiYgdGVtcENvbi5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRlbXBBcnJheSA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgIHRlbXBDaGlsZCA9IHRlbXBDb24uY2hpbGROb2RlcztcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gdGVtcENoaWxkLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRlbXBBcnJheS5wdXNoKHRlbXBDaGlsZFtpXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHRlbXBDb24gPSB0ZW1wQXJyYXlbdGVtcE9mZnNldCAtIDFdIHx8IHRlbXBBcnJheVswXSB8fCB0ZW1wQ29uLnByZXZpb3VzRWxlbWVudFNpYmxpbmcgfHwgdGVtcENvbi5wcmV2aW91c1NpYmxpbmcgfHwgc3RhcnRDb247XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB0ZW1wT2Zmc2V0ID0gdGVtcENvbi50ZXh0Q29udGVudC5sZW5ndGg7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGVuZENvbiA9IHRlbXBDb247XHJcbiAgICAgICAgICAgIGNvbnN0IGVuZE9mZiA9IHRlbXBPZmZzZXQ7XHJcbiAgICAgICAgICAgIGNvbnN0IGNvbW1vbkNvbiA9IHJhbmdlLmNvbW1vbkFuY2VzdG9yQ29udGFpbmVyO1xyXG4gICAgICAgICAgICBjb25zdCBuZXdOb2RlTmFtZSA9IGFwcGVuZE5vZGUubm9kZU5hbWU7XHJcblxyXG4gICAgICAgICAgICBsZXQgc3RhcnQgPSB7fSwgZW5kID0ge307XHJcbiAgICAgICAgICAgIGxldCBuZXdOb2RlLCByZWdFeHA7XHJcblxyXG4gICAgICAgICAgICBpZiAoY2hlY2tDU1NQcm9wZXJ0eUFycmF5KSB7XHJcbiAgICAgICAgICAgICAgICByZWdFeHAgPSAnKD86O3xefFxcXFxzKSg/OicgKyBjaGVja0NTU1Byb3BlcnR5QXJyYXlbMF07XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IGNoZWNrQ1NTUHJvcGVydHlBcnJheS5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIHJlZ0V4cCArPSAnfCcgKyBjaGVja0NTU1Byb3BlcnR5QXJyYXlbaV07XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICByZWdFeHAgKz0gJylcXFxccyo6W147XSpcXFxccyooPzo7fCQpJztcclxuICAgICAgICAgICAgICAgIHJlZ0V4cCA9IG5ldyBSZWdFeHAocmVnRXhwLCAnaWcnKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLyoqIHRhZyBjaGVjayBmdW5jdGlvbiovXHJcbiAgICAgICAgICAgIGNvbnN0IGNoZWNrQ3NzID0gZnVuY3Rpb24gKHZOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoaXNSZW1vdmVGb3JtYXQgfHwgdk5vZGUubm9kZVR5cGUgPT09IDMgfHwgdXRpbC5pc0JyZWFrKHZOb2RlKSkgcmV0dXJuIHRydWU7XHJcblxyXG4gICAgICAgICAgICAgICAgbGV0IHN0eWxlID0gJyc7XHJcbiAgICAgICAgICAgICAgICBpZiAocmVnRXhwICYmIHZOb2RlLnN0eWxlLmNzc1RleHQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHN0eWxlID0gdk5vZGUuc3R5bGUuY3NzVGV4dC5yZXBsYWNlKHJlZ0V4cCwgJycpLnRyaW0oKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoc3R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SYW5nZS5lbmRPZmZzZXQ7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgLyoqIG11bHRpIGxpbmUgKi9cclxuICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAvLyBnZXQgbGluZSBub2Rlc1xyXG4gICAgICAgICAgICAgICAgY29uc3QgbGluZU5vZGVzID0gdGhpcy5nZXRTZWxlY3RlZEZvcm1hdEVsZW1lbnRzKCk7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBlbmRMZW5ndGggPSBsaW5lTm9kZXMubGVuZ3RoIC0gMTtcclxuXHJcbiAgICAgICAgICAgICAgICAvLyBzdGFydENvblxyXG4gICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGFwcGVuZE5vZGUuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgIHN0YXJ0ID0gdGhpcy5fbm9kZUNoYW5nZV9zdGFydExpbmUobGluZU5vZGVzWzBdLCBuZXdOb2RlLCBjaGVja0Nzcywgc3RhcnRDb24sIHN0YXJ0T2ZmLCBpc1JlbW92ZUZvcm1hdCk7XHJcblxyXG4gICAgICAgICAgICAgICAgLy8gbWlkXHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IGVuZExlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGFwcGVuZE5vZGUuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9ub2RlQ2hhbmdlX21pZGRsZUxpbmUobGluZU5vZGVzW2ldLCBuZXdOb2RlLCBjaGVja0NzcywgaXNSZW1vdmVGb3JtYXQpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8vIGVuZENvblxyXG4gICAgICAgICAgICAgICAgaWYgKGVuZExlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gYXBwZW5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biA9PT0gZW5kQ29uO1xyXG4gICAgICAgICAgICBsZXQgc3RhcnRDb250YWluZXIgPSBzdGFydENvbjtcclxuICAgICAgICAgICAgbGV0IHN0YXJ0T2Zmc2V0ID0gc3RhcnRPZmY7XHJcbiAgICAgICAgICAgIGxldCBlbmRDb250YWluZXIgPSBlbmRDb247XHJcbiAgICAgICAgICAgIGxldCBlbmRPZmZzZXQgPSBlbmRPZmY7XHJcbiAgICAgICAgICAgIGxldCBzdGFydFBhc3MgPSBmYWxzZTtcclxuICAgICAgICAgICAgbGV0IGVuZFBhc3MgPSBmYWxzZTtcclxuICAgICAgICAgICAgbGV0IHBDdXJyZW50LCBuZXdOb2RlLCBhcHBlbmROb2RlLCBjc3NUZXh0O1xyXG5cclxuICAgICAgICAgICAgZnVuY3Rpb24gY2hlY2tDc3MgKHZOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCByZWdFeHAgPSBuZXcgUmVnRXhwKCcoPzo7fF58XFxcXHMpKD86JyArIGNzc1RleHQgKyAnbnVsbClcXFxccyo6W147XSpcXFxccyooPzo7fCQpJywgJ2lnJyk7XHJcbiAgICAgICAgICAgICAgICBsZXQgc3R5bGUgPSAnJztcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAocmVnRXhwICYmIHZOb2RlLnN0eWxlLmNzc1RleHQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHN0eWxlID0gcmVnRXhwLnRlc3Qodk5vZGUuc3R5bGUuY3NzVGV4dCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIFxyXG4gICAgICAgICAgICAgICAgcmV0dXJuICFzdHlsZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgKGZ1bmN0aW9uIHJlY3Vyc2lvbkZ1bmMoY3VycmVudCwgbm9kZSkge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlcyA9IGN1cnJlbnQuY2hpbGROb2RlcztcclxuXHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gY2hpbGROb2Rlcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjaGlsZCA9IGNoaWxkTm9kZXNbaV07XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvdmVyTm9kZSA9IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNsb25lTm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gc3RhcnRDb250YWluZXJcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXN0YXJ0UGFzcyAmJiBjaGlsZCA9PT0gc3RhcnRDb250YWluZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldk5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKHN0YXJ0Q29udGFpbmVyLm5vZGVUeXBlID09PSAxID8gJycgOiBzdGFydENvbnRhaW5lci5zdWJzdHJpbmdEYXRhKDAsIHN0YXJ0T2Zmc2V0KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHROb2RlID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShzdGFydENvbnRhaW5lci5ub2RlVHlwZSA9PT0gMSA/ICcnIDogc3RhcnRDb250YWluZXIuc3Vic3RyaW5nRGF0YShzdGFydE9mZnNldCwgKGVuZE9mZnNldCA+IHN0YXJ0T2Zmc2V0ID8gZW5kT2Zmc2V0IC0gc3RhcnRPZmZzZXQgOiBzdGFydE9mZnNldCAtIGVuZE9mZnNldCkpKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2Tm9kZS5kYXRhLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQocHJldk5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gY2hpbGQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNzc1RleHQgPSAnJztcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUgIT09IHBOb2RlICYmIG5ld05vZGUgIT09IGVsICYmIG5ld05vZGUgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKG5ld05vZGUpICYmIG5ld05vZGUubm9kZVR5cGUgPT09IDEgJiYgY2hlY2tDc3MobmV3Tm9kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzVGV4dCArPSBuZXdOb2RlLnN0eWxlLmNzc1RleHQuc3Vic3RyKDAsIG5ld05vZGUuc3R5bGUuY3NzVGV4dC5pbmRleE9mKCc6JykpICsgJ3wnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlID0gcEN1cnJlbnQucG9wKCkgfHwgdGV4dE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlID0gY2hpbGROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZS5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuYXBwZW5kQ2hpbGQoY2hpbGROb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcE5vZGUuYXBwZW5kQ2hpbGQobmV3SW5uZXJOb2RlKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29udGFpbmVyID0gdGV4dE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0T2Zmc2V0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRQYXNzID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdOb2RlICE9PSB0ZXh0Tm9kZSkgbmV3Tm9kZS5hcHBlbmRDaGlsZChzdGFydENvbnRhaW5lcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNTYW1lTm9kZSkgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBlbmRDb250YWluZXJcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWVuZFBhc3MgJiYgY2hpbGQgPT09IGVuZENvbnRhaW5lcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZnRlck5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKGVuZENvbnRhaW5lci5ub2RlVHlwZSA9PT0gMSA/ICcnIDogZW5kQ29udGFpbmVyLnN1YnN0cmluZ0RhdGEoZW5kT2Zmc2V0LCAoZW5kQ29udGFpbmVyLmxlbmd0aCAtIGVuZE9mZnNldCkpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dE5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKGlzU2FtZU5vZGUgfHwgZW5kQ29udGFpbmVyLm5vZGVUeXBlID09PSAxID8gJycgOiBlbmRDb250YWluZXIuc3Vic3RyaW5nRGF0YSgwLCBlbmRPZmZzZXQpKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZnRlck5vZGUuZGF0YS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gY2hpbGQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjc3NUZXh0ID0gJyc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUgIT09IHBOb2RlICYmIG5ld05vZGUgIT09IGVsICYmIG5ld05vZGUgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV3Tm9kZS5ub2RlVHlwZSA9PT0gMSAmJiBjaGVja0NzcyhuZXdOb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzc1RleHQgKz0gbmV3Tm9kZS5zdHlsZS5jc3NUZXh0LnN1YnN0cigwLCBuZXdOb2RlLnN0eWxlLmNzc1RleHQuaW5kZXhPZignOicpKSArICd8JztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZU5vZGUgPSBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpIHx8IGFmdGVyTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuYXBwZW5kQ2hpbGQobmV3Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcE5vZGUuYXBwZW5kQ2hpbGQoY2xvbmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUudGV4dENvbnRlbnQgPSBhZnRlck5vZGUuZGF0YTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGNoaWxkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjc3NUZXh0ID0gJyc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChuZXdOb2RlICE9PSBwTm9kZSAmJiBuZXdOb2RlICE9PSBlbCAmJiBuZXdOb2RlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGlvbihuZXdOb2RlKSAmJiBuZXdOb2RlLm5vZGVUeXBlID09PSAxICYmIGNoZWNrQ3NzKG5ld05vZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQucHVzaChuZXdOb2RlLmNsb25lTm9kZShmYWxzZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzc1RleHQgKz0gbmV3Tm9kZS5zdHlsZS5jc3NUZXh0LnN1YnN0cigwLCBuZXdOb2RlLnN0eWxlLmNzc1RleHQuaW5kZXhPZignOicpKSArICd8JztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBuZXdOb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZSA9IHBDdXJyZW50LnBvcCgpIHx8IHRleHROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IGNoaWxkTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuYXBwZW5kQ2hpbGQobmV3Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3SW5uZXJOb2RlLmFwcGVuZENoaWxkKGNoaWxkTm9kZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlbmRDb250YWluZXIgPSB0ZXh0Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZW5kT2Zmc2V0ID0gdGV4dE5vZGUuZGF0YS5sZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVuZFBhc3MgPSB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1JlbW92ZUZvcm1hdCAmJiBjb2xsYXBzZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZSA9IHRleHROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dE5vZGUudGV4dENvbnRlbnQgPSB1dGlsLnplcm9XaWR0aFNwYWNlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV3Tm9kZSAhPT0gdGV4dE5vZGUpIG5ld05vZGUuYXBwZW5kQ2hpbGQoZW5kQ29udGFpbmVyKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBvdGhlclxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdGFydFBhc3MpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxICYmICF1dGlsLmlzQnJlYWsoY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGNoaWxkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjc3NUZXh0ID0gJyc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChuZXdOb2RlLnBhcmVudE5vZGUgIT09IG51bGwgJiYgbmV3Tm9kZSAhPT0gZWwgJiYgbmV3Tm9kZSAhPT0gbmV3SW5uZXJOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV3Tm9kZS5ub2RlVHlwZSA9PT0gMSAmJiAhdXRpbC5pc0JyZWFrKGNoaWxkKSAmJiAoZW5kUGFzcyB8fCB2YWxpZGF0aW9uKG5ld05vZGUpKSAmJiBjaGVja0NzcyhuZXdOb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50LnB1c2gobmV3Tm9kZS5jbG9uZU5vZGUoZmFsc2UpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjc3NUZXh0ICs9IG5ld05vZGUuc3R5bGUuY3NzVGV4dC5zdWJzdHIoMCwgbmV3Tm9kZS5zdHlsZS5jc3NUZXh0LmluZGV4T2YoJzonKSkgKyAnfCc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGUgPSBwQ3VycmVudC5wb3AoKSB8fCBjaGlsZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBjaGlsZE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZE5vZGUgPT09IGNoaWxkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVuZFBhc3MpIG5vZGUgPSBuZXdJbm5lck5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIG5vZGUgPSBwTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbmRQYXNzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwTm9kZS5hcHBlbmRDaGlsZChjaGlsZE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuYXBwZW5kQ2hpbGQoY2hpbGROb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBjbG9uZU5vZGUgPSBjaGlsZC5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY2xvbmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEgJiYgIXV0aWwuaXNCcmVhayhjaGlsZCkpIGNvdmVyTm9kZSA9IGNsb25lTm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgcmVjdXJzaW9uRnVuYyhjaGlsZCwgY292ZXJOb2RlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSkoZWxlbWVudCwgcE5vZGUpO1xyXG5cclxuICAgICAgICAgICAgaWYgKGlzUmVtb3ZlRm9ybWF0KSB7XHJcbiAgICAgICAgICAgICAgICBzdGFydENvbnRhaW5lciA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoY29sbGFwc2VkID8gdXRpbC56ZXJvV2lkdGhTcGFjZSA6IG5ld0lubmVyTm9kZS50ZXh0Q29udGVudCk7XHJcbiAgICAgICAgICAgICAgICBwTm9kZS5pbnNlcnRCZWZvcmUoc3RhcnRDb250YWluZXIsIG5ld0lubmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICBwTm9kZS5yZW1vdmVDaGlsZChuZXdJbm5lck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgaWYgKGNvbGxhcHNlZCkgc3RhcnRPZmZzZXQgPSAxO1xyXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbGxhcHNlZCkge1xyXG4gICAgICAgICAgICAgICAgc3RhcnRDb250YWluZXIgPSBlbmRDb250YWluZXIgPSBuZXdJbm5lck5vZGU7XHJcbiAgICAgICAgICAgICAgICBzdGFydE9mZnNldCA9IDE7XHJcbiAgICAgICAgICAgICAgICBlbmRPZmZzZXQgPSAxO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB1dGlsLnJlbW92ZUVtcHR5Tm9kZShwTm9kZSk7XHJcbiAgICAgICAgICAgIGVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocE5vZGUsIGVsZW1lbnQpO1xyXG4gICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oZWxlbWVudCk7XHJcblxyXG4gICAgICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAgICAgc3RhcnRDb250YWluZXI6IHN0YXJ0Q29udGFpbmVyLFxyXG4gICAgICAgICAgICAgICAgc3RhcnRPZmZzZXQ6I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ZUZvcm1hdCkge1xyXG4gICAgICAgICAgICBpZiAoaXNSZW1vdmVGb3JtYXQpIHtcclxuICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoZWxlbWVudC50ZXh0Q29udGVudCA/IGVsZW1lbnQudGV4dENvbnRlbnQgOiB1dGlsLnplcm9XaWR0aFNwYWNlKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIChmdW5jdGlvbiByZWN1cnNpb25GdW5jKGN1cnJlbnQsIG5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGVzID0gY3VycmVudC5jaGlsZE5vZGVzO1xyXG4gICAgXHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGNoaWxkTm9kZXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNoaWxkID0gY2hpbGROb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvdmVyTm9kZSA9IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKGNoaWxkKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlLmFwcGVuZENoaWxkKGNsb25lTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEgJiYgIXV0aWwuaXNCcmVhayhjaGlsZCkpIGNvdmVyTm9kZSA9IGNsb25lTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBj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ICAqIEByZXR1cm5zIHt7Y29udGFpbmVyOiAqLCBvZmZzZXQ6ICp9fVxyXG4gICAgICAgICAqIEBwcml2YXRlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgX25vZGVDaGFuZ2Vfc3RhcnRMaW5lOiBmdW5jdGlvbiAoZWxlbWVudCwgbmV3SW5uZXJOb2RlLCB2YWxpZGF0aW9uLCBzdGFydENvbiwgc3RhcnRPZmYsIGlzUmVtb3ZlRm9ybWF0KSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGVsID0gZWxlbWVudDtcclxuICAgICAgICAgICAgY29uc3QgcE5vZGUgPSBlbGVtZW50LmNsb25lTm9kZShmYWxzZSk7XHJcblxyXG4gICAgICAgICAgICBsZXQgY29udGFpbmVyID0gc3RhcnRDb247XHJcbiAgICAgICAgICAgIGxldCBvZmZzZXQgPSBzdGFydE9mZjtcclxuICAgICAgICAgICAgbGV0IHBhc3NOb2RlID0gZmFsc2U7XHJcbiAgICAgICAgICAgIGxldCBwQ3VycmVudCwgbmV3Tm9kZSwgYXBwZW5kTm9kZTtcclxuXHJcbiAgICAgICAgICAgIChmdW5jdGlvbiByZWN1cnNpb25GdW5jKGN1cnJlbnQsIG5vZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZXMgPSBjdXJyZW50LmNoaWxkTm9kZXM7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gY2hpbGROb2Rlcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGROb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhc3NOb2RlICYmICF1dGlsLmlzQnJlYWsoY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdXJzaW9uRnVuYyhjaGlsZCwgY2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBjaGlsZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUucGFyZW50Tm9kZSAhPT0gbnVsbCAmJiBuZXdOb2RlICE9PSBlbCAmJiBuZXdOb2RlICE9PSBuZXdJbm5lck5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdOb2RlLm5vZGVUeXBlID09PSAxICYmIHZhbGlkYXRpb24obmV3Tm9kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IGNoaWxkTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuYXBwZW5kQ2hpbGQobmV3Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuYXBwZW5kQ2hpbGQoY2hpbGROb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld0lubmVyTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gc3RhcnRDb250YWluZXJcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXBhc3NOb2RlICYmIGNoaWxkID09PSBjb250YWluZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldk5vZGUgPSB1dGlsLmNyZWF0ZVRleHROb2RlKGNvbnRhaW5lci5ub2RlVHlwZSA9PT0gMSA/ICcnIDogY29udGFpbmVyLnN1YnN0cmluZ0RhdGEoMCwgb2Zmc2V0KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHROb2RlID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShjb250YWluZXIubm9kZVR5cGUgPT09IDEgPyAnJyA6IGNvbnRhaW5lci5zdWJzdHJpbmdEYXRhKG9mZnNldCwgKGNvbnRhaW5lci5sZW5ndGggLSBvZmZzZXQpKSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldk5vZGUuZGF0YS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlLmFwcGVuZENoaWxkKHByZXZOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChuZXdOb2RlICE9PSBwTm9kZSAmJiBuZXdOb2RlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV3Tm9kZS5ub2RlVHlwZSA9PT0gMSAmJiB2YWxpZGF0aW9uKG5ld05vZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQucHVzaChuZXdOb2RlLmNsb25lTm9kZShmYWxzZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlID0gcEN1cnJlbnQucG9wKCkgfHwgbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBjaGlsZE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZE5vZGUgIT09IG5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZS5hcHBlbmRDaGlsZChjaGlsZE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3SW5uZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodXRpbC5pc0JyZWFrKGNoaWxkKSkgbmV3SW5uZXJOb2RlLmFwcGVuZENoaWxkKGNoaWxkLmNsb25lTm9kZShmYWxzZSkpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcE5vZGUuYXBwZW5kQ2hpbGQobmV3SW5uZXJOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdGV4dE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhc3NOb2RlID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY29udGFpbmVyKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXBhc3NOb2RlIHx8IHZhbGlkYXRpb24oY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY2xvbmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxICYmICF1dGlsLmlzQnJlYWsoY2hpbGQpKSBjb3Zlck5vZGUgPSBjbG9uZU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjb3Zlck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KShlbGVtZW50LCBwTm9kZSk7XHJcblxyXG4gICAgICAgICAgICBpZiAoaXNSZW1vdmVGb3JtYXQpIHtcclxuICAgICAgICAgICAgICAgIGNvbnRhaW5lciA9IHV0aWwuY3JlYXRlVGV4dE5vZGUobmV3SW5uZXJOb2RlLnRleHRDb250ZW50KTtcclxuICAgICAgICAgICAgICAgIHBOb2RlLmluc2VydEJlZm9yZShjb250YWluZXIsIG5ld0lubmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICBwTm9kZS5yZW1vdmVDaGlsZChuZXdJbm5lck5vZGUpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoIWlzUmVtb3ZlRm9ybWF0ICYmIHBOb2RlLmNoaWxkcmVuLmxlbmd0aCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuY2hpbGROb2Rlcykge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciA9IGVsZW1lbnQuY2hpbGROb2Rlc1swXTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdXRpbC5jcmVhdGVUZXh0Tm9kZSh1dGlsLnplcm9XaWR0aFNwYWNlKTtcclxuICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFwcGVuZENoaWxkKGNvbnRhaW5lcik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUVtcHR5Tm9kZShwTm9kZSk7XHJcbiAgICAgICAgICAgICAgICBlbGVtZW50LnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHBOb2RlLCBlbGVtZW50KTtcclxuICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShlbGVtZW50KTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogY29udGFpbmVyLFxyXG4gICAgICAgICAgICAgICAgb2Zmc2V0OiBvZmZzZXRcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gd3JhcHMgbGFzdCBsaW5lIHNlbGVjdGVkIHRleHQuXHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSBlbGVtZW50IC0gVGhlIG5vZGUgb2YgdGhlIGxpbmUgdGhhdCBjb250YWlucyB0aGUgc2VsZWN0ZWQgdGV4dCBub2RlLlxyXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gbmV3SW5uZXJOb2RlIC0gVGhlIGRvbSB0aGF0IHdpbGwgd3JhcCB0aGUgc2VsZWN0ZWQgdGV4dCBhcmVhXHJcbiAgICAgICAgICogQHBhcmFtIHtmdW5jdGlvbn0gdmFsaWRhdGlvbiAtIENoZWNrIGlmIHRoZSBub2RlIHNob3VsZCBiZSBzdHJpcHBlZC5cclxuICAgICAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IGVuZENvbiAtIFRoZSBlbmRDb250YWluZXIgcHJvcGVydHkgb2YgdGhlIHNlbGVjdGlvbi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Bjb25zdCBjaGlsZCA9IGNoaWxkTm9kZXNbaV07XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvdmVyTm9kZSA9IG5vZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYXNzTm9kZSAmJiAhdXRpbC5pc0JyZWFrKGNoaWxkKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gY2hpbGQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChuZXdOb2RlLnBhcmVudE5vZGUgIT09IG51bGwgJiYgbmV3Tm9kZSAhPT0gZWwgJiYgbmV3Tm9kZSAhPT0gbmV3SW5uZXJOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGlvbihuZXdOb2RlKSAmJiBuZXdOb2RlLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQucHVzaChuZXdOb2RlLmNsb25lTm9kZShmYWxzZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBjaGlsZE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SW5uZXJOb2RlLmluc2VydEJlZm9yZShjaGlsZE5vZGUsIG5ld0lubmVyTm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld0lubmVyTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZW5kQ29udGFpbmVyXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXNzTm9kZSAmJiBjaGlsZCA9PT0gY29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFmdGVyTm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoY29udGFpbmVyLm5vZGVUeXBlID09PSAxID8gJycgOiBjb250YWluZXIuc3Vic3RyaW5nRGF0YShvZmZzZXQsIChjb250YWluZXIubGVuZ3RoIC0gb2Zmc2V0KSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0Tm9kZSA9IHV0aWwuY3JlYXRlVGV4dE5vZGUoY29udGFpbmVyLm5vZGVUeXBlID09PSAxID8gJycgOiBjb250YWluZXIuc3Vic3RyaW5nRGF0YSgwLCBvZmZzZXQpKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZnRlck5vZGUuZGF0YS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlLmluc2VydEJlZm9yZShhZnRlck5vZGUsIG5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBub2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmV3Tm9kZSAhPT0gcE5vZGUgJiYgbmV3Tm9kZSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24obmV3Tm9kZSkgJiYgbmV3Tm9kZS5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50LnB1c2gobmV3Tm9kZS5jbG9uZU5vZGUoZmFsc2UpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBuZXdOb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZSA9IHBDdXJyZW50LnBvcCgpIHx8IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlID0gY2hpbGROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZS5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGROb2RlICE9PSBub2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuaW5zZXJ0QmVmb3JlKGNoaWxkTm9kZSwgbmV3SW5uZXJOb2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3SW5uZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodXRpbC5pc0JyZWFrKGNoaWxkKSkgbmV3SW5uZXJOb2RlLmFwcGVuZENoaWxkKGNoaWxkLmNsb25lTm9kZShmYWxzZSkpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcE5vZGUuaW5zZXJ0QmVmb3JlKG5ld0lubmVyTm9kZSwgcE5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciA9IHRleHROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgPSB0ZXh0Tm9kZS5kYXRhLmxlbmd0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFzc05vZGUgPSB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5pbnNlcnRCZWZvcmUoY29udGFpbmVyLCBub2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghcGFzc05vZGUgfHwgdmFsaWRhdGlvbihjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmVOb2RlID0gY2hpbGQuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5pbnNlcnRCZWZvcmUoY2xvbmVOb2RlLCBub2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEgJiYgIXV0aWwuaXNCcmVhayhjaGlsZCkpIGNvdmVyTm9kZSA9IGNsb25lTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNvdmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pKGVsZW1lbnQsIHBOb2RlKTtcclxuXHJcbiAgICAgICAgICAgIGlmIChpc1JlbW92ZUZvcm1hdCkge1xyXG4gICAgICAgICAgICAgICAgY29udGFpbmVyID0gdXRpbC5jcmVhdGVUZXh0Tm9kZShuZXdJbm5lck5vZGUudGV4dENvbnRlbnQpO1xyXG4gICAgICAgICAgICAgICAgb2Zmc2V0ID0gY29udGFpbmVyLnRleHRDb250ZW50Lmxlbmd0aDtcclxuICAgICAgICAgICAgICAgIHBOb2RlLmluc2VydEJlZm9yZShjb250YWluZXIsIG5ld0lubmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICBwTm9kZS5yZW1vdmVDaGlsZChuZXdJbm5lck5vZGUpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoIWlzUmVtb3ZlRm9ybWF0ICYmIHBOb2RlLmNoaWxkTm9kZXMubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5jaGlsZE5vZGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gZWxlbWVudC5jaGlsZE5vZGVzWzBdO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBjb250YWluZXIgPSB1dGlsLmNyZWF0ZVRleHROb2RlKHV0aWwuemVyb1dpZHRoU3BhY2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYXBwZW5kQ2hpbGQoY29udGFpbmVyKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlRW1wdHlOb2RlKHBOb2RlKTtcclxuICAgICAgICAgICAgICAgIGVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocE5vZGUsIGVsZW1lbnQpO1xyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGVsZW1lbnQpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAgICAgY29udGFpbmVyOiBjb250YWluZXIsXHJcbiAgICAgICAgICAgICAgICBvZmZzZXQ6IG9mZnNldFxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBFeGVjdXRlIGNvbW1hbmQgb2YgY29tbWFuZCBidXR0b24oQWxsIEJ1dHRvbnMgZXhjZXB0IHN1Ym1lbnUgYW5kIGRpYWxvZylcclxuICAgICAgICAgKiAocmVkbywgdW5kbywgYm9sZCwgdW5kZXJsaW5lLCBpdGFsaWMsIHN0cmlrZXRocm91Z2gsIHN1YnNjcmlwdCwgc3VwZXJzY3JpcHQsIHJlbW92ZUZvcm1hdCwgaW5kZW50LCBvdXRkZW50LCBmdWxsc2NyZWVuLCBzaG93QmxvY2tzLCBjb2RldmlldywgcHJldmlldywgcHJpbnQpXHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSB0YXJnZXQgLSBUaGUgZWxlbWVudCBvZiBjb21tYW5kIGJ1dHRvblxyXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfSBjb21tYW5kIC0gUHJvcGVydHkgb2YgY29tbWFuZCBidXR0b24gKGRhdGEtdmFsdWUpXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgY29tbWFuZEhhbmRsZXI6IGZ1bmN0aW9uICh0YXJnZXQsIGNvbW1hbmQpIHtcclxuICAgICAgICAgICAgc3dpdGNoIChjb21tYW5kKSB7XHJcbiAgICAgICAgICAgICAgICBjYXNlICdjb2RlVmlldyc6XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyc09mZigpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMudG9nZ2xlQ29kZVZpZXcoKTtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKHRhcmdldCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICBjYXNlICdmdWxsU2NyZWVuJzpcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRyb2xsZXJzT2ZmKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50b2dnbGVGdWxsU2NyZWVuKHRhcmdldCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnaW5kZW50JzpcclxuICAgICAgICAgICAgICAgIGNhc2UgJ291dGRlbnQnOlxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuaW5kZW50KGNvbW1hbmQpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAncmVkbyc6XHJcbiAgICAgICAgICAgICAgICBjYXNlICd1bmRvJzpcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmV4ZWNDb21tYW5kKGNvbW1hbmQsIGZhbHNlLCBudWxsKTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIGNhc2UgJ3JlbW92ZUZvcm1hdCc6XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVGb3JtYXQoKTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIGNhc2UgJ3ByZXZpZXcnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAncHJpbnQnOlxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMub3BlbldpbmRvd0NvbnRlbnRzKGNvbW1hbmQpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnc2hvd0Jsb2Nrcyc6XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50b2dnbGVEaXNwbGF5QmxvY2tzKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnc3Vic2NyaXB0JzpcclxuICAgICAgICAgICAgICAgICAgICBpZiAodXRpbC5oYXNDbGFzcyhjb250ZXh0LnRvb2wuc3VwZXJzY3JpcHQsICdvbicpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY0NvbW1hbmQoJ3N1cGVyc2NyaXB0JywgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKGNvbnRleHQudG9vbC5zdXBlcnNjcmlwdCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY0NvbW1hbmQoY29tbWFuZCwgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3ModGFyZ2V0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIGNhc2UgJ3N1cGVyc2NyaXB0JzpcclxuICAgICAgICAgICAgICAgICAgICBpZiAodXRpbC5oYXNDbGFzcyhjb250ZXh0LnRvb2wuc3Vic2NyaXB0LCAnb24nKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmV4ZWNDb21tYW5kKCdzdWJzY3JpcHQnLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3MoY29udGV4dC50b29sLnN1YnNjcmlwdCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY0NvbW1hbmQoY29tbWFuZCwgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3ModGFyZ2V0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIGRlZmF1bHQgOiAvLyAnYm9sZ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gICAgY29uc3QgcmFuZ2VMaW5lcyA9IHRoaXMuZ2V0U2VsZWN0ZWRGb3JtYXRFbGVtZW50cygpO1xyXG4gICAgICAgICAgICBsZXQgcCwgbWFyZ2luO1xyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IHJhbmdlTGluZXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgIHAgPSByYW5nZUxpbmVzW2ldO1xyXG4gICAgICAgICAgICAgICAgbWFyZ2luID0gL1xcZCsvLnRlc3QocC5zdHlsZS5tYXJnaW5MZWZ0KSA/IHAuc3R5bGUubWFyZ2luTGVmdC5tYXRjaCgvXFxkKy8pWzBdICogMSA6IDA7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKCdpbmRlbnQnID09PSBjb21tYW5kKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbWFyZ2luICs9IDI1O1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBtYXJnaW4gLT0gMjU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICBcclxuICAgICAgICAgICAgICAgIHAuc3R5bGUubWFyZ2luTGVmdCA9IChtYXJnaW4gPCAwID8gMCA6IG1hcmdpbikgKyAncHgnO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEFkZCBvciByZW1vdmUgdGhlIGNsYXNzIG5hbWUgb2YgXCJib2R5XCIgc28gdGhhdCB0aGUgY29kZSBibG9jayBpcyB2aXNpYmxlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgdG9nZ2xlRGlzcGxheUJsb2NrczogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKGNvbnRleHQuZWxlbWVudC53eXNpd3lnLCAnc3VuLWVkaXRvci1zaG93LWJ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gIH1cclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQ2hhbmdlcyB0byBmdWxsIHNjcmVlbiBvciBkZWZhdWx0IHNjcmVlblxyXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gZWxlbWVudCAtIGZ1bGwgc2NyZWVuIGJ1dHRvblxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIHRvZ2dsZUZ1bGxTY3JlZW46IGZ1bmN0aW9uIChlbGVtZW50KSB7XHJcbiAgICAgICAgICAgIGlmICghdGhpcy5fdmFyaWFibGUuaXNGdWxsU2NyZWVuKSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl92YXJpYWJsZS5pc0Z1bGxTY3JlZW4gPSB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLnBvc2l0aW9uID0gJ2ZpeGVkJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLnRvcCA9ICcwJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLmxlZnQgPSAnMCc7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5zdHlsZS53aWR0aCA9ICcxMDAlJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLmhlaWdodCA9ICcxMDAlJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLnpJbmRleCA9ICcyMTQ3NDgzNjQ3JztcclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLl92YXJpYWJsZS5fYm9keU92ZXJmbG93ID0gX2QuYm9keS5zdHlsZS5vdmVyZmxvdztcclxuICAgICAgICAgICAgICAgIF9kLmJvZHkuc3R5bGUub3ZlcmZsb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gIF9kLmJvZHkuc3R5bGUub3ZlcmZsb3cgPSB0aGlzLl92YXJpYWJsZS5fYm9keU92ZXJmbG93O1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChjb250ZXh0Lm9wdGlvbi5zdGlja3lUb29sYmFyID4gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKGNvbnRleHQuZWxlbWVudC50b29sYmFyLCAnc3VuLWVkaXRvci1zdGlja3knKTtcclxuICAgICAgICAgICAgICAgICAgICBldmVudC5vblNjcm9sbF93aW5kb3coKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKGVsZW1lbnQuZmlyc3RFbGVtZW50Q2hpbGQsICdpY29uLXJlZHVjdGlvbicpO1xyXG4gICAgICAgICAgICAgICAgdXRpbC5hZGRDbGFzcyhlbGVtZW50LmZpcnN0RWxlbWVudENoaWxkLCAnaWNvbi1leHBhbnNpb24nKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBPcGVuIHRoZSBwcmV2aWV3IHdpbmRvdyBvciBvcGVuIHRoZSBwcmludCB3aW5kb3dcclxuICAgICAgICAgKiBAcGFyYW0ge1N0cmluZ30gbW9kZSAtICdwcmV2aWV3JyBvciAncHJpbnQnXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgb3BlbldpbmRvd0NvbnRlbnRzOiBmdW5jdGlvbiAobW9kZSkge1xyXG4gICAgICAgICAgICBjb25zdCBpc1ByaW50ID0gbW9kZSA9PT0gJ3ByaW50JztcclxuICAgICAgICAgICAgY29uc3Qgd2luZG93T2JqZWN0ID0gX3cub3BlbignJywgJ19ibGFuaycpO1xyXG4gICAgICAgICAgICB3aW5kb3dPYmplY3QubWltZVR5cGUgPSAndGV4dC9odG1sJztcclxuICAgICAgICAgICAgd2luZG93T2JqZWN0LmRvY3VtZW50LndyaXRlKCcnICtcclxuICAgICAgICAgICAgICAgICc8IWRvY3R5cGUgaHRtbD48aHRtbD4nICtcclxuICAgICAgICAgICAgICAgICc8aGVhZD4nICtcclxuICAgICAgICAgICAgICAgICc8bWV0YSBjaGFyc2V0PVwidXRmLThcIiAvPicgK1xyXG4gICAgICAgICAgICAgICAgJzxtZXRhIG5hbWU9XCJ2aWV3cG9ydFwiIGNvbnRlbnQ9XCJ3aWR0aD1kZXZpY2Utd2lkdGgsIGluaXRpYWwtc2NhbGU9MVwiPicgK1xyXG4gICAgICAgICAgICAgICAgJzx0aXRsZT4nICsgKGlzUHJpbnQgPyBsYW5nLnRvb2xiYXIucHJpbnQgOiBsYW5nLnRvb2xiYXIucHJldmlldykgKyAnPC90aXRsZT4nICtcclxuICAgICAgICAgICAgICAgICc8bGluayByZWw9XCJzdHlsZXNoZWV0XCIgdHlwZT1cInRleHQvY3NzXCIgaHJlZj1cIicgKyB1dGlsLmdldEluY2x1ZGVQYXRoKFsnc3VuZWRpdG9yLWNvbnRlbnRzJywgJ3N1bmVkaXRvciddLCAnY3NzJykgKyAnXCI+JyArXHJcbiAgICAgICAgICAgICAgICAnPC9oZWFkPicgK1xyXG4gICAgICAgICAgICAgICAgJzxib2R5PicgK1xyXG4gICAgICAgICAgICAgICAgJzxkaXYgY2xhc3M9XCJzdW4tZWRpdG9yLWVkaXRhYmxlXCIgc3R5bGU9XCJ3aWR0aDonICsgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcub2Zmc2V0V2lkdGggKyAncHg7IG1hcmdpbjphdXRvO1wiPicgK1xyXG4gICAgICAgICAgICAgICAgdGhpcy5nZXRDb250ZW50cygpICsgJzwvZGl2PicgK1xyXG4gICAgICAgICAgICAgICAgKGlzUHJpbnQgPyAnPHNjcmlwdD5fdy5wcmludCgpOzwvc2NyaXB0PicgOiAnJykgKyAnPC9ib2R5PicgK1xyXG4gICAgICAgICAgICAgICAgJzwvaHRtbD4nKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gR2V0cyB0aGUgY3VycmVudCBjb250ZW50c1xyXG4gICAgICAgICAqIEByZXR1cm5zIHtPYmplY3R9XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZ2V0Q29udGVudHM6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgbGV0IGNvbnRlbnRzID0gJyc7XHJcblxyXG4gICAgICAgICAgICBpZiAoY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJUZXh0LnRyaW0oKS5sZW5ndGggPT09IDApIHJldHVybiBjb250ZW50cztcclxuXHJcbiAgICAgICAgICAgIGlmIChlZGl0b3IuX3ZhcmlhYmxlLnd5c2l3eWdBY3RpdmUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnRlbnRzID0gY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGVudHMgPSB1dGlsLmNvbnZlcnRDb250ZW50c0ZvckVkaXRvcihjb250ZXh0LmVsZW1lbnQuY29kZS52YWx1ZSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IHJlbmRlckhUTUwgPSB1dGlsLmNyZWF0ZUVsZW1lbnQoJ0RJVicpO1xyXG4gICAgICAgICAgICByZW5kZXJIVE1MLmlubmVySFRNTCA9IGNvbnRlbnRzO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgZmlnY2FwdGlvbnMgPSB1dGlsLmdldExpc3RDaGlsZHJlbihyZW5kZXJIVE1MLCBmdW5jdGlvbiAoY3VycmVudCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIC9GSUdDQVBUSU9OL2kudGVzdChjdXJyZW50Lm5vZGVOYW1lKTtcclxuICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gZmlnY2FwdGlvbnMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgIGZpZ2NhcHRpb25zW2ldLm91dGVySFRNTCA9IGZpZ2NhcHRpb25zW2ldLm91dGVySFRNTC5yZXBsYWNlKC8oPyFePGZpZ2NhcHRpb25cXHMrKShjb250ZW50ZWRpdGFibGU9XCIoW2Etel0rfFxccyopXCIpXFxzKig/PVtePl0qPikvaSwgJycpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gcmVuZGVySFRNTC5pbm5lckhUTUw7XHJcbiAgICAgICAgfVxyXG4gICAgfTtcclxuXHJcbiAgICAvKipcclxuICAgICAqIEBkZXNjcmlwdGlvbiBldmVudCBmdW5jdGlvblxyXG4gICAgICovXHJcbiAgICBjb25zdCBldmVudCA9IHtcclxuICAgICAgICBfc2hvcnRjdXRLZXlDb2RlOiB7XHJcbiAgICAgICAgICAgIDY2OiBbJ2JvbGQnLCAnQiddLFxyXG4gICAgICAgICAgICA4MzogWydzdHJpa2V0aHJvdWdoJywgJ1NUUklLRSddLFxyXG4gICAgICAgICAgICA4NTogWyd1bmRlcmxpbmUnLCAnVSddLFxyXG4gICAgICAgICAgICA3MzogWydpdGFsaWMnLCAnSSddLFxyXG4gICAgICAgICAgICA4OTogWydyZWRvJ10sXHJcbiAgICAgICAgICAgIDkwOiBbJ3VuZG8nXSxcclxuICAgICAgICAgICAgMjE5OiBbJ291dGRlbnQnXSxcclxuICAgICAgICAgICAgMjIxOiBbJ2luZGVudCddXHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgX2RpcmVjdGlvbktleUtleUNvZGU6IG5ldyBSZWdFeHAoJ14oPzo4fDEzfDMyfDQ2fDMzfDM0fDM1fDM2fDM3fDM4fDM5fDQwfDk4fDEwMHwxMDJ8MTA0KSQnKSxcclxuXHJcbiAgICAgICAgX2NoYW5nZUJ1dHRvbk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0aW9uUGFyZW50Lm5vZGVOYW1lLnRvVXBwZXJDYXNlKCk7XHJcbiAgICAgICAgICAgICAgICBjdXJyZW50Tm9kZXMucHVzaChub2RlTmFtZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIEZvcm1hdCAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRGb3JtYXQgJiYgdXRpbC5pc0Zvcm1hdEVsZW1lbnQoc2VsZWN0aW9uUGFyZW50KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdGT1JNQVQnKTtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwLkZPUk1BVCwgbm9kZU5hbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRGb3JtYXQgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvKiogRm9udCAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRGb250ICYmIChzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udEZhbWlseS5sZW5ndGggPiAwIHx8IChzZWxlY3Rpb25QYXJlbnQuZmFjZSAmJiBzZWxlY3Rpb25QYXJlbnQuZmFjZS5sZW5ndGggPiAwKSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnRk9OVCcpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNlbGVjdEZvbnQgPSAoc2VsZWN0aW9uUGFyZW50LnN0eWxlLmZvbnRGYW1pbHkgfHwgc2VsZWN0aW9uUGFyZW50LmZhY2UgfHwgbGFuZy50b29sYmFyLmZvbnQpLnJlcGxhY2UoL1tcIiddL2csJycpO1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwuY2hhbmdlVHh0KGNvbW1hbmRNYXAuRk9OVCwgc2VsZWN0Rm9udCk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEZvbnQgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvKiogQSAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRBICYmIC9eQSQvLnRlc3Qobm9kZU5hbWUpICYmIHNlbGVjdGlvblBhcmVudC5nZXRBdHRyaWJ1dGUoJ2RhdGEtaW1hZ2UtbGluaycpID09PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFjb250ZXh0LmxpbmsgfHwgZWRpdG9yLmNvbnRyb2xsZXJBcnJheVswXSAhPT0gY29udGV4dC5saW5rLmxpbmtCdG4pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oJ2xpbmsnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucGx1Z2lucy5saW5rLmNhbGxfY29udHJvbGxlcl9saW5rQnV0dG9uLmNhbGwoZWRpdG9yLCBzZWxlY3Rpb25QYXJlbnQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEEgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZmluZEEgJiYgY29udGV4dC5saW5rICYmIGVkaXRvci5jb250cm9sbGVyQXJyYXlbMF0gPT09IGNvbnRleHQubGluay5saW5rQnRuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmNvbnRyb2xsZXJzT2ZmKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIFNQQU4gKi9cclxuICAgICAgICAgICAgICAgIGlmIChmaW5kU2l6ZSAmJiAvXlNQQU4kLy50ZXN0KG5vZGVOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIC8qKiBmb250IHNpemUgKi9cclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uUGFyZW50LnN0eWxlLmZvbnRTaXplLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ1NJWkUnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcC5TSVpFLCBzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udFNpemUubWF0Y2goL1xcZCsvKVswXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbmRTaXplID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBjb21tYW5kIG1hcCAqL1xyXG4gICAgICAgICAgICAgICAgY3NzVGV4dCA9IHNlbGVjdGlvblBhcmVudC5zdHlsZS5jc3NUZXh0O1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRCICYmIC9mb250XFwtd2VpZ2h0XFxzKjpcXHMqKD86XFxkK3xib2xkfGJvbGRlcikoPzo7fFxcc3wpLy50ZXN0KGNzc1RleHQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ0InKTtcclxuICAgICAgICAgICAgICAgICAgICBmaW5kQiA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRJICYmIC9mb250XFwtc3R5bGVcXHMqOlxccyooPzppdGFsaWN8b2JsaXF1ZSkoPzo7fFxccykvLnRlc3QoY3NzVGV4dCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnSScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRJID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZFUgJiYgL3RleHRcXC1kZWNvcmF0aW9uKD86XFwtbGluZSk/XFxzKjpcXHMqdW5kZXJsaW5lKD86O3xcXHN8KS8udGVzdChjc3NUZXh0KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdVJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZFUgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChmaW5kUyAmJiAvdGV4dFxcLWRlY29yYXRpb24oPzpcXC1saW5lKT9cXHMqOlxccypsaW5lLXRocm91Z2goPzo7fFxcc3wpLy50ZXN0KGNzc1RleHQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ1NUUklLRScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRTID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goKC9eU1RST05HJC8udGVzdChub2RlTmFtZSkgPyAnQicgOiAvXkVNJC8udGVzdChub2RlTmFtZSkgPyAnSScgOiBub2RlTmFtZSkpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogQSBUYWcgZWRpdCBjb250cm9sbGVyIG9mZiAqL1xyXG4gICAgICAgICAgICBpZiAoZmluZEEpIGVkaXRvci5jb250cm9sbGVyc09mZigpO1xyXG5cclxuICAgICAgICAgICAgLyoqIHRvZ2dsZSBjbGFzcyBvbiAqL1xyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvbW1hbmRNYXBOb2Rlcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgbm9kZU5hbWUgPSBjb21tYW5kTWFwTm9kZXNbaV07XHJcbiAgICAgICAgICAgICAgICBpZiAoY2xhc3NPbkNoZWNrLnRlc3Qobm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5hZGRDbGFzcyhjb21tYW5kTWFwW25vZGVOYW1lXSwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiByZW1vdmUgY2xhc3MsIGRpc3BsYXkgdGV4dCAqL1xyXG4gICAgICAgICAgICBmb3IgKGxldCBrZXkgaW4gY29tbWFuZE1hcCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKGNvbW1hbmRNYXBOb2Rlcy5pbmRleE9mKGtleSkgPiAtMSkgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICBpZiAoL15GT05UL2kudGVzdChrZXkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcFtrZXldLCBsYW5nLnRvb2xiYXIuZm9udCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBlbHNlIGlmICgvXlNJWkUkL2kudGVzdChrZXkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcFtrZXldLCBsYW5nLnRvb2xiYXIuZm9udFNpemUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVDbGFzcyhjb21tYW5kTWFwW2tleV0sICdvbicpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogc2F2ZSBjdXJyZW50IG5vZGVzICovXHJcbiAgICAgICAgICAgIGVkaXRvci5fdmFyaWFibGUuY3VycmVudE5vZGVzID0gY3VycmVudE5vZGVzLnJldmVyc2UoKTtcclxuXHJcbi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hL3N1bi1lZGl0b3ItaWQtdG9vbGJhci8udGVzdChjbGFzc05hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICB0YXJnZXQgPSB0YXJnZXQucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgIGNvbW1hbmQgPSB0YXJnZXQuZ2V0QXR0cmlidXRlKCdkYXRhLWNvbW1hbmQnKTtcclxuICAgICAgICAgICAgICAgIGRpc3BsYXkgPSB0YXJnZXQuZ2V0QXR0cmlidXRlKCdkYXRhLWRpc3BsYXknKTtcclxuICAgICAgICAgICAgICAgIGNsYXNzTmFtZSA9IHRhcmdldC5jbGFzc05hbWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICghY29tbWFuZCAmJiAhZGlzcGxheSkgcmV0dXJuO1xyXG4gICAgICAgICAgICBpZiAodGFyZ2V0LmRpc2FibGVkKSByZXR1cm47XHJcbiAgICAgICAgICAgIFxyXG4gICAgICAgICAgICAvKiogRGlhbG9nLCBTdWJtZW51ICovXHJcbiAgICAgICAgICAgIGlmIChkaXNwbGF5KSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoL3N1Ym1lbnUvLnRlc3QoZGlzcGxheSkgJiYgKHRhcmdldC5uZXh0RWxlbWVudFNpYmxpbmcgPT09IG51bGwgfHwgdGFyZ2V0ICE9PSBlZGl0b3Iuc3VibWVudUFjdGl2ZUJ1dHRvbikpIHtcclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9mZigpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5jYWxsUGx1Z2luKGNvbW1hbmQsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnN1Ym1lbnVPbih0YXJnZXQpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKC9kaWFsb2cvLnRlc3QoZGlzcGxheSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbihjb21tYW5kLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmRpYWxvZy5vcGVuLmNhbGwoZWRpdG9yLCBjb21tYW5kLCBmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgZWRpdG9yLnN1Ym1lbnVPZmYoKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZWRpdG9yLnN1Ym1lbnVPZmYoKTtcclxuXHJcbiAgICAgICAgICAgIC8qKiBkZWZhdWx0IGNvbW1hbmQgKi9cclxuICAgICAgICAgICAgaWYgKGNvbW1hbmQpIHtcclxuICAgICAgICAgICAgICAgIGVkaXRvci5mb2N1cygpO1xyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmNvbW1hbmRIYW5kbGVyKHRhcmdldCwgY29tbWFuZCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBvbkNsaWNrX3d5c2l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcbiAgICAgICAgICAgIGNvbnN0IHRhcmdldEVsZW1lbnQgPSBlLnRhcmdldDtcclxuICAgICAgICAgICAgZWRpdG9yLnN1Ym1lbnVPZmYoKTtcclxuXHJcbiAgICAgICAgICAgIGlmICgvXklNRyQvaS50ZXN0KHRhcmdldEVsZW1lbnQubm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbignaW1hZ2UnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGVkaXRvci5wbHVnaW5zLnJlc2l6aW5nLmNhbGxfY29udHJvbGxlcl9yZXNpemUuY2FsbChlZGl0b3IsIHRhcmdldEVsZW1lbnQsICdpbWFnZScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmltYWdlLm9uTW9kaWZ5TW9kZS5jYWxsKGVkaXRvciwgdGFyZ2V0RWxlbWVudCwgc2l6ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF1dGlsLmdldFBhcmVudEVsZW1lbnQodGFyZ2V0RWxlbWVudCwgJy5zdW4tZWRpdG9yLWlkLWltYWdlLWNvbnRhaW5lcicpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmltYWdlLm9wZW5Nb2RpZnkuY2FsbChlZGl0b3IsIHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucGx1Z2lucy5pbWFnZS51cGRhdGVfaW1hZ2UuY2FsbChlZGl0b3IpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY29udHJvbGxlcnNPZmYoKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICgvc3VuLWVkaXRvci1pZC1pZnJhbWUtaW5uZXItcmVzaXppbmctY292ZXIvaS50ZXN0KHRhcmdldEVsZW1lbnQuY2xhc3NOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oJ3ZpZGVvJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGlmcmFtZSA9IHV0aWwuZ2V0Q2hpbGRFbGVtZW50KHRhcmdldEVsZW1lbnQucGFyZW50Tm9kZSwgJ2lmcmFtZScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBlZGl0b3IucGx1Z2lucy5yZXNpemluZy5jYWxsX2NvbnRyb2xsZXJfcmVzaXplLmNhbGwoZWRpdG9yLCBpZnJhbWUsICd2aWRlbycpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLnZpZGVvLm9uTW9kaWZ5TW9kZS5jYWxsKGVkaXRvciwgaWZyYW1lLCBzaXplKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZWRpdG9yLl9zZXRFZGl0b3JSYW5nZSgpO1xyXG4gICAgICAgICAgICBldmVudC5fZmluZEJ1dHRvbkVmZmVjdFRhZygpO1xyXG5cclxuICAgICAgICAgICAgaWYgKGVkaXRvci5faXNCYWxsb29uKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLmdldFJhbmdlKCkuY29sbGFwc2VkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZXZlbnQuX2hpZGVUb29sYmFyKCk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGV2ZW50Ll9zaG93VG9vbGJhckJhbGxvb24oKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGZpZ2NhcHRpb24gPSB1dGlsLmdldFBhcmVudEVsZW1lbnQodGFyZ2V0RWxlbWVudCwgJ0ZJR0NBUFRJT04nKTtcclxuICAgICAgICAgICAgaWYgKGZpZ2NhcHRpb24gJiYgZmlnY2FwdGlvbi5nZXRBdHRyaWJ1dGUoJ2NvbnRlbnRlZGl0YWJsZScpICE9PSAndHVyZScpIHtcclxuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIGZpZ2NhcHRpb24uc2V0QXR0cmlidXRlKCdjb250ZW50ZWRpdGFibGUnLCB0cnVlKTtcclxuICAgICAgICAgICAgICAgIGZpZ2NhcHRpb24uZm9jdXMoKTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLl9pc0lubGluZSAmJiAhZWRpdG9yLl9pbmxpbmVUb29sYmFyQXR0ci5pc1Nob3cpIHtcclxuICAgICAgICAgICAgICAgICAgICBldmVudC5fc2hvd1Rvb2xiYXJJbmxpbmUoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkZVRvb2xiYXIgPSBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50Ll9oaWRlVG9vbGJhcigpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBfZC5yZW1vdmVFdmVudExpc3RlbmVyKCdjbGljaycsIGhpZGVUb29sYmFyKTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBfZC5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGhpZGVUb29sYmFyKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHRkID0gdXRpbC5nZXRQYXJlbnRFbGVtZW50KHRhcmdldEVsZW1lbnQsIHV0aWwuaXNDZWxsKTtcclxuICAgICAgICAgICAgICAgIGlmICh0ZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuY29udHJvbGxlckFycmF5Lmxlbmd0aCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbigndGFibGUnLCBlZGl0b3IucGx1Z2lucy50YWJsZS5jYWxsX2NvbnRyb2xsZXJfdGFibGVFZGl0LmJpbmQoZWRpdG9yLCB0ZCkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKHVzZXJGdW5jdGlvbi5vbkNsaWNrKSB1c2VyRnVuY3Rpb24ub25DbGljayhlKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBfc2hvd1Rvb2xiYXJCYWxsb29uOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHJhbmdlID0gZWRpdG9yLmdldFJhbmdlKCk7XHJcbiAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSAyMDtcclxuICAgICAgICAgICAgY29uc3QgdG9vbGJhciA9IGNvbnRleHQuZWxlbWVudC50b29sYmFyO1xyXG4gICAgICAgICAgICBjb25zdCBzZWxlY3Rpb24gPSBfdy5nZXRTZWxlY3Rpb24oKTtcclxuXHJcbiAgICAgICAgICAgIGxldCBpc0RpclRvcDtcclxuICAgICAgICAgICAgaWYgKHNlbGVjdGlvbi5mb2N1c05vZGUgPT09IHNlbGVjdGlvbi5hbmNob3JOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBpc0RpclRvcCA9IHNlbGVjdGlvbi5mb2N1c09mZnNldCA8IHNlbGVjdGlvbi5hbmNob3JPZmZzZXQ7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGVzID0gdXRpbC5nZXRMaXN0Q2hpbGROb2RlcyhyYW5nZS5jb21tb25BbmNlc3RvckNvbnRhaW5lcik7XHJcbiAgICAgICAgICAgICAgICBpc0RpclRvcCA9IHV0aWwuZ2V0QXJyYXlJbmRleChjaGls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XRXaWR0aDtcclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgIHRvb2xiYXIuc3R5bGUubGVmdCA9IChsIDwgMCA/IHBhZGRpbmcgOiBvdmVyUmlnaHQgPCAwID8gbCA6IGwgLSBvdmVyUmlnaHQgLSBwYWRkaW5nKSArICdweCc7XHJcbiAgICAgICAgICAgIHRvb2xiYXIuc3R5bGUudG9wID0gKHQpICsgJ3B4JztcclxuXHJcbiAgICAgICAgICAgIGlmIChpc0RpclRvcCkge1xyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVDbGFzcyhjb250ZXh0LmVsZW1lbnQuX2Fycm93LCAnYXJyb3ctdXAnKTtcclxuICAgICAgICAgICAgICAgIHV0aWwuYWRkQ2xhc3MoY29udGV4dC5lbGVtZW50Ll9hcnJvdywgJ2Fycm93LWRvd24nKTtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC5fYXJyb3cuc3R5bGUudG9wID0gKHRvb2xiYXJIZWlnaHQpICsgJ3B4JztcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3MoY29udGV4dC5lbGVtZW50Ll9hcnJvdywgJ2Fycm93LWRvd24nKTtcclxuICAgICAgICAgICAgICAgIHV0aWwuYWRkQ2xhc3MoY29udGV4dC5lbGVtZW50Ll9hcnJvdywgJ2Fycm93LXVwJyk7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQuX2Fycm93LnN0eWxlLnRvcCA9ICctMTFweCc7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGFycm93X3dpZHRoID0gY29udGV4dC5lbGVtZW50Ll9hcnJvdy5vZmZzZXRXaWR0aDtcclxuICAgICAgICAgICAgY29uc3QgYXJyb3dfbGVmdCA9ICh0b29sYmFyV2lkdGggLyAyICsgKGwgPCAwID8gbCAtIGFycm93X3dpZHRoIDogb3ZlclJpZ2h0IDwgMCA/IDAgOiBvdmVyUmlnaHQgKyBhcnJvd193aWR0aCkpO1xyXG4gICAgICAgICAgICBjb25zdCBhcnJvd19wb2ludF93aWR0aCA9IGFycm93X3dpZHRoIC8gMjtcclxuICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Ll9hcnJvdy5zdHlsZS5sZWZ0ID0gKGFycm93X2xlZnQgPCBhcnJvd19wb2ludF93aWR0aCA/IGFycm93X3BvaW50X3dpZHRoIDogYXJyb3dfbGVmdCArIGFycm93X3BvaW50X3dpZHRoID49IHRvb2xiYXJXaWR0aCA/IGFycm93X2xlZnQgLSBhcnJvd19wb2ludF93aWR0aCA6IGFycm93X2xlZnQpICsgJ3B4JztcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBfc2hvd1Rvb2xiYXJJbmxpbmU6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29uc3QgdG9vbGJhciA9IGNvbnRleHQuZWxlbWVudC50b29sYmFyO1xyXG4gICAgICAgICAgICB0b29sYmFyLnN0eWxlLmRpc3BsYXkgPSAnYmxvY2snO1xyXG4gICAgICAgICAgICBlZGl0b3IuX2lubGluZVRvb2xiYXJBdHRyLndpZHRoID0gdG9vbGJhci5zdHlsZS53aWR0aCA9IGNvbnRleHQub3B0aW9uLnRvb2xiYXJXaWR0aDtcclxuICAgICAgICAgICAgZWRpdG9yLl9pbmxpbmVUb29sYmFyQXR0ci50b3AgPSB0b29sYmFyLnN0eWxlLnRvcCA9ICgtMSAtIHRvb2xiYXIub2Zmc2V0SGVpZ2h0KSArICdweCc7XHJcbiAgICAgICAgICAgIGV2ZW50Lm9uU2Nyb2xsX3dpbmRvdygpO1xyXG4gICAgICAgICAgICBlZGl0b3IuX2lubGluZVRvb2xiYXJBdHRyLmlzU2hvdyA9IHRydWU7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgX2hpZGVUb29sYmFyOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b29sYmFyLnN0eWxlLmRpc3BsYXkgPSAnbm9uZSc7XHJcbiAgICAgICAgICAgIGVkaXRvci5faW5saW5lVG9vbGJhckF0dHIuaXNTaG93ID0gZmFsc2U7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgb25LZXlEb3duX3d5c2l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGtleUNvZGUgPSBlLmtleUNvZGU7XHJcbiAgICAgICAgICAgIGNvbnN0IHNoaWZ0ID0gZS5zaGlmdEtleTtcclxuICAgICAgICAgICAgY29uc3QgY3RybCA9IGUuY3RybEtleSB8fCBlLm1ldGFLZXk7XHJcbiAgICAgICAgICAgIGNvbnN0IGFsdCA9IGUuYWx0S2V5O1xyXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG5cclxuICAgICAgICAgICAgaWYgKGVkaXRvci5faXNCYWxsb29uKSB7XHJcbiAgICAgICAgICAgICAgICBldmVudC5faGlkZVRvb2xiYXIoKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZnVuY3Rpb24gc2hvcnRjdXRDb21tYW5kKGtleUNvZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGV2ZW50Ll9zaG9ydGN1dEtleUNvZGVba2V5Q29kZV07XHJcbiAgICAgICAgICAgICAgICBpZiAoIWtleSkgcmV0dXJuIGZhbHNlO1xyXG5cclxuICAgICAgICAgICAgICAgIGVkaXRvci5jb21tYW5kSGFuZGxlcih1dGlsLmdldEZvcm1hdEVsZW1lbnQoZWRpdG9yLmdldFNlbGVjdGlvbk5vZGUoKSksIGtleVswXSk7XHJcbiAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKGVkaXRvci5jb21tYW5kTWFwW2tleVsxXV0sICdvbicpO1xyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogU2hvcnRjdXRzICovXHJcbiAgICAgICAgICAgIGlmIChjdHJsICYmICEvXig/OjE2fDE3fDE4KSQvLnRlc3Qoa2V5Q29kZSkpIHtcclxuICAgICAgICAgICAgICAgIGlmICghKCFzaGlmdCAmJiBrZXlDb2RlID09PSA4MykgJiYgc2hvcnRjdXRDb21tYW5kKGtleUNvZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLyoqIGRlZmF1bHQga2V5IGFjdGlvbiAqL1xyXG4gICAgICAgICAgICBjb25zdCBzZWxlY3Rpb25Ob2RlID0gZWRpdG9yLmdldFNlbGVjdGlvbk5vZGUoKTtcclxuICAgICAgICAgICAgc3dpdGNoIChrZXlDb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjYXNlIDg6IC8qKmJhY2tzcGFjZSBrZXkqL1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICh1dGlsLmlzRm9ybWF0RWxlbWVudChzZWxlY3Rpb25Ob2RlKSAmJiB1dGlsLmlzV3lzaXd5Z0RpdihzZWxlY3Rpb25Ob2RlLnBhcmVudE5vZGUpICYmIHNlbGVjdGlvbk5vZGUucHJldmlvdXNTaWJsaW5nID09PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0aW9uTm9kZS5pbm5lckhUTUwgPSB1dGlsLnplcm9XaWR0aFNwYWNlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIFxyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSA5OlxyXG4gICAgICAgICAgICAgICAgICAgIC8qKnRhYiBrZXkqL1xyXG4gICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoY3RybCB8fCBhbHQpIGJyZWFrO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY29udHJvbGxlcnNPZmYoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGN1cnJlbnROb2RlID0gc2VsZWN0aW9uTm9kZSB8fCBlZGl0b3IuZ2V0U2VsZWN0aW9uTm9kZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHdoaWxlICghdXRpbC5pc0NlbGwoY3VycmVudE5vZGUpICYmICF1dGlsLmlzV3lzaXd5Z0RpdihjdXJyZW50Tm9kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudE5vZGUgPSBjdXJyZW50Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnROb2RlICYmIHV0aWwuaXNDZWxsKGN1cnJlbnROb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IHV0aWwuZ2V0UGFyZW50RWxlbWVudChjdXJyZW50Tm9kZSwgJ3RhYmxlJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNlbGxzID0gdXRpbC5nZXRMaXN0Q2hpbGRyZW4odGFibGUsIHV0aWwuaXNDZWxsKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlkeCA9IHNoaWZ0ID8gdXRpbC5wcmV2SWR4KGNlbGxzLCBjdXJyZW50Tm9kZSkgOiB1dGlsLm5leHRJZHgoY2VsbHMsIGN1cnJlbnROb2RlKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpZHggPT09IGNlbGxzLmxlbmd0aCAmJiAhc2hpZnQpIGlkeCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpZHggPT09IC0xICYmIHNoaWZ0KSBpZHggPSBjZWxscy5sZW5ndGggLSAxO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbW92ZUNlbGwgPSBjZWxsc1tpZHhdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1vdmVDZWxsKSByZXR1cm4gZmFsc2U7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UmFuZ2UobW92ZUNlbGwsIDAsIG1vdmVDZWxsLCAwKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLyoqIGZvcm1hdCBUYWcgKi9cclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5lcyA9IGVkaXRvci5nZXRTZWxlY3RlZEZvcm1hdEVsZW1lbnRzKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghc2hpZnQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFiVGV4dCA9IHV0aWwuY3JlYXRlVGV4dE5vZGUobmV3IEFycmF5KGVkaXRvci5fdmFyaWFibGUudGFiU2l6ZSArIDEpLmpvaW4oJ1xcdTAwQTAnKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lcy5sZW5ndGggPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pbnNlcnROb2RlKHRhYlRleHQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFJhbmdlKHRhYlRleHQsIGVkaXRvci5fdmFyaWFibGUudGFiU2l6ZSwgdGFiVGV4dCwgZWRpdG9yLl92YXJpYWJsZS50YWJTaXplKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBsaW5lcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVzW2ldLmluc2VydEJlZm9yZSh0YWJUZXh0LmNsb25lTm9kZShmYWxzZSksIGxpbmVzW2ldLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGxpbmVzLmxlbmd0aCwgY2hpbGQ7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGQgPSBsaW5lc1tpXS5maXJzdENoaWxkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC9eXFxzezEsNH0kLy50ZXN0KGNoaWxkLnRleHRDb250ZW50KSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShjaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKC9eXFxzezEsNH0vLnRlc3QoY2hpbGQudGV4dENvbnRlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGQudGV4dENvbnRlbnQgPSBjaGlsZC50ZXh0Q29udGVudC5yZXBsYWNlKC9eXFxzezEsNH0vLCAnJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAodXNlckZ1bmN0aW9uLm9uS2V5RG93bikgdXNlckZ1bmN0aW9uLm9uS2V5RG93bihlKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBvbktleVVwX3d5c2l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGVkaXRvci5fc2V0RWRpdG9yUmFuZ2UoKTtcclxuICAgICAgICAgICAgZWRpdG9yLmNvbnRyb2xsZXJzT2ZmKCk7XHJcbiAgICAgICAgICAgIGNvbnN0IHNlbGVjdGlvbk5vZGUgPSBlZGl0b3IuZ2V0U2VsZWN0aW9uTm9kZSgpO1xyXG5cclxuICAgICAgICAgICAgaWYgKGVkaXRvci5faXNCYWxsb29uICYmICFlZGl0b3IuZ2V0UmFuZ2UoKS5jb2xsYXBzZWQpIHtcclxuICAgICAgICAgICAgICAgIGV2ZW50Ll9zaG93VG9vbGJhckJhbGxvb24oKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLyoqIHdoZW4gZm9ybWF0IHRhZyBkZWxldGVkICovXHJcbiAgICAgICAgICAgIGlmIChlLmtleUNvZGUgPT09IDggJiYgdXRpbC5pc1d5c2l3eWdEaXYoc2VsZWN0aW9uTm9kZSkgJiYgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcudGV4dENvbnRlbnQubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IG9Gb3JtYXRUYWcgPSB1dGlsLmNyZWF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XG5cclxuICAgICAgICAgICAgaWYgKGV2ZW50Ll9kaXJlY3Rpb25LZXlLZXlDb2RlLnRlc3QoZS5rZXlDb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgZXZlbnQuX2ZpbmRCdXR0b25FZmZlY3RUYWcoKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKHVzZXJGdW5jdGlvbi5vbktleVVwKSB1c2VyRnVuY3Rpb24ub25LZXlVcChlKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBvblNjcm9sbF93eXNpd3lnOiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICBlZGl0b3IuY29udHJvbGxlcnNPZmYoKTtcclxuICAgICAgICAgICAgaWYgKHVzZXJGdW5jdGlvbi5vblNjcm9sbCkgdXNlckZ1bmN0aW9uLm9uU2Nyb2xsKGUpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIG9uRHJvcF93eXNpd3lnOiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICBjb25zdCBmaWxlcyA9IGUuZGF0YVRyYW5zZmVyLmZpbGVzO1xyXG5cclxuICAgICAgICAgICAgaWYgKGZpbGVzLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcbiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgICAgICBcclxuICAgICAgICAgICAgICAgIGVkaXRvci5mb2N1cygpO1xyXG4gICAgXHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbignaW1hZ2UnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGV4dC5pbWFnZS5pbWdJbnB1dEZpbGUuZmlsZXMgPSBmaWxlcztcclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3IucGx1Z2lucy5pbWFnZS5vblJlbmRlcl9pbWdJbnB1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ja3lUb29sYmFyO1xyXG4gICAgICAgICAgICBcclxuICAgICAgICAgICAgaWYgKHkgPCBlZGl0b3JUb3ApIHtcclxuICAgICAgICAgICAgICAgIGV2ZW50Ll9vZmZTdGlja3lUb29sYmFyKGVsZW1lbnQpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2UgaWYgKHkgKyBlZGl0b3IuX3ZhcmlhYmxlLm1pblJlc2l6aW5nU2l6ZSA+PSBlZGl0b3JIZWlnaHQgKyBlZGl0b3JUb3ApIHtcclxuICAgICAgICAgICAgICAgIGlmICghZWRpdG9yLl92YXJpYWJsZS5fc3RpY2t5KSBldmVudC5fb25TdGlja3lUb29sYmFyKGVsZW1lbnQpO1xyXG4gICAgICAgICAgICAgICAgZWxlbWVudC50b29sYmFyLnN0eWxlLnRvcCA9IChlZGl0b3JIZWlnaHQgKyBlZGl0b3JUb3AgKyBjb250ZXh0Lm9wdGlvbi5zdGlja3lUb29sYmFyIC15IC0gZWRpdG9yLl92YXJpYWJsZS5taW5SZXNpemluZ1NpemUpICsgJ3B4JztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNlIGlmICh5ID49IGVkaXRvclRvcCkge1xyXG4gICAgICAgICAgICAgICAgZXZlbnQuX29uU3RpY2t5VG9vbGJhcihlbGVtZW50KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIF9vblN0aWNreVRvb2xiYXI6IGZ1bmN0aW9uIChlbGVtZW50KSB7XHJcbiAgICAgICAgICAgIGlmICghZWRpdG9yLl9pc0lubGluZSkge1xyXG4gICAgICAgICAgICAgICAgZWxlbWVudC5fc3RpY2t5RHVtbXkuc3R5bGUuaGVpZ2h0ID0gZWxlbWVudC50b29sYmFyLm9mZnNldEhlaWdodCArICdweCc7XHJcbiAgICAgICAgICAgICAgICBlbGVtZW50Ll9zdGlja3lEdW1teS5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJztcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZWxlbWVudC50b29sYmFyLnN0eWxlLnRvcCA9IGNvbnRleHQub3B0aW9uLnN0aWNreVRvb2xiYXIgKyAncHgnO1xyXG4gICAgICAgICAgICBlbGVtZW50LnRvb2xiYXIuc3R5bGUud2lkdGggPSBlZGl0b3IuX2lzSW5saW5lID8gZWRpdG9yLl9pbmxpbmVUb29sYmFyQXR0ci53aWR0aCA6IGVsZW1lbnQudG9vbGJhci5vZmZzZXRXaWR0aCArICdweCc7XHJcbiAgICAgICAgICAgIHV0aWwuYWRkQ2xhc3MoZWxlbWVudC50b29sYmFyLCAnc3VuLWVkaXRvci1zdGlja3knKTtcclxuICAgICAgICAgICAgZWRpdG9yLl92YXJpYWJsZS5fc3RpY2t5ID0gdHJ1ZTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBfb2ZmU3RpY2t5VG9vbGJhcjogZnVuY3Rpb24gKGVsZW1lbnQpIHtcclxuICAgICAgICAgICAgZWxlbWVudC5fc3RpY2t5RHVtbXkuc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICAgICAgZWxlbWVudC50b29sYmFyLnN0eWxlLnRvcCA9IGVkaXRvci5faXNJbmxpbmUgPyBlZGl0b3IuX2lubGluZVRvb2xiYXJBdHRyLnRvcCA6ICcnO1xyXG4gICAgICAgICAgICBlbGVtZW50LnRvb2xiYXIuc3R5bGUud2lkdGggPSBlZGl0b3IuX2lzSW5saW5lID8gZWRpdG9yLl9pbmxpbmVUb29sYmFyQXR0ci53aWR0aCA6ICcnO1xyXG4gICAgICAgICAgICBlbGVtZW50LmVkaXRvckFyZWEuc3R5bGUubWFyZ2luVG9wID0gJyc7XHJcbiAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3MoZWxlbWVudC50b29sYmFyLCAnc3VuLWVkaXRvci1zdGlja3knKTtcclxuICAgICAgICAgICAgZWRpdG9yLl92YXJpYWJsZS5fc3RpY2t5ID0gZmF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leHQub3B0aW9uLnN0aWNreVRvb2xiYXIgPiAtMSkgX3cuYWRkRXZlbnRMaXN0ZW5lcignc2Nyb2xsJywgZXZlbnQub25TY3JvbGxfd2luZG93LCBmYWxzZSk7XHJcblxyXG4gICAgLyoqIGFkZCBwbHVnaW4gdG8gcGx1Z2lucyBvYmplY3QgKi9cclxuICAgIGlmIChwbHVnaW5zKSB7XHJcbiAgICAgICAgT2JqZWN0LmtleXMocGx1Z2lucykubWFwKGZ1bmN0aW9uKGtleSkge1xyXG4gICAgICAgICAgICBsZXQgcGx1Z2luID0gcGx1Z2luc1trZXldO1xyXG4gICAgICAgICAgICBlZGl0b3IucGx1Z2luc1twbHVnaW4ubmFtZV0gPSB1dGlsLmNvcHlPYmoocGx1Z2luKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKiogVXNlciBmdW5jdGlvbiAqL1xyXG4gICAgY29uc3QgdXNlckZ1bmN0aW9uID0ge1xyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBFdmVudCBmdW5jdGlvbnNcclxuICAgICAgICAgKiBAcGFyYW0ge09iamVjdH0gZXZlbnQgLSBFdmVudCBPYmplY3RcclxuICAgICAgICAgKi9cclxuICAgICAgICBvblNjcm9sbDogbnVsbCxcclxuICAgICAgICBvbkNsaWNrOiBudWxsLFxyXG4gICAgICAgIG9uS2V5RG93bjogbnVsbCxcclxuICAgICAgICBvbktleVVwOiBudWxsLFxyXG4gICAgICAgIG9uRHJvcDogbnVsbCxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIENhbGxlZCB3aGVuIHRoZSBpbWFnZSBpcyB1cGxvYWRlZCBvciB0aGUgdXBsb2FkZWQgaW1hZ2UgaXMgZGVsZXRlZFxyXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gdGFyZ2V0SW1nRWxlbWVudCAtIEN1cnJlbnQgaW1nIGVsZW1lbn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ogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQub3JpZ2luRWxlbWVudC52YWx1ZSA9IGVkaXRvci5nZXRDb250ZW50cygpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBHZXRzIHRoZSBzdW5lZGl0b3IncyBjb250ZXh0IG9iamVjdC4gQ29udGFpbnMgc2V0dGluZ3MsIHBsdWdpbnMsIGFuZCBjYWNoZWQgZWxlbWVudCBvYmplY3RzXHJcbiAgICAgICAgICogQHJldHVybnMge09iamVjdH1cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRDb250ZXh0OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBjb250ZXh0O1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBHZXRzIHRoZSBjb250ZW50cyBvZiB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICogQHJldHVybnMge1N0cmluZ31cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRDb250ZW50czogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICByZXR1cm4gZWRpdG9yLmdldENvbnRlbnRzKCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEdldHMgdXBsb2FkZWQgaW1hZ2VzIGluZm9ybWF0aW9uc1xyXG4gICAgICAgICAqIEByZXR1cm5zIHtBcnJheX1cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRJbWFnZXNJbmZvOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBlZGl0b3IuX3ZhcmlhYmxlLl9pbWFnZXNJbmZvO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIE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pd3lnQWN0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5pbm5lckhUTUwgPSB1dGlsLmNvbnZlcnRDb250ZW50c0ZvckVkaXRvcihjb250ZW50cyk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQuY29kZS52YWx1ZSA9IGNvbnRlbnRzO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEFkZCBjb250ZW50cyB0byB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICogQHBhcmFtIHtTdHJpbmd9IGNvbnRlbnRzIC0gQ29udGVudHMgdG8gSW5wdXRcclxuICAgICAgICAgKi9cclxuICAgICAgICBhcHBlbmRDb250ZW50czogZnVuY3Rpb24gKGNvbnRlbnRzKSB7XHJcbiAgICAgICAgICAgIGlmIChlZGl0b3IuX3ZhcmlhYmxlLnd5c2l3eWdBY3RpdmUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC53eXNpd3lnLmlubmVySFRNTCArPSB1dGlsLmNvbnZlcnRDb250ZW50c0ZvckVkaXRvcihjb250ZW50cyk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQuY29kZS52YWx1ZSArPSBjb250ZW50cztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEaXNhYmxlIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKi9cclxuICAgICAgICBkaXNhYmxlZDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb250ZXh0LnRvb2wuY292ZXIuc3R5bGUuZGlzcGxheSA9ICdibG9jayc7XHJcbiAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC53eXNpd3lnLnNldEF0dHJpYnV0ZSgnY29udGVudGVkaXRhYmxlJywgZmFsc2UpO1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQuY29kZS5zZXRBdHRyaWJ1dGUoJ2Rpc2FibGVkJywgJ2Rpc2FibGVkJyk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEVuYWJsZWQgdGhlIHN1bmVkaXRvclxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGVuYWJsZWQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29udGV4dC50b29sLmNvdmVyLnN0eWxlLmRpc3BsYXkgPSAnbm9uZSc7XHJcbiAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC53eXNpd3lnLnNldEF0dHJpYnV0ZSgnY29udGVudGVkaXRhYmxlJywgdHJ1ZSk7XHJcbiAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC5jb2RlLnJlbW92ZUF0dHJpYnV0ZSgnZGlzYWJsZWQnKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gU2hvdyB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgc2hvdzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb25zdCB0b3BBcmVhU3R5bGUgPSBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5zdHlsZTtcclxuICAgICAgICAgICAgaWYgKHRvcEFyZWFTdHlsZS5kaXNwbGF5ID09PSAnbm9uZScpIHRvcEFyZWFTdHlsZS5kaXNwbGF5ID0gY29udGV4dC5vcHRpb24uZGlzcGxheTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gSGlkZSB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgaGlkZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEZXN0cm95IHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKi9cclxuICAgICAgICBkZXN0cm95OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIC8qKiByZW1vdmUgd2luZG93IGV2ZW50IGxpc3RlbmVycyAqL1xyXG4gICAgICAgICAgICBfdy5yZW1vdmVFdmVudExpc3RlbmVyKCdyZXNpemUnLCBldmVudC5vblJlc2l6ZV93aW5kb3cpO1xyXG4gICAgICAgICAgICBfdy5yZW1vdmVFdmVudExpc3RlbmVyKCdzY3JvbGwnLCBldmVudC5vblNjcm9sbF93aW5kb3cpO1xyXG4gICAgICAgICAgICBcclxuICAgICAgICAgICAgLyoqIHJlbW92ZSBlbGVtZW50ICovXHJcbiAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShjb250ZXh0LmVsZW1lbnQudG9wQXJlYSk7XHJcblxyXG4gICAgICAgICAgICB0aGlzLm9uU2Nyb2xsID0gbnVsbDtcclxuICAgICAgICAgICAgdGhpcy5vbkNsaWNrID0gbnVsbDtcclxuICAgICAgICAgICAgdGhpcy5vbktleURvd24gPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLm9uS2V5VXAgPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLm9uRHJvcCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuc2F2ZSA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMub25JbWFnZVVwbG9hZCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMubm90aWNlT3BlbiA9IG51bGw7XH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