@zklogic/draw.io
Version:
Draw.IO - Graph Editor integration in Angular-cli
1 lines • 222 kB
JavaScript
!function(){EditorUi.VERSION="@DRAWIO-VERSION@",EditorUi.compactUi="atlas"!=uiTheme,Editor.isDarkMode()&&(mxGraphView.prototype.gridColor=mxGraphView.prototype.defaultDarkGridColor),EditorUi.enableLogging="1"!=urlParams.stealth&&"1"!=urlParams.lockdown&&(/.*\.draw\.io$/.test(window.location.hostname)||/.*\.diagrams\.net$/.test(window.location.hostname))&&"support.draw.io"!=window.location.hostname,EditorUi.drawHost=window.DRAWIO_BASE_URL,EditorUi.lightboxHost=window.DRAWIO_LIGHTBOX_URL,EditorUi.lastErrorMessage=null,EditorUi.ignoredAnonymizedChars="\n\t`~!@#$%^&*()_+{}|:\"<>?-=[];'./,\n\t",EditorUi.templateFile=TEMPLATE_PATH+"/index.xml",EditorUi.cacheUrl="1"==urlParams.dev?"/cache":window.REALTIME_URL,null==EditorUi.cacheUrl&&"undefined"!=typeof DrawioFile&&(DrawioFile.SYNC="none"),Editor.cacheTimeout=1e4,EditorUi.enablePlantUml=EditorUi.enableLogging,EditorUi.isElectronApp=null!=window&&null!=window.process&&null!=window.process.versions&&null!=window.process.versions.electron,EditorUi.nativeFileSupport=!mxClient.IS_OP&&!EditorUi.isElectronApp&&"1"!=urlParams.extAuth&&"showSaveFilePicker"in window&&"showOpenFilePicker"in window,EditorUi.enableDrafts=!mxClient.IS_CHROMEAPP&&isLocalStorage&&"0"!=urlParams.drafts,EditorUi.scratchpadHelpLink="https://www.diagrams.net/doc/faq/scratchpad",EditorUi.defaultMermaidConfig={theme:"neutral",arrowMarkerAbsolute:!1,flowchart:{htmlLabels:!1},sequence:{diagramMarginX:50,diagramMarginY:10,actorMargin:50,width:150,height:65,boxMargin:10,boxTextMargin:5,noteMargin:10,messageMargin:35,mirrorActors:!0,bottomMarginAdj:1,useMaxWidth:!0,rightAngles:!1,showSequenceNumbers:!1},gantt:{titleTopMargin:25,barHeight:20,barGap:4,topPadding:50,leftPadding:75,gridLineStartPadding:35,fontSize:11,fontFamily:'"Open-Sans", "sans-serif"',numberSectionStyles:4,axisFormat:"%Y-%m-%d"}},EditorUi.logError=function(e,t,i,n,l,r,s){if(r=null!=r?r:e.indexOf("NetworkError")>=0||e.indexOf("SecurityError")>=0||e.indexOf("NS_ERROR_FAILURE")>=0||e.indexOf("out of memory")>=0?"CONFIG":"SEVERE",EditorUi.enableLogging&&"1"!=urlParams.dev)try{if(e==EditorUi.lastErrorMessage||null!=e&&null!=t&&(-1!=e.indexOf("Script error")||-1!=e.indexOf("extension")));else if(null!=e&&e.indexOf("DocumentClosedError")<0){EditorUi.lastErrorMessage=e;var o=null!=window.DRAWIO_LOG_URL?window.DRAWIO_LOG_URL:"";l=null!=l?l:new Error(e),(new Image).src=o+"/log?severity="+r+"&v="+encodeURIComponent(EditorUi.VERSION)+"&msg=clientError:"+encodeURIComponent(e)+":url:"+encodeURIComponent(window.location.href)+":lnum:"+encodeURIComponent(i)+(null!=n?":colno:"+encodeURIComponent(n):"")+(null!=l&&null!=l.stack?"&stack="+encodeURIComponent(l.stack):"")}}catch(e){}try{s||null==window.console||console.error(r,e,t,i,n,l)}catch(e){}},EditorUi.logEvent=function(e){if("1"==urlParams.dev)EditorUi.debug("logEvent",e);else if(EditorUi.enableLogging)try{var t=null!=window.DRAWIO_LOG_URL?window.DRAWIO_LOG_URL:"";(new Image).src=t+"/images/1x1.png?v="+encodeURIComponent(EditorUi.VERSION)+(null!=e?"&data="+encodeURIComponent(JSON.stringify(e)):"")}catch(e){}},EditorUi.sendReport=function(e,t){if("1"==urlParams.dev)EditorUi.debug("sendReport",e);else if(EditorUi.enableLogging)try{t=null!=t?t:5e4,e.length>t&&(e=e.substring(0,t)+"\n...[SHORTENED]"),mxUtils.post("/email","version="+encodeURIComponent(EditorUi.VERSION)+"&url="+encodeURIComponent(window.location.href)+"&data="+encodeURIComponent(e))}catch(e){}},EditorUi.debug=function(){try{if(null!=window.console&&"1"==urlParams.test){for(var e=[(new Date).toISOString()],t=0;t<arguments.length;t++)null!=arguments[t]&&e.push(arguments[t]);console.log.apply(console,e)}}catch(e){}},EditorUi.removeChildNodes=function(e){for(;null!=e.firstChild;)e.removeChild(e.firstChild)},EditorUi.prototype.emptyDiagramXml='<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel>',EditorUi.prototype.emptyLibraryXml="<mxlibrary>[]</mxlibrary>",EditorUi.prototype.mode=null,EditorUi.prototype.timeout=Editor.prototype.timeout,EditorUi.prototype.sidebarFooterHeight=38,EditorUi.prototype.defaultCustomShapeStyle="shape=stencil(tZRtTsQgEEBPw1+DJR7AoN6DbWftpAgE0Ortd/jYRGq72R+YNE2YgTePloEJGWblgA18ZuKFDcMj5/Sm8boZq+BgjCX4pTyqk6ZlKROitwusOMXKQDODx5iy4pXxZ5qTHiFHawxB0JrQZH7lCabQ0Fr+XWC1/E8zcsT/gAi+Subo2/3Mh6d/oJb5nU1b5tW7r2knautaa3T+U32o7f7vZwpJkaNDLORJjcu7t59m2jXxqX9un+tt022acsfmoKaQZ+vhhswZtS6Ne/ThQGt0IV0N3Yyv6P3CeT9/tHO0XFI5cAE=);whiteSpace=wrap;html=1;",EditorUi.prototype.maxBackgroundSize=1600,EditorUi.prototype.maxImageSize=520,EditorUi.prototype.maxTextWidth=520,EditorUi.prototype.resampleThreshold=1e5,EditorUi.prototype.maxImageBytes=1e6,EditorUi.prototype.maxBackgroundBytes=25e5,EditorUi.prototype.maxTextBytes=5e5,EditorUi.prototype.currentFile=null,EditorUi.prototype.printPdfExport=!1,EditorUi.prototype.pdfPageExport=!0,EditorUi.prototype.formatEnabled="0"!=urlParams.format,EditorUi.prototype.insertTemplateEnabled=!0,EditorUi.prototype.closableScratchpad=!0,EditorUi.prototype.embedExportBorder=8,EditorUi.prototype.embedExportBackground=null,function(){EditorUi.prototype.useCanvasForExport=!1,EditorUi.prototype.jpgSupported=!1;try{var e=document.createElement("canvas");EditorUi.prototype.canvasSupported=!(!e.getContext||!e.getContext("2d"))}catch(e){}try{var t=document.createElement("canvas"),i=new Image;i.onload=function(){try{t.getContext("2d").drawImage(i,0,0);var e=t.toDataURL("image/png");EditorUi.prototype.useCanvasForExport=null!=e&&e.length>6}catch(e){}},i.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1px" height="1px" version="1.1"><foreignObject pointer-events="all" width="1" height="1"><div xmlns="http://www.w3.org/1999/xhtml"></div></foreignObject></svg>')))}catch(e){}try{(t=document.createElement("canvas")).width=t.height=1;var n=t.toDataURL("image/jpeg");EditorUi.prototype.jpgSupported=null!==n.match("image/jpeg")}catch(e){}}(),EditorUi.prototype.openLink=function(e,t,i){return this.editor.graph.openLink(e,t,i)},EditorUi.prototype.showSplash=function(e){},EditorUi.prototype.getLocalData=function(e,t){t(localStorage.getItem(e))},EditorUi.prototype.setLocalData=function(e,t,i){localStorage.setItem(e,t),null!=i&&i()},EditorUi.prototype.removeLocalData=function(e,t){localStorage.removeItem(e),t()},EditorUi.prototype.setMathEnabled=function(e){this.editor.graph.mathEnabled=e,this.editor.updateGraphComponents(),this.editor.graph.refresh(),this.editor.graph.defaultMathEnabled=e,this.fireEvent(new mxEventObject("mathEnabledChanged"))},EditorUi.prototype.isMathEnabled=function(e){return this.editor.graph.mathEnabled},EditorUi.prototype.isOfflineApp=function(){return"1"==urlParams.offline},EditorUi.prototype.isOffline=function(e){return this.isOfflineApp()||!navigator.onLine||!e&&("1"==urlParams.stealth||"1"==urlParams.lockdown)},EditorUi.prototype.createSpinner=function(e,t,i){var n=null==e||null==t;i=null!=i?i:24;var l=new Spinner({lines:12,length:i,width:Math.round(i/3),radius:Math.round(i/2),rotate:0,color:Editor.isDarkMode()?"#c0c0c0":"#000",speed:1.5,trail:60,shadow:!1,hwaccel:!1,zIndex:2e9}),r=l.spin;l.spin=function(i,s){var o=!1;if(!this.active){if(r.call(this,i),this.active=!0,null!=s){n&&(t=Math.max(document.body.clientHeight||0,document.documentElement.clientHeight||0)/2,e=document.body.clientWidth/2-2);var a=document.createElement("div");a.style.position="absolute",a.style.whiteSpace="nowrap",a.style.background="#4B4243",a.style.color="white",a.style.fontFamily=Editor.defaultHtmlFont,a.style.fontSize="9pt",a.style.padding="6px",a.style.paddingLeft="10px",a.style.paddingRight="10px",a.style.zIndex=2e9,a.style.left=Math.max(0,e)+"px",a.style.top=Math.max(0,t+70)+"px",mxUtils.setPrefixedStyle(a.style,"borderRadius","6px"),mxUtils.setPrefixedStyle(a.style,"transform","translate(-50%,-50%)"),Editor.isDarkMode()||mxUtils.setPrefixedStyle(a.style,"boxShadow","2px 2px 3px 0px #ddd"),"..."!=s.substring(s.length-3,s.length)&&"!"!=s.charAt(s.length-1)&&(s+="..."),a.innerHTML=s,i.appendChild(a),l.status=a}this.pause=mxUtils.bind(this,(function(){var e=function(){};return this.active&&(e=mxUtils.bind(this,(function(){this.spin(i,s)}))),this.stop(),e})),o=!0}return o};var s=l.stop;return l.stop=function(){s.call(this),this.active=!1,null!=l.status&&null!=l.status.parentNode&&l.status.parentNode.removeChild(l.status),l.status=null},l.pause=function(){return function(){}},l},EditorUi.prototype.isCompatibleString=function(e){try{var t=mxUtils.parseXml(e),i=this.editor.extractGraphModel(t.documentElement,!0);return null!=i&&0==i.getElementsByTagName("parsererror").length}catch(e){}return!1},EditorUi.prototype.isVisioData=function(e){return e.length>8&&(208==e.charCodeAt(0)&&207==e.charCodeAt(1)&&17==e.charCodeAt(2)&&224==e.charCodeAt(3)&&161==e.charCodeAt(4)&&177==e.charCodeAt(5)&&26==e.charCodeAt(6)&&225==e.charCodeAt(7)||80==e.charCodeAt(0)&&75==e.charCodeAt(1)&&3==e.charCodeAt(2)&&4==e.charCodeAt(3)||80==e.charCodeAt(0)&&75==e.charCodeAt(1)&&3==e.charCodeAt(2)&&6==e.charCodeAt(3))},EditorUi.prototype.isRemoteVisioData=function(e){return e.length>8&&(208==e.charCodeAt(0)&&207==e.charCodeAt(1)&&17==e.charCodeAt(2)&&224==e.charCodeAt(3)&&161==e.charCodeAt(4)&&177==e.charCodeAt(5)&&26==e.charCodeAt(6)&&225==e.charCodeAt(7)||60==e.charCodeAt(0)&&63==e.charCodeAt(1)&&120==e.charCodeAt(2)&&109==e.charCodeAt(3)&&108==e.charCodeAt(3))};var e=EditorUi.prototype.createKeyHandler;EditorUi.prototype.createKeyHandler=function(t){var i=e.apply(this,arguments);if(!this.editor.chromeless||this.editor.editable){var n=i.getFunction,l=this.editor.graph,r=this;i.getFunction=function(e){if(l.isSelectionEmpty()&&null!=r.pages&&r.pages.length>0){var t=r.getSelectedPageIndex();if(mxEvent.isShiftDown(e)){if(37==e.keyCode)return function(){t>0&&r.movePage(t,t-1)};if(38==e.keyCode)return function(){t>0&&r.movePage(t,0)};if(39==e.keyCode)return function(){t<r.pages.length-1&&r.movePage(t,t+1)};if(40==e.keyCode)return function(){t<r.pages.length-1&&r.movePage(t,r.pages.length-1)}}else if(mxEvent.isControlDown(e)||mxClient.IS_MAC&&mxEvent.isMetaDown(e)){if(37==e.keyCode)return function(){t>0&&r.selectNextPage(!1)};if(38==e.keyCode)return function(){t>0&&r.selectPage(r.pages[0])};if(39==e.keyCode)return function(){t<r.pages.length-1&&r.selectNextPage(!0)};if(40==e.keyCode)return function(){t<r.pages.length-1&&r.selectPage(r.pages[r.pages.length-1])}}}return n.apply(this,arguments)}}return i};var t=EditorUi.prototype.extractGraphModelFromHtml;EditorUi.prototype.extractGraphModelFromHtml=function(e){var i=t.apply(this,arguments);if(null==i)try{var n=e.indexOf("<mxfile ");if(n>=0){var l=e.lastIndexOf("</mxfile>");l>n&&(i=e.substring(n,l+15).replace(/>/g,">").replace(/</g,"<").replace(/\\"/g,'"').replace(/\n/g,""))}else{var r=mxUtils.parseXml(e),s=this.editor.extractGraphModel(r.documentElement,null!=this.pages||"hidden"==this.diagramContainer.style.visibility);i=null!=s?mxUtils.getXml(s):""}}catch(e){}return i},EditorUi.prototype.validateFileData=function(e){if(null!=e&&e.length>0){var t=e.indexOf('<meta charset="utf-8">');if(t>=0){var i='<meta charset="utf-8"/>',n=i.length;e=e.slice(0,t)+i+e.slice(t+n-1,e.length)}e=Graph.zapGremlins(e)}return e},EditorUi.prototype.replaceFileData=function(e){var t=null!=(e=this.validateFileData(e))&&e.length>0?mxUtils.parseXml(e).documentElement:null,i=null!=t?this.editor.extractGraphModel(t,!0):null;if(null!=i&&(t=i),null!=t){var n=this.editor.graph;n.model.beginUpdate();try{var l=null!=this.pages?this.pages.slice():null,r=t.getElementsByTagName("diagram");if("0"!=urlParams.pages||r.length>1||1==r.length&&r[0].hasAttribute("name")){this.fileNode=t,this.pages=null!=this.pages?this.pages:[];for(var s=r.length-1;s>=0;s--){var o=this.updatePageRoot(new DiagramPage(r[s]));null==o.getName()&&o.setName(mxResources.get("pageWithNumber",[s+1])),n.model.execute(new ChangePage(this,o,0==s?o:null,0))}}else"0"!=urlParams.pages&&null==this.fileNode&&(this.fileNode=t.ownerDocument.createElement("mxfile"),this.currentPage=new DiagramPage(t.ownerDocument.createElement("diagram")),this.currentPage.setName(mxResources.get("pageWithNumber",[1])),n.model.execute(new ChangePage(this,this.currentPage,this.currentPage,0))),this.editor.setGraphXml(t),null!=this.currentPage&&(this.currentPage.root=this.editor.graph.model.root);if(null!=l)for(s=0;s<l.length;s++)n.model.execute(new ChangePage(this,l[s],null))}finally{n.model.endUpdate()}}},EditorUi.prototype.createFileData=function(e,t,i,n,l,r,s,o,a,d,u){t=null!=t?t:this.editor.graph,l=null!=l&&l,a=null==a||a;var h=null,m=null;if(null==i||i.getMode()==App.MODE_DEVICE||i.getMode()==App.MODE_BROWSER?h="_blank":m=h=n,null==e)return"";var g=e;if("mxfile"!=g.nodeName.toLowerCase())if(u)(c=e.ownerDocument.createElement("diagram")).setAttribute("id",Editor.guid()),c.appendChild(e),(g=e.ownerDocument.createElement("mxfile")).appendChild(c);else{var c,p=Graph.zapGremlins(mxUtils.getXml(e)),f=Graph.compress(p);if(Graph.decompress(f)!=p)return p;(c=e.ownerDocument.createElement("diagram")).setAttribute("id",Editor.guid()),mxUtils.setTextContent(c,f),(g=e.ownerDocument.createElement("mxfile")).appendChild(c)}if(d)(g=g.cloneNode(!0)).removeAttribute("modified"),g.removeAttribute("host"),g.removeAttribute("agent"),g.removeAttribute("etag"),g.removeAttribute("userAgent"),g.removeAttribute("version"),g.removeAttribute("editor"),g.removeAttribute("type");else{g.removeAttribute("userAgent"),g.removeAttribute("version"),g.removeAttribute("editor"),g.removeAttribute("pages"),g.removeAttribute("type"),mxClient.IS_CHROMEAPP?g.setAttribute("host","Chrome"):EditorUi.isElectronApp?g.setAttribute("host","Electron"):g.setAttribute("host",window.location.hostname),g.setAttribute("modified",(new Date).toISOString()),g.setAttribute("agent",navigator.appVersion),g.setAttribute("version",EditorUi.VERSION),g.setAttribute("etag",Editor.guid());var x=null!=i?i.getMode():this.mode;null!=x&&g.setAttribute("type",x),g.getElementsByTagName("diagram").length>1&&null!=this.pages&&g.setAttribute("pages",this.pages.length)}var v=u?mxUtils.getPrettyXml(g):mxUtils.getXml(g);return r||l||!(s||null!=i&&/(\.html)$/i.test(i.getTitle()))?(r||!l&&null!=i&&/(\.svg)$/i.test(i.getTitle()))&&(null==i||i.getMode()!=App.MODE_DEVICE&&i.getMode()!=App.MODE_BROWSER||(n=null),v=this.getEmbeddedSvg(v,t,n,null,o,a,m)):v=this.getHtml2(mxUtils.getXml(g),t,null!=i?i.getTitle():null,h,m),v},EditorUi.prototype.getXmlFileData=function(e,t,i,n){e=null==e||e,t=null!=t&&t,i=null!=i?i:!Editor.compressXml;var l=this.editor.getGraphXml(e,n);if(e&&null!=this.fileNode&&null!=this.currentPage){function r(e){var t=e.getElementsByTagName("mxGraphModel"),n=t.length>0?t[0]:null,r=e;if(null==n&&i){var s=mxUtils.trim(mxUtils.getTextContent(e));if(r=e.cloneNode(!1),s.length>0){var o=Graph.decompress(s);null!=o&&o.length>0&&r.appendChild(mxUtils.parseXml(o).documentElement)}}else null==n||i?r=e.cloneNode(!0):(r=e.cloneNode(!1),mxUtils.setTextContent(r,Graph.compressNode(n)));l.appendChild(r)}if(EditorUi.removeChildNodes(this.currentPage.node),mxUtils.setTextContent(this.currentPage.node,Graph.compressNode(l)),l=this.fileNode.cloneNode(!1),t)r(this.currentPage.node);else for(var s=0;s<this.pages.length;s++){var o=this.pages[s],a=o.node;if(o!=this.currentPage)if(o.needsUpdate){var d=new mxCodec(mxUtils.createXmlDocument()).encode(new mxGraphModel(o.root));this.editor.graph.saveViewState(o.viewState,d,null,n),EditorUi.removeChildNodes(a),mxUtils.setTextContent(a,Graph.compressNode(d)),delete o.needsUpdate}else n&&(this.updatePageRoot(o),null!=o.viewState.backgroundImage&&(null!=o.viewState.backgroundImage.originalSrc?o.viewState.backgroundImage=this.createImageForPageLink(o.viewState.backgroundImage.originalSrc,o):Graph.isPageLink(o.viewState.backgroundImage.src)&&(o.viewState.backgroundImage=this.createImageForPageLink(o.viewState.backgroundImage.src,o))),null!=o.viewState.backgroundImage&&null!=o.viewState.backgroundImage.originalSrc)&&(d=new mxCodec(mxUtils.createXmlDocument()).encode(new mxGraphModel(o.root)),this.editor.graph.saveViewState(o.viewState,d,null,n),a=a.cloneNode(!1),mxUtils.setTextContent(a,Graph.compressNode(d)));r(a)}}return l},EditorUi.prototype.anonymizeString=function(e,t){for(var i=[],n=0;n<e.length;n++){var l=e.charAt(n);EditorUi.ignoredAnonymizedChars.indexOf(l)>=0?i.push(l):isNaN(parseInt(l))?l.toLowerCase()!=l?i.push(String.fromCharCode(65+Math.round(25*Math.random()))):l.toUpperCase()!=l?i.push(String.fromCharCode(97+Math.round(25*Math.random()))):/\s/.test(l)?i.push(" "):i.push("?"):i.push(t?"0":Math.round(9*Math.random()))}return i.join("")},EditorUi.prototype.anonymizePatch=function(e){if(null!=e[EditorUi.DIFF_INSERT])for(var t=0;t<e[EditorUi.DIFF_INSERT].length;t++)try{var i=e[EditorUi.DIFF_INSERT][t].data,n=mxUtils.parseXml(i).documentElement.cloneNode(!1);null!=n.getAttribute("name")&&n.setAttribute("name",this.anonymizeString(n.getAttribute("name"))),e[EditorUi.DIFF_INSERT][t].data=mxUtils.getXml(n)}catch(i){e[EditorUi.DIFF_INSERT][t].data=i.message}if(null!=e[EditorUi.DIFF_UPDATE]){for(var l in e[EditorUi.DIFF_UPDATE]){var r=e[EditorUi.DIFF_UPDATE][l];if(null!=r.name&&(r.name=this.anonymizeString(r.name)),null!=r.cells){var s=mxUtils.bind(this,(function(e){var t=r.cells[e];if(null!=t){for(var i in t)null!=t[i].value&&(t[i].value="["+t[i].value.length+"]"),null!=t[i].xmlValue&&(t[i].xmlValue="["+t[i].xmlValue.length+"]"),null!=t[i].style&&(t[i].style="["+t[i].style.length+"]"),0==Object.keys(t[i]).length&&delete t[i];0==Object.keys(t).length&&delete r.cells[e]}}));s(EditorUi.DIFF_INSERT),s(EditorUi.DIFF_UPDATE),0==Object.keys(r.cells).length&&delete r.cells}0==Object.keys(r).length&&delete e[EditorUi.DIFF_UPDATE][l]}0==Object.keys(e[EditorUi.DIFF_UPDATE]).length&&delete e[EditorUi.DIFF_UPDATE]}return e},EditorUi.prototype.anonymizeAttributes=function(e,t){if(null!=e.attributes)for(var i=0;i<e.attributes.length;i++)"as"!=e.attributes[i].name&&e.setAttribute(e.attributes[i].name,this.anonymizeString(e.attributes[i].value,t));if(null!=e.childNodes)for(i=0;i<e.childNodes.length;i++)this.anonymizeAttributes(e.childNodes[i],t)},EditorUi.prototype.anonymizeNode=function(e,t){for(var i=e.getElementsByTagName("mxCell"),n=0;n<i.length;n++)null!=i[n].getAttribute("value")&&i[n].setAttribute("value","["+i[n].getAttribute("value").length+"]"),null!=i[n].getAttribute("xmlValue")&&i[n].setAttribute("xmlValue","["+i[n].getAttribute("xmlValue").length+"]"),null!=i[n].getAttribute("style")&&i[n].setAttribute("style","["+i[n].getAttribute("style").length+"]"),null!=i[n].parentNode&&"root"!=i[n].parentNode.nodeName&&null!=i[n].parentNode.parentNode&&(i[n].setAttribute("id",i[n].parentNode.getAttribute("id")),i[n].parentNode.parentNode.replaceChild(i[n],i[n].parentNode));return e},EditorUi.prototype.synchronizeCurrentFile=function(e){var t=this.getCurrentFile();null!=t&&(t.savingFile?this.handleError({message:mxResources.get("busy")}):!e&&t.invalidChecksum?t.handleFileError(null,!0):this.spinner.spin(document.body,mxResources.get("updatingDocument"))&&(t.clearAutosave(),this.editor.setStatus(""),e?t.reloadFile(mxUtils.bind(this,(function(){t.handleFileSuccess("manual"==DrawioFile.SYNC)})),mxUtils.bind(this,(function(e){t.handleFileError(e,!0)}))):t.synchronizeFile(mxUtils.bind(this,(function(){t.handleFileSuccess("manual"==DrawioFile.SYNC)})),mxUtils.bind(this,(function(e){t.handleFileError(e,!0)})))))},EditorUi.prototype.getFileData=function(e,t,i,n,l,r,s,o,a,d,u){l=null==l||l,r=null!=r&&r;var h=this.editor.graph;if(t||!e&&null!=a&&/(\.svg)$/i.test(a.getTitle())){var m=null!=h.themes&&"darkTheme"==h.defaultThemeName;if(d=!1,m||null!=this.pages&&this.currentPage!=this.pages[0]){var g=h.getGlobalVariable;(h=this.createTemporaryGraph(m?h.getDefaultStylesheet():h.getStylesheet())).setBackgroundImage=this.editor.graph.setBackgroundImage;var c=this.pages[0];this.currentPage==c?h.setBackgroundImage(this.editor.graph.backgroundImage):null!=c.viewState&&null!=c.viewState&&h.setBackgroundImage(c.viewState.backgroundImage),h.getGlobalVariable=function(e){return"page"==e?c.getName():"pagenumber"==e?1:g.apply(this,arguments)},document.body.appendChild(h.container),h.model.setRoot(c.root)}}s=null!=s?s:this.getXmlFileData(l,r,d,u),a=null!=a?a:this.getCurrentFile();var p=this.createFileData(s,h,a,window.location.href,e,t,i,n,l,o,d);return h!=this.editor.graph&&h.container.parentNode.removeChild(h.container),p},EditorUi.prototype.getHtml=function(e,t,i,n,l,r){r=null==r||r;var s=null,o=EditorUi.drawHost+"/js/embed-static.min.js";if(null!=t){var a=r?t.getGraphBounds():t.getBoundingBox(t.getSelectionCells()),d=t.view.scale,u=Math.floor(a.x/d-t.view.translate.x),h=Math.floor(a.y/d-t.view.translate.y);if(s=t.background,null==l){var m=this.getBasenames().join(";");m.length>0&&(o=EditorUi.drawHost+"/embed.js?s="+m)}e.setAttribute("x0",u),e.setAttribute("y0",h)}null!=e&&(e.setAttribute("pan","1"),e.setAttribute("zoom","1"),e.setAttribute("resize","0"),e.setAttribute("fit","0"),e.setAttribute("border","20"),e.setAttribute("links","1"),null!=n&&e.setAttribute("edit",n)),null!=l&&(l=l.replace(/&/g,"&"));var g=null!=e?Graph.zapGremlins(mxUtils.getXml(e)):"",c=Graph.compress(g);return Graph.decompress(c)!=g&&(c=encodeURIComponent(g)),(null==l?'\x3c!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]--\x3e\n':"")+"<!DOCTYPE html>\n<html"+(null!=l?' xmlns="http://www.w3.org/1999/xhtml">':">")+"\n<head>\n"+(null==l?null!=i?"<title>"+mxUtils.htmlEntities(i)+"</title>\n":"":"<title>diagrams.net</title>\n")+(null!=l?'<meta http-equiv="refresh" content="0;URL=\''+l+"'\"/>\n":"")+"</head>\n<body"+(null==l&&null!=s&&s!=mxConstants.NONE?' style="background-color:'+s+';">':">")+'\n<div class="mxgraph" style="position:relative;overflow:auto;width:100%;">\n<div style="width:1px;height:1px;overflow:hidden;">'+c+"</div>\n</div>\n"+(null==l?'<script type="text/javascript" src="'+o+'"><\/script>':'<a style="position:absolute;top:50%;left:50%;margin-top:-128px;margin-left:-64px;" href="'+l+'" target="_blank"><img border="0" src="'+EditorUi.drawHost+'/images/drawlogo128.png"/></a>')+"\n</body>\n</html>\n"},EditorUi.prototype.getHtml2=function(e,t,i,n,l){var r=window.DRAWIO_VIEWER_URL||EditorUi.drawHost+"/js/viewer-static.min.js";null!=l&&(l=l.replace(/&/g,"&"));var s={highlight:"#0000ff",nav:this.editor.graph.foldingEnabled,resize:!0,xml:Graph.zapGremlins(e),toolbar:"pages zoom layers lightbox"};return null!=this.pages&&null!=this.currentPage&&(s.page=mxUtils.indexOf(this.pages,this.currentPage)),(null==l?'\x3c!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]--\x3e\n':"")+"<!DOCTYPE html>\n<html"+(null!=l?' xmlns="http://www.w3.org/1999/xhtml">':">")+"\n<head>\n"+(null==l?null!=i?"<title>"+mxUtils.htmlEntities(i)+"</title>\n":"":"<title>diagrams.net</title>\n")+(null!=l?'<meta http-equiv="refresh" content="0;URL=\''+l+"'\"/>\n":"")+'<meta charset="utf-8"/>\n</head>\n<body>\n<div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="'+mxUtils.htmlEntities(JSON.stringify(s))+'"></div>\n'+(null==l?'<script type="text/javascript" src="'+r+'"><\/script>':'<a style="position:absolute;top:50%;left:50%;margin-top:-128px;margin-left:-64px;" href="'+l+'" target="_blank"><img border="0" src="'+EditorUi.drawHost+'/images/drawlogo128.png"/></a>')+"\n</body>\n</html>\n"},EditorUi.prototype.setFileData=function(e){e=this.validateFileData(e),this.currentPage=null,this.fileNode=null,this.pages=null;var t=null!=e&&e.length>0?mxUtils.parseXml(e).documentElement:null,i=Editor.extractParserError(t,mxResources.get("invalidOrMissingFile"));if(i)throw new Error(mxResources.get("notADiagramFile")+" ("+i+")");var n=null!=t?this.editor.extractGraphModel(t,!0):null;if(null!=n&&(t=n),null!=t&&"mxfile"==t.nodeName){var l=t.getElementsByTagName("diagram");if("0"!=urlParams.pages||l.length>1||1==l.length&&l[0].hasAttribute("name")){var r=null;this.fileNode=t,this.pages=[];for(var s=0;s<l.length;s++){null==l[s].getAttribute("id")&&l[s].setAttribute("id",s);var o=new DiagramPage(l[s]);null==o.getName()&&o.setName(mxResources.get("pageWithNumber",[s+1])),this.pages.push(o),null!=urlParams["page-id"]&&o.getId()==urlParams["page-id"]&&(r=o)}this.currentPage=null!=r?r:this.pages[Math.max(0,Math.min(this.pages.length-1,urlParams.page||0))],t=this.currentPage.node}}if("0"!=urlParams.pages&&null==this.fileNode&&null!=t&&(this.fileNode=t.ownerDocument.createElement("mxfile"),this.currentPage=new DiagramPage(t.ownerDocument.createElement("diagram")),this.currentPage.setName(mxResources.get("pageWithNumber",[1])),this.pages=[this.currentPage]),this.editor.setGraphXml(t),null!=this.currentPage&&(this.currentPage.root=this.editor.graph.model.root),null!=urlParams["layer-ids"])try{var a=urlParams["layer-ids"].split(" "),d={};for(s=0;s<a.length;s++)d[a[s]]=!0;var u=this.editor.graph.getModel(),h=u.getChildren(u.root);for(s=0;s<h.length;s++){var m=h[s];u.setVisible(m,d[m.id]||!1)}}catch(e){}},EditorUi.prototype.getBaseFilename=function(e){var t=this.getCurrentFile(),i=null!=t&&null!=t.getTitle()?t.getTitle():this.defaultFilename;return(/(\.xml)$/i.test(i)||/(\.html)$/i.test(i)||/(\.svg)$/i.test(i)||/(\.png)$/i.test(i))&&(i=i.substring(0,i.lastIndexOf("."))),/(\.drawio)$/i.test(i)&&(i=i.substring(0,i.lastIndexOf("."))),!e&&null!=this.pages&&this.pages.length>1&&null!=this.currentPage&&null!=this.currentPage.node.getAttribute("name")&&this.currentPage.getName().length>0&&(i=i+"-"+this.currentPage.getName()),i},EditorUi.prototype.downloadFile=function(e,t,i,n,l,r,s,o,a,d,u,h){try{n=null!=n?n:this.editor.graph.isSelectionEmpty();var m=this.getBaseFilename(!l),g=m+("xml"==e||"pdf"==e&&u?".drawio":"")+"."+e;if("xml"==e){var c=Graph.xmlDeclaration+"\n"+this.getFileData(!0,null,null,null,n,l,null,null,null,t);this.saveData(g,e,c,"text/xml")}else if("html"==e)c=this.getHtml2(this.getFileData(!0),this.editor.graph,m),this.saveData(g,e,c,"text/html");else if("svg"!=e&&"xmlsvg"!=e||!this.spinner.spin(document.body,mxResources.get("export")))"xmlpng"==e?g=m+".png":"jpeg"==e&&(g=m+".jpg"),this.saveRequest(g,e,mxUtils.bind(this,(function(t,i){try{var m=this.editor.graph.pageVisible;null!=r&&(this.editor.graph.pageVisible=r);var g=this.createDownloadRequest(t,e,n,i,s,l,o,a,d,u,h);return this.editor.graph.pageVisible=m,g}catch(e){this.handleError(e)}})));else{var p=null,f=mxUtils.bind(this,(function(e){e.length<=MAX_REQUEST_SIZE?this.saveData(g,"svg",e,"image/svg+xml"):this.handleError({message:mxResources.get("drawingTooLarge")},mxResources.get("error"),mxUtils.bind(this,(function(){mxUtils.popup(p)})))}));if("svg"==e){var x=this.editor.graph.background;(s||x==mxConstants.NONE)&&(x=null);var v=this.editor.graph.getSvg(x,null,null,null,null,n);i&&this.editor.graph.addSvgShadow(v),this.editor.convertImages(v,mxUtils.bind(this,mxUtils.bind(this,(function(e){this.spinner.stop(),f(Graph.xmlDeclaration+"\n"+Graph.svgDoctype+"\n"+mxUtils.getXml(e))}))))}else g=m+".svg",p=this.getFileData(!1,!0,null,mxUtils.bind(this,(function(e){this.spinner.stop(),f(e)})),n)}}catch(e){this.handleError(e)}},EditorUi.prototype.createDownloadRequest=function(e,t,i,n,l,r,s,o,a,d,u){var h=this.editor.graph,m=h.getGraphBounds(),g=this.getFileData(!0,null,null,null,i,0!=r&&"xmlpng"!=t,null,null,null,!1,"pdf"==t),c="",p="";if(m.width*m.height>MAX_AREA||g.length>MAX_REQUEST_SIZE)throw{message:mxResources.get("drawingTooLarge")};var f=d?"1":"0";if("pdf"==t&&(null!=u?p="&from="+u.from+"&to="+u.to:0==r&&(p="&allPages=1")),"xmlpng"==t&&(f="1",t="png",null!=this.pages&&null!=this.currentPage))for(var x=0;x<this.pages.length;x++)if(this.pages[x]==this.currentPage){c="&from="+x;break}var v=h.background;"png"!=t&&"pdf"!=t||!l?l||null!=v&&v!=mxConstants.NONE||(v="#ffffff"):v=mxConstants.NONE;var b={globalVars:h.getExportVariables()};return a&&(b.grid={size:h.gridSize,steps:h.view.gridSteps,color:h.view.gridColor}),Graph.translateDiagram&&(b.diagramLanguage=Graph.diagramLanguage),new mxXmlRequest(EXPORT_URL,"format="+t+c+p+"&bg="+(null!=v?v:mxConstants.NONE)+"&base64="+n+"&embedXml="+f+"&xml="+encodeURIComponent(g)+(null!=e?"&filename="+encodeURIComponent(e):"")+"&extras="+encodeURIComponent(JSON.stringify(b))+(null!=s?"&scale="+s:"")+(null!=o?"&border="+o:""))},EditorUi.prototype.setMode=function(e,t){this.mode=e},EditorUi.prototype.loadDescriptor=function(e,t,i){var n=window.location.hash,l=mxUtils.bind(this,(function(i){var l=null!=e.data?e.data:"";null!=i&&i.length>0&&(l.length>0&&(l+="\n"),l+=i);var r="csv"!=e.format&&l.length>0?l:this.emptyDiagramXml,s=new LocalFile(this,r,null!=urlParams.title?decodeURIComponent(urlParams.title):this.defaultFilename,!0);if(s.getHash=function(){return n},this.fileLoaded(s),"csv"==e.format&&this.importCsv(l,mxUtils.bind(this,(function(e){this.editor.undoManager.clear(),this.editor.setModified(!1),this.editor.setStatus("")}))),null!=e.update){var o=null!=e.interval?parseInt(e.interval):6e4,a=null,d=mxUtils.bind(this,(function(){var t=this.currentPage;mxUtils.post(e.update,"xml="+encodeURIComponent(mxUtils.getXml(this.editor.getGraphXml())),mxUtils.bind(this,(function(e){t===this.currentPage&&(e.getStatus()>=200&&e.getStatus()<=300?(this.updateDiagram(e.getText()),u()):this.handleError({message:mxResources.get("error")+" "+e.getStatus()}))})),mxUtils.bind(this,(function(e){this.handleError(e)})))})),u=mxUtils.bind(this,(function(){window.clearTimeout(a),a=window.setTimeout(d,o)}));this.editor.addListener("pageSelected",mxUtils.bind(this,(function(){u(),d()}))),u(),d()}null!=t&&t()}));null!=e.url&&e.url.length>0?this.editor.loadUrl(e.url,mxUtils.bind(this,(function(e){l(e)})),mxUtils.bind(this,(function(e){null!=i&&i(e)}))):l("")},EditorUi.prototype.updateDiagram=function(e){var t=null,i=this;function n(e){var t=new mxCellOverlay(e.image||r.warningImage,e.tooltip,e.align,e.valign,e.offset);return t.addListener(mxEvent.CLICK,(function(t,n){i.alert(e.tooltip)})),t}if(null!=e&&e.length>0){var l=null!=(t=mxUtils.parseXml(e))?t.documentElement:null;if(null!=l&&"updates"==l.nodeName){var r=this.editor.graph,s=r.getModel();s.beginUpdate();var o=null;try{for(l=l.firstChild;null!=l;){if("update"==l.nodeName){var a=s.getCell(l.getAttribute("id"));if(null!=a){try{var d=l.getAttribute("value");if(null!=d){var u=mxUtils.parseXml(d).documentElement;if(null!=u)if("1"==u.getAttribute("replace-value"))s.setValue(a,u);else for(var h=u.attributes,m=0;m<h.length;m++)r.setAttributeForCell(a,h[m].nodeName,h[m].nodeValue.length>0?h[m].nodeValue:null)}}catch(e){null!=window.console&&console.log("Error in value for "+a.id+": "+e)}try{var g=l.getAttribute("style");null!=g&&r.model.setStyle(a,g)}catch(e){null!=window.console&&console.log("Error in style for "+a.id+": "+e)}try{var c=l.getAttribute("icon");if(null!=c){var p=c.length>0?JSON.parse(c):null;null!=p&&p.append||r.removeCellOverlays(a),null!=p&&r.addCellOverlay(a,n(p))}}catch(e){null!=window.console&&console.log("Error in icon for "+a.id+": "+e)}try{var f=l.getAttribute("geometry");if(null!=f){f=JSON.parse(f);var x=r.getCellGeometry(a);if(null!=x){for(key in x=x.clone(),f){var v=parseFloat(f[key]);"dx"==key?x.x+=v:"dy"==key?x.y+=v:"dw"==key?x.width+=v:"dh"==key?x.height+=v:x[key]=parseFloat(f[key])}r.model.setGeometry(a,x)}}}catch(e){null!=window.console&&console.log("Error in icon for "+a.id+": "+e)}}}else if("model"==l.nodeName){for(var b=l.firstChild;null!=b&&b.nodeType!=mxConstants.NODETYPE_ELEMENT;)b=b.nextSibling;null!=b&&new mxCodec(l.firstChild).decode(b,s)}else"view"==l.nodeName?(l.hasAttribute("scale")&&(r.view.scale=parseFloat(l.getAttribute("scale"))),(l.hasAttribute("dx")||l.hasAttribute("dy"))&&(r.view.translate=new mxPoint(parseFloat(l.getAttribute("dx")||0),parseFloat(l.getAttribute("dy")||0)))):"fit"==l.nodeName&&(o=l.hasAttribute("max-scale")?parseFloat(l.getAttribute("max-scale")):1);l=l.nextSibling}}finally{s.endUpdate()}null!=o&&this.chromelessResize&&this.chromelessResize(!0,o)}}return t},EditorUi.prototype.getCopyFilename=function(e,t){var i,n=null!=e&&null!=e.getTitle()?e.getTitle():this.defaultFilename,l="",r=n.lastIndexOf(".");return r>=0&&(l=n.substring(r),n=n.substring(0,r)),t&&(new Date,n+=" "+(i=new Date).getFullYear()+"-"+(i.getMonth()+1)+"-"+i.getDate()+"-"+i.getHours()+"-"+i.getMinutes()+"-"+i.getSeconds()),mxResources.get("copyOf",[n])+l},EditorUi.prototype.fileLoaded=function(e,t){var i=this.getCurrentFile();this.fileLoadedError=null,this.fileEditable=null,this.setCurrentFile(null);var n=!1;this.hideDialog(),null!=i&&(EditorUi.debug("File.closed",[i]),i.removeListener(this.descriptorChangedListener),i.close()),this.editor.graph.model.clear(),this.editor.undoManager.clear();var l=mxUtils.bind(this,(function(){this.setGraphEnabled(!1),this.setCurrentFile(null),null!=i&&this.updateDocumentTitle(),this.editor.graph.model.clear(),this.editor.undoManager.clear(),this.setBackgroundImage(null),!t&&null!=window.location.hash&&window.location.hash.length>0&&(window.location.hash=""),null!=this.fname&&(this.fnameWrapper.style.display="none",this.fname.innerHTML="",this.fname.setAttribute("title",mxResources.get("rename"))),this.editor.setStatus(""),this.updateUi(),t||this.showSplash()}));if(null!=e)try{if(mxClient.IS_SF&&"min"==uiTheme&&(this.diagramContainer.style.visibility=""),this.openingFile=!0,this.setCurrentFile(e),e.addListener("descriptorChanged",this.descriptorChangedListener),e.addListener("contentChanged",this.descriptorChangedListener),e.open(),delete this.openingFile,this.setGraphEnabled(!0),this.setMode(e.getMode()),this.editor.graph.model.prefix=Editor.guid()+"-",this.editor.undoManager.clear(),this.descriptorChanged(),this.updateUi(),e.isEditable()?e.isModified()?(e.addUnsavedStatus(),null!=e.backupPatch&&e.patch([e.backupPatch])):this.editor.setStatus(""):this.editor.setStatus('<span class="geStatusAlert">'+mxUtils.htmlEntities(mxResources.get("readOnly"))+"</span>"),!this.editor.isChromelessView()||this.editor.editable?(this.editor.graph.selectUnlockedLayer(),this.showLayersDialog(),this.restoreLibraries(),window.self!==window.top&&window.focus()):this.editor.graph.isLightboxView()&&this.lightboxFit(),this.chromelessResize&&this.chromelessResize(),this.editor.fireEvent(new mxEventObject("fileLoaded")),n=!0,!this.isOffline()&&null!=e.getMode()){var r="1"==urlParams.sketch?"sketch":uiTheme;null==r?r="default":"sketch"!=r&&"min"!=r||(r+=Editor.isDarkMode()?"-dark":"-light"),EditorUi.logEvent({category:e.getMode().toUpperCase()+"-OPEN-FILE-"+e.getHash(),action:"size_"+e.getSize(),label:"autosave_"+(this.editor.autosave?"on":"off")+"_theme_"+r})}if(EditorUi.debug("File.opened",[e]),"1"==urlParams.viewerOnlyMsg&&this.showAlert(mxResources.get("viewerOnlyMsg")),this.editor.editable&&this.mode==e.getMode()&&e.getMode()!=App.MODE_DEVICE&&null!=e.getMode())try{this.addRecent({id:e.getHash(),title:e.getTitle(),mode:e.getMode()})}catch(e){}try{mxSettings.setOpenCounter(mxSettings.getOpenCounter()+1),mxSettings.save()}catch(e){}}catch(n){if(this.fileLoadedError=n,EditorUi.enableLogging&&!this.isOffline())try{EditorUi.logEvent({category:"ERROR-LOAD-FILE-"+(null!=e?e.getHash():"none"),action:"message_"+n.message,label:"stack_"+n.stack})}catch(e){}var s=mxUtils.bind(this,(function(){null!=urlParams.url&&this.spinner.spin(document.body,mxResources.get("reconnecting"))?window.location.search=this.getSearch(["url"]):null!=i?this.fileLoaded(i):l()}));t?s():this.handleError(n,mxResources.get("errorLoadingFile"),s,!0,null,null,!0)}else l();return n},EditorUi.prototype.getHashValueForPages=function(e,t){var i=0,n=new mxGraphModel,l=new mxCodec;null!=t&&(t.byteCount=0,t.attrCount=0,t.eltCount=0,t.nodeCount=0);for(var r=0;r<e.length;r++){this.updatePageRoot(e[r]);var s=e[r].node.cloneNode(!1);s.removeAttribute("name"),n.root=e[r].root;var o=l.encode(n);this.editor.graph.saveViewState(e[r].viewState,o,!0),o.removeAttribute("pageWidth"),o.removeAttribute("pageHeight"),s.appendChild(o),null!=t&&(t.eltCount+=s.getElementsByTagName("*").length,t.nodeCount+=s.getElementsByTagName("mxCell").length),i=(i<<5)-i+this.hashValue(s,(function(e,t,i,n){return!n||"mxGeometry"!=e.nodeName&&"mxPoint"!=e.nodeName||"x"!=t&&"y"!=t&&"width"!=t&&"height"!=t?n&&"mxCell"==e.nodeName&&"previous"==t?null:i:Math.round(i)}),t)<<0}return i},EditorUi.prototype.hashValue=function(e,t,i){var n=0;if(null!=e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName&&"function"==typeof e.getAttribute){if(null!=e.nodeName&&(n^=this.hashValue(e.nodeName,t,i)),null!=e.attributes){null!=i&&(i.attrCount+=e.attributes.length);for(var l=0;l<e.attributes.length;l++){var r=e.attributes[l].name,s=null!=t?t(e,r,e.attributes[l].value,!0):e.attributes[l].value;null!=s&&(n^=this.hashValue(r,t,i)+this.hashValue(s,t,i))}}if(null!=e.childNodes)for(l=0;l<e.childNodes.length;l++)n=(n<<5)-n+this.hashValue(e.childNodes[l],t,i)<<0}else if(null!=e&&"function"!=typeof e){var o=String(e),a=0;for(null!=i&&(i.byteCount+=o.length),l=0;l<o.length;l++)a=(a<<5)-a+o.charCodeAt(l)<<0;n^=a}return n},EditorUi.prototype.descriptorChanged=function(){},EditorUi.prototype.restoreLibraries=function(){},EditorUi.prototype.saveLibrary=function(e,t,i,n,l,r,s){},EditorUi.prototype.isScratchpadEnabled=function(){return isLocalStorage||mxClient.IS_CHROMEAPP},EditorUi.prototype.toggleScratchpad=function(){this.isScratchpadEnabled()&&(null==this.scratchpad?StorageFile.getFileContent(this,".scratchpad",mxUtils.bind(this,(function(e){null==e&&(e=this.emptyLibraryXml),this.loadLibrary(new StorageLibrary(this,e,".scratchpad"))}))):this.closeLibrary(this.scratchpad))},EditorUi.prototype.createLibraryDataFromImages=function(e){var t=mxUtils.createXmlDocument(),i=t.createElement("mxlibrary");return mxUtils.setTextContent(i,JSON.stringify(e)),t.appendChild(i),mxUtils.getXml(t)},EditorUi.prototype.closeLibrary=function(e){null!=e&&(this.removeLibrarySidebar(e.getHash()),e.constructor!=LocalLibrary&&mxSettings.removeCustomLibrary(e.getHash()),".scratchpad"==e.title&&(this.scratchpad=null))},EditorUi.prototype.removeLibrarySidebar=function(e){var t=this.sidebar.palettes[e];if(null!=t){for(var i=0;i<t.length;i++)t[i].parentNode.removeChild(t[i]);delete this.sidebar.palettes[e]}},EditorUi.prototype.repositionLibrary=function(e){var t=this.sidebar.container;if(null==e){var i=this.sidebar.palettes["L.scratchpad"];null==i&&(i=this.sidebar.palettes.search),null!=i&&(e=i[i.length-1].nextSibling)}e=null!=e?e:t.firstChild.nextSibling.nextSibling;var n=t.lastChild,l=n.previousSibling;t.insertBefore(n,e),t.insertBefore(l,n)},EditorUi.prototype.loadLibrary=function(e,t){var i=mxUtils.parseXml(e.getData());if("mxlibrary"!=i.documentElement.nodeName)throw{message:mxResources.get("notALibraryFile")};var n=JSON.parse(mxUtils.getTextContent(i.documentElement));this.libraryLoaded(e,n,i.documentElement.getAttribute("title"),t)},EditorUi.prototype.getLibraryStorageHint=function(e){return""},EditorUi.prototype.libraryLoaded=function(e,t,i,n){if(null!=this.sidebar){e.constructor!=LocalLibrary&&mxSettings.addCustomLibrary(e.getHash()),".scratchpad"==e.title&&(this.scratchpad=e);var l=this.sidebar.palettes[e.getHash()],r=null!=l?l[l.length-1].nextSibling:null;this.removeLibrarySidebar(e.getHash());var s=null,o=mxUtils.bind(this,(function(t,i){0==t.length&&e.isEditable()?(null==s&&((s=document.createElement("div")).className="geDropTarget",mxUtils.write(s,mxResources.get("dragElementsHere"))),i.appendChild(s)):this.addLibraryEntries(t,i)}));null!=this.sidebar&&null!=t&&this.sidebar.addEntries(t);var a=i;null==a&&null!=(a=e.getTitle())&&/(\.xml)$/i.test(a)&&(a=a.substring(0,a.lastIndexOf(".")));var d=this.sidebar.addPalette(e.getHash(),a,null==n||n,mxUtils.bind(this,(function(e){o(t,e)})));this.repositionLibrary(r);var u=d.parentNode.previousSibling,h=u.getAttribute("title");null!=h&&h.length>0&&".scratchpad"!=e.title&&u.setAttribute("title",this.getLibraryStorageHint(e)+"\n"+h);var m=document.createElement("div");m.style.position="absolute",m.style.right="0px",m.style.top="0px",m.style.padding="8px",m.style.backgroundColor="inherit",u.style.position="relative";var g=document.createElement("img");g.setAttribute("src",Editor.crossImage),g.setAttribute("title",mxResources.get("close")),g.setAttribute("valign","absmiddle"),g.setAttribute("border","0"),g.style.position="relative",g.style.top="2px",g.style.width="14px",g.style.cursor="pointer",g.style.margin="0 3px",Editor.isDarkMode()&&(g.style.filter="invert(100%)");var c=null;if((".scratchpad"!=e.title||this.closableScratchpad)&&(m.appendChild(g),mxEvent.addListener(g,"click",mxUtils.bind(this,(function(t){if(!mxEvent.isConsumed(t)){var i=mxUtils.bind(this,(function(){this.closeLibrary(e)}));null!=c?this.confirm(mxResources.get("allChangesLost"),null,i,mxResources.get("cancel"),mxResources.get("discardChanges")):i(),mxEvent.consume(t)}})))),e.isEditable()){var p=this.editor.graph,f=null,x=mxUtils.bind(this,(function(i){this.showLibraryDialog(e.getTitle(),d,t,e,e.getMode()),mxEvent.consume(i)})),v=mxUtils.bind(this,(function(i){e.setModified(!0),e.isAutosave()?(null!=f&&null!=f.parentNode&&f.parentNode.removeChild(f),(f=g.cloneNode(!1)).setAttribute("src",Editor.spinImage),f.setAttribute("title",mxResources.get("saving")),f.style.cursor="default",f.style.marginRight="2px",f.style.marginTop="-2px",m.insertBefore(f,m.firstChild),u.style.paddingRight=18*m.childNodes.length+"px",this.saveLibrary(e.getTitle(),t,e,e.getMode(),!0,!0,(function(){null!=f&&null!=f.parentNode&&(f.parentNode.removeChild(f),u.style.paddingRight=18*m.childNodes.length+"px")}))):null==c&&((c=g.cloneNode(!1)).setAttribute("src",Editor.saveImage),c.setAttribute("title",mxResources.get("save")),m.insertBefore(c,m.firstChild),mxEvent.addListener(c,"click",mxUtils.bind(this,(function(i){this.saveLibrary(e.getTitle(),t,e,e.getMode(),e.constructor==LocalLibrary,!0,(function(){null==c||e.isModified()||(u.style.paddingRight=18*m.childNodes.length+"px",c.parentNode.removeChild(c),c=null)})),mxEvent.consume(i)}))),u.style.paddingRight=18*m.childNodes.length+"px")})),b=mxUtils.bind(this,(function(e,i,n,l){e=p.cloneCells(mxUtils.sortCells(p.model.getTopmostCells(e)));for(var r=0;r<e.length;r++){var o=p.getCellGeometry(e[r]);null!=o&&o.translate(-i.x,-i.y)}d.appendChild(this.sidebar.createVertexTemplateFromCells(e,i.width,i.height,l||"",!0,!1,!1));var a={xml:Graph.compress(mxUtils.getXml(this.editor.graph.encodeCells(e))),w:i.width,h:i.height};null!=l&&(a.title=l),t.push(a),v(n),null!=s&&null!=s.parentNode&&t.length>0&&(s.parentNode.removeChild(s),s=null)})),y=mxUtils.bind(this,(function(e){if(p.isSelectionEmpty())p.getRubberband().isActive()?(p.getRubberband().execute(e),p.getRubberband().reset()):this.showError(mxResources.get("error"),mxResources.get("nothingIsSelected"),mxResources.get("ok"));else{var t=p.getSelectionCells(),i=p.view.getBounds(t),n=p.view.scale;i.x/=n,i.y/=n,i.width/=n,i.height/=n,i.x-=p.view.translate.x,i.y-=p.view.translate.y,b(t,i)}mxEvent.consume(e)}));mxEvent.addGestureListeners(d,(function(){}),mxUtils.bind(this,(function(e){p.isMouseDown&&null!=p.panningManager&&null!=p.graphHandler.first&&(p.graphHandler.suspend(),null!=p.graphHandler.hint&&(p.graphHandler.hint.style.visibility="hidden"),d.style.backgroundColor="#f1f3f4",d.style.cursor="copy",p.panningManager.stop(),p.autoScroll=!1,mxEvent.consume(e))})),mxUtils.bind(this,(function(e){p.isMouseDown&&null!=p.panningManager&&null!=p.graphHandler&&(d.style.backgroundColor="",d.style.cursor="default",this.sidebar.showTooltips=!0,p.panningManager.stop(),p.graphHandler.reset(),p.isMouseDown=!1,p.autoScroll=!0,y(e),mxEvent.consume(e))}))),mxEvent.addListener(d,"mouseleave",mxUtils.bind(this,(function(e){p.isMouseDown&&null!=p.graphHandler.first&&(p.graphHandler.resume(),null!=p.graphHandler.hint&&(p.graphHandler.hint.style.visibility="visible"),d.style.backgroundColor="",d.style.cursor="",p.autoScroll=!0)}))),Graph.fileSupport&&(mxEvent.addListener(d,"dragover",mxUtils.bind(this,(function(e){d.style.backgroundColor="#f1f3f4",e.dataTransfer.dropEffect="copy",d.style.cursor="copy",this.sidebar.hideTooltip(),e.stopPropagation(),e.preventDefault()}))),mxEvent.addListener(d,"drop",mxUtils.bind(this,(function(e){d.style.cursor="",d.style.backgroundColor="",e.dataTransfer.files.length>0&&this.importFiles(e.dataTransfer.files,0,0,this.maxImageSize,mxUtils.bind(this,(function(i,n,l,r,a,u,h,m,g){if(null!=i&&"image/"==n.substring(0,6)){var c="shape=image;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;aspect=fixed;image="+this.convertDataUri(i),p=[new mxCell("",new mxGeometry(0,0,a,u),c)];p[0].vertex=!0,b(p,new mxRectangle(0,0,a,u),e,mxEvent.isAltDown(e)?null:h.substring(0,h.lastIndexOf(".")).replace(/_/g," ")),null!=s&&null!=s.parentNode&&t.length>0&&(s.parentNode.removeChild(s),s=null)}else{var f=!1,x=mxUtils.bind(this,(function(i,n){if(null!=i&&"application/pdf"==n){var l=Editor.extractGraphModelFromPdf(i);null!=l&&l.length>0&&(n="text/xml",i=l)}if(null!=i){var r=mxUtils.parseXml(i);if("mxlibrary"==r.documentElement.nodeName)try{var a=JSON.parse(mxUtils.getTextContent(r.documentElement));o(a,d),t=t.concat(a),v(e),this.spinner.stop(),f=!0}catch(e){}else if("mxfile"==r.documentElement.nodeName)try{for(var u=r.documentElement.getElementsByTagName("diagram"),h=0;h<u.length;h++){var m=this.stringToCells(Editor.getDiagramNodeXml(u[h])),g=this.editor.graph.getBoundingBoxFromGeometry(m);b(m,new mxRectangle(0,0,g.width,g.height),e)}f=!0}catch(e){null!=window.console&&console.log("error in drop handler:",e)}}f||(this.spinner.stop(),this.handleError({message:mxResources.get("errorLoadingFile")})),null!=s&&null!=s.parentNode&&t.length>0&&(s.parentNode.removeChild(s),s=null)}));null!=g&&null!=h&&(/(\.v(dx|sdx?))($|\?)/i.test(h)||/(\.vs(x|sx?))($|\?)/i.test(h))?this.importVisio(g,(function(e){x(e,"text/xml")}),null,h):!this.isOffline()&&(new XMLHttpRequest).upload&&this.isRemoteFileFormat(i,h)&&null!=g?this.parseFile(g,mxUtils.bind(this,(function(e){4==e.readyState&&(this.spinner.stop(),e.status>=200&&e.status<=299?x(e.responseText,"text/xml"):this.handleError({message:mxResources.get(413==e.status?"drawingTooLarge":"invalidOrMissingFile")},mxResources.get("errorLoadingFile")))}))):x(i,n)}}))),e.stopPropagation(),e.preventDefault()}))),mxEvent.addListener(d,"dragleave",(function(e){d.style.cursor="",d.style.backgroundColor="",e.stopPropagation(),e.preventDefault()}))),(g=g.cloneNode(!1)).setAttribute("src",Editor.editImage),g.setAttribute("title",mxResources.get("edit")),m.insertBefore(g,m.firstChild),mxEvent.addListener(g,"click",x),mxEvent.addListener(d,"dblclick",(function(e){mxEvent.getSource(e)==d&&x(e)}));var E=g.cloneNode(!1);if(E.setAttribute("src",Editor.plusImage),E.setAttribute("title",mxResources.get("add")),m.insertBefore(E,m.firstChild),mxEvent.addListener(E,"click",y),!this.isOffline()&&".scratchpad"==e.title&&null!=EditorUi.scratchpadHelpLink){var w=document.createElement("span");w.setAttribute("title",mxResources.get("help")),w.style.cssText="color:#a3a3a3;text-decoration:none;margin-right:2px;cursor:pointer;",mxUtils.write(w,"?"),mxEvent.addGestureListeners(w,mxUtils.bind(this,(function(e){this.openLink(EditorUi.scratchpadHelpLink),mxEvent.consume(e)}))),m.insertBefore(w,m.firstChild)}}u.appendChild(m),u.style.paddingRight=18*m.childNodes.length+"px"}},EditorUi.prototype.addLibraryEntries=function(e,t){for(var i=0;i<e.length;i++){var n=e[i],l=n.data;if(null!=l){l=this.convertDataUri(l);var r="shape=image;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;";"fixed"==n.aspect&&(r+="aspect=fixed;"),t.appendChild(this.sidebar.createVertexTemplate(r+"image="+l,n.w,n.h,"",n.title||"",!1,!1,!0))}else if(null!=n.xml){var s=this.stringToCells(Graph.decompress(n.xml));s.length>0&&t.appendChild(this.sidebar.createVertexTemplateFromCells(s,n.w,n.h,n.title||"",!0,!1,!0))}}},EditorUi.prototype.getResource=function(e){return null!=e?e[mxLanguage]||e.main:null},EditorUi.prototype.footerHeight=0,"1"==urlParams.savesidebar&&(Sidebar.prototype.thumbWidth=64,Sidebar.prototype.thumbHeight=64),EditorUi.initTheme=function(){"atlas"==uiTheme?(mxClient.link("stylesheet",STYLE_PATH+"/atlas.css"),"undefined"!=typeof Toolbar&&(Toolbar.prototype.unselectedBackground="linear-gradient(rgb(255, 255, 255) 0px, rgb(242, 242, 242) 100%)",Toolbar.prototype.selectedBackground="rgb(242, 242, 242)"),Editor.prototype.initialTopSpacing=3,EditorUi.prototype.menubarHeight=41,EditorUi.prototype.toolbarHeight=38):Editor.isDarkMode()&&(mxClient.link("stylesheet",STYLE_PATH+"/dark.css"),Dialog.backdropColor=Editor.darkColor,Format.inactiveTabBackgroundColor="black",Graph.prototype.defaultThemeName="darkTheme",Graph.prototype.shapeBackgroundColor=Editor.darkColor,Graph.prototype.shapeForegroundColor=Editor.lightColor,Graph.prototype.defaultPageBackgroundColor=Editor.darkColor,Graph.prototype.defaultPageBorderColor="#505759",BaseFormatPanel.prototype.buttonBackgroundColor=Editor.darkColor,mxGraphHandler.prototype.previewColor="#cccccc",StyleFormatPanel.prototype.defaultStrokeColor="#cccccc",mxConstants.DROP_TARGET_COLOR="#00ff00"),Editor.sketchFontFamily="Architects Daughter",Editor.sketchFontSource="https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter","1"==urlParams.sketch&&(Graph.prototype.defaultVertexStyle={hachureGap:"4"},Graph.prototype.defaultEdgeStyle={edgeStyle:"none",rounded:"0",curved:"1",jettySize:"auto",orthogonalLoop:"1",endArrow:"open",startSize:"14",endSize:"14",sourcePerimeterSpacing:"8",targetPerimeterSpacing:"8"},Editor.configurationKey=".sketch-configuration",Editor.settingsKey=".sketch-config",Graph.prototype.defaultGridEnabled="1"==urlParams.grid,Graph.prototype.defaultPageVisible="1"==urlParams.pv,Graph.prototype.defaultEdgeLength=120,Editor.fitWindowBorders=new mxRectangle(60,30,30,30))},EditorUi.initTheme(),EditorUi.prototype.showImageDialog=function(e,t,i,n,l){var r=new ImageDialog(this,e,t,i,n,l);this.showDialog(r.container,Graph.fileSupport?480:360,Graph.fileSupport?200:90,!0,!0),r.init()},EditorUi.prototype.showBackgroundImageDialog=function(e,t){e=null!=e?e:mxUtils.bind(this,(function(e,t){if(!t){var i=new ChangePageSetup(this,null,e);i.ignoreColor=!0,this.editor.graph.model.execute(i)}}));var i=new BackgroundImageDialog(this,e,t);this.showDialog(i.container,360,200,!0,!0),i.init()},EditorUi.prototype.showLibraryDialog=function(e,t,i,n,l){var r=new LibraryDialog(this,e,t,i,n,l);this.showDialog(r.container,640,440,!0,!1,mxUtils.bind(this,(function(e){e&&null==this.getCurrentFile()&&"1"!=urlParams.embed&&this.showSplash()}))),r.init()};var n=EditorUi.prototype.createFormat;EditorUi.prototype.createFormat=function(e){var t=n.apply(this,arguments);return this.editor.graph.addListener("viewStateChanged",mxUtils.bind(this,(function(e){this.editor.graph.isSelectionEmpty()&&t.refresh()}))),t},EditorUi.prototype.createSidebarFooterContainer=function(){var e=this.createDiv("geSidebarContainer geSidebarFooter");e.style.position="absolute",e.style.overflow="hidden";var t=document.createElement("a");t.className="geTitle",t.style.color="#DF6C0C",t.style.fontWeight="bold",t.style.height="100%",t.style.paddingTop="9px",t.innerHTML="<span>+</span>";var i=t.getElementsByTagName("span")[0];return i.style.fontSize="18px",i.style.marginRight="5px",mxUtils.write(t,mxResources.get("moreShapes")+"..."),mxEvent.addListener(t,mxClient.IS_POINTER?"pointerdown":"mousedown",mxUtils.bind(this,(function(e){e.preventDefault()}))),mxEvent.addListener(t,"click",mxUtils.bind(this,(function(e){this.actions.get("shapes").funct(),mxEvent.consume(e)}))),e.appendChild(t),e},EditorUi.prototype.handleError=function(e,t,i,n,l,r,s){var o=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){},a=null!=e&&null!=e.error?e.error:e;if(null!=e&&null!=e.stack&&null!=e.message)try{s?null!=window.console&&console.error("EditorUi.handleError:",e):EditorUi.logError((""==e.message&&e.name,e.name),e.filename,e.lineNumber,e.columnNumber,e,"INFO")}catch(a){}if(null!=a||null!=t){var d=mxUtils.htmlEntities(mxResources.get("unknownError")),u=mxResources.get("ok"),h=null;if(t=null!=t?t:mxResources.get("error"),null!=a){if(null!=a.retry&&(u=mxResources.get("cancel"),h=function(){o(),a.retry()}),404==a.code||404==a.status||403==a.code){d=403==a.code?null!=a.message?mxUtils.htmlEntities(a.message):mxUtils.htmlEntities(mxResources.get("accessDenied")):null!=l?l:mxUtils.htmlEntities(mxResources.get("fileNotFoundOrDenied")+(null!=this.drive&&null!=this.drive.user?" ("+this.drive.user.displayName+", "+this.drive.user.email+")":""));var m=null!=l?null:null!=r?r:window.location.hash;if(null!=m&&("#G"==m.substring(0,2)||"#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D"==m.substring(0,45))&&(null!=e&&null!=e.error&&(null!=e.error.errors&&e.error.errors.length>0&&"fileAccess"==e.error.errors[0].reason||null!=e.error.data&&e.error.data.length>0&&"fileAccess"==e.error.data[0].reason)||404==a.code||404==a.status))return m="#U"==m.substring(0,2)?m.substring(45,m.lastIndexOf("%26ex")):m.substring(2),void this.showError(t,d,mxResources.get("openInNewWindow"),mxUtils.bind(this,(function(){this.editor.graph.openLink("https://drive.google.com/open?id="+m),this.handleError(e,t,i,n,l)})),h,mxResources.get("changeUser"),mxUtils.bind(this,(function(){var e=this.drive.getUsersList(),t=document.createElement("div"),i=document.createElement("span");i.style.marginTop="6px",mxUtils.write(i,mxResources.get("changeUser")+": "),t.appendChild(i);var n=document.createElement("select");function l(){n.innerHTML="";for(var t=0;t<e.length;t++){var i=document.createElement("option");mxUtils.write(i,e[t].displayName),i.value=t,n.appendChild(i),(i=document.createElement("option")).innerHTML=" ",mxUtils.write(i,"<"+e[t].email+">"),i.setAttribute("disabled","disabled"),n.appendChild(i)}i=document.createElement("option"),mxUtils.write(i,mxResources.get("addAccount")),i.value=e.length,n.appendChild(i)}n.style.width="200px",l(),mxEvent.addListener(n,"change",mxUtils.bind(this,(function(){var t=n.value,i=e.length!=t;i&&this.drive.setUser(e[t]),this.drive.authorize(i,mxUtils.bind(this,(function(){i||(e=this.drive.getUsersList(),l())})),mxUtils.bind(this,(function(e){this.handleError(e)})),!0)}))),t.appendChild(n);var r=new CustomDialog(this,t,mxUtils.bind(this,(function(){this.loadFile(window.location.hash.substr(1),!0)})));this.showDialog(r.container,300,100,!0,!0)})),mxResources.get("cancel"),mxUtils.bind(this,(function(){this.hideDialog(),null!=i&&i()})),480,150)}null!=a.message?d=""==a.message&&null!=a.name?mxUtils.htmlEntities(a.name):mxUtils.htmlEntities(a.message):null!=a.response&&null!=a.response.error?d=mxUtils.htmlEntities(a.response.error):void 0!==window.App&&(a.code==App.ERROR_TIMEOUT?d=mxUtils.htmlEntities(mxResources.get("timeout")):a.code==App.ERROR_BUSY?d=mxUtils.htmlEntities(mxResources.get("busy")):"string"==typeof a&&a.length>0&&(d=mxUtils.htmlEntities(a)))}var g=null,c=null;null!=a&&null!=a.helpLink?(g=mxResources.get("help"),c=mxUtils.bind(this,(function(){return this.editor.graph.openLink(a.helpLink)}))):null!=a&&null!=a.ownerEmail&&(g=mxResources.get("contactOwner"),d+=mxUtils.htmlEntities(" ("+g+": "+a.ownerEmail+")"),c=mxUtils.bind(this,(function(){return this.openLink("mailto:"+mxUtils.htmlEntities(a.ownerEmail))}))),this.showError(t,d,u,i,h,null,null,g,c,null,null,null,n?i:null)}else null!=i&&i()},EditorUi.prototype.alert=function(e,t,i){var n=new ErrorDialog(this,null,e,mxResources.get("ok"),t);this.showDialog(n.container,i||340,100,!0,!1),n.init()},EditorUi.prototype.confirm=function(e,t,i,n,l,r){var s=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){},o=Math.min(200,28*Math.ceil(e.length/50)),a=new ConfirmDialog(this,e,(function(){s(),null!=t&&t()}),(function(){s(),null!=i&&i()}),n,l,null,null,null,null,o);this.showDialog(a.container,340,46+o,!0,r),a.init()},EditorUi.prototype.showBanner=function(e,t,i,n){var l=!1;if(!(this.bannerShowing||this["hideBanner"+e]||isLocalStorage&&null!=mxSettings.settings&&null!=mxSettings.settings["close"+e])){var r=document.createElement("div");r.style.cssText="position:absolute;bottom:10px;left:50%;max-width:90%;padding:18px 34px 12px 20px;font-size:16px;font-weight:bold;white-space:nowrap;cursor:pointer;z-index:"+mxPopupMenu.prototype.zIndex+";",mxUtils.setPrefixedStyle(r.style,"box-shadow","1px 1px 2px 0px #ddd"),mxUtils.setPrefixedStyle(r.style,"transform","translate(-50%,120%)"),mxUtils.setPrefixedStyle(r.style,"transition","all 1s ease"),r.className="geBtn gePrimaryBtn";var s=document.createElement("img");s.setAttribute("src",IMAGE_PATH+"/logo.png"),s.setAttribute("border","0"),s.setAttribute("align","absmiddle"),s.style.cssText="margin-top:-4px;margin-left:8px;margin-right:12px;width:26px;height:26px;",r.appendChild(s);var o=document.createElement("img");o.setAttribute("src",Dialog.prototype.closeImage),o.setAttribute("title",mxResources.get(n?"doNotShowAgain":"close")),o.setAttribute("border","0"),o.style.cssText="position:absolute;right:10px;top:12px;filter:invert(1);padding:6px;margin:-6px;cursor:default;",r.appendChild(o),mxUtils.write(r,t),document.body.appendChild(r),this.bannerShowing=!0;var a=document.createElement("div");a.style.cssText="font-size:11px;text-align:center;font-weight:normal;";var d=document.createElement("input");if(d.setAttribute("type","checkbox"),d.setAttribute("id","geDoNotShowAgainCheckbox"),d.style.marginRight="6px",!n){a.appendChild(d);var u=document.createElement("label");u.setAttribute("for","geDoNotShowAgainCheckbox"),mxUtils.write(u,mxResources.get("doNotShowAgain")),a.appendChild(u),r.style.paddingBottom="30px",r.appendChild(a)}var h=mxUtils.bind(this,(function(){null!=r.parentNode&&(r.parentNode.removeChild(r),this.bannerShowing=!1,(d.checked||n)&&(this["hideBanner"+e]=!0,isLocalStorage&&null!=mxSettings.settings&&(mxSettings.settings["close"+e]=Date.now(),mxSettings.save())))}));mxEvent.addListener(o,"click",mxUtils.bind(this,(function(e){mxEvent.consume(e),h()})));var m=mxUtils.bind(this,(function(){mxUtils.setPrefixedStyle(r.style,"transform","translate(-50%,120%)"),window.setTimeout(mxUtils.bind(this,(function(){h()})),1e3)}));mxEvent.addListener(r,"click",mxUtils.bind(this,(function(e){var t=mxEvent.getSource(e);t!=d&&t!=u?(null!=i&&i(),h(),mxEvent.consume(e)):m()}))),window.setTimeout(mxUtils.bind(this,(function(){mxUtils.setPrefixedStyle(r.style,"transform","translate(-50%,0%)")})),500),window.setTimeout(m,3e4),l=!0}return l},EditorUi.prototype.setCurrentFile=function(e){null!=e&&(e.opened=new Date),this.currentFile=e},EditorUi.prototype.getCurrentFile=function(){return this.currentFile},EditorUi.prototype.isExportToCanvas=function(){return this.editor.isExportToCanvas()},EditorUi.prototype.createImageDataUri=function(e,t,i,n){var l=e.toDataURL("image/"+i);if(!(null!=l&&l.length>6))throw{message:mxResources.get("unknownError")};return null!=t&&(l=Editor.writeGraphModelToPng(l,"tEXt","mxfile",encodeURIComponent(t))),n>0&&(l=Editor.writeGraphModelToPng(l,"pHYs","dpi",n)),l},EditorUi.prototype.saveCanvas=function(e,t,i,n,l){var r="jpeg"==i?"jpg":i,s=this.getBaseFilename(n)+(null!=t?".drawio":"")+"."+r,o=this.createImageDataUri(e,t,i,l);this.saveData(s,r,o.substring(o.lastIndexOf(",")+1),"image/"+i,!0)},EditorUi.prototype.isLocalFileSave=function(){return"remote"!=urlParams.save&&(mxClient.IS_IE||void 0!==window.Blob&&void 0!==window.URL)&&9!=document.documentMode&&8!=document.documentMode&&7!=document.documentMode||this.isOfflineApp()||mxClient.IS_IOS},EditorUi.prototype.showTextDialog=function(e,t){var i=new TextareaDialog(this,e,t,null,null,mxResources.get("close"));i.textarea.style.width="600px",i.textarea.style.height="380px",this.showDialog(i.container,620,460,!0,!0,null,null,null,null,!0),i.init(),document.execCommand("selectall",!1,null)},EditorUi.prototype.doSaveLocalFile=function(e,t,i,n,l,r){if("text/xml"!=i||/(\.drawio)$/i.test(t)||/(\.xml)$/i.test(t)||/(\.svg)$/i.test(t)||/(\.html)$/i.test(t)||(t=t+"."+(r=null!=r?r:"drawio")),window.Blob&&navigator.msSaveOrOpenBlob){var s=n?this.base64ToBlob(e,i):new Blob([e],{type:i});navigator.msSaveOrOpenBlob(s,t)}else if(mxClient.IS_IE){var o=window.open("about:blank","_blank");null==o?mxUtils.popup(e,!0):(o.document.write(e),o.document.close(),o.document.execCommand("SaveAs",!0,t),o.close())}else if(mxClient.IS_IOS&&this.isOffline())navigator.standalone||null==i||"image/"!=i.substring(0,6)?this.showTextDialog(t+":",e):this.openInNewWindow(e,i,n);else{var a=document.createElement("a"),d=(null==navigator.userAgent||navigator.userAgent.indexOf("PaleMoon/")<0)&&void 0!==a.download;if(mxClient.IS_GC&&null!=navigator.userAgent){var u=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);d=65!=(!!u&&parseInt(u[2],10))&&d}if(d||this.isOffline()){a.href=URL.createObjectURL(n?this.base64ToBlob(e,i):new Blob([e],{type:i})),d?a.download=t:a.setAttribute("target","_blank"),document.body.appendChild(a);try{window.setTimeout((function(){URL.revokeObjectURL(a.href)}),2e4),a.click(),a.parentNode.removeChild(a)}catch(e){}}else this.createEchoRequest(e,t,i,n,l).simulate(document,"_blank")}},EditorUi.prototype.createEchoRequest=function(e,t,i,n,l,r){var s="xml="+encodeURIComponent(e);return new mxXmlRequest(SAVE_URL,s+(null!=i?"&mime="+i:"")+(null!=l?"&format="+l:"")+(null!=r?"&base64="+r:"")+(null!=t?"&filename="+encodeURIComponent(t):"")+(n?"&binary=1":""))},EditorUi.prototype.base64ToBlob=function(e,t){t=t||"";for(var i=1024,n=atob(e),l=n.length,r=Math.ceil(l/i),s=new Array(r),o=0;o<r;++o){for(var a=o*i,d=Math.min(a+i,l),u=new Array(d-a),h=a,m=0;h<d;++m,++h)u[m]=n[h].charCodeAt(0);s[o]=new Uint8Array(u)}return new Blob(s,{type:t})},EditorUi.prototype.saveLocalFile=function(e,t,i,n,l,r,s,o){r=null!=r&&r,s=null!=s?s:!("vsdx"==l||mxClient.IS_IOS&&navigator.standalone);var a=this.getServiceCount(r);isLocalStorage&&a++;var d=a<=4?2:a>6?4:3,u=new CreateDialog(this,t,mxUtils.bind(this,(function(t,l){try{if("_blank"==l)if(null!=i&&"image/"==i.substring(0,6))this.openInNewWindow(e,i,n);else if(null!=i&&"text/html"==i.substring(0,9)){var r=new EmbedDialog(this,e);this.showDialog(r.container,450,240,!0,!0),r.init()}else{var s=window.open("about:blank");null==s?mxUtils.popup(e,!0):(s.document.write("<pre>"+mxUtils.htmlEntities(e,!1)+"</pre>"),s.document.close())}else l==App.MODE_DEVICE||"download"==l?this.doSaveLocalFile(e,t,i,n,null,o):null!=t&&t.length>0&&this.pickFolder(l,mxUtils.bind(this,(function(r){try{this.exportFile(e,t,i,n,l,r)}catch(e){this.handleError(e)}})))}catch(e){this.handleError(e)}})),mxUtils.bind(this,(function(){this.hideDialog()})),mxResources.get("saveAs"),mxResources.get("download"),!1,r,s,null,a>1,d,e,i,n),h=this.isServices(a)?a>d?390:270:160;this.showDialog(u.container,420,h,!0,!0),u.init()},EditorUi.prototype.openInNewWindow=function(e,t,i){var n=window.open("about:blank");if(null==n||null==n.document)mxUtils.popup(e,!0);else if("image/svg+xml"!=t||mxClient.IS_SVG){if("image/svg+xml"==t)n.document.write("<html>"+e+"</html>");else{var l=i?e:btoa(unescape(encodeURIComponent(e)));n.document.write('<html><img style="max-width:100%;" src="data:'+t+";base64,"+l+'"/></html>')}n.document.close()}else n.document.write("<html><pre>"+mxUtils.htmlEntities(e,!1)+"</pre></html>"),n.document.close()};var l=EditorUi.prototype.addChromelessToolbarItems;EditorUi.prototype.isChromelessImageExportEnabled=function(){return"draw.io"!=this.getServiceName()||/.*\.draw\.io$/.test(window.location.hostname)||/.*\.diagrams\.net$/.test(window.location.hostname)},EditorUi.prototype.addChromelessToolbarItems=function(e){if(null!=urlParams.tags){this.tagsComponent=null,this.tagsDialog=null;var t=e(mxUtils.bind(this,(function(e){if(null==this.tagsComponent&&(this.tagsComponent=this.editor.graph.createTagsDialog(mxUtils.bind(this,(function(){return null!=this.tagsDialog})),!0),this.tagsComponent.div.getElementsByTagName("div")[0].style.position="",mxUtils.setPrefixedStyle(this.tagsComponent.div.style,"borderRadius","5px"),this.tagsComponent.div.className="geScrollable",this.tagsComponent.div.style.maxHeight="160px",this.tagsComponent.div.style.maxWidth="120px",this.tagsComponent.div.style.padding="4px",this.tagsComponent.div.style.overflow="auto",this.tagsComponent.div.style.height="auto",this.tagsComponent.div.style.position="fixed",this.tagsComponent.div.style.fontFamily=Editor.defaultHtmlFont,mxClient.IS_IE||mxClient.IS_IE11?(this.tagsComponent.div.style.backgroundColor="#ffffff",this.tagsComponent.div.style.border="2px solid black",this.tagsComponent.div.style.color="#000000"):(this.tagsComponent.div.style.backgroundColor="#000000",this.tagsComponent.div.style.color="#ffffff",mxUtils.setOpacity(this.tagsComponent.div,80))),null!=this.tagsDialog)this.tagsDialog.parentNode.removeChild(this.tagsDialog),this.tagsDialog=null;else{this.tagsDialog=this.tagsComponent.div,mxEvent.addListener(this.tagsDialog,"mouseleave",mxUtils.bind(this,(function(){null!=this.tagsDialog&&(this.tagsDialog.parentNode.removeChild(this.tagsDialog),this.tagsDialog=null)})));var i=t.getBoundingClientRect();this.tagsDialog.style.left=i.left+"px",this.tagsDialog.style.bottom=parseInt(this.chromelessToolbar.style.bottom)+this.chromelessToolbar.offsetHeight+4+"px";var n=mxUtils.getCurrentStyle(this.editor.graph.container);this.tagsDialog.style.zIndex=n.zIndex,document.body.appendChild(this.tagsDialog),this.tagsComponent.refresh(),this.editor.fireEvent(new mxEventObject("tagsDialogShown"))}mxEvent.consume(e)})),Editor.tagsImage,mxResources.get("tags")),i=this.editor.graph.getModel();i.addListener(mxEvent.CHANGE,mxUtils.bind(this,(function(){var e=this.editor.graph.getAllTags();t.style.display=e.length>0?"":"none"})))}if(l.apply(this,arguments),this.editor.addListener("tagsDialogShown",mxUtils.bind(this,(function(){null!=this.layersDialog&&(this.layersDialog.parentNode.removeChild(this.layersDialog),this.layersDialog=null)}))),this.editor.addListener("layersDialogShown",mxUtils.bind(this,(function(){null!=this.tagsDialog&&(this.tagsDialog.parentNode.removeChild(this.tagsDialog),this.tagsDialog=null)}))),this.editor.addListener("pageSelected",mxUtils.bind(this,(function(){null!=this.tagsDialog&&(this.tagsDialog.parentNode.removeChild(this.tagsDialog),this.tagsDialog=null),null!=this.layersDialog&&(this.layersDialog.parentNode.removeChild(this.layersDialog),this.layersDialog=null)}))),mxEvent.addListener(this.editor.graph.container,"click",mxUtils.bind(this,(function(){null!=this.tagsDialog&&(this.tagsDialog.parentNode.removeChild(this.tagsDialog),this.tagsDialog=null),null!=this.layersDialog&&(this.layersDialog.parentNode.removeChild(this.layersDialog),this.layersDialog=null)}))),this.isExportToCanvas()&&this.isChromelessImageExportEnabled()){this.exportDialog=null;var n=e(mxUtils.bind(this,(function(e){var t=mxUtils.bind(this,(function(){mxEvent.removeListener(this.editor.graph.container,"click",t),null!=this.exportDialog&&(this.exportDialog.parentNode.removeChild(this.exportDialog),this.exportDialog=null)}));if(null!=this.exportDialog)t.apply(this);else{this.exportDialog=document.createElement("div");var i=n.getBoundingClientRect();mxUtils.setPrefixedStyle(this.exportDialog.style,"borderRadius","5px"),this.exportDialog.style.position="fixed",this.exportDialog.style.textAlign="center",this.exportDialog.style.fontFamily=Editor.defaultHtmlFont,this.exportDialog.style.backgroundColor="#000000",this.exportDialog.style.width="50px",this.exportDialog.style.height="50px",this.exportDialog.style.padding="4px 2px 4px 2px",this.exportDialog.style.color="#ffffff",mxUtils.setOpacity(this.exportDialog,70),this.exportDialog.style.left=i.left+"px",this.exportDialog.style.bottom=parseInt(this.chromelessToolbar.style.bottom)+this.chromelessToolbar.offsetHeight+4+"px";var l=mxUtils.getCurrentStyle(this.editor.graph.container);this.exportDialog.style.zIndex=l.zIndex;var r=new Spinner({lines:8,length:6,width:5,radius:6,rotate:0,color:"#fff",speed:1.5,trail:60,shadow:!1,hwaccel:!1,top:"28px",zIndex:2e9});r.spin(this.exportDialog),this.editor.exportToCanvas(mxUtils.bind(this,(function(e){r.stop(),this.exportDialog.style.width="auto",this.exportDialog.style.height="auto",this.exportDialog.style.padding="10px";var i=this.createImageDataUri(e,null,"png"),n=document.createElement("img");n.style.maxWidth="140px",n.style.maxHeight="140px",n.style.cursor="pointer",n.style.backgroundColor="white",n.setAttribute("title",mxResources.get("openInNewWindow")),n.setAttribute("border","0"),n.setAttribute("src",i),this.exportDialog.appendChild(n),mxEvent.addListener(n,"click",mxUtils.bind(this,(function(){this.openInNewWindow(i.substring(i.indexOf(",")+1),"image/png",!0),t.apply(this,arguments)})))})),null,this.thumbImageCache,null,mxUtils.bind(this,(function(e){this.spinner.stop(),this.handleError(e)})),null,null,null,null,null,null,null,Editor.defaultBorder),mxEvent.addListener(this.editor.graph.container,"click",t),document.body.appendChild(this.exportDialog)}mxEvent.consume(e)})),Editor.cameraImage,mxResources.get("export"))}},EditorUi.prototype.saveData=function(e,t,i,n,l){this.isLocalFileSave()?this.saveLocalFile(i,e,n,l,t):this.saveRequest(e,t,mxUtils.bind(this,(function(e,r){return this.createEchoRequest(i,e,n,l,t,r)})),i,l,n)},EditorUi.prototype.saveRequest=function(e,t,i,n,l,r,s){s=null!=s?s:!mxClient.IS_IOS||!navigator.standalone;var o=this.getServiceCount(!1);isLocalStorage&&o++;var a=o<=4?2:o>6?4:3,d=new CreateDialog(this,e,mxUtils.bind(this,(function(e,l){if("_blank"==l||null!=e&&e.length>0){var s=l==App.MODE_DEVICE||"download"==l||null==l||"_blank"==l?"0":"1",o=i("_blank"==l?null:e,s);null!=o&&(l==App.MODE_DEVICE||"download"==l||"_blank"==l?o.simulate(document,"_blank"):this.pickFolder(l,mxUtils.bind(this,(function(i){if(r=null!=r?r:"pdf"==t?"application/pdf":"image/"+t,null!=n)try{this.exportFile(n,e,r,!0,l,i)}catch(e){this.handleError(e)}else this.spinner.spin(document.body,mxResources.get("saving"))&&o.send(mxUtils.bind(this,(function(){if(this.spinner.stop(),o.getStatus()>=200&&o.getStatus()<=299)try{this.exportFile(o.getText(),e,r,!0,l,i)}catch(e){this.handleError(e)}else this.handleError({message:mxResources.get("errorSavingFile")})})),(function(e){this.spinner.stop(),this.handleError(e)}))}))))}})),mxUtils.bind(this,(function(){this.hideDialog()})),mxResources.get("saveAs"),mxResources.get("download"),!1,!1,s,null,o>1,a,n,r,l),u=this.isServices(o)?o>4?390:270:160;this.showDialog(d.container,420,u,!0,!0),d.init()},EditorUi.prototype.isServices=function(e){return 1!=e},EditorUi.prototype.getEditBlankXml=function(){return this.getFileData(!0)},EditorUi.prototype.exportFile=function(e,t,i,n,l,r){},EditorUi.prototype.pickFolder=function(e,t,i){t(null)},EditorUi.prototype.exportSvg=function(e,t,i,n,l,r,s,o,a,d,u,h,m,g){if(this.spinner.spin(document.body,mxResources.get("export")))try{var c=this.editor.graph.isSelectionEmpty();i=null!=i?i:c;var p=t?null:this.editor.graph.background;p==mxConstants.NONE&&(p=null),null==p&&0==t&&(p=u?this.editor.graph.defaultPageBackgroundColor:"#ffffff");var f=this.editor.graph.getSvg(p,e,s,o,null,i,null,null,"blank"==d?"_blank":"self"==d?"_top":null,null,!0,u,h);n&&this.editor.graph.addSvgShadow(f);var x=this.getBaseFilename()+(l?".drawio":"")+".svg";g=null!=g?g:mxUtils.bind(this,(function(e){this.isLocalFileSave()||e.length<=MAX_REQUEST_SIZE?this.saveData(x,"svg",e,"image/svg+xml"):this.handleError({message:mxResources.get("drawingTooLarge")},mxResources.get("error"),mxUtils.bind(this,(function(){mxUtils.popup(e)})))}));var v=mxUtils.bind(this,(function(e){this.spinner.stop(),l&&e.setAttribute("content",this.getFileData(!0,null,null,null,i,a,null,null,null,!1)),g(Graph.xmlDeclaration+"\n"+(l?Graph.svgFileComment+"\n":"")+Graph.svgDoctype+"\n"+mxUtils.getXml(e))}));this.editor.graph.mathEnabled&&this.editor.addMathCss(f);var b=mxUtils.bind(this,(function(e){r?(null==this.thumbImageCache&&(this.thumbImageCache=new Object),this.editor.convertImages(e,v,this.thumbImageCache)):v(e)}));m?this.embedFonts(f,b):(this.editor.addFontCss(f),b(f))}catch(e){this.handleError(e)}},EditorUi.prototype.addRadiobox=function(e,t,i,n,l,r,s){return this.addCheckbox(e,i,n,l,r,s,!0,t)},EditorUi.prototype.addCheckbox=function(e,t,i,n,l,r,s,o){r=null==r||r;var a=document.createElement("input");a.style.marginRight="8px",a.style.marginTop="16px",a.setAttribute("type",s?"radio":"checkbox");var d="geCheckbox-"+Editor.guid();if(a.id=d,null!=o&&a.setAttribute("name",o),i&&(a.setAttribute("checked","checked"),a.defaultChecked=!0),n&&a.setAttribute("disabled","disabled"),r){e.appendChild(a);var u=document.createElement("label");mxUtils.write(u,t),u.setAttribute("for",d),e.appendChild(u),l||mxUtils.br(e)}return a},EditorUi.prototype.addEditButton=function(e,t){var i=this.addCheckbox(e,mxResources.get("edit")+":",!0,null,!0);i.style.marginLeft="24px";var n=this.getCurrentFile(),l="";null!=n&&n.getMode()!=App.MODE_DEVICE&&n.getMode()!=App.MODE_BROWSER&&(l=window.location.href);var r=document.createElement("select");r.style.width="120px",r.style.marginLeft="8px",r.style.marginRight="10px",r.className="geBtn";var s=document.createElement("option");s.setAttribute("value","blank"),mxUtils.write(s,mxResources.get("makeCopy")),r.appendChild(s);var o=document.createElement("option");return o.setAttribute("value","custom"),mxUtils.write(o,mxResources.get("custom")+"..."),r.appendChild(o),e.appendChild(r),mxEvent.addListener(r,"change",mxUtils.bind(this,(function(){if("custom"==r.value){var e=new FilenameDialog(this,l,mxResources.get("ok"),(function(e){null!=e?l=e:r.value="blank"}),mxResources.get("url"),null,null,null,null,(function(){r.value="blank"}));this.showDialog(e.container,300,80,!0,!1),e.init()}}))),mxEvent.addListener(i,"change",mxUtils.bind(this,(function(){i.checked&&(null==t||t.checked)?r.removeAttribute("disabled"):r.setAttribute("disabled","disabled")}))),mxUtils.br(e),{getLink:function(){return i.checked?"blank"===r.value?"_blank":l:null},getEditInput:function(){return i},getEditSelect:function(){return r}}},EditorUi.prototype.addLinkSection=function(e,t){mxUtils.write(e,mxResources.get("links")+":");var i=document.createElement("select");i.style.width="100px",i.style.marginLeft="8px",i.style.marginRight="10px",i.className="geBtn";var n=document.createElement("option");n.setAttribute("value","auto"),mxUtils.write(n,mxResources.get("automatic")),i.appendChild(n);var l=document.createElement("option");l.setAttribute("value","blank"),mxUtils.write(l,mxResources.get("openInNewWindow")),i.appendChild(l);var r=document.createElement("option");if(r.setAttribute("value","self"),mxUtils.write(r,mxResources.get("openInThisWindow")),i.appendChild(r),t){var s=document.createElement("option");s.setAttribute("value","frame"),mxUtils.write(s,mxResources.get("openInThisWindow")+" ("+mxResources.get("iframe")+")"),i.appendChild(s)}e.appendChild(i),mxUtils.write(e,mxResources.get("borderColor")+":");var o="#0000ff",a=null;function d(){var e=document.createElement("div");e.style.width="100%",e.style.height="100%",e.style.boxSizing="border-box",null!=o&&o!=mxConstants.NONE?(e.style.border="1px solid black",e.style.backgroundColor=o):(e.style.backgroundPosition="center center",e.style.backgroundRepeat="no-repeat",e.style.backgroundImage="url('"+Dialog.prototype.closeImage+"')"),a.innerHTML="",a.appendChild(e)}return a=mxUtils.button("",mxUtils.bind(this,(function(e){this.pickColor(o||"none",(function(e){o=e,d()})),mxEvent.consume(e)}))),d(),a.style.padding=mxClient.IS_FF?"4px 2px 4px 2px":"4px",a.style.marginLeft="4px",a.style.height="22px",a.style.width="22px",a.style.position="relative",a.style.top=mxClient.IS_IE||mxClient.IS_IE11||mxClient.IS_EDGE?"6px":"1px",a.className="geColorBtn",e.appendChild(a),mxUtils.br(e),{getColor:function(){return o},getTarget:function(){return i.value},focus:function(){i.focus()}}},EditorUi.prototype.createUrlParameters=function(e,t,i,n,l,r,s){return s=null!=s?s:[],n&&("https://viewer.diagrams.net"==EditorUi.lightboxHost&&"1"!=urlParams.dev||s.push("lightbox=1"),"auto"!=e&&s.push("target="+e),null!=t&&t!=mxConstants.NONE&&s.push("highlight="+("#"==t.charAt(0)?t.substring(1):t)),null!=l&&l.length>0&&s.push("edit="+encodeURIComponent(l)),r&&s.push("layers=1"),this.editor.graph.foldingEnabled&&s.push("nav=1")),i&&null!=this.currentPage&&null!=this.pages&&this.currentPage!=this.pages[0]&&s.push("page-id="+this.currentPage.getId()),s},EditorUi.prototype.createLink=function(e,t,i,n,l,r,s,o,a,d){a=this.createUrlParameters(e,t,i,n,l,r,a);var u=this.getCurrentFile(),h=!0,m="";return null!=s?m="#U"+encodeURIComponent(s):(u=this.getCurrentFile(),o||null==u||u.constructor!=window.DriveFile?m="#R"+encodeURIComponent(i?this.getFileData(!0,null,null,null,null,null,null,!0,null,!1):Graph.compress(mxUtils.getXml(this.editor.getGraphXml()))):(m="#"+u.getHash(),h=!1)),h&&null!=u&&null!=u.getTitle()&&u.getTitle()!=this.defaultFilename&&a.push("title="+encodeURIComponent(u.getTitle())),d&&m.length>1&&(a.push("open="+m.substring(1)),m=""),(n&&"1"!=urlParams.dev?EditorUi.lightboxHost:mxClient.IS_CHROMEAPP||EditorUi.isElectronApp||!/.*\.draw\.io$/.test(window.location.hostname)?EditorUi.drawHost:"https://"+window.location.host)+"/"+(a.length>0?"?"+a.join("&"):"")+m},EditorUi.prototype.createHtml=function(e,t,i,n,l,r,s,o,a,d,u,h){this.getBasenames();var m={};""!=l&&l!=mxConstants.NONE&&(m.highlight=l),"auto"!==n&&(m.target=n),d||(m.lightbox=!1),m.nav=this.editor.graph.foldingEnabled;var g=parseInt(i);isNaN(g)||100==g||(m.zoom=g/100);var c=[];s&&(c.push("pages"),m.resize=!0,null!=this.pages&&null!=this.currentPage&&(m.page=mxUtils.indexOf(this.pages,this.currentPage))),t&&(c.push("zoom"),m.resize=!0),o&&c.push("layers"),a&&c.push("tags"),c.length>0&&(d&&c.push("lightbox"),m.toolbar=c.join(" ")),null!=u&&u.length>0&&(m.edit=u),null!=e?m.url=e:m.xml=this.getFileData(!0,null,null,null,null,!s);var p='<div class="mxgraph" style="'+(r?"max-width:100%;":"")+(""!=c?"border:1px solid transparent;":"")+'" data-mxgraph="'+mxUtils.htmlEntities(JSON.stringify(m))+'"></div>',f=null!=e?"&fetch="+encodeURIComponent(e):"";h(p,'<script type="text/javascript" src="'+(f.length>0?("1"==urlParams.dev?"https://test.draw.io/embed2.js?dev=1":EditorUi.lightboxHost+"/embed2.js?")+f:"1"==urlParams.dev?"https://test.draw.io/js/viewer-static.min.js":window.DRAWIO_VIEWER_URL?window.DRAWIO_VIEWER_URL:EditorUi.lightboxHost+"/js/viewer-static.min.js")+'"><\/script>')},EditorUi.prototype.showHtmlDialog=function(e,t,i,n){var l=document.createElement("div");l.style.whiteSpace="nowrap",this.editor.graph;var r=document.createElement("h3");mxUtils.write(r,mxResources.get("html")),r.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:12px",l.appendChild(r);var s=document.createElement("div");s.style.cssText="border-bottom:1px solid lightGray;padding-bottom:8px;margin-bottom:12px;";var o=document.createElement("input");o.style.cssText="margin-right:8px;margin-top:8px;margin-bottom:8px;",o.setAttribute("value","url"),o.setAttribute("type","radio"),o.setAttribute("name","type-embedhtmldialog");var a=o.cloneNode(!0);a.setAttribute("value","copy"),s.appendChild(a);var d=document.createElement("span");mxUtils.write(d,mxResources.get("includeCopyOfMyDiagram")),s.appendChild(d),mxUtils.br(s),s.appendChild(o),d=document.createElement("span"),mxUtils.write(d,mxResources.get("publicDiagramUrl")),s.appendChild(d);var u=this.getCurrentFile();if(null==i&&null!=u&&u.constructor==window.DriveFile){var h=document.createElement("a");h.style.paddingLeft="12px",h.style.color="gray",h.style.cursor="pointer",mxUtils.write(h,mxResources.get("share")),s.appendChild(h),mxEvent.addListener(h,"click",mxUtils.bind(this,(function(){this.hideDialog(),this.drive.showPermissions(u.getId())})))}a.setAttribute("checked","checked"),null==i&&o.setAttribute("disabled","disabled"),l.appendChild(s);var m=this.addLinkSection(l),g=this.addCheckbox(l,mxResources.get("zoom"),!0,null,!0);mxUtils.write(l,":");var c=document.createElement("input");c.setAttribute("type","text"),c.style.marginRight="16px",c.style.width="60px",c.style.marginLeft="4px",c.style.marginRight="12px",c.value="100%",l.appendChild(c);var p=this.addCheckbox(l,mxResources.get("fit"),!0),f=null!=this.pages&&this.pages.length>1,x=x=this.addCheckbox(l,mxResources.get("allPages"),f,!f),v=this.addCheckbox(l,mxResources.get("layers"),!0),b=this.addCheckbox(l,mxResources.get("tags"),!0),y=this.addCheckbox(l,mxResources.get("lightbox"),!0),E=this.addEditButton(l,y),w=E.getEditInput();w.style.marginBottom="16px",mxEvent.addListener(y,"change",(function(){y.checked?w.removeAttribute("disabled"):w.setAttribute("disabled","disabled"),w.checked&&y.checked?E.getEditSelect().removeAttribute("disabled"):E.getEditSelect().setAttribute("disabled","disabled")}));var C=new CustomDialog(this,l,mxUtils.bind(this,(function(){n(o.checked?i:null,g.checked,c.value,m.getTarget(),m.getColor(),p.checked,x.checked,v.checked,b.checked,y.checked,E.getLink())})),null,e,t);this.showDialog(C.container,340,430,!0,!0),a.focus()},EditorUi.prototype.showPublishLinkDialog=function(e,t,i,n,l,r,s,o){var a=document.createElement("div");a.style.whiteSpace="nowrap",this.editor.graph;var d=document.createElement("h3");mxUtils.write(d,e||mxResources.get("link")),d.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:12px",a.appendChild(d);var u=this.getCurrentFile(),h=0;if(null==u||u.constructor!=window.DriveFile||t)s=null!=s?s:"https://www.diagrams.net/doc/faq/publish-diagram-as-link";else{h=80,s=null!=s?s:"https://www.diagrams.net/doc/faq/google-drive-publicly-publish-diagram";var m=document.createElement("div");m.style.cssText="border-bottom:1px solid lightGray;padding-bottom:14px;padding-top:6px;margin-bottom:14px;text-align:center;";var g=document.createElement("div");g.style.whiteSpace="normal",mxUtils.write(g,mxResources.get("linkAccountRequired")),m.appendChild(g);var c=mxUtils.button(mxResources.get("share"),mxUtils.bind(this,(function(){this.drive.showPermissions(u.getId())})));c.style.marginTop="12px",c.className="geBtn",m.appendChild(c),a.appendChild(m);var p=document.createElement("a");p.style.paddingLeft="12px",p.style.color="gray",p.style.fontSize="11px",p.style.cursor="pointer",mxUtils.write(p,mxResources.get("check")),m.appendChild(p),mxEvent.addListener(p,"click",mxUtils.bind(this,(function(){this.spinner.spin(document.body,mxResources.get("loading"))&&this.getPublicUrl(this.getCurrentFile(),mxUtils.bind(this,(function(e){this.spinner.stop();var t=new ErrorDialog(this,null,mxResources.get(null!=e?"diagramIsPublic":"diagramIsNotPublic"),mxResources.get("ok"));this.showDialog(t.container,300,80,!0,!1),t.init()})))})))}var f=null,x=null;null==i&&null==n||(h+=30,mxUtils.write(a,mxResources.get("width")+":"),(f=document.createElement("input")).setAttribute("type","text"),f.style.marginRight="16px",f.style.width="50px",f.style.marginLeft="6px",f.style.marginRight="16px",f.style.marginBottom="10px",f.value="100%",a.appendChild(f),mxUtils.write(a,mxResources.get("height")+":"),(x=document.createElement("input")).setAttribute("type","text"),x.style.width="50px",x.style.marginLeft="6px",x.style.marginBottom="10px",x.value=n+"px",a.appendChild(x),mxUtils.br(a));var v=this.addLinkSection(a,r),b=null!=this.pages&&this.pages.length>1,y=null;(null==u||u.constructor!=window.DriveFile||t)&&(y=this.addCheckbox(a,mxResources.get("allPages"),b,!b));var E=this.addCheckbox(a,mxResources.get("lightbox"),!0,null,null,!r),w=this.addEditButton(a,E),C=w.getEditInput();r&&(C.style.marginLeft=E.style.marginLeft,E.style.display="none",h-=20);var U=this.addCheckbox(a,mxResources.get("layers"),!0);U.style.marginLeft=C.style.marginLeft,U.style.marginTop="8px";var S=this.addCheckbox(a,mxResources.get("tags"),!0);S.style.marginLeft=C.style.marginLeft,S.style.marginBottom="16px",S.style.marginTop="16px",mxEvent.addListener(E,"change",(function(){E.checked?(U.removeAttribute("disabled"),C.removeAttribute("disabled")):(U.setAttribute("disabled","disabled"),C.setAttribute("disabled","disabled")),C.checked&&E.checked?w.getEditSelect().removeAttribute("disabled"):w.getEditSelect().setAttribute("disabled","disabled")}));var R=new CustomDialog(this,a,mxUtils.bind(this,(function(){l(v.getTarget(),v.getColor(),null==y||y.checked,E.checked,w.getLink(),U.checked,null!=f?f.value:null,null!=x?x.value:null,S.checked)})),null,mxResources.get("create"),s,o);this.showDialog(R.container,340,300+h,!0,!0),null!=f?(f.focus(),mxClient.IS_GC||mxClient.IS_FF||document.documentMode>=5?f.select():document.execCommand("selectAll",!1,null)):v.focus()},EditorUi.prototype.showRemoteExportDialog=function(e,t,i,n,l){var r=document.createElement("div");r.style.whiteSpace="nowrap";var s=document.createElement("h3");if(mxUtils.write(s,mxResources.get("image")),s.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:"+(l?"10":"4")+"px",r.appendChild(s),l){mxUtils.write(r,mxResources.get("zoom")+":");var o=document.createElement("input");o.setAttribute("type","text"),o.style.marginRight="16px",o.style.width="60px",o.style.marginLeft="4px",o.style.marginRight="12px",o.value=this.lastExportZoom||"100%",r.appendChild(o),mxUtils.write(r,mxResources.get("borderWidth")+":");var a=document.createElement("input");a.setAttribute("type","text"),a.style.marginRight="16px",a.style.width="60px",a.style.marginLeft="4px",a.value=this.lastExportBorder||"0",r.appendChild(a),mxUtils.br(r)}var d=this.addCheckbox(r,mxResources.get("selectionOnly"),!1,this.editor.graph.isSelectionEmpty()),u=n?null:this.addCheckbox(r,mxResources.get("includeCopyOfMyDiagram"),Editor.defaultIncludeDiagram),h=this.editor.graph,m=n?null:this.addCheckbox(r,mxResources.get("transparentBackground"),h.background==mxConstants.NONE||null==h.background);null!=m&&(m.style.marginBottom="16px");var g=new CustomDialog(this,r,mxUtils.bind(this,(function(){var e=parseInt(o.value)/100||1,t=parseInt(a.value)||0;i(!d.checked,null!=u&&u.checked,null!=m&&m.checked,e,t)})),null,e,t);this.showDialog(g.container,300,(l?25:0)+(n?125:210),!0,!0)},EditorUi.prototype.showExportDialog=function(e,t,i,n,l,r,s,o,a){s=null!=s?s:Editor.defaultIncludeDiagram;var d=document.createElement("div");d.style.whiteSpace="nowrap";var u=this.editor.graph,h="jpeg"==o?220:300,m=document.createElement("h3");mxUtils.write(m,e),m.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:10px",d.appendChild(m),mxUtils.write(d,mxResources.get("zoom")+":");var g=document.createElement("input");g.setAttribute("type","text"),g.style.marginRight="16px",g.style.width="60px",g.style.marginLeft="4px",g.style.marginRight="12px",g.value=this.lastExportZoom||"100%",d.appendChild(g),mxUtils.write(d,mxResources.get("borderWidth")+":");var c=document.createElement("input");c.setAttribute("type","text"),c.style.marginRight="16px",c.style.width="60px",c.style.marginLeft="4px",c.value=this.lastExportBorder||"0",d.appendChild(c),mxUtils.br(d);var p=this.addCheckbox(d,mxResources.get("selectionOnly"),!1,u.isSelectionEmpty()),f=document.createElement("input");f.style.marginTop="16px",f.style.marginRight="8px",f.style.marginLeft="24px",f.setAttribute("disabled","disabled"),f.setAttribute("type","checkbox");var x=document.createElement("select");x.style.marginTop="16px",x.style.marginLeft="8px";for(var v=["selectionOnly","diagram","page"],b=0;b<v.length;b++)if(!u.isSelectionEmpty()||"selectionOnly"!=v[b]){var y=document.createElement("option");mxUtils.write(y,mxResources.get(v[b])),y.setAttribute("value",v[b]),x.appendChild(y)}a?(mxUtils.write(d,mxResources.get("size")+":"),d.appendChild(x),mxUtils.br(d),h+=26,mxEvent.addListener(x,"change",(function(){"selectionOnly"==x.value&&(p.checked=!0)}))):r&&(d.appendChild(f),mxUtils.write(d,mxResources.get("crop")),mxUtils.br(d),h+=30,mxEvent.addListener(p,"change",(function(){p.checked?f.removeAttribute("disabled"):f.setAttribute("disabled","disabled")}))),u.isSelectionEmpty()?a&&(p.style.display="none",p.nextSibling.style.display="none",p.nextSibling.nextSibling.style.display="none",h-=30):(x.value="diagram",f.setAttribute("checked","checked"),f.defaultChecked=!0,mxEvent.addListener(p,"change",(function(){p.checked?x.value="selectionOnly":x.value="diagram"})));var E=this.addCheckbox(d,mxResources.get("transparentBackground"),!1,null,null,"jpeg"!=o),w=null;Editor.isDarkMode()&&(w=this.addCheckbox(d,mxResources.get("dark"),!0),h+=26);var C=this.addCheckbox(d,mxResources.get("shadow"),u.shadowVisible),U=document.createElement("input");U.style.marginTop="16px",U.style.marginRight="8px",U.setAttribute("type","checkbox");var S=document.createElement("input");S.style.marginTop="16px",S.style.marginRight="8px",S.setAttribute("type","checkbox"),!this.isOffline()&&this.canvasSupported||U.setAttribute("disabled","disabled"),t&&(d.appendChild(U),mxUtils.write(d,mxResources.get("embedImages")),mxUtils.br(d),d.appendChild(S),mxUtils.write(d,mxResources.get("embedFonts")),mxUtils.br(d),h+=60);var R=null;"png"!=o&&"jpeg"!=o||(R=this.addCheckbox(d,mxResources.get("grid"),!1,this.isOffline()||!this.canvasSupported,!1,!0),h+=30);var D=this.addCheckbox(d,mxResources.get("includeCopyOfMyDiagram"),s,null,null,"jpeg"!=o);D.style.marginBottom="16px";var k=document.createElement("select");k.style.maxWidth="260px",k.style.marginLeft="8px",k.style.marginRight="10px",k.className="geBtn";var A=document.createElement("option");A.setAttribute("value","auto"),mxUtils.write(A,mxResources.get("automatic")),k.appendChild(A);var I=document.createElement("option");I.setAttribute("value","blank"),mxUtils.write(I,mxResources.get("openInNewWindow")),k.appendChild(I);var L=document.createElement("option");L.setAttribute("value","self"),mxUtils.write(L,mxResources.get("openInThisWindow")),k.appendChild(L),"svg"==o&&(mxUtils.write(d,mxResources.get("links")+":"),d.appendChild(k),mxUtils.br(d),mxUtils.br(d),h+=50);var F=new CustomDialog(this,d,mxUtils.bind(this,(function(){this.lastExportBorder=c.value,this.lastExportZoom=g.value,l(g.value,E.checked,!p.checked,C.checked,D.checked,U.checked,c.value,f.checked,!1,k.value,null!=R?R.checked:null,null!=w?w.checked:null,x.value,S.checked)})),null,i,n);this.showDialog(F.container,340,h,!0,!0,null,null,null,null,!0),g.focus(),mxClient.IS_GC||mxClient.IS_FF||document.documentMode>=5?g.select():document.execCommand("selectAll",!1,null)},EditorUi.prototype.showEmbedImageDialog=function(e,t,i,n,l){var r=document.createElement("div");r.style.whiteSpace="nowrap";var s=this.editor.graph;if(null!=t){var o=document.createElement("h3");mxUtils.write(o,t),o.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:4px",r.appendChild(o)}var a=this.addCheckbox(r,mxResources.get("fit"),!0),d=this.addCheckbox(r,mxResources.get("shadow"),s.shadowVisible&&n,!n),u=this.addCheckbox(r,i),h=this.addCheckbox(r,mxResources.get("lightbox"),!0),m=this.addEditButton(r,h),g=m.getEditInput(),c=s.model.getChildCount(s.model.getRoot())>1,p=this.addCheckbox(r,mxResources.get("layers"),c,!c);p.style.marginLeft=g.style.marginLeft,p.style.marginBottom="12px",p.style.marginTop="8px",mxEvent.addListener(h,"change",(function(){h.checked?(c&&p.removeAttribute("disabled"),g.removeAttribute("disabled")):(p.setAttribute("disabled","disabled"),g.setAttribute("disabled","disabled")),g.checked&&h.checked?m.getEditSelect().removeAttribute("disabled"):m.getEditSelect().setAttribute("disabled","disabled")}));var f=new CustomDialog(this,r,mxUtils.bind(this,(function(){e(a.checked,d.checked,u.checked,h.checked,m.getLink(),p.checked)})),null,mxResources.get("embed"),l);this.showDialog(f.container,280,300,!0,!0)},EditorUi.prototype.createEmbedImage=function(e,t,i,n,l,r,s,o){var a=this.editor.graph.getGraphBounds(),d=this.getSelectedPageIndex();function u(t){var o=" ",u="";n&&(o=" onclick=\"(function(img){if(img.wnd!=null&&!img.wnd.closed){img.wnd.focus();}else{var r=function(evt){if(evt.data=='ready'&&evt.source==img.wnd){img.wnd.postMessage(decodeURIComponent(img.getAttribute('src')),'*');window.removeEventListener('message',r);}};window.addEventListener('message',r);img.wnd=window.open('"+EditorUi.lightboxHost+"/?client=1"+(null!=d?"&page="+d:"")+(l?"&edit=_blank":"")+(r?"&layers=1":"")+"');}})(this);\"",u+="cursor:pointer;"),e&&(u+="max-width:100%;");var h="";i&&(h=' width="'+Math.round(a.width)+'" height="'+Math.round(a.height)+'"'),s('<img src="'+t+'"'+h+(""!=u?' style="'+u+'"':"")+o+"/>")}if(this.isExportToCanvas())this.editor.exportToCanvas(mxUtils.bind(this,(function(e){var t=n?this.getFileData(!0):null;u(this.createImageDataUri(e,t,"png"))})),null,null,null,mxUtils.bind(this,(function(e){o({message:mxResources.get("unknownError")})})),null,!0,i?2:1,null,t,null,null,Editor.defaultBorder);else{var h=this.getFileData(!0);if(a.width*a.height<=MAX_AREA&&h.length<=MAX_REQUEST_SIZE){var m="";i&&(m="&w="+Math.round(2*a.width)+"&h="+Math.round(2*a.height));var g=new mxXmlRequest(EXPORT_URL,"format=png&base64=1&embedXml="+(n?"1":"0")+m+"&xml="+encodeURIComponent(h));g.send(mxUtils.bind(this,(function(){g.getStatus()>=200&&g.getStatus()<=299?u("data:image/png;base64,"+g.getText()):o({message:mxResources.get("unknownError")})})))}else o({message:mxResources.get("drawingTooLarge")})}},EditorUi.prototype.createEmbedSvg=function(e,t,i,n,l,r,s){var o=this.editor.graph.getSvg(null,null,null,null,null,null,null,null,null,null,!i),a=o.getElementsByTagName("a");if(null!=a)for(var d=0;d<a.length;d++){var u=a[d].getAttribute("href");null!=u&&"#"==u.charAt(0)&&"_blank"==a[d].getAttribute("target")&&a[d].removeAttribute("target")}if(n&&o.setAttribute("content",this.getFileData(!0)),t&&this.editor.graph.addSvgShadow(o),i){var h=" ",m="";n&&(h="onclick=\"(function(img){if(img.wnd!=null&&!img.wnd.closed){img.wnd.focus();}else{var r=function(evt){if(evt.data=='ready'&&evt.source==img.wnd){img.wnd.postMessage(decodeURIComponent(img.getAttribute('src')),'*');window.removeEventListener('message',r);}};window.addEventListener('message',r);img.wnd=window.open('"+EditorUi.lightboxHost+"/?client=1"+(l?"&edit=_blank":"")+(r?"&layers=1":"")+"');}})(this);\"",m+="cursor:pointer;"),e&&(m+="max-width:100%;"),this.editor.convertImages(o,mxUtils.bind(this,(function(e){s('<img src="'+Editor.createSvgDataUri(mxUtils.getXml(e))+'"'+(""!=m?' style="'+m+'"':"")+h+"/>")})))}else{if(m="",n){var g=this.getSelectedPageIndex(),c="(function(svg){var src=window.event.target||window.event.srcElement;while (src!=null&&src.nodeName.toLowerCase()!='a'){src=src.parentNode;}if(src==null){if(svg.wnd!=null&&!svg.wnd.closed){svg.wnd.focus();}else{var r=function(evt){if(evt.data=='ready'&&evt.source==svg.wnd){svg.wnd.postMessage(decodeURIComponent(svg.getAttribute('content')),'*');window.removeEventListener('message',r);}};window.addEventListener('message',r);svg.wnd=window.open('"+EditorUi.lightboxHost+"/?client=1"+(null!=g?"&page="+g:"")+(l?"&edit=_blank":"")+(r?"&layers=1":"")+"');}}})(this);";o.setAttribute("onclick",c),m+="cursor:pointer;"}if(e){var p=parseInt(o.getAttribute("width")),f=parseInt(o.getAttribute("height"));o.setAttribute("viewBox","-0.5 -0.5 "+p+" "+f),m+="max-width:100%;max-height:"+f+"px;",o.removeAttribute("height")}""!=m&&o.setAttribute("style",m),this.editor.addFontCss(o),this.editor.graph.mathEnabled&&this.editor.addMathCss(o),s(mxUtils.getXml(o))}},EditorUi.prototype.timeSince=function(e){var t=Math.floor((new Date-e)/1e3),i=Math.floor(t/31536e3);return i>1?i+" "+mxResources.get("years"):(i=Math.floor(t/2592e3))>1?i+" "+mxResources.get("months"):(i=Math.floor(t/86400))>1?i+" "+mxResources.get("days"):(i=Math.floor(t/3600))>1?i+" "+mxResources.get("hours"):(i=Math.floor(t/60))>1?i+" "+mxResources.get("minutes"):1==i?i+" "+mxResources.get("minute"):null},EditorUi.prototype.decodeNodeIntoGraph=function(e,t){if(null!=e){var i=null;if("diagram"==e.nodeName)i=e;else if("mxfile"==e.nodeName){var n=e.getElementsByTagName("diagram");if(n.length>0){i=n[0];var l=t.getGlobalVariable;t.getGlobalVariable=function(e){return"page"==e?i.getAttribute("name")||mxResources.get("pageWithNumber",[1]):"pagenumber"==e?1:l.apply(this,arguments)}}}null!=i&&(e=Editor.parseDiagramNode(i))}var r=this.editor.graph;try{this.editor.graph=t,this.editor.setGraphXml(e)}catch(e){}finally{this.editor.graph=r}return e},EditorUi.prototype.getPngFileProperties=function(e){var t=1,i=0;if(null!=e){if(e.hasAttribute("scale")){var n=parseFloat(e.getAttribute("scale"));!isNaN(n)&&n>0&&(t=n)}e.hasAttribute("border")&&(n=parseInt(e.getAttribute("border")),!isNaN(n)&&n>0&&(i=n))}return{scale:t,border:i}},EditorUi.prototype.getEmbeddedPng=function(e,t,i,n,l){try{var r=this.editor.graph,s=null!=r.themes&&"darkTheme"==r.defaultThemeName,o=null;if(null!=i&&i.length>0)r=this.createTemporaryGraph(s?r.getDefaultStylesheet():r.getStylesheet()),document.body.appendChild(r.container),this.decodeNodeIntoGraph(this.editor.extractGraphModel(mxUtils.parseXml(i).documentElement,!0),r),o=i;else if(s||null!=this.pages&&this.currentPage!=this.pages[0]){var a=(r=this.createTemporaryGraph(s?r.getDefaultStylesheet():r.getStylesheet())).getGlobalVariable;r.setBackgroundImage=this.editor.graph.setBackgroundImage;var d=this.pages[0];this.currentPage==d?r.setBackgroundImage(this.editor.graph.backgroundImage):null!=d.viewState&&null!=d.viewState&&r.setBackgroundImage(d.viewState.backgroundImage),r.getGlobalVariable=function(e){return"page"==e?d.getName():"pagenumber"==e?1:a.apply(this,arguments)},document.body.appendChild(r.container),r.model.setRoot(d.root)}this.editor.exportToCanvas(mxUtils.bind(this,(function(i){try{null==o&&(o=this.getFileData(!0,null,null,null,null,null,null,null,null,!1));var n=i.toDataURL("image/png");n=Editor.writeGraphModelToPng(n,"tEXt","mxfile",encodeURIComponent(o)),e(n.substring(n.lastIndexOf(",")+1)),r!=this.editor.graph&&r.container.parentNode.removeChild(r.container)}catch(e){null!=t&&t(e)}})),null,null,null,mxUtils.bind(this,(function(e){null!=t&&t(e)})),null,null,n,null,r.shadowVisible,null,r,l,null,null,null,"diagram",null)}catch(e){null!=t&&t(e)}},EditorUi.prototype.getEmbeddedSvg=function(e,t,i,n,l,r,s,o,a,d,u,h,m){o=null==o||o,u=null!=u?u:0;var g=null!=a?a:t.background;g==mxConstants.NONE&&(g=null);var c=t.getSvg(g,d,u,null,null,r,null,null,null,t.shadowVisible||h,null,m,"diagram");(t.shadowVisible||h)&&t.addSvgShadow(c,null,null,0==u),null!=e&&c.setAttribute("content",e),null!=i&&c.setAttribute("resource",i);var p=mxUtils.bind(this,(function(e){var t=(n?"":Graph.xmlDeclaration+"\n"+Graph.svgFileComment+"\n"+Graph.svgDoctype+"\n")+mxUtils.getXml(e);return null!=l&&l(t),t}));if(t.mathEnabled&&this.editor.addMathCss(c),null==l)return p(c);this.embedFonts(c,mxUtils.bind(this,(function(e){o?this.editor.convertImages(e,mxUtils.bind(this,(function(e){p(e)}))):p(e)})))},EditorUi.prototype.embedFonts=function(e,t){this.editor.loadFonts(mxUtils.bind(this,(function(){try{null!=this.editor.resolvedFontCss&&this.editor.addFontCss(e,this.editor.resolvedFontCss),this.editor.embedExtFonts(mxUtils.bind(this,(function(i){try{null!=i&&this.editor.addFontCss(e,i),t(e)}catch(i){t(e)}})))}catch(i){t(e)}})))},EditorUi.prototype.exportImage=function(e,t,i,n,l,r,s,o,a,d,u,h,m){if(a=null!=a?a:"png",this.spinner.spin(document.body,mxResources.get("exporting"))){var g=this.editor.graph.isSelectionEmpty();i=null!=i?i:g,null==this.thumbImageCache&&(this.thumbImageCache=new Object);try{this.editor.exportToCanvas(mxUtils.bind(this,(function(e){this.spinner.stop();try{this.saveCanvas(e,l?this.getFileData(!0,null,null,null,i,o):null,a,null==this.pages||0==this.pages.length,u)}catch(e){this.handleError(e)}})),null,this.thumbImageCache,null,mxUtils.bind(this,(function(e){this.spinner.stop(),this.handleError(e)})),null,i,e||1,t,n,null,null,r,s,d,h,m)}catch(e){this.spinner.stop(),this.handleError(e)}}},EditorUi.prototype.isCorsEnabledForUrl=function(e){return this.editor.isCorsEnabledForUrl(e)},EditorUi.prototype.importXml=function(e,t,i,n,l,r,s){t=null!=t?t:0,i=null!=i?i:0;var o=[];try{var a=this.editor.graph;if(null!=e&&e.length>0){a.model.beginUpdate();try{var d=mxUtils.parseXml(e),u={},h=this.editor.extractGraphModel(d.documentElement,null!=this.pages);if(null!=h&&"mxfile"==h.nodeName&&null!=this.pages){var m=h.getElementsByTagName("diagram");if(1!=m.length||r){if(m.length>0){var g=[],c=0;null!=this.pages&&1==this.pages.length&&this.isDiagramEmpty()&&(u[m[0].getAttribute("id")]=this.pages[0].getId(),h=Editor.parseDiagramNode(m[0]),n=!1,c=1);for(var p=c;p<m.length;p++){var f=m[p].getAttribute("id");m[p].removeAttribute("id");var x=this.updatePageRoot(new DiagramPage(m[p]));u[f]=m[p].getAttribute("id");var v=this.pages.length;null==x.getName()&&x.setName(mxResources.get("pageWithNumber",[v+1])),a.model.execute(new ChangePage(this,x,x,v,!0)),g.push(x)}this.updatePageLinks(u,g)}}else if(h=Editor.parseDiagramNode(m[0]),null!=this.currentPage&&(u[m[0].getAttribute("id")]=this.currentPage.getId(),null!=this.pages&&1==this.pages.length&&this.isDiagramEmpty()&&this.currentPage.getName()==mxResources.get("pageWithNumber",[1]))){var b=m[0].getAttribute("name");null!=b&&""!=b&&this.editor.graph.model.execute(new RenamePage(this,this.currentPage,b))}}if(null!=h&&"mxGraphModel"===h.nodeName&&null!=(o=a.importGraphModel(h,t,i,n)))for(p=0;p<o.length;p++)this.updatePageLinksForCell(u,o[p]);s&&this.insertHandler(o,null,null,a.defaultVertexStyle,a.defaultEdgeStyle,!1,!0)}finally{a.model.endUpdate()}}}catch(e){if(l)throw e;this.handleError(e)}return o},EditorUi.prototype.updatePageLinks=function(e,t){for(var i=0;i<t.length;i++)this.updatePageLinksForCell(e,t[i].root)},EditorUi.prototype.updatePageLinksForCell=function(e,t){var i=document.createElement("div"),n=this.editor.graph,l=n.getLinkForCell(t);if(null!=l&&n.setLinkForCell(t,this.updatePageLink(e,l)),n.isHtmlLabel(t)){i.innerHTML=n.sanitizeHtml(n.getLabel(t));for(var r=i.getElementsByTagName("a"),s=!1,o=0;o<r.length;o++)null!=(l=r[o].getAttribute("href"))&&(r[o].setAttribute("href",this.updatePageLink(e,l)),s=!0);s&&n.labelChanged(t,i.innerHTML)}for(o=0;o<n.model.getChildCount(t);o++)this.updatePageLinksForCell(e,n.model.getChildAt(t,o))},EditorUi.prototype.updatePageLink=function(e,t){if(Graph.isPageLink(t)){var i=e[t.substring(t.indexOf(",")+1)];t=null!=i?"data:page/id,"+i:null}else if("data:action/json,"==t.substring(0,17))try{var n=JSON.parse(t.substring(17));if(null!=n.actions){for(var l=0;l<n.actions.length;l++){var r=n.actions[l];if(null!=r.open&&Graph.isPageLink(r.open)){var s=r.open.substring(r.open.indexOf(",")+1);null!=(i=e[s])?r.open="data:page/id,"+i:null==this.getPageById(s)&&delete r.open}}t="data:action/json,"+JSON.stringify(n)}}catch(e){}return t},EditorUi.prototype.isRemoteVisioFormat=function(e){return/(\.v(sd|dx))($|\?)/i.test(e)||/(\.vs(s|x))($|\?)/i.test(e)},EditorUi.prototype.importVisio=function(e,t,i,n,l){n=null!=n?n:e.name,i=null!=i?i:mxUtils.bind(this,(function(e){this.handleError(e)}));var r=mxUtils.bind(this,(function(){if(this.loadingExtensions=!1,this.doImportVisio){var r=this.isRemoteVisioFormat(n);try{var s="UNKNOWN-VISIO",o=n.lastIndexOf(".");if(o>=0&&o<n.length)s=n.substring(o+1).toUpperCase();else{var a=n.lastIndexOf("/");a>=0&&a<n.length&&(n=n.substring(a+1))}EditorUi.logEvent({category:s+"-MS-IMPORT-FILE",action:"filename_"+n,label:r?"remote":"local"})}catch(e){}if(r)if(null==VSD_CONVERT_URL||this.isOffline())i({message:"conf"==this.getServiceName()?mxResources.get("vsdNoConfig"):mxResources.get("serviceUnavailableOrBlocked")});else{var d=new FormData;d.append("file1",e,n);var u=new XMLHttpRequest;u.open("POST",VSD_CONVERT_URL+(/(\.vss|\.vsx)$/.test(n)?"?stencil=1":"")),u.responseType="blob",this.addRemoteServiceSecurityCheck(u),null!=l&&u.setRequestHeader("x-convert-custom",l),u.onreadystatechange=mxUtils.bind(this,(function(){if(4==u.readyState)if(u.status>=200&&u.status<=299)try{var e=u.response;"text/xml"==e.type?((l=new FileReader).onload=mxUtils.bind(this,(function(e){try{t(e.target.result)}catch(e){i({message:mxResources.get("errorLoadingFile")})}})),l.readAsText(e)):this.doImportVisio(e,t,i,n)}catch(e){i(e)}else try{var l;""==u.responseType||"text"==u.responseType?i({message:u.responseText}):((l=new FileReader).onload=function(){i({message:JSON.parse(l.result).Message})},l.readAsText(u.response))}catch(e){i({})}})),u.send(d)}else try{this.doImportVisio(e,t,i,n)}catch(e){i(e)}}else this.spinner.stop(),this.handleError({message:mxResources.get("serviceUnavailableOrBlocked")})}));this.doImportVisio||this.loadingExtensions||this.isOffline(!0)?r():(this.loadingExtensions=!0,mxscript("js/extensions.min.js",r))},EditorUi.prototype.importGraphML=function(e,t,i){i=null!=i?i:mxUtils.bind(this,(function(e){this.handleError(e)}));var n=mxUtils.bind(this,(function(){if(this.loadingExtensions=!1,this.doImportGraphML)try{this.doImportGraphML(e,t,i)}catch(e){i(e)}else this.spinner.stop(),this.handleError({message:mxResources.get("serviceUnavailableOrBlocked")})}));this.doImportGraphML||this.loadingExtensions||this.isOffline(!0)?n():(this.loadingExtensions=!0,mxscript("js/extensions.min.js",n))},EditorUi.prototype.exportVisio=function(e){var t=mxUtils.bind(this,(function(){if(this.loadingExtensions=!1,"undefined"!=typeof VsdxExport)try{new VsdxExport(this).exportCurrentDiagrams(e)||this.handleError({message:mxResources.get("unknownError")})}catch(e){this.handleError(e)}else this.spinner.stop(),this.handleError({message:mxResources.get("serviceUnavailableOrBlocked")})}));"undefined"!=typeof VsdxExport||this.loadingExtensions||this.isOffline(!0)?t():(this.loadingExtensions=!0,mxscript("js/extensions.min.js",t))},EditorUi.prototype.convertLucidChart=function(e,t,i){var n=mxUtils.bind(this,(function(){if(this.loadingExtensions=!1,void 0!==window.LucidImporter)try{var n=JSON.parse(e);t(LucidImporter.importState(n));try{if(EditorUi.logEvent({category:"LUCIDCHART-IMPORT-FILE",action:"size_"+e.length}),null!=window.console&&"1"==urlParams.test){var l=[(new Date).toISOString(),"convertLucidChart",n];if(null!=n.state&&l.push(JSON.parse(n.state)),null!=n.svgThumbs)for(var r=0;r<n.svgThumbs.length;r++)l.push(Editor.createSvgDataUri(n.svgThumbs[r]));null!=n.thumb&&l.push(n.thumb),console.log.apply(console,l)}}catch(e){}}catch(e){null!=window.console&&console.error(e),i(e)}else i({message:mxResources.get("serviceUnavailableOrBlocked")})}));void 0!==window.LucidImporter||this.loadingExtensions||this.isOffline(!0)?window.setTimeout(n,0):(this.loadingExtensions=!0,"1"==urlParams.dev?mxscript("js/diagramly/Extensions.js",(function(){mxscript("js/orgchart/bridge.min.js",(function(){mxscript("js/orgchart/bridge.collections.min.js",(function(){mxscript("js/orgchart/OrgChart.Layout.min.js",(function(){mxscript("js/orgchart/mxOrgChartLayout.js",n)}))}))}))})):mxscript("js/extensions.min.js",n))},EditorUi.prototype.generateMermaidImage=function(e,t,i,n){var l=this,r=function(){try{this.loadingMermaid=!1,(t=null!=t?t:mxUtils.clone(EditorUi.defaultMermaidConfig)).securityLevel="strict",t.startOnLoad=!1,Editor.isDarkMode()&&(t.theme="dark"),mermaid.mermaidAPI.initialize(t),mermaid.mermaidAPI.render("geMermaidOutput-"+(new Date).getTime(),e,(function(e){try{(mxClient.IS_IE||mxClient.IS_IE11)&&(e=e.replace(/ xmlns:\S*="http:\/\/www.w3.org\/XML\/1998\/namespace"/g,"").replace(/ (NS xml|\S*):space="preserve"/g,' xml:space="preserve"'));var t=mxUtils.parseXml(e).getElementsByTagName("svg");if(t.length>0){var r=parseFloat(t[0].getAttribute("width")),s=parseFloat(t[0].getAttribute("height"));if(isNaN(r)||isNaN(s))try{var o=t[0].getAttribute("viewBox").split(/\s+/);r=parseFloat(o[2]),s=parseFloat(o[3])}catch(e){r=r||100,s=s||100}i(l.convertDataUri(Editor.createSvgDataUri(e)),r,s)}else n({message:mxResources.get("invalidInput")})}catch(e){n(e)}}))}catch(e){n(e)}};"undefined"!=typeof mermaid||this.loadingMermaid||this.isOffline(!0)?r():(this.loadingMermaid=!0,"1"==urlParams.dev?mxscript("js/mermaid/mermaid.min.js",r):mxscript("js/extensions.min.js",r))},EditorUi.prototype.generatePlantUmlImage=function(e,t,n,l){function s(e,t,i){return c1=e>>2,c2=(3&e)<<4|t>>4,c3=(15&t)<<2|i>>6,c4=63&i,r="",r+=o(63&c1),r+=o(63&c2),r+=o(63&c3),r+=o(63&c4),r}function o(e){return e<10?String.fromCharCode(48+e):(e-=10)<26?String.fromCharCode(65+e):(e-=26)<26?String.fromCharCode(97+e):0==(e-=26)?"-":1==e?"_":"?"}var a,d="txt"==t?PLANT_URL+"/txt/":"png"==t?PLANT_URL+"/png/":PLANT_URL+"/svg/",u=new XMLHttpRequest;u.open("GET",d+(a=e,function(e){for(r="",i=0;i<e.length;i+=3)i+2==e.length?r+=s(e.charCodeAt(i),e.charCodeAt(i+1),0):i+1==e.length?r+=s(e.charCodeAt(i),0,0):r+=s(e.charCodeAt(i),e.charCodeAt(i+1),e.charCodeAt(i+2));return r}(Graph.arrayBufferToString(pako.deflateRaw(a)))),!0),"txt"!=t&&(u.responseType="blob"),u.onload=function(e){if(this.status>=200&&this.status<300)if("txt"==t)n(this.response);else{var i=new FileReader;i.readAsDataURL(this.response),i.onloadend=function(e){var t=new Image;t.onload=function(){try{var e=t.width,r=t.height;if(0==e&&0==r){var s=i.result,o=s.indexOf(","),a=decodeURIComponent(escape(atob(s.substring(o+1)))),d=mxUtils.parseXml(a).getElementsByTagName("svg");d.length>0&&(e=parseFloat(d[0].getAttribute("width")),r=parseFloat(d[0].getAttribute("height")))}n(i.result,e,r)}catch(e){l(e)}},t.src=i.result},i.onerror=function(e){l(e)}}else l(e)},u.onerror=function(e){l(e)},u.send()},EditorUi.prototype.insertAsPreText=function(e,t,i){var n=this.editor.graph,l=null;n.getModel().beginUpdate();try{l=n.insertVertex(null,null,"<pre>"+e+"</pre>",t,i,1,1,"text;html=1;align=left;verticalAlign=top;"),n.updateCellSize(l,!0)}finally{n.getModel().endUpdate()}return l},EditorUi.prototype.insertTextAt=function(e,t,i,n,l,r,s,o){if(r=null==r||r,s=null==s||s,null!=e){if(Graph.fileSupport&&!this.isOffline()&&(new XMLHttpRequest).upload&&this.isRemoteFileFormat(e))return this.parseFile(new Blob([e.replace(/\s+/g," ")],{type:"application/octet-stream"}),mxUtils.bind(this,(function(e){4==e.readyState&&e.status>=200&&e.status<=299&&this.editor.graph.setSelectionCells(this.insertTextAt(e.responseText,t,i,!0))}))),[];if("data:"==e.substring(0,5)||!this.isOffline()&&(l||/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(e))){var a=this.editor.graph;if("data:application/pdf;base64,"==e.substring(0,28)&&null!=(d=Editor.extractGraphModelFromPdf(e))&&d.length>0)return this.importXml(d,t,i,r,!0,o);if(Editor.isPngDataUrl(e)&&null!=(d=Editor.extractGraphModelFromPng(e))&&d.length>0)return this.importXml(d,t,i,r,!0,o);if("data:image/svg+xml;"==e.substring(0,19))try{var d=null;"data:image/svg+xml;base64,"==e.substring(0,26)?(d=e.substring(e.indexOf(",")+1),d=window.atob&&!mxClient.IS_SF?atob(d):Base64.decode(d,!0)):d=decodeURIComponent(e.substring(e.indexOf(",")+1));var u=this.importXml(d,t,i,r,!0,o);if(u.length>0)return u}catch(e){}return this.loadImage(e,mxUtils.bind(this,(function(n){if("data:"==e.substring(0,5))this.resizeImage(n,e,mxUtils.bind(this,(function(e,n,l){a.setSelectionCell(a.insertVertex(null,null,"",a.snap(t),a.snap(i),n,l,"shape=image;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;aspect=fixed;imageAspect=0;image="+this.convertDataUri(e)+";"))})),s,this.maxImageSize);else{var l=Math.min(1,Math.min(this.maxImageSize/n.width,this.maxImageSize/n.height)),r=Math.round(n.width*l),o=Math.round(n.height*l);a.setSelectionCell(a.insertVertex(null,null,"",a.snap(t),a.snap(i),r,o,"shape=image;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;aspect=fixed;imageAspect=0;image="+e+";"))}})),mxUtils.bind(this,(function(){var l=null;a.getModel().beginUpdate();try{l=a.insertVertex(a.getDefaultParent(),null,e,a.snap(t),a.snap(i),1,1,"text;"+(n?"html=1;":"")),a.updateCellSize(l),a.fireEvent(new mxEventObject("textInserted","cells",[l]))}finally{a.getModel().endUpdate()}a.setSelectionCell(l)}))),[]}if(e=Graph.zapGremlins(mxUtils.trim(e)),this.isCompatibleString(e))return this.importXml(e,t,i,r,null,o);if(e.length>0){if(!this.isLucidChartData(e)){var h=null;(a=this.editor.graph).getModel().beginUpdate();try{if(h=a.insertVertex(a.getDefaultParent(),null,"",a.snap(t),a.snap(i),1,1,"text;whiteSpace=wrap;"+(n?"html=1;":"")),a.fireEvent(new mxEventObject("textInserted","cells",[h])),"<"==e.charAt(0)&&e.indexOf(">")==e.length-1&&(e=mxUtils.htmlEntities(e)),e.length>this.maxTextBytes&&(e=e.substring(0,this.maxTextBytes)+"..."),h.value=e,a.updateCellSize(h),this.maxTextWidth>0&&h.geometry.width>this.maxTextWidth){var m=a.getPreferredSizeForCell(h,this.maxTextWidth);h.geometry.width=m.width,h.geometry.height=m.height}Graph.isLink(h.value)&&a.setLinkForCell(h,h.value),h.geometry.width+=a.gridSize,h.geometry.height+=a.gridSize}finally{a.getModel().endUpdate()}return[h]}this.convertLucidChart(e,mxUtils.bind(this,(function(e){this.editor.graph.setSelectionCells(this.importXml(e,t,i,r,null,o))})),mxUtils.bind(this,(function(e){this.handleError(e)})))}}return[]},EditorUi.prototype.formatFileSize=function(e){var t=-1;do{e/=1024,t++}while(e>1024);return Math.max(e,.1).toFixed(1)+[" kB"," MB"," GB"," TB","PB","EB","ZB","YB"][t]},EditorUi.prototype.convertDataUri=function(e){if("data:"==e.substring(0,5)){var t=e.indexOf(";");t>0&&(e=e.substring(0,t)+e.substring(e.indexOf(",",t+1)))}return e},EditorUi.prototype.isRemoteFileFormat=function(e,t){return/(\"contentType\":\s*\"application\/gliffy\+json\")/.test(e)},EditorUi.prototype.isLucidChartData=function(e){return null!=e&&('{"state":"{\\"Properties\\":'==e.substring(0,26)||'{"Properties":'==e.substring(0,14))},EditorUi.prototype.importLocalFile=function(e,t){if(e&&Graph.fileSupport){if(null==this.importFileInputElt){var i=document.createElement("input");i.setAttribute("type","file"),mxEvent.addListener(i,"change",mxUtils.bind(this,(function(){null!=i.files&&(this.importFiles(i.files,null,null,this.maxImageSize),i.type="",i.type="file",i.value="")}))),i.style.display="none",document.body.appendChild(i),this.importFileInputElt=i}this.importFileInputElt.click()}else{if(window.openNew=!1,window.openKey="import",window.listBrowserFiles=mxUtils.bind(this,(function(e,t){StorageFile.listFiles(this,"F",e,t)})),window.openBrowserFile=mxUtils.bind(this,(function(e,t,i){StorageFile.getFileContent(this,e,t,i)})),window.deleteBrowserFile=mxUtils.bind(this,(function(e,t,i){StorageFile.deleteFile(this,e,t,i)})),!t){var n=Editor.useLocalStorage;Editor.useLocalStorage=!e}if(window.openFile=new OpenFile(mxUtils.bind(this,(function(e){this.hideDialog(e)}))),window.openFile.setConsumer(mxUtils.bind(this,(function(e,t){if(null!=t&&Graph.fileSupport&&/(\.v(dx|sdx?))($|\?)/i.test(t)){var i=new Blob([e],{type:"application/octet-stream"});this.importVisio(i,mxUtils.bind(this,(function(e){this.importXml(e,0,0,!0)})),null,t)}else this.editor.graph.setSelectionCells(this.importXml(e,0,0,!0))}))),this.showDialog(new OpenDialog(this).container,Editor.useLocalStorage?640:360,Editor.useLocalStorage?480:220,!0,!0,(function(){window.openFile=null})),!t){var l=this.dialog,r=l.close;this.dialog.close=mxUtils.bind(this,(function(e){Editor.useLocalStorage=n,r.apply(l,arguments),e&&null==this.getCurrentFile()&&"1"!=urlParams.embed&&this.showSplash()}))}}},EditorUi.prototype.importZipFile=function(e,t,i){var n=this,l=mxUtils.bind(this,(function(){this.loadingExtensions=!1,"undefined"!=typeof JSZip?JSZip.loadAsync(e).then((function(l){if(0==Object.keys(l.files).length)i();else{var r={version:0},s=!1;l.forEach((function(e,n){var l=n.name.toLowerCase();if("diagram/diagram.xml"==l)s=!0,n.async("string").then((function(e){0==e.indexOf("<mxfile ")?t(e):i()}));else if(0==l.indexOf("versions/")){var o=parseInt(l.substr(9));o>r.version&&(r={version:o,zipEntry:n})}})),r.version>0?r.zipEntry.async("string").then((function(l){!n.isOffline()&&(new XMLHttpRequest).upload&&n.isRemoteFileFormat(l,e.name)?n.parseFile(new Blob([l],{type:"application/octet-stream"}),mxUtils.bind(this,(function(e){4==e.readyState&&(e.status>=200&&e.status<=299?t(e.responseText):i())})),e.name):i()})):s||i()}}),(function(e){i(e)})):i()}));"undefined"!=typeof JSZip||this.loadingExtensions||this.isOffline(!0)?l():(this.loadingExtensions=!0,mxscript("js/extensions.min.js",l))},EditorUi.prototype.importFile=function(e,t,i,n,l,r,s,o,a,d,u,h){d=null==d||d;var m=!1,g=null,c=mxUtils.bind(this,(function(e){var t=null;null!=e&&"<mxlibrary"==e.substring(0,10)?this.loadLibrary(new LocalLibrary(this,e,s)):t=this.importXml(e,i,n,d,null,null!=h?mxEvent.isControlDown(h):null),null!=o&&o(t)}));if("image"==t.substring(0,5)){var p=!1;if("image/png"==t.substring(0,9)){var f=u?null:this.extractGraphModelFromPng(e);null!=f&&f.length>0&&(g=this.importXml(f,i,n,d,null,null!=h?mxEvent.isControlDown(h):null),p=!0)}if(!p){var x=this.editor.graph,v=e.indexOf(";");v>0&&(e=e.substring(0,v)+e.substring(e.indexOf(",",v+1))),d&&x.isGridEnabled()&&(i=x.snap(i),n=x.snap(n)),g=[x.insertVertex(null,null,"",i,n,l,r,"shape=image;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;aspect=fixed;imageAspect=0;image="+e+";")]}}else/(\.*<graphml )/.test(e)?(m=!0,this.importGraphML(e,c)):null!=a&&null!=s&&(/(\.v(dx|sdx?))($|\?)/i.test(s)||/(\.vs(x|sx?))($|\?)/i.test(s))?(m=!0,this.importVisio(a,c)):!this.isOffline()&&(new XMLHttpRequest).upload&&this.isRemoteFileFormat(e,s)?(m=!0,this.parseFile(null!=a?a:new Blob([e],{type:"application/octet-stream"}),mxUtils.bind(this,(function(e){4==e.readyState&&(e.status>=200&&e.status<=299?c(e.responseText):null!=o&&o(null))})),s)):0==e.indexOf("PK")&&null!=a?(m=!0,this.importZipFile(a,c,mxUtils.bind(this,(function(){g=this.insertTextAt(this.validateFileData(e),i,n,!0,null,d),o(g)})))):/(\.v(sd|dx))($|\?)/i.test(s)||/(\.vs(s|x))($|\?)/i.test(s)||(g=this.insertTextAt(this.validateFileData(e),i,n,!0,null,d,null,null!=h?mxEvent.isControlDown(h):null));return m||null==o||o(g),g},EditorUi.prototype.importFiles=function(e,t,i,n,l,r,s,o,a,d,u,h,m){n=null!=n?n:this.maxImageSize,d=null!=d?d:this.maxImageBytes;var g=null!=t&&null!=i,c=!0;t=null!=t?t:0,i=null!=i?i:0;var p=!1;if(!mxClient.IS_CHROMEAPP&&null!=e)for(var f=u||this.resampleThreshold,x=0;x<e.length;x++)if("image/"==e[x].type.substring(0,6)&&e[x].size>f){p=!0;break}var v=mxUtils.bind(this,(function(){var a=this.editor.graph,p=a.gridSize;if(l=null!=l?l:mxUtils.bind(this,(function(e,t,i,n,l,r,s,o,a){try{return null!=e&&"<mxlibrary"==e.substring(0,10)?(this.spinner.stop(),this.loadLibrary(new LocalLibrary(this,e,s)),null):this.importFile(e,t,i,n,l,r,s,o,a,g,h,m)}catch(e){return this.handleError(e),null}})),r=null!=r?r:mxUtils.bind(this,(function(e){a.setSelectionCells(e)})),this.spinner.spin(document.body,mxResources.get("loading")))for(var f=e.length,x=f,v=[],b=mxUtils.bind(this,(function(e,t){if(v[e]=t,0==--x){if(this.spinner.stop(),null!=o)o(v);else{var i=[];a.getModel().beginUpdate();try{for(var n=0;n<v.length;n++){var l=v[n]();null!=l&&(i=i.concat(l))}}finally{a.getModel().endUpdate()}}r(i)}})),y=0;y<f;y++)mxUtils.bind(this,(function(r){var o=e[r];if(null!=o){var m=new FileReader;m.onload=mxUtils.bind(this,(function(e){if(null==s||s(o))if("image/"==o.type.substring(0,6))if("image/svg"==o.type.substring(0,9)){var m=(U=Graph.clipSvgDataUri(e.target.result)).indexOf(","),g=decodeURIComponent(escape(atob(U.substring(m+1)))),f=mxUtils.parseXml(g),x=f.getElementsByTagName("svg");if(x.length>0){var v=x[0],y=h?null:v.getAttribute("content");null!=y&&"<"!=y.charAt(0)&&"%"!=y.charAt(0)&&(y=unescape(window.atob?atob(y):Base64.decode(y,!0))),null!=y&&"%"==y.charAt(0)&&(y=decodeURIComponent(y)),null==y||"<mxfile "!==y.substring(0,8)&&"<mxGraphModel "!==y.substring(0,14)?b(r,mxUtils.bind(this,(function(){try{if(U.substring(0,m+1),null!=f){var e=f.getElementsByTagName("svg");if(e.length>0){var s=e[0],d=s.getAttribute("width"),u=s.getAttribute("height");d=null!=d&&"%"!=d.charAt(d.length-1)?parseFloat(d):NaN,u=null!=u&&"%"!=u.charAt(u.length-1)?parseFloat(u):NaN;var h=s.getAttribute("viewBox");if(null==h||0==h.length)s.setAttribute("viewBox","0 0 "+d+" "+u);else if(isNaN(d)||isNaN(u)){var g=h.split(" ");g.length>3&&(d=parseFloat(g[2]),u=parseFloat(g[3]))}U=Editor.createSvgDataUri(mxUtils.getXml(s));var c=Math.min(1,Math.min(n/Math.max(1,d)),n/Math.max(1,u)),x=l(U,o.type,t+r*p,i+r*p,Math.max(1,Math.round(d*c)),Math.max(1,Math.round(u*c)),o.name);if(isNaN(d)||isNaN(u)){var v=new Image;v.onload=mxUtils.bind(this,(function(){d=Math.max(1,v.width),u=Math.max(1,v.height),x[0].geometry.width=d,x[0].geometry.height=u,s.setAttribute("viewBox","0 0 "+d+" "+u);var e=(U=Editor.createSvgDataUri(mxUtils.getXml(s))).indexOf(";");e>0&&(U=U.substring(0,e)+U.substring(U.indexOf(",",e+1))),a.setCellStyles("image",U,[x[0]])})),v.src=Editor.createSvgDataUri(mxUtils.getXml(s))}return x}}}catch(e){}return null}))):b(r,mxUtils.bind(this,(function(){return l(y,"text/xml",t+r*p,i+r*p,0,0,o.name)})))}else b(r,mxUtils.bind(this,(function(){return null})))}else{var E=!1;if("image/png"==o.type){var w=h?null:this.extractGraphModelFromPng(e.target.result);if(null!=w&&w.length>0){var C=new Image;C.src=e.target.result,b(r,mxUtils.bind(this,(function(){return l(w,"text/xml",t+r*p,i+r*p,C.width,C.height,o.name)}))),E=!0}}E||(mxClient.IS_CHROMEAPP?(this.spinner.stop(),this.showError(mxResources.get("error"),mxResources.get("dragAndDropNotSupported"),mxResources.get("cancel"),mxUtils.bind(this,(function(){})),null,mxResources.get("ok"),mxUtils.bind(this,(function(){this.actions.get("import").funct()})))):this.loadImage(e.target.result,mxUtils.bind(this,(function(s){this.resizeImage(s,e.target.result,mxUtils.bind(this,(function(e,s,a){b(r,mxUtils.bind(this,(function(){if(null!=e&&e.length<d){var h=c&&this.isResampleImageSize(o.size,u)?Math.min(1,Math.min(n/s,n/a)):1;return l(e,o.type,t+r*p,i+r*p,Math.round(s*h),Math.round(a*h),o.name)}return this.handleError({message:mxResources.get("imageTooBig")}),null})))})),c,n,u,o.size)})),mxUtils.bind(this,(function(){this.handleError({message:mxResources.get("invalidOrMissingFile")})}))))}else{var U=e.target.result;l(U,o.type,t+r*p,i+r*p,240,160,o.name,(function(e){b(r,(function(){return e}))}),o)}})),/(\.v(dx|sdx?))($|\?)/i.test(o.name)||/(\.vs(x|sx?))($|\?)/i.test(o.name)?l(null,o.type,t+r*p,i+r*p,240,160,o.name,(function(e){b(r,(function(){return e}))}),o):"image"==o.type.substring(0,5)||"application/pdf"==o.type?m.readAsDataURL(o):m.readAsText(o)}}))(y)}));if(p){var b=[];for(x=0;x<e.length;x++)b.push(e[x]);e=b,this.confirmImageResize((function(e){c=e,v()}),a)}else v()},EditorUi.prototype.confirmImageResize=function(e,t){t=null!=t&&t;var i=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){},n=isLocalStorage||mxClient.IS_CHROMEAPP?mxSettings.getResizeImages():null,l=function(n,l){(n||t)&&(mxSettings.setResizeImages(n?l:null),mxSettings.save()),i(),e(l)};null==n||t?this.showDialog(new ConfirmDialog(this,mxResources.get("resizeLargeImages"),(function(e){l(e,!0)}),(function(e){l(e,!1)}),mxResources.get("resize"),mxResources.get("actualSize"),'<img style="margin-top:8px;" src="'+Editor.loResImage+'"/>','<img style="margin-top:8px;" src="'+Editor.hiResImage+'"/>',isLocalStorage||mxClient.IS_CHROMEAPP).container,340,isLocalStorage||mxClient.IS_CHROMEAPP?220:200,!0,!0):l(!1,n)},EditorUi.prototype.parseFile=function(e,t,i){var n=new FileReader;n.onload=mxUtils.bind(this,(function(){this.parseFileData(n.result,t,i)})),n.readAsText(e)},EditorUi.prototype.parseFileData=function(e,t,i){i=null!=i?i:file.name;var n=new XMLHttpRequest;n.open("POST",OPEN_URL),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.onreadystatechange=function(){t(n)},n.send("format=xml&filename="+encodeURIComponent(i)+"&data="+encodeURIComponent(e));try{EditorUi.logEvent({category:"GLIFFY-IMPORT-FILE",action:"size_"+file.size})}catch(e){}},EditorUi.prototype.isResampleImageSize=function(e,t){return e>(null!=t?t:this.resampleThreshold)},EditorUi.prototype.resizeImage=function(e,t,i,n,l,r,s){l=null!=l?l:this.maxImageSize;var o=Math.max(1,e.width),a=Math.max(1,e.height);if(n&&this.isResampleImageSize(null!=s?s:t.length,r))try{var d=Math.max(o/l,a/l);if(d>1){var u=Math.round(o/d),h=Math.round(a/d),m=document.createElement("canvas");m.width=u,m.height=h,m.getContext("2d").drawImage(e,0,0,u,h);var g=m.toDataURL();if(g.length<t.length){var c=document.createElement("canvas");c.width=u,c.height=h,g!==c.toDataURL()&&(t=g,o=u,a=h)}}}catch(e){}i(t,o,a)},EditorUi.prototype.extractGraphModelFromPng=function(e){return Editor.extractGraphModelFromPng(e)},EditorUi.prototype.loadImage=function(e,t,i){try{var n=new Image;n.onload=function(){n.width=n.width>0?n.width:120,n.height=n.height>0?n.height:120,t(n)},null!=i&&(n.onerror=i),n.src=e}catch(e){if(null==i)throw e;i(e)}};var s=EditorUi.prototype.init;EditorUi.prototype.init=function(){mxStencilRegistry.allowEval=mxStencilRegistry.allowEval&&!this.isOfflineApp(),this.isSettingsEnabled()&&("1"==urlParams.sketch&&this.doSetSketchMode(null!=mxSettings.settings.sketchMode&&null==urlParams.rough?mxSettings.settings.sketchMode:"0"!=urlParams.rough),this.formatWidth=mxSettings.getFormatWidth());var e=this,t=this.editor.graph;Editor.isDarkMode()&&(t.view.defaultGridColor=mxGraphView.prototype.defaultDarkGridColor),t.cellEditor.editPlantUmlData=function(i,n,l){var r=JSON.parse(l),s=new TextareaDialog(e,mxResources.get("plantUml")+":",r.data,(function(n){null!=n&&e.spinner.spin(document.body,mxResources.get("inserting"))&&e.generatePlantUmlImage(n,r.format,(function(l,s,o){e.spinner.stop(),t.getModel().beginUpdate();try{if("txt"==r.format)t.labelChanged(i,"<pre>"+l+"</pre>"),t.updateCellSize(i,!0);else{t.setCellStyles("image",e.convertDataUri(l),[i]);var a=t.model.getGeometry(i);null!=a&&((a=a.clone()).width=s,a.height=o,t.cellsResized([i],[a],!1))}t.setAttributeForCell(i,"plantUmlData",JSON.stringify({data:n,format:r.format}))}finally{t.getModel().endUpdate()}}),(function(t){e.handleError(t)}))}),null,null,400,220);e.showDialog(s.container,420,300,!0,!0),s.init()},t.cellEditor.editMermaidData=function(i,n,l){var r=JSON.parse(l),s=new TextareaDialog(e,mxResources.get("mermaid")+":",r.data,(function(n){null!=n&&e.spinner.spin(document.body,mxResources.get("inserting"))&&e.generateMermaidImage(n,r.config,(function(l,s,o){e.spinner.stop(),t.getModel().beginUpdate();try{t.setCellStyles("image",l,[i]);var a=t.model.getGeometry(i);null!=a&&((a=a.clone()).width=Math.max(a.width,s),a.height=Math.max(a.height,o),t.cellsResized([i],[a],!1)),t.setAttributeForCell(i,"mermaidData",JSON.stringify({data:n,config:r.config},null,2))}finally{t.getModel().endUpdate()}}),(function(t){e.handleError(t)}))}),null,null,400,220);e.showDialog(s.container,420,300,!0,!0),s.init()};var i=t.cellEditor.startEditing;t.cellEditor.startEditing=function(n,l){try{var r=this.graph.getAttributeForCell(n,"plantUmlData");if(null!=r)this.editPlantUmlData(n,l,r);else if(null!=(r=this.graph.getAttributeForCell(n,"mermaidData")))this.editMermaidData(n,l,r);else{var s=t.getCellStyle(n);"1"==mxUtils.getValue(s,"metaEdit","0")?e.showDataDialog(n):i.apply(this,arguments)}}catch(t){e.handleError(t)}},t.getLinkTitle=function(t){return e.getLinkTitle(t)},t.customLinkClicked=function(t){var i=!1;try{e.handleCustomLink(t),i=!0}catch(t){e.handleError(t)}return i};var n=t.parseBackgroundImage;t.parseBackgroundImage=function(e){var t=n.apply(this,arguments);return null!=t&&null!=t.src&&Graph.isPageLink(t.src)&&(t={originalSrc:t.src}),t};var l=t.setBackgroundImage;t.setBackgroundImage=function(t){null!=t&&null!=t.originalSrc&&(t=e.createImageForPageLink(t.originalSrc,e.currentPage,this)),l.apply(this,arguments)},this.editor.addListener("pageRenamed",mxUtils.bind(this,(function(){t.refreshBackgroundImage()}))),this.editor.addListener("pageMoved",mxUtils.bind(this,(function(){t.refreshBackgroundImage()}))),this.editor.addListener("pagesPatched",mxUtils.bind(this,(function(e,i){var n=null!=t.backgroundImage?t.backgroundImage.originalSrc:null;if(null!=n){var l=n.indexOf(",");if(l>0)for(var r=n.substring(l+1),s=i.getProperty("patches"),o=0;o<s.length;o++)if(null!=s[o][EditorUi.DIFF_UPDATE]&&null!=s[o][EditorUi.DIFF_UPDATE][r]){t.refreshBackgroundImage();break}}})));var r=t.getBackgroundImageObject;t.getBackgroundImageObject=function(t,i){var n=r.apply(this,arguments);if(null!=n&&null!=n.originalSrc)if(i){if(i&&null!=this.themes&&"darkTheme"==this.defaultThemeName){var l=this.stylesheet,s=this.shapeForegroundColor,o=this.shapeBackgroundColor;this.stylesheet=this.getDefaultStylesheet(),this.shapeBackgroundColor="#ffffff",this.shapeForegroundColor="#000000",n=e.createImageForPageLink(n.originalSrc),this.shapeBackgroundColor=o,this.shapeForegroundColor=s,this.stylesheet=l}}else n={src:n.originalSrc};return n};var o=this.clearDefaultStyle;this.clearDefaultStyle=function(){o.apply(this,arguments)},this.isOffline()||void 0===window.EditDataDialog||(EditDataDialog.placeholderHelpLink="https://www.diagrams.net/doc/faq/predefined-placeholders"),(/viewer\.diagrams\.net$/.test(window.location.hostname)||/embed\.diagrams\.net$/.test(window.location.hostname))&&(this.editor.editBlankUrl="https://app.diagrams.net/");var a=e.editor.getEditBlankUrl;this.editor.getEditBlankUrl=function(e){return e=null!=e?e:"","1"==urlParams.dev&&(e+=(e.length>0?"&":"?")+"dev=1"),a.apply(this,arguments)};var d=t.addClickHandler;if(t.addClickHandler=function(e,i,n){var l=i;i=function(e,i){if(null==i){var n=mxEvent.getSource(e);"a"==n.nodeName.toLowerCase()&&(i=n.getAttribute("href"))}null!=i&&t.isCustomLink(i)&&(mxEvent.isTouchEvent(e)||!mxEvent.isPopupTrigger(e))&&t.customLinkClicked(i)&&mxEvent.consume(e),null!=l&&l(e,i)},d.call(this,e,i,n)},s.apply(this,arguments),mxClient.IS_SVG&&this.editor.graph.addSvgShadow(t.view.canvas.ownerSVGElement,null,!0),null!=this.menus){var u=Menus.prototype.addPopupMenuEditItems;this.menus.addPopupMenuEditItems=function(t,i,n){e.editor.graph.isSelectionEmpty()?u.apply(this,arguments):e.menus.addMenuItems(t,["delete","-","cut","copy","copyAsImage","-","duplicate"],null,n)}}e.actions.get("print").funct=function(){e.showDialog(new PrintDialog(e).container,360,null!=e.pages&&e.pages.length>1?450:370,!0,!0)},this.defaultFilename=mxResources.get("untitledDiagram");var h=t.getExportVariables;t.getExportVariables=function(){var t=h.apply(this,arguments),i=e.getCurrentFile();return null!=i&&(t.filename=i.getTitle()),t.pagecount=null!=e.pages?e.pages.length:1,t.page=null!=e.currentPage?e.currentPage.getName():"",t.pagenumber=null!=e.pages&&null!=e.currentPage?mxUtils.indexOf(e.pages,e.currentPage)+1:1,t};var m=t.getGlobalVariable;t.getGlobalVariable=function(t){var i=e.getCurrentFile();return"filename"==t&&null!=i?i.getTitle():"page"==t&&null!=e.currentPage?e.currentPage.getName():"pagenumber"==t?null!=e.currentPage&&null!=e.pages?mxUtils.indexOf(e.pages,e.currentPage)+1:1:"pagecount"==t?null!=e.pages?e.pages.length:1:m.apply(this,arguments)};var g=t.labelLinkClicked;t.labelLinkClicked=function(e,i,n){var l=i.getAttribute("href");null==l||!t.isCustomLink(l)||!mxEvent.isTouchEvent(n)&&mxEvent.isPopupTrigger(n)?g.apply(this,arguments):((!t.isEnabled()||null!=e&&t.isCellLocked(e.cell))&&(t.customLinkClicked(l),t.getRubberband().reset()),mxEvent.consume(n))},this.editor.getOrCreateFilename=function(){var t=e.defaultFilename,i=e.getCurrentFile();return null!=i&&(t=null!=i.getTitle()?i.getTitle():t),t};var c=this.actions.get("print");if(c.setEnabled(!mxClient.IS_IOS||!navigator.standalone),c.visible=c.isEnabled(),this.editor.chromeless&&!this.editor.editable||(this.keyHandler.bindAction(70,!0,"findReplace"),this.keyHandler.bindAction(67,!0,"copyStyle",!0),this.keyHandler.bindAction(86,!0,"pasteStyle",!0),this.keyHandler.bindAction(77,!0,"editGeometry",!0),this.keyHandler.bindAction(88,!0,"insertText",!0),this.keyHandler.bindAction(75,!0,"insertRectangle"),this.keyHandler.bindAction(75,!0,"insertEllipse",!0),this.altShiftActions[83]="synchronize",this.installImagePasteHandler(),this.installNativeClipboardHandler()),this.spinner=this.createSpinner(null,null,24),Graph.fileSupport&&t.addListener(mxEvent.EDITING_STARTED,mxUtils.bind(this,(function(e){var i=t.cellEditor.text2,n=null;null!=i&&(mxEvent.addListener(i,"dragleave",(function(e){null!=n&&(n.parentNode.removeChild(n),n=null),e.stopPropagation(),e.preventDefault()})),mxEvent.addListener(i,"dragover",mxUtils.bind(this,(function(e){null==n&&(!mxClient.IS_IE||document.documentMode>10)&&(n=this.highlightElement(i)),e.stopPropagation(),e.preventDefault()}))),mxEvent.addListener(i,"drop",mxUtils.bind(this,(function(e){if(null!=n&&(n.parentNode.removeChild(n),n=null),e.dataTransfer.files.length>0)this.importFiles(e.dataTransfer.files,0,0,this.maxImageSize,(function(e,i,n,l,r,s){t.insertImage(e,r,s)}),(function(){}),(function(e){return"image/"==e.type.substring(0,6)}),(function(e){for(var t=0;t<e.length;t++)e[t]()}),mxEvent.isControlDown(e));else if(mxUtils.indexOf(e.dataTransfer.types,"text/uri-list")>=0){var i=e.dataTransfer.getData("text/uri-list");/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(i)?this.loadImage(decodeURIComponent(i),mxUtils.bind(this,(function(e){var n=Math.max(1,e.width),l=Math.max(1,e.height),r=this.maxImageSize,s=Math.min(1,Math.min(r/Math.max(1,n)),r/Math.max(1,l));t.insertImage(decodeURIComponent(i),n*s,l*s)}))):document.execCommand("insertHTML",!1,e.dataTransfer.getData("text/plain"))}else mxUtils.indexOf(e.dataTransfer.types,"text/html")>=0?document.execCommand("insertHTML",!1,e.dataTransfer.getData("text/html")):mxUtils.indexOf(e.dataTransfer.types,"text/plain")>=0&&document.execCommand("insertHTML",!1,e.dataTransfer.getData("text/plain"));e.stopPropagation(),e.preventDefault()}))))}))),this.isSettingsEnabled()){var p=this.editor.graph.view;p.setUnit(mxSettings.getUnit()),p.addListener("unitChanged",(function(e,t){mxSettings.setUnit(t.getProperty("unit")),mxSettings.save()}));var f=this.canvasSupported&&9!=document.documentMode&&("1"==urlParams.ruler||mxSettings.isRulerOn())&&(!this.editor.isChromelessView()||this.editor.editable);this.ruler=f?new mxDualRuler(this,p.unit):null,this.refresh()}if("1"==urlParams.styledev){var x=document.getElementById("geFooter");null!=x&&(this.styleInput=document.createElement("input"),this.styleInput.setAttribute("type","text"),this.styleInput.style.position="absolute",this.styleInput.style.top="14px",this.styleInput.style.left="2px",this.styleInput.style.width="98%",this.styleInput.style.visibility="hidden",this.styleInput.style.opacity="0.9",mxEvent.addListener(this.styleInput,"change",mxUtils.bind(this,(function(){this.editor.graph.getModel().setStyle(this.editor.graph.getSelectionCell(),this.styleInput.value)}))),x.appendChild(this.styleInput),this.editor.graph.getSelectionModel().addListener(mxEvent.CHANGE,mxUtils.bind(this,(function(e,t){if(this.editor.graph.getSelectionCount()>0){var i=this.editor.graph.getSelectionCell(),n=this.editor.graph.getModel().getStyle(i);this.styleInput.value=n||"",this.styleInput.style.visibility="visible"}else this.styleInput.style.visibility="hidden"}))));var v=this.isSelectionAllowed;this.isSelectionAllowed=function(e){return mxEvent.getSource(e)==this.styleInput||v.apply(this,arguments)}}var b=document.getElementById("geInfo");if(null!=b&&b.parentNode.removeChild(b),Graph.fileSupport&&(!this.editor.chromeless||this.editor.editable)){var y=null;mxEvent.addListener(t.container,"dragleave",(function(e){t.isEnabled()&&(null!=y&&(y.parentNode.removeChild(y),y=null),e.stopPropagation(),e.preventDefault())})),mxEvent.addListener(t.container,"dragover",mxUtils.bind(this,(function(e){null==y&&(!mxClient.IS_IE||document.documentMode>10)&&(y=this.highlightElement(t.container)),null!=this.sidebar&&this.sidebar.hideTooltip(),e.stopPropagation(),e.preventDefault()}))),mxEvent.addListener(t.container,"drop",mxUtils.bind(this,(function(e){if(null!=y&&(y.parentNode.removeChild(y),y=null),t.isEnabled()){var i=mxUtils.convertPoint(t.container,mxEvent.getClientX(e),mxEvent.getClientY(e)),n=t.view.translate,l=t.view.scale,r=i.x/l-n.x,s=i.y/l-n.y;if(e.dataTransfer.files.length>0)mxEvent.isShiftDown(e)?this.openFiles(e.dataTransfer.files,!0):(mxEvent.isAltDown(e)&&(r=null,s=null),this.importFiles(e.dataTransfer.files,r,s,this.maxImageSize,null,null,null,null,mxEvent.isControlDown(e),null,null,mxEvent.isShiftDown(e),e));else{mxEvent.isAltDown(e)&&(r=0,s=0);var o=mxUtils.indexOf(e.dataTransfer.types,"text/uri-list")>=0?e.dataTransfer.getData("text/uri-list"):null,a=this.extractGraphModelFromEvent(e,null!=this.pages);if(null!=a)t.setSelectionCells(this.importXml(a,r,s,!0));else if(mxUtils.indexOf(e.dataTransfer.types,"text/html")>=0){var d=e.dataTransfer.getData("text/html"),u=document.createElement("div");u.innerHTML=t.sanitizeHtml(d);var h=null,m=u.getElementsByTagName("img");if(null!=m&&1==m.length)null==(d=m[0].getAttribute("src"))&&(d=m[0].getAttribute("srcset")),/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(d)||(h=!0);else{var g=u.getElementsByTagName("a");if(null!=g&&1==g.length)d=g[0].getAttribute("href");else{var c=u.getElementsByTagName("pre");null!=c&&1==c.length&&(d=mxUtils.getTextContent(c[0]))}}var p=!0,f=mxUtils.bind(this,(function(){t.setSelectionCells(this.insertTextAt(d,r,s,!0,h,null,p,mxEvent.isControlDown(e)))}));h&&null!=d&&d.length>this.resampleThreshold?this.confirmImageResize((function(e){p=e,f()}),mxEvent.isControlDown(e)):f()}else null!=o&&/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(o)?this.loadImage(decodeURIComponent(o),mxUtils.bind(this,(function(e){var i=Math.max(1,e.width),n=Math.max(1,e.height),l=this.maxImageSize,a=Math.min(1,Math.min(l/Math.max(1,i)),l/Math.max(1,n));t.setSelectionCell(t.insertVertex(null,null,"",r,s,i*a,n*a,"shape=image;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;aspect=fixed;imageAspect=0;image="+o+";"))})),mxUtils.bind(this,(function(e){t.setSelectionCells(this.insertTextAt(o,r,s,!0))}))):mxUtils.indexOf(e.dataTransfer.types,"text/plain")>=0&&t.setSelectionCells(this.insertTextAt(e.dataTransfer.getData("text/plain"),r,s,!0))}}e.stopPropagation(),e.preventDefault()})),!1)}t.enableFlowAnimation=!0,this.initPages(),"1"==urlParams.embed&&this.initializeEmbedMode(),this.installSettings()},EditorUi.prototype.installImagePasteHandler=function(){if(!mxClient.IS_IE){var e=this.editor.graph;e.container.addEventListener("paste",mxUtils.bind(this,(function(t){if(!mxEvent.isConsumed(t))try{for(var i=t.clipboardData||t.originalEvent.clipboardData,n=!1,l=0;l<i.types.length;l++)if("text/"===i.types[l].substring(0,5)){n=!0;break}if(!n){var r=i.items;for(index in r){var s=r[index];if("file"===s.kind){if(e.isEditing())this.importFiles([s.getAsFile()],0,0,this.maxImageSize,(function(t,i,n,l,r,s){e.insertImage(t,r,s)}),(function(){}),(function(e){return"image/"==e.type.substring(0,6)}),(function(e){for(var t=0;t<e.length;t++)e[t]()}));else{var o=this.editor.graph.getInsertPoint();this.importFiles([s.getAsFile()],o.x,o.y,this.maxImageSize),mxEvent.consume(t)}break}}}}catch(e){}})),!1)}},EditorUi.prototype.installNativeClipboardHandler=function(){var e=this.editor.graph,t=document.createElement("div");t.setAttribute("autocomplete","off"),t.setAttribute("autocorrect","off"),t.setAttribute("autocapitalize","off"),t.setAttribute("spellcheck","false"),t.style.textRendering="optimizeSpeed",t.style.fontFamily="monospace",t.style.wordBreak="break-all",t.style.background="transparent",t.style.color="transparent",t.style.position="absolute",t.style.whiteSpace="nowrap",t.style.overflow="hidden",t.style.display="block",t.style.fontSize="1",t.style.zIndex="-1",t.style.resize="none",t.style.outline="none",t.style.width="1px",t.style.height="1px",mxUtils.setOpacity(t,0),t.contentEditable=!0,t.innerHTML=" ";var i=!1;function n(){window.setTimeout((function(){t.innerHTML=" ",t.focus(),document.execCommand("selectAll",!1,null)}),0)}this.keyHandler.bindControlKey(88,null),this.keyHandler.bindControlKey(67,null),this.keyHandler.bindControlKey(86,null),mxEvent.addListener(document,"keydown",mxUtils.bind(this,(function(n){var l=mxEvent.getSource(n);null==e.container||!e.isEnabled()||e.isMouseDown||e.isEditing()||null!=this.dialog||"INPUT"==l.nodeName||"TEXTAREA"==l.nodeName||(224==n.keyCode||!mxClient.IS_MAC&&17==n.keyCode||mxClient.IS_MAC&&(91==n.keyCode||93==n.keyCode))&&(i||(t.style.left=e.container.scrollLeft+10+"px",t.style.top=e.container.scrollTop+10+"px",e.container.appendChild(t),i=!0,t.focus(),document.execCommand("selectAll",!1,null)))}))),mxEvent.addListener(document,"keyup",mxUtils.bind(this,(function(n){var l=n.keyCode;window.setTimeout(mxUtils.bind(this,(function(){!i||224!=l&&17!=l&&91!=l&&93!=l||(i=!1,e.isEditing()||null!=this.dialog||null==e.container||e.container.focus(),t.parentNode.removeChild(t),null==this.dialog&&mxUtils.clearSelection())})),0)}))),mxEvent.addListener(t,"copy",mxUtils.bind(this,(function(i){if(e.isEnabled())try{mxClipboard.copy(e),this.copyCells(t),n()}catch(e){this.handleError(e)}}))),mxEvent.addListener(t,"cut",mxUtils.bind(this,(function(i){if(e.isEnabled())try{mxClipboard.copy(e),this.copyCells(t,!0),n()}catch(e){this.handleError(e)}}))),mxEvent.addListener(t,"paste",mxUtils.bind(this,(function(i){e.isEnabled()&&!e.isCellLocked(e.getDefaultParent())&&(t.innerHTML=" ",t.focus(),null!=i.clipboardData&&this.pasteCells(i,t,!0,!0),mxEvent.isConsumed(i)||window.setTimeout(mxUtils.bind(this,(function(){this.pasteCells(i,t,!1,!0)})),0))})),!0);var l=this.isSelectionAllowed;this.isSelectionAllowed=function(e){return mxEvent.getSource(e)==t||l.apply(this,arguments)}},EditorUi.prototype.setSketchMode=function(e){this.spinner.spin(document.body,mxResources.get("working")+"...")&&window.setTimeout(mxUtils.bind(this,(function(){this.spinner.stop(),this.doSetSketchMode(e),null==urlParams.rough&&(mxSettings.settings.sketchMode=e,mxSettings.save()),this.fireEvent(new mxEventObject("sketchModeChanged"))})),0)},EditorUi.prototype.setPagesVisible=function(e){Editor.pagesVisible!=e&&(Editor.pagesVisible=e,mxSettings.settings.pagesVisible=e,mxSettings.save(),this.fireEvent(new mxEventObject("pagesVisibleChanged")))},EditorUi.prototype.setInlineFullscreen=function(e){Editor.inlineFullscreen!=e&&(Editor.inlineFullscreen=e,this.fireEvent(new mxEventObject("inlineFullscreenChanged")),(window.opener||window.parent).postMessage(JSON.stringify({event:"resize",fullscreen:Editor.inlineFullscreen,rect:this.diagramContainer.getBoundingClientRect()}),"*"),window.setTimeout(mxUtils.bind(this,(function(){this.refresh(),this.actions.get("resetView").funct()})),10))},EditorUi.prototype.doSetSketchMode=function(e){if(Editor.sketchMode!=e){var t=this.editor.graph;function i(e,t,i){null==e[t]&&(e[t]=i)}Editor.sketchMode=e,this.menus.defaultFonts=Menus.prototype.defaultFonts,this.menus.defaultFontSize=e?20:16,t.defaultVertexStyle=mxUtils.clone(Graph.prototype.defaultVertexStyle),i(t.defaultVertexStyle,"fontSize",this.menus.defaultFontSize),t.defaultEdgeStyle=mxUtils.clone(Graph.prototype.defaultEdgeStyle),i(t.defaultEdgeStyle,"fontSize",this.menus.defaultFontSize-4),i(t.defaultEdgeStyle,"edgeStyle","none"),i(t.defaultEdgeStyle,"rounded","0"),i(t.defaultEdgeStyle,"curved","1"),i(t.defaultEdgeStyle,"jettySize","auto"),i(t.defaultEdgeStyle,"orthogonalLoop","1"),i(t.defaultEdgeStyle,"endArrow","open"),i(t.defaultEdgeStyle,"endSize","14"),i(t.defaultEdgeStyle,"startSize","14"),e&&(i(t.defaultVertexStyle,"fontFamily",Editor.sketchFontFamily),i(t.defaultVertexStyle,"fontSource",Editor.sketchFontSource),i(t.defaultVertexStyle,"hachureGap","4"),i(t.defaultVertexStyle,"sketch","1"),i(t.defaultEdgeStyle,"fontFamily",Editor.sketchFontFamily),i(t.defaultEdgeStyle,"fontSource",Editor.sketchFontSource),i(t.defaultEdgeStyle,"sketch","1"),i(t.defaultEdgeStyle,"hachureGap","4"),i(t.defaultEdgeStyle,"sourcePerimeterSpacing","8"),i(t.defaultEdgeStyle,"targetPerimeterSpacing","8"),this.menus.defaultFonts=[{fontFamily:Editor.sketchFontFamily,fontUrl:decodeURIComponent(Editor.sketchFontSource)},{fontFamily:"Rock Salt",fontUrl:"https://fonts.googleapis.com/css?family=Rock+Salt"},{fontFamily:"Permanent Marker",fontUrl:"https://fonts.googleapis.com/css?family=Permanent+Marker"}].concat(this.menus.defaultFonts)),t.currentVertexStyle=mxUtils.clone(t.defaultVertexStyle),t.currentEdgeStyle=mxUtils.clone(t.defaultEdgeStyle),this.clearDefaultStyle()}},EditorUi.prototype.getLinkTitle=function(e){var t=Graph.prototype.getLinkTitle.apply(this,arguments);if(Graph.isPageLink(e)){var i=e.indexOf(",");if(i>0){var n=this.getPageById(e.substring(i+1));t=null!=n?n.getName():mxResources.get("pageNotFound")}}else"data:"==e.substring(0,5)&&(t=mxResources.get("action"));return t},EditorUi.prototype.handleCustomLink=function(e){if(Graph.isPageLink(e)){var t=e.indexOf(","),i=this.getPageById(e.substring(t+1));if(!i)throw new Error(mxResources.get("pageNotFound")||"Page not found");this.selectPage(i)}else this.editor.graph.handleCustomLink(e)},EditorUi.prototype.isSettingsEnabled=function(){return void 0!==window.mxSettings&&(isLocalStorage||mxClient.IS_CHROMEAPP)},EditorUi.prototype.installSettings=function(){if(this.isSettingsEnabled()){if(Editor.pagesVisible=mxSettings.settings.pagesVisible,ColorDialog.recentColors=mxSettings.getRecentColors(),isLocalStorage)try{window.addEventListener("storage",mxUtils.bind(this,(function(e){e.key==mxSettings.key&&(mxSettings.load(),ColorDialog.recentColors=mxSettings.getRecentColors(),this.menus.customFonts=mxSettings.getCustomFonts())})),!1)}catch(e){}this.fireEvent(new mxEventObject("styleChanged","keys",[],"values",[],"cells",[])),this.menus.customFonts=mxSettings.getCustomFonts(),this.addListener("customFontsChanged",mxUtils.bind(this,(function(e,t){if("1"!=urlParams["ext-fonts"])mxSettings.setCustomFonts(this.menus.customFonts);else{var i=t.getProperty("customFonts");this.menus.customFonts=i,mxSettings.setCustomFonts(i)}mxSettings.save()}))),this.editor.graph.connectionHandler.setCreateTarget(mxSettings.isCreateTarget()),this.fireEvent(new mxEventObject("copyConnectChanged")),this.addListener("copyConnectChanged",mxUtils.bind(this,(function(e,t){mxSettings.setCreateTarget(this.editor.graph.connectionHandler.isCreateTarget()),mxSettings.save()}))),this.editor.graph.pageFormat=null!=this.editor.graph.defaultPageFormat?this.editor.graph.defaultPageFormat:mxSettings.getPageFormat(),this.addListener("pageFormatChanged",mxUtils.bind(this,(function(e,t){mxSettings.setPageFormat(this.editor.graph.pageFormat),mxSettings.save()}))),this.editor.graph.view.gridColor=mxSettings.getGridColor(Editor.isDarkMode()),this.editor.graph.view.defaultDarkGridColor=mxSettings.getGridColor(!0),this.editor.graph.view.defaultGridColor=mxSettings.getGridColor(!1),this.addListener("gridColorChanged",mxUtils.bind(this,(function(e,t){mxSettings.setGridColor(this.editor.graph.view.gridColor,Editor.isDarkMode()),mxSettings.save()}))),(mxClient.IS_CHROMEAPP||EditorUi.isElectronApp)&&(this.editor.addListener("autosaveChanged",mxUtils.bind(this,(function(e,t){mxSettings.setAutosave(this.editor.autosave),mxSettings.save()}))),this.editor.autosave=mxSettings.getAutosave()),null!=this.sidebar&&(null!=urlParams["search-shapes"]&&null!=this.sidebar.searchShapes?(this.sidebar.searchShapes(decodeURIComponent(urlParams["search-shapes"])),this.sidebar.showEntries("search")):(this.sidebar.showPalette("search",mxSettings.settings.search),this.editor.chromeless&&!this.editor.editable||!(mxSettings.settings.isNew||parseInt(mxSettings.settings.version||0)<=8)||(this.toggleScratchpad(),mxSettings.save()))),this.addListener("formatWidthChanged",(function(){mxSettings.setFormatWidth(this.formatWidth),mxSettings.save()}))}},EditorUi.prototype.copyImage=function(e,t,i){try{null!=navigator.clipboard&&this.spinner.spin(document.body,mxResources.get("exporting"))&&this.editor.exportToCanvas(mxUtils.bind(this,(function(e,i){try{this.spinner.stop();var n=this.createImageDataUri(e,t,"png"),l=parseInt(i.getAttribute("width")),r=parseInt(i.getAttribute("height"));this.writeImageToClipboard(n,l,r,mxUtils.bind(this,(function(e){this.handleError(e)})))}catch(e){this.handleError(e)}})),null,null,null,mxUtils.bind(this,(function(e){this.spinner.stop(),this.handleError(e)})),null,null,null!=i?i:4,null==this.editor.graph.background||this.editor.graph.background==mxConstants.NONE,null,null,null,10,null,null,!1,null,e.length>0?e:null)}catch(e){this.handleError(e)}},EditorUi.prototype.writeImageToClipboard=function(e,t,i,n){var l=this.base64ToBlob(e.substring(e.indexOf(",")+1),"image/png"),r=new ClipboardItem({"image/png":l,"text/html":new Blob(['<img src="'+e+'" width="'+t+'" height="'+i+'">'],{type:"text/html"})});navigator.clipboard.write([r]).catch(n)},EditorUi.prototype.copyCells=function(e,t){var i=this.editor.graph;if(i.isSelectionEmpty())e.innerHTML="";else{var n=mxUtils.sortCells(i.model.getTopmostCells(i.getSelectionCells())),l=mxUtils.getXml(i.encodeCells(n));mxUtils.setTextContent(e,encodeURIComponent(l)),t?(i.removeCells(n,!1),i.lastPasteXml=null):(i.lastPasteXml=l,i.pasteCounter=0),e.focus(),document.execCommand("selectAll",!1,null)}},EditorUi.prototype.copyXml=function(){var e=null;if(Editor.enableNativeCipboard){var t=this.editor.graph;if(!t.isSelectionEmpty()){e=mxUtils.sortCells(t.getExportableCells(t.model.getTopmostCells(t.getSelectionCells())));var i=mxUtils.getXml(t.encodeCells(e));navigator.clipboard.writeText(i)}}return e},EditorUi.prototype.pasteXml=function(e,t,i,n){var l=this.editor.graph,r=null;l.lastPasteXml==e?l.pasteCounter++:(l.lastPasteXml=e,l.pasteCounter=0);var s=l.pasteCounter*l.gridSize;if(i||this.isCompatibleString(e))r=this.importXml(e,s,s),l.setSelectionCells(r);else if(t&&1==l.getSelectionCount()){var o=l.getStartEditingCell(l.getSelectionCell(),n);if(/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(e)&&"image"==l.getCurrentCellStyle(o)[mxConstants.STYLE_SHAPE])l.setCellStyles(mxConstants.STYLE_IMAGE,e,[o]);else{l.model.beginUpdate();try{l.labelChanged(o,e),Graph.isLink(e)&&l.setLinkForCell(o,e)}finally{l.model.endUpdate()}}l.setSelectionCell(o)}else{var a=l.getInsertPoint();l.isMouseInsertPoint()&&(s=0,l.lastPasteXml==e&&l.pasteCounter>0&&l.pasteCounter--),r=this.insertTextAt(e,a.x+s,a.y+s,!0),l.setSelectionCells(r)}return l.isSelectionEmpty()||(l.scrollCellToVisible(l.getSelectionCell()),null!=this.hoverIcons&&this.hoverIcons.update(l.view.getState(l.getSelectionCell()))),r},EditorUi.prototype.pasteCells=function(e,t,i,n){if(!mxEvent.isConsumed(e)){var l=t,r=!1;if(i&&null!=e.clipboardData&&e.clipboardData.getData){var s=e.clipboardData.getData("text/plain"),o=!1;if(null!=s&&s.length>0&&"%3CmxGraphModel%3E"==s.substring(0,18)){var a=decodeURIComponent(s);this.isCompatibleString(a)&&(o=!0,s=a)}var d=o?null:e.clipboardData.getData("text/html");null!=d&&d.length>0?r="text/plain"!=(l=this.parseHtmlData(d)).getAttribute("data-type"):null!=s&&s.length>0&&(l=document.createElement("div"),mxUtils.setTextContent(l,d))}if(null!=(c=l.getElementsByTagName("span"))&&c.length>0&&"application/vnd.lucid.chart.objects"===c[0].getAttribute("data-lucid-type")){var u=c[0].getAttribute("data-lucid-content");null!=u&&u.length>0&&(this.convertLucidChart(u,mxUtils.bind(this,(function(e){var t=this.editor.graph;t.lastPasteXml==e?t.pasteCounter++:(t.lastPasteXml=e,t.pasteCounter=0);var i=t.pasteCounter*t.gridSize;t.setSelectionCells(this.importXml(e,i,i)),t.scrollCellToVisible(t.getSelectionCell())})),mxUtils.bind(this,(function(e){this.handleError(e)}))),mxEvent.consume(e))}else{var h=r?l.innerHTML:mxUtils.trim(null==l.innerText?mxUtils.getTextContent(l):l.innerText),m=!1;try{var g=h.lastIndexOf("%3E");g>=0&&g<h.length-3&&(h=h.substring(0,g+3))}catch(e){}try{var c;a=null!=(c=l.getElementsByTagName("span"))&&c.length>0?mxUtils.trim(decodeURIComponent(c[0].textContent)):decodeURIComponent(h),this.isCompatibleString(a)&&(m=!0,h=a)}catch(e){}try{if(null!=h&&h.length>0){this.pasteXml(h,n,m,e);try{mxEvent.consume(e)}catch(e){}}else if(!i){var p=this.editor.graph;p.lastPasteXml=null,p.pasteCounter=0}}catch(e){this.handleError(e)}}}t.innerHTML=" "},EditorUi.prototype.addFileDropHandler=function(e){if(Graph.fileSupport)for(var t=null,i=0;i<e.length;i++)mxEvent.addListener(e[i],"dragleave",(function(e){null!=t&&(t.parentNode.removeChild(t),t=null),e.stopPropagation(),e.preventDefault()})),mxEvent.addListener(e[i],"dragover",mxUtils.bind(this,(function(e){(this.editor.graph.isEnabled()||"1"!=urlParams.embed)&&null==t&&(!mxClient.IS_IE||document.documentMode>10&&document.documentMode<12)&&(t=this.highlightElement()),e.stopPropagation(),e.preventDefault()}))),mxEvent.addListener(e[i],"drop",mxUtils.bind(this,(function(e){if(null!=t&&(t.parentNode.removeChild(t),t=null),this.editor.graph.isEnabled()||"1"!=urlParams.embed)if(e.dataTransfer.files.length>0)this.hideDialog(),"1"==urlParams.embed?this.importFiles(e.dataTransfer.files,0,0,this.maxImageSize,null,null,null,null,!mxEvent.isControlDown(e)&&!mxEvent.isShiftDown(e)):this.openFiles(e.dataTransfer.files,!0);else if(null==(n=this.extractGraphModelFromEvent(e))){var i=null!=e.dataTransfer?e.dataTransfer:e.clipboardData;if(null!=i){if(10==document.documentMode||11==document.documentMode)n=i.getData("Text");else{var n=null;if(null!=(n=mxUtils.indexOf(i.types,"text/uri-list")>=0?e.dataTransfer.getData("text/uri-list"):mxUtils.indexOf(i.types,"text/html")>=0?i.getData("text/html"):null)&&n.length>0){var l=document.createElement("div");l.innerHTML=this.editor.graph.sanitizeHtml(n);var r=l.getElementsByTagName("img");r.length>0&&(n=r[0].getAttribute("src"))}else mxUtils.indexOf(i.types,"text/plain")>=0&&(n=i.getData("text/plain"))}if(null!=n)if(Editor.isPngDataUrl(n)){var s=Editor.extractGraphModelFromPng(n);null!=s&&s.length>0&&this.openLocalFile(s,null,!0)}else!this.isOffline()&&this.isRemoteFileFormat(n)?new mxXmlRequest(OPEN_URL,"format=xml&data="+encodeURIComponent(n)).send(mxUtils.bind(this,(function(e){e.getStatus()>=200&&e.getStatus()<=299&&this.openLocalFile(e.getText(),null,!0)}))):/^https?:\/\//.test(n)&&(null==this.getCurrentFile()?window.location.hash="#U"+encodeURIComponent(n):window.openWindow((mxClient.IS_CHROMEAPP?EditorUi.drawHost+"/":"https://"+location.host+"/")+window.location.search+"#U"+encodeURIComponent(n)))}}else this.openLocalFile(n,null,!0);e.stopPropagation(),e.preventDefault()})))},EditorUi.prototype.highlightElement=function(e){var t=0,i=0,n=0,l=0;if(null==e){var r=document.body,s=document.documentElement;n=(r.clientWidth||s.clientWidth)-3,l=Math.max(r.clientHeight||0,s.clientHeight)-3}else t=e.offsetTop,i=e.offsetLeft,n=e.clientWidth,l=e.clientHeight;var o=document.createElement("div");return o.style.zIndex=mxPopupMenu.prototype.zIndex+2,o.style.border="3px dotted rgb(254, 137, 12)",o.style.pointerEvents="none",o.style.position="absolute",o.style.top=t+"px",o.style.left=i+"px",o.style.width=Math.max(0,n-3)+"px",o.style.height=Math.max(0,l-3)+"px",null!=e&&e.parentNode==this.editor.graph.container?this.editor.graph.container.appendChild(o):document.body.appendChild(o),o},EditorUi.prototype.stringToCells=function(e){var t=mxUtils.parseXml(e),i=this.editor.extractGraphModel(t.documentElement),n=[];if(null!=i){var l=new mxCodec(i.ownerDocument),r=new mxGraphModel;l.decode(i,r);for(var s=r.getChildAt(r.getRoot(),0),o=0;o<r.getChildCount(s);o++)n.push(r.getChildAt(s,o))}return n},EditorUi.prototype.openFileHandle=function(e,t,i,n,l){if(null!=t&&t.length>0){(!this.useCanvasForExport&&/(\.png)$/i.test(t)||/(\.pdf)$/i.test(t))&&(t=t.substring(0,t.length-4)+".drawio");var r=mxUtils.bind(this,(function(e){if(t.lastIndexOf(".")>=0?t=t.substring(0,t.lastIndexOf("."))+".drawio":t+=".drawio","<mxlibrary"==e.substring(0,10)){null==this.getCurrentFile()&&"1"!=urlParams.embed&&this.openLocalFile(this.emptyDiagramXml,this.defaultFilename,n);try{this.loadLibrary(new LocalLibrary(this,e,t))}catch(e){this.handleError(e,mxResources.get("errorLoadingFile"))}}else this.openLocalFile(e,t,n)}));if(/(\.v(dx|sdx?))($|\?)/i.test(t)||/(\.vs(x|sx?))($|\?)/i.test(t))this.importVisio(i,mxUtils.bind(this,(function(e){this.spinner.stop(),r(e)})));else if(/(\.*<graphml )/.test(e))this.importGraphML(e,mxUtils.bind(this,(function(e){this.spinner.stop(),r(e)})));else if(Graph.fileSupport&&!this.isOffline()&&(new XMLHttpRequest).upload&&this.isRemoteFileFormat(e,t))this.parseFile(i,mxUtils.bind(this,(function(e){4==e.readyState&&(this.spinner.stop(),e.status>=200&&e.status<=299?r(e.responseText):this.handleError({message:mxResources.get(413==e.status?"drawingTooLarge":"invalidOrMissingFile")},mxResources.get("errorLoadingFile")))})));else if(this.isLucidChartData(e))/(\.json)$/i.test(t)&&(t=t.substring(0,t.length-5)+".drawio"),this.convertLucidChart(e,mxUtils.bind(this,(function(e){this.spinner.stop(),this.openLocalFile(e,t,n)})),mxUtils.bind(this,(function(e){this.spinner.stop(),this.handleError(e)})));else if("<mxlibrary"==e.substring(0,10)){this.spinner.stop(),null==this.getCurrentFile()&&"1"!=urlParams.embed&&this.openLocalFile(this.emptyDiagramXml,this.defaultFilename,n);try{this.loadLibrary(new LocalLibrary(this,e,i.name))}catch(e){this.handleError(e,mxResources.get("errorLoadingFile"))}}else if(0==e.indexOf("PK"))this.importZipFile(i,mxUtils.bind(this,(function(e){this.spinner.stop(),r(e)})),mxUtils.bind(this,(function(){this.spinner.stop(),this.openLocalFile(e,t,n)})));else{if("image/png"==i.type.substring(0,9))e=this.extractGraphModelFromPng(e);else if("application/pdf"==i.type){var s=Editor.extractGraphModelFromPdf(e);null!=s&&(l=null,n=!0,e=s)}this.spinner.stop(),this.openLocalFile(e,t,n,l,null!=l?i:null)}}},EditorUi.prototype.openFiles=function(e,t){if(this.spinner.spin(document.body,mxResources.get("loading")))for(var i=0;i<e.length;i++)mxUtils.bind(this,(function(e){var i=new FileReader;i.onload=mxUtils.bind(this,(function(i){try{this.openFileHandle(i.target.result,e.name,e,t)}catch(i){this.handleError(i)}})),i.onerror=mxUtils.bind(this,(function(e){this.spinner.stop(),this.handleError(e),window.openFile=null})),"image"!==e.type.substring(0,5)&&"application/pdf"!==e.type||"image/svg"===e.type.substring(0,9)?i.readAsText(e):i.readAsDataURL(e)}))(e[i])},EditorUi.prototype.openLocalFile=function(e,t,i,n,l){var r=this.getCurrentFile(),s=mxUtils.bind(this,(function(){if(window.openFile=null,null==t&&null!=this.getCurrentFile()&&this.isDiagramEmpty()){var r=mxUtils.parseXml(e);null!=r&&(this.editor.setGraphXml(r.documentElement),this.editor.graph.selectAll())}else this.fileLoaded(new LocalFile(this,e,t||this.defaultFilename,i,n,l))}));if(!(null!=e&&e.length>0))throw new Error(mxResources.get("notADiagramFile"));null==r||!r.isModified()&&(mxClient.IS_CHROMEAPP||EditorUi.isElectronApp||null!=n)?s():(mxClient.IS_CHROMEAPP||EditorUi.isElectronApp||null!=n)&&null!=r&&r.isModified()?this.confirm(mxResources.get("allChangesLost"),null,s,mxResources.get("cancel"),mxResources.get("discardChanges")):(window.openFile=new OpenFile((function(){window.openFile=null})),window.openFile.setData(e,t),window.openWindow(this.getUrl(),null,mxUtils.bind(this,(function(){null!=r&&r.isModified()?this.confirm(mxResources.get("allChangesLost"),null,s,mxResources.get("cancel"),mxResources.get("discardChanges")):s()}))))},EditorUi.prototype.getBasenames=function(){var e={};if(null!=this.pages)for(var t=0;t<this.pages.length;t++)this.updatePageRoot(this.pages[t]),this.addBasenamesForCell(this.pages[t].root,e);else this.addBasenamesForCell(this.editor.graph.model.getRoot(),e);var i=[];for(var n in e)i.push(n);return i},EditorUi.prototype.addBasenamesForCell=function(e,t){function i(e){if(null!=e){var i=e.lastIndexOf(".");i>0&&(e=e.substring(i+1,e.length)),null==t[e]&&(t[e]=!0)}}var n=this.editor.graph,l=n.getCellStyle(e),r=l[mxConstants.STYLE_SHAPE];i(mxStencilRegistry.getBasenameForStencil(r)),n.model.isEdge(e)&&(i(mxMarker.getPackageForType(l[mxConstants.STYLE_STARTARROW])),i(mxMarker.getPackageForType(l[mxConstants.STYLE_ENDARROW])));for(var s=n.model.getChildCount(e),o=0;o<s;o++)this.addBasenamesForCell(n.model.getChildAt(e,o),t)},EditorUi.prototype.setGraphEnabled=function(e){this.diagramContainer.style.visibility=e?"":"hidden",this.formatContainer.style.visibility=e?"":"hidden",this.sidebarFooterContainer.style.display=e?"":"none",this.sidebarContainer.style.display=e?"":"none",this.hsplit.style.display=e?"":"none",this.editor.graph.setEnabled(e),null!=this.ruler&&(this.ruler.hRuler.container.style.visibility=e?"":"hidden",this.ruler.vRuler.container.style.visibility=e?"":"hidden"),null!=this.tabContainer&&(this.tabContainer.style.visibility=e?"":"hidden"),e||(null!=this.actions.outlineWindow&&this.actions.outlineWindow.window.setVisible(!1),null!=this.actions.layersWindow&&this.actions.layersWindow.window.setVisible(!1),null!=this.menus.tagsWindow&&this.menus.tagsWindow.window.setVisible(!1),null!=this.menus.findWindow&&this.menus.findWindow.window.setVisible(!1),null!=this.menus.findReplaceWindow&&this.menus.findReplaceWindow.window.setVisible(!1))},EditorUi.prototype.initializeEmbedMode=function(){if(this.setGraphEnabled(!1),(window.opener||window.parent)!=window&&("1"!=urlParams.spin||this.spinner.spin(document.body,mxResources.get("loading")))){var e=!1;this.installMessageHandler(mxUtils.bind(this,(function(t,i,n,l){if(e||(e=!0,this.spinner.stop(),this.addEmbedButtons(),this.setGraphEnabled(!0)),null!=t&&0!=t.length||(t=this.emptyDiagramXml),this.setCurrentFile(new EmbedFile(this,t,{})),this.mode=App.MODE_EMBED,this.setFileData(t),l)try{var r=this.editor.graph;r.setGridEnabled(!1),r.pageVisible=!1;var s=r.model.cells;for(var o in s){var a=s[o];null!=a&&null!=a.style&&(a.style+=";sketch=1;"+(-1==a.style.indexOf("fontFamily=")||a.style.indexOf("fontFamily=Helvetica;")>-1?"fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;":""))}}catch(e){console.log(e)}this.editor.isChromelessView()?this.editor.graph.isLightboxView()&&this.lightboxFit():this.showLayersDialog(),this.chromelessResize&&this.chromelessResize(),this.editor.undoManager.clear(),this.editor.modified=null!=n&&n,this.updateUi(),window.self!==window.top&&window.focus(),null!=this.format&&this.format.refresh()})))}},EditorUi.prototype.showLayersDialog=function(){this.editor.graph.getModel().getChildCount(this.editor.graph.getModel().getRoot())>1&&(null==this.actions.layersWindow?this.actions.get("layers").funct():this.actions.layersWindow.window.setVisible(!0))},EditorUi.prototype.getPublicUrl=function(e,t){null!=e?e.getPublicUrl(t):t(null)},EditorUi.prototype.createLoadMessage=function(e){var t=this.editor.graph;return{event:e,pageVisible:t.pageVisible,translate:t.view.translate,bounds:t.getGraphBounds(),currentPage:this.getSelectedPageIndex(),scale:t.view.scale,page:t.view.getBackgroundPageBounds()}},EditorUi.prototype.sendEmbeddedSvgExport=function(e){var t=this.editor.graph;t.isEditing()&&t.stopEditing(!t.isInvokesStopCellEditing());var i=window.opener||window.parent;if(this.editor.modified){var n=t.background;null!=n&&n!=mxConstants.NONE||(n=this.embedExportBackground),this.getEmbeddedSvg(this.getFileData(!0,null,null,null,null,null,null,null,null,!1),t,null,!0,mxUtils.bind(this,(function(t){i.postMessage(JSON.stringify({event:"export",point:this.embedExitPoint,exit:null==e||!e,data:Editor.createSvgDataUri(t)}),"*")})),null,null,!0,n,1,this.embedExportBorder)}else e||i.postMessage(JSON.stringify({event:"exit",point:this.embedExitPoint}),"*");e||(this.diagramContainer.removeAttribute("data-bounds"),Editor.inlineFullscreen=!1,t.model.clear(),this.editor.undoManager.clear(),this.setBackgroundImage(null),this.editor.modified=!1,this.fireEvent(new mxEventObject("editInlineStop")))},EditorUi.prototype.installMessageHandler=function(e){var t=null,i=!1,n=!1,l=null,r=mxUtils.bind(this,(function(e,t){this.editor.modified&&"0"!=urlParams.modified?null!=urlParams.modified&&this.editor.setStatus(mxUtils.htmlEntities(mxResources.get(urlParams.modified))):this.editor.setStatus("")}));this.editor.graph.model.addListener(mxEvent.CHANGE,r),mxEvent.addListener(window,"message",mxUtils.bind(this,(function(r){var o=window.opener||window.parent;if(r.source==o){var a=r.data,d=null,u=mxUtils.bind(this,(function(e){if(null!=e&&"function"==typeof e.charAt&&"<"!=e.charAt(0))try{Editor.isPngDataUrl(e)?e=Editor.extractGraphModelFromPng(e):"data:image/svg+xml;base64,"==e.substring(0,26)?e=atob(e.substring(26)):"data:image/svg+xml;utf8,"==e.substring(0,24)&&(e=e.substring(24)),null!=e&&("%"==e.charAt(0)?e=decodeURIComponent(e):"<"!=e.charAt(0)&&(e=Graph.decompress(e)))}catch(e){}return e}));if("json"==urlParams.proto){var h=!1;try{a=JSON.parse(a)}catch(e){a=null}try{if(null==a)return;if("dialog"==a.action)return this.showError(null!=a.titleKey?mxResources.get(a.titleKey):a.title,null!=a.messageKey?mxResources.get(a.messageKey):a.message,null!=a.buttonKey?mxResources.get(a.buttonKey):a.button),void(null!=a.modified&&(this.editor.modified=a.modified));if("layout"==a.action)return void this.executeLayoutList(a.layouts);if("prompt"==a.action){this.spinner.stop();var m=new FilenameDialog(this,a.defaultValue||"",null!=a.okKey?mxResources.get(a.okKey):a.ok,(function(e){null!=e?s.postMessage(JSON.stringify({event:"prompt",value:e,message:a}),"*"):s.postMessage(JSON.stringify({event:"prompt-cancel",message:a}),"*")}),null!=a.titleKey?mxResources.get(a.titleKey):a.title);return this.showDialog(m.container,300,80,!0,!1),void m.init()}if("draft"==a.action){var g=u(a.xml);this.spinner.stop(),m=new DraftDialog(this,mxResources.get("draftFound",[a.name||this.defaultFilename]),g,mxUtils.bind(this,(function(){this.hideDialog(),s.postMessage(JSON.stringify({event:"draft",result:"edit",message:a}),"*")})),mxUtils.bind(this,(function(){this.hideDialog(),s.postMessage(JSON.stringify({event:"draft",result:"discard",message:a}),"*")})),a.editKey?mxResources.get(a.editKey):null,a.discardKey?mxResources.get(a.discardKey):null,a.ignore?mxUtils.bind(this,(function(){this.hideDialog(),s.postMessage(JSON.stringify({event:"draft",result:"ignore",message:a}),"*")})):null),this.showDialog(m.container,640,480,!0,!1,mxUtils.bind(this,(function(e){e&&this.actions.get("exit").funct()})));try{m.init()}catch(e){s.postMessage(JSON.stringify({event:"draft",error:e.toString(),message:a}),"*")}return}if("template"==a.action){this.spinner.stop();var c=1==a.enableRecent,p=1==a.enableSearch,f=1==a.enableCustomTemp;if("1"==urlParams.newTempDlg&&!a.templatesOnly&&null!=a.callback){var x=this.getCurrentUser(),v=new TemplatesDialog(this,(function(e,t,i){e=e||this.emptyDiagramXml,s.postMessage(JSON.stringify({event:"template",xml:e,blank:e==this.emptyDiagramXml,name:t,tempUrl:i.url,libs:i.libs,builtIn:null!=i.info&&null!=i.info.custContentId,message:a}),"*")}),mxUtils.bind(this,(function(){this.actions.get("exit").funct()})),null,null,null!=x?x.id:null,c?mxUtils.bind(this,(function(e,t,i){this.remoteInvoke("getRecentDiagrams",[i],null,e,t)})):null,p?mxUtils.bind(this,(function(e,t,i,n){this.remoteInvoke("searchDiagrams",[e,n],null,t,i)})):null,mxUtils.bind(this,(function(e,t,i){this.remoteInvoke("getFileContent",[e.url],null,t,i)})),null,f?mxUtils.bind(this,(function(e){this.remoteInvoke("getCustomTemplates",null,null,e,(function(){e({},0)}))})):null,!1,!1,!0,!0);return void this.showDialog(v.container,window.innerWidth,window.innerHeight,!0,!1,null,!1,!0)}return m=new NewDialog(this,!1,!a.templatesOnly&&null!=a.callback,mxUtils.bind(this,(function(t,i,n,l){t=t||this.emptyDiagramXml,null!=a.callback?s.postMessage(JSON.stringify({event:"template",xml:t,blank:t==this.emptyDiagramXml,name:i,tempUrl:n,libs:l,builtIn:!0,message:a}),"*"):(e(t,r,t!=this.emptyDiagramXml,a.toSketch),this.editor.modified||this.editor.setStatus(""))})),null,null,null,null,null,null,null,c?mxUtils.bind(this,(function(e){this.remoteInvoke("getRecentDiagrams",[null],null,e,(function(){e(null,"Network Error!")}))})):null,p?mxUtils.bind(this,(function(e,t){this.remoteInvoke("searchDiagrams",[e,null],null,t,(function(){t(null,"Network Error!")}))})):null,mxUtils.bind(this,(function(e,t,i){s.postMessage(JSON.stringify({event:"template",docUrl:e,info:t,name:i}),"*")})),null,null,f?mxUtils.bind(this,(function(e){this.remoteInvoke("getCustomTemplates",null,null,e,(function(){e({},0)}))})):null,1==a.withoutType),this.showDialog(m.container,620,460,!0,!1,mxUtils.bind(this,(function(e){this.sidebar.hideTooltip(),e&&this.actions.get("exit").funct()}))),void m.init()}if("textContent"==a.action){var b=this.getDiagramTextContent();return void s.postMessage(JSON.stringify({event:"textContent",data:b,message:a}),"*")}if("status"==a.action)return null!=a.messageKey?this.editor.setStatus(mxUtils.htmlEntities(mxResources.get(a.messageKey))):null!=a.message&&this.editor.setStatus(mxUtils.htmlEntities(a.message)),void(null!=a.modified&&(this.editor.modified=a.modified));if("spinner"==a.action){var y=null!=a.messageKey?mxResources.get(a.messageKey):a.message;return void(null==a.show||a.show?this.spinner.spin(document.body,y):this.spinner.stop())}if("exit"==a.action)return void this.actions.get("exit").funct();if("viewport"==a.action)return void(null!=a.viewport&&(this.embedViewport=a.viewport));if("snapshot"==a.action)return void this.sendEmbeddedSvgExport(!0);if("export"==a.action){if("png"==a.format||"xmlpng"==a.format){if(null==a.spin&&null==a.spinKey||this.spinner.spin(document.body,null!=a.spinKey?mxResources.get(a.spinKey):a.spin)){var E=null!=a.xml?a.xml:this.getFileData(!0);this.editor.graph.setEnabled(!1);var w=this.editor.graph,C=mxUtils.bind(this,(function(e){this.editor.graph.setEnabled(!0),this.spinner.stop();var t=this.createLoadMessage("export");t.format=a.format,t.message=a,t.data=e,t.xml=E,s.postMessage(JSON.stringify(t),"*")})),U=mxUtils.bind(this,(function(e){null==e&&(e=Editor.blankImage),"xmlpng"==a.format&&(e=Editor.writeGraphModelToPng(e,"tEXt","mxfile",encodeURIComponent(E))),w!=this.editor.graph&&w.container.parentNode.removeChild(w.container),C(e)})),S=a.pageId||(null!=this.pages?a.currentPage?this.currentPage.getId():this.pages[0].getId():null);if(this.isExportToCanvas()){var R=mxUtils.bind(this,(function(){if(null!=this.pages&&this.currentPage.getId()!=S){var e,t=w.getGlobalVariable;w=this.createTemporaryGraph(w.getStylesheet());for(var i=0;i<this.pages.length;i++)if(this.pages[i].getId()==S){e=this.updatePageRoot(this.pages[i]);break}null==e&&(e=this.currentPage),w.getGlobalVariable=function(i){return"page"==i?e.getName():"pagenumber"==i?1:t.apply(this,arguments)},document.body.appendChild(w.container),w.model.setRoot(e.root)}if(null!=a.layerIds){var n=w.model,l=n.getChildCells(n.getRoot()),r={};for(i=0;i<a.layerIds.length;i++)r[a.layerIds[i]]=!0;for(i=0;i<l.length;i++)n.setVisible(l[i],r[l[i].id]||!1)}this.editor.exportToCanvas(mxUtils.bind(this,(function(e){U(e.toDataURL("image/png"))})),a.width,null,a.background,mxUtils.bind(this,(function(){U(null)})),null,null,a.scale,a.transparent,a.shadow,null,w,a.border,null,a.grid,a.keepTheme)}));null!=a.xml&&a.xml.length>0?(i=!0,this.setFileData(E),i=!1,this.editor.graph.mathEnabled?window.setTimeout((function(){window.MathJax.Hub.Queue(R)}),0):R()):R()}else new mxXmlRequest(EXPORT_URL,"format=png&embedXml="+("xmlpng"==a.format?"1":"0")+(null!=S?"&pageId="+S:"")+(null!=a.layerIds&&a.layerIds.length>0?"&extras="+encodeURIComponent(JSON.stringify({layerIds:a.layerIds})):"")+(null!=a.scale?"&scale="+a.scale:"")+"&base64=1&xml="+encodeURIComponent(E)).send(mxUtils.bind(this,(function(e){e.getStatus()>=200&&e.getStatus()<=299?C("data:image/png;base64,"+e.getText()):U(null)})),mxUtils.bind(this,(function(){U(null)})))}}else R=mxUtils.bind(this,(function(){var e=this.createLoadMessage("export");if(e.message=a,"html2"==a.format||"html"==a.format&&("0"!=urlParams.pages||null!=this.pages&&this.pages.length>1)){var t=this.getXmlFileData();e.xml=mxUtils.getXml(t),e.data=this.getFileData(null,null,!0,null,null,null,t),e.format=a.format}else{if("html"!=a.format){mxSvgCanvas2D.prototype.foAltText=null;var i=null!=a.background?a.background:this.editor.graph.background;i==mxConstants.NONE&&(i=null),e.xml=this.getFileData(!0,null,null,null,null,null,null,null,null,!1),e.format="svg";var n=mxUtils.bind(this,(function(t){this.editor.graph.setEnabled(!0),this.spinner.stop(),e.data=Editor.createSvgDataUri(t),s.postMessage(JSON.stringify(e),"*")}));if("xmlsvg"==a.format)(null==a.spin&&null==a.spinKey||this.spinner.spin(document.body,null!=a.spinKey?mxResources.get(a.spinKey):a.spin))&&this.getEmbeddedSvg(e.xml,this.editor.graph,null,!0,n,null,null,a.embedImages,i,a.scale,a.border,a.shadow,a.keepTheme);else if(null==a.spin&&null==a.spinKey||this.spinner.spin(document.body,null!=a.spinKey?mxResources.get(a.spinKey):a.spin)){this.editor.graph.setEnabled(!1);var l=this.editor.graph.getSvg(i,a.scale,a.border,null,null,null,null,null,null,this.editor.graph.shadowVisible||a.shadow,null,a.keepTheme);(this.editor.graph.shadowVisible||a.shadow)&&this.editor.graph.addSvgShadow(l),this.embedFonts(l,mxUtils.bind(this,(function(e){a.embedImages||null==a.embedImages?this.editor.convertImages(e,mxUtils.bind(this,(function(e){n(mxUtils.getXml(e))}))):n(mxUtils.getXml(e))})))}return}var r=this.editor.getGraphXml();e.data=this.getHtml(r,this.editor.graph),e.xml=mxUtils.getXml(r),e.format=a.format}s.postMessage(JSON.stringify(e),"*")})),null!=a.xml&&a.xml.length>0?(i=!0,this.setFileData(a.xml),i=!1,this.editor.graph.mathEnabled?window.setTimeout((function(){window.MathJax.Hub.Queue(R)}),0):R()):R();return}if("load"!=a.action){if("merge"==a.action){var D=this.getCurrentFile();return void(null!=D&&null!=(g=u(a.xml))&&""!=g&&D.mergeFile(new LocalFile(this,g),(function(){s.postMessage(JSON.stringify({event:"merge",message:a}),"*")}),(function(e){s.postMessage(JSON.stringify({event:"merge",message:a,error:e}),"*")})))}return"remoteInvokeReady"==a.action?void this.handleRemoteInvokeReady(s):"remoteInvoke"==a.action?void this.handleRemoteInvoke(a,r.origin):"remoteInvokeResponse"==a.action?void this.handleRemoteInvokeResponse(a):void s.postMessage(JSON.stringify({error:"unknownMessage",data:JSON.stringify(a)}),"*")}if(h=a.toSketch,n=1==a.autosave,this.hideDialog(),null!=a.modified&&null==urlParams.modified&&(urlParams.modified=a.modified),null!=a.saveAndExit&&null==urlParams.saveAndExit&&(urlParams.saveAndExit=a.saveAndExit),null!=a.noSaveBtn&&null==urlParams.noSaveBtn&&(urlParams.noSaveBtn=a.noSaveBtn),null!=a.rough){var k=Editor.sketchMode;this.doSetSketchMode(a.rough),k!=Editor.sketchMode&&this.fireEvent(new mxEventObject("sketchModeChanged"))}if(null!=a.dark&&(k=Editor.darkMode,this.doSetDarkMode(a.dark),k!=Editor.darkMode&&this.fireEvent(new mxEventObject("darkModeChanged"))),null!=a.border&&(this.embedExportBorder=a.border),null!=a.background&&(this.embedExportBackground=a.background),null!=a.viewport&&(this.embedViewport=a.viewport),this.embedExitPoint=null,null!=a.rect){var A=this.embedExportBorder;this.diagramContainer.style.border="2px solid #295fcc",this.diagramContainer.style.top=a.rect.top+"px",this.diagramContainer.style.left=a.rect.left+"px",this.diagramContainer.style.height=a.rect.height+"px",this.diagramContainer.style.width=a.rect.width+"px",this.diagramContainer.style.bottom="",this.diagramContainer.style.right="",d=mxUtils.bind(this,(function(){var e=this.editor.graph,t=e.maxFitScale;e.maxFitScale=a.maxFitScale,e.fit(2*A),e.maxFitScale=t,e.container.scrollTop-=2*A,e.container.scrollLeft-=2*A,this.fireEvent(new mxEventObject("editInlineStart","data",[a]))}))}if(null!=a.noExitBtn&&null==urlParams.noExitBtn&&(urlParams.noExitBtn=a.noExitBtn),null!=a.title&&null!=this.buttonContainer){g=document.createElement("span");mxUtils.write(g,a.title),null!=this.embedFilenameSpan&&this.embedFilenameSpan.parentNode.removeChild(this.embedFilenameSpan),this.buttonContainer.appendChild(g),this.embedFilenameSpan=g}try{a.libs&&this.sidebar.showEntries(a.libs)}catch(e){}a=null!=a.xmlpng?this.extractGraphModelFromPng(a.xmlpng):null!=a.descriptor?a.descriptor:a.xml}catch(e){this.handleError(e)}}var I=mxUtils.bind(this,(function(){return"0"!=urlParams.pages||null!=this.pages&&this.pages.length>1?this.getFileData(!0):mxUtils.getXml(this.editor.getGraphXml())})),L=mxUtils.bind(this,(function(r,o){i=!0;try{e(r,o,null,h)}catch(e){this.handleError(e)}if(i=!1,null!=urlParams.modified&&this.editor.setStatus(""),l=I(),n&&null==t&&(t=mxUtils.bind(this,(function(e,t){var n=I();if(n!=l&&!i){var r=this.createLoadMessage("autosave");r.xml=n,(window.opener||window.parent).postMessage(JSON.stringify(r),"*")}l=n})),this.editor.graph.model.addListener(mxEvent.CHANGE,t),this.editor.graph.addListener("gridSizeChanged",t),this.editor.graph.addListener("shadowVisibleChanged",t),this.addListener("pageFormatChanged",t),this.addListener("pageScaleChanged",t),this.addListener("backgroundColorChanged",t),this.addListener("backgroundImageChanged",t),this.addListener("foldingEnabledChanged",t),this.addListener("mathEnabledChanged",t),this.addListener("gridEnabledChanged",t),this.addListener("guidesEnabledChanged",t),this.addListener("pageViewChanged",t)),"1"==urlParams.returnbounds||"json"==urlParams.proto){var a=this.createLoadMessage("load");a.xml=r,s.postMessage(JSON.stringify(a),"*")}null!=d&&d()}));if(null!=a&&"function"==typeof a.substring&&"data:application/vnd.visio;base64,"==a.substring(0,34)){var F="0M8R4KGxGuE"==a.substring(34,45)?"raw.vsd":"raw.vsdx";this.importVisio(this.base64ToBlob(a.substring(a.indexOf(",")+1)),(function(e){L(e,r)}),mxUtils.bind(this,(function(e){this.handleError(e)})),F)}else null!=a&&"function"==typeof a.substring&&!this.isOffline()&&(new XMLHttpRequest).upload&&this.isRemoteFileFormat(a,"")?this.parseFile(new Blob([a],{type:"application/octet-stream"}),mxUtils.bind(this,(function(e){4==e.readyState&&e.status>=200&&e.status<=299&&"<mxGraphModel"==e.responseText.substring(0,13)&&L(e.responseText,r)})),""):null!=a&&"function"==typeof a.substring&&this.isLucidChartData(a)?this.convertLucidChart(a,mxUtils.bind(this,(function(e){L(e)})),mxUtils.bind(this,(function(e){this.handleError(e)}))):null==a||"object"!=typeof a||null==a.format||null==a.data&&null==a.url?(a=u(a),L(a,r)):this.loadDescriptor(a,mxUtils.bind(this,(function(e){L(I(),r)})),mxUtils.bind(this,(function(e){this.handleError(e,mxResources.get("errorLoadingFile"))})))}})));var s=window.opener||window.parent,o="json"==urlParams.proto?JSON.stringify({event:"init"}):urlParams.ready||"ready";if(s.postMessage(o,"*"),"json"==urlParams.proto){var a=this.editor.graph.openLink;this.editor.graph.openLink=function(e,t,i){a.apply(this,arguments),s.postMessage(JSON.stringify({event:"openLink",href:e,target:t,allowOpener:i}),"*")}}},EditorUi.prototype.addEmbedButtons=function(){if(null!=this.menubar&&"1"!=urlParams.embedInline){var e=document.createElement("div");e.style.display="inline-block",e.style.position="absolute",e.style.paddingTop="atlas"==uiTheme||"1"==urlParams.atlas?"2px":"0px",e.style.paddingLeft="8px",e.style.paddingBottom="2px";var t=document.createElement("button");t.className="geBigButton";var i=t;if("1"==urlParams.noSaveBtn){if("0"!=urlParams.saveAndExit){var n="1"==urlParams.publishClose?mxResources.get("publish"):mxResources.get("saveAndExit");mxUtils.write(t,n),t.setAttribute("title",n),mxEvent.addListener(t,"click",mxUtils.bind(this,(function(){this.actions.get("saveAndExit").funct()}))),e.appendChild(t)}}else mxUtils.write(t,mxResources.get("save")),t.setAttribute("title",mxResources.get("save")+" ("+Editor.ctrlKey+"+S)"),mxEvent.addListener(t,"click",mxUtils.bind(this,(function(){this.actions.get("save").funct()}))),e.appendChild(t),"1"==urlParams.saveAndExit&&(t=document.createElement("a"),mxUtils.write(t,mxResources.get("saveAndExit")),t.setAttribute("title",mxResources.get("saveAndExit")),t.className="geBigButton geBigStandardButton",t.style.marginLeft="6px",mxEvent.addListener(t,"click",mxUtils.bind(this,(function(){this.actions.get("saveAndExit").funct()}))),e.appendChild(t),i=t);if("1"!=urlParams.noExitBtn){t=document.createElement("a");var l="1"==urlParams.publishClose?mxResources.get("close"):mxResources.get("exit");mxUtils.write(t,l),t.setAttribute("title",l),t.className="geBigButton geBigStandardButton",t.style.marginLeft="6px",mxEvent.addListener(t,"click",mxUtils.bind(this,(function(){this.actions.get("exit").funct()}))),e.appendChild(t),i=t}i.style.marginRight="20px",this.toolbar.container.appendChild(e),this.toolbar.staticElements.push(e),e.style.right="atlas"==uiTheme||"1"==urlParams.atlas?"42px":"52px"}},EditorUi.prototype.showImportCsvDialog=function(){null==this.importCsvDialog&&(this.importCsvDialog=new TextareaDialog(this,mxResources.get("csv")+":",Editor.defaultCsvValue,mxUtils.bind(this,(function(e){this.importCsv(e)})),null,null,620,430,null,!0,!0,mxResources.get("import"),this.isOffline()?null:"https://drawio-app.com/import-from-csv-to-drawio/")),this.showDialog(this.importCsvDialog.container,640,520,!0,!0,null,null,null,null,!0),this.importCsvDialog.init()},EditorUi.prototype.executeLayoutList=function(e,t){for(var i=this.editor.graph,n=i.getSelectionCells(),l=0;l<e.length;l++){var r=new window[e[l].layout](i);if(null!=e[l].config)for(var s in e[l].config)r[s]=e[l].config[s];this.executeLayout((function(){r.execute(i.getDefaultParent(),0==n.length?null:n)}),l==e.length-1,t)}},EditorUi.prototype.importCsv=function(e,t){try{var i=e.split("\n"),n=[],l=[],r=[],s={};if(i.length>0){for(var o={},a=null,d=null,u=null,h=null,m=null,g=null,c="whiteSpace=wrap;html=1;",p=null,f=null,x="",v="auto",b="auto",y=null,E=null,w=40,C=40,U=100,S=0,R=this.editor.graph,D=(R.view,R.getGraphBounds(),function(){null!=t?t(de):(R.setSelectionCells(de),R.scrollCellToVisible(R.getSelectionCell()))}),k=R.getFreeInsertPoint(),A=k.x,I=k.y,L=I,F=null,T="auto",M=(f=null,[]),P=null,N=null,O=0;O<i.length&&"#"==i[O].charAt(0);){for(e=i[O],O++;O<i.length&&"\\"==e.charAt(e.length-1)&&"#"==i[O].charAt(0);)e=e.substring(0,e.length-1)+mxUtils.trim(i[O].substring(1)),O++;if("#"!=e.charAt(1)){var B=e.indexOf(":");if(B>0){var G=mxUtils.trim(e.substring(1,B)),H=mxUtils.trim(e.substring(B+1));"label"==G?F=R.sanitizeHtml(H):"labelname"==G&&H.length>0&&"-"!=H?m=H:"labels"==G&&H.length>0&&"-"!=H?g=JSON.parse(H):"style"==G?d=H:"parentstyle"==G?c=H:"stylename"==G&&H.length>0&&"-"!=H?h=H:"styles"==G&&H.length>0&&"-"!=H?u=JSON.parse(H):"vars"==G&&H.length>0&&"-"!=H?a=JSON.parse(H):"identity"==G&&H.length>0&&"-"!=H?p=H:"parent"==G&&H.length>0&&"-"!=H?f=H:"namespace"==G&&H.length>0&&"-"!=H?x=H:"width"==G?v=H:"height"==G?b=H:"left"==G&&H.length>0?y=H:"top"==G&&H.length>0?E=H:"ignore"==G?N=H.split(","):"connect"==G?M.push(JSON.parse(H)):"link"==G?P=H:"padding"==G?S=parseFloat(H):"edgespacing"==G?w=parseFloat(H):"nodespacing"==G?C=parseFloat(H):"levelspacing"==G?U=parseFloat(H):"layout"==G&&(T=H)}}}if(null==i[O])throw new Error(mxResources.get("invalidOrMissingFile"));for(var _=this.editor.csvToArray(i[O]),V=null,z=null,X=[],j=0;j<_.length;j++)p==_[j]&&(V=j),f==_[j]&&(z=j),X.push(mxUtils.trim(_[j]).replace(/[^a-z0-9]+/gi,"_").replace(/^\d+/,"").replace(/_+$/,""));if(null==F&&(F="%"+X[0]+"%"),null!=M)for(var W=0;W<M.length;W++)null==o[M[W].to]&&(o[M[W].to]={});var J=[];for(j=O+1;j<i.length;j++){if(null==(K=this.editor.csvToArray(i[j]))){var q=i[j].length>40?i[j].substring(0,40)+"...":i[j];throw new Error(q+" ("+j+"):\n"+mxResources.get("containsValidationErrors"))}K.length>0&&J.push(K)}R.model.beginUpdate();try{for(j=0;j<J.length;j++){var K=J[j],$=null,Y=null!=V?x+K[V]:null;null!=Y&&($=R.model.getCell(Y));var Z=null!=$,Q=new mxCell(F,new mxGeometry(A,L,0,0),d||"whiteSpace=wrap;html=1;");Q.vertex=!0,Q.id=Y;for(var ee=0;ee<K.length;ee++)R.setAttributeForCell(Q,X[ee],K[ee]);if(null!=m&&null!=g){var te=g[Q.getAttribute(m)];null!=te&&R.labelChanged(Q,te)}if(null!=h&&null!=u){var ie=u[Q.getAttribute(h)];null!=ie&&(Q.style=ie)}if(R.setAttributeForCell(Q,"placeholders","1"),Q.style=R.replacePlaceholders(Q,Q.style,a),Z?(R.model.setValue($,Q.value),R.model.setStyle($,Q.style),mxUtils.indexOf(r,$)<0&&r.push($),R.fireEvent(new mxEventObject("cellsInserted","cells",[$]))):R.fireEvent(new mxEventObject("cellsInserted","cells",[Q])),$=Q,!Z)for(W=0;W<M.length;W++)o[M[W].to][$.getAttribute(M[W].to)]=$;null!=P&&"link"!=P&&(R.setLinkForCell($,$.getAttribute(P)),R.setAttributeForCell($,P,null));var ne=this.editor.graph.getPreferredSizeForCell($);if(f=null!=z?R.model.getCell(x+K[z]):null,$.vertex){var le=null!=f?0:A,re=null!=f?0:I;null!=y&&null!=$.getAttribute(y)&&($.geometry.x=le+parseFloat($.getAttribute(y))),null!=E&&null!=$.getAttribute(E)&&($.geometry.y=re+parseFloat($.getAttribute(E)));var se="@"==v.charAt(0)?$.getAttribute(v.substring(1)):null;$.geometry.width=null!=se&&"auto"!=se?parseFloat($.getAttribute(v.substring(1))):"auto"==v||"auto"==se?ne.width+S:parseFloat(v);var oe="@"==b.charAt(0)?$.getAttribute(b.substring(1)):null;$.geometry.height=null!=oe&&"auto"!=oe?parseFloat(oe):"auto"==b||"auto"==oe?ne.height+S:parseFloat(b),L+=$.geometry.height+C}Z?(null==s[Y]&&(s[Y]=[]),s[Y].push($)):(n.push($),null!=f?(f.style=R.replacePlaceholders(f,c,a),R.addCell($,f),l.push(f)):r.push(R.addCell($)))}for(j=0;j<l.length;j++)se="@"==v.charAt(0)?l[j].getAttribute(v.substring(1)):null,oe="@"==b.charAt(0)?l[j].getAttribute(b.substring(1)):null,"auto"!=v&&"auto"!=se||"auto"!=b&&"auto"!=oe||R.updateGroupBounds([l[j]],S,!0);var ae=r.slice(),de=r.slice();for(W=0;W<M.length;W++){var ue=M[W];for(j=0;j<n.length;j++){$=n[j];var he=mxUtils.bind(this,(function(e,t,i){var n=t.getAttribute(i.from);if(null!=n&&""!=n)for(var l=n.split(","),r=0;r<l.length;r++){var s=o[i.to][l[r]];if(null!=s){var d=i.label;null!=i.fromlabel&&(d=(t.getAttribute(i.fromlabel)||"")+(d||"")),null!=i.sourcelabel&&(d=R.replacePlaceholders(t,i.sourcelabel,a)+(d||"")),null!=i.tolabel&&(d=(d||"")+(s.getAttribute(i.tolabel)||"")),null!=i.targetlabel&&(d=(d||"")+R.replacePlaceholders(s,i.targetlabel,a));var u="target"==i.placeholders==!i.invert?s:e,h=null!=i.style?R.replacePlaceholders(u,i.style,a):R.createCurrentEdgeStyle(),m=R.insertEdge(null,null,d||"",i.invert?s:e,i.invert?e:s,h);if(null!=i.labels)for(var g=0;g<i.labels.length;g++){var c=i.labels[g],p=null!=c.x?c.x:0,f=null!=c.y?c.y:0,x=new mxCell(c.label||g,new mxGeometry(p,f,0,0),"resizable=0;html=1;");x.vertex=!0,x.connectable=!1,x.geometry.relative=!0,null!=c.placeholders&&(x.value=R.replacePlaceholders("target"==c.placeholders==!i.invert?s:e,x.value,a)),null==c.dx&&null==c.dy||(x.geometry.offset=new mxPoint(null!=c.dx?c.dx:0,null!=c.dy?c.dy:0)),m.insert(x)}de.push(m),mxUtils.remove(i.invert?e:s,ae)}}}));if(he($,$,ue),null!=s[$.id])for(ee=0;ee<s[$.id].length;ee++)he($,s[$.id][ee],ue)}}if(null!=N)for(j=0;j<n.length;j++)for($=n[j],ee=0;ee<N.length;ee++)R.setAttributeForCell($,mxUtils.trim(N[ee]),null);if(r.length>0){var me=new mxParallelEdgeLayout(R);me.spacing=w,me.checkOverlap=!0;var ge=function(){me.spacing>0&&me.execute(R.getDefaultParent());for(var e=0;e<r.length;e++){var t=R.getCellGeometry(r[e]);t.x=Math.round(R.snap(t.x)),t.y=Math.round(R.snap(t.y)),"auto"==v&&(t.width=Math.round(R.snap(t.width))),"auto"==b&&(t.height=Math.round(R.snap(t.height)))}};if("["==T.charAt(0)){var ce=D;R.view.validate(),this.executeLayoutList(JSON.parse(T),(function(){ge(),ce()})),D=null}else if("circle"==T){var pe=new mxCircleLayout(R);pe.disableEdgeStyle=!1,pe.resetEdges=!1;var fe=pe.isVertexIgnored;pe.isVertexIgnored=function(e){return fe.apply(this,arguments)||mxUtils.indexOf(r,e)<0},this.executeLayout((function(){pe.execute(R.getDefaultParent()),ge()}),!0,D),D=null}else if("horizontaltree"==T||"verticaltree"==T||"auto"==T&&de.length==2*r.length-1&&1==ae.length){R.view.validate();var xe=new mxCompactTreeLayout(R,"horizontaltree"==T);xe.levelDistance=C,xe.edgeRouting=!1,xe.resetEdges=!1,this.executeLayout((function(){xe.execute(R.getDefaultParent(),ae.length>0?ae[0]:null)}),!0,D),D=null}else if("horizontalflow"==T||"verticalflow"==T||"auto"==T&&1==ae.length){R.view.validate();var ve=new mxHierarchicalLayout(R,"horizontalflow"==T?mxConstants.DIRECTION_WEST:mxConstants.DIRECTION_NORTH);ve.intraCellSpacing=C,ve.parallelEdgeSpacing=w,ve.interRankCellSpacing=U,ve.disableEdgeStyle=!1,this.executeLayout((function(){ve.execute(R.getDefaultParent(),de),R.moveCells(de,A,I)}),!0,D),D=null}else if("organic"==T||"auto"==T&&de.length>r.length){R.view.validate();var be=new mxFastOrganicLayout(R);be.forceConstant=3*C,be.disableEdgeStyle=!1,be.resetEdges=!1;var ye=be.isVertexIgnored;be.isVertexIgnored=function(e){return ye.apply(this,arguments)||mxUtils.indexOf(r,e)<0},this.executeLayout((function(){be.execute(R.getDefaultParent()),ge()}),!0,D),D=null}}this.hideDialog()}finally{R.model.endUpdate()}null!=D&&D()}}catch(W){this.handleError(W)}},EditorUi.prototype.getSearch=function(e){var t="";if("1"!=urlParams.offline&&"1"!=urlParams.demo&&null!=e&&window.location.search.length>0){var i="?";for(var n in urlParams)mxUtils.indexOf(e,n)<0&&null!=urlParams[n]&&(t+=i+n+"="+urlParams[n],i="&")}else t=window.location.search;return t},EditorUi.prototype.getUrl=function(e){var t=null!=e?e:window.location.pathname,i=t.indexOf("?")>0?1:0;if("1"==urlParams.offline)t+=window.location.search;else{var n=["tmp","libs","clibs","state","fileId","code","share","notitle","data","url","embed","client","create","title","splash"];for(var l in urlParams)mxUtils.indexOf(n,l)<0&&(t+=0==i?"?":"&",null!=urlParams[l]&&(t+=l+"="+urlParams[l],i++))}return t},EditorUi.prototype.showLinkDialog=function(e,t,i,n,l){var r=new LinkDialog(this,e,t,i,!0,n,l);this.showDialog(r.container,560,130,!0,!0),r.init()},EditorUi.prototype.getServiceCount=function(e){var t=1;return null==this.drive&&"function"!=typeof window.DriveClient||t++,null==this.dropbox&&"function"!=typeof window.DropboxClient||t++,null==this.oneDrive&&"function"!=typeof window.OneDriveClient||t++,null!=this.gitHub&&t++,null!=this.gitLab&&t++,null!=this.notion&&t++,e&&isLocalStorage&&"1"==urlParams.browser&&t++,t},EditorUi.prototype.updateUi=function(){this.updateButtonContainer(),this.updateActionStates();var e=this.getCurrentFile(),t=null!=e||"1"==urlParams.embed&&this.editor.graph.isEnabled();this.menus.get("viewPanels").setEnabled(t),this.menus.get("viewZoom").setEnabled(t);var i=("1"!=urlParams.embed||!this.editor.graph.isEnabled())&&(null==e||e.isRestricted());this.actions.get("makeCopy").setEnabled(!i),this.actions.get("print").setEnabled(!i),this.menus.get("exportAs").setEnabled(!i),this.menus.get("embed").setEnabled(!i);var n="1"!=urlParams.embed||this.editor.graph.isEnabled();this.menus.get("extras").setEnabled(n),Editor.enableCustomLibraries&&(this.menus.get("openLibraryFrom").setEnabled(n),this.menus.get("newLibrary").setEnabled(n));var l="1"==urlParams.embed&&this.editor.graph.isEnabled()||null!=e&&e.isEditable();this.actions.get("image").setEnabled(t),this.actions.get("zoomIn").setEnabled(t),this.actions.get("zoomOut").setEnabled(t),this.actions.get("resetView").setEnabled(t),this.actions.get("undo").setEnabled(this.canUndo()&&l),this.actions.get("redo").setEnabled(this.canRedo()&&l),this.menus.get("edit").setEnabled(t),this.menus.get("view").setEnabled(t),this.menus.get("importFrom").setEnabled(l),this.menus.get("arrange").setEnabled(l),null!=this.toolbar&&(null!=this.toolbar.edgeShapeMenu&&this.toolbar.edgeShapeMenu.setEnabled(l),null!=this.toolbar.edgeStyleMenu&&this.toolbar.edgeStyleMenu.setEnabled(l)),this.updateUserElement()},EditorUi.prototype.updateButtonContainer=function(){},EditorUi.prototype.updateUserElement=function(){},EditorUi.prototype.scheduleSanityCheck=function(){},EditorUi.prototype.stopSanityCheck=function(){},EditorUi.prototype.isDiagramActive=function(){var e=this.getCurrentFile();return null!=e&&e.isEditable()||"1"==urlParams.embed&&this.editor.graph.isEnabled()};var o=EditorUi.prototype.updateActionStates;EditorUi.prototype.updateActionStates=function(){o.apply(this,arguments);var e=this.editor.graph,t=this.getCurrentFile(),i=this.getSelectionState(),n=this.isDiagramActive();this.actions.get("pageSetup").setEnabled(n),this.actions.get("autosave").setEnabled(null!=t&&t.isEditable()&&t.isAutosaveOptional()),this.actions.get("guides").setEnabled(n),this.actions.get("editData").setEnabled(e.isEnabled()),this.actions.get("shadowVisible").setEnabled(n),this.actions.get("connectionArrows").setEnabled(n),this.actions.get("connectionPoints").setEnabled(n),this.actions.get("copyStyle").setEnabled(n&&!e.isSelectionEmpty()),this.actions.get("pasteStyle").setEnabled(n&&i.cells.length>0),this.actions.get("editGeometry").setEnabled(i.vertices.length>0),this.actions.get("createShape").setEnabled(n),this.actions.get("createRevision").setEnabled(n),this.actions.get("moveToFolder").setEnabled(null!=t),this.actions.get("makeCopy").setEnabled(null!=t&&!t.isRestricted()),this.actions.get("editDiagram").setEnabled(n&&(null==t||!t.isRestricted())),this.actions.get("publishLink").setEnabled(null!=t&&!t.isRestricted()),this.actions.get("tags").setEnabled("hidden"!=this.diagramContainer.style.visibility),this.actions.get("layers").setEnabled("hidden"!=this.diagramContainer.style.visibility),this.actions.get("outline").setEnabled("hidden"!=this.diagramContainer.style.visibility),this.actions.get("rename").setEnabled(null!=t&&t.isRenamable()||"1"==urlParams.embed),this.actions.get("close").setEnabled(null!=t),this.menus.get("publish").setEnabled(null!=t&&!t.isRestricted());var l=this.actions.get("findReplace");l.setEnabled("hidden"!=this.diagramContainer.style.visibility),l.label=mxResources.get("find")+(e.isEnabled()?"/"+mxResources.get("replace"):"")+"...";var r=e.view.getState(e.getSelectionCell());this.actions.get("editShape").setEnabled(n&&null!=r&&null!=r.shape&&null!=r.shape.stencil)};var a=EditorUi.prototype.destroy;EditorUi.prototype.destroy=function(){null!=this.exportDialog&&(this.exportDialog.parentNode.removeChild(this.exportDialog),this.exportDialog=null),a.apply(this,arguments)},null!=window.ExportDialog&&(ExportDialog.showXmlOption=!1,ExportDialog.showGifOption=!1,ExportDialog.exportFile=function(e,t,i,n,l,r,s,o){var a=e.editor.graph;if("xml"==i)e.hideDialog(),e.saveData(t,"xml",mxUtils.getXml(e.editor.getGraphXml()),"text/xml");else if("svg"==i)e.hideDialog(),e.saveData(t,"svg",mxUtils.getXml(a.getSvg(n,l,r)),"image/svg+xml");else{var d=e.getFileData(!0,null,null,null,null,!0),u=a.getGraphBounds(),h=Math.floor(u.width*l/a.view.scale),m=Math.floor(u.height*l/a.view.scale);if(d.length<=MAX_REQUEST_SIZE&&h*m<MAX_AREA)if(e.hideDialog(),"png"!=i&&"jpg"!=i&&"jpeg"!=i||!e.isExportToCanvas()){var g={globalVars:a.getExportVariables()};o&&(g.grid={size:a.gridSize,steps:a.view.gridSteps,color:a.view.gridColor}),e.saveRequest(t,i,(function(e,t){return new mxXmlRequest(EXPORT_URL,"format="+i+"&base64="+(t||"0")+(null!=e?"&filename="+encodeURIComponent(e):"")+"&extras="+encodeURIComponent(JSON.stringify(g))+(s>0?"&dpi="+s:"")+"&bg="+(null!=n?n:"none")+"&w="+h+"&h="+m+"&border="+r+"&xml="+encodeURIComponent(d))}))}else"png"==i?e.exportImage(l,null==n||"none"==n,!0,!1,!1,r,!0,!1,null,o,s):e.exportImage(l,!1,!0,!1,!1,r,!0,!1,"jpeg",o);else mxUtils.alert(mxResources.get("drawingTooLarge"))}}),EditorUi.prototype.getDiagramTextContent=function(){this.editor.graph.setEnabled(!1);var e=this.editor.graph,t="";if(null!=this.pages)for(var i=0;i<this.pages.length;i++){var n=e;this.currentPage!=this.pages[i]&&(n=this.createTemporaryGraph(e.getStylesheet()),this.updatePageRoot(this.pages[i]),n.model.setRoot(this.pages[i].root)),t+=this.pages[i].getName()+" "+n.getIndexableText()+" "}else t=e.getIndexableText();return this.editor.graph.setEnabled(!0),t},EditorUi.prototype.showRemotelyStoredLibrary=function(e){var t={},i=document.createElement("div");i.style.whiteSpace="nowrap",this.editor.graph;var n=document.createElement("h3");mxUtils.write(n,mxUtils.htmlEntities(e)),n.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:12px",i.appendChild(n);var l=document.createElement("div");l.style.cssText="border:1px solid lightGray;overflow: auto;height:300px",l.innerHTML='<div style="text-align:center;padding:8px;"><img src="'+IMAGE_PATH+'/spin.gif"></div>';var r={};try{for(var s=mxSettings.getCustomLibraries(),o=0;o<s.length;o++){var a=s[o];if("R"==a.substring(0,1)){var d=JSON.parse(decodeURIComponent(a.substring(1)));r[d[0]]={id:d[0],title:d[1],downloadUrl:d[2]}}}}catch(e){}this.remoteInvoke("getCustomLibraries",null,null,(function(e){if(l.innerHTML="",0==e.length)l.innerHTML='<div style="text-align:center;padding-top:20px;color:gray;">'+mxUtils.htmlEntities(mxResources.get("noLibraries"))+"</div>";else for(var i=0;i<e.length;i++){var n=e[i];r[n.id]&&(t[n.id]=n),function(e,i){mxEvent.addListener(i,"change",(function(){this.checked?t[e.id]=e:delete t[e.id]}))}(n,this.addCheckbox(l,n.title,r[n.id]))}}),mxUtils.bind(this,(function(e){l.innerHTML="";var t=document.createElement("div");t.style.padding="8px",t.style.textAlign="center",mxUtils.write(t,mxResources.get("error")+": "),mxUtils.write(t,null!=e&&null!=e.message?e.message:mxResources.get("unknownError")),l.appendChild(t)}))),i.appendChild(l);var u=new CustomDialog(this,i,mxUtils.bind(this,(function(){this.spinner.spin(document.body,mxResources.get("loading"));var e=0;for(var i in t)null==r[i]&&(e++,mxUtils.bind(this,(function(t){this.remoteInvoke("getFileContent",[t.downloadUrl],null,mxUtils.bind(this,(function(i){0==--e&&this.spinner.stop();try{this.loadLibrary(new RemoteLibrary(this,i,t))}catch(e){this.handleError(e,mxResources.get("errorLoadingFile"))}})),mxUtils.bind(this,(function(){0==--e&&this.spinner.stop(),this.handleError(null,mxResources.get("errorLoadingFile"))})))}))(t[i]));for(var i in r)t[i]||this.closeLibrary(new RemoteLibrary(this,null,r[i]));0==e&&this.spinner.stop()})),null,null,"https://www.diagrams.net/doc/faq/custom-libraries-confluence-cloud");this.showDialog(u.container,340,390,!0,!0,null,null,null,null,!0)},EditorUi.prototype.remoteInvokableFns={getDiagramTextContent:{isAsync:!1},getLocalStorageFile:{isAsync:!1,allowedDomains:["app.diagrams.net"]},getLocalStorageFileNames:{isAsync:!1,allowedDomains:["app.diagrams.net"]},setMigratedFlag:{isAsync:!1,allowedDomains:["app.diagrams.net"]}},EditorUi.prototype.remoteInvokeCallbacks=[],EditorUi.prototype.remoteInvokeQueue=[],EditorUi.prototype.handleRemoteInvokeReady=function(e){this.remoteWin=e;for(var t=0;t<this.remoteInvokeQueue.length;t++)e.postMessage(this.remoteInvokeQueue[t],"*");this.remoteInvokeQueue=[]},EditorUi.prototype.handleRemoteInvokeResponse=function(e){var t=e.msgMarkers,i=this.remoteInvokeCallbacks[t.callbackId];if(null==i)throw new Error("No callback for "+(null!=t?t.callbackId:"null"));e.error?i.error&&i.error(e.error.errResp):i.callback&&i.callback.apply(this,e.resp),this.remoteInvokeCallbacks[t.callbackId]=null},EditorUi.prototype.remoteInvoke=function(e,t,i,n,l){var r=!0,s=window.setTimeout(mxUtils.bind(this,(function(){r=!1,l({code:App.ERROR_TIMEOUT,message:mxResources.get("timeout")})})),this.timeout),o=mxUtils.bind(this,(function(){window.clearTimeout(s),r&&n.apply(this,arguments)})),a=mxUtils.bind(this,(function(){window.clearTimeout(s),r&&l.apply(this,arguments)}));(i=i||{}).callbackId=this.remoteInvokeCallbacks.length,this.remoteInvokeCallbacks.push({callback:o,error:a});var d=JSON.stringify({event:"remoteInvoke",funtionName:e,functionArgs:t,msgMarkers:i});null!=this.remoteWin?this.remoteWin.postMessage(d,"*"):this.remoteInvokeQueue.push(d)},EditorUi.prototype.handleRemoteInvoke=function(e,t){var i=mxUtils.bind(this,(function(t,i){var n={event:"remoteInvokeResponse",msgMarkers:e.msgMarkers};null!=i?n.error={errResp:i}:null!=t&&(n.resp=t),this.remoteWin.postMessage(JSON.stringify(n),"*")}));try{var n=e.funtionName,l=this.remoteInvokableFns[n];if(null!=l&&"function"==typeof this[n]){if(l.allowedDomains){for(var r=!1,s=0;s<l.allowedDomains.length;s++)if(t=="https://"+l.allowedDomains[s]){r=!0;break}if(!r)return void i(null,"Invalid Call: "+n+" is not allowed.")}var o=e.functionArgs;if(Array.isArray(o)||(o=[]),l.isAsync)o.push((function(){i(Array.prototype.slice.apply(arguments))})),o.push((function(e){i(null,e||"Unkown Error")})),this[n].apply(this,o);else{var a=this[n].apply(this,o);i([a])}}else i(null,"Invalid Call: "+n+" is not found.")}catch(e){i(null,"Invalid Call: An error occurred, "+e.message)}},EditorUi.prototype.openDatabase=function(e,t){if(null==this.database){var i=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB;if(null!=i)try{var n=i.open("database",2);n.onupgradeneeded=function(e){try{var i=n.result;e.oldVersion<1&&i.createObjectStore("objects",{keyPath:"key"}),e.oldVersion<2&&(i.createObjectStore("files",{keyPath:"title"}),i.createObjectStore("filesInfo",{keyPath:"title"}),EditorUi.migrateStorageFiles=isLocalStorage)}catch(e){null!=t&&t(e)}},n.onsuccess=mxUtils.bind(this,(function(t){var i=n.result;this.database=i,EditorUi.migrateStorageFiles&&(StorageFile.migrate(i),EditorUi.migrateStorageFiles=!1),"app.diagrams.net"!=location.host||this.drawioMigrationStarted||(this.drawioMigrationStarted=!0,this.getDatabaseItem(".drawioMigrated3",mxUtils.bind(this,(function(e){if(!e||"1"==urlParams.forceMigration){var t=document.createElement("iframe");t.style.display="none",t.setAttribute("src","https://www.draw.io?embed=1&proto=json&forceMigration="+urlParams.forceMigration),document.body.appendChild(t);var i,n=!0,l=!1,r=0,s=mxUtils.bind(this,(function(){l=!0,this.setDatabaseItem(".drawioMigrated3",!0),t.contentWindow.postMessage(JSON.stringify({action:"remoteInvoke",funtionName:"setMigratedFlag"}),"*")})),o=mxUtils.bind(this,(function(){r++,a()})),a=mxUtils.bind(this,(function(){try{if(r>=i.length)return void s();var e=i[r];StorageFile.getFileContent(this,e,mxUtils.bind(this,(function(i){null==i||".scratchpad"==e&&i==this.emptyLibraryXml?t.contentWindow.postMessage(JSON.stringify({action:"remoteInvoke",funtionName:"getLocalStorageFile",functionArgs:[e]}),"*"):o()})),o)}catch(e){console.log(e)}})),d=mxUtils.bind(this,(function(e){try{this.setDatabaseItem(null,[{title:e.title,size:e.data.length,lastModified:Date.now(),type:e.isLib?"L":"F"},{title:e.title,data:e.data}],o,o,["filesInfo","files"])}catch(e){console.log(e)}})),u=mxUtils.bind(this,(function(e){try{if(e.source!=t.contentWindow)return;var r={};try{r=JSON.parse(e.data)}catch(e){}"init"==r.event?(t.contentWindow.postMessage(JSON.stringify({action:"remoteInvokeReady"}),"*"),t.contentWindow.postMessage(JSON.stringify({action:"remoteInvoke",funtionName:"getLocalStorageFileNames"}),"*")):"remoteInvokeResponse"!=r.event||l||(n?null!=r.resp&&r.resp.length>0&&null!=r.resp[0]?(i=r.resp[0],n=!1,a()):s():null!=r.resp&&r.resp.length>0&&null!=r.resp[0]?d(r.resp[0]):o())}catch(e){console.log(e)}}));window.addEventListener("message",u)}})))),e(i),i.onversionchange=function(){i.close()}})),n.onerror=t,n.onblocked=function(){}}catch(e){null!=t&&t(e)}else null!=t&&t()}else e(this.database)},EditorUi.prototype.setDatabaseItem=function(e,t,i,n,l){this.openDatabase(mxUtils.bind(this,(function(r){try{l=l||"objects",Array.isArray(l)||(l=[l],e=[e],t=[t]);var s=r.transaction(l,"readwrite");s.oncomplete=i,s.onerror=n;for(var o=0;o<l.length;o++)s.objectStore(l[o]).put(null!=e&&null!=e[o]?{key:e[o],data:t[o]}:t[o])}catch(e){null!=n&&n(e)}})),n)},EditorUi.prototype.removeDatabaseItem=function(e,t,i,n){this.openDatabase(mxUtils.bind(this,(function(l){n=n||"objects",Array.isArray(n)||(n=[n],e=[e]);var r=l.transaction(n,"readwrite");r.oncomplete=t,r.onerror=i;for(var s=0;s<n.length;s++)r.objectStore(n[s]).delete(e[s])})),i)},EditorUi.prototype.getDatabaseItem=function(e,t,i,n){this.openDatabase(mxUtils.bind(this,(function(l){try{n=n||"objects";var r=l.transaction([n],"readonly").objectStore(n).get(e);r.onsuccess=function(){t(r.result)},r.onerror=i}catch(e){null!=i&&i(e)}})),i)},EditorUi.prototype.getDatabaseItems=function(e,t,i){this.openDatabase(mxUtils.bind(this,(function(n){try{i=i||"objects";var l=n.transaction([i],"readonly").objectStore(i).openCursor(IDBKeyRange.lowerBound(0)),r=[];l.onsuccess=function(t){null==t.target.result?e(r):(r.push(t.target.result.value),t.target.result.continue())},l.onerror=t}catch(e){null!=t&&t(e)}})),t)},EditorUi.prototype.getDatabaseItemKeys=function(e,t,i){this.openDatabase(mxUtils.bind(this,(function(n){try{i=i||"objects";var l=n.transaction([i],"readonly").objectStore(i).getAllKeys();l.onsuccess=function(){e(l.result)},l.onerror=t}catch(e){null!=t&&t(e)}})),t)},EditorUi.prototype.commentsSupported=function(){var e=this.getCurrentFile();return null!=e&&e.commentsSupported()},EditorUi.prototype.commentsRefreshNeeded=function(){var e=this.getCurrentFile();return null==e||e.commentsRefreshNeeded()},EditorUi.prototype.commentsSaveNeeded=function(){var e=this.getCurrentFile();return null!=e&&e.commentsSaveNeeded()},EditorUi.prototype.getComments=function(e,t){var i=this.getCurrentFile();null!=i?i.getComments(e,t):e([])},EditorUi.prototype.addComment=function(e,t,i){var n=this.getCurrentFile();null!=n?n.addComment(e,t,i):t(Date.now())},EditorUi.prototype.canReplyToReplies=function(){var e=this.getCurrentFile();return null==e||e.canReplyToReplies()},EditorUi.prototype.canComment=function(){var e=this.getCurrentFile();return null==e||e.canComment()},EditorUi.prototype.newComment=function(e,t){var i=this.getCurrentFile();return null!=i?i.newComment(e,t):new DrawioComment(this,null,e,Date.now(),Date.now(),!1,t)},EditorUi.prototype.isRevisionHistorySupported=function(){var e=this.getCurrentFile();return null!=e&&e.isRevisionHistorySupported()},EditorUi.prototype.getRevisions=function(e,t){var i=this.getCurrentFile();null!=i&&i.getRevisions?i.getRevisions(e,t):t({message:mxResources.get("unknownError")})},EditorUi.prototype.isRevisionHistoryEnabled=function(){var e=this.getCurrentFile();return null!=e&&(e.constructor==DriveFile&&e.isEditable()||e.constructor==DropboxFile)},EditorUi.prototype.getServiceName=function(){return"draw.io"},EditorUi.prototype.addRemoteServiceSecurityCheck=function(e){e.setRequestHeader("Content-Language","da, mi, en, de-DE")},EditorUi.prototype.loadUrl=function(e,t,i,n,l,r,s,o){return EditorUi.logEvent("SHOULD NOT BE CALLED: loadUrl"),this.editor.loadUrl(e,t,i,n,l,r,s,o)},EditorUi.prototype.loadFonts=function(e){return EditorUi.logEvent("SHOULD NOT BE CALLED: loadFonts"),this.editor.loadFonts(e)},EditorUi.prototype.createSvgDataUri=function(e){return EditorUi.logEvent("SHOULD NOT BE CALLED: createSvgDataUri"),Editor.createSvgDataUri(e)},EditorUi.prototype.embedCssFonts=function(e,t){return EditorUi.logEvent("SHOULD NOT BE CALLED: embedCssFonts"),this.editor.embedCssFonts(e,t)},EditorUi.prototype.embedExtFonts=function(e){return EditorUi.logEvent("SHOULD NOT BE CALLED: embedExtFonts"),this.editor.embedExtFonts(e)},EditorUi.prototype.exportToCanvas=function(e,t,i,n,l,r,s,o,a,d,u,h,m,g,c,p){return EditorUi.logEvent("SHOULD NOT BE CALLED: exportToCanvas"),this.editor.exportToCanvas(e,t,i,n,l,r,s,o,a,d,u,h,m,g,c,p)},EditorUi.prototype.createImageUrlConverter=function(){return EditorUi.logEvent("SHOULD NOT BE CALLED: createImageUrlConverter"),this.editor.createImageUrlConverter()},EditorUi.prototype.convertImages=function(e,t,i,n){return EditorUi.logEvent("SHOULD NOT BE CALLED: convertImages"),this.editor.convertImages(e,t,i,n)},EditorUi.prototype.convertImageToDataUri=function(e,t){return EditorUi.logEvent("SHOULD NOT BE CALLED: convertImageToDataUri"),this.editor.convertImageToDataUri(e,t)},EditorUi.prototype.base64Encode=function(e){return EditorUi.logEvent("SHOULD NOT BE CALLED: base64Encode"),Editor.base64Encode(e)},EditorUi.prototype.updateCRC=function(e,t,i,n){return EditorUi.logEvent("SHOULD NOT BE CALLED: updateCRC"),Editor.updateCRC(e,t,i,n)},EditorUi.prototype.crc32=function(e){return EditorUi.logEvent("SHOULD NOT BE CALLED: crc32"),Editor.crc32(e)},EditorUi.prototype.writeGraphModelToPng=function(e,t,i,n,l){return EditorUi.logEvent("SHOULD NOT BE CALLED: writeGraphModelToPng"),Editor.writeGraphModelToPng(e,t,i,n,l)},EditorUi.prototype.getLocalStorageFileNames=function(){if("1"==localStorage.getItem(".localStorageMigrated")&&"1"!=urlParams.forceMigration)return null;for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t),n=localStorage.getItem(i);if(i.length>0&&(".scratchpad"==i||"."!=i.charAt(0))&&n.length>0){var l="<mxfile "===n.substring(0,8)||"<?xml"===n.substring(0,5)||"\x3c!--[if IE]>"===n.substring(0,12),r="<mxlibrary>"===n.substring(0,11);(l||r)&&e.push(i)}}return e},EditorUi.prototype.getLocalStorageFile=function(e){if("1"==localStorage.getItem(".localStorageMigrated")&&"1"!=urlParams.forceMigration)return null;var t=localStorage.getItem(e);return{title:e,data:t,isLib:"<mxlibrary>"===t.substring(0,11)}},EditorUi.prototype.setMigratedFlag=function(){localStorage.setItem(".localStorageMigrated","1")}}();var CommentsWindow=function(e,t,i,n,l,r){var s=!e.canComment(),o=e.canReplyToReplies(),a=null,d=document.createElement("div");d.className="geCommentsWin",d.style.background=Editor.isDarkMode()?Dialog.backdropColor:"whiteSmoke";var u=EditorUi.compactUi?"26px":"30px",h=document.createElement("div");h.className="geCommentsList",h.style.backgroundColor=Editor.isDarkMode()?Dialog.backdropColor:"whiteSmoke",h.style.bottom=parseInt(u)+7+"px",d.appendChild(h);var m=document.createElement("span");m.style.cssText="display:none;padding-top:10px;text-align:center;",mxUtils.write(m,mxResources.get("noCommentsFound"));var g=document.createElement("div");g.className="geToolbarContainer geCommentsToolbar",g.style.height=u,g.style.padding=EditorUi.compactUi?"4px 0px 3px 0px":"1px",g.style.backgroundColor=Editor.isDarkMode()?Dialog.backdropColor:"whiteSmoke";var c=document.createElement("a");function p(){for(var e=h.getElementsByTagName("div"),t=0,i=0;i<e.length;i++)"none"!=e[i].style.display&&e[i].parentNode==h&&t++;m.style.display=0==t?"block":"none"}function f(e,t,i,n){a={div:t,comment:e,saveCallback:i,deleteOnCancel:n};var l=t.querySelector(".geCommentTxt"),r=t.querySelector(".geCommentActionsList"),s=document.createElement("textarea");s.className="geCommentEditTxtArea",s.style.minHeight=l.offsetHeight+"px",s.value=e.content,t.insertBefore(s,l);var o=document.createElement("div");function d(){t.removeChild(s),t.removeChild(o),r.style.display="block",l.style.display="block"}o.className="geCommentEditBtns";var u=mxUtils.button(mxResources.get("cancel"),(function(){n?(t.parentNode.removeChild(t),p()):d(),a=null}));u.className="geCommentEditBtn",o.appendChild(u);var h=mxUtils.button(mxResources.get("save"),(function(){l.innerHTML="",e.content=s.value,mxUtils.write(l,e.content),d(),i(e),a=null}));mxEvent.addListener(s,"keydown",mxUtils.bind(this,(function(e){mxEvent.isConsumed(e)||((mxEvent.isControlDown(e)||mxClient.IS_MAC&&mxEvent.isMetaDown(e))&&13==e.keyCode?(h.click(),mxEvent.consume(e)):27==e.keyCode&&(u.click(),mxEvent.consume(e)))}))),h.focus(),h.className="geCommentEditBtn gePrimaryBtn",o.appendChild(h),t.insertBefore(o,l),r.style.display="none",l.style.display="none",s.focus()}function x(t,i){i.innerHTML="";var n=new Date(t.modifiedDate),l=e.timeSince(n);null==l&&(l=mxResources.get("lessThanAMinute")),mxUtils.write(i,mxResources.get("timeAgo",[l],"{1} ago")),i.setAttribute("title",n.toLocaleDateString()+" "+n.toLocaleTimeString())}function v(e){var t=document.createElement("img");t.className="geCommentBusyImg",t.src=IMAGE_PATH+"/spin.gif",e.appendChild(t),e.busyImg=t}function b(e){e.style.border="1px solid red",e.removeChild(e.busyImg)}function y(e){e.style.border="",e.removeChild(e.busyImg)}function E(t,i,n,l,r){if(r||!t.isResolved){m.style.display="none";var d=document.createElement("div");d.className="geCommentContainer",d.setAttribute("data-commentId",t.id),d.style.marginLeft=20*l+5+"px",t.isResolved&&!Editor.isDarkMode()&&(d.style.backgroundColor="ghostWhite");var u=document.createElement("div");u.className="geCommentHeader";var g=document.createElement("img");g.className="geCommentUserImg",g.src=t.user.pictureUrl||Editor.userImage,u.appendChild(g);var c=document.createElement("div");c.className="geCommentHeaderTxt",u.appendChild(c);var w=document.createElement("div");w.className="geCommentUsername",mxUtils.write(w,t.user.displayName||""),c.appendChild(w);var C=document.createElement("div");C.className="geCommentDate",C.setAttribute("data-commentId",t.id),x(t,C),c.appendChild(C),d.appendChild(u);var S=document.createElement("div");S.className="geCommentTxt",mxUtils.write(S,t.content||""),d.appendChild(S),t.isLocked&&(d.style.opacity="0.5");var R=document.createElement("div");R.className="geCommentActions";var D=document.createElement("ul");D.className="geCommentActionsList",R.appendChild(D),s||t.isLocked||0!=l&&!o||F(mxResources.get("reply"),(function(){M("",!0)}),t.isResolved);var k=e.getCurrentUser();null==k||k.id!=t.user.id||s||t.isLocked||(F(mxResources.get("edit"),(function(){!function i(){f(t,d,(function(){v(d),t.editComment(t.content,(function(){y(d)}),(function(t){b(d),i(),e.handleError(t,null,null,null,mxUtils.htmlEntities(mxResources.get("objectNotFound")))}))}))}()}),t.isResolved),F(mxResources.get("delete"),(function(){e.confirm(mxResources.get("areYouSure"),(function(){v(d),t.deleteComment((function(e){if(!0===e){var n=d.querySelector(".geCommentTxt");n.innerHTML="",mxUtils.write(n,mxResources.get("msgDeleted"));for(var l=d.querySelectorAll(".geCommentAction"),r=0;r<l.length;r++)l[r].parentNode.removeChild(l[r]);y(d),d.style.opacity="0.5"}else{var s=T().replies;for(r=0;r<s.length;r++)h.removeChild(s[r]);for(r=0;r<i.length;r++)if(i[r]==t){i.splice(r,1);break}m.style.display=0==h.getElementsByTagName("div").length?"block":"none"}}),(function(t){b(d),e.handleError(t,null,null,null,mxUtils.htmlEntities(mxResources.get("objectNotFound")))}))}))}),t.isResolved)),s||t.isLocked||0!=l||F(t.isResolved?mxResources.get("reopen"):mxResources.get("resolve"),(function(e){function i(){var i=e.target;i.innerHTML="",t.isResolved=!t.isResolved,mxUtils.write(i,t.isResolved?mxResources.get("reopen"):mxResources.get("resolve"));for(var n=t.isResolved?"none":"",l=T().replies,r=Editor.isDarkMode()?"transparent":t.isResolved?"ghostWhite":"white",s=0;s<l.length;s++){l[s].style.backgroundColor=r;for(var o=l[s].querySelectorAll(".geCommentAction"),a=0;a<o.length;a++)o[a]!=i.parentNode&&(o[a].style.display=n);U||(l[s].style.display="none")}p()}t.isResolved?M(mxResources.get("reOpened")+": ",!0,i,!1,!0):M(mxResources.get("markedAsResolved"),!1,i,!0)})),d.appendChild(R),null!=n?h.insertBefore(d,n.nextSibling):h.appendChild(d);for(var A=0;null!=t.replies&&A<t.replies.length;A++){var I=t.replies[A];I.isResolved=t.isResolved,E(I,t.replies,null,l+1,r)}if(null!=a)if(a.comment.id==t.id){var L=t.content;t.content=a.comment.content,f(t,d,a.saveCallback,a.deleteOnCancel),t.content=L}else null==a.comment.id&&a.comment.pCommentId==t.id&&(h.appendChild(a.div),f(a.comment,a.div,a.saveCallback,a.deleteOnCancel));return d}function F(e,i,n){var l=document.createElement("li");l.className="geCommentAction";var r=document.createElement("a");r.className="geCommentActionLnk",mxUtils.write(r,e),l.appendChild(r),mxEvent.addListener(r,"click",(function(e){i(e,t),e.preventDefault(),mxEvent.consume(e)})),D.appendChild(l),n&&(l.style.display="none")}function T(){var e=[],i=d;return function t(n){if(e.push(i),null!=n.replies)for(var l=0;l<n.replies.length;l++)i=i.nextSibling,t(n.replies[l])}(t),{pdiv:i,replies:e}}function M(i,n,r,s,o){var a=T().pdiv,d=e.newComment(i,e.getCurrentUser());d.pCommentId=t.id,null==t.replies&&(t.replies=[]);var u=E(d,t.replies,a,l+1);function h(){v(u),t.addReply(d,(function(e){d.id=e,t.replies.push(d),y(u),r&&r()}),(function(t){m(),b(u),e.handleError(t,null,null,null,mxUtils.htmlEntities(mxResources.get("objectNotFound")))}),s,o)}function m(){f(d,u,(function(e){h()}),!0)}n?m():h()}}if(c.className="geButton",!s){var w=c.cloneNode();w.innerHTML='<div class="geSprite geSprite-plus" style="display:inline-block;"></div>',w.setAttribute("title",mxResources.get("create")+"..."),mxEvent.addListener(w,"click",(function(t){var i=e.newComment("",e.getCurrentUser()),n=E(i,D,null,0);!function t(){f(i,n,(function(i){v(n),e.addComment(i,(function(e){i.id=e,D.push(i),y(n)}),(function(i){b(n),t(),e.handleError(i,null,null,null,mxUtils.htmlEntities(mxResources.get("objectNotFound")))}))}),!0)}(),t.preventDefault(),mxEvent.consume(t)})),g.appendChild(w)}var C=c.cloneNode();C.innerHTML='<img src="'+IMAGE_PATH+'/check.png" style="width: 16px; padding: 2px;">',C.setAttribute("title",mxResources.get("showResolved"));var U=!1;if(Editor.isDarkMode()&&(C.style.filter="invert(100%)"),mxEvent.addListener(C,"click",(function(e){U=!U,this.className=U?"geButton geCheckedBtn":"geButton",k(),e.preventDefault(),mxEvent.consume(e)})),g.appendChild(C),e.commentsRefreshNeeded()){var S=c.cloneNode();S.innerHTML='<img src="'+IMAGE_PATH+'/update16.png" style="width: 16px; padding: 2px;">',S.setAttribute("title",mxResources.get("refresh")),Editor.isDarkMode()&&(S.style.filter="invert(100%)"),mxEvent.addListener(S,"click",(function(e){k(),e.preventDefault(),mxEvent.consume(e)})),g.appendChild(S)}if(e.commentsSaveNeeded()){var R=c.cloneNode();R.innerHTML='<img src="'+IMAGE_PATH+'/save.png" style="width: 20px; padding: 2px;">',R.setAttribute("title",mxResources.get("save")),Editor.isDarkMode()&&(R.style.filter="invert(100%)"),mxEvent.addListener(R,"click",(function(e){r(),e.preventDefault(),mxEvent.consume(e)})),g.appendChild(R)}d.appendChild(g);var D=[],k=mxUtils.bind(this,(function(){if(this.hasError=!1,null!=a)try{a.div=a.div.cloneNode(!0);var t=a.div.querySelector(".geCommentEditTxtArea"),i=a.div.querySelector(".geCommentEditBtns");a.comment.content=t.value,t.parentNode.removeChild(t),i.parentNode.removeChild(i)}catch(t){e.handleError(t)}h.innerHTML='<div style="padding-top:10px;text-align:center;"><img src="'+IMAGE_PATH+'/spin.gif" valign="middle"> '+mxUtils.htmlEntities(mxResources.get("loading"))+"...</div>",o=e.canReplyToReplies(),e.commentsSupported()?e.getComments((function(e){function t(e){if(null!=e){e.sort((function(e,t){return new Date(e.modifiedDate)-new Date(t.modifiedDate)}));for(var i=0;i<e.length;i++)t(e[i].replies)}}e.sort((function(e,t){return new Date(e.modifiedDate)-new Date(t.modifiedDate)})),h.innerHTML="",h.appendChild(m),m.style.display="block",D=e;for(var i=0;i<D.length;i++)t(D[i].replies),E(D[i],D,null,0,U);null!=a&&null==a.comment.id&&null==a.comment.pCommentId&&(h.appendChild(a.div),f(a.comment,a.div,a.saveCallback,a.deleteOnCancel))}),mxUtils.bind(this,(function(e){h.innerHTML=mxUtils.htmlEntities(mxResources.get("error")+(e&&e.message?": "+e.message:"")),this.hasError=!0}))):h.innerHTML=mxUtils.htmlEntities(mxResources.get("error"))}));k(),this.refreshComments=k;var A=mxUtils.bind(this,(function(){if(this.window.isVisible()){for(var e=h.querySelectorAll(".geCommentDate"),t={},i=0;i<e.length;i++){var n=e[i];t[n.getAttribute("data-commentId")]=n}for(i=0;i<D.length;i++)l(D[i])}function l(e){var i=t[e.id];if(null!=i){x(e,i);for(var n=0;null!=e.replies&&n<e.replies.length;n++)l(e.replies[n])}}}));setInterval(A,6e4),this.refreshCommentsTime=A,this.window=new mxWindow(mxResources.get("comments"),d,t,i,n,l,!0,!0),this.window.minimumSize=new mxRectangle(0,0,300,200),this.window.destroyOnClose=!1,this.window.setMaximizable(!1),this.window.setResizable(!0),this.window.setClosable(!0),this.window.setVisible(!0),this.window.addListener(mxEvent.SHOW,mxUtils.bind(this,(function(){this.window.fit()}))),this.window.setLocation=function(e,t){var i=window.innerWidth||document.body.clientWidth||document.documentElement.clientWidth,n=window.innerHeight||document.body.clientHeight||document.documentElement.clientHeight;e=Math.max(0,Math.min(e,i-this.table.clientWidth)),t=Math.max(0,Math.min(t,n-this.table.clientHeight-48)),this.getX()==e&&this.getY()==t||mxWindow.prototype.setLocation.apply(this,arguments)};var I=mxUtils.bind(this,(function(){var e=this.window.getX(),t=this.window.getY();this.window.setLocation(e,t)}));mxEvent.addListener(window,"resize",I),this.destroy=function(){mxEvent.removeListener(window,"resize",I),this.window.destroy()}},ConfirmDialog=function(e,t,i,n,l,r,s,o,a,d,u){var h=document.createElement("div");if(h.style.textAlign="center",u=null!=u?u:44,(v=document.createElement("div")).style.padding="6px",v.style.overflow="auto",v.style.maxHeight=u+"px",v.style.lineHeight="1.2em",mxUtils.write(v,t),h.appendChild(v),null!=d){var m=document.createElement("div");m.style.padding="6px 0 6px 0";var g=document.createElement("img");g.setAttribute("src",d),m.appendChild(g),h.appendChild(m)}var c=document.createElement("div");c.style.textAlign="center",c.style.whiteSpace="nowrap";var p=document.createElement("input");p.setAttribute("type","checkbox");var f=mxUtils.button(r||mxResources.get("cancel"),(function(){e.hideDialog(),null!=n&&n(p.checked)}));f.className="geBtn",null!=o&&(f.innerHTML=o+"<br>"+f.innerHTML,f.style.paddingBottom="8px",f.style.paddingTop="8px",f.style.height="auto",f.style.width="40%"),e.editor.cancelFirst&&c.appendChild(f);var x=mxUtils.button(l||mxResources.get("ok"),(function(){e.hideDialog(),null!=i&&i(p.checked)}));if(c.appendChild(x),null!=s?(x.innerHTML=s+"<br>"+x.innerHTML+"<br>",x.style.paddingBottom="8px",x.style.paddingTop="8px",x.style.height="auto",x.className="geBtn",x.style.width="40%"):x.className="geBtn gePrimaryBtn",e.editor.cancelFirst||c.appendChild(f),h.appendChild(c),a){var v;c.style.marginTop="10px",(v=document.createElement("p")).style.marginTop="20px",v.style.marginBottom="0px",v.appendChild(p);var b=document.createElement("span");mxUtils.write(b," "+mxResources.get("rememberThisSetting")),v.appendChild(b),h.appendChild(v),mxEvent.addListener(b,"click",(function(e){p.checked=!p.checked,mxEvent.consume(e)}))}else c.style.marginTop="12px";this.init=function(){x.focus()},this.container=h};