From 0976f87563398f4e019176e4f3a6beefdc564a3b Mon Sep 17 00:00:00 2001 From: "JiHong.Lee" <0125ses@hanmail.net> Date: Thu, 20 Sep 2018 02:04:48 +0900 Subject: [PATCH] fix: display option, tree shaking --- README.md | 18 ++++++++++++++++-- bower.json | 2 +- dist/suneditor.min.js | 2 +- package-lock.json | 2 +- package.json | 2 +- sample/build/suneditor.customize.js | 6 +++--- sample/html/getting-started.html | 18 ++++++++++++++++-- src/lib/context.js | 3 ++- src/lib/core.js | 11 ++--------- src/suneditor.js | 2 +- 10 files changed, 44 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index d31643ea2..906e0bfba 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ suneditor.create('sample', { }); ``` -### 2. Load plugins +### 2. Load only what you want ```javascript import 'suneditor/dist/css/suneditor.min.css' import suneditor from 'suneditor' @@ -131,7 +131,7 @@ import suneditor from 'suneditor' import plugins from 'suneditor/src/plugins' suneditor.create('sample', { - modules: plugins, + plugins: plugins, buttonList: [ ['undo', 'redo'], ['font', 'fontSize', 'formatBlock'], @@ -146,6 +146,20 @@ suneditor.create('sample', { ['preview', 'print'] ] }) + +// You can also load what you want +suneditor.create('sample', { + plugins: [ + plugins.font + plugins.fontSize, + plugins.formatBlock + ], + buttonList: [ + ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'], + ['font', 'fontSize', 'formatBlock'], + ['removeFormat'] + ] +}) ``` ### 4. Plugins can be used directly in the button list diff --git a/bower.json b/bower.json index 48dbb0296..e71f7588f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "suneditor", - "version": "2.0.10", + "version": "2.0.11", "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 a9c7eb32e..61e9bb669 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";__webpack_exports__.a={name:"fontColor",add:function(_this,targetElement){let listDiv=eval(this.setSubmenu());listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickUp.bind(_this)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(){const e=document.createElement("DIV");e.className="layer_editor",e.style.display="none";const t=["#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 i='
",e.innerHTML=i,e},pickUp:function(e){if(e.preventDefault(),e.stopPropagation(),!/^BUTTON$/i.test(e.target.tagName))return!1;this.focus();const t=document.createElement("SPAN");t.style.color=e.target.getAttribute("data-value"),this.wrapRangeToTag(t,["color"]),this.submenuOff()}}},"1kvd":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"dialog",add:function(_this){const context=_this.context;context.dialog={_resizeClientX:0,_resizeClientY:0,_resize_plugin:"",_resize_w:0,_resize_h:0,_resize_direction:""};let dialog_div=document.createElement("DIV");dialog_div.className="sun-editor-id-dialogBox sun-editor-common";let dialog_back=document.createElement("DIV");dialog_back.className="modal-dialog-background sun-editor-id-dialog-back",dialog_back.style.display="none";let dialog_area=document.createElement("DIV");dialog_area.className="modal-dialog sun-editor-id-dialog-modal",dialog_area.style.display="none",dialog_div.appendChild(dialog_back),dialog_div.appendChild(dialog_area),context.dialog.modalArea=dialog_div,context.dialog.back=dialog_back,context.dialog.modal=dialog_area;let resize_div_container=eval(this.setController_resize());context.dialog.resizeContainer=resize_div_container,context.dialog.resizeDiv=resize_div_container.getElementsByClassName("modal-resize")[0],context.dialog.resizeDot=resize_div_container.getElementsByClassName("resize-dot")[0],context.dialog.resizeDisplay=resize_div_container.getElementsByClassName("resize-display")[0];let resize_button=eval(this.setController_button(_this.lang));context.dialog.resizeButton=resize_button;let resize_handles=resize_div_container.getElementsByClassName("sun-editor-name-resize-handle");context.dialog.modal.addEventListener("click",this.onClick_dialog.bind(_this)),context.element.topArea.getElementsByClassName("sun-editor-container")[0].appendChild(dialog_div),resize_handles[0].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_handles[1].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_handles[2].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_handles[3].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_handles[4].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_handles[5].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_handles[6].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_handles[7].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(_this)),resize_button.addEventListener("click",this.onClick_resizeButton.bind(_this)),context.element.relative.appendChild(resize_div_container),context.element.relative.appendChild(resize_button),dialog_div=null,dialog_back=null,dialog_area=null,resize_div_container=null,resize_button=null,resize_handles=null},onClick_dialog:function(e){e.stopPropagation(),(/modal-dialog/.test(e.target.className)||/close/.test(e.target.getAttribute("data-command")))&&this.plugins.dialog.closeDialog.call(this)},openDialog:function(e,t,i){if(this.modalForm)return!1;this.context.dialog.updateModal=i,this.context.dialog.modalArea.style.position="full"===t?"fixed":"absolute",this.context.dialog.kind=e,this.modalForm=this.context[e].modal;const n=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",n&&n.focus()},closeDialog: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)},setController_resize:function(){const e=document.createElement("DIV");return e.className="modal-resize-container",e.style.display="none",e.innerHTML='
',e},setController_button:function(e){const t=document.createElement("DIV");return t.className="resize-btn",t.style.display="none",t.innerHTML='
',t},call_controller_resize:function(e,t){this.context.dialog._resize_plugin=t,e.setAttribute("unselectable","on"),e.contentEditable=!1;const i=this.context.dialog.resizeContainer,n=this.context.dialog.resizeDiv,o=e.offsetWidth,l=e.offsetHeight,s=e.offsetTop-this.context.element.wysiwyg.scrollTop,a=e.offsetLeft;return i.style.top=s+"px",i.style.left=a+"px",i.style.width=o+"px",i.style.height=l+"px",n.style.top="0px",n.style.left="0px",n.style.width=o+"px",n.style.height=l+"px",this.context.dialog.resizeButton.style.top=l+s+"px",this.context.dialog.resizeButton.style.left=a+"px",this.util.changeTxt(this.context.dialog.resizeDisplay,o+" x "+l),this.context.dialog.resizeContainer.style.display="block",this.context.dialog.resizeButton.style.display="block",this.context.dialog.resizeDot.style.display="block",this.context.dialog._resize_w=o,this.context.dialog._resize_h=l,this.controllerArray=[this.context.dialog.resizeContainer,this.context.dialog.resizeButton],{w:o,h:l,t:s,l:a}},cancel_controller_resize:function(){this.context[this.context.dialog._resize_plugin]._resize_element.style.width=this.context.dialog._resize_w+"px",this.context[this.context.dialog._resize_plugin]._resize_element.style.height=this.context.dialog._resize_h+"px",this.context.element.resizeBackground.style.display="none",this.context.dialog.resizeContainer.style.display="none",this.context.dialog.resizeButton.style.display="none",this.plugins[this.context.dialog._resize_plugin].init.call(this)},onClick_resizeButton:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");t&&(e.preventDefault(),/^\d+$/.test(t)?this.plugins[this.context.dialog._resize_plugin].setSize.call(this,t+"%",""):/update/.test(t)?this.plugins[this.context.dialog._resize_plugin].openModify.call(this):/delete/.test(t)&&this.plugins[this.context.dialog._resize_plugin].destroy.call(this),this.submenuOff(),this.focus())},onMouseDown_resize_handle:function(e){const t=this.context.dialog._resize_direction=e.target.classList[0];e.stopPropagation(),e.preventDefault(),this.context.dialog.resizeDot.style.display="none",this.context.dialog._resizeClientX=e.clientX,this.context.dialog._resizeClientY=e.clientY,this.context.element.resizeBackground.style.display="block",this.context.dialog.resizeButton.style.display="none",this.context.dialog.resizeDiv.style.float=/l/.test(t)?"right":/r/.test(t)?"left":"none";const i=this.plugins.dialog.resizing_element.bind(this),n=function(){this.plugins.dialog.cancel_controller_resize.call(this),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",n)}.bind(this);document.addEventListener("mousemove",i),document.addEventListener("mouseup",n)},resizing_element:function(e){const t=this.context.dialog._resize_direction,i=e.clientX,n=e.clientY,o=this.context[this.context.dialog._resize_plugin];let l=o._element_w,s=o._element_h;const a=o._element_w+(/r/.test(t)?i-this.context.dialog._resizeClientX:this.context.dialog._resizeClientX-i),r=o._element_h+(/b/.test(t)?n-this.context.dialog._resizeClientY:this.context.dialog._resizeClientY-n),d=o._element_h/o._element_w*a;/t/.test(t)&&(this.context.dialog.resizeDiv.style.top=o._element_h-(/h/.test(t)?r:d)+"px"),/l/.test(t)&&(this.context.dialog.resizeDiv.style.left=o._element_w-a+"px"),/r|l/.test(t)&&(this.context.dialog.resizeDiv.style.width=a+"px",l=a),/^(?:t|b)[^h]$/.test(t)?(this.context.dialog.resizeDiv.style.height=d+"px",s=d):/^(?:t|b)h$/.test(t)&&(this.context.dialog.resizeDiv.style.height=r+"px",s=r),this.context.dialog._resize_w=l,this.context.dialog._resize_h=s,this.util.changeTxt(this.context.dialog.resizeDisplay,Math.round(l)+" x "+Math.round(s))}}},"3FqI":function(e,t,i){},"50IV":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"font",add:function(_this,targetElement){let listDiv=eval(this.setSubmenu(_this.context.user));listDiv.getElementsByClassName("list_family")[0].addEventListener("click",this.pickup.bind(_this)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=document.createElement("DIV");let i,n,o,l;t.className="layer_editor",t.style.display="none";let s=e.font?e.font:["Arial","Comic Sans MS","Courier New,Courier","Georgia","tahoma","Trebuchet MS,Helvetica","Verdana"],a='
",a+="
",t.innerHTML=a,t},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=e.target;this.focus(),this.util.changeTxt(this.context.tool.font,t.getAttribute("data-txt"));const i=document.createElement("SPAN");i.style.fontFamily=t.getAttribute("data-value"),this.wrapRangeToTag(i,["font-family"]),this.submenuOff()}}},KKur:function(module,__webpack_exports__,__webpack_require__){"use strict";var _modules_dialog__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("1kvd");__webpack_exports__.a={name:"image",add:function(_this){_this._addModule(_modules_dialog__WEBPACK_IMPORTED_MODULE_0__.a);const context=_this.context;context.image={_linkElement:null,_element:null,_resize_element:null,_element_w:1,_element_h:1,_element_l:0,_element_t:0,_origin_w:context.user.imageSize,_origin_h:0,_altText:"",_imageCaption:null,_linkValue:"",_align:"none",_captionChecked:!1,_proportionChecked:!0,_onCaption:!1,_floatClassRegExp:"float\\-[a-z]+"};let image_dialog=eval(this.setDialog(_this.context.user,_this.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.caption=image_dialog.querySelector("#suneditor_image_check_caption"),context.image.proportion=image_dialog.querySelector("#suneditor_image_check_proportion"),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=_this.context.user.imageSize,context.image.modal.getElementsByClassName("sun-editor-tab-button")[0].addEventListener("click",this.openTab.bind(_this)),context.image.modal.getElementsByClassName("btn-primary")[0].addEventListener("click",this.submit.bind(_this)),context.image.imageX.addEventListener("change",this.setInputSize.bind(_this,"x")),context.image.imageY.addEventListener("change",this.setInputSize.bind(_this,"y")),image_dialog.getElementsByClassName("sun-editor-id-image-revert-button")[0].addEventListener("click",this.sizeRevert.bind(_this)),context.dialog.modal.appendChild(image_dialog),image_dialog=null},setDialog:function(e,t){const i=document.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="init"===e?document.getElementsByClassName("sun-editor-id-tab-link")[0]:e.target;if(!/^BUTTON$/i.test(t.tagName))return!1;const i=t.getAttribute("data-tab-link");let n,o,l;for(o=document.getElementsByClassName("sun-editor-id-tab-content"),n=0;n0){const t=this.context.user.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:result.length;e0){const n=document.createElement("A");return n.href=/^https?:\/\//.test(t)?t:"http://"+t,n.target=i?"_blank":"",n.setAttribute("data-image-link","image"),n.addEventListener("click",function(e){e.preventDefault()}),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.caption.checked,this.context.image._proportionChecked=this.context.image.proportion.checked;try{this.context.dialog.updateModal?this.plugins.image.update_image.call(this):(this.plugins.image.onRender_imgInput.call(this),this.plugins.image.onRender_imgUrl.call(this))}finally{this.plugins.dialog.closeDialog.call(this),this.closeLoading()}return!1},create_caption:function(){const e=document.createElement("FIGCAPTION");return e.innerHTML="

"+this.lang.dialogBox.imageBox.caption+"

",e.addEventListener("click",this.plugins.image.toggle_caption_contenteditable.bind(this,!0)),e},set_cover:function(e){const t=document.createElement("FIGURE");return t.className="sun-editor-image-cover",t.appendChild(e),t},set_container:function(e){const t=document.createElement("DIV");return t.className="sun-editor-id-image-container",t.setAttribute("contenteditable",!1),t.appendChild(e),t},create_image:function(e,t,i,n,o,l){if(l)return void(this.context.image._element.src=e);let s=document.createElement("IMG");s.src=e,s.style.width=n,s.setAttribute("data-align",o),s.setAttribute("data-proportion",this.context.image._proportionChecked),s.alt=this.context.image._altText,s=this.plugins.image.onRender_link(s,t,i);const a=this.plugins.image.set_cover.call(this,s),r=this.plugins.image.set_container.call(this,a);this.context.image._captionChecked&&(this.context.image._imageCaption=this.plugins.image.create_caption.call(this),this.context.image._imageCaption.setAttribute("contenteditable",!1),a.appendChild(this.context.image._imageCaption)),"center"!==o&&(r.style.display="inline-block",this.util.removeClass(r,this.context.image._floatClassRegExp),this.util.addClass(r,"float-"+o)),this.insertNode(r,this.util.getFormatElement(this.getSelectionNode())),this.appendP(r)},update_image:function(){const e=this.context.image,t=e._linkValue;let i=this.util.getParentElement(e._element,".sun-editor-image-cover"),n=this.util.getParentElement(e._element,".sun-editor-id-image-container"),o=!1;if(null===i&&(o=!0,i=this.plugins.image.set_cover.call(this,e._element.cloneNode(!0))),null===n?(o=!0,n=this.plugins.image.set_container.call(this,i.cloneNode(!0))):o&&(n.innerHTML="",n.appendChild(i)),this.plugins.image.onRender_imgInput.call(this),e._element.src=e.imgUrlFile.value,e._element.alt=e._altText,e._element.setAttribute("data-proportion",e._proportionChecked),e._element.style.width=e.imageX.value+"px",e._element.style.height=e.imageY.value+"px",e._captionChecked?null===e._imageCaption&&(e._imageCaption=this.plugins.image.create_caption.call(this),i.appendChild(e._imageCaption)):e._imageCaption&&this.util.removeItem(e._imageCaption),"center"!==e._align?(n.style.display="inline-block",this.util.removeClass(n,this.context.image._floatClassRegExp),this.util.addClass(n,"float-"+e._align)):(n.style.display="",this.util.removeClass(n,this.context.image._floatClassRegExp),this.util.addClass(n,"float-none")),e._element.setAttribute("data-align",e._align),t.trim().length>0)if(null!==e._linkElement)e._linkElement.href=t,e._linkElement.target=e.imgLinkNewWindowCheck.checked?"_blank":"",e._element.setAttribute("data-image-link",t);else{let n=this.plugins.image.onRender_link(e._element.cloneNode(!0),t,this.context.image.imgLinkNewWindowCheck.checked);i.removeChild(e._element),i.insertBefore(n,e._imageCaption)}else if(null!==e._linkElement){const t=e._element;t.setAttribute("data-image-link","");let n=t.cloneNode(!0);i.removeChild(e._linkElement),i.insertBefore(n,e._imageCaption)}if(o){const t=this.util.getFormatElement(e._element);t.parentNode.insertBefore(n,t),this.util.removeItem(t)}},toggle_caption_contenteditable:function(e,t){this.context.image._onCaption=e,this.context.image._imageCaption.setAttribute("contenteditable",e),this.context.image._imageCaption.focus()},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=i._resize_element=e,i._imageCaption=i._linkElement?i._linkElement.nextSibling:e.nextSibling,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(){const e=this.context.image;e.imgUrlFile.value=e._element.src,e.altText.value=e._element.alt,e.imgLink.value=null===e._linkElement?"":e._linkElement.href,e.imgLinkNewWindowCheck.checked=e._linkElement&&"_blank"===e._linkElement.target,e.modal.querySelector("#suneditor_image_radio_"+(e._element.getAttribute("data-align")||"none")).checked=!0,e._captionChecked=e.caption.checked=!!e._imageCaption,e.proportion.checked=e._proportionChecked="true"===e._element.getAttribute("data-proportion"),e.imageX.value=e._element.offsetWidth,e.imageY.value=e._element.offsetHeight,e.imageY.disabled=!1,e.proportion.disabled=!1,this.plugins.dialog.openDialog.call(this,"image",null,!0)},setSize:function(e,t){this.context.image._resize_element.style.width=e,this.context.image._resize_element.style.height=t},destroy:function(){const e=this.util.getParentElement(this.context.image._element,".sun-editor-id-image-container")||this.context.image._element;this.util.removeItem(e),this.plugins.image.init.call(this)},init:function(){this.context.image.imgInputFile.value="",this.context.image.imgUrlFile.value="",this.context.image.altText.value="",this.context.image.imgLink.value="",this.context.image.imgLinkNewWindowCheck.checked=!1,this.context.image.modal.querySelector("#suneditor_image_radio_none").checked=!0,this.context.image.caption.checked=!1,this.context.image.proportion.checked=!1,this.context.image.imageX.value=this.context.user.imageSize,this.context.image.imageY.value="",this.context.image.imageY.disabled=!0,this.context.image.proportion.disabled=!0,this.context.image._element=null,this.plugins.image.openTab.call(this,"init")}}},MIhV:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"fontSize",add:function(_this,targetElement){let listDiv=eval(this.setSubmenu(_this.context.user));listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickup.bind(_this)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=document.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;this.focus(),this.util.changeTxt(this.context.tool.fontSize,e.target.getAttribute("data-value"));const t=document.createElement("SPAN");t.style.fontSize=e.target.getAttribute("data-value")+"px",this.wrapRangeToTag(t,["font-size"]),this.submenuOff()}}},Rp48:function(module,__webpack_exports__,__webpack_require__){"use strict";var _modules_dialog__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("1kvd");__webpack_exports__.a={name:"link",add:function(_this){_this._addModule(_modules_dialog__WEBPACK_IMPORTED_MODULE_0__.a);const context=_this.context;context.link={};let link_dialog=eval(this.setDialog(_this.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_LinkBtn(_this.lang));context.link.linkBtn=link_button,context.link._linkAnchor=null,link_dialog.getElementsByClassName("btn-primary")[0].addEventListener("click",this.submit.bind(_this)),link_button.addEventListener("click",this.onClick_linkBtn.bind(_this)),context.dialog.modal.appendChild(link_dialog),context.element.relative.appendChild(link_button),link_dialog=null,link_button=null},setDialog:function(e){const t=document.createElement("DIV");return t.className="modal-content sun-editor-id-dialog-link",t.style.display="none",t.innerHTML='",t},setController_LinkBtn:function(e){const t=document.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();try{(function(){if(0===this.context.link.focusElement.value.trim().length)return!1;const e=/^https?:\/\//.test(this.context.link.focusElement.value)?this.context.link.focusElement.value:"http://"+this.context.link.focusElement.value,t=this.context.link.linkAnchorText||this.context.dialog.document.getElementById("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=document.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=""}).call(this)}finally{this.plugins.dialog.closeDialog.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,t.style.left=e.offsetLeft+"px",t.style.top=e.offsetTop+e.offsetHeight-this.context.element.wysiwyg.scrollTop+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.openDialog.call(this,"link",null,!0)):(this.util.removeItem(this.context.link._linkAnchor),this.context.link._linkAnchor=null,this.focus()),this.context.link.linkBtn.style.display="none")},init:function(){this.context.link.linkBtn.style.display="none",this.context.link._linkAnchor=null,this.context.link.focusElement.value="",this.context.link.linkAnchorText.value="",this.context.link.linkNewWindowCheck.checked=!1}}},VquE:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"table",add:function(_this,targetElement){const context=_this.context;let listDiv=eval(this.setSubmenu()),tablePicker=listDiv.getElementsByClassName("sun-editor-id-table-picker")[0];context.submenu.tableHighlight=listDiv.getElementsByClassName("sun-editor-id-table-highlighted")[0],context.submenu.tableUnHighlight=listDiv.getElementsByClassName("sun-editor-id-table-unhighlighted")[0],context.submenu.tableDisplay=listDiv.getElementsByClassName("sun-editor-table-display")[0],context.submenu._tableXY=[],tablePicker.addEventListener("mousemove",this.onMouseMove_tablePicker.bind(_this)),tablePicker.addEventListener("click",this.appendTable.bind(_this)),targetElement.parentNode.appendChild(listDiv),listDiv=null,tablePicker=null},setSubmenu:function(){const e=document.createElement("DIV");return e.className="table-content",e.style.display="none",e.innerHTML='
1 x 1
',e},appendTable:function(){const e=document.createElement("TABLE");let t=this.context.submenu._tableXY[0],i=this.context.submenu._tableXY[1],n="";for(;i>0;){n+="";let e=t;for(;e>0;)n+="



",--e;n+="",--i}n+="",e.innerHTML=n,this.insertNode(e,this.util.getFormatElement(this.getSelectionNode())),this.appendP(e),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.submenu.tableHighlight.style.width=t+"em",this.context.submenu.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.submenu.tableUnHighlight.style.width=n+"em",this.context.submenu.tableUnHighlight.style.height=o+"em",this.util.changeTxt(this.context.submenu.tableDisplay,t+" x "+i),this.context.submenu._tableXY=[t,i]},reset_table_picker:function(){if(!this.context.submenu.tableHighlight)return;const e=this.context.submenu.tableHighlight.style,t=this.context.submenu.tableUnHighlight.style;e.width="1em",e.height="1em",t.width="5em",t.height="5em",this.util.changeTxt(this.context.submenu.tableDisplay,"1 x 1"),this.submenuOff()}}},WRt5:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"align",add:function(_this,targetElement){let listDiv=eval(this.setSubmenu(_this.lang));listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickup.bind(_this)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=document.createElement("DIV");return t.className="layer_editor layer_align",t.style.display="none",t.innerHTML='
",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),this.submenuOff()}}},WUQj:function(e,t,i){},WzUB:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"formatBlock",add:function(_this,targetElement){let listDiv=eval(this.setSubmenu(_this.lang));listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickUp.bind(_this)),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(e){const t=document.createElement("DIV");return t.className="layer_editor layer_size",t.style.display="none",t.innerHTML='
",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-value"),t=t.parentNode;this.focus(),this.util.changeTxt(this.commandMap.FORMAT,i),this.execCommand("formatBlock",!1,i),this.submenuOff()}}},XJR1:function(e,t,i){"use strict";i.r(t);i("3FqI"),i("WUQj");var n=i("WRt5"),o=i("50IV"),l=i("MIhV"),s=i("0A7J"),a=i("s0fJ"),r=i("g4XY"),d=i("gMuy"),c=i("VquE"),u=i("WzUB"),m=i("Rp48"),g=i("KKur"),h=i("hlhS"),p={align:n.a,font:o.a,fontSize:l.a,fontColor:s.a,hiliteColor:a.a,horizontalRule:r.a,list:d.a,table:c.a,formatBlock:u.a,link:m.a,image:g.a,video:h.a};var _={util:{getXMLHttpRequest:function(){if(!window.ActiveXObject)return window.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},getIncludePath:function(e,t){let i="";const n="js"===t?"script":"link",o="js"===t?"src":"href";let l="(?:";for(let t=0,i=e.length;t"+i+"

";return 0===n.length&&(n="



"),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\\d)$/i.test(e.tagName))},getFormatElement:function(e){if(!e)return null;if(!e||this.isWysiwygDiv(e))e=context.element.wysiwyg.firstChild;else for(;!this.isWysiwygDiv(e.parentNode);)e=e.parentNode;return e},getArrayIndex:function(e,t){let i=-1;for(let n=0,o=e.length;n0){for(let t=0;t0?e.getRangeAt(0):this._createDefaultRange(),this._variable.range=t,t.collapsed?this._variable.selectionNode=t.commonAncestorContainer:this._variable.selectionNode=e.extentNode||e.anchorNode},_createDefaultRange:function(){const t=document.createRange();return t.setStart(e.element.wysiwyg.firstChild,0),t.setEnd(e.element.wysiwyg.firstChild,0),t},setRange:function(e,t,i,n){const o=document.createRange();o.setStart(e,t),o.setEnd(i,n);const l=window.getSelection();l.rangeCount>0&&l.removeAllRanges(),this._variable.range=o,l.addRange(o)},getRange:function(){return this._variable.range||this._createDefaultRange()},getSelectionNode:function(){return this._variable.selectionNode?this._variable.selectionNode:e.element.wysiwyg.firstChild},isEdgePoint:function(e,t){return 0===t||t===e.nodeValue.length},showLoading:function(){e.element.loading.style.display="block"},closeLoading:function(){e.element.loading.style.display="none"},appendP:function(e){const i=document.createElement("P");return i.innerHTML="",(e=t.getFormatElement(e)).parentNode.insertBefore(i,e.nextElementSibling),i},insertNode:function(e,t){const i=this.getRange();let n=null;if(t)n=t.parentNode,t=t.nextSibling;else{const e=i.startContainer,o=i.startOffset,l=i.endContainer,s=i.endOffset,a=i.commonAncestorContainer;if(n=e,3===e.nodeType&&(n=e.parentNode),i.collapsed)3===a.nodeType?t=a.splitText(s):(null!==n.lastChild&&/^BR$/i.test(n.lastChild.nodeName)&&n.removeChild(n.lastChild),t=null);else if(e===l){let i=e;this.isEdgePoint(l,s)||(t=l.splitText(s)),this.isEdgePoint(e,o)||(i=e.splitText(o)),n.removeChild(i)}else for(this.removeNode(),t=l;1!==t.nodeType;)t=t.parentNode}try{n.insertBefore(e,t)}catch(t){n.appendChild(e)}},removeNode:function(){const e=this.getRange();if(e.deleteContents)return void e.deleteContents();const i=e.startContainer,n=e.startOffset,o=e.endContainer,l=e.endOffset,s=e.commonAncestorContainer;let a=null,r=null;const d=t.getListChildNodes(s);let c=t.getArrayIndex(d,i),u=t.getArrayIndex(d,o);for(let e=c+1,t=i;e>=0;e--)d[e]===t.parentNode&&d[e].firstChild===t&&0===n&&(c=e,t=t.parentNode);for(let e=u-1,t=o;e>c;e--)d[e]===t.parentNode&&1===d[e].nodeType&&(d.splice(e,1),t=t.parentNode,--u);for(let e=c;e<=u;e++){const s=d[e];0===s.length||3===s.nodeType&&void 0===s.data?t.removeItem(s):s!==i?s!==o?t.removeItem(s):(r=1===o.nodeType?document.createTextNode(o.textContent):document.createTextNode(o.substringData(l,o.length-l))).length>0?o.data=r.data:t.removeItem(o):(a=1===i.nodeType?document.createTextNode(i.textContent):document.createTextNode(i.substringData(0,n))).length>0?i.data=a.data:t.removeItem(i)}},wrapRangeToTag:function(e,i){const n=this.getRange(),o=n.startContainer,l=n.startOffset,s=n.endContainer,a=n.endOffset,r=n.commonAncestorContainer;let d,c,u={},m={};if(i){c="(?:;|^|\\s)(?:"+i[0];for(let e=1;e0?o.data=e.data:o.data=o.substringData(0,l),t.data.length>0&&o.parentNode.insertBefore(t,d.nextSibling)}u.container=d,u.offset=1,m.container=d,m.offset=1}else{const i=function(t){if(3===t.nodeType)return!0;let i="";return c&&t.style.cssText.length>0&&(i=t.style.cssText.replace(c,"").trim()),(t.nodeName!==e.nodeName||i.length>0)&&(t.style.cssText.length>0&&(t.style.cssText=i),!0)};if(t.hasClass(r,"sun-editor-id-wysiwyg")){const n=t.getListChildren(r,function(e){return t.isFormatElement(e)});let c=t.getParentElement(o,"P"),g=t.getParentElement(s,"P");for(let e=0,t=n.length;e0){for(c=d=r.pop();r.length>0;)d=r.pop(),c.appendChild(d);i.appendChild(c),o=d}else o=i}if(g||h!==u){if(!g||n(h)){const e=h.cloneNode(!1);o.appendChild(e),1===h.nodeType&&(p=e)}e(h,p)}else{const e=document.createTextNode(u.substringData(0,m)),t=document.createTextNode(u.substringData(m,u.length-m));for(e.data.length>0&&o.appendChild(e),d=o,r=[];d!==a&&null!==d;)n(d)&&1===d.nodeType&&r.push(d.cloneNode(!1)),d=d.parentNode;for(c=d=r.pop()||o;r.length>0;)d=r.pop(),c.appendChild(d);c!==o?(i.appendChild(c),o=d):o=i,a.appendChild(i),u=t,m=0,g=!0,o.appendChild(u)}}}(e,a),e.parentNode.insertBefore(a,e),t.removeItem(e),{container:u,offset:m}},_wrapLineNodesEnd:function(e,i,n,o,l){const s=e,a=document.createElement("P");let r,d,c,u=o,m=l,g=!1;return function e(t,o){const l=t.childNodes;for(let t=l.length-1;0<=t;t--){const h=l[t];let p=o;if(g){if(1===h.nodeType){e(h,h);continue}for(d=h,r=[];null!==d.parentNode&&d!==s&&d!==i;)n(d)&&1===d.nodeType&&r.push(d.cloneNode(!1)),d=d.parentNode;if(r.length>0){for(c=d=r.pop();r.length>0;)d=r.pop(),c.insertBefore(d,c.firstChild);i.insertBefore(c,i.firstChild),o=d}else o=i}if(g||h!==u){if(!g||n(h)){const e=h.cloneNode(!1);o.insertBefore(e,o.firstChild),1===h.nodeType&&(p=e)}e(h,p)}else{const e=document.createTextNode(u.substringData(m,u.length-m)),t=document.createTextNode(u.substringData(0,m));for(e.data.length>0&&o.insertBefore(e,o.firstChild),d=o,r=[];d!==a&&null!==d;)n(d)&&1===d.nodeType&&r.push(d.cloneNode(!1)),d=d.parentNode;for(c=d=r.pop()||o;r.length>0;)d=r.pop(),c.insertBefore(d,c.firstChild);c!==o?(i.insertBefore(c,i.firstChild),o=d):o=i,a.insertBefore(i,a.firstChild),u=t,m=t.data.length,g=!0,o.insertBefore(u,o.firstChild)}}}(e,a),e.parentNode.insertBefore(a,e),t.removeItem(e),{container:u,offset:m}},indent:function(e,i){const n=t.getParentElement(e,"P");if(!n)return;let o=/\d+/.test(n.style.marginLeft)?1*n.style.marginLeft.match(/\d+/)[0]:0;"indent"===i?o+=25:o-=25,n.style.marginLeft=(o<0?0:o)+"px"},toggleDisplayBlocks:function(){t.toggleClass(e.element.wysiwyg,"sun-editor-show-block")},toggleCodeView:function(){if(this._variable.wysiwygActive)e.element.code.value=e.element.wysiwyg.innerHTML.trim().replace(/<\/p>(?=[^\n])/gi,"

\n"),e.element.wysiwyg.style.display="none",e.element.code.style.display="block",this._variable.wysiwygActive=!1;else{const t={"&":"&"," ":" ",""":"'","<":"<",">":">"},i=e.element.code.value.replace(/&[a-z]+;/g,function(e){return"string"==typeof t[e]?t[e]:e});e.element.wysiwyg.innerHTML=i.trim().length>0?i:"



",e.element.wysiwyg.scrollTop=0,e.element.code.style.display="none",e.element.wysiwyg.style.display="block",this._variable.wysiwygActive=!0}},toggleFullScreen:function(i){this._variable.isFullScreen?(e.element.topArea.style.cssText=this._variable.originCssText,e.element.editorArea.style.height=this._variable.editorHeight+"px",t.removeClass(i.firstElementChild,"icon-reduction"),t.addClass(i.firstElementChild,"icon-expansion")):(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.innerHeight_fullScreen=window.innerHeight-e.tool.bar.offsetHeight,e.element.editorArea.style.height=this._variable.innerHeight_fullScreen+"px",t.removeClass(i.firstElementChild,"icon-expansion"),t.addClass(i.firstElementChild,"icon-reduction")),this._variable.isFullScreen=!this._variable.isFullScreen},openWindowContents:function(i){const n="print"===i,l=window.open("","_blank");l.mimeType="text/html",l.document.write(''+(n?o.toolbar.print:o.toolbar.preview)+''+e.element.wysiwyg.innerHTML+""+(n?"' : '') + '');\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._variable.selectionNode; !util.isWysiwygDiv(selectionParent); selectionParent = selectionParent.parentNode) {\n if (selectionParent.nodeType !== 1) continue;\n nodeName = selectionParent.nodeName.toUpperCase();\n currentNodes.push(nodeName);\n /** Format */\n\n if (findFormat && util.isFormatElement(selectionParent)) {\n commandMapNodes.push('FORMAT');\n util.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.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.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.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.changeTxt(commandMap[key], lang.toolbar.font);\n } else if (/^SIZE$/i.test(key)) {\n util.changeTxt(commandMap[key], lang.toolbar.fontSize);\n } else {\n util.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 resizebar */\n\n if (context.user.showPathLabel) context.element.navigation.textContent = editor._variable.currentNodes.join(' > ');\n },\n resize_window: function () {\n if (editor._variable.isFullScreen) {\n editor._variable.innerHeight_fullScreen += window.innerHeight - context.tool.bar.offsetHeight - editor._variable.innerHeight_fullScreen;\n context.element.editorArea.style.height = editor._variable.innerHeight_fullScreen + 'px';\n }\n },\n onMouseDown_toolbar: function (e) {\n e.preventDefault();\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 /** 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.openDialog.call(editor, command, target.getAttribute('data-option'), 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\n switch (command) {\n case 'codeView':\n editor.toggleCodeView();\n util.toggleClass(target, 'on');\n break;\n\n case 'fullScreen':\n editor.toggleFullScreen(target);\n util.toggleClass(target, 'on');\n break;\n\n case 'indent':\n case 'outdent':\n editor.indent(editor._variable.selectionNode, command);\n break;\n\n case 'redo':\n case 'undo':\n case 'removeFormat':\n editor.execCommand(command, false, null);\n break;\n\n case 'preview':\n case 'print':\n editor.openWindowContents(command);\n break;\n\n case 'showBlocks':\n editor.toggleDisplayBlocks();\n util.toggleClass(target, 'on');\n break;\n\n case 'subscript':\n if (util.hasClass(context.tool.superscript, 'on')) {\n editor.execCommand('superscript', false, null);\n util.removeClass(context.tool.superscript, 'on');\n }\n\n editor.execCommand(command, false, null);\n util.toggleClass(target, 'on');\n break;\n\n case 'superscript':\n if (util.hasClass(context.tool.subscript, 'on')) {\n editor.execCommand('subscript', false, null);\n util.removeClass(context.tool.subscript, 'on');\n }\n\n editor.execCommand(command, false, null);\n util.toggleClass(target, 'on');\n break;\n\n default:\n editor.execCommand(command, false, target.getAttribute('data-value'));\n util.toggleClass(target, 'on');\n }\n }\n },\n onMouseUp_wysiwyg: function (e) {\n e.stopPropagation();\n const targetElement = e.target;\n editor.submenuOff();\n\n if (/^HTML$/i.test(targetElement.nodeName)) {\n e.preventDefault();\n editor.focus();\n return;\n }\n\n if (/^IMG$/i.test(targetElement.nodeName)) {\n e.preventDefault();\n editor.callPlugin('image', function () {\n const size = editor.plugins.dialog.call_controller_resize.call(editor, targetElement, 'image');\n editor.plugins.image.onModifyMode.call(editor, targetElement, size);\n });\n return;\n }\n\n editor._setEditorRange();\n\n event._findButtonEffectTag();\n },\n onKeyDown_wysiwyg: function (e) {\n // editor._setSelectionNode();\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 function shortcutCommand(keyCode) {\n const key = event._shortcutKeyCode[keyCode];\n if (!key) return false;\n editor.execCommand(key[0], false, null);\n util.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 switch (keyCode) {\n case 8:\n /**backspace key*/\n if (util.isFormatElement(editor._variable.selectionNode) && editor._variable.selectionNode.previousSibling === null) {\n e.preventDefault();\n e.stopPropagation();\n editor._variable.selectionNode.innerHTML = '';\n return false;\n }\n\n break;\n\n case 9:\n /**tab key*/\n e.preventDefault();\n if (ctrl || alt) break;\n let currentNode = editor._variable.selectionNode || editor.getSelectionNode();\n\n while (!/^TD$/i.test(currentNode.tagName) && !util.isWysiwygDiv(currentNode)) {\n currentNode = currentNode.parentNode;\n }\n\n if (currentNode && /^TD$/i.test(currentNode.tagName)) {\n const table = util.getParentElement(currentNode, 'table');\n const cells = util.getListChildren(table, util.isCell);\n let idx = shift ? util.prevIdx(cells, currentNode) : util.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 /** if P Tag */\n\n\n if (shift) break;\n const tabText = document.createTextNode(new Array(editor._variable.tabSize + 1).join('\\u00A0'));\n editor.insertNode(tabText);\n editor.setRange(tabText, editor._variable.tabSize, tabText, editor._variable.tabSize);\n break;\n }\n },\n onKeyUp_wysiwyg: function (e) {\n editor._setEditorRange();\n /** when format tag deleted */\n\n\n if (e.keyCode === 8 && util.isWysiwygDiv(editor._variable.selectionNode)) {\n e.preventDefault();\n e.stopPropagation();\n const oFormatTag = document.createElement(editor._variable.currentNodes[0]);\n oFormatTag.innerHTML = '';\n\n editor._variable.selectionNode.appendChild(oFormatTag);\n\n editor._variable.selectionNode = oFormatTag;\n editor.setRange(oFormatTag, 0, oFormatTag, 0);\n }\n\n if (event._directionKeyKeyCode.test(e.keyCode)) {\n event._findButtonEffectTag();\n }\n },\n onScroll_wysiwyg: function () {\n editor.controllersOff();\n },\n onDrop_wysiwyg: function (e) {\n const files = e.dataTransfer.files;\n if (files.length === 0) return true;\n e.stopPropagation();\n e.preventDefault();\n\n if (editor.plugins.image) {\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 onMouseDown_resizeBar: 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 document.removeEventListener('mousemove', event.resize_editor);\n document.removeEventListener('mouseup', closureFunc);\n }\n\n document.addEventListener('mousemove', event.resize_editor);\n document.addEventListener('mouseup', closureFunc);\n },\n resize_editor: function (e) {\n const resizeInterval = e.clientY - editor._variable.resizeClientY;\n context.element.editorArea.style.height = context.element.editorArea.offsetHeight + resizeInterval + 'px';\n editor._variable.editorHeight = context.element.editorArea.offsetHeight + resizeInterval;\n editor._variable.resizeClientY = e.clientY;\n }\n };\n /** add event listeners */\n\n /** tool bar event */\n\n context.tool.bar.addEventListener('click', event.onClick_toolbar, false);\n context.tool.bar.addEventListener('mousedown', event.onMouseDown_toolbar, false);\n /** editor area */\n\n context.element.wysiwyg.addEventListener('scroll', event.onScroll_wysiwyg, false);\n context.element.wysiwyg.addEventListener('mouseup', event.onMouseUp_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 /** resize bar */\n\n context.element.resizebar.addEventListener('mousedown', event.onMouseDown_resizeBar, false);\n /** window resize event */\n\n window.addEventListener('resize', event.resize_window, false);\n /** add plugin to plugins object */\n\n if (plugins) {\n let pluginsValues = Object.values(plugins);\n\n for (let i = 0, len = pluginsValues.length, plugin; i < len; i++) {\n plugin = pluginsValues[i];\n editor.plugins[plugin.name] = util.copyObj(plugin);\n }\n\n pluginsValues = null;\n }\n /** User function */\n\n\n return {\n /**\r\n * @description Copying the contents of the editor to the original textarea\r\n */\n save: function () {\n if (editor._variable.wysiwygActive) {\n context.element.originElement.value = context.element.wysiwyg.innerHTML;\n } else {\n context.element.originElement.value = context.element.code.value;\n }\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 getContent: function () {\n let content = '';\n if (context.element.wysiwyg.innerText.trim().length === 0) return content;\n\n if (editor._variable.wysiwygActive) {\n content = context.element.wysiwyg.innerHTML;\n } else {\n content = context.element.code.value;\n }\n\n return content;\n },\n\n /**\r\n * @description Change the contents of the suneditor\r\n * @param {String} content - Content to Input\r\n */\n setContent: function (content) {\n const innerHTML = util.convertContentForEditor(content);\n\n if (editor._variable.wysiwygActive) {\n context.element.wysiwyg.innerHTML = innerHTML;\n } else {\n context.element.code.value = innerHTML;\n }\n },\n\n /**\r\n * @description Add content to the suneditor\r\n * @param {String} content - to Input\r\n */\n appendContent: function (content) {\n if (editor._variable.wysiwygActive) {\n const oP = document.createElement('P');\n oP.innerHTML = content;\n context.element.wysiwyg.appendChild(oP);\n } else {\n context.element.code.value += oP.outerHTML;\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 },\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 },\n\n /**\r\n * @description Show the suneditor\r\n */\n show: function () {\n const topAreaStyle = context.element.topArea.style;\n topAreaStyle.cssText = editor._variable.originCssText;\n if (topAreaStyle.display === 'none') topAreaStyle.display = 'block';\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 window.removeEventListener('resize', event.resize_window);\n /** remove element */\n\n context.element.topArea.parentNode.removeChild(context.element.topArea);\n this.save = null;\n this.getContext = null;\n this.getContent = null;\n this.setContent = null;\n this.appendContent = null;\n this.disabled = null;\n this.enabled = null;\n this.show = null;\n this.hide = null;\n this.destroy = null;\n }\n };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (core);//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvbGliL2NvcmUuanMuanMiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9zcmMvbGliL2NvcmUuanM/OGE4ZCJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XHJcblxyXG4vKipcclxuICogQGRlc2NyaXB0aW9uIFN1bkVkaXRvciBjb3JlIGNsb3N1cmVcclxuICogQHBhcmFtIGNvbnRleHRcclxuICogQHBhcmFtIHV0aWxcclxuICogQHBhcmFtIG1vZHVsZXNcclxuICogQHBhcmFtIHBsdWdpbnNcclxuICogQHBhcmFtIGxhbmdcclxuICogQHJldHVybnMge3tzYXZlOiBzYXZlLCBnZXRDb250ZXh0OiBnZXRDb250ZXh0LCBnZXRDb250ZW50OiBnZXRDb250ZW50LCBzZXRDb250ZW50OiBzZXRDb250ZW50LCBhcHBlbmRDb250ZW50OiBhcHBlbmRDb250ZW50LCBkaXNhYmxlZDogZGlzYWJsZWQsIGVuYWJsZWQ6IGVuYWJsZWQsIHNob3c6IHNob3csIGhpZGU6IGhpZGUsIGRlc3Ryb3k6IGRlc3Ryb3l9fVxyXG4gKi9cclxuY29uc3QgY29yZSA9IGZ1bmN0aW9uIChjb250ZXh0LCB1dGlsLCBtb2R1bGVzLCBwbHVnaW5zLCBsYW5nKSB7XHJcbiAgICAvKipcclxuICAgICAqIEBkZXNjcmlwdGlvbiBQcmFjdGljYWwgZWRpdG9yIGZ1bmN0aW9uXHJcbiAgICAgKiBUaGlzIGZ1bmN0aW9uIGlzICd0aGlzJyB1c2VkIGJ5IG90aGVyIHBsdWdpbnNcclxuICAgICAqL1xyXG4gICAgY29uc3QgZWRpdG9yID0ge1xyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBFbGVtZW50cyBhbmQgdXNlciBvcHRpb25zIHBhcmFtZXRlcnMgb2YgdGhlIHN1bmVkaXRvclxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBsb2FkZWQgbW9kdWxlc1xyXG4gICAgICAgICAqL1xyXG4gICAgICAgIG1vZHVsZXM6IHt9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gbG9hZGVkIHBsdWdpbnNcclxuICAgICAgICAgKi9cclxuICAgICAgICBwbHVnaW5zOiB7fSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIFdoZXRoZXIgdGhlIHBsdWdpbiBpcyBpbml0aWFsaXplZFxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGluaXRQbHVnaW5zOiB7fSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIHV0aWwgZnVuY3Rpb25cclxuICAgICAgICAgKi9cclxuICAgICAgICB1dGlsOiB1dGlsLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gbG9hZGVkIGxhbmd1YWdlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgbGFuZzogbGFuZyxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIGRpYWxvZyBlbGVtZW50XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZGlhbG9nRm9ybTogbnVsbCxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIHN1Ym1lbnUgZWxl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AgX2FkZE1vZHVsZTogZnVuY3Rpb24gKG1vZHVsZU9iaikge1xyXG4gICAgICAgICAgICBjb25zdCBtb2R1bGVOYW1lID0gbW9kdWxlT2JqLm5hbWU7XHJcbiAgICAgICAgICAgIGlmICghdGhpcy5wbHVnaW5zW21vZHVsZU5hbWVdKSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnBsdWdpbnNbbW9kdWxlTmFtZV0gPSB0aGlzLnV0aWwuY29weU9iaihtb2R1bGVPYmopO1xyXG4gICAgICAgICAgICAgICAgdGhpcy5wbHVnaW5zW21vZHVsZU5hbWVdLmFkZCh0aGlzKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBFbmFibGVkIHN1Ym1lbnVcclxuICAgICAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IGVsZW1lbnQgLSBTdWJtZW51IGVsZW1lbnQgdG8gY2FsbFxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIHN1Ym1lbnVPbjogZnVuY3Rpb24gKGVsZW1lbnQpIHtcclxuICAgICAgICAgICAgdGhpcy5zdWJtZW51ID0gZWxlbWVudC5uZXh0RWxlbWVudFNpYmxpbmc7XHJcbiAgICAgICAgICAgIHRoaXMuc3VibWVudS5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJztcclxuICAgICAgICAgICAgdXRpbC5hZGRDbGFzcyhlbGVtZW50LCAnb24nKTtcclxuICAgICAgICAgICAgdGhpcy5zdWJtZW51QWN0aXZlQnV0dG9uID0gZWxlbWVudDtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRGlzYWJsZSBzdWJtZW51XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgc3VibWVudU9mZjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBpZiAodGhpcy5zdWJtZW51KSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnN1Ym1lbnUuc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICAgICAgICAgIHRoaXMuc3VibWVudSA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKHRoaXMuc3VibWVudUFjdGl2ZUJ1dHRvbiwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnN1Ym1lbnVBY3RpdmVCdXR0b24gPSBudWxsO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoY29udGV4dC5pbWFnZSAmJiBjb250ZXh0LmltYWdlLl9vbkNhcHRpb24gPT09IHRydWUpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMucGx1Z2lucy5pbWFnZS50b2dnbGVfY2FwdGlvbl9jb250ZW50ZWRpdGFibGUuY2FsbChlZGl0b3IsIGZhbHNlKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyc09mZigpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEaXNhYmxlIGNvbnRyb2xsZXIgaW4gZWRpdG9yIGFyZWEgKGxpbmsgYnV0dG9uLCBpbWFnZSByZXNpemUgYnV0dG9uKVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGNvbnRyb2xsZXJzT2ZmOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGxlbiA9IHRoaXMuY29udHJvbGxlckFycmF5Lmxlbmd0aDtcclxuXHJcbiAgICAgICAgICAgIGlmIChsZW4gPiAwKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyQXJyYXlbaV0uc3R5bGUuZGlzcGxheSA9ICd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yaWFibGUuc2VsZWN0aW9uTm9kZSwgJ2ZpZ2NhcHRpb24nKTtcclxuICAgICAgICAgICAgaWYgKGNhcHRpb24pIHtcclxuICAgICAgICAgICAgICAgIGNhcHRpb24uZm9jdXMoKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC53eXNpd3lnLmZvY3VzKCk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHRoaXMuX3NldEVkaXRvclJhbmdlKCk7XHJcbiAgICAgICAgICAgIGV2ZW50Ll9maW5kQnV0dG9uRWZmZWN0VGFnKCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIFNhdmluZyB0aGUgcmFuZ2Ugb2JqZWN0IGFuZCB0aGUgY3VycmVudGx5IHNlbGVjdGVkIG5vZGUgb2YgZWRpdG9yXHJcbiAgICAgICAgICogQHByaXZhdGVcclxuICAgICAgICAgKi9cclxuICAgICAgICBfc2V0RWRpdG9yUmFuZ2U6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29uc3Qgc2VsZWN0aW9uID0gd2luZG93LmdldFNlbGVjdGlvbigpO1xyXG4gICAgICAgICAgICBsZXQgcmFuZ2UgPSBudWxsO1xyXG5cclxuICAgICAgICAgICAgaWYgKHNlbGVjdGlvbi5yYW5nZUNvdW50ID4gMCkge1xyXG4gICAgICAgICAgICAgICAgcmFuZ2UgPSBzZWxlY3Rpb24uZ2V0UmFuZ2VBdCgwKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHJhbmdlID0gdGhpcy5fY3JlYXRlRGVmYXVsdFJhbmdlKCk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHRoaXMuX3ZhcmlhYmxlLnJhbmdlID0gcmFuZ2U7XHJcblxyX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n0gb2Zmc2V0IC0gVGhlIG9mZnNldCBwcm9wZXJ0eSBvZiB0aGUgc2VsZWN0aW9uIG9iamVjdC5cclxuICAgICAgICAgKiBAcmV0dXJucyB7Qm9vbGVhbn1cclxuICAgICAgICAgKi9cclxuICAgICAgICBpc0VkZ2VQb2ludDogZnVuY3Rpb24gKGNvbnRhaW5lciwgb2Zmc2V0KSB7XHJcbiAgICAgICAgICAgIHJldHVybiAob2Zmc2V0ID09PSAwKSB8fCAob2Zmc2V0ID09PSBjb250YWluZXIubm9kZVZhbHVlLmxlbmd0aCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIFNob3cgbG9hZGluZyBib3hcclxuICAgICAgICAgKi9cclxuICAgICAgICBzaG93TG9hZGluZzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQubG9hZGluZy5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJztcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQ2xvc2UgbG9hZGluZyBib3hcclxuICAgICAgICAgKi9cclxuICAgICAgICBjbG9zZUxvYWRpbmc6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LmxvYWRpbmcuc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQXBwZW5kIFAgdGFnIHRvIGN1cnJlbnQgbGluZSBuZXh0XHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSBlbGVtZW50IC0gSW5zZXJ0IGFzIHNpYmxpbmdzIG9mIHRoYXQgZWxlbWVudFxyXG4gICAgICAgICAqIEByZXR1cm5zIHtFbGVtZW50fVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgI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HN0YXJ0T2ZmID0gcmFuZ2Uuc3RhcnRPZmZzZXQ7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBlbmRDb24gPSByYW5nZS5lbmRDb250YWluZXI7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBlbmRPZmYgPSByYW5nZS5lbmRPZmZzZXQ7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjb21tb25Db24gPSByYW5nZS5jb21tb25BbmNlc3RvckNvbnRhaW5lcjtcclxuXHJcbiAgICAgICAgICAgICAgICBwYXJlbnROb2RlID0gc3RhcnRDb247XHJcbiAgICAgICAgICAgICAgICBpZiAoc3RhcnRDb24ubm9kZVR5cGUgPT09IDMpIHtcclxuICAgICAgICAgICAgICAgICAgICBwYXJlbnROb2RlID0gc3RhcnRDb24ucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvKiogU2VsZWN0IHdpdGhpbiB0aGUgc2FtZSBub2RlICovXHJcbiAgICAgICAgICAgICAgICBpZiAocmFuZ2UuY29sbGFwc2VkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbW1vbkNvbi5ub2RlVHlwZSA9PT0gMykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByaWdodE5vZGUgPSBjb21tb25Db24uc3BsaXRUZXh0KGVuZE9mZik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyZW50Tm9kZS5sYXN0Q2hpbGQgIT09IG51bGwgJiYgL15CUiQvaS50ZXN0KHBhcmVudE5vZGUubGFzdENoaWxkLm5vZGVOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5yZW1vdmVDaGlsZChwYXJlbnROb2RlLmxhc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmlnaHROb2RlID0gbnVsbDtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAvKiogU2VsZWN0IG11bHRpcGxlIG5vZGVzICovXHJcbiAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NhbWVDb250YWluZXIgPSBzdGFydENvbiA9PT0gZW5kQ29uO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoaXNTYW1lQ29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZW1vdmVOb2RlID0gc3RhcnRDb247XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VkZ2VQb2ludChlbmRDb24sIGVuZE9mZikpIHJpZ2h0Tm9kZSA9IGVuZENvbi5zcGxpdFRleHQoZW5kT2ZmKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzRWRnZVBvaW50KHN0YXJ0Q29uLCBzdGFydE9mZikpIHJlbW92ZU5vZGUgPSBzdGFydENvbi5zcGxpdFRleHQoc3RhcnRPZmYpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5yZW1vdmVDaGlsZChyZW1vdmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlTm9kZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByaWdodE5vZGUgPSBlbmRDb247XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocmlnaHROb2RlLm5vZGVUeXBlICE9PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByaWdodE5vZGUgPSByaWdodE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUgPSByaWdodE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IHJpZ2h0Tm9kZS5uZXh0U2libGluZztcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKG9Ob2RlLCByaWdodE5vZGUpO1xyXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XHJcbiAgICAgICAgICAgICAgICBwYXJlbnROb2RlLmFwcGVuZENoaWxkKG9Ob2RlKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLy8gdGhpcy5zZXRSYW5nZShvTm9kZSwgMCwgb05vZGUsIDApO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEZWxldGUgdGhlIGN1cnJlbnRseSBzZWxlY3RlZCBub2RlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgcmVtb3ZlTm9kZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb25zdCByYW5nZSA9IHRoaXMuZ2V0UmFuZ2UoKTtcclxuXHJcbiAgICAgICAgICAgIGlmIChyYW5nZS5kZWxldGVDb250ZW50cykge1xyXG4gICAgICAgICAgICAgICAgcmFuZ2UuZGVsZXRlQ29udGVudHMoKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3Qgc3RhcnRDb24gPSByYW5nZS5zdGFydENvbnRhaW5lcjtcclxuICAgICAgICAgIC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xuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBlbmRJbmRleCAtIDEsIGVuZE5vZGUgPSBlbmRDb247IGkgPiBzdGFydEluZGV4OyBpLS0pIHtcclxuICAgICAgICAgICAgICAgIGlmIChjaGlsZE5vZGVzW2ldID09PSBlbmROb2RlLnBhcmVudE5vZGUgJiYgY2hpbGROb2Rlc1tpXS5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZXMuc3BsaWNlKGksIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVuZE5vZGUgPSBlbmROb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgLS1lbmRJbmRleDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IHN0YXJ0SW5kZXg7IGkgPD0gZW5kSW5kZXg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGNoaWxkTm9kZXNbaV07XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0ubGVuZ3RoID09PSAwIHx8IChpdGVtLm5vZGVUeXBlID09PSAzICYmIGl0ZW0uZGF0YSA9PT0gdW5kZWZpbmVkKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShpdGVtKTtcclxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaXRlbSA9PT0gc3RhcnRDb24pIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc3RhcnRDb24ubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmVmb3JlTm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHN0YXJ0Q29uLnRleHRDb250ZW50KTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiZWZvcmVOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb24uc3Vic3RyaW5nRGF0YSgwLCBzdGFydE9mZikpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJlZm9yZU5vZGUubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbi5kYXRhID0gYmVmb3JlTm9kZS5kYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShzdGFydENvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaXRlbSA9PT0gZW5kQ29uKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVuZENvbi5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhZnRlck5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShlbmRDb24udGV4dENvbnRlbnQpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFmdGVyTm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKGVuZENvbi5zdWJzdHJpbmdEYXRhKGVuZE9mZiwgKGVuZENvbi5sZW5ndGggLSBlbmRPZmYpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoYWZ0ZXJOb2RlLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZW5kQ29uLm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jtdKlxcXFxzKig/Ojt8JCknO1xyXG4gICAgICAgICAgICAgICAgcmVnRXhwID0gbmV3IFJlZ0V4cChyZWdFeHAsICdnaScpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogb25lIG5vZGUgKi9cclxuICAgICAgICAgICAgaWYgKHN0YXJ0Q29uID09PSBlbmRDb24pIHtcclxuICAgICAgICAgICAgICAgIG5ld05vZGUgPSBhcHBlbmROb2RlLmNsb25lTm9kZShmYWxzZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIE5vIG5vZGUgc2VsZWN0ZWQgKi9cclxuICAgICAgICAgICAgICAgIGlmIChzdGFydE9mZiA9PT0gZW5kT2ZmKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZS5pbm5lckhUTUwgPSAnJiM2NTI3OSc7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHV0aWwuaXNGb3JtYXRFbGVtZW50KHN0YXJ0Q29uKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbi5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbi5zcGxpdFRleHQoc3RhcnRPZmYpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbi5wYXJlbnROb2RlLmluc2VydEJlZm9yZShuZXdOb2RlLCBzdGFydENvbi5uZXh0U2libGluZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgLyoqIFNlbGVjdCB3aXRoaW4gdGhlIHNhbWUgbm9kZSAqL1xyXG4gICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNFbGVtZW50ID0gc3RhcnRDb24ubm9kZVR5cGUgPT09IDE7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzRWxlbWVudCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlLmlubmVySFRNTCA9IHN0YXJ0Q29uLm91dGVySFRNTDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb24ucGFyZW50Tm9kZS5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKHN0YXJ0Q29uKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiZWZvcmVOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb24uc3Vic3RyaW5nRGF0YSgwLCBzdGFydE9mZikpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZnRlck5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShzdGFydENvbi5zdWJzdHJpbmdEYXRhKGVuZE9mZiwgKHN0YXJ0Q29uLmxlbmd0aCAtIGVuZE9mZikpKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUuaW5uZXJUZXh0ID0gc3RhcnRDb24uc3Vic3RyaW5nRGF0YShzdGFydE9mZiwgKGVuZE9mZiAtIHN0YXJ0T2ZmKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29uLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKG5ld05vZGUsIHN0YXJ0Q29uLm5leHRTaWJsaW5nKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiZWZvcmVOb2RlLmRhdGEubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb24uZGF0YSA9IGJlZm9yZU5vZGUuZGF0YTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29uLmRhdGEgPSBzdGFydENvbi5zdWJzdHJpbmdEYXRhKDAsIHN0YXJ0T2ZmKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFmdGVyTm9kZS5kYXRhLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29uLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKGFmdGVyTm9kZSwgbmV3Tm9kZS5uZXh0U2libGluZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgc3RhcnQuY29udGFpbmVyID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgIHN0YXJ0Lm9mZnNldCA9IDE7XHJcbiAgICAgICAgICAgICAgICBlbmQuY29udGFpbmVyID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgIGVuZC5vZmZzZXQgPSAxO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIC8qKiBtdWx0aXBsZSBub2RlcyAqL1xyXG4gICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgIC8qKiB0YWcgY2hlY2sgZnVuY3Rpb24qL1xyXG4gICAgICAgICAgICAgICAgY29uc3QgY2hlY2tDc3MgPSBmdW5jdGlvbiAodk5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAodk5vZGUubm9kZVR5cGUgPT09IDMpIHJldHVybiB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBsZXQgc3R5bGUgPSAnJztcclxuICAgICAgICAgICAgICAgICAgICBpZiAocmVnRXhwICYmIHZOb2RlLnN0eWxlLmNzc1RleHQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZSA9IHZOb2RlLnN0eWxlLmNzc1RleHQucmVwbGFjZShyZWdFeHAsICcnKS50cmltKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAodk5vZGUubm9kZU5hbWUgIT09IGFwcGVuZE5vZGUubm9kZU5hbWUgfHwgc3R5bGUubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodk5vZGUuc3R5bGUuY3NzVGV4dC5sZW5ndGggPiAwKSB2Tm9kZS5zdHlsZS5jc3NUZXh0ID0gc3R5bGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICAvKiogb25lIGxpbmUgKi9cclxuICAgICAgICAgICAgICAgIGlmICghdXRpbC5oYXNDbGFzcyhjb21tb25Db24sICdzdW4tZWRpdG9yLWlkLXd5c2l3eWcnKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBhcHBlbmROb2RlLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbmV3UmFuZ2UgPSB0aGlzLl93cmFwTGluZU5vZGVzUGFydChjb21tb25Db24sIG5ld05vZGUsIGNoZWNrQ3NzLCBzdGFydENvbiwgc3RhcnRPZmYsIGVuZENvbiwgZW5kT2ZmKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgc3RhcnQuY29udGFpbmVyID0gbmV3UmFuZ2Uuc3RhcnRDb250YWluZXI7XHJcbiAgICAgICAgICAgICAgICAgICAgc3RhcnQub2Zmc2V0ID0gbmV3UmFuZ2Uuc3RhcnRPZmZzZXQ7XHJcbiAgICAgICAgICAgICAgICAgICAgZW5kLmNvbnRhaW5lciA9IG5ld1JhbmdlLmVuZENvbnRhaW5lcjtcclxuICAgICAgICAgICAgICAgICAgICBlbmQub2Zmc2V0ID0gbmV3UmFuZ2UuZW5kT2Zmc2V0O1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgLyoqIG11bHRpIGxpbmUgKi9cclxuICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIC8vIGdldCBsaW5lIG5vZGVzXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZU5vZGVzID0gdXRpbC5nZXRMaXN0Q2hpbGRyZW4oY29tbW9uQ29uLCBmdW5jdGlvbiAoY3VycmVudCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdXRpbC5pc0Zvcm1hdEVsZW1lbnQoY3VycmVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzdGFydExpbmUgPSB1dGlsLmdldFBhcmVudEVsZW1lbnQoc3RhcnRDb24sICdQJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGVuZExpbmUgPSB1dGlsLmdldFBhcmVudEVsZW1lbnQoZW5kQ29uLCAnUCcpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gbGluZU5vZGVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGFydExpbmUgPT09IGxpbmVOb2Rlc1tpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRMaW5lID0gaTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmRMaW5lID09PSBsaW5lTm9kZXNbaV0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZExpbmUgPSBpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIHN0YXJ0Q29uXHJcbiAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGFwcGVuZE5vZGUuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydCA9IHRoaXMuX3dyYXBMaW5lTm9kZXNTdGFydChsaW5lTm9kZXNbc3RhcnRMaW5lXSwgbmV3Tm9kZSwgY2hlY2tDc3MsIHN0YXJ0Q29uLCBzdGFydE9mZik7XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gbWlkXHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHN0YXJ0TGluZSArIDE7IGkgPCBlbmRMaW5lOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGFwcGVuZE5vZGUuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fd3JhcExpbmVOb2RlcyhsaW5lTm9kZXNbaV0sIG5ld05vZGUsIGNoZWNrQ3NzKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZW5kQ29uXHJcbiAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGFwcGVuZE5vZGUuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICBlbmQgPSB0aGlzLl93cmFwTGluZU5vZGVzRW5kKGxpbmVOb2Rlc1tlbmRMaW5lXSwgbmV3Tm9kZSwgY2hlY2tDc3MsIGVuZENvbiwgZW5kT2ZmKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgIC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XTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24oY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjbG9uZU5vZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgPT09IHN0YXJ0Q29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Tm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHN0YXJ0Q29udGFpbmVyLnN1YnN0cmluZ0RhdGEoMCwgc3RhcnRPZmZzZXQpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb250YWluZXIuc3Vic3RyaW5nRGF0YShzdGFydE9mZnNldCwgKHN0YXJ0Q29udGFpbmVyLmxlbmd0aCAtIHN0YXJ0T2Zmc2V0KSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRPZmZzZXQgPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb250YWluZXIgPSBjbG9uZU5vZGUgPSBjaGlsZC5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKGNoaWxkID09PSBlbmRDb250YWluZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFmdGVyTm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKGVuZENvbnRhaW5lci5zdWJzdHJpbmdEYXRhKGVuZE9mZnNldCwgKGVuZENvbnRhaW5lci5sZW5ndGggLSBlbmRPZmZzZXQpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZCA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKGVuZENvbnRhaW5lci5zdWJzdHJpbmdEYXRhKDAsIGVuZE9mZnNldCkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kT2Zmc2V0ID0gY2hpbGQubGVuZ3RoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kQ29udGFpbmVyID0gY2xvbmVOb2RlID0gY2hpbGQuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZU5vZGVMaXN0LnB1c2goY2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmFwcGVuZENoaWxkKGNsb25lTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSkgY292ZXJOb2RlID0gY2xvbmVOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjb3Zlck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KShlbCwgbmV3SW5uZXJOb2RlKTtcclxuXHJcbiAgICAgICAgICAgIGVsLmlubmVySFRNTCA9ICcnO1xyXG4gICAgICAgICAgICBlbC5hcHBlbmRDaGlsZChwcmV2Tm9kZSk7XHJcbiAgICAgICAgICAgIGVsLmFwcGVuZENoaWxkKG5ld0lubmVyTm9kZSk7XHJcbiAgICAgICAgICAgIGVsLmFwcGVuZENoaWxkKGFmdGVyTm9kZSk7XHJcblxyXG4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AgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gY2hpbGROb2Rlcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjaGlsZCA9IGNoaWxkTm9kZXNbaV07XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvdmVyTm9kZSA9IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24oY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjbG9uZU5vZGUgPSBjaGlsZC5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmFwcGVuZENoaWxkKGNsb25lTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSkgY292ZXJOb2RlID0gY2xvbmVOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjb3Zlck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KShlbGVtZW50LCBuZXdJbm5lck5vZGUpO1xyXG5cclxuICAgICAgICAgICAgZWxlbWVudC5pbm5lckhUTUwgPSAnJztcclxuICAgICAgICAgICAgZWxlbWVudC5hcHBlbmRDaGlsZChuZXdJbm5lck5vZGUpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiB3cmFwcyBmaXJzdCBsaW5lIHNlbGVjdGVkIHRleHQuXHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSBlbGVtZW50IC0gVGhlIG5vZGUgb2YgdGhlIGxpbmUgdGhhdCBjb250YWlucyB0aGUgc2VsZWN0ZWQgdGV4dCBub2RlLlxyXG4gICAgICAgICAqIEBwYXJhbSB7RWxlb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dXJzaW9uRnVuYyhjdXJyZW50LCBub2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGVzID0gY3VycmVudC5jaGlsZE5vZGVzO1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGNoaWxkTm9kZXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZCA9IGNoaWxkTm9kZXNbaV07XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvdmVyTm9kZSA9IG5vZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYXNzTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gY2hpbGQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChuZXdOb2RlLnBhcmVudE5vZGUgIT09IG51bGwgJiYgbmV3Tm9kZSAhPT0gZWwgJiYgbmV3Tm9kZSAhPT0gbmV3SW5uZXJOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGlvbihuZXdOb2RlKSAmJiBuZXdOb2RlLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQucHVzaChuZXdOb2RlLmNsb25lTm9kZShmYWxzZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SW5uZXJOb2RlLmFwcGVuZENoaWxkKGFwcGVuZE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3SW5uZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBzdGFydENvbnRhaW5lclxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghcGFzc05vZGUgJiYgY2hpbGQgPT09IGNvbnRhaW5lcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcmV2Tm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKGNvbnRhaW5lci5zdWJzdHJpbmdEYXRhKDAsIG9mZnNldCkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0Tm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKGNvbnRhaW5lci5zdWJzdHJpbmdEYXRhKG9mZnNldCwgKGNvbnRhaW5lci5sZW5ndGggLSBvZmZzZXQpKSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldk5vZGUuZGF0YS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlLmFwcGVuZENoaWxkKHByZXZOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChuZXdOb2RlICE9PSBwTm9kZSAmJiBuZXdOb2RlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGlvbihuZXdOb2RlKSAmJiBuZXdOb2RlLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQucHVzaChuZXdOb2RlLmNsb25lTm9kZShmYWxzZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IG5ld05vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKSB8fCBub2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZS5hcHBlbmRDaGlsZChuZXdOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFwcGVuZE5vZGUgIT09IG5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZS5hcHBlbmRDaGlsZChhcHBlbmROb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld0lubmVyTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcE5vZGUuYXBwZW5kQ2hpbGQobmV3SW5uZXJOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdGV4dE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhc3NOb2RlID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY29udGFpbmVyKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXBhc3NOb2RlIHx8IHZhbGlkYXRpb24oY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY2xvbmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxKSBjb3Zlck5vZGUgPSBjbG9uZU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjb3Zlck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KShlbGVtZW50LCBwTm9kZSk7XHJcblxyXG4gICAgICAgICAgICBlbGVtZW50LnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHBOb2RlLCBlbGVtZW50KTtcclxuICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGVsZW1lbnQpO1xyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogY29udGFpbmVyLFxyXG4gICAgICAgICAgICAgICAgb2Zmc2V0OiBvZmZzZXRcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gd3JhcHMgbGFzdCBsaW5lIHNlbGVjdGVkIHRleHQuXHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSBlbGVtZW50IC0gVGhlIG5vZGUgb2YgdGhlIGxpbmUgdGhhdCBjb250YWlucyB0aGUgc2VsZWN0ZWQgdGV4dCBub2RlLlxyXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gbmV3SW5uZXJOb2RlIC0gVGhlIGRvbSB0aGF0IHdpbGwgd3JhcCB0aGUgc2VsZWN0ZWQgdGV4dCBhcmVhXHJcbiAgICAgICAgICogQHBhcmFtIHtmdW5jdGlvbn0gdmFsaWRhdGlvbiAtIENoZWNrIGlmIHRoZSBub2RlIHNob3VsZCBiZSBzdHJpcHBlZC5cclxuICAgICAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IGVuZENvbiAtIFRoZSBlbmRDb250YWluZXIgcHJvcGVydHkgb2YgdGhlIHNlbGVjdGlvbiBvYmplY3QuXHJcbiAgICAgICAgICogQHBhcmFtIHtOdW1iZXJ9IGVuZE9mZiAtIFRoZSBlbmRPZmZzZXQgcHJvcGVydHkgb2YgdGhlIHNlbGVjdGlvbiBvYmplY3QuXHJcbiAgICAgICAgICogQHJldHVybnMge3tjb250YWluZXI6ICosIG9mZnNldDogKn19XHJcbiAgICAgICAgICogQHByaXZhdGVcclxuICAgICAgICAgKi9cclxuICAgICAgICBfd3JhcExpbmVOb2Rlc0VuZDogZnVuY3Rpb24gKGVsZW1lbnQsIG5ld0lubmVyTm9kZSwgdmFsaWRhdGlvbiwgZW5kQ29uLCBlbmRPZmYpIHtcclxuICAgICAgICAgICAgY29uc3QgZWwgPSBlbGVtZW50O1xyXG4gICAgICAgICAgICBjb25zdCBwTm9kZSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ1AnKTtcclxuXHJcbiAgICAgICAgICAgIGxldCBjb250YWluZXIgPSBlbmRDb247XHJcbiAgICAgICAgICAgIGxldCBvZmZzZXQgPSBlbmRPZmY7XHJcbiAgICAgICAgICAgIGxldCBwYXNzTm9kZSA9IGZhbHNlO1xyXG4gICAgICAgICAgICBsZXQgcEN1cnJlbnQsIG5ld05vZGUsIGFwcGVuZE5vZGU7XHJcblxyXG4gICAgICAgICAgICAoZnVuY3Rpb24gcmVjdXJzaW9uRnVuYyhjdXJyZW50LCBub2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGVzID0gY3VycmVudC5jaGlsZE5vZGVzO1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IGNoaWxkTm9kZXMubGVuZ3RoIC0xOyAwIDw9IGk7IGktLSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGROb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhc3NOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdXJzaW9uRnVuYyhjaGlsZCwgY2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBjaGlsZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUucGFyZW50Tm9kZSAhPT0gbnVsbCAmJiBuZXdOb2RlICE9PSBlbCAmJiBuZXdOb2RlICE9PSBuZXdJbm5lck5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKG5ld05vZGUpICYmIG5ld05vZGUubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuaW5zZXJ0QmVmb3JlKG5ld05vZGUsIGFwcGVuZE5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuaW5zZXJ0QmVmb3JlKGFwcGVuZE5vZGUsIG5ld0lubmVyTm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld0lubmVyTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZW5kQ29udGFpbmVyXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXNzTm9kZSAmJiBjaGlsZCA9PT0gY29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFmdGVyTm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKGNvbnRhaW5lci5zdWJzdHJpbmdEYXRhKG9mZnNldCwgKGNvbnRhaW5lci5sZW5ndGggLSBvZmZzZXQpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHROb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoY29udGFpbmVyLnN1YnN0cmluZ0RhdGEoMCwgb2Zmc2V0KSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWZ0ZXJOb2RlLmRhdGEubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5pbnNlcnRCZWZvcmUoYWZ0ZXJOb2RlLCBub2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUgIT09IHBOb2RlICYmIG5ld05vZGUgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKG5ld05vZGUpICYmIG5ld05vZGUubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpIHx8IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmluc2VydEJlZm9yZShuZXdOb2RlLCBhcHBlbmROb2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXBwZW5kTm9kZSAhPT0gbm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SW5uZXJOb2RlLmluc2VydEJlZm9yZShhcHBlbmROb2RlLCBuZXdJbm5lck5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdJbm5lck5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBOb2RlLmluc2VydEJlZm9yZShuZXdJbm5lck5vZGUsIHBOb2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIgPSB0ZXh0Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0ID0gdGV4dE5vZGUuZGF0YS5sZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhc3NOb2RlID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuaW5zZXJ0QmVmb3JlKGNvbnRhaW5lciwgbm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXBhc3NOb2RlIHx8IHZhbGlkYXRpb24oY2hpbGQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuaW5zZXJ0QmVmb3JlKGNsb25lTm9kZSwgbm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxKSBjb3Zlck5vZGUgPSBjbG9uZU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjb3Zlck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KShlbGVtZW50LCBwTm9kZSk7XHJcblxyXG4gICAgICAgICAgICBlbGVtZW50LnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHBOb2RlLCBlbGVtZW50KTtcclxuICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGVsZW1lbnQpO1xyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogY29udGFpbmVyLFxyXG4gICAgICAgICAgICAgICAgb2Zmc2V0OiBvZmZzZXRcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gVGhpcyBmdW5jdGlvbiBpbXBsZW1lbnRzIGluZGVudGF0aW9uLlxyXG4gICAgICAgICAqIFNldCBcIm1hcmdpbi1sZWZ0XCIgdG8gXCIyNXB4XCIgaW4gdGhlIHRvcCBcIlBcIiB0YWcgb2YgdGhlIHBhcmFtZXRlciBub2RlLlxyXG4gICAgICAgICAqIEBwYXJhbSBlbGVtZW50IHtFbGVtZW50fSAtIFRoZSBlbGVtZW50IHRvIGluZGVudCAoZWRpdG9yLmdldFNlbGVjdGlvbk5vZGUoKSlcclxuICAgICAgICAgKiBAcGFyYW0gY29tbWFuZCB7U3RyaW5nfSAtIFNlcGFyYXRvciAoXCJpbmRlbnRcIiBvciBcIm91dGRlbnRcIilcclxuICAgICAgICAgKi9cclxuICAgICAgICBpbmRlbnQ6IGZ1bmN0aW9uIChlbGVtZW50LCBjb21tYW5kKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHAgPSB1dGlsLmdldFBhcmVudEVsZW1lbnQoZWxlbWVudCwgJ1AnKTtcclxuICAgICAgICAgICAgaWYgKCFwKSByZXR1cm47XHJcblxyXG4gICAgICAgICAgICBsZXQgbWFyZ2luID0gL1xcZCsvLnRlc3QocC5zdHlsZS5tYXJnaW5MZWZ0KSA/IHAuc3R5bGUubWFyZ2luTGVmdC5tYXRjaCgvXFxkKy8pWzBdICogMSA6IDA7XHJcblxyXG4gICAgICAgICAgICBpZiAoJ2luZGVudCcgPT09IGNvbW1hbmQpIHtcclxuICAgICAgICAgICAgICAgIG1hcmdpbiArPSAyNTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIG1hcmdpbiAtPSAyNTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcC5zdHlsZS5tYXJnaW5MZWZ0ID0gKG1hcmdpbiA8IDAgPyAwIDogbWFyZ2luKSArICdweCc7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEFkZCBvciByZW1vdmUgdGhlIGNsYXNzIG5hbWUgb2YgXCJib2R5XCIgc28gdGhhdCB0aGUgY29kZSBibG9jayBpcyB2aXNpYmxlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgdG9nZ2xlRGlzcGxheUJsb2NrczogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKGNvbnRleHQuZWxlbWVudC53eXNpd3lnLCAnc3VuLWVkaXRvci1zaG93LWJsb2NrJyk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIENoYW5nZXMgdG8gY29kZSB2aWV3IG9yIHd5c2l3eWcgdmlld1xyXG4gICAgICAgICAqL1xyXG4gICAgICAgIHRvZ2dsZUNvZGVWaWV3OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGlmICghdGhpcy5fdmFyaWFibGUud3lzaXd5Z0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgZWMgPSB7JyZhbXA7JzogJyYnLCAnJm5ic3A7JzogJ1xcdTAwQTAnLCBcIiZxdW90O1wiOiBcIidcIiwgJyZsdDsnOiAnPCcsICcmZ3Q7JzogJz4nfTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNvZGVfaHRtbCA9IGNvbnRleHQuZWxlbWVudC5jb2RlLnZhbHVlLnJlcGxhY2UoLyZbYS16XSs7L2csIGZ1bmN0aW9uIChtKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICh0eXBlb2YgZWNbbV0gPT09ICdzdHJpbmcnKSA/IGVjW21dIDogbTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MID0gY29kZV9odG1sLnRyaW0oKS5sZW5ndGggPiAwID8gY29kZV9odG1sIDogJzxwPiYjNjUyNzk8L3A+JztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC53eXNpd3lnLnNjcm9sbFRvcCA9IDA7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQuY29kZS5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuc3R5bGUuZGlzcGxheSA9ICdibG9jayc7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl92YXJpYWJsZS53eXNpd3lnQWN0aXZlID0gdHJ1ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB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bnQuZmlyc3RFbGVtZW50Q2hpbGQsICdpY29uLXJlZHVjdGlvbicpO1xyXG4gICAgICAgICAgICAgICAgdXRpbC5hZGRDbGFzcyhlbGVtZW50LmZpcnN0RWxlbWVudENoaWxkLCAnaWNvbi1leHBhbnNpb24nKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5fdmFyaWFibGUuaXNGdWxsU2NyZWVuID0gIXRoaXMuX3ZhcmlhYmxlLmlzRnVsbFNjcmVlbjtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gT3BlbiB0aGUgcHJldmlldyB3aW5kb3cgb3Igb3BlbiB0aGUgcHJpbnQgd2luZG93XHJcbiAgICAgICAgICogQHBhcmFtIHtTdHJpbmd9IG1vZGUgLSAncHJldmlldycgb3IgJ3ByaW50J1xyXG4gICAgICAgICAqL1xyXG4gICAgICAgIG9wZW5XaW5kb3dDb250ZW50czogZnVuY3Rpb24gKG1vZGUpIHtcclxuICAgICAgICAgICAgY29uc3QgaXNQcmludCA9IG1vZGUgPT09ICdwcmludCc7XHJcbiAgICAgICAgICAgIGNvbnN0IHdpbmRvd09iamVjdCA9IHdpbmRvdy5vcGVuKCcnLCAnX2JsYW5rJyk7XHJcbiAgICAgICAgICAgIHdpbmRvd09iamVjdC5taW1lVHlwZSA9ICd0ZXh0L2h0bWwnO1xyXG4gICAgICAgICAgICB3aW5kb3dPYmplY3QuZG9jdW1lbnQud3JpdGUoJycgK1xyXG4gICAgICAgICAgICAgICAgJzwhZG9jdHlwZSBodG1sPjxodG1sPicgK1xyXG4gICAgICAgICAgICAgICAgJzxoZWFkPicgK1xyXG4gICAgICAgICAgICAgICAgJzxtZXRhIGNoYXJzZXQ9XCJ1dGYtOFwiIC8+JyArXHJcbiAgICAgICAgICAgICAgICAnPG1ldGEgbmFtZT1cInZpZXdwb3J0XCIgY29udGVudD1cIndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xXCI+JyArXHJcbiAgICAgICAgICAgICAgICAnPHRpdGxlPicgKyAoaXNQcmludCA/IGxhbmcudG9vbGJhci5wcmludCA6IGxhbmcudG9vbGJhci5wcmV2aWV3KSArICc8L3RpdGxlPicgK1xyXG4gICAgICAgICAgICAgICAgJzxsaW5rIHJlbD1cInN0eWxlc2hlZXRcIiB0eXBlPVwidGV4dC9jc3NcIiBocmVmPVwiJyArIHV0aWwuZ2V0SW5jbHVkZVBhdGgoWydzdW5lZGl0b3ItY29udGVudHMnLCAnc3VuZWRpdG9yJ10sICdjc3MnKSArICdcIj4nICtcclxuICAgICAgICAgICAgICAgICc8L2hlYWQ+JyArXHJcbiAgICAgICAgICAgICAgICAnPGJvZHkgY2xhc3M9XCJzdW4tZWRpdG9yLWVkaXRhYmxlXCI+JyArIGNvbnRleHQuZWxlbWVudC53eXNpd3lnLmlubmVySFRNTCArICc8L2JvZHk+JyArXHJcbiAgICAgICAgICAgICAgICAnPC9ib2R5PicgKyAoaXNQcmludCA/ICc8c2NyaXB0PndpbmRvdy5wcmludCgpOzwvc2NyaXB0PicgOiAnJykgKyAnPC9odG1sPicpO1xyXG4gICAgICAgIH1cclxuICAgIH07XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAZGVzY3JpcHRpb24gZXZlbnQgZnVuY3Rpb25cclxuICAgICAqL1xyXG4gICAgY29uc3QgZXZlbnQgPSB7XHJcbiAgICAgICAgX3Nob3J0Y3V0S2V5Q29kZToge1xyXG4gICAgICAgICAgICA2NjogWydib2xkJywgJ0InXSxcclxuICAgICAgICAgICAgODM6IFsnc3RyaWtldGhyb3VnaCcsICdTVFJJS0UnXSxcclxuICAgICAgICAgICAgODU6IFsndW5kZXJsaW5lJywgJ1UnXSxcclxuICAgICAgICAgICAgNzM6IFsnaXRhbGljJywgJ0knXSxcclxuICAgICAgICAgICAgODk6IFsncmVkbyddLFxyXG4gICAgICAgICAgICA5MDogWyd1bmRvJ10sXHJc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XNXeXNpd3lnRGl2KHNlbGVjdGlvblBhcmVudCk7IHNlbGVjdGlvblBhcmVudCA9IHNlbGVjdGlvblBhcmVudC5wYXJlbnROb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uUGFyZW50Lm5vZGVUeXBlICE9PSAxKSBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIG5vZGVOYW1lID0gc2VsZWN0aW9uUGFyZW50Lm5vZGVOYW1lLnRvVXBwZXJDYXNlKCk7XHJcbiAgICAgICAgICAgICAgICBjdXJyZW50Tm9kZXMucHVzaChub2RlTmFtZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIEZvcm1hdCAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRGb3JtYXQgJiYgdXRpbC5pc0Zvcm1hdEVsZW1lbnQoc2VsZWN0aW9uUGFyZW50KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdGT1JNQVQnKTtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwWydGT1JNQVQnXSwgbm9kZU5hbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRGb3JtYXQgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvKiogRm9udCAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRGb250ICYmIChzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udEZhbWlseS5sZW5ndGggPiAwIHx8IChzZWxlY3Rpb25QYXJlbnQuZmFjZSAmJiBzZWxlY3Rpb25QYXJlbnQuZmFjZS5sZW5ndGggPiAwKSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnRk9OVCcpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNlbGVjdEZvbnQgPSAoc2VsZWN0aW9uUGFyZW50LnN0eWxlLmZvbnRGYW1pbHkgfHwgc2VsZWN0aW9uUGFyZW50LmZhY2UgfHwgbGFuZy50b29sYmFyLmZvbnQpLnJlcGxhY2UoL1tcIiddL2csJycpO1xyXG4gICAgICAgICAgICAgICAgICAgIHV0aWwuY2hhbmdlVHh0KGNvbW1hbmRNYXBbJ0ZPTlQnXSwgc2VsZWN0Rm9udCk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEZvbnQgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvKiogQSAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRBICYmIC9eQSQvLnRlc3Qobm9kZU5hbWUpICYmIHNlbGVjdGlvblBhcmVudC5nZXRBdHRyaWJ1dGUoJ2RhdGEtaW1hZ2UtbGluaycpID09PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFjb250ZXh0LmxpbmsgfHwgZWRpdG9yLmNvbnRyb2xsZXJBcnJheVswXSAhPT0gY29udGV4dC5saW5rLmxpbmtCdG4pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oJ2xpbmsnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucGx1Z2lucy5saW5rLmNhbGxfY29udHJvbGxlcl9saW5rQnV0dG9uLmNhbGwoZWRpdG9yLCBzZWxlY3Rpb25QYXJlbnQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEEgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZmluZEEgJiYgY29udGV4dC5saW5rICYmIGVkaXRvci5jb250cm9sbGVyQXJyYXlbMF0gPT09IGNvbnRleHQubGluay5saW5rQnRuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmNvbnRyb2xsZXJzT2ZmKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIFNQQU4gKi9cclxuICAgICAgICAgICAgICAgIGlmIChmaW5kU2l6ZSAmJiAvXlNQQU4kLy50ZXN0KG5vZGVOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIC8qKiBmb250IHNpemUgKi9cclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uUGFyZW50LnN0eWxlLmZvbnRTaXplLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ1NJWkUnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcFsnU0laRSddLCBzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udFNpemUubWF0Y2goL1xcZCsvKVswXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbmRTaXplID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBjb21tYW5kIG1hcCAqL1xyXG4gICAgICAgICAgICAgICAgY3NzVGV4dCA9IHNlbGVjdGlvblBhcmVudC5zdHlsZS5jc3NUZXh0O1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRCICYmIC9mb250XFwtd2VpZ2h0XFxzKjpcXHMqKD86XFxkK3xib2xkfGJvbGRlcikoPzo7fFxcc3wpLy50ZXN0KGNzc1RleHQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ0InKTtcclxuICAgICAgICAgICAgICAgICAgICBmaW5kQiA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRJICYmIC9mb250XFwtc3R5bGVcXHMqOlxccyooPzppdGFsaWN8b2JsaXF1ZSkoPzo7fFxccykvLnRlc3QoY3NzVGV4dCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnSScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRJID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZFUgJiYgL3RleHRcXC1kZWNvcmF0aW9uKD86XFwtbGluZSk/XFxzKjpcXHMqdW5kZXJsaW5lKD86O3xcXHN8KS8udGVzdChjc3NUZXh0KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdVJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZFUgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChmaW5kUyAmJiAvdGV4dFxcLWRlY29yYXRpb24oPzpcXC1saW5lKT9cXHMqOlxccypsaW5lLXRocm91Z2goPzo7fFxcc3wpLy50ZXN0KGNzc1RleHQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ1NUUklLRScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRTID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goKC9eU1RST05HJC8udGVzdChub2RlTmFtZSkgPyAnQicgOiAvXkVNJC8udGVzdChub2RlTmFtZSkgPyAnSScgOiBub2RlTmFtZSkpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvKiogQSBUYWcgZWRpdCBjb250cm9sbGVyIG9mZiAqL1xyXG4gICAgICAgICAgICBpZiAoZmluZEEpIGVkaXRvci5jb250cm9sbGVyc09mZigpO1xyXG5cclxuICAgICAgICAgICAgLyoqIHRvZ2dsZSBjbGFzcyBvbiAqL1xyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvbW1hbmRNYXBOb2Rlcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgbm9kZU5hbWUgPSBjb21tYW5kTWFwTm9kZXNbaV07XHJcbiAgICAgICAgICAgICAgICBpZiAoY2xhc3NPbkNoZWNrLnRlc3Qobm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5hZGRDbGFzcyhjb21tYW5kTWFwW25vZGVOYW1lXSwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiByZW1vdmUgY2xhc3MsIGRpc3BsYXkgdGV4dCAqL1xyXG4gICAgICAgICAgICBmb3IgKGxldCBrZXkgaW4gY29tbWFuZE1hcCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKGNvbW1hbmRNYXBOb2Rlcy5pbmRleE9mKGtleSkgPiAtMSkgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICBpZiAoL15GT05UL2kudGVzdChrZXkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcFtrZXldLCBsYW5nLnRvb2xiYXIuZm9udCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBlbHNlIGlmICgvXlNJWkUkL2kudGVzdChrZXkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcFtrZXldLCBsYW5nLnRvb2xiYXIuZm9udFNpemUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW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XHJcbiAgICAgICAgICAgIC8qKiBEaWFsb2csIFN1Ym1lbnUgKi9cclxuICAgICAgICAgICAgaWYgKGRpc3BsYXkpIHtcclxuICAgICAgICAgICAgICAgIGlmICgvc3VibWVudS8udGVzdChkaXNwbGF5KSAmJiAodGFyZ2V0Lm5leHRFbGVtZW50U2libGluZyA9PT0gbnVsbCB8fCB0YXJnZXQgIT09IGVkaXRvci5zdWJtZW51QWN0aXZlQnV0dG9uKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5zdWJtZW51T2ZmKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oY29tbWFuZCwgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9uKHRhcmdldCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoL2RpYWxvZy8udGVzdChkaXNwbGF5KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5jYWxsUGx1Z2luKGNvbW1hbmQsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnMuZGlhbG9nLm9wZW5EaWFsb2cuY2FsbChlZGl0b3IsIGNvbW1hbmQsIHRhcmdldC5nZXRBdHRyaWJ1dGUoJ2RhdGEtb3B0aW9uJyksIGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9mZigpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9mZigpO1xyXG5cclxuICAgICAgICAgICAgLyoqIGRlZmF1bHQgY29tbWFuZCAqL1xyXG4gICAgICAgICAgICBpZiAoY29tbWFuZCkge1xyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmZvY3VzKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgc3dpdGNoIChjb21tYW5kKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnY29kZVZpZXcnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudG9nZ2xlQ29kZVZpZXcoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdmdWxsU2NyZWVuJzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnRvZ2dsZUZ1bGxTY3JlZW4odGFyZ2V0KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdpbmRlbnQnOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ291dGRlbnQnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaW5kZW50KGVkaXRvci5fdmFyaWFibGUuc2VsZWN0aW9uTm9kZSwgY29tbWFuZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3JlZG8nOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3VuZG8nOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3JlbW92ZUZvcm1hdCc6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5leGVjQ29tbWFuZChjb21tYW5kLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3ByZXZpZXcnOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3ByaW50JzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9wZW5XaW5kb3dDb250ZW50cyhjb21tYW5kKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnc2hvd0Jsb2Nrcyc6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50b2dnbGVEaXNwbGF5QmxvY2tzKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3ModGFyZ2V0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnc3Vic2NyaXB0JzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHV0aWwuaGFzQ2xhc3MoY29udGV4dC50b29sLnN1cGVyc2NyaXB0LCAnb24nKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmV4ZWNDb21tYW5kKCdzdXBlcnNjcmlwdCcsIGZhbHNlLCBudWxsKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3MoY29udGV4dC50b29sLnN1cGVyc2NyaXB0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZXhlY0NvbW1hbmQoY29tbWFuZCwgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKHRhcmdldCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3N1cGVyc2NyaXB0JzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHV0aWwuaGFzQ2xhc3MoY29udGV4dC50b29sLnN1YnNjcmlwdCwgJ29uJykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5leGVjQ29tbWFuZCgnc3Vic2NyaXB0JywgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVDbGFzcyhjb250ZXh0LnRvb2wuc3Vic2NyaXB0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZXhlY0NvbW1hbmQoY29tbWFuZCwgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKHRhcmdldCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHQgOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZXhlY0NvbW1hbmQoY29tbWFuZCwgZmFsc2UsIHRhcmdldC5nZXRBdHRyaWJ1dGUoJ2RhdGEtdmFsdWUnKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3ModGFyZ2V0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIG9uTW91c2VVcF93eXNpd3lnOiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgdGFyZ2V0RWxlbWVudCA9IGUudGFyZ2V0O1xyXG4gICAgICAgICAgICBlZGl0b3Iuc3VibWVudU9mZigpO1xyXG5cclxuICAgICAgICAgICAgaWYgKC9eSFRNTCQvaS50ZXN0KHRhcmdldEVsZW1lbnQubm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuZm9jdXMoKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKC9eSU1HJC9pLnRlc3QodGFyZ2V0RWxlbWVudC5ub2RlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIGVkaXRvci5jYWxsUGx1Z2luKCdpbWFnZScsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplID0gZWRpdG9yLnBsdWdpbnMuZGlhbG9nLmNhbGxfY29udHJvbGxlcl9yZXNpemUuY2FsbChlZGl0b3IsIHRhcmdldEVsZW1lbnQsICdpbWFnZScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmltYWdlLm9uTW9kaWZ5TW9kZS5jYWxsKGVkaXRvciwgdGFyZ2V0RWxlbWVudCwgc2l6ZSk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZWRpdG9yLl9zZXRFZGl0b3JSYW5nZSgpO1xyXG4gICAgICAgICAgICBldmVudC5fZmluZEJ1dHRvbkVmZmVjdFRhZygpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIG9uS2V5RG93bl93eXNpd3lnOiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICAvLyBlZGl0b3IuX3NldFNlbGVjdGlvbk5vZGUoKTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGtleUNvZGUgPSBlLmtleUNvZGU7XHJcbiAgICAgICAgICAgIGNvbnN0IHNoaWZ0ID0gZS5zaGlmdEtleTtcclxuICAgICAgICAgICAgY29uc3QgY3RybCA9IGUuY3RybEtleSB8fCBlLm1ldGFLZXk7XHJcbiAgICAgICAgICAgIGNvbnN0IGFsdCA9IGUuYWx0S2V5O1xyXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG5cclxuICAgICAgICAgICAgZnVuY3Rpb24gc2hvcnRjdXRDb21tYW5kKGtleUNvZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGV2ZW50Ll9zaG9ydGN1dEtleUNvZGVba2V5Q29kZV07XHJcbiAgICAgICAgICAgICAgICBpZiAoIWtleSkgcmV0dXJuIGZhbHNlO1xyXG5cclxuICAgICAgICAgICAgICAgIGVkaXRvci5leGVjQ29tbWFuZChrZXlbMF0sIGZhbHNlLCBudWxsKTtcclxuICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3MoZWRpdG9yLmNvbW1hbmRNYXBba2V5WzFdXSwgJ29uJyk7XHJcblxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiBTaG9ydGN1dHMgKi9cclxuICAgICAgICAgICAgaWYgKGN0cmwgJiYgIS9eKD86MTZ8MTd8MTgpJC8udGVzdChrZXlDb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKCEoc2hpZnQgJiYga2V5Q29kZSAhPT0gODMpICYmIHNob3J0Y3V0Q29tbWFuZChrZXlDb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiBkZWZhdWx0IGtleSBhY3Rpb24gKi9cclxuICAgICAgICAgICAgc3dpdGNoIChrZXlDb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjYXNlIDg6IC8qKmJhY2tzcGFjZSBrZXkqL1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICh1dGlsLmlzRm9ybWF0RWxlbWVudChlZGl0b3IuX3ZhcmlhYmxlLnNlbGVjdGlvbk5vZGUpICYmIGVkaXRvci5fdmFyaWFibGUuc2VsZWN0aW9uTm9kZS5wcmV2aW91c1NpYmxpbmcgPT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuX3ZhcmlhYmxlLnNlbGVjdGlvbk5vZGUuaW5uZXJIVE1MID0gJyYjNjUyNzknO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSA5OlxyXG4gICAgICAgICAgICAgICAgICAgIC8qKnRhYiBrZXkqL1xyXG4gICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoY3RybCB8fCBhbHQpIGJyZWFrO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VycmVudE5vZGUgPSBlZGl0b3IuX3ZhcmlhYmxlLnNlbGVjdGlvbk5vZGUgfHwgZWRpdG9yLmdldFNlbGVjdGlvbk5vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICB3aGlsZSAoIS9eVEQkL2kudGVzdChjdXJyZW50Tm9kZS50YWdOYW1lKSAmJiAhdXRpbC5pc1d5c2l3eWdEaXYoY3VycmVudE5vZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnROb2RlID0gY3VycmVudE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50Tm9kZSAmJiAvXlREJC9pLnRlc3QoY3VycmVudE5vZGUudGFnTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFibGUgPSB1dGlsLmdldFBhcmVudEVsZW1lbnQoY3VycmVudE5vZGUsICd0YWJsZScpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjZWxscyA9IHV0aWwuZ2V0TGlzdENoaWxkcmVuKHRhYmxlLCB1dGlsLmlzQ2VsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpZHggPSBzaGlmdCA/IHV0aWwucHJldklkeChjZWxscywgY3VycmVudE5vZGUpIDogdXRpbC5uZXh0SWR4KGNlbGxzLCBjdXJyZW50Tm9kZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaWR4ID09PSBjZWxscy5sZW5ndGggJiYgIXNoaWZ0KSBpZHggPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaWR4ID09PSAtMSAmJiBzaGlmdCkgaWR4ID0gY2VsbHMubGVuZ3RoIC0gMTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1vdmVDZWxsID0gY2VsbHNbaWR4XTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtb3ZlQ2VsbCkgcmV0dXJuIGZhbHNlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFJhbmdlKG1vdmVDZWxsLCAwLCBtb3ZlQ2VsbCwgMClcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLyoqIGlmIFAgVGFnICovXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNoaWZ0KSBicmVhaztcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFiVGV4dCA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKG5ldyBBcnJheShlZGl0b3IuX3ZhcmlhYmxlLnRhYlNpemUgKyAxKS5qb2luKCdcXHUwMEEwJykpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5pbnNlcnROb2RlKHRhYlRleHQpO1xyXG4gICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRSYW5nZSh0YWJUZXh0LCBlZGl0b3IuX3ZhcmlhYmxlLnRhYlNpemUsIHRhYlRleHQsIGVkaXRvci5fdmFyaWFibGUudGFiU2l6ZSlcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBvbktleVVwX3d5c2l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGVkaXRvci5fc2V0RWRpdG9yUmFuZ2UoKTtcclxuXHJcbiAgICAgICAgICAgIC8qKiB3aGVuIGZvcm1hdCB0YWcgZGVsZXRlZCAqL1xyXG4gICAgICAgICAgICBpZiAoZS5rZXlDb2RlID09PSA4ICYmIHV0aWwuaXNXeXNpd3lnRGl2KGVkaXRvci5fdmFyaWFibGUuc2VsZWN0aW9uTm9kZSkpIHtcclxuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3Qgb0Zvcm1hdFRhZyA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoZWRpdG9yLl92YXJpYWJsZS5jdXJyZW50Tm9kZXNbMF0pO1xyXG4gICAgICAg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Ck7XHJcblxyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oJ2ltYWdlJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRleHQuaW1hZ2UuaW1nSW5wdXRGaWxlLmZpbGVzID0gZmlsZXM7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnMuaW1hZ2Uub25SZW5kZXJfaW1nSW5wdXQuY2FsbChlZGl0b3IpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRleHQuaW1hZ2UuaW1nSW5wdXRGaWxlLmZpbGVzID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgb25Nb3VzZURvd25fcmVzaXplQmFyOiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG5cclxuICAgICAgICAgICAgZWRpdG9yLl92YXJpYWJsZS5yZXNpemVDbGllbnRZID0gZS5jbGllbnRZO1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQucmVzaXplQmFja2dyb3VuZC5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJztcclxuXHJcbiAgICAgICAgICAgIGZ1bmN0aW9uIGNsb3N1cmVGdW5jKCkge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LnJlc2l6ZUJhY2tncm91bmQuc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICAgICAgICAgIGRvY3VtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ21vdXNlbW92ZScsIGV2ZW50LnJlc2l6ZV9lZGl0b3IpO1xyXG4gICAgICAgICAgICAgICAgZG9jdW1lbnQucmVtb3ZlRXZlbnRMaXN0ZW5lcignbW91c2V1cCcsIGNsb3N1cmVGdW5jKTtcclxuICAgICAgICAgICAgfVxyXG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BPYmplY3QudmFsdWVzKHBsdWdpbnMpO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBwbHVnaW5zVmFsdWVzLmxlbmd0aCwgcGx1Z2luOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgcGx1Z2luID0gcGx1Z2luc1ZhbHVlc1tpXTtcclxuICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnNbcGx1Z2luLm5hbWVdID0gdXRpbC5jb3B5T2JqKHBsdWdpbik7XHJcbiAgICAgICAgfVxyXG4gICAgICAgICBwbHVnaW5zVmFsdWVzID0gbnVsbDtcclxuICAgIH1cclxuXHJcbiAgICAvKiogVXNlciBmdW5jdGlvbiAqL1xyXG4gICAgcmV0dXJuIHtcclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQ29weWluZyB0aGUgY29udGVudHMgb2YgdGhlIGVkaXRvciB0byB0aGUgb3JpZ2luYWwgdGV4dGFyZWFcclxuICAgICAgICAgKi9cclxuICAgICAgICBzYXZlOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGlmIChlZGl0b3IuX3ZhcmlhYmxlLnd5c2l3eWdBY3RpdmUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC5vcmlnaW5FbGVtZW50LnZhbHVlID0gY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lm9yaWdpbkVsZW1lbnQudmFsdWUgPSBjb250ZXh0LmVsZW1lbnQuY29kZS52YWx1ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBHZXRzIHRoZSBzdW5lZGl0b3IncyBjb250ZXh0IG9iamVjdC4gQ29udGFpbnMgc2V0dGluZ3MsIHBsdWdpbnMsIGFuZCBjYWNoZWQgZWxlbWVudCBvYmplY3RzXHJcbiAgICAgICAgICogQHJldHVybnMge09iamVjdH1cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRDb250ZXh0OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBjb250ZXh0O1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBHZXRzIHRoZSBjb250ZW50cyBvZiB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICogQHJldHVybnMge1N0cmluZ31cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRDb250ZW50OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGxldCBjb250ZW50ID0gJyc7XHJcblxyXG4gICAgICAgICAgICBpZiAoY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJUZXh0LnRyaW0oKS5sZW5ndGggPT09IDApIHJldHVybiBjb250ZW50O1xyXG5cclxuICAgICAgICAgICAgaWYgKGVkaXRvci5fdmFyaWFibGUud3lzaXd5Z0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgY29udGVudCA9IGNvbnRleHQuZWxlbWVudC53eXNpd3lnLmlubmVySFRNTDtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGNvbnRlbnQgPSBjb250ZXh0LmVsZW1lbnQuY29kZS52YWx1ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gY29udGVudDtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQ2hhbmdlIHRoZSBjb250ZW50cyBvZiB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICogQHBhcmFtIHtTdHJpbmd9IGNvbnRlbnQgLSBDb250ZW50IHRvIElucHV0XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgc2V0Q29udGVudDogZnVuY3Rpb24gKGNvbnRlbnQpIHtcclxuICAgICAgICAgICAgY29uc3QgaW5uZXJIVE1MID0gdXRpbC5jb252ZXJ0Q29udGVudEZvckVkaXRvcihjb250ZW50KTtcclxuXHJcbiAgICAgICAgICAgIGlmIChlZGl0b3IuX3ZhcmlhYmxlLnd5c2l3eWdBY3RpdmUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC53eXNpd3lnLmlubmVySFRNTCA9IGlubmVySFRNTDtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC5jb2RlLnZhbHVlID0gaW5uZXJIVE1MO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEFkZCBjb250ZW50IHRvIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKiBAcGFyYW0ge1N0cmluZ30gY29udGVudCAtIHRvIElucHV0XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgYXBwZW5kQ29udGVudDogZnVuY3Rpb24gKGNvbnRlbnQpIHtcclxuICAgICAgICAgICAgaWYgKGVkaXRvci5fdmFyaWFibGUud3lzaXd5Z0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgb1AgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdQJyk7XHJcbiAgICAgICAgICAgICAgICBvUC5pbm5lckhUTUwgPSBjb250ZW50O1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuYXBwZW5kQ2hpbGQob1ApO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LmNvZGUudmFsdWUgKz0gb1Aub3V0ZXJIVE1MO1xyXG4gICAgICAgICAgICB9XHJc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ub25lJykgdG9wQXJlYVN0eWxlLmRpc3BsYXkgPSAnYmxvY2snO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBIaWRlIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKi9cclxuICAgICAgICBoaWRlOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLmRpc3BsYXkgPSAnbm9uZSc7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIERlc3Ryb3kgdGhlIHN1bmVkaXRvclxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGRlc3Ryb3k6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgLyoqIHJlbW92ZSB3aW5kb3cgZXZlbnQgbGlzdGVuZXJzICovXHJcbiAgICAgICAgICAgIHdpbmRvdy5yZW1vdmVFdmVudExpc3RlbmVyKCdyZXNpemUnLCBldmVudC5yZXNpemVfd2luZG93KTtcclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgIC8qKiByZW1vdmUgZWxlbWVudCAqL1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5wYXJlbnROb2RlLnJlbW92ZUNoaWxkKGNvbnRleHQuZWxlbWVudC50b3BBcmVhKTtcclxuXHJcbiAgICAgICAgICAgIHRoaXMuc2F2ZSA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuZ2V0Q29udGV4dCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuZ2V0Q29udGVudCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuc2V0Q29udGVudCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuYXBwZW5kQ29udGVudCA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMuZGlzYWJsZ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DQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQXJIQTtBQXVIQTtBQUNBO0FBQ0EiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./src/lib/core.js\n"); +eval("__webpack_require__.r(__webpack_exports__);\n\n/**\r\n * @description SunEditor core closure\r\n * @param context\r\n * @param util\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, util, plugins, lang) {\n /**\r\n * @description Practical editor function\r\n * This function is 'this' used by other plugins\r\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 util function\r\n */\n util: util,\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 controllers array (image resize area, link modified button)\r\n */\n controllerArray: [],\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 {Element} originCssText - Remembered the CSS of the editor before full screen (Used when returning to original size again)\r\n * @property {Number} editorHeight - The height value entered by the user or the height value of the \"textarea\" when the suneditor is created\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 originCssText: context.element.topArea.style.cssText,\n editorHeight: context.user.height,\n currentNodes: []\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.callModule.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 {Object} moduleObj - module object (dialog)\r\n */\n _addModule: function (moduleObj) {\n const moduleName = moduleObj.name;\n\n if (!this.plugins[moduleName]) {\n this.plugins[moduleName] = this.util.copyObj(moduleObj);\n this.plugins[moduleName].add(this);\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 this.submenu = element.nextElementSibling;\n this.submenu.style.display = 'block';\n util.addClass(element, 'on');\n this.submenuActiveButton = element;\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.removeClass(this.submenuActiveButton, 'on');\n this.submenuActiveButton = null;\n }\n\n if (context.image && context.image._onCaption === true) {\n this.plugins.image.toggle_caption_contenteditable.call(editor, false);\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\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\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 document.execCommand(command, showDefaultUI, 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.getParentElement(this._variable.selectionNode, '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 = window.getSelection();\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._variable.selectionNode = range.commonAncestorContainer;\n } else {\n this._variable.selectionNode = 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 = document.createRange();\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 = document.createRange();\n range.setStart(startCon, startOff);\n range.setEnd(endCon, endOff);\n const selection = window.getSelection();\n\n if (selection.rangeCount > 0) {\n selection.removeAllRanges();\n }\n\n this._variable.range = range;\n selection.addRange(range);\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 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 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 P tag to current line next\r\n * @param {Element} element - Insert as siblings of that element\r\n * @returns {Element}\r\n */\n appendP: function (element) {\n const oP = document.createElement('P');\n oP.innerHTML = '';\n element = util.getFormatElement(element);\n element.parentNode.insertBefore(oP, element.nextElementSibling);\n return oP;\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 /** Select within the same node */\n\n\n if (range.collapsed) {\n if (commonCon.nodeType === 3) {\n rightNode = commonCon.splitText(endOff);\n } else {\n if (parentNode.lastChild !== null && /^BR$/i.test(parentNode.lastChild.nodeName)) {\n parentNode.removeChild(parentNode.lastChild);\n }\n\n rightNode = null;\n }\n }\n /** Select multiple nodes */\n else {\n const isSameContainer = startCon === endCon;\n\n if (isSameContainer) {\n let removeNode = startCon;\n if (!this.isEdgePoint(endCon, endOff)) rightNode = endCon.splitText(endOff);\n if (!this.isEdgePoint(startCon, startOff)) removeNode = startCon.splitText(startOff);\n parentNode.removeChild(removeNode);\n } else {\n this.removeNode();\n rightNode = endCon;\n\n while (rightNode.nodeType !== 1) {\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 } // this.setRange(oNode, 0, oNode, 0);\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.getListChildNodes(commonCon);\n let startIndex = util.getArrayIndex(childNodes, startCon);\n let endIndex = util.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.removeItem(item);\n continue;\n }\n\n if (item === startCon) {\n if (startCon.nodeType === 1) {\n beforeNode = document.createTextNode(startCon.textContent);\n } else {\n beforeNode = document.createTextNode(startCon.substringData(0, startOff));\n }\n\n if (beforeNode.length > 0) {\n startCon.data = beforeNode.data;\n } else {\n util.removeItem(startCon);\n }\n\n continue;\n }\n\n if (item === endCon) {\n if (endCon.nodeType === 1) {\n afterNode = document.createTextNode(endCon.textContent);\n } else {\n afterNode = document.createTextNode(endCon.substringData(endOff, endCon.length - endOff));\n }\n\n if (afterNode.length > 0) {\n endCon.data = afterNode.data;\n } else {\n util.removeItem(endCon);\n }\n\n continue;\n }\n\n util.removeItem(item);\n }\n },\n\n /**\r\n * @description Copies the node of the argument value and wraps all selected text.\r\n * 1. When there is the same 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 same node, removed only Css attribute values received as arguments\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']...])\r\n */\n wrapRangeToTag: function (appendNode, checkCSSPropertyArray) {\n const range = this.getRange();\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 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, 'gi');\n }\n /** one node */\n\n\n if (startCon === endCon) {\n newNode = appendNode.cloneNode(false);\n /** No node selected */\n\n if (startOff === endOff) {\n newNode.innerHTML = '';\n\n if (util.isFormatElement(startCon)) {\n startCon.appendChild(newNode);\n } else {\n startCon.splitText(startOff);\n startCon.parentNode.insertBefore(newNode, startCon.nextSibling);\n }\n }\n /** Select within the same node */\n else {\n const isElement = startCon.nodeType === 1;\n\n if (isElement) {\n newNode.innerHTML = startCon.outerHTML;\n startCon.parentNode.appendChild(newNode);\n util.removeItem(startCon);\n } else {\n const beforeNode = document.createTextNode(startCon.substringData(0, startOff));\n const afterNode = document.createTextNode(startCon.substringData(endOff, startCon.length - endOff));\n newNode.innerText = startCon.substringData(startOff, endOff - startOff);\n startCon.parentNode.insertBefore(newNode, startCon.nextSibling);\n\n if (beforeNode.data.length > 0) {\n startCon.data = beforeNode.data;\n } else {\n startCon.data = startCon.substringData(0, startOff);\n }\n\n if (afterNode.data.length > 0) {\n startCon.parentNode.insertBefore(afterNode, newNode.nextSibling);\n }\n }\n }\n\n start.container = newNode;\n start.offset = 1;\n end.container = newNode;\n end.offset = 1;\n }\n /** multiple nodes */\n else {\n /** tag check function*/\n const checkCss = function (vNode) {\n if (vNode.nodeType === 3) 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 (vNode.nodeName !== appendNode.nodeName || style.length > 0) {\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.hasClass(commonCon, 'sun-editor-id-wysiwyg')) {\n newNode = appendNode.cloneNode(false);\n\n const newRange = this._wrapLineNodesPart(commonCon, newNode, checkCss, startCon, startOff, endCon, endOff);\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 = util.getListChildren(commonCon, function (current) {\n return util.isFormatElement(current);\n });\n let startLine = util.getParentElement(startCon, 'P');\n let endLine = util.getParentElement(endCon, 'P');\n\n for (let i = 0, len = lineNodes.length; i < len; i++) {\n if (startLine === lineNodes[i]) {\n startLine = i;\n continue;\n }\n\n if (endLine === lineNodes[i]) {\n endLine = i;\n break;\n }\n } // startCon\n\n\n newNode = appendNode.cloneNode(false);\n start = this._wrapLineNodesStart(lineNodes[startLine], newNode, checkCss, startCon, startOff); // mid\n\n for (let i = startLine + 1; i < endLine; i++) {\n newNode = appendNode.cloneNode(false);\n\n this._wrapLineNodes(lineNodes[i], newNode, checkCss);\n } // endCon\n\n\n newNode = appendNode.cloneNode(false);\n end = this._wrapLineNodesEnd(lineNodes[endLine], newNode, checkCss, endCon, endOff);\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 * @returns {{startContainer: *, startOffset: *, endContainer: *, endOffset: *}}\r\n * @private\r\n */\n _wrapLineNodesPart: function (element, newInnerNode, validation, startCon, startOff, endCon, endOff) {\n const el = element;\n const removeNodeList = [];\n let startContainer = startCon;\n let startOffset = startOff;\n let endContainer = endCon;\n let endOffset = endOff;\n let prevNode, afterNode;\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\n if (validation(child)) {\n let cloneNode;\n\n if (child === startContainer) {\n prevNode = document.createTextNode(startContainer.substringData(0, startOffset));\n child = document.createTextNode(startContainer.substringData(startOffset, startContainer.length - startOffset));\n startOffset = 0;\n startContainer = cloneNode = child.cloneNode(false);\n } else if (child === endContainer) {\n afterNode = document.createTextNode(endContainer.substringData(endOffset, endContainer.length - endOffset));\n child = document.createTextNode(endContainer.substringData(0, endOffset));\n endOffset = child.length;\n endContainer = cloneNode = child.cloneNode(false);\n } else {\n cloneNode = child.cloneNode(false);\n }\n\n removeNodeList.push(child);\n node.appendChild(cloneNode);\n if (child.nodeType === 1) coverNode = cloneNode;\n }\n\n recursionFunc(child, coverNode);\n }\n })(el, newInnerNode);\n\n el.innerHTML = '';\n el.appendChild(prevNode);\n el.appendChild(newInnerNode);\n el.appendChild(afterNode);\n return {\n startContainer: startContainer,\n startOffset: startOffset,\n endContainer: endContainer,\n endOffset: 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 * @private\r\n */\n _wrapLineNodes: function (element, newInnerNode, validation) {\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) coverNode = cloneNode;\n }\n\n recursionFunc(child, coverNode);\n }\n })(element, newInnerNode);\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 * @returns {{container: *, offset: *}}\r\n * @private\r\n */\n _wrapLineNodesStart: function (element, newInnerNode, validation, startCon, startOff) {\n const el = element;\n const pNode = document.createElement('P');\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) {\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 appendNode = newNode = pCurrent.pop();\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n }\n\n newInnerNode.appendChild(appendNode);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n } // startContainer\n\n\n if (!passNode && child === container) {\n const prevNode = document.createTextNode(container.substringData(0, offset));\n const textNode = document.createTextNode(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 (validation(newNode) && newNode.nodeType === 1) {\n pCurrent.push(newNode.cloneNode(false));\n }\n\n newNode = newNode.parentNode;\n }\n\n appendNode = newNode = pCurrent.pop() || node;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.appendChild(newNode);\n }\n\n if (appendNode !== node) {\n newInnerNode.appendChild(appendNode);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n\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) coverNode = cloneNode;\n }\n\n recursionFunc(child, coverNode);\n }\n })(element, pNode);\n\n element.parentNode.insertBefore(pNode, element);\n util.removeItem(element);\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 * @returns {{container: *, offset: *}}\r\n * @private\r\n */\n _wrapLineNodesEnd: function (element, newInnerNode, validation, endCon, endOff) {\n const el = element;\n const pNode = document.createElement('P');\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) {\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 appendNode = newNode = pCurrent.pop();\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.insertBefore(newNode, appendNode.firstChild);\n }\n\n newInnerNode.insertBefore(appendNode, newInnerNode.firstChild);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n } // endContainer\n\n\n if (!passNode && child === container) {\n const afterNode = document.createTextNode(container.substringData(offset, container.length - offset));\n const textNode = document.createTextNode(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 appendNode = newNode = pCurrent.pop() || node;\n\n while (pCurrent.length > 0) {\n newNode = pCurrent.pop();\n appendNode.insertBefore(newNode, appendNode.firstChild);\n }\n\n if (appendNode !== node) {\n newInnerNode.insertBefore(appendNode, newInnerNode.firstChild);\n node = newNode;\n } else {\n node = newInnerNode;\n }\n\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) coverNode = cloneNode;\n }\n\n recursionFunc(child, coverNode);\n }\n })(element, pNode);\n\n element.parentNode.insertBefore(pNode, element);\n util.removeItem(element);\n return {\n container: container,\n offset: offset\n };\n },\n\n /**\r\n * @description This function implements indentation.\r\n * Set \"margin-left\" to \"25px\" in the top \"P\" tag of the parameter node.\r\n * @param element {Element} - The element to indent (editor.getSelectionNode())\r\n * @param command {String} - Separator (\"indent\" or \"outdent\")\r\n */\n indent: function (element, command) {\n const p = util.getParentElement(element, 'P');\n if (!p) return;\n let 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 /**\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.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 if (!this._variable.wysiwygActive) {\n const ec = {\n '&': '&',\n ' ': '\\u00A0',\n \""\": \"'\",\n '<': '<',\n '>': '>'\n };\n const code_html = context.element.code.value.replace(/&[a-z]+;/g, function (m) {\n return typeof ec[m] === 'string' ? ec[m] : m;\n });\n context.element.wysiwyg.innerHTML = code_html.trim().length > 0 ? code_html : '



';\n context.element.wysiwyg.scrollTop = 0;\n context.element.code.style.display = 'none';\n context.element.wysiwyg.style.display = 'block';\n this._variable.wysiwygActive = true;\n } else {\n context.element.code.value = context.element.wysiwyg.innerHTML.trim().replace(/<\\/p>(?=[^\\n])/gi, '<\\/p>\\n');\n context.element.wysiwyg.style.display = 'none';\n context.element.code.style.display = 'block';\n this._variable.wysiwygActive = false;\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 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.innerHeight_fullScreen = window.innerHeight - context.tool.bar.offsetHeight;\n context.element.editorArea.style.height = this._variable.innerHeight_fullScreen + 'px';\n util.removeClass(element.firstElementChild, 'icon-expansion');\n util.addClass(element.firstElementChild, 'icon-reduction');\n } else {\n context.element.topArea.style.cssText = this._variable.originCssText;\n context.element.editorArea.style.height = this._variable.editorHeight + 'px';\n util.removeClass(element.firstElementChild, 'icon-reduction');\n util.addClass(element.firstElementChild, 'icon-expansion');\n }\n\n this._variable.isFullScreen = !this._variable.isFullScreen;\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 const windowObject = window.open('', '_blank');\n windowObject.mimeType = 'text/html';\n windowObject.document.write('' + '' + '' + '' + '' + '' + (isPrint ? lang.toolbar.print : lang.toolbar.preview) + '' + '' + '' + '' + context.element.wysiwyg.innerHTML + '' + '' + (isPrint ? '' : '') + '');\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._variable.selectionNode; !util.isWysiwygDiv(selectionParent); selectionParent = selectionParent.parentNode) {\n if (selectionParent.nodeType !== 1) continue;\n nodeName = selectionParent.nodeName.toUpperCase();\n currentNodes.push(nodeName);\n /** Format */\n\n if (findFormat && util.isFormatElement(selectionParent)) {\n commandMapNodes.push('FORMAT');\n util.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.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.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.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.changeTxt(commandMap[key], lang.toolbar.font);\n } else if (/^SIZE$/i.test(key)) {\n util.changeTxt(commandMap[key], lang.toolbar.fontSize);\n } else {\n util.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 resizebar */\n\n if (context.user.showPathLabel) context.element.navigation.textContent = editor._variable.currentNodes.join(' > ');\n },\n resize_window: function () {\n if (editor._variable.isFullScreen) {\n editor._variable.innerHeight_fullScreen += window.innerHeight - context.tool.bar.offsetHeight - editor._variable.innerHeight_fullScreen;\n context.element.editorArea.style.height = editor._variable.innerHeight_fullScreen + 'px';\n }\n },\n onMouseDown_toolbar: function (e) {\n e.preventDefault();\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 /** 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.openDialog.call(editor, command, target.getAttribute('data-option'), 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\n switch (command) {\n case 'codeView':\n editor.toggleCodeView();\n util.toggleClass(target, 'on');\n break;\n\n case 'fullScreen':\n editor.toggleFullScreen(target);\n util.toggleClass(target, 'on');\n break;\n\n case 'indent':\n case 'outdent':\n editor.indent(editor._variable.selectionNode, command);\n break;\n\n case 'redo':\n case 'undo':\n case 'removeFormat':\n editor.execCommand(command, false, null);\n break;\n\n case 'preview':\n case 'print':\n editor.openWindowContents(command);\n break;\n\n case 'showBlocks':\n editor.toggleDisplayBlocks();\n util.toggleClass(target, 'on');\n break;\n\n case 'subscript':\n if (util.hasClass(context.tool.superscript, 'on')) {\n editor.execCommand('superscript', false, null);\n util.removeClass(context.tool.superscript, 'on');\n }\n\n editor.execCommand(command, false, null);\n util.toggleClass(target, 'on');\n break;\n\n case 'superscript':\n if (util.hasClass(context.tool.subscript, 'on')) {\n editor.execCommand('subscript', false, null);\n util.removeClass(context.tool.subscript, 'on');\n }\n\n editor.execCommand(command, false, null);\n util.toggleClass(target, 'on');\n break;\n\n default:\n editor.execCommand(command, false, target.getAttribute('data-value'));\n util.toggleClass(target, 'on');\n }\n }\n },\n onMouseUp_wysiwyg: function (e) {\n e.stopPropagation();\n const targetElement = e.target;\n editor.submenuOff();\n\n if (/^HTML$/i.test(targetElement.nodeName)) {\n e.preventDefault();\n editor.focus();\n return;\n }\n\n if (/^IMG$/i.test(targetElement.nodeName)) {\n e.preventDefault();\n editor.callPlugin('image', function () {\n const size = editor.plugins.dialog.call_controller_resize.call(editor, targetElement, 'image');\n editor.plugins.image.onModifyMode.call(editor, targetElement, size);\n });\n return;\n }\n\n editor._setEditorRange();\n\n event._findButtonEffectTag();\n },\n onKeyDown_wysiwyg: function (e) {\n // editor._setSelectionNode();\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 function shortcutCommand(keyCode) {\n const key = event._shortcutKeyCode[keyCode];\n if (!key) return false;\n editor.execCommand(key[0], false, null);\n util.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 switch (keyCode) {\n case 8:\n /**backspace key*/\n if (util.isFormatElement(editor._variable.selectionNode) && editor._variable.selectionNode.previousSibling === null) {\n e.preventDefault();\n e.stopPropagation();\n editor._variable.selectionNode.innerHTML = '';\n return false;\n }\n\n break;\n\n case 9:\n /**tab key*/\n e.preventDefault();\n if (ctrl || alt) break;\n let currentNode = editor._variable.selectionNode || editor.getSelectionNode();\n\n while (!/^TD$/i.test(currentNode.tagName) && !util.isWysiwygDiv(currentNode)) {\n currentNode = currentNode.parentNode;\n }\n\n if (currentNode && /^TD$/i.test(currentNode.tagName)) {\n const table = util.getParentElement(currentNode, 'table');\n const cells = util.getListChildren(table, util.isCell);\n let idx = shift ? util.prevIdx(cells, currentNode) : util.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 /** if P Tag */\n\n\n if (shift) break;\n const tabText = document.createTextNode(new Array(editor._variable.tabSize + 1).join('\\u00A0'));\n editor.insertNode(tabText);\n editor.setRange(tabText, editor._variable.tabSize, tabText, editor._variable.tabSize);\n break;\n }\n },\n onKeyUp_wysiwyg: function (e) {\n editor._setEditorRange();\n /** when format tag deleted */\n\n\n if (e.keyCode === 8 && util.isWysiwygDiv(editor._variable.selectionNode)) {\n e.preventDefault();\n e.stopPropagation();\n const oFormatTag = document.createElement(editor._variable.currentNodes[0]);\n oFormatTag.innerHTML = '';\n\n editor._variable.selectionNode.appendChild(oFormatTag);\n\n editor._variable.selectionNode = oFormatTag;\n editor.setRange(oFormatTag, 0, oFormatTag, 0);\n }\n\n if (event._directionKeyKeyCode.test(e.keyCode)) {\n event._findButtonEffectTag();\n }\n },\n onScroll_wysiwyg: function () {\n editor.controllersOff();\n },\n onDrop_wysiwyg: function (e) {\n const files = e.dataTransfer.files;\n if (files.length === 0) return true;\n e.stopPropagation();\n e.preventDefault();\n\n if (editor.plugins.image) {\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 onMouseDown_resizeBar: 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 document.removeEventListener('mousemove', event.resize_editor);\n document.removeEventListener('mouseup', closureFunc);\n }\n\n document.addEventListener('mousemove', event.resize_editor);\n document.addEventListener('mouseup', closureFunc);\n },\n resize_editor: function (e) {\n const resizeInterval = e.clientY - editor._variable.resizeClientY;\n context.element.editorArea.style.height = context.element.editorArea.offsetHeight + resizeInterval + 'px';\n editor._variable.editorHeight = context.element.editorArea.offsetHeight + resizeInterval;\n editor._variable.resizeClientY = e.clientY;\n }\n };\n /** add event listeners */\n\n /** tool bar event */\n\n context.tool.bar.addEventListener('click', event.onClick_toolbar, false);\n context.tool.bar.addEventListener('mousedown', event.onMouseDown_toolbar, false);\n /** editor area */\n\n context.element.wysiwyg.addEventListener('scroll', event.onScroll_wysiwyg, false);\n context.element.wysiwyg.addEventListener('mouseup', event.onMouseUp_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 /** resize bar */\n\n context.element.resizebar.addEventListener('mousedown', event.onMouseDown_resizeBar, false);\n /** window resize event */\n\n window.addEventListener('resize', event.resize_window, false);\n /** add plugin to plugins object */\n\n if (plugins) {\n let pluginsValues = Object.values(plugins);\n\n for (let i = 0, len = pluginsValues.length, plugin; i < len; i++) {\n plugin = pluginsValues[i];\n editor.plugins[plugin.name] = util.copyObj(plugin);\n }\n\n pluginsValues = null;\n }\n /** User function */\n\n\n return {\n /**\r\n * @description Copying the contents of the editor to the original textarea\r\n */\n save: function () {\n if (editor._variable.wysiwygActive) {\n context.element.originElement.value = context.element.wysiwyg.innerHTML;\n } else {\n context.element.originElement.value = context.element.code.value;\n }\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 getContent: function () {\n let content = '';\n if (context.element.wysiwyg.innerText.trim().length === 0) return content;\n\n if (editor._variable.wysiwygActive) {\n content = context.element.wysiwyg.innerHTML;\n } else {\n content = context.element.code.value;\n }\n\n return content;\n },\n\n /**\r\n * @description Change the contents of the suneditor\r\n * @param {String} content - Content to Input\r\n */\n setContent: function (content) {\n const innerHTML = util.convertContentForEditor(content);\n\n if (editor._variable.wysiwygActive) {\n context.element.wysiwyg.innerHTML = innerHTML;\n } else {\n context.element.code.value = innerHTML;\n }\n },\n\n /**\r\n * @description Add content to the suneditor\r\n * @param {String} content - to Input\r\n */\n appendContent: function (content) {\n if (editor._variable.wysiwygActive) {\n const oP = document.createElement('P');\n oP.innerHTML = content;\n context.element.wysiwyg.appendChild(oP);\n } else {\n context.element.code.value += oP.outerHTML;\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 },\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 },\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.user.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 window.removeEventListener('resize', event.resize_window);\n /** remove element */\n\n context.element.topArea.parentNode.removeChild(context.element.topArea);\n this.save = null;\n this.getContext = null;\n this.getContent = null;\n this.setContent = null;\n this.appendContent = null;\n this.disabled = null;\n this.enabled = null;\n this.show = null;\n this.hide = null;\n this.destroy = null;\n }\n };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (core);//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvbGliL2NvcmUuanMuanMiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9zcmMvbGliL2NvcmUuanM/OGE4ZCJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XHJcblxyXG4vKipcclxuICogQGRlc2NyaXB0aW9uIFN1bkVkaXRvciBjb3JlIGNsb3N1cmVcclxuICogQHBhcmFtIGNvbnRleHRcclxuICogQHBhcmFtIHV0aWxcclx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ICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gdXRpbCBmdW5jdGlvblxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIHV0aWw6IHV0aWwsXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBsb2FkZWQgbGFuZ3VhZ2VcclxuICAgICAgICAgKi9cclxuICAgICAgICBsYW5nOiBsYW5nLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gZGlhbG9nIGVsZW1lbnRcclxuICAgICAgICAgKi9cclxuICAgICAgICBkaWFsb2dGb3JtOiBudWxsLFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gc3VibWVudSBlbGVtZW50XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgc3VibWVudTogbnVsbCxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIGFjdGl2ZSBidXR0b24gZWxlbWVudCBpbiBzdWJtZW51XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgc3VibWVudUFjdGl2ZUJ1dHRvbjogbnVsbCxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIGNvbnRyb2xsZXJzIGFycmF5IChpbWFnZSByZXNpemUgYXJlYSwgbGluayBtb2RpZmllZCBidXR0b24pXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgY29udHJvbGxlckFycmF5OiBbXSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEVsZW1lbnRzIHRoYXQgbmVlZCB0byBjaGFuZ2UgdGV4dCBvciBjbGFzc05hbWUgZm9yIGVhY2ggc2VsZWN0aW9uIGNoYW5nZVxyXG4gICAgICAgICAqIEBwcm9wZXJ0eSB7RWxlbWVudH0gRk9STUFUIC0gZm9ybWF0IGJ1dHRvblxyXG4gICAgICAgICAqIEBwcm9wZXJ0eSB7RWxlbWVudH0gRk9OVCAtIGZvbnQgZmFtaWx5IGJ1dHRvblxyXG4gICAgICAgICAqIEBwcm9wZXJ0eSB7RWxlbWVudH0gU0laRSAtIGZvbnQgc2l6ZSBidXR0b25cclxuICAgICAgICAgKiBAcHJvcGVydHkge0VsZW1lbnR9IEIgLSBib2xkIGJ1dHRvblxyXG4gICAgICAgICAqIEBwcm9wZXJ0eSB7RWxlbWVudH0gVSAtIHVuZGVybGluZSBidXR0b25cclxuICAgICAgICAgKiBAcHJvcGVydHkge0VsZW1lbnR9IEkgLSBpdGFsaWMgYnV0dG9uXHJcbiAgICAgICAgICogQHByb3BlcnR5IHtFbGVtZW50fSBTVFJJS0UgLSBzdHJpa2UgYnV0dG9uXHJcbiAgICAgICAgICogQHByb3BlcnR5IHtFbGVtZW50fSBTVUIgLSBzdWJzY3JpcHQgYnV0dG9uXHJcbiAgICAgICAgICogQHByb3BlcnR5IHtFbGVtZW50fSBTVVAgLSBzdXBlcnNjcmlwdCBidXR0b25cclxuICAgICAgICAgKi9cclxuICAgICAgICBjb21tYW5kTWFwOiB7XHJcbiAgICAgICAgICAgIEZPUk1BVDogY29udGV4dC50b29sLmZvcm1hdCxcclxuICAgICAgICAgICAgRk9OVDogY29udGV4dC50b29sLmZvbnQsXHJcbiAgICAgICAgICAgIFNJWkU6IGNvbnRleHQudG9vbC5mb250U2l6ZSxcclxuICAgICAgICAgICAgQjogY29udGV4dC50b29sLmJvbGQsXHJcbiAgICAgICAgICAgIFU6IGNvbnRleHQudG9vbC51bmRlcmxpbmUsXHJcbiAgICAgICAgICAgIEk6IGNvbnRleHQudG9vbC5pdGFsaWMsXHJcbiAgICAgICAgICAgIFNUUklLRTogY29udGV4dC50b29sLnN0cmlrZSxcclxuICAgICAgICAgICAgU1VCOiBjb250ZXh0LnRvb2wuc3Vic2NyaXB0LFxyXG4gICAgICAgICAgICBTVVA6IGNvbnRleHQudG9vbC5zdXBlcnN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W50Lm5leHRFbGVtZW50U2libGluZztcclxuICAgICAgICAgICAgdGhpcy5zdWJtZW51LnN0eWxlLmRpc3BsYXkgPSAnYmxvY2snO1xyXG4gICAgICAgICAgICB1dGlsLmFkZENsYXNzKGVsZW1lbnQsICdvbicpO1xyXG4gICAgICAgICAgICB0aGlzLnN1Ym1lbnVBY3RpdmVCdXR0b24gPSBlbGVtZW50O1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBEaXNhYmxlIHN1Ym1lbnVcclxuICAgICAgICAgKi9cclxuICAgICAgICBzdWJtZW51T2ZmOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGlmICh0aGlzLnN1Ym1lbnUpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuc3VibWVudS5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zdWJtZW51ID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3ModGhpcy5zdWJtZW51QWN0aXZlQnV0dG9uLCAnb24nKTtcclxuICAgICAgICAgICAgICAgIHRoaXMuc3VibWVudUFjdGl2ZUJ1dHRvbiA9IG51bGw7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmIChjb250ZXh0LmltYWdlICYmIGNvbnRleHQuaW1hZ2UuX29uQ2FwdGlvbiA9PT0gdHJ1ZSkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5wbHVnaW5zLmltYWdlLnRvZ2dsZV9jYXB0aW9uX2NvbnRlbnRlZGl0YWJsZS5jYWxsKGVkaXRvciwgZmFsc2UpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLmNvbnRyb2xsZXJzT2ZmKCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIERpc2FibGUgY29udHJvbGxlciBpbiBlZGl0b3IgYXJlYSAobGluayBidXR0b24sIGltYWdlIHJlc2l6ZSBidXR0b24pXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgY29udHJvbGxlcnNPZmY6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29uc3QgbGVuID0gdGhpcy5jb250cm9sbGVyQXJyYXkubGVuZ3RoO1xyXG5cclxuICAgICAgICAgICAgaWYgKGxlbiA+IDApIHtcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRyb2xsZXJBcnJheVtpXS5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdGhpcy5jb250cm9sbGVyQXJyYXkgPSBbXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBqYXZhc2NyaXB0IGV4ZWNDb21tYW5kXHJcbiAgICAgICAgICogQHBhcmFtIHtTdHJpbmd9IGNvbW1hbmQgLSBqYXZhc2NyaXB0IGV4ZWNDb21tYW5kIGZ1bmN0aW9uIHByb3BlcnR5XHJcbiAgICAgICAgICogQHBhcmFtIHtCb29sZWFufSBzaG93RGVmYXVsdFVJIC0gamF2YXNjcmlwdCBleGVjQ29tbWFuZCBmdW5jdGlvbiBwcm9wZXJ0eVxyXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfSB2YWx1ZSAtIGphdmFzY3JpcHQgZXhlY0NvbW1hbmQgZnVuY3Rpb24gcHJvcGVydHlcclxuICAgICAgICAgKi9cclxuICAgICAgICBleGVjQ29tbWFuZDogZnVuY3Rpb24gKGNvbW1hbmQsIHNob3dEZWZhdWx0VUksIHZhbHVlKSB7XHJcbiAgICAgICAgICAgIGRvY3VtZW50LmV4ZWNDb21tYW5kKGNvbW1hbmQsIHNob3dEZWZhdWx0VUksIHZhbHVlKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRm9jdXMgdG8gd3lzaXd5ZyBhcmVhXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZm9jdXM6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgaWYgKGNvbnRleHQuZWxlbWVudC53eXNpd3lnLnN0eWxlLmRpc3BsYXkgPT09ICdub25lJykgcmV0dXJuO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgY2FwdGlvbiA9IHV0aWwuZ2V0UGFyZW50RWxlbWVudCh0aGlzLl92YXJpYWJsZS5zZWxlY3Rpb25Ob2RlLCAnZmlnY2FwdGlvbicpO1xyXG4gICAgICAgICAgICBpZiAoY2FwdGlvbikge1xyXG4gICAgICAgICAgICAgICAgY2FwdGlvbi5mb2N1cygpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuZm9jdXMoKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5fc2V0RWRpdG9yUmFuZ2UoKTtcclxuICAgICAgICAgICAgZXZlbnQuX2ZpbmRCdXR0b25FZmZlY3RUYWcoKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gU2F2aW5nIHRoZSByYW5nZSBvYmplY3QgYW5kIHRoZSBjdXJyZW50bHkgc2VsZWN0ZWQgbm9kZSBvZiBlZGl0b3JcclxuICAgICAgICAgKiBAcHJpdmF0ZVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIF9zZXRFZGl0b3JSYW5nZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb25zdCBzZWxlY3Rp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RDb24sIHN0YXJ0T2ZmKTtcclxuICAgICAgICAgICAgcmFuZ2Uuc2V0RW5kKGVuZENvbiwgZW5kT2ZmKTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IHNlbGVjdGlvbiA9IHdpbmRvdy5nZXRTZWxlY3Rpb24oKTtcclxuXHJcbiAgICAgICAgICAgIGlmIChzZWxlY3Rpb24ucmFuZ2VDb3VudCA+IDApIHtcclxuICAgICAgICAgICAgICAgIHNlbGVjdGlvbi5yZW1vdmVBbGxSYW5nZXMoKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5fdmFyaWFibGUucmFuZ2UgPSByYW5nZTtcclxuICAgICAgICAgICAgc2VsZWN0aW9uLmFkZFJhbmdlKHJhbmdlKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gR2V0IGN1cnJlbnQgZWRpdG9yJ3MgcmFuZ2Ugb2JqZWN0XHJcbiAgICAgICAgICogQHJldHVybnMge09iamVjdH1cclxuICAgICAgICAgKi9cclxuICAgICAgICBnZXRSYW5nZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fdmFyaWFibGUucmFuZ2UgfHwgdGhpcy5fY3JlYXRlRGVmYXVsdFJhbmdlKCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEdldCBjdXJyZW50IHNlbGVjdCBub2RlXHJcbiAgICAgICAgICogQHJldHVybnMge05vZGV9XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZ2V0U2VsZWN0aW9uTm9kZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBpZiAodGhpcy5fdmFyaWFibGUuc2VsZWN0aW9uTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3ZhcmlhYmxlLnNlbGVjdGl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4gICAgICAgICAqL1xyXG4gICAgICAgIGNsb3NlTG9hZGluZzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQubG9hZGluZy5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBBcHBlbmQgUCB0YWcgdG8gY3VycmVudCBsaW5lIG5leHRcclxuICAgICAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IGVsZW1lbnQgLSBJbnNlcnQgYXMgc2libGluZ3Mgb2YgdGhhdCBlbGVtZW50XHJcbiAgICAgICAgICogQHJldHVybnMge0VsZW1lbnR9XHJcbiAgICAgICAgICovXHJcbiAgICAgICAgYXBwZW5kUDogZnVuY3Rpb24gKGVsZW1lbnQpIHtcclxuICAgICAgICAgICAgY29uc3Qgb1AgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdQJyk7XHJcbiAgICAgICAgICAgIG9QLmlubmVySFRNTCA9ICcmIzY1Mjc5JztcclxuXHJcbiAgICAgICAgICAgIGVsZW1lbnQgPSB1dGlsLmdldEZvcm1hdEVsZW1lbnQoZWxlbWVudCk7XHJcbiAgICAgICAgICAgIGVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUob1AsIGVsZW1lbnQubmV4dEVsZW1lbnRTaWJsaW5nKTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiBvUDtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRGVsZXRlIHNlbGVjdGVkIG5vZGUgYW5kIGluc2VydCBhcmd1bWVudCB2YWx1ZSBub2RlXHJcbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSBvTm9kZSAtIE5vZGUgdG8gYmUgaW5zZXJ0ZWRcclxuICAgICAgICAgKiBAcGFyYW0geyhFbGVtZW50fG51bGwpfSByaWdodE5vZGUgLSBJZiB0aGUgbm9kZSBleGlzdHMsIGl0IGlzIGluc2VydGVkIGFmdGVyIHRoZSBub2RlXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgaW5zZXJ0Tm9kZTogZnVuY3Rpb24gKG9Ob2RlLCByaWdodE5vZGUpIHtcclxuICAgICAgICAgICAgY29uc3QgcmFuZ2UgPSB0aGlzLmdldFJhbmdlKCk7XHJcbiAgICAgICAgICAgIGxldCBwYXJlbnROb2RlID0gbnVsbDtcclxuXHJcbiAgICAgICAgICAgIGlmICghcmlnaHROb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBzdGFydENvbiA9IHJhbmdlLnN0YXJ0Q29udGFpbmVyO1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgc3RhcnRPZmYgPSByYW5nZS5zdGFydE9mZnNldDtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGVuZENvbiA9IHJhbmdlLmVuZENvbnRhaW5lcjtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGVuZE9mZiA9IHJhbmdlLmVuZE9mZnNldDtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkNvbiA9IHJhbmdlLmNvbW1vbkFuY2VzdG9yQ29udGFpbmVyO1xyXG5cclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUgPSBzdGFydENvbjtcclxuICAgICAgICAgICAgICAgIGlmIChzdGFydENvbi5ub2RlVHlwZSA9PT0gMykge1xyXG4gICAgICAgICAgICAgICAgICAgIHBhcmVudE5vZGUgPSBzdGFydENvbi5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBTZWxlY3Qgd2l0aGluIHRoZSBzYW1lIG5vZGUgKi9cclxuICAgICAgICAgICAgICAgIGlmIChyYW5nZS5jb2xsYXBzZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoY29tbW9uQ29uLm5vZGVUeXBlID09PSAzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IGNvbW1vbkNvbi5zcGxpdFRleHQoZW5kT2ZmKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJlbnROb2RlLmxhc3RDaGlsZCAhPT0gbnVsbCAmJiAvXkJSJC9pLnRlc3QocGFyZW50Tm9kZS5sYXN0Q2hpbGQubm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnROb2RlLnJlbW92ZUNoaWxkKHBhcmVudE5vZGUubGFzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICByaWdodE5vZGUgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIC8qKiBTZWxlY3QgbXVsdGlwbGUgbm9kZXMgKi9cclxuICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzU2FtZUNvbnRhaW5lciA9IHN0YXJ0Q29uID09PSBlbmRDb247XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1NhbWVDb250YWluZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJlbW92ZU5vZGUgPSBzdGFydENvbjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzRWRnZVBvaW50KGVuZENvbiwgZW5kT2ZmKSkgcmlnaHROb2RlID0gZW5kQ29uLnNwbGl0VGV4dChlbmRPZmYpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNFZGdlUG9pbnQoc3RhcnRDb24sIHN0YXJ0T2ZmKSkgcmVtb3ZlTm9kZSA9IHN0YXJ0Q29uLnNwbGl0VGV4dChzdGFydE9mZik7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnROb2RlLnJlbW92ZUNoaWxkKHJlbW92ZU5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVOb2RlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IGVuZENvbjtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChyaWdodE5vZGUubm9kZVR5cGUgIT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJpZ2h0Tm9kZSA9IHJpZ2h0Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgcGFyZW50Tm9kZSA9IHJpZ2h0Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgcmlnaHROb2RlID0gcmlnaHROb2RlLm5leHRTaWJsaW5nO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUob05vZGUsIHJpZ2h0Tm9kZSk7XHJcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcclxuICAgICAgICAgICAgICAgIHBhcmVudE5vZGUuYXBwZW5kQ2hpbGQob05vZGUpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvLyB0aGlzLnNldFJhbmdlKG9Ob2RlLCAwLCBvTm9kZSwgMCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIERlbGV0ZSB0aGUgY3VycmVudGx5IHNlbGVjdGVkIG5vZGVcclxuICAgICAgICAgKi9cclxuICAgICAgICByZW1vdmVOb2RlOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHJhbmdlID0gdGhpcy5nZXRSYW5nZSgpO1xyXG5cclxuICAgICAgICAgICAgaWYgKHJhbmdlLmRlbGV0ZUNvbnRlbnRzKSB7XHJcbiAgICAgICAgICAgICAgICByYW5nZS5kZWxldGVDb250ZW50cygpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBjb25zdCBzdGFydENvbiA9IHJhbmdlLnN0YXJ0Q29udGFpbmVyO1xyXG4gICAgICAgICAgICBjb25zdCBzdGFydE9mZiA9IHJhbmdlLnN0YXJ0T2Zmc2V0O1xyXG4gICAgICAgICAgICBjb25zdCBlbmRDb24gPSByYW5nZS5lbmRDb250YWluZXI7XHJcbiAgICAgICAgICAgIGNvbnN0IGVuZE9mZiA9IHJhbmdlLmVuZE9mZnNldDtcclxuICAgICAgICAgICAgY29uc3QgY29tbW9uQ29uID0gcmFuZ2UuY29tbW9uQW5jZXN0b3JDb250YWluZXI7XHJcblxyXG4gICAgICAgICAgICBsZXQgYmVmb3JlTm9kZSA9IG51bGw7XHJcbiAgICAgICAgICAgIGxldCBhZnRlck5vZGUgPSBudWxsO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgY2hpbGROb2RlcyA9IHV0aWwuZ2V0TGlzdENoaWxkTm9kZXMoY29tbW9uQ29uKTtcclxuICAgICAgICAgICAgbGV0IHN0YXJ0SW5kZXggPSB1dGlsLmdldEFycmF5SW5kZXgoY2hpbGROb2Rlcywgc3RhcnRDb24pO1xyXG4gICAgICAgICAgICBsZXQgZW5kSW5kZXggPSB1dGlsLmdldEFycmF5SW5kZXgoY2hpbGROb2RlcywgZW5kQ29uKTtcclxuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBzdGFydEluZGV4ICsgMSwgc3RhcnROb2RlID0gc3RhcnRDb247IGkgPj0gMDsgaS0tKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoY2hpbGROb2Rlc1tpXSA9PT0gc3RhcnROb2RlLnBhcmVudE5vZGUgJiYgY2hpbGROb2Rlc1tpXS5maXJzdENoaWxkID09PSBzdGFydE5vZGUgJiYgc3RhcnRPZmYgPT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaTtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydE5vZGUgPSBzdGFydE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IGVuZEluZGV4IC0gMSwgZW5kTm9kZSA9IGVuZENvbjsgaSA+IHN0YXJ0SW5kZXg7IGktLSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkTm9kZXNbaV0gPT09IGVuZE5vZGUucGFyZW50Tm9kZSAmJiBjaGlsZE5vZGVzW2ldLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY2hpbGROb2Rlcy5zcGxpY2UoaSwgMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZW5kTm9kZSA9IGVuZE5vZGUucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAtLWVuZEluZGV4O1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleDsgaSA8PSBlbmRJbmRleDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gY2hpbGROb2Rlc1tpXTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaXRlbS5sZW5ndGggPT09IDAgfHwgKGl0ZW0ubm9kZVR5cGUgPT09IDMgJiYgaXRlbS5kYXRhID09PSB1bmRlZmluZWQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGl0ZW0pO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpdGVtID09PSBzdGFydENvbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdGFydENvbi5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiZWZvcmVOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb24udGV4dENvbnRlbnQpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJlZm9yZU5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShzdGFydENvbi5zdWJzdHJpbmdEYXRhKDAsIHN0YXJ0T2ZmKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoYmVmb3JlTm9kZS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29uLmRhdGEgPSBiZWZvcmVOb2RlLmRhdGE7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKHN0YXJ0Q29uKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpdGVtID09PSBlbmRDb24pIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoZW5kQ29uLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFmdGVyTm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKGVuZENvbi50ZXh0Q29udGVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYWZ0ZXJOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoZW5kQ29uLnN1YnN0cmluZ0RhdGEoZW5kT2ZmLCAoZW5kQ29uLmxlbmd0aCAtIGVuZE9mZikpKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhZnRlck5vZGUubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlbmRDb24uZGF0YSA9IGFmdGVyTm9kZS5kYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlSXRlbShlbmRDb24pO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVJdGVtKGl0ZW0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIENvcGllcyB0aGUgbm9kZSBvZiB0aGUgYXJndW1lbnQgdmFsdWUgYW5kIHdyYXBzIGFsbCBzZWxlY3RlZCB0ZXh0LlxyXG4gICAgICAgICAqIDEuIFdoZW4gdGhlcmUgaXMgdGhlIHNhbWUgbm9kZSBpbiB0aGUgc2VsZWN0aW9uIGFyZWEsIHRoZSB0YWcgaXMgc3RyaXBwZWQuXHJcbiAgICAgICAgICogM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1xyXG4gICAgICAgICAgICBsZXQgbmV3Tm9kZSwgcmVnRXhwO1xyXG5cclxuICAgICAgICAgICAgaWYgKGNoZWNrQ1NTUHJvcGVydHlBcnJheSkge1xyXG4gICAgICAgICAgICAgICAgcmVnRXhwID0gJyg/Ojt8XnxcXFxccykoPzonICsgY2hlY2tDU1NQcm9wZXJ0eUFycmF5WzBdO1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBjaGVja0NTU1Byb3BlcnR5QXJyYXkubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICByZWdFeHAgKz0gJ3wnICsgY2hlY2tDU1NQcm9wZXJ0eUFycmF5W2ldO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgcmVnRXhwICs9ICcpXFxcXHMqOlteO10qXFxcXHMqKD86O3wkKSc7XHJcbiAgICAgICAgICAgICAgICByZWdFeHAgPSBuZXcgUmVnRXhwKHJlZ0V4cCwgJ2dpJyk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiBvbmUgbm9kZSAqL1xyXG4gICAgICAgICAgICBpZiAoc3RhcnRDb24gPT09IGVuZENvbikge1xyXG4gICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGFwcGVuZE5vZGUuY2xvbmVOb2RlKGZhbHNlKTtcclxuXHJcbiAgICAgICAgICAgICAgICAvKiogTm8gbm9kZSBzZWxlY3RlZCAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKHN0YXJ0T2ZmID09PSBlbmRPZmYpIHtcclxuICAgICAgICAgICAgICAgICAgICBuZXdOb2RlLmlubmVySFRNTCA9ICcmIzY1Mjc5JztcclxuICAgICAgICAgICAgICAgICAgICBpZiAodXRpbC5pc0Zvcm1hdEVsZW1lbnQoc3RhcnRDb24pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29uLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29uLnNwbGl0VGV4dChzdGFydE9mZik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q29uLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKG5ld05vZGUsIHN0YXJ0Q29uLm5leHRTaWJsaW5nKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAvKiogU2VsZWN0IHdpdGhpbiB0aGUgc2FtZSBub2RlICovXHJcbiAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0VsZW1lbnQgPSBzdGFydENvbi5ub2RlVHlwZSA9PT0gMTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoaXNFbGVtZW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUuaW5uZXJIVE1MID0gc3RhcnRDb24ub3V0ZXJIVE1MO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbi5wYXJlbnROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oc3RhcnRDb24pO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJlZm9yZU5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShzdGFydENvbi5zdWJzdHJpbmdEYXRhKDAsIHN0YXJ0T2ZmKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFmdGVyTm9kZSA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHN0YXJ0Q29uLnN1YnN0cmluZ0RhdGEoZW5kT2ZmLCAoc3RhcnRDb24ubGVuZ3RoIC0gZW5kT2ZmKSkpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZS5pbm5lclRleHQgPSBzdGFydENvbi5zdWJzdHJpbmdEYXRhKHN0YXJ0T2ZmLCAoZW5kT2ZmIC0gc3RhcnRPZmYpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb24ucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUobmV3Tm9kZSwgc3RhcnRDb24ubmV4dFNpYmxpbmcpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJlZm9yZU5vZGUuZGF0YS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbi5kYXRhID0gYmVmb3JlTm9kZS5kYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb24uZGF0YSA9IHN0YXJ0Q29uLnN1YnN0cmluZ0RhdGEoMCwgc3RhcnRPZmYpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWZ0ZXJOb2RlLmRhdGEubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRDb24ucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUoYWZ0ZXJOb2RlLCBuZXdOb2RlLm5leHRTaWJsaW5nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBzdGFydC5jb250YWluZXIgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgc3RhcnQub2Zmc2V0ID0gMTtcclxuICAgICAgICAgICAgICAgIGVuZC5jb250YWluZXIgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgZW5kLm9mZnNldCA9IDE7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgLyoqIG11bHRpcGxlIG5vZGVzICovXHJcbiAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgLyoqIHRhZyBjaGVjayBmdW5jdGlvbiovXHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaGVja0NzcyA9IGZ1bmN0aW9uICh2Tm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICh2Tm9kZS5ub2RlVHlwZSA9PT0gMykgcmV0dXJuIHRydWU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzdHlsZSA9ICcnO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChyZWdFeHAgJiYgdk5vZGUuc3R5bGUuY3NzVGV4dC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlID0gdk5vZGUuc3R5bGUuY3NzVGV4dC5yZXBsYWNlKHJlZ0V4cCwgJycpLnRyaW0oKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmICh2Tm9kZS5ub2RlTmFtZSAhPT0gYXBwZW5kTm9kZS5ub2RlTmFtZSB8fCBzdHlsZS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2Tm9kZS5zdHlsZS5jc3NUZXh0Lmxlbmd0aCA+IDApIHZOb2RlLnN0eWxlLmNzc1RleHQgPSBzdHlsZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBvbmUgbGluZSAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKCF1dGlsLmhhc0NsYXNzKGNvbW1vbkNvbiwgJ3N1bi1lZGl0b3ItaWQtd3lzaXd5ZycpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGFwcGVuZE5vZGUuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdSYW5nZSA9IHRoaXMuX3dyYXBMaW5lTm9kZXNQYXJ0KGNvbW1vbkNvbiwgbmV3Tm9kZSwgY2hlY2tDc3MsIHN0YXJ0Q29uLCBzdGFydE9mZiwgZW5kQ29uLCBlbmRPZmYpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBzdGFydC5jb250YWluZXIgPSBuZXdSYW5nZS5zdGFydENvbnRhaW5lcjtcclxuICAgICAgICAgICAgICAgICAgICBzdGFydC5vZmZzZXQgPSBuZXdSYW5nZS5zdGFydE9mZnNldDtcclxuICAgICAgICAgICAgICAgICAgICBlbmQuY29udGFpbmVyID0gbmV3UmFuZ2UuZW5kQ29udGFpbmVyO1xyXG4gICAgICAgICAgICAgICAgICAgIGVuZC5vZmZzZXQgPSBuZXdSYW5nZS5lbmRPZmZzZXQ7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAvKiogbXVsdGkgbGluZSAqL1xyXG4gICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZ2V0IGxpbmUgbm9kZXNcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5lTm9kZXMgPSB1dGlsLmdldExpc3RDaGlsZHJlbihjb21tb25Db24sIGZ1bmN0aW9uIChjdXJyZW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1dGlsLmlzRm9ybWF0RWxlbWVudChjdXJyZW50KTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHN0YXJ0TGluZSA9IHV0aWwuZ2V0UGFyZW50RWxlbWVudChzdGFydENvbiwgJ1AnKTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgZW5kTGluZSA9IHV0aWwuZ2V0UGFyZW50RWxlbWVudChlbmRDb24sICdQJyk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBsaW5lTm9kZXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXJ0TGluZSA9PT0gbGluZU5vZGVzW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydExpbmUgPSBpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuZExpbmUgPT09IGxpbmVOb2Rlc1tpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kTGluZSA9IGk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gc3RhcnRDb25cclxuICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gYXBwZW5kTm9kZS5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0ID0gdGhpcy5fd3JhcExpbmVOb2Rlc1N0YXJ0KGxpbmVOb2Rlc1tzdGFydExpbmVdLCBuZXdOb2RlLCBjaGVja0Nzcywgc3RhcnRDb24sIHN0YXJ0T2ZmKTtcclxuICAgICAgICAgICAgICAgICAgICAvLyBtaWRcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnRMaW5lICsgMTsgaSA8IGVuZExpbmU7IGkrKykge1xyXG4gICAgICAgICAgIC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ICAgICAgICAgICBsZXQgZW5kQ29udGFpbmVyID0gZW5kQ29uO1xyXG4gICAgICAgICAgICBsZXQgZW5kT2Zmc2V0ID0gZW5kT2ZmO1xyXG4gICAgICAgICAgICBsZXQgcHJldk5vZGUsIGFmdGVyTm9kZTtcclxuXHJcbiAgICAgICAgICAgIChmdW5jdGlvbiByZWN1cnNpb25GdW5jKGN1cnJlbnQsIG5vZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZXMgPSBjdXJyZW50LmNoaWxkTm9kZXM7XHJcblxyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGNoaWxkTm9kZXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2hpbGQgPSBjaGlsZE5vZGVzW2ldO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb3Zlck5vZGUgPSBub2RlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGlvbihjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNsb25lTm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZCA9PT0gc3RhcnRDb250YWluZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoc3RhcnRDb250YWluZXIuc3Vic3RyaW5nRGF0YSgwLCBzdGFydE9mZnNldCkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGQgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShzdGFydENvbnRhaW5lci5zdWJzdHJpbmdEYXRhKHN0YXJ0T2Zmc2V0LCAoc3RhcnRDb250YWluZXIubGVuZ3RoIC0gc3RhcnRPZmZzZXQpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydE9mZnNldCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydENvbnRhaW5lciA9IGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiAoY2hpbGQgPT09IGVuZENvbnRhaW5lcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWZ0ZXJOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoZW5kQ29udGFpbmVyLnN1YnN0cmluZ0RhdGEoZW5kT2Zmc2V0LCAoZW5kQ29udGFpbmVyLmxlbmd0aCAtIGVuZE9mZnNldCkpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoZW5kQ29udGFpbmVyLnN1YnN0cmluZ0RhdGEoMCwgZW5kT2Zmc2V0KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmRPZmZzZXQgPSBjaGlsZC5sZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmRDb250YWluZXIgPSBjbG9uZU5vZGUgPSBjaGlsZC5jbG9uZU5vZGUoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVOb2RlID0gY2hpbGQuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlTm9kZUxpc3QucHVzaChjaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY2xvbmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxKSBjb3Zlck5vZGUgPSBjbG9uZU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNvdmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pKGVsLCBuZXdJbm5lck5vZGUpO1xyXG5cclxuICAgICAgICAgICAgZWwuaW5uZXJIVE1MID0gJyc7XHJcbiAgICAgICAgICAgIGVsLmFwcGVuZENoaWxkKHByZXZOb2RlKTtcclxuICAgICAgICAgICAgZWwuYXBwZW5kQ2hpbGQobmV3SW5uZXJOb2RlKTtcclxuICAgICAgICAgICAgZWwuYXBwZW5kQ2hpbGQoYWZ0ZXJOb2RlKTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgICAgICBzdGFydENvbnRhaW5lcjogc3RhcnRDb250YWluZXIsXHJcbiAgICAgICAgICAgICAgICBzdGFydE9mZnNldDogc3RhcnRPZmZzZXQsXHJcbiAgICAgICAgICAgICAgICBlbmRDb250YWluZXI6IGVuZENvbnRhaW5lcixcclxuICAgICAgICAgICAgICAgIGVuZE9mZnNldDogZW5kT2Zmc2V0XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIHdyYXBzIG1pZCBsaW5lcyBzZWxlY3RlZCB0ZXh0LlxyXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gZWxlbWVudCAtIFRoZSBub2RlIG9mIHRoZSBsaW5lIHRoYXQgY29udGFpbnMgdGhlIHNlbGVjdGVkIHRleHQgbm9kZS5cclxuICAgICAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IG5ld0lubmVyTm9kZSAtIFRoZSBkb20gdGhhdCB3aWxsIHdyYXAgdGhlIHNlbGVjdGVkIHRleHQgYXJlYVxyXG4gICAgICAgICAqIEBwYXJhbSB7ZnVuY3Rpb259IHZhbGlkYXRpb24gLSBDaGVjayBpZiB0aGUgbm9kZSBzaG91bGQgYmUgc3RyaXBwZWQuXHJcbiAgICAgICAgICogQHByaXZhdGVcclxuICAgICAgICAgKi9cclxuICAgICAgICBfd3JhcExpbmVOb2RlczogZnVuY3Rpb24gKGVsZW1lbnQsIG5ld0lubmVyTm9kZSwgdmFsaWRhdGlvbikge1xyXG4gICAgICAgICAgICAoZnVuY3Rpb24gcmVjdXJzaW9uRnVuYyhjdXJyZW50LCBub2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGVzID0gY3VycmVudC5jaGlsZE5vZGVzO1xyXG5cclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBjaGlsZE5vZGVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNoaWxkID0gY2hpbGROb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGlvbihjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNsb25lTm9kZSA9IGNoaWxkLmNsb25lTm9kZShmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQoY2xvbmVOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxKSBjb3Zlck5vZGUgPSBjbG9uZU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNvdmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcb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GVsZW1lbnQsIG5ld0lubmVyTm9kZSwgdmFsaWRhdGlvbiwgc3RhcnRDb24sIHN0YXJ0T2ZmKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGVsID0gZWxlbWVudDtcclxuICAgICAgICAgICAgY29uc3QgcE5vZGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdQJyk7XHJcblxyXG4gICAgICAgICAgICBsZXQgY29udGFpbmVyID0gc3RhcnRDb247XHJcbiAgICAgICAgICAgIGxldCBvZmZzZXQgPSBzdGFydE9mZjtcclxuICAgICAgICAgICAgbGV0IHBhc3NOb2RlID0gZmFsc2U7XHJcbiAgICAgICAgICAgIGxldCBwQ3VycmVudCwgbmV3Tm9kZSwgYXBwZW5kTm9kZTtcclxuXHJcbiAgICAgICAgICAgIChmdW5jdGlvbiByZWN1cnNpb25GdW5jKGN1cnJlbnQsIG5vZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZXMgPSBjdXJyZW50LmNoaWxkTm9kZXM7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gY2hpbGROb2Rlcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGROb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY292ZXJOb2RlID0gbm9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhc3NOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdXJzaW9uRnVuYyhjaGlsZCwgY2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBjaGlsZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUucGFyZW50Tm9kZSAhPT0gbnVsbCAmJiBuZXdOb2RlICE9PSBlbCAmJiBuZXdOb2RlICE9PSBuZXdJbm5lck5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKG5ld05vZGUpICYmIG5ld05vZGUubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocEN1cnJlbnQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZSA9IG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuYXBwZW5kQ2hpbGQobmV3Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuYXBwZW5kQ2hpbGQoYXBwZW5kTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdJbm5lck5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIHN0YXJ0Q29udGFpbmVyXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXNzTm9kZSAmJiBjaGlsZCA9PT0gY29udGFpbmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoY29udGFpbmVyLnN1YnN0cmluZ0RhdGEoMCwgb2Zmc2V0KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHROb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoY29udGFpbmVyLnN1YnN0cmluZ0RhdGEob2Zmc2V0LCAoY29udGFpbmVyLmxlbmd0aCAtIG9mZnNldCkpKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2Tm9kZS5kYXRhLmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXBwZW5kQ2hpbGQocHJldk5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcEN1cnJlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5ld05vZGUgIT09IHBOb2RlICYmIG5ld05vZGUgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0aW9uKG5ld05vZGUpICYmIG5ld05vZGUubm9kZVR5cGUgPT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudC5wdXNoKG5ld05vZGUuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gbmV3Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpIHx8IG5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlLmFwcGVuZENoaWxkKG5ld05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXBwZW5kTm9kZSAhPT0gbm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SW5uZXJOb2RlLmFwcGVuZENoaWxkKGFwcGVuZE5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3SW5uZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwTm9kZS5hcHBlbmRDaGlsZChuZXdJbm5lck5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIgPSB0ZXh0Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFzc05vZGUgPSB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hcHBlbmRDaGlsZChjb250YWluZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghcGFzc05vZGUgfHwgdmFsaWRhdGlvbihjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmVOb2RlID0gY2hpbGQuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hcHBlbmRDaGlsZChjbG9uZU5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEpIGNvdmVyTm9kZSA9IGNsb25lTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNvdmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pKGVsZW1lbnQsIHBOb2RlKTtcclxuXHJcbiAgICAgICAgICAgIGVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocE5vZGUsIGVsZW1lbnQpO1xyXG4gICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oZWxlbWVudCk7XHJcblxyXG4gICAgICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAgICAgY29udGFpbmVyOiBjb250YWluZXIsXHJcbiAgICAgICAgICAgICAgICBvZmZzZXQ6IG9mZnNldFxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgIH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5cclxuICAgICAgICAgICAgbGV0IGNvbnRhaW5lciA9IGVuZENvbjtcclxuICAgICAgICAgICAgbGV0IG9mZnNldCA9IGVuZE9mZjtcclxuICAgICAgICAgICAgbGV0IHBhc3NOb2RlID0gZmFsc2U7XHJcbiAgICAgICAgICAgIGxldCBwQ3VycmVudCwgbmV3Tm9kZSwgYXBwZW5kTm9kZTtcclxuXHJcbiAgICAgICAgICAgIChmdW5jdGlvbiByZWN1cnNpb25GdW5jKGN1cnJlbnQsIG5vZGUpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkTm9kZXMgPSBjdXJyZW50LmNoaWxkTm9kZXM7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gY2hpbGROb2Rlcy5sZW5ndGggLTE7IDAgPD0gaTsgaS0tKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGQgPSBjaGlsZE5vZGVzW2ldO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb3Zlck5vZGUgPSBub2RlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAocGFzc05vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN1cnNpb25GdW5jKGNoaWxkLCBjaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZSA9IGNoaWxkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmV3Tm9kZS5wYXJlbnROb2RlICE9PSBudWxsICYmIG5ld05vZGUgIT09IGVsICYmIG5ld05vZGUgIT09IG5ld0lubmVyTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24obmV3Tm9kZSkgJiYgbmV3Tm9kZS5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50LnB1c2gobmV3Tm9kZS5jbG9uZU5vZGUoZmFsc2UpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBuZXdOb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwQ3VycmVudC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmROb2RlID0gbmV3Tm9kZSA9IHBDdXJyZW50LnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwZW5kTm9kZS5pbnNlcnRCZWZvcmUobmV3Tm9kZSwgYXBwZW5kTm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lubmVyTm9kZS5pbnNlcnRCZWZvcmUoYXBwZW5kTm9kZSwgbmV3SW5uZXJOb2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld05vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlID0gbmV3SW5uZXJOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBlbmRDb250YWluZXJcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXBhc3NOb2RlICYmIGNoaWxkID09PSBjb250YWluZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWZ0ZXJOb2RlID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoY29udGFpbmVyLnN1YnN0cmluZ0RhdGEob2Zmc2V0LCAoY29udGFpbmVyLmxlbmd0aCAtIG9mZnNldCkpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dE5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjb250YWluZXIuc3Vic3RyaW5nRGF0YSgwLCBvZmZzZXQpKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZnRlck5vZGUuZGF0YS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlLmluc2VydEJlZm9yZShhZnRlck5vZGUsIG5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBub2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwQ3VycmVudCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmV3Tm9kZSAhPT0gcE5vZGUgJiYgbmV3Tm9kZSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24obmV3Tm9kZSkgJiYgbmV3Tm9kZS5ub2RlVHlwZSA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDdXJyZW50LnB1c2gobmV3Tm9kZS5jbG9uZU5vZGUoZmFsc2UpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBuZXdOb2RlLnBhcmVudE5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUgPSBuZXdOb2RlID0gcEN1cnJlbnQucG9wKCkgfHwgbm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBDdXJyZW50Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld05vZGUgPSBwQ3VycmVudC5wb3AoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZE5vZGUuaW5zZXJ0QmVmb3JlKG5ld05vZGUsIGFwcGVuZE5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcHBlbmROb2RlICE9PSBub2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdJbm5lck5vZGUuaW5zZXJ0QmVmb3JlKGFwcGVuZE5vZGUsIG5ld0lubmVyTm9kZS5maXJzdENoaWxkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUgPSBuZXdOb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ld0lubmVyTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcE5vZGUuaW5zZXJ0QmVmb3JlKG5ld0lubmVyTm9kZSwgcE5vZGUuZmlyc3RDaGlsZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciA9IHRleHROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgPSB0ZXh0Tm9kZS5kYXRhLmxlbmd0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFzc05vZGUgPSB0cnVlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5pbnNlcnRCZWZvcmUoY29udGFpbmVyLCBub2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghcGFzc05vZGUgfHwgdmFsaWRhdGlvbihjaGlsZCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmVOb2RlID0gY2hpbGQuY2xvbmVOb2RlKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5pbnNlcnRCZWZvcmUoY2xvbmVOb2RlLCBub2RlLmZpcnN0Q2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQubm9kZVR5cGUgPT09IDEpIGNvdmVyTm9kZSA9IGNsb25lTm9kZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJlY3Vyc2lvbkZ1bmMoY2hpbGQsIGNvdmVyTm9kZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pKGVsZW1lbnQsIHBOb2RlKTtcclxuXHJcbiAgICAgICAgICAgIGVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocE5vZGUsIGVsZW1lbnQpO1xyXG4gICAgICAgICAgICB1dGlsLnJlbW92ZUl0ZW0oZWxlbWVudCk7XHJcblxyXG4gICAgICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAgICAgY29udGFpbmVyOiBjb250YWluZXIsXHJcbiAgICAgICAgICAgICAgIC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cbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSBlbGVtZW50IC0gZnVsbCBzY3JlZW4gYnV0dG9uXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgdG9nZ2xlRnVsbFNjcmVlbjogZnVuY3Rpb24gKGVsZW1lbnQpIHtcclxuICAgICAgICAgICAgaWYgKCF0aGlzLl92YXJpYWJsZS5pc0Z1bGxTY3JlZW4pIHtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLnBvc2l0aW9uID0gJ2ZpeGVkJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLnRvcCA9ICcwJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLmxlZnQgPSAnMCc7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5zdHlsZS53aWR0aCA9ICcxMDAlJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLmhlaWdodCA9ICcxMDAlJztcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC50b3BBcmVhLnN0eWxlLnpJbmRleCA9ICcyMTQ3NDgzNjQ3JztcclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLl92YXJpYWJsZS5pbm5lckhlaWdodF9mdWxsU2NyZWVuID0gKHdpbmRvdy5pbm5lckhlaWdodCAtIGNvbnRleHQudG9vbC5iYXIub2Zmc2V0SGVpZ2h0KTtcclxuICAgICAgICAgICAgICAgIGNvbnRleHQuZWxlbWVudC5lZGl0b3JBcmVhLnN0eWxlLmhlaWdodCA9IHRoaXMuX3ZhcmlhYmxlLmlubmVySGVpZ2h0X2Z1bGxTY3JlZW4gKyAncHgnO1xyXG5cclxuICAgICAgICAgICAgICAgIHV0aWwucmVtb3ZlQ2xhc3MoZWxlbWVudC5maXJzdE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gICAgICAgICAgICBjb25zdCBpc1ByaW50ID0gbW9kZSA9PT0gJ3ByaW50JztcclxuICAgICAgICAgICAgY29uc3Qgd2luZG93T2JqZWN0ID0gd2luZG93Lm9wZW4oJycsICdfYmxhbmsnKTtcclxuICAgICAgICAgICAgd2luZG93T2JqZWN0Lm1pbWVUeXBlID0gJ3RleHQvaHRtbCc7XHJcbiAgICAgICAgICAgIHdpbmRvd09iamVjdC5kb2N1bWVudC53cml0ZSgnJyArXHJcbiAgICAgICAgICAgICAgICAnPCFkb2N0eXBlIGh0bWw+PGh0bWw+JyArXHJcbiAgICAgICAgICAgICAgICAnPGhlYWQ+JyArXHJcbiAgICAgICAgICAgICAgICAnPG1ldGEgY2hhcnNldD1cInV0Zi04XCIgLz4nICtcclxuICAgICAgICAgICAgICAgICc8bWV0YSBuYW1lPVwidmlld3BvcnRcIiBjb250ZW50PVwid2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTFcIj4nICtcclxuICAgICAgICAgICAgICAgICc8dGl0bGU+JyArIChpc1ByaW50ID8gbGFuZy50b29sYmFyLnByaW50IDogbGFuZy50b29sYmFyLnByZXZpZXcpICsgJzwvdGl0bGU+JyArXHJcbiAgICAgICAgICAgICAgICAnPGxpbmsgcmVsPVwic3R5bGVzaGVldFwiIHR5cGU9XCJ0ZXh0L2Nzc1wiIGhyZWY9XCInICsgdXRpbC5nZXRJbmNsdWRlUGF0aChbJ3N1bmVkaXRvci1jb250ZW50cycsICdzdW5lZGl0b3InXSwgJ2NzcycpICsgJ1wiPicgK1xyXG4gICAgICAgICAgICAgICAgJzwvaGVhZD4nICtcclxuICAgICAgICAgICAgICAgICc8Ym9keSBjbGFzcz1cInN1bi1lZGl0b3ItZWRpdGFibGVcIj4nICsgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MICsgJzwvYm9keT4nICtcclxuICAgICAgICAgICAgICAgICc8L2JvZHk+JyArIChpc1ByaW50ID8gJzxzY3J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AgICAgICAgIHV0aWwuY2hhbmdlVHh0KGNvbW1hbmRNYXBbJ0ZPUk1BVCddLCBub2RlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEZvcm1hdCA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBGb250ICovXHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEZvbnQgJiYgKHNlbGVjdGlvblBhcmVudC5zdHlsZS5mb250RmFtaWx5Lmxlbmd0aCA+IDAgfHwgKHNlbGVjdGlvblBhcmVudC5mYWNlICYmIHNlbGVjdGlvblBhcmVudC5mYWNlLmxlbmd0aCA+IDApKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdGT05UJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2VsZWN0Rm9udCA9IChzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udEZhbWlseSB8fCBzZWxlY3Rpb25QYXJlbnQuZmFjZSB8fCBsYW5nLnRvb2xiYXIuZm9udCkucmVwbGFjZSgvW1wiJ10vZywnJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgdXRpbC5jaGFuZ2VUeHQoY29tbWFuZE1hcFsnRk9OVCddLCBzZWxlY3RGb250KTtcclxuICAgICAgICAgICAgICAgICAgICBmaW5kRm9udCA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIC8qKiBBICovXHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEEgJiYgL15BJC8udGVzdChub2RlTmFtZSkgJiYgc2VsZWN0aW9uUGFyZW50LmdldEF0dHJpYnV0ZSgnZGF0YS1pbWFnZS1saW5rJykgPT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbnRleHQubGluayB8fCBlZGl0b3IuY29udHJvbGxlckFycmF5WzBdICE9PSBjb250ZXh0LmxpbmsubGlua0J0bikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbignbGluaycsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wbHVnaW5zLmxpbmsuY2FsbF9jb250cm9sbGVyX2xpbmtCdXR0b24uY2FsbChlZGl0b3IsIHNlbGVjdGlvblBhcmVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBmaW5kQSA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaW5kQSAmJiBjb250ZXh0LmxpbmsgJiYgZWRpdG9yLmNvbnRyb2xsZXJBcnJheVswXSA9PT0gY29udGV4dC5saW5rLmxpbmtCdG4pIHtcclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY29udHJvbGxlcnNPZmYoKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvKiogU1BBTiAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRTaXplICYmIC9eU1BBTiQvLnRlc3Qobm9kZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgLyoqIGZvbnQgc2l6ZSAqL1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxlY3Rpb25QYXJlbnQuc3R5bGUuZm9udFNpemUubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnU0laRScpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwWydTSVpFJ10sIHNlbGVjdGlvblBhcmVudC5zdHlsZS5mb250U2l6ZS5tYXRjaCgvXFxkKy8pWzBdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZmluZFNpemUgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLyoqIGNvbW1hbmQgbWFwICovXHJcbiAgICAgICAgICAgICAgICBjc3NUZXh0ID0gc2VsZWN0aW9uUGFyZW50LnN0eWxlLmNzc1RleHQ7XHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEIgJiYgL2ZvbnRcXC13ZWlnaHRcXHMqOlxccyooPzpcXGQrfGJvbGR8Ym9sZGVyKSg/Ojt8XFxzfCkvLnRlc3QoY3NzVGV4dCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnQicpO1xyXG4gICAgICAgICAgICAgICAgICAgIGZpbmRCID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZmluZEkgJiYgL2ZvbnRcXC1zdHlsZVxccyo6XFxzKig/Oml0YWxpY3xvYmxpcXVlKSg/Ojt8XFxzKS8udGVzdChjc3NUZXh0KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbW1hbmRNYXBOb2Rlcy5wdXNoKCdJJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZEkgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChmaW5kVSAmJiAvdGV4dFxcLWRlY29yYXRpb24oPzpcXC1saW5lKT9cXHMqOlxccyp1bmRlcmxpbmUoPzo7fFxcc3wpLy50ZXN0KGNzc1RleHQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29tbWFuZE1hcE5vZGVzLnB1c2goJ1UnKTtcclxuICAgICAgICAgICAgICAgICAgICBmaW5kVSA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGZpbmRTICYmIC90ZXh0XFwtZGVjb3JhdGlvbig/OlxcLWxpbmUpP1xccyo6XFxzKmxpbmUtdGhyb3VnaCg/Ojt8XFxzfCkvLnRlc3QoY3NzVGV4dCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgnU1RSSUtFJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZmluZFMgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBjb21tYW5kTWFwTm9kZXMucHVzaCgoL15TVFJPTkckLy50ZXN0KG5vZGVOYW1lKSA/ICdCJyA6IC9eRU0kLy50ZXN0KG5vZGVOYW1lKSA/ICdJJyA6IG5vZGVOYW1lKSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiBBIFRhZyBlZGl0IGNvbnRyb2xsZXIgb2ZmICovXHJcbiAgICAgICAgICAgIGlmIChmaW5kQSkgZWRpdG9yLmNvbnRyb2xsZXJzT2ZmKCk7XHJcblxyXG4gICAgICAgICAgICAvKiogdG9nZ2xlIGNsYXNzIG9uICovXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tbWFuZE1hcE5vZGVzLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBub2RlTmFtZSA9IGNvbW1hbmRNYXBOb2Rlc1tpXTtcclxuICAgICAgICAgICAgICAgIGlmIChjbGFzc09uQ2hlY2sudGVzdChub2RlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmFkZENsYXNzKGNvbW1hbmRNYXBbbm9kZU5hbWVdLCAnb24nKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLyoqIHJlbW92ZSBjbGFzcywgZGlzcGxheSB0ZXh0ICovXHJcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBjb21tYW5kTWFwKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoY29tbWFuZE1hcE5vZGVzLmluZGV4T2Yoa2V5KSA+IC0xKSBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIGlmICgvXkZPTlQvaS50ZXN0KGtleSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwW2tleV0sIGxhbmcudG9vbGJhci5mb250KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKC9eU0laRSQvaS50ZXN0KGtleSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLmNoYW5nZVR4dChjb21tYW5kTWFwW2tleV0sIGxhbmcudG9vbGJhci5mb250U2l6ZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKGNvbW1hbmRNYXBba2V5XSwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8qKiBzYXZlIGN1cnJlbnQgbm9kZXMgKi9cclxuICAgICAgICAgICAgZWRpdG9yLl92YXJpYWJsZS5jdXJyZW50Tm9kZXMgPSBjdXJyZW50Tm9kZXMucmV2ZXJzZSgpO1xyXG5cclxuICAgICAgICAgICAgLyoqICBEaXNwbGF5cyB0aGUgY3VycmVudCBub2RlIHN0cnVjdHVyZSB0byByZXNpemViYXIgKi9cclxuICAgICAgICAgICAgaWYgKGNvbnRleHQudXNlci5zaG93UGF0aExhYmVsKSBjb250ZXh0LmVsZW1lbnQubmF2aWdhdGlvbi50ZXh0Q29udGVudCA9IGVkaXRvci5fdmFyaWFibGUuY3VycmVudE5vZGVzLmpvaW4oJyA+ICcpO1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIHJlc2l6ZV93aW5kb3c6IGZ1bmN0aW9uICgpIH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Rvb2wvLnRlc3QoY2xhc3NOYW1lKSAmJiAhL3N1bi1lZGl0b3ItaWQtdG9vbGJhci8udGVzdChjbGFzc05hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICB0YXJnZXQgPSB0YXJnZXQucGFyZW50Tm9kZTtcclxuICAgICAgICAgICAgICAgIGNvbW1hbmQgPSB0YXJnZXQuZ2V0QXR0cmlidXRlKCdkYXRhLWNvbW1hbmQnKTtcclxuICAgICAgICAgICAgICAgIGRpc3BsYXkgPSB0YXJnZXQuZ2V0QXR0cmlidXRlKCdkYXRhLWRpc3BsYXknKTtcclxuICAgICAgICAgICAgICAgIGNsYXNzTmFtZSA9IHRhcmdldC5jbGFzc05hbWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICghY29tbWFuZCAmJiAhZGlzcGxheSkgcmV0dXJuO1xyXG4gICAgICAgICAgICBcclxuICAgICAgICAgICAgLyoqIERpYWxvZywgU3VibWVudSAqL1xyXG4gICAgICAgICAgICBpZiAoZGlzcGxheSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKC9zdWJtZW51Ly50ZXN0KGRpc3BsYXkpICYmICh0YXJnZXQubmV4dEVsZW1lbnRTaWJsaW5nID09PSBudWxsIHx8IHRhcmdldCAhPT0gZWRpdG9yLnN1Ym1lbnVBY3RpdmVCdXR0b24pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnN1Ym1lbnVPZmYoKTtcclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbihjb21tYW5kLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zdWJtZW51T24odGFyZ2V0KTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBlbHNlIGlmICgvZGlhbG9nLy50ZXN0KGRpc3BsYXkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oY29tbWFuZCwgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucGx1Z2lucy5kaWFsb2cub3BlbkRpYWxvZy5jYWxsKGVkaXRvciwgY29tbWFuZCwgdGFyZ2V0LmdldEF0dHJpYnV0ZSgnZGF0YS1vcHRpb24nKSwgZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGVkaXRvci5zdWJtZW51T2ZmKCk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGVkaXRvci5zdWJtZW51T2ZmKCk7XHJcblxyXG4gICAgICAgICAgICAvKiogZGVmYXVsdCBjb21tYW5kICovXHJcbiAgICAgICAgICAgIGlmIChjb21tYW5kKSB7XHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuZm9jdXMoKTtcclxuXHJcbiAgICAgICAgICAgICAgICBzd2l0Y2ggKGNvbW1hbmQpIHtcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdjb2RlVmlldyc6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50b2dnbGVDb2RlVmlldygpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKHRhcmdldCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ2Z1bGxTY3JlZW4nOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudG9nZ2xlRnVsbFNjcmVlbih0YXJnZXQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnRvZ2dsZUNsYXNzKHRhcmdldCwgJ29uJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ2luZGVudCc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnb3V0ZGVudCc6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pbmRlbnQoZWRpdG9yLl92YXJpYWJsZS5zZWxlY3Rpb25Ob2RlLCBjb21tYW5kKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncmVkbyc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAndW5kbyc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncmVtb3ZlRm9ybWF0JzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmV4ZWNDb21tYW5kKGNvbW1hbmQsIGZhbHNlLCBudWxsKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncHJldmlldyc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncHJpbnQnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iub3BlbldpbmRvd0NvbnRlbnRzKGNvbW1hbmQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdzaG93QmxvY2tzJzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnRvZ2dsZURpc3BsYXlCbG9ja3MoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdzdWJzY3JpcHQnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodXRpbC5oYXNDbGFzcyhjb250ZXh0LnRvb2wuc3VwZXJzY3JpcHQsICdvbicpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZXhlY0NvbW1hbmQoJ3N1cGVyc2NyaXB0JywgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC5yZW1vdmVDbGFzcyhjb250ZXh0LnRvb2wuc3VwZXJzY3JpcHQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5leGVjQ29tbWFuZChjb21tYW5kLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3ModGFyZ2V0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnc3VwZXJzY3JpcHQnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodXRpbC5oYXNDbGFzcyhjb250ZXh0LnRvb2wuc3Vic2NyaXB0LCAnb24nKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmV4ZWNDb21tYW5kKCdzdWJzY3JpcHQnLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1dGlsLnJlbW92ZUNsYXNzKGNvbnRleHQudG9vbC5zdWJzY3JpcHQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5leGVjQ29tbWFuZChjb21tYW5kLCBmYWxzZSwgbnVsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHV0aWwudG9nZ2xlQ2xhc3ModGFyZ2V0LCAnb24nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdCA6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5leGVjQ29tbWFuZChjb21tYW5kLCBmYWxzZSwgdGFyZ2V0LmdldEF0dHJpYnV0ZSgnZGF0YS12YWx1ZScpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyh0YXJnZXQsICdvbicpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgb25Nb3VzZVVwX3d5c2l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcblxyXG4gICAgICAgICAgICBjb25zdCB0YXJnZXRFbGVtZW50ID0gZS50YXJnZXQ7XHJcbiAgICAgICAgICAgIGVkaXRvci5zdWJtZW51T2ZmKCk7XHJcblxyXG4gICAgICAgICAgICBpZiAoL15IVE1MJC9pLnRlc3QodGFyZ2V0RWxlbWVudC5ub2RlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIGVkaXRvci5mb2N1cygpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoL15JTUckL2kudGVzdCh0YXJnZXRFbGVtZW50Lm5vZGVOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmNhbGxQbHVnaW4oJ2ltYWdlJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBlZGl0b3IucGx1Z2lucy5kaWFsb2cuY2FsbF9jb250cm9sbGVyX3Jlc2l6ZS5jYWxsKGVkaXRvciwgdGFyZ2V0RWxlbWVudCwgJ2ltYWdlJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnBsdWdpbnMuaW1hZ2Uub25Nb2RpZnlNb2RlLmNhbGwoZWRpdG9yLCB0YXJnZXRFbGVtZW50LCBzaXplKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBlZGl0b3IuX3NldEVkaXRvclJhbmdlKCk7XHJcbiAgICAgICAgICAgIGV2ZW50Ll9maW5kQnV0dG9uRWZmZWN0VGFnKCk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgb25LZXlEb3duX3d5c2l3eWc6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIC8vIGVkaXRvci5fc2V0U2VsZWN0aW9uTm9kZSgpO1xyXG5cclxuICAgICAgICAgICAgY29uc3Qga2V5Q29kZSA9IGUua2V5Q29kZTtcclxuICAgICAgICAgICAgY29uc3Qgc2hpZnQgPSBlLnNoaWZ0S2V5O1xyXG4gICAgICAgICAgICBjb25zdCBjdHJsID0gZS5jdHJsS2V5IHx8IGUubWV0YUtleTtcclxuICAgICAgICAgICAgY29uc3QgYWx0ID0gZS5hbHRLZXk7XHJcbiAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcblxyXG4gICAgICAgICAgICBmdW5jdGlvbiBzaG9ydGN1dENvbW1hbmQoa2V5Q29kZSkge1xyXG4gICAgICAgICAgICAgICAgY29uc3Qga2V5ID0gZXZlbnQuX3Nob3J0Y3V0S2V5Q29kZVtrZXlDb2RlXTtcclxuICAgICAgICAgICAgICAgIGlmICgha2V5KSByZXR1cm4gZmFsc2U7XHJcblxyXG4gICAgICAgICAgICAgICAgZWRpdG9yLmV4ZWNDb21tYW5kKGtleVswXSwgZmFsc2UsIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgdXRpbC50b2dnbGVDbGFzcyhlZGl0b3IuY29tbWFuZE1hcFtrZXlbMV1dLCAnb24nKTtcclxuXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLyoqIFNob3J0Y3V0cyAqL1xyXG4gICAgICAgICAgICBpZiAoY3RybCAmJiAhL14oPzoxNnwxN3wxOCkkLy50ZXN0KGtleUNvZGUpKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIShzaGlmdCAmJiBrZXlDb2RlICE9PSA4MykgJiYgc2hvcnRjdXRDb21tYW5kKGtleUNvZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLyoqIGRlZmF1bHQga2V5IGFjdGlvbiAqL1xyXG4gICAgICAgICAgICBzd2l0Y2ggKGtleUNvZGUpIHtcclxuICAgICAgICAgICAgICAgIGNhc2UgODogLyoqYmFja3NwYWNlIGtleSovXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHV0aWwuaXNGb3JtYXRFbGVtZW50KGVkaXRvci5fdmFyaWFibGUuc2VsZWN0aW9uTm9kZSkgJiYgZWRpdG9yLl92YXJpYWJsZS5zZWxlY3Rpb25Ob2RlLnByZXZpb3VzU2libGluZyA9PT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5fdmFyaWFibGUuc2VsZWN0aW9uTm9kZS5pbm5lckhUTUwgPSAnJiM2NTI3OSc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICBjYXNlIDk6XHJcbiAgICAgICAgICAgICAgICAgICAgLyoqdGFiIGtleSovXHJcbiAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChjdHJsIHx8IGFsdCkgYnJlYWs7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjdXJyZW50Tm9kZSA9IGVkaXRvci5fdmFyaWFibGUuc2VsZWN0aW9uTm9kZSB8fCBlZGl0b3IuZ2V0U2VsZWN0aW9uTm9kZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHdoaWxlICghL15URCQvaS50ZXN0KGN1cnJlbnROb2RlLnRhZ05hbWUpICYmICF1dGlsLmlzV3lzaXd5Z0RpdihjdXJyZW50Tm9kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudE5vZGUgPSBjdXJyZW50Tm9kZS5wYXJlbnROb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnROb2RlICYmIC9eVEQkL2kudGVzdChjdXJyZW50Tm9kZS50YWdOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IHV0aWwuZ2V0UGFyZW50RWxlbWVudChjdXJyZW50Tm9kZSwgJ3RhYmxlJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNlbGxzID0gdXRpbC5nZXRMaXN0Q2hpbGRyZW4odGFibGUsIHV0aWwuaXNDZWxsKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlkeCA9IHNoaWZ0ID8gdXRpbC5wcmV2SWR4KGNlbGxzLCBjdXJyZW50Tm9kZSkgOiB1dGlsLm5leHRJZHgoY2VsbHMsIGN1cnJlbnROb2RlKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpZHggPT09IGNlbGxzLmxlbmd0aCAmJiAhc2hpZnQpIGlkeCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpZHggPT09IC0xICYmIHNoaWZ0KSBpZHggPSBjZWxscy5sZW5ndGggLSAxO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbW92ZUNlbGwgPSBjZWxsc1tpZHhdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1vdmVDZWxsKSByZXR1cm4gZmFsc2U7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UmFuZ2UobW92ZUNlbGwsIDAsIG1vdmVDZWxsLCAwKVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvKiogaWYgUCBUYWcgKi9cclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2hpZnQpIGJyZWFrO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJUZXh0ID0gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUobmV3IEFycmF5KGVkaXRvci5fdmFyaWFibGUudGFiU2l6ZSArIDEpLmpvaW4oJ1xcdTAwQTAnKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmluc2VydE5vZGUodGFiVGV4dCk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFJhbmdlKHRhYlRleHQsIGVkaXRvci5fdmFyaWFibGUudGFiU2l6ZSwgdGFiVGV4dCwgZWRpdG9yLl92YXJpYWJsZS50YWJTaXplKVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIG9uS2V5VXBfd3lz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5ZzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBlZGl0b3IuY29udHJvbGxlcnNPZmYoKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBvbkRyb3Bfd3lzaXd5ZzogZnVuY3Rpb24gKGUpIHtcclxuICAgICAgICAgICAgY29uc3QgZmlsZXMgPSBlLmRhdGFUcmFuc2Zlci5maWxlcztcclxuXHJcbiAgICAgICAgICAgIGlmIChmaWxlcy5sZW5ndGggPT09IDApIHJldHVybiB0cnVlO1xyXG5cclxuICAgICAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKTtcclxuICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICBcclxuICAgICAgICAgICAgaWYgKGVkaXRvci5wbHVnaW5zLmltYWdlKSB7XHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuZm9jdXMoKTtcclxuXHJcbiAgICAgICAgICAgICAgICBlZGl0b3IuY2FsbFBsdWdpbignaW1hZ2UnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGV4dC5pbWFnZS5pbWdJbnB1dEZpbGUuZmlsZXMgPSBmaWxlcztcclxuICAgICAgICAgICAgICAgICAgICBlZGl0b3IucGx1Z2lucy5pbWFnZS5vblJlbmRlcl9pbWdJbnB1dC5jYWxsKGVkaXRvcik7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGV4dC5pbWFnZS5pbWdJbnB1dEZpbGUuZmlsZXMgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICBvbk1vdXNlRG93bl9yZXNpemVCYXI6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcblxyXG4gICAgICAgICAgICBlZGl0b3IuX3ZhcmlhYmxlLnJlc2l6ZUNsaWVudFkgPSB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ICAgICAgaWYgKGVkaXRvci5fdmFyaWFibGUud3lzaXd5Z0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lm9yaWdpbkVsZW1lbnQudmFsdWUgPSBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5pbm5lckhUTUw7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQub3JpZ2luRWxlbWVudC52YWx1ZSA9IGNvbnRleHQuZWxlbWVudC5jb2RlLnZhbHVlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEdldHMgdGhlIHN1bmVkaXRvcidzIGNvbnRleHQgb2JqZWN0LiBDb250YWlucyBzZXR0aW5ncywgcGx1Z2lucywgYW5kIGNhY2hlZCBlbGVtZW50IG9iamVjdHNcclxuICAgICAgICAgKiBAcmV0dXJucyB7T2JqZWN0fVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGdldENvbnRleHQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgcmV0dXJuIGNvbnRleHQ7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEdldHMgdGhlIGNvbnRlbnRzIG9mIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKiBAcmV0dXJucyB7U3RyaW5nfVxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGdldENvbnRlbnQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSAnJztcclxuXHJcbiAgICAgICAgICAgIGlmIChjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5pbm5lclRleHQudHJpbSgpLmxlbmd0aCA9PT0gMCkgcmV0dXJuIGNvbnRlbnQ7XHJcblxyXG4gICAgICAgICAgICBpZiAoZWRpdG9yLl92YXJpYWJsZS53eXNpd3lnQWN0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZW50ID0gY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGVudCA9IGNvbnRleHQuZWxlbWVudC5jb2RlLnZhbHVlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiBjb250ZW50O1xyXG4gICAgICAgIH0sXHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEBkZXNjcmlwdGlvbiBDaGFuZ2UgdGhlIGNvbnRlbnRzIG9mIHRoZSBzdW5lZGl0b3JcclxuICAgICAgICAgKiBAcGFyYW0ge1N0cmluZ30gY29udGVudCAtIENvbnRlbnQgdG8gSW5wdXRcclxuICAgICAgICAgKi9cclxuICAgICAgICBzZXRDb250ZW50OiBmdW5jdGlvbiAoY29udGVudCkge1xyXG4gICAgICAgICAgICBjb25zdCBpbm5lckhUTUwgPSB1dGlsLmNvbnZlcnRDb250ZW50Rm9yRWRpdG9yKGNvbnRlbnQpO1xyXG5cclxuICAgICAgICAgICAgaWYgKGVkaXRvci5fdmFyaWFibGUud3lzaXd5Z0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuaW5uZXJIVE1MID0gaW5uZXJIVE1MO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LmNvZGUudmFsdWUgPSBpbm5lckhUTUw7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gQWRkIGNvbnRlbnQgdG8gdGhlIHN1bmVkaXRvclxyXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfSBjb250ZW50IC0gdG8gSW5wdXRcclxuICAgICAgICAgKi9cclxuICAgICAgICBhcHBlbmRDb250ZW50OiBmdW5jdGlvbiAoY29udGVudCkge1xyXG4gICAgICAgICAgICBpZiAoZWRpdG9yLl92YXJpYWJsZS53eXNpd3lnQWN0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBvUCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ1AnKTtcclxuICAgICAgICAgICAgICAgIG9QLmlubmVySFRNTCA9IGNvbnRlbnQ7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5hcHBlbmRDaGlsZChvUCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQuY29kZS52YWx1ZSArPSBvUC5vdXRlckhUTUw7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRGlzYWJsZSB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZGlzYWJsZWQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29udGV4dC50b29sLmNvdmVyLnN0eWxlLmRpc3BsYXkgPSAnYmxvY2snO1xyXG4gICAgICAgICAgICBjb250ZXh0LmVsZW1lbnQud3lzaXd5Zy5zZXRBdHRyaWJ1dGUoJ2NvbnRlbnRlZGl0YWJsZScsIGZhbHNlKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRW5hYmxlZCB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZW5hYmxlZDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb250ZXh0LnRvb2wuY292ZXIuc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICAgICAgY29udGV4dC5lbGVtZW50Lnd5c2l3eWcuc2V0QXR0cmlidXRlKCdjb250ZW50ZWRpdGFibGUnLCB0cnVlKTtcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gU2hvdyB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgc2hvdzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBjb25zdCB0b3BBcmVhU3R5bGUgPSBjb250ZXh0LmVsZW1lbnQudG9wQXJlYS5zdHlsZTtcclxuICAgICAgICAgICAgaWYgKHRvcEFyZWFTdHlsZS5kaXNwbGF5ID09PSAnbm9uZScpIHRvcEFyZWFTdHlsZS5kaXNwbGF5ID0gY29udGV4dC51c2VyLmRpc3BsYXk7XHJcbiAgICAgICAgfSxcclxuXHJcbiAgICAgICAgLyoqXHJcbiAgICAgICAgICogQGRlc2NyaXB0aW9uIEhpZGUgdGhlIHN1bmVkaXRvclxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIGhpZGU6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgY29udGV4dC5lbGVtZW50LnRvcEFyZWEuc3R5bGUuZGlzcGxheSA9ICdub25lJztcclxuICAgICAgICB9LFxyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBAZGVzY3JpcHRpb24gRGVzdHJveSB0aGUgc3VuZWRpdG9yXHJcbiAgICAgICAgICovXHJcbiAgICAgICAgZGVzdHJveTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAvKiogcmVtb3ZlIHdpbmRvdyBldmVudCBsaXN0ZW5lcnMgKi9cclxuICAgICAgICAgICAgd2luZG93LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ3Jlc2l6ZScsIGV2ZW50LnJlc2l6ZV93aW5kb3cpO1xyXG4gICAgICAgICAgICBcclxuICAgICAgICAgICAgLyoqIHJlbW92ZS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7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7O0FBSUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7O0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7QUFHQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7OztBQUdBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7O0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7O0FBR0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUFBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQXBIQTtBQXNIQTtBQUNBO0FBQ0EiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./src/lib/core.js\n"); /***/ }), @@ -166,7 +166,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n/**\r\n * @description util /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/util */ \"./src/lib/util.js\");\n/* harmony import */ var _lib_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/core */ \"./src/lib/core.js\");\n/* harmony import */ var _lib_constructor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/constructor */ \"./src/lib/constructor.js\");\n/* harmony import */ var _lib_context__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/context */ \"./src/lib/context.js\");\n/* harmony import */ var _lang_en__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lang/en */ \"./src/lang/en.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\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n util: _lib_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n core: _lib_core__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n _Constructor: _lib_constructor__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n _Context: _lib_context__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n _defaultLang: _lang_en__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n\n /**\r\n * @description Returns the create function with preset options.\r\n * If the options overlap, the options of the 'create' function take precedence.\r\n * @param {Json} options - Initialization options\r\n * @returns {function}\r\n */\n init: function (init_options) {\n const self = this;\n return {\n create: function (idOrElement, options) {\n return self.create(idOrElement, options, init_options);\n }\n };\n },\n\n /**\r\n * @description Create the suneditor\r\n * @param {String|Element} idOrElement - textarea Id or textarea element\r\n * @param {Json} options - user options\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 create: function (idOrElement, options, _init_options) {\n if (typeof options !== 'object') options = {};\n\n if (_init_options) {\n options = Object.assign(this.util.copyObj(_init_options), options);\n }\n\n const element = typeof idOrElement === 'string' ? document.getElementById(idOrElement) : idOrElement;\n\n if (!element) {\n if (typeof idOrElement === 'string') {\n throw Error('[SUNEDITOR.create.fail] The element for that id was not found (ID:\"' + idOrElement + '\")');\n }\n\n throw Error('[SUNEDITOR.create.fail] suneditor requires textarea\\'s element or id value');\n }\n\n const cons = this._Constructor.init(element, options, options.lang || this._defaultLang, options.plugins, this.util.convertContentForEditor);\n\n if (document.getElementById(cons.constructed._top.id)) {\n throw Error('[SUNEDITOR.create.fail] The ID of the suneditor you are trying to create already exists (ID:\"' + cons.constructed._top.id + '\")');\n }\n\n element.style.display = 'none';\n cons.constructed._top.style.display = 'block';\n /** Create to sibling node */\n\n if (typeof element.nextElementSibling === 'object') {\n element.parentNode.insertBefore(cons.constructed._top, element.nextElementSibling);\n } else {\n element.parentNode.appendChild(cons.constructed._top);\n }\n\n return this.core(this._Context(element, cons.constructed, cons.options), this.util, options.modules, cons.plugins, cons.options.lang);\n }\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvc3VuZWRpdG9yLmpzLmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vLy4vc3JjL3N1bmVkaXRvci5qcz9iNTliIl0sInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIHd5c2l3eWcgd2ViIGVkaXRvclxyXG4gKlxyXG4gKiBzdW5lZGl0b3IuanNcclxuICogQ29weXJpZ2h0IDIwMTcgSmlIb25nIExlZS5cclxuICogTUlUIGxpY2Vuc2UuXHJcbiAqL1xyXG4ndXNlIHN0cmljdCc7XHJcblxyXG5pbXBvcnQgdXRpbCBmcm9tICcuL2xpYi91dGlsJztcclxuaW1wb3J0IGNvcmUgZnJvbSAnLi9saWIvY29yZSc7XHJcbmltcG9ydCBfQ29uc3RydWN0b3IgZnJvbSAnLi9saWIvY29uc3RydWN0b3InO1xyXG5pbXBvcnQgX0NvbnRleHQgZnJvbSAnLi9saWIvY29udGV4dCc7XHJcbmltcG9ydCBfZGVmYXVsdExhbmcgZnJvbSAnLi9sYW5nL2VuJ1xyXG5cclxuXHJcbmV4cG9ydCBkZWZhdWx0IHtcclxuICAgIHV0aWwsXHJcbiAgICBjb3JlLFxyXG4gICAgX0NvbnN0cnVjdG9yLFxyXG4gICAgX0NvbnRleHQsXHJcbiAgICBfZGVmYXVsdExhbmcsXHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAZGVzY3JpcHRpb24gUmV0dXJucyB0aGUgY3JlYXRlIGZ1bmN0aW9uIHdpdGggcHJlc2V0IG9wdGlvbnMuXHJcbiAgICAgKiBJZiB0aGUgb3B0aW9ucyBvdmVybGFwLCB0aGUgb3B0aW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zLCBjb25zLnBsdWdpbnMsIGNvbnMub3B0aW9ucy5sYW5nKTtcclxuICAgIH1cclxufTtcclxuIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTs7Ozs7OztBQU9BO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7Ozs7O0FBTUE7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBSEE7QUFLQTtBQUNBO0FBQ0E7Ozs7OztBQU1BO0FBQ0E7QUFDQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUE5REEiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./src/suneditor.js\n"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _lib_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/util */ \"./src/lib/util.js\");\n/* harmony import */ var _lib_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/core */ \"./src/lib/core.js\");\n/* harmony import */ var _lib_constructor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/constructor */ \"./src/lib/constructor.js\");\n/* harmony import */ var _lib_context__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/context */ \"./src/lib/context.js\");\n/* harmony import */ var _lang_en__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lang/en */ \"./src/lang/en.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\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n util: _lib_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n core: _lib_core__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n _Constructor: _lib_constructor__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n _Context: _lib_context__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n _defaultLang: _lang_en__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n\n /**\r\n * @description Returns the create function with preset options.\r\n * If the options overlap, the options of the 'create' function take precedence.\r\n * @param {Json} options - Initialization options\r\n * @returns {function}\r\n */\n init: function (init_options) {\n const self = this;\n return {\n create: function (idOrElement, options) {\n return self.create(idOrElement, options, init_options);\n }\n };\n },\n\n /**\r\n * @description Create the suneditor\r\n * @param {String|Element} idOrElement - textarea Id or textarea element\r\n * @param {Json} options - user options\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 create: function (idOrElement, options, _init_options) {\n if (typeof options !== 'object') options = {};\n\n if (_init_options) {\n options = Object.assign(this.util.copyObj(_init_options), options);\n }\n\n const element = typeof idOrElement === 'string' ? document.getElementById(idOrElement) : idOrElement;\n\n if (!element) {\n if (typeof idOrElement === 'string') {\n throw Error('[SUNEDITOR.create.fail] The element for that id was not found (ID:\"' + idOrElement + '\")');\n }\n\n throw Error('[SUNEDITOR.create.fail] suneditor requires textarea\\'s element or id value');\n }\n\n const cons = this._Constructor.init(element, options, options.lang || this._defaultLang, options.plugins, this.util.convertContentForEditor);\n\n if (document.getElementById(cons.constructed._top.id)) {\n throw Error('[SUNEDITOR.create.fail] The ID of the suneditor you are trying to create already exists (ID:\"' + cons.constructed._top.id + '\")');\n }\n\n element.style.display = 'none';\n cons.constructed._top.style.display = 'block';\n /** Create to sibling node */\n\n if (typeof element.nextElementSibling === 'object') {\n element.parentNode.insertBefore(cons.constructed._top, element.nextElementSibling);\n } else {\n element.parentNode.appendChild(cons.constructed._top);\n }\n\n return this.core(this._Context(element, cons.constructed, cons.options), this.util, cons.plugins, cons.options.lang);\n }\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvc3VuZWRpdG9yLmpzLmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vLy4vc3JjL3N1bmVkaXRvci5qcz9iNTliIl0sInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIHd5c2l3eWcgd2ViIGVkaXRvclxyXG4gKlxyXG4gKiBzdW5lZGl0b3IuanNcclxuICogQ29weXJpZ2h0IDIwMTcgSmlIb25nIExlZS5cclxuICogTUlUIGxpY2Vuc2UuXHJcbiAqL1xyXG4ndXNlIHN0cmljdCc7XHJcblxyXG5pbXBvcnQgdXRpbCBmcm9tICcuL2xpYi91dGlsJztcclxuaW1wb3J0IGNvcmUgZnJvbSAnLi9saWIvY29yZSc7XHJcbmltcG9ydCBfQ29uc3RydWN0b3IgZnJvbSAnLi9saWIvY29uc3RydWN0b3InO1xyXG5pbXBvcnQgX0NvbnRleHQgZnJvbSAnLi9saWIvY29udGV4dCc7XHJcbmltcG9ydCBfZGVmYXVsdExhbmcgZnJvbSAnLi9sYW5nL2VuJ1xyXG5cclxuXHJcbmV4cG9ydCBkZWZhdWx0IHtcclxuICAgIHV0aWwsXHJcbiAgICBjb3JlLFxyXG4gICAgX0NvbnN0cnVjdG9yLFxyXG4gICAgX0NvbnRleHQsXHJcbiAgICBfZGVmYXVsdExhbmcsXHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAZGVzY3JpcHRpb24gUmV0dXJucyB0aGUgY3JlYXRlIGZ1bmN0aW9uIHdpdGggcHJlc2V0IG9wdGlvbnMuXHJcbiA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vbnMub3B0aW9ucyksIHRoaXMudXRpbCwgY29ucy5wbHVnaW5zLCBjb25zLm9wdGlvbnMubGFuZyk7XHJcbiAgICB9XHJcbn07XHJcbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7Ozs7Ozs7QUFPQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUdBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Ozs7OztBQU1BO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUhBO0FBS0E7QUFDQTtBQUNBOzs7Ozs7QUFNQTtBQUNBO0FBQ0E7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBOURBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./src/suneditor.js\n"); /***/ }), diff --git a/sample/html/getting-started.html b/sample/html/getting-started.html index 868c7d2af..d56daa06c 100644 --- a/sample/html/getting-started.html +++ b/sample/html/getting-started.html @@ -97,7 +97,7 @@

1. Default options

// insert options }); -

2. Load plugins

+

2. Load only what you want

import 'suneditor/dist/css/suneditor.min.css'
 import suneditor from 'suneditor'
 import {en, ko} from 'suneditor/src/lang'
@@ -134,7 +134,7 @@ 

3. Load all plugins

import plugins from 'suneditor/src/plugins' suneditor.create('sample', { - modules: plugins, + plugins: plugins, buttonList: [ ['undo', 'redo'], ['font', 'fontSize', 'formatBlock'], @@ -148,6 +148,20 @@

3. Load all plugins

['fullScreen', 'showBlocks', 'codeView'], ['preview', 'print'] ] +}) + +// You can also load what you want +suneditor.create('sample', { + plugins: [ + plugins.font + plugins.fontSize, + plugins.formatBlock + ], + buttonList: [ + ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'], + ['font', 'fontSize', 'formatBlock'], + ['removeFormat'] + ] })

4. Plugins can be used directly in the button list

diff --git a/src/lib/context.js b/src/lib/context.js index fff8baba7..f131e307c 100644 --- a/src/lib/context.js +++ b/src/lib/context.js @@ -45,7 +45,8 @@ const _Context = function (element, cons, options) { font: options.font, fontSize: options.fontSize, height: options.height.match(/\d+/)[0], - showPathLabel: options.showPathLabel + showPathLabel: options.showPathLabel, + display: options.display }, dialog: {}, submenu: {} diff --git a/src/lib/core.js b/src/lib/core.js index c7ce8efe4..80451c124 100644 --- a/src/lib/core.js +++ b/src/lib/core.js @@ -4,12 +4,11 @@ * @description SunEditor core closure * @param context * @param util - * @param modules * @param plugins * @param lang * @returns {{save: save, getContext: getContext, getContent: getContent, setContent: setContent, appendContent: appendContent, disabled: disabled, enabled: enabled, show: show, hide: hide, destroy: destroy}} */ -const core = function (context, util, modules, plugins, lang) { +const core = function (context, util, plugins, lang) { /** * @description Practical editor function * This function is 'this' used by other plugins @@ -20,11 +19,6 @@ const core = function (context, util, modules, plugins, lang) { */ context: context, - /** - * @description loaded modules - */ - modules: {}, - /** * @description loaded plugins */ @@ -1555,8 +1549,7 @@ const core = function (context, util, modules, plugins, lang) { */ show: function () { const topAreaStyle = context.element.topArea.style; - topAreaStyle.cssText = editor._variable.originCssText; - if (topAreaStyle.display === 'none') topAreaStyle.display = 'block'; + if (topAreaStyle.display === 'none') topAreaStyle.display = context.user.display; }, /** diff --git a/src/suneditor.js b/src/suneditor.js index 5dc290be9..ae02ac957 100644 --- a/src/suneditor.js +++ b/src/suneditor.js @@ -75,6 +75,6 @@ export default { element.parentNode.appendChild(cons.constructed._top); } - return this.core(this._Context(element, cons.constructed, cons.options), this.util, options.modules, cons.plugins, cons.options.lang); + return this.core(this._Context(element, cons.constructed, cons.options), this.util, cons.plugins, cons.options.lang); } };