/* @license Copyright (C) Exontrol. All rights reserved. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):(t="undefined"!=typeof globalThis?globalThis:t||self,e(t.exontrol||{}))}(this,function(t){"use strict";function e(){}function o(t){return t instanceof Array}function i(t){return t instanceof c.Arr}function n(t){return t instanceof Function}function r(t){return t instanceof ClipboardEvent}function s(t){return t instanceof c.Surface.Element}function h(t){return null!=t}function l(t){return null==t}function a(t,e,o){return l(t)?~~o:c.s2F(t,e)}var u,c=c||window.exontrol,p=c.G,f=c.UR,g=Math.round,y=Math.max,d=Math.min,S="pos",v="imageSize",C="client";c.Def.Surface={},c.Shapes.Surface={},c.Mrg(c,function(){function t(t,e){this.init(t,e)}return t.prototype.init=function(t,e){var o=new c.Surface.SV;if(this.oSV=o,this.oSV.oT=this,this.oVS=new c.ScrollBar,this.oVS.oSV=this.oSV,this.oVS.getWheelChange=function(){return this.oSV.getWheelChange()},this.oVS.getLocked=function(){return this.oSV.getLocked()},o.aSR()){var i=this.oVS.drawP;this.oVS.drawP=function(t,e,n,r){i.call(this,t,e,n,r),o.onDrawPartScroll(this,t,e,n,r)}}if(this.oHS=new c.ScrollBar,this.oHS.oSV=this.oSV,this.oHS.getWheelChange=function(){return this.oSV.getWheelChange()},this.oHS.getLocked=function(){return this.oSV.getLocked()},o.aSR()){var n=this.oHS.drawP;this.oHS.drawP=function(t,e,i,r){n.call(this,t,e,i,r),o.onDrawPartScroll(this,t,e,i,r)}}this.Listeners=this.oLts=this.oSV.oLts,this.oCW=new c.CW(t,{AllowXChg:0,ScrollBars:c.Def.Surface.scrollBars}),this.oCW.oT=this,this.Shortcuts=this.oCW.oSts,f&&(this.oUR=new f.M({oC:this,cU:u.Update,onUR:this.onundoredo}),this.oUR.oT=this,this.oUR.gUR=function(t){return function(){return!this.oT.isReadOnly()&&t.apply(this,arguments)||null}}(this.oUR.gUR),this.Shortcuts.Add("CTRL + Z",this.Undo,this,"undoes the last action or a sequence of actions"),this.Shortcuts.Add("CTRL + Y",this.Redo,this,"redoes the last action that was undone (reverses the Undo method)")),this.initCW(),this.exports(),this.SetOptions(e,!0),c.DPR.Reg(this),this.Refresh()},t.prototype.on=function(t,e,o){},t.prototype.off=function(t,e,o){},c.Lts.Onf(t.prototype),t.version="4.0",t.type="Surface",t.LinkControlPointEnum={exNoControlPoint:0,exStartControlPoint:1,exEndControlPoint:2,exControlPoint:4,exMiddleControlPoint:8,exOrthoArrange:16,exAllowChangeFrom:32,exAllowChangeTo:64},t.CoordEnum={exDefCoord:0,exCartesian:1,exAllowPositiveOnly:16},t.SingleSelEnum={exDisableSel:0,exEnableSel:1,exSingleSel:2,exToggleSel:4,exDisableCtrlSel:8,exDisableShiftSel:16,exDisableDrag:32},t.Options={allowUndoRedo:null,undoRedoQueueLength:null,scrollBars:null,scrollBarsHome:void 0,scrollBarsLayout:void 0,tfi:null,locked:null,readOnly:null,wheelChange:null,smooth:null,margins:null,shapes:null,cursors:null,singleSel:null,zoom:null,zoomLevels:null,formatText:null,pad:null,imageSize:null,imageAlign:null,showLinks:null,showLinksOnCollapse:null,collapsedLink:null,link:null,linkStartFrom:null,linkEndTo:null,linkUnselected:null,allowActions:null,expandGlyphSize:null,allowChangeParent:null,selements:null,slinks:null,defArrange:{dir:0,dx:36,dy:36,align:1,compact:!0},allowLinkControlPoint:null,coord:null,showOrigin:null,origin:{size:null,width:null,color:null,style:null,cap:null},showGridLines:null,minorGridLines:{step:null,width:null,color:null,style:null,cap:null},majorGridLines:{step:null,width:null,color:null,style:null,cap:null},showAxes:null,axes:{width:null,color:null,style:null,cap:null},alignObjectsToGridLines:null,selection:null,allowUndoRedo:null,undoRedoQueueLength:null,focusLink:null},f&&(t.blockUR=function(t){return function(){var e=this,o=arguments;(this.oSV||this).blockUR(function(){t.apply(e,o)})}}),t.ElementOptions={visible:!0,enabled:!0,selectable:!0,key:null,caption:null,formatText:null,pad:null,image:null,imageSize:void 0,imageAlign:null,shape:null,cursor:null,client:null,parent:null,expand:null,position:null,autoSize:null,resizable:null,movable:null},t.LinkOptions={visible:!0,key:null,caption:null,captionAlign:null,captionFormat:null,from:null,to:null,link:null,collapsedLink:null,allowControlPoint:null,customPath:void 0},t.prototype.initCW=function(){var t=this.oCW,e=(t=t.Add("control",{Dock:5})).Add("vertical",{Dock:4,Resizable:!1,Size:16,VisibleExtends:"vscroll,control",Opacity:0,HoverOpacity:1});e.Add("grip",{Dock:2,Size:16,SizeExtends:"grip,hscroll",VisibleExtends:"hscroll",AllowXChg:!1,Resizable:!1}),e.Add("vscroll",{Dock:5,AllowXChg:!1,Control:this.oVS}),t.Add("hscroll",{Dock:2,Resizable:!1,VisibleExtends:"control",Control:this.oHS,Opacity:0,HoverOpacity:1}),t.Add("main",{Dock:5,HoverExtends:"vertical,vscroll,hscroll,grip",Extends:"vertical,hscroll",Control:this.oSV,HScroll:"hscroll",VScroll:"vscroll"})},t.prototype.exports=function(){var e=this.oCW;e&&(["GetCanvas","SetCanvas","SetClientRect","GetClientRect","p2W","W","gPtr","inv"].forEach(function(t){t in this||(this[t]=e[t].bind(e))},this),this.GetScrollBars=e.GetSBs.bind(e),this.SetScrollBars=e.SetSBs.bind(e));var o=this.oSV;if(o){["SetOptions","GetOptions","opt","bU","eU","onRL","Refresh","Smooth","Smoothless","Home","FitToClient","EnsureVisibleClient","Soom","GetSelection","SetSelection","SelectAll","UnselectAll","RemoveSelection","EnsureVisibleSelection","getSelCount","GetElements","GetLinks","Clear","Arrange","e2V","isReadOnly","Cut","Copy","Paste"].forEach(function(t){t in this||(this[t]=o[t].bind(o))},this);var i=o.W();i&&["GetScroll","SetScroll","GetSI","SetSI","toEVP","toEVR","SSw"].forEach(function(t){t in o||(o[t]=i[t].bind(i))}),c.expO(t.Options,this,o)}},t.prototype.defAA=function(){return"fit(Shift+MButton,Ctrl+MButton,Alt+MButton),zoom(MButton),select(Shift,Ctrl),link(Alt)[toggle],create(Alt),move,scroll"},t.prototype.roAA=function(){return"scroll,zoom,fit,select,drag-drop"},t.prototype.lRA=function(t){this.oCW.lRA(t)},Object.defineProperty(t.prototype,"Elements",{get:function(){return this.GetElements()}}),Object.defineProperty(t.prototype,"Links",{get:function(){return this.GetLinks()}}),Object.defineProperty(t.prototype,"Selection",{get:function(){return this.GetSelection()},set:function(t){this.SetSelection(t)}}),t.prototype.GetLayout=function(t){return c.Lay.Save(this.onlayout,this,t)},t.prototype.SetLayout=function(t,e){c.Lay.Load(t,this.onlayout,this,e)},t.prototype.onlayout=function(t){this.oCW.onlayout(t)},t.prototype.GetStatistics=function(){function t(t,e){return c.Format(t,e||0)}var e="",o=c.C2R(this.GetClientRect()),i=this.oSV;return e+="Size: "+t(o[2])+"x"+t(o[3]),e+="\nZoom: "+t(i.getZoom())+"%",e+="\nElement: "+t(function(){var t=0;return i.getVO().forEach(function(e,o){s(o)&&t++}),t}())+"/"+t(i.oSE.GetCount()),e+="\nLink: "+t(i.getVL().len())+"/"+t(i.oSL.GetCount()),e+="\nSel: "+t(i.getSelCount())},Object.defineProperty(t.prototype,"Options",{get:function(){return this.GetOptions()},set:function(t){this.SetOptions(t)},configurable:!0}),u=c.Def.UR.Surface={Update:"Smooth",AddElement:"AddElement",RemoveElement:"RemoveElement",MoveElement:"MoveElement",UpdateElement:"UpdateElement",AddLink:"AddLink",RemoveLink:"RemoveLink",UpdateLink:"UpdateLink"},t.prototype.gUR=function(){return this.oUR&&this.oUR.gUR()},t.prototype.onundoredo=function(t){this.oSV.onChange("undo-redo",t)},t.prototype.GetAllowUndoRedo=e,t.prototype.SetAllowUndoRedo=e,t.prototype.GetUndoRedoQueueLength=e,t.prototype.SetUndoRedoQueueLength=e,t.prototype.CanUndo=e,t.prototype.CanRedo=e,t.prototype.StartBlockUndoRedo=e,t.prototype.EndBlockUndoRedo=e,t.prototype.BlockUndoRedo=function(t,e){n(t)&&(this.StartBlockUndoRedo(),t.call(e||this),this.EndBlockUndoRedo())},t.prototype.Undo=e,t.prototype.Redo=e,t.prototype.UndoListAction=function(t,e){},t.prototype.RedoListAction=function(t,e){},t.prototype.UndoRemoveAction=function(t,e){},t.prototype.RedoRemoveAction=function(t,e){},t.prototype.GroupUndoRedoActions=function(t){},t.prototype.BeginUpdate=function(){this.bU()},t.prototype.EndUpdate=function(){this.eU()},t.prototype.Update=function(t,e){this.bU(),t&&t.call(e||this),this.eU()},t.prototype.Element=function(t){return this.oSV.oSE.Item(t)},t.prototype.Link=function(t){return this.oSV.oSL.Item(t)},t.prototype.feE=function(t,e){return this.oSV.oSE.forEach(t,e||this)},t.prototype.feEU=function(t,e){return this.oSV.oSE.forEachU(t,e||this)},t.prototype.feL=function(t,e){return this.oSV.oSL.forEach(t,e||this)},t.prototype.feLU=function(t,e){return this.oSV.oSL.forEachU(t,e||this)},c.ComboBox&&(t.prototype.dCBl=function(t,e,o){var i=this.oSV,n=i.getSel(),r=n&&n.first();i.drawCS(t,e,i.getSelCount(),36),o.oO.label=r&&o.label(r.getImage(),r.getCaption())||""},t.prototype.cCB=function(e){var o=this.e2V(e);return!o||o instanceof t.SV},t.prototype.sCB=function(t){return t&&this.SetSelection(null),this.getSelCount()},c.CW.prototype.SetCanvas=function(t,e){return c.ComboBox.implExHost(t,"onselchange")}(c.CW.prototype.SetCanvas)),c.expO({Layout:null,Statistics:null},t.prototype),{Surface:t}}()),c.Mrg(c.Surface,function(){function t(t){this.init(t)}function g(t,e){this.init(t,e)}function O(t){this.init(t)}function m(t,e){this.init(t,e)}function L(){this.mIO=new Map}function A(t,e){this.init(t,e)}function E(t){this.Elements=new c.Arr,this.Out=new Map,this.In=new Map,this.Build(t)}function R(){this.Group=null,this.In=new c.Arr,this.InAll=new c.Arr,this.Out=new c.Arr,this.OutAll=new c.Arr}function w(){this.rgGroups=[],this.rgCache=new Map}function b(t){var e=new c.Arr;Object.getOwnPropertyNames(e).forEach(function(t){this[t]=e[t]},this),this.oArrangement=t,this.nAdding=0}function U(t,e,o){this.Elements=new c.Arr,this.Start=e||0,this.End=o||0,h(t)&&this.Elements.add(t)}function G(){var t=new c.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function k(){var t=new c.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function P(t,e){this.oSurfaceElementsArrange=t,this.Origin=e,this.Elements=new c.Arr,this.Groups=new w,this.Size=new Map,this.Input=new b(this),this.Loc=new k,this.spArrangeDX=null,this.spArrangeDY=null,this.nlipa=0,["getArrangeDir","getArrangeDX","getArrangeDY","getArrangeAlign","getArrangeCompact"].forEach(function(e){this[e]=t[e].bind(t)},this)}function x(t){this.oSurfaceElementsArrange=t,this.Links=new E(this.oSurfaceElementsArrange.oSL),this.rgElementCache=new Map,this.rgArrangementCache=[]}function I(t,e,o){this.oSE=t,this.oSL=e,this.oDefArrange=c.Mrg(c.Def.Surface.defArrange,o),this.Cache=new x(this)}return t.prototype.init=function(t){this.oSV=t,this.mK2I=null,this.rgE=new c.Arr,this.rgE.onRemove=t.onDelElement.bind(t),["bU","eU"].forEach(function(e){this[e]=t[e].bind(t)},this),["forEach","forEachU","add","indexOf","getPos","setPos"].forEach(function(t){this[t]=this.rgE[t].bind(this.rgE)},this)},t.prototype.onRL=function(){this.oSV.onRL()},t.prototype.resK2I=function(){this.mK2I=null},t.prototype.Add=function(t){this.bU(),this.resK2I();var e=new c.Surface.Element(this,t);return this.oSV.onAddElement(e),this.eU(),e},t.prototype.Create=function(t){var e=null,o={client:t};return this.OnCreate&&!this.OnCreate(o)&&(e=this.Add(o)),e},t.prototype.OnCreate=function(t){},t.prototype.GetCount=function(){return this.rgE.len()},t.prototype.Item=function(t){var e=null;return~~t===t?e=this.rgE.at(t)||null:s(t)?e=this.rgE.has(t)?t:null:l(e=function(t){var e=t.mK2I;return l(e)&&(t.mK2I=e=new Map,t.forEach(function(t){var o=t.getKey();!e.has(o)&&e.set(o,t)})),e}(this).get(t))&&(e=this.rgE.at(t)||null),e},t.prototype.Remove=function(t){this.RemoveRange(this.Item(t))},t.prototype.RemoveRange=function(t){this.bU(),this.resK2I(),(t=this.dscn(t)).forEach(function(t){var e=t.ownCol(!1);e&&(e.remove(t),t.resOwnCol())}),this.rgE.removeRange(t.reverse()),this.eU()},t.prototype.Clear=function(){this.bU(),this.oSV.oSL.Clear(),this.oSV.rgSel=null,this.resK2I(),this.xE(),this.oSV.uSR(null),this.eU()},t.prototype.xE=function(){this.rgE.clear()},t.prototype.dscn=function(t){var e,n=c.Arr.empty;if(t&&(e=t,s(t)?e=[t]:i(t)&&(e=t.rgE),o(e))){n=new c.Arr,e.forEach(function(t){n.ann(this.Item(t))},this);for(var r=0;r1&&t!=e-1&&this.SetPosition(e-1),t},g.prototype.BringForward=function(){var t=this.GetPosition(),e=this.oSE.GetCount();return e>1&&t+11&&t>0&&this.SetPosition(0),t},g.prototype.SendBackward=function(){var t=this.GetPosition();return this.oSE.GetCount()>1&&t>0&&this.SetPosition(t-1),t},g.prototype.GetKey=function(){return this.oO.key},g.prototype.SetKey=function(t){this.bU(),this.oSE.resK2I(),this.oO.key=t,this.eU()},g.prototype.getKey=function(){var t=this.GetKey();return(t=h(t)?t.toString():"")||this.getPlainCaption()},g.prototype.GetVisible=function(){return this.oO.visible},g.prototype.SetVisible=function(t){this.bU(),this.oO.visible=t,this.eU(!0)},g.prototype.getVisible=function(){return l(this.GetVisible())||this.GetVisible()},g.prototype.isVisible=function(){return this.GetVisible()||l(this.GetVisible())},g.prototype.GetEnabled=function(){return this.oO.enabled},g.prototype.SetEnabled=function(t){this.bU(),this.oO.enabled=t,this.eU()},g.prototype.getEnabled=function(){return l(this.GetEnabled())||this.GetEnabled()},g.prototype.isEnabled=function(){return!!this.getEnabled()&&(!this.oP||this.oP.isEnabled())},g.prototype.GetSelectable=function(){return this.oO.selectable},g.prototype.SetSelectable=function(t){this.bU(),this.oO.selectable=t,this.eU()},g.prototype.getSelectable=function(){return l(this.GetSelectable())||this.GetSelectable()},g.prototype.isSelectable=function(){return this.getSelectable()},g.prototype.GetCaption=function(){return this.oO.caption},g.prototype.SetCaption=function(t){this.bU(),this.oSE.resK2I(),this.oO.caption=t,this.eU(!0)},g.prototype.getCaption=function(){return this.GetCaption()},g.prototype.getPlainCaption=function(){return c.H.TextNoHTML(this.getCaption())},g.prototype.GetFormatText=function(){return this.oO.formatText},g.prototype.SetFormatText=function(t){this.bU(),this.oO.formatText=t,this.eU()},g.prototype.getFormatText=function(){var t=this.GetFormatText();return h(t)?~~t:this.getView().getFormatText()},g.prototype.GetPad=function(){return this.oO.pad},g.prototype.SetPad=function(t){this.bU(),this.oO.pad=t,this.eU()},g.prototype.getPad=function(){var t=this.GetPad();return h(t)?c.pad2A(t):this.getView().getPad()},g.prototype.GetImage=function(){return this.oO.image},g.prototype.SetImage=function(t){this.bU(),this.oO.image=t,this.eU(!0)},g.prototype.getImage=function(){var t=this.GetImage();return h(t)?t.toString():""},g.prototype.GetImageSize=function(){return this.oO.imageSize},g.prototype.SetImageSize=function(t){this.bU(),this.oO.imageSize=t,this.eU(!0)},g.prototype.getImageSize=function(){var t=this.GetImageSize();return void 0!==t?t:this.getView().getImageSize()},g.prototype.GetImageAlign=function(){return this.oO.imageAlign},g.prototype.SetImageAlign=function(t){this.bU(),this.oO.imageAlign=t,this.eU(!0)},g.prototype.getImageAlign=function(){var t=this.GetImageAlign();return h(t)?c.ToI(t,2):this.getView().getImageAlign()},g.prototype.gCnt=function(t,e){var o=this.getPad(),i=c.HP.Measure(this.getImage(),this.getImageSize(),t),n=c.PRt(e.slice(),o,-1),r=null;if(h(i))switch(this.getImageAlign()){case 3:(r=n.slice())[1]=c.BOf(n)-i.height,r[3]=i.height,r[0]+=(r[2]-i.width)/2,r[2]=i.width,n[3]-=i.height+o[1];break;case 2:(r=n.slice())[3]=i.height,r[0]+=(r[2]-i.width)/2,r[2]=i.width,n[1]+=i.height+o[1],n[3]-=i.height+o[1];break;case 1:(r=n.slice())[0]=c.ROf(n)-i.width,r[2]=i.width,r[1]+=(r[3]-i.height)/2,r[3]=i.height,n[2]-=i.width+o[0];break;default:(r=n.slice())[2]=i.width,r[1]+=(r[3]-i.height)/2,r[3]=i.height,n[0]+=i.width+o[0],n[2]-=i.width+o[0]}return{rtCaption:n,rtImage:r}},g.prototype.draw=function(t,e,o){var i,n=!this.isEnabled();n&&c.H.lA++,t.selClip(e),i=this.gCnt(t,e),t.drawHTMLPicture(this.getImage(),i.rtImage,this.getImageSize()),t.drawHTMLText(this.getCaption(),i.rtCaption,o&&o.formatText||this.getFormatText(),o&&o.tfi&&c.ToTFI(o.tfi)),t.resClip(),n&&--c.H.lA},g.prototype.GetShape=function(){return this.oO.shape},g.prototype.SetShape=function(t){this.bU(),this.oO.shape=t,this.eU(!0)},g.prototype.GetCursor=function(){return this.oO.cursor},g.prototype.SetCursor=function(t){this.bU(),this.oO.cursor=t,this.eU()},g.prototype.GetClient=function(){return this.oO.client},g.prototype.SetClient=function(t){this.bU(),this.oO.client=t,this.eU(!0)},g.prototype.getContentSize=function(t){var e={width:0,height:0},o=this.getPad(),i=this.getView().toShape(this),n=c.H.Measure(t,this.getCaption(),null,this.getFormatText(),i.tfi&&c.ToTFI(i.tfi)),r=c.HP.Measure(this.getImage(),this.getImageSize(),t);return h(n)&&(e.width+=n.width+1,e.height+=n.height+1),h(r)&&(this.getImageAlign()>=2?(e.width=y(e.width,r.width),e.height&&(e.height+=o[1]),e.height+=r.height):(e.height=y(e.height,r.height),e.width&&(e.width+=o[0]),e.width+=r.width)),e.width+=o[0]<<1,e.height+=o[1]<<1,e},g.prototype.getClient=function(){var t,e=c.C2R(this.GetClient()||32);return this.getAutoSize()&&(t=this.getView().gAS(this),e[2]=t.width,e[3]=t.height),e},g.prototype.GetParent=function(){return this.oP},g.prototype.SetParent=function(t){if(t!=this.oP){this.oO.parent=t;var e=this.hasOptsP();if(e!=this.oP){this.bU();var o=this.ownCol(!1);h(o)&&(o.remove(this),this.resOwnCol()),(this.oP=e)&&this.ownCol(!0).add(this),this.eU(!0)}}},g.prototype.canParent=function(t){return!(t==this.oP||t&&t.isChildOf(this))},g.prototype.isChildOf=function(t){for(var e=this;e&&e!=t;)e=e.oP;return e==t},g.prototype.hasOptsP=function(){var t=null,e=this.oO.parent;return e&&(e=this.oSE.Item(e))&&this.canParent(e)&&(t=e),t},g.prototype.ownCol=function(t){var e=null;return this.oP&&(e=this.oP.rgC,t&&!e&&(this.oP.rgC=e=new c.Arr)),e},g.prototype.resOwnCol=function(){h(this.oP)&&h(this.oP.rgC)&&0==this.oP.rgC.len()&&(this.oP.rgC=null)},g.prototype.dscn=function(){return this.oSE.dscn(this)},g.prototype.GetExpand=function(){return this.oO.expand},g.prototype.SetExpand=function(t){t!=this.isExpanded()&&(this.bU(),this.oO.expand=t,this.eU(!0))},g.prototype.isExpanded=function(){return!(!l(this.GetExpand())&&!this.GetExpand())},g.prototype.ToggleExpand=function(){this.SetExpand(!this.isExpanded())},g.prototype.GetAutoSize=function(){return this.oO.autoSize},g.prototype.SetAutoSize=function(t){this.bU(),this.oO.autoSize=t,this.eU(!0)},g.prototype.getAutoSize=function(){return this.GetAutoSize()},g.prototype.GetResizable=function(){return this.oO.resizable},g.prototype.SetResizable=function(t){this.bU(),this.oO.resizable=t,this.eU(!0)},g.prototype.getResizable=function(){return!(!l(this.GetResizable())&&!this.GetResizable())},g.prototype.isResizable=function(){return this.getResizable()&&!this.getAutoSize()},g.prototype.GetMovable=function(){return this.oO.movable},g.prototype.SetMovable=function(t){this.bU(),this.oO.movable=t,this.eU(!0)},g.prototype.getMovable=function(){return!(!l(this.GetMovable())&&!this.GetMovable())},g.prototype.isMovable=function(){return this.getMovable()},g.prototype.hasVisibleChild=function(){var t=null;return this.rgC&&this.rgC.forEachU(function(e){return e.getVisible()&&(t=e),t}),t},g.prototype.getVisibleChild=function(){var t;return this.rgC&&this.isExpanded()&&this.rgC.forEach(function(e){e.getVisible()&&(t=t||[]).push(e)}),t},g.prototype.hasChild=function(){return this.rgC&&this.rgC.len()},g.prototype.getRoot=function(){for(var t=this;t.oP;)t=t.oP;return t},g.prototype.getLevel=function(){for(var t=0,e=this;e=e.oP;)t++;return t},g.prototype.getCollapsedParent=function(){for(var t=null,e=this;e.oP;)(e=e.oP).isExpanded()||(t=e);return t||this},g.prototype.getExpandGlyph=function(){return this.eG=this.eG||{expand:this}},g.prototype.IsArrangeGroup=function(){var t;return(this.oP||this.rgC)&&(t=this.getRoot().dscn()),t},g.prototype.isVisibleEx=function(){return this.isVisible()&&(!this.oP||this.oP.isExpanded()&&this.oP.isVisibleEx())},g.prototype.ArrangeLoc=function(){var t=[0,0,0,0];return this.isVisibleEx()&&(t=this.getClient()),t},g.prototype.ArrangeSize=function(){var t=this.ArrangeLoc();return{cx:t[2],cy:t[3]}},g.prototype.ArrangeTo=function(t){var e=this.getClient(),o=e.slice();e[0]=p.X(t),e[1]=p.Y(t),this.SetClient(e),this.getView().onMoveElement(this,o)},g.prototype.toString=function(){return this.getKey()||this.oSE.indexOf(this)},g.prototype.EnsureVisible=function(){for(var t=this;t=t.oP;)t.SetExpand(!0);this.getView().EnsureVisibleClient(this)},g.prototype.genID=function(){var t=this.GetKey();return l(t)&&this.SetKey(t=function(){var t=this.oSE,e=this.getKey();return e&&t.Item(e)==this||(e=t.nextID()),e}.call(this)),t},g.prototype.coO=function(){var t=c.Cpy(this.oO);return t[C]=this.getClient(),t.position=this.GetPosition(),s(t.parent)&&(t.parent=t.parent.genID()),t},f&&(g.prototype.scUR=function(t){t.o=this.oSE,t.i=this.genID()},g.prototype.arUR=function(t){this.scUR(t),t.d=this.coO(),t.Do=function(t){if(this.del?!t:t)this.o.Remove(this.i);else{var e=this.o.Add(this.d);e&&e.EnsureVisible()}}},g.prototype.mvUR=function(t,e){e&&(this.scUR(t,!0),t.d={from:c.C2R(e),to:this.getClient()},t.Do=function(t){var e=this.o.Item(this.i);e&&(e.SetClient(t?this.d.from:this.d.to),e.EnsureVisible())})},g.prototype.uUR=function(t,e,o){this.scUR(t,!0),(t.d=f.diff(e,o))&&("position"in e&&!("position"in t.d.from)&&(t.d.from.position=e.position),"position"in o&&!("position"in t.d.to)&&(t.d.to.position=o.position),t.Do=function(t){var e=this.o.Item(this.i);e&&(e.SetOptions(t?this.d.from:this.d.to),e.EnsureVisible())})},g.prototype.StartUpdateElement=function(){return this.getView().gUR()&&this.coO()},g.prototype.suo=g.prototype.StartUpdateElement,g.prototype.EndUpdateElement=function(t){t&&this.getView().nUR(u.UpdateElement,function(e){this.uUR(e,t,this.coO())},this)},g.prototype.euo=g.prototype.EndUpdateElement,g.prototype.UpdateElement=function(t,e){if(n(t)){var o=this.StartUpdateElement();t.call(e||this),this.EndUpdateElement(o)}}),O.prototype.init=function(t){this.oSV=t,this.rgL=new c.Arr,this.rgL.onRemove=this.onDelLink.bind(this),this.import()},O.prototype.import=function(){var t=this.oSV;["bU","eU"].forEach(function(e){this[e]=t[e].bind(t)},this),["forEach","forEachU","add","indexOf"].forEach(function(t){this[t]=this.rgL[t].bind(this.rgL)},this)},O.prototype.onRL=function(){this.oSV.onRL()},O.prototype.resK2I=function(){this.mK2I=null},O.prototype.onDelElement=function(t){this.oIOL&&this.RemoveRange(this.oIOL.linksOf(t))},O.prototype.onAddLink=function(t){(this.oIOL=this.oIOL||new L).add(t),this.oSV.onAddLink(t)},O.prototype.onDelLink=function(t){this.oFL=null,this.oIOL&&this.oIOL.remove(t),this.oSV.onDelLink(t)},O.prototype.toE=function(t){return this.oSV.oSE.Item(t)},O.prototype.allowLink=function(t,e){return!(!(t=this.toE(t))||!(e=this.toE(e)))&&((!this.oIOL||this.oIOL.can(t,e))&&this.oSV.onAllowLink(t,e))},O.prototype.Add=function(t){var e=null;return t&&this.allowLink(t.from,t.to)&&(this.bU(),this.resK2I(),e=new c.Surface.Link(this,t),this.onAddLink(e),this.eU()),e},O.prototype.Create=function(t,e){var o,i=null;return this.allowLink(t,e)&&(o={from:t,to:e},this.OnCreate&&!this.OnCreate(o)&&(i=this.Add(o))),i},O.prototype.OnCreate=function(t){},O.prototype.GetCount=function(){return this.rgL.len()},O.prototype.Item=function(t){var e=null;return~~t===t?e=this.rgL.at(t)||null:!function(t){return t instanceof c.Surface.Link}(t)?(e=function(t){var e=t.mK2I;return l(e)&&(t.mK2I=e=new Map,t.forEach(function(t){var o=t.getKey();!e.has(o)&&e.set(o,t)})),e}(this).get(t))||(e=this.rgL.at(t)||null):e=this.rgL.has(t)?t:null,e},O.prototype.Remove=function(t){var e=this.Item(t);e&&(this.bU(),this.resK2I(),this.rgL.remove(e),this.eU())},O.prototype.RemoveRange=function(t){this.bU(),this.resK2I(),this.rgL.removeRange(t),this.eU()},O.prototype.Clear=function(){this.bU(),this.oIOL=null,this.resK2I(),this.rgL.clear(),this.eU()},O.prototype.linksOf=function(t){return this.oIOL?this.oIOL.linksOf(t):c.Arr.empty},O.prototype.linkOf=function(t,e){return this.oIOL&&this.oIOL.get(t,e)||null},O.prototype.Load=function(t){var e=this;this.bU(),this.Clear(),c.B.split(t).forEach(function(t){!function(t,o){var i,n,r,s;o&&(i=o.get("link"))&&(n=i.split("-")).length>1&&(r={caption:t,from:n[0],to:n[1]},c.Surface.Link.F.f2o(o,function(t,e,o){c.Surface.Link.F.isF(o)&&(r[t]=e)}),c.Surface.Link.FLink.f2o(o,function(t,e,o){var i=o.sWith(c.Surface.Link.FCollapsedLink);if(i&&(o=o.substr(c.Surface.Link.FCollapsedLink.length),t=c.F.l1st(c.Surface.Link.FLink.toN(o))),c.Surface.Link.FLink.isF(o)){var n=i?"collapsedLink":"link";(r[n]=r[n]||{})[t]=e}}),s=e.Add(r),o.has("focus")&&(e.oFL=s))}(t.caption,t.flags)}),this.eU()},O.prototype.Save=function(){function t(t){var e=t.GetKey();return l(e)&&(e=t.getPlainCaption()),e}var e=[],o=this.oFL;return this.rgL.forEachI(function(i){i.oF&&i.oT&&e.push(function(e){var i=c.B.quoteC(e.getCaption()),n=c.Surface.Link.F.Save(e),r=e.GetLink(),s=e.GetCollapsedLink();if((n=n||new Map).set("link",t(e.oF)+"-"+t(e.oT)),r)for(var h in r)n.set(h,r[h]);if(s)for(var h in s)n.set(c.Surface.Link.FCollapsedLink+h,s[h]);return e==o&&n.set("focus",null),i+=c.B.quoteF(n)}(i))}),c.B.quoteS(e)},O.prototype.nextID=function(t){function e(){for(var t="";this.Item(t=o+ ++this.__nextID););return t}this.__nextID=this.__nextID||0;var o="_l",i=e.call(this);if(h(t)){i=[i],t=y(0,c.ToI(t,1)-1);for(var n=0;ns;o;){o=!1,t=!0;for(var i=0,h=n.length;t&&is,e=!0)}return e}function o(){for(var t,e=!1,o=n.length>s;o;){o=!1,t=!0;for(var i=0,h=n.length;t&&ii;a--)"E"==r.lO(l,n[a])&&(n.splice(i,a-i),o=n.length>s,t=!1,e=!0)}return e}function i(){for(var t,e=!1,o=n.length>s;o;){o=!1,t=!0;for(var i=0,h=n.length;t&&is,e=!0)}}return e}var n,r=c.Surface.SV,s=3;if(t){for((n=t.slice()).splice(0,0,[0,0]),n.push([1,1]);e()||o()||i(););n.splice(0,1),n.splice(n.length-1,1)}return n&&t&&n.length!=t.length?n:t},m.prototype.cp2P=function(t,e,o){var i,n=[];if(t){i=new m.PCONVP(e,o),n.push(e);for(var r=0,s=t.length;r1&&this.isSelected(v)&&(I=this.getSelCount()),c.EyO(L)&&(L=null);function V(t,e,o,i){T=T||i;var n=[this.scaled(o[0]),this.scaled(o[1]),this.scaled(o[2]),this.scaled(o[3])];this.ctxScale(e,[0,0,0,0],function(){L?e.drawShape(n,L.normal||L):v?this.drawE(e,n,v):e.drawFrameRect(n)}),I&&e.drawHTMLText(I,o,c.DrawTextFormatEnum.exTextAlignCenter|c.DrawTextFormatEnum.exTextAlignVCenter)}e.rurEFPaint=V,e.rurEFOpts=function(t,e){e.visible=!1,e.limitClient=!1},e.rurDrag=function(t){T&&T.SetVisible(t.from!=t.to);var i={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y};r.call(this,i,b),t.frame=this.htR(x,i.dx,i.dy,P),!e.rurEFPaint&&V.call(this,t,this.gCtx(),this.rtCA(t.frame,!1)),o(t)},e.rurCancel=function(t){n(!0)},e.rurDrop=function(t){n();var e=r.call(this,{dx:t.to.x-t.from.x,dy:t.to.y-t.from.y},b),o=this.htR(x,e.dx,e.dy,P);if(C)c.EyR(o)||this.onRURChange(this.orurDC=this.onRURCreate(o,f));else if(v){var h=s(v)?i(t):void 0,u="Smoothless";void 0!==h&&w.forEach(function(t){s(t)&&t.oP!=h&&(u="Smooth")}),this[u].call(this,function(){this.bU();var t=null;R&&(t=new c.M1,w.forEach(function(e){t.set(e,e.getClient())})),w.forEach(function(t){(!R||v==t||s(v)&&this.isSelected(t))&&(!E&&s(t)&&(t=t.getRoot()),this.onRURApplyClient(t,this.htR(x,e.dx,e.dy,t.getClient()))),void 0!==h&&(a=a||l.call(this,w)).get(t)&&this.onRURApplyParent(t,h)},this),s(h)&&(h.SetExpand(!0),this.EnsureVisibleOnExpand(v)),R&&this.onRURResize(v,t),this.onRURChange(v,b),this.eU()},this)}}}}else if(m=C||this.rurAllowMove(v,f)){var D=this.Lyt().rgVO,F=this.getExpandGlyphSize(),M=null;e.rurOnlyAO=v,e.rurDragStart=function(t){M=this.p2O,this.p2O=function(t){var e=this.ptCA(t,!0);return D.p2O(p.X(e),this.Lyt().y2C(p.Y(e)),v)}},e.rurDragEnd=function(t){this.p2O=M||this.p2O},e.rurDrag=function(t){function e(t){var e,o,i,n=t,r=b.get(t);if(r){for(;!e&&(n=n.oP);)e=b.get(n);e&&(o=n.getClient(),i=t.getClient(),t.SetClient([o[0]-(e[0]-r[0]),o[1]-(e[1]-r[1]),i[2],i[3]]))}}C&&!b.len()&&(C=!!(v=this.orurDC=this.onRURCreate(p.C2R(this.ptCA(g,!0),0,0),f)))&&(d={o:v,ht:68,new:!0},b.set(v,v.getClient()));var i=this.Lyt(),n={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y},h=function(){},l=this.onRL;this.getAlignObjectsToGridLines()||(e=h),r.call(this,n,b),D=i.rgVO,this.onRL=h,this.bU(),s(v)&&D.setZOrd(v,D.len()),b.forEach(function(t,o){if(!R||v==o||s(v)&&this.isSelected(o)){var r;(function(t,e,o,i,n){e&&t.SetClient(this.htR(e,o,i,n))}).call(this,o,d.ht,n.dx,n.dy,t),o.oP&&e(o),D.set(o,i.r2C(o.getClient())),F>0&&D.get(r=o.getExpandGlyph())&&D.set(r,i.r2C(A.Layout.expandGlyphRect(o.getClient(),F)))}},this),!C&&R&&this.onRURResize(v,b,D),this.resVO(),this.eU(),this.onRL=l,o(t)},e.rurDrop=function(t){n();var e=i(t),o="Smoothless";void 0!==e&&w.forEach(function(t){s(t)&&t.oP!=e&&(o="Smooth")}),this[o].call(this,function(){this.bU(),w.forEach(function(t){this.onRURApplyClient(t,t.getClient()),void 0===e||t!=v&&!this.isSelected(t)||(a=a||l.call(this,w)).get(t)&&(s(t)&&!t.isMovable()||this.onRURApplyParent(t,e))},this),s(e)&&(e.SetExpand(!0),this.EnsureVisibleOnExpand(v)),!C&&R&&this.onRURResize(v,b),this.onRURChange(v,C?null:b),this.eU()},this)},e.rurCancel=function(t){n(!0),this.bU(),b.forEach(function(t,e){this.onRURApplyClient(e,t)},this),C&&v.Remove(),this.eU()}}m&&this.rurDrag(t,e)}},A.prototype.rurDragDrop=function(t,e){var o=this.p2O(this.gPtr(t));this.isSable(o)&&c.RUR.D3(t,{object:o,shape:this.getShape(o),client:this.rtCA(o.GetClient(),!1),source:this,onpaint:function(t,e){this.source.drawE(t,e,this.object)},onclick:function(t){e.rurStatus&&e.rurStatus.call(this,t)},onmove:function(t){t.drag.setCursor(c.GP.Get(e.rurName,this.getCursors()))}})},A.prototype.rurLink=function(t,e){var o=this.gPtr(t),i=this.p2O(o);s(i)&&(e.rurEFPaint=function(t,e,o,n){var r=this.p2O(this.ptCA(t.to,!1)),s=this.oSL.allowLink(i,r),h=t.from.x1){var d,S,v=h.GetCustomPath(),C=new c.Surface.Link.PCONVP(n[0],n[n.length-1]),O=h.rgCP;e.rurDrag=function(t){function e(t){var e=this.ptCA(t,!0),o=this.origin();return C.toPh([p.X(e)+p.X(o),this.Lyt().y2C(p.Y(e))+p.Y(o)])}o.call(this,0),!O&&(O=h.rgCP=h.p2CP(n)),O&&(a?function(){if(!S){function o(t,e){return"V"==A.lO(t,e)?y:d}var n,r,s,h,a,u,f,g,y=new c.Arr,d=new c.Arr,v=[0,0],C=[1,1];"m"==i?(u=~~l.substr(1))>0&&u0&&u=0&&f=0?(a=p.LPR(s,h,.5),O.splice(g,0,a.slice()),O.splice(g,0,a.slice()),r=o(s,h),f?(r.push(f,f+1),f-1>=0&&o(O[f-1],O[f]).push(f-1,f)):(r.push(f+1,f+2),f+30&&o=0&&h0&&(s=y(0,t.drag.current.x-c.ROf(r)));var l=t.drag.current.y-c.TOf(r);l>0&&(l=y(0,t.drag.current.y-c.BOf(r))),(s||l)&&this.rurScrollD(s,l),clearTimeout(R);var p=(this.p2O(t.drag.current)||{}).expand;if(p&&!p.isExpanded()){var d=this;R=setTimeout(function(){d.bU(),p.SetExpand(!0),i(),d.eU()},512)}a.to=this.ptCA(t.drag.current,!0),a.dx=a.to.x-a.from.x,a.dy=a.to.y-a.from.y,i(),h(A)&&A.SetClient(this.rtCA(a.frame,!1));break;case 4:case 5:clearTimeout(R),this.orurOnlyAO=null,o(this),h(m)&&m.call(L,a),m=null,h(C)&&C.call(L,t)}},this,{contiguously:!0,client:r})}},A.prototype.onRURDragStart=function(t,e){switch(this.orurDC=null,t){case"move":case"link":var o=this.p2HT(this.gPtr(e));o&&(this.orurDC=o.o);break;case"link-cp":this.orurDC=this.p2L(this.gPtr(e))}},A.prototype.onRURDragEnd=function(t,e){e.drag.cancel||e.drag.click||this.orurDC&&this.onChange(t,this.orurDC),this.orurDC=null},A.prototype.getChange=function(t,e){return{element:e,action:t}},A.prototype.onChange=function(t,e){this.onchange(this.getChange(t,e))},A.prototype.onchange=function(t){this.oLts.onchange.do(t)},A.prototype.focusPointAbs=function(t){var e=this.ptCA(t,!0),o=this.p2O(t);return h(o)&&(e=p.R2C(this.Lyt().o2R(o))),e},A.prototype.focusRectAbs=function(t){var e=p.Rect(t.from,t.to);if(!c.EyR(e)){var o=this.Lyt(),i=o.r2O(e);i.length&&i.forEach(function(t){e=c.URt(e,o.o2R(t))}),e=o.r2C(e)}return e},A.prototype.onRURCreate=function(t,o){var i,n=this.onAddElement;return this.onAddElement=e,i=this.oSE.Create(t),this.onAddElement=n,i},A.prototype.rurAllowMove=function(t,e){return s(t)},A.prototype.allowRur=function(t,e){return h(t)},A.prototype.rurAction=function(t,e,o){var i=this.gPtr(o),n={rurName:t,rurFlags:e,rurOnlyAO:this.p2O(i)||{},rurStatus:function(e){this.rurActionClick(t,e)}};if(this.allowRur(o,n)){var r="rur"+c.getP(function(t){for(var e,o="",i=0,n=t.length;i=0&&(n=h.gCP())&&r<=n.length&&(i=r?r==n.length?A.lO(n[n.length-1],[1,1]):A.lO(n[r-1],n[r]):A.lO([0,0],n[0]))&&(o+="-"+i.toLowerCase()))),o},A.prototype.p2O=function(t){return this.Lyt().p2O(this.ptCA(t,!0),0,0,this.getVO())||null},A.prototype.r2O=function(t){return this.Lyt().r2O(this.rtCA(t,!0))},A.prototype.p2A=function(t){return t=this.p2V(t),c.H.P2A(this,p.X(t),p.Y(t))},A.prototype.onSetAO=function(t){function e(e){var o=i.getShape(e);o&&(!c.EyO(o.hover)&&t.set({owner:i,id:e.idAOH||(e.idAOH={}),object:e,inv:i.inv,hitTest:function(t,o,n){return r?r===e:n.object==i.p2O([t,o])&&i.isAP(t,o)},duration:n}),!c.EyO(o.click)&&t.set({owner:i,id:e.idAOC||(e.idAOC={}),object:e,inv:i.inv,hitTest:function(t,o,n){return r?r===e:n.object==i.p2O([t,o])&&i.isAP(t,o)},actOn:r==e?1:4,duration:n}))}var o=null;if(this.isSelectable()&&!t.hasOf(this)&&(o=this.getVO())){var i=this,n=i.getSmooth(),r=i.orurOnlyAO;s(r)?e(r,o.indexOf(r)):(o.forEach(function(t,o){e(o)},this),this.onExtAO(t,o))}},A.prototype.onExtAO=function(t,e){},A.prototype.onimg=function(){this.Refresh()},A.prototype.onRL=function(){this.resVO(),this.oLyt=null},A.prototype.resVO=function(){this.rgVO=null,this.rgVL=null,this.mAS=null,this.resAO()},A.prototype.bU=function(){this.lI++},A.prototype.eU=function(){if(!--this.lI){var t=this.gCW();!t||this.oLyt?this.invAO():(this.resAO(),t.Render())}},A.prototype.beU=function(){this.bU(),this.eU()},A.prototype.Refresh=function(){this.bU(),this.onRL(),this.eU()},A.prototype.islow=function(){return this.getScale()<.5},A.prototype.Smooth=function(t,e){if(n(t))if(this.getSmooth()){var o=this.getSmooth(),i=null,r=null;if(o>0&&(c.A.Cancel(this.sSA),i=this.getVO(),r=this.Lyt(),this.bU()),h(this.rgVO)&&this.rgVO.clean(),t.call(e||this),o>0){var s=this.uSR;this.uSR(),this.uSR=function(){},this.rgVO=i,this.oLyt=r,this.eU(),this.oLyt=null,this.rgVO=null,this.uSR=s;var l=this.origin(),a=this.getVO(),u=this.Lyt();new c.Arr(i.diff(a)).rforEach(function(t){var e=i.get(t),o=a.get(t),n=t.expand||t;if((!e||!o)&&n.oP&&n.oSE.Item(n)){var s=n.oP;if(!e){for(;s&&!(e=i.get(s.getExpandGlyph()));)s=s.oP;e&&i.push(t,p.C2R(p.R2C(e)))}if(!o){for(;s&&!(o=a.get(s.getExpandGlyph()));)s=s.oP;o&&a.push(t,p.C2R(p.R2C(o)))}}!e&&i.push(t,r.o2R(t,l)||p.C2R(p.R2C(o))),!o&&a.push(t,u.o2R(t,l)||p.C2R(p.R2C(e)))}),this.rgVL=null,(this.rgVO=i).morph(a,{inv:this.invAO,refresh:this.Refresh,thisArg:this,name:this.sSA,onXDoL:!1,duration:o})}}else c.A.Cancel(this.sSA),t.call(e||this)},A.prototype.Smoothless=function(t,e){n(t)&&t.call(e||this)},A.prototype.Lyt=function(){if(!this.oLyt){var t,e=this.gCtx();e&&(t=c.TFI.bCTX(e,this.getTfi())),this.oLyt=this.newLyt(),e&&c.TFI.eCTX(e,t)}return this.oLyt},A.prototype.newLyt=function(){return new A.Layout(this)},A.prototype.getVO=function(){return this.rgVO||(this.rgVO=this.Lyt().scroll(this.GetScrollRect(),this.origin()))},A.prototype.getVL=function(){if(l(this.rgVL)){var t=this.getVO(),e=this.Lyt(),o=this.origin(),i=this.GetScrollRect(),n=new c.Arr;this.getShowLinks()&&(c.ORt(i,-i[0],-i[1]),this.oSL.forEach(function(r){if(r.getVisible()){var s=this.ftL(r),h=t.get(s.oF)||e.o2R(s.oF,o),l=t.get(s.oT)||e.o2R(s.oT,o);h&&l&&c.NRt(i,c.URt(h,l))&&n.push(r)}},this)),this.rgVL=n}return this.rgVL},A.prototype.rOrg=function(){var t=[0,0];return this.aPO()?this.isC()&&(t=[0,1]):this.aSR()&&(t=[.5,.5]),t},A.prototype.origin=function(t){t=t||this.GetScroll();var e=this.getBorder();return[-(this.sR[0]+t.x)+e,-(this.sR[1]+t.y)+e]},A.prototype.ptCA=function(t,e){var o={x:p.X(t),y:p.Y(t)},i=this.GetScroll(),n=this.GetInsideRect(!0),r=this.sR;return l(e)||e?(o.x-=n[0],o.y-=n[1],o.x=this.scaled(o.x),o.y=this.scaled(o.y),o.x+=r[0]+i.x,o.y+=r[1]+i.y,this.isC()&&(o.y=-o.y)):(this.isC()&&(o.y=-o.y),o.x-=r[0]+i.x,o.y-=r[1]+i.y,o.x=this.unscaled(o.x),o.y=this.unscaled(o.y),o.x+=n[0],o.y+=n[1]),o},A.prototype.rtCA=function(t,e){return p.Rect(this.ptCA(p.R2C(t,17),e),this.ptCA(p.R2C(t,68),e))},A.prototype.isExtSBS=function(){var t=this.gCW();return t&&12288==(12288&t.gSBs())},A.prototype.uSR=function(t){if(this.oW){var e,o=this.aSR(),i=this.sR,n=this.GetInsideRect(),r=this.rOrg(),s=[-n[2]*r[0],-n[3]*r[1],n[2],n[3]],h=[0,0,0,0];o&&c.IsA(t)?this.oT.GetScrollBars()!=c.ScrollBarsEnum.exNoScroll&&(i=t):(i=o?null===t?s:i?c.URt(i,s):s:h,i=c.URt(this.Lyt().rtLyt,i)),i=i||h,this.aPO()&&(e=[0,0,c.ROf(i),c.BOf(i)],this.isC()&&(e[3]=-(e[1]=c.TOf(i))),i=c.NRt(i,e)||h);var l=!1,a=this.oW.GetSI(!0),u=this.oW.GetSI(!1);r=this.rOrg(),this.sR=i,[a,u].forEach(function(t,e){if(t){var o=e+c.w;i[o]!=t.range&&(l=!0,t.range=i[o]),n[o]!=t.page&&(l=!0,t.pos+=(t.page-n[o])*r[e],t.page=n[o])}},this),l&&(this.resVO(),this.oW.SetSI(a,u),!this.lI&&this.invAO())}},A.prototype.aSR=function(){return!0},A.prototype.getScale=function(){return l(this.scale)&&(this.scale=this.getZoom()/100),this.scale},A.prototype.scaled=function(t){return t/this.getScale()},A.prototype.unscaled=function(t){return t*this.getScale()},A.prototype.GetZoom=function(){return this.oO.zoom},A.prototype.SetZoom=function(t){this.bU(),this.scale=null,this.oO.zoom=t,this.uSR(),this.eU()},A.prototype.getZoom=function(){var t=this.GetZoom(),e=this.getZoomLevels();return l(t)&&(t=100),y(e[0],d(e[e.length-1],t))},A.prototype.GetZoomLevels=function(){return this.oO.zoomLevels},A.prototype.SetZoomLevels=function(t){this.bU(),this.scale=null,this.oO.zoomLevels=t,this.uSR(),this.eU()},A.prototype.getZoomLevels=function(){var t=[100],e=new c.Arr;return c.ToS(this.GetZoomLevels(),"25,35,50,65,75,80,90,100,110,125,150,175,200,250,300,400,500").split(",").forEach(function(t){e.push(y(10,d(1e3,c.ToN(t,100))))}),e.isEmpty()||(t=e.byO()).sort(function(t,e){return t-e}),t},A.prototype.zoomOnWheel=function(t){var e=!1,o=c.WhelInc(t);if(o){var i=this.getZoomLevels(),n=100*this.getScale(),r=function(t,e){var o=0,i=e.length;if(t>=e[o])for(;t>=e[o+1]&&oMath.abs(t.drag.offset.dy)?t.drag.offset.dx:t.drag.offset.dy),t.drag.current);break;case 4:case 5:h(s)&&s.call(l,t)}},this)}},A.prototype.GetScrollBarsHome=function(){return this.oO.scrollBarsHome},A.prototype.SetScrollBarsHome=function(t){this.bU(),this.oO.scrollBarsHome=t,this.eU()},A.prototype.getScrollBarsHome=function(){var t=this.GetScrollBarsHome();return void 0===t&&(t="black"),t||null},A.prototype.GetScrollBarsLayout=function(){return this.oO.scrollBarsLayout},A.prototype.SetScrollBarsLayout=function(t){this.bU(),this.oO.scrollBarsLayout=t,this.eU()},A.prototype.getScrollBarsLayout=function(){var t=this.GetScrollBarsLayout();return void 0===t&&(t="black"),t||null},A.prototype.Soom=function(t,e,o){var i=h(t),n=h(e);if(i||n){o=o||this.rOrg();var r=100*this.getScale(),s=this.GetInsideRect(!0),l=this.ptCA(e,!1),a={x:s[0]+s[2]*o[0],y:s[1]+s[3]*o[1]};((i&=r!=t)||(n&=l.x!=a.x||l.y!=a.y))&&(c.A.Cancel("soom"),c.A.Progress(function(o){this.bU(),i&&this.SetZoom(r+(t-r)*o),n&&(l=this.ptCA(e,!1),this.rurScrollD((l.x-a.x)*o,(l.y-a.y)*o)),this.eU()},{name:"soom",thisArg:this,duration:this.getSmooth(),onXDoL:!1,transition:"swipe"}))}},A.prototype.Home=function(){this.Soom(100,[0,0])},A.prototype.FitToClient=function(t){function e(t,e){return{x:t[0]+t[2]*e[0],y:t[1]+t[3]*e[1]}}var o=l(t);if(t=t||this.Lyt().rtLyt,l(t))this.Home();else if(!c.EyR(t)){var i=this.GetInsideRect(!0),n=this.getScale(),r=d(i[2]/t[2],i[3]/t[3]),s=this.rOrg(),h=e(t,s);o&&r>n?r=null:r1),t.rgSel=null),r&&(t.rgSel=t.rgSel||new c.Arr).push(e)),i|=n!=t.isSelected(e);return i}var r=!1,s=!o&&(this.isToggleSel()||this.isToggleCtrlSel()&&2&this.oSelEv.modifier),a=this.valueToElements(t);i(a)?s?a.forEach(function(t){r|=n(this,t,s)},this):(r=!a.equal(this.rgSel))&&(this.isSingleSel()?n(this,a.last()):(this.rgSel=new c.Arr,a.forEach(function(t){this.isSable(t)&&this.rgSel.push(t)},this))):r=n(this,a,s),r&&(i(this.rgSel)&&0==this.rgSel.len()&&(this.rgSel=null),0==this.lI&&(void 0===e||e)&&this.invAO(),this.onSel())},A.prototype.rurSelectClick=function(t){var e=this.allowSelect()&&t&&t.drag&&4==t.drag.status&&1==c.e2B(t);if(e){var o=this.p2O(t.drag.current);this.selectModifierEvent(t),this.select(o),this.selectModifierEvent(null),this.onRurClick(o)}return e},A.prototype.onRurClick=function(t){this.EnsureVisibleClient(t)},A.prototype.onSel=function(){this.onselchange(this.GetSelection())},A.prototype.onselchange=function(t){this.oLts.onselchange.do(t)},A.prototype.onfocuslink=function(t){this.oLts.onfocuslink.do(t)},A.prototype.drawS=function(t,e){l(e)?this.drawO(t):(e?(this.drawO(t),this.drawL(t)):(this.drawL(t),this.drawO(t)),this.drawLCP(t))},A.prototype.drawO=function(t,e,o){var i=this.getVO(),n=this.isSelectable()?t.gAO():null;if(i){n&&(n.hasOf(this)||(n=null));var r=i.toA();(l(o)||o<0)&&(o=r.length);for(var s,h=e||0,a=r.length,u=0;h1){var n,r,s=this.toShape("multiSel");s&&(o=c.Format(o,0),n=t.sizeHTMLText(o),r=p.C2R(p.R2C(e,i),n.width+8,n.height+8,i),t.drawShape(r,s,{text:o}))}},A.prototype.acTL=function(){var t=this.GetClientRect(),e=this.rtCA(t),o=c.ORt(e.slice(),-e[0],-e[1]),i=this.isC(),n=e[1],r=c.BOf(e),s=e[3];return i&&(n=s+n,r-=s),{lA:e[0],tA:n,rA:c.ROf(e),bA:r,lC:o[0],tC:o[1],rC:c.ROf(o),bC:c.BOf(o),xR:o[2]/e[2],yR:o[3]/e[3],x:function(t){return this.lC+(t-this.lA)*this.xR},y:function(t){return this.tC+(t-this.tA)*this.yR}}},A.dGL=function(t,e,o,i){e&&c.ToI(e.width,1)&&(t.save(),h(e.width)&&(t.lineWidth=e.width),h(e.color)&&(t.strokeStyle=e.color),h(e.style)&&t.setLineDash(c.IsA(e.style)?e.style:[e.style]),h(e.cap)&&(t.lineCap=e.cap),h(e.join)&&(t.lineJoin=e.join),t.beginPath(),o.call(i,e),t.stroke(),t.restore())},A.prototype.drawA=function(t){function e(){var e=0,i=0;(e>=o.lA&&e=o.rA&&e=o.tA&&i=o.bA&&i1&&A.dGL(t,e,function(){for(t=f;t<=g;t+=p)c(h(t));for(var t=S;t<=v;t+=p)u(l(t))})}if(this.getShowGridLines()){var o=this.acTL(),i=o.lC,n=o.rC,r=o.tC,s=o.bC,h=o.x.bind(o),l=o.y.bind(o);!this.islow()&&e(this.getMinorGridLines()),e(this.getMajorGridLines())}},A.prototype.ftL=function(t){return this.ftcL(t)},A.prototype.ftDefLink=function(t){return t},A.prototype.ftcL=function(t){var e=t.oF.getCollapsedParent(),o=t.oT.getCollapsedParent();return e==t.oF&&o==t.oT?t:{oF:e,oT:o}},A.prototype.drawL=function(t){function e(t){var e=C.get(t);return void 0==e&&C.set(t,e=v.get(t)||O.o2R(t,m)),e}function o(t,e){return t?e?c.Inh(t,e):t:e}function i(t,e){return h&&h.has(t)?e=o(n,e):l&&l.has(t)?e=o(r,e):s&&(e=o(s,e)),e}var n,r,s,h,l,a,u,f=c.L,g=this,y=g.oSL,d=!g.isReadOnly()&&y.oFL||null,S=g.getSel(),v=g.getVO(),C=new c.M1,O=g.Lyt(),m=g.origin(),L=g.getLink(),E=g.getCollapsedLink(),R=function(t,e){return e},w=t.drawDir;S.len()&&(n=g.getLinkStartFrom(),r=g.getLinkEndTo(),s=g.getLinkUnselected(),(n||r)&&S.forEach(function(t){y.linksOf(t).forEach(function(e){e.getFrom()==t&&n&&(h=h||new c.Arr).push(e),e.getTo()==t&&r&&(l=l||new c.Arr).push(e)})}),(h||l||s)&&(R=i)),t.drawDir=function(t,e,o,i,n){function r(t,e){t&&(u=u||new Map).set(t,p.C2R(e,6,6))}var s=n.link,h=s.getCustomPath(),l=n.p||t,c=o&&s.rgCP;if(h&&(s.oSL.oFL==s&&s.oSL.oSV.orurDC==s&&(h=s.sCP(h)),l=s.cp2P(h,l[0],l[l.length-1])),s==d)for(var f,g,y,S=function(t,e,o){var i=t.aCP();return i&&(2==(t.getLink()||{}).type&&(i&=-4),i&&A.lO(e,o)&&(i&=-13)),i}(d,(a=l)[0],a[a.length-1]),v=0,C=a.length;v1){for(var r=0;r<4;r++)t[r]=e(t[r]);t[2]=y(i,t[2]),t[3]=y(i,t[3])}return t}.call(this,c.HitTest.Resize(t,e,o,i,n))},A.prototype.onCopy=function(){var t,e=this.getSel(),o=[];return e.forEach(function(t){t.genID(),o.push(t.coO())}),this.oSL.linksOf(e).forEach(function(o){e.has(o.getFrom())&&e.has(o.getTo())&&(o.genID(),(t=t||[]).push(o.coO()))}),{e:o,l:t}},A.prototype.offP=function(t){return this.getPad()},A.prototype.onPaste=function(t){var e,i,n,r,s=t.e;o(s)&&(i=this.oSE.nextID(s.length),n=new Map,s.forEach(function(t,e){n.set(t.key,t.key=i[e])},this),s.forEach(function(t){h(t.parent)&&(t.parent=n.get(t.parent))},this),e=this.offP(t),s.forEach(function(t){e&&t.client&&c.ORt(t.client,e[0],e[1]),this.oSE.Add(t)},this),o(r=t.l)&&r.forEach(function(t,e){t.key=this.oSL.nextID(),t.from=n.get(t.from),t.to=n.get(t.to),this.oSL.Add(t)},this))},A.prototype.aCCP=function(){return c.EVis(this.GetCanvas())},A.prototype.Cut=function(){this.aCCP()&&(this.Copy(),this.RemoveSelection())},A.prototype.Copy=function(){if(this.aCCP()){var t=c.win.event,e=JSON.stringify(this.onCopy());r(t)?(c.SEP(t),t.clipboardData.setData("text/plain",e)):c.nav.clipboard.writeText(e)}},A.prototype.Paste=function(){function t(t){this.Smooth(function(){var e,o=this.oSE.GetCount();try{this.onPaste(JSON.parse(t))}catch(t){}if(o!=this.oSE.GetCount()){for(var i=o,n=this.oSE.GetCount();i=this.End)},U.prototype.UnionWith=function(t){var e=this.IntersectWith(t);return e&&(this.Start=d(this.Start,t.Start),this.End=y(this.End,t.End),this.Elements.push(t.Elements)),e},Object.addPrototypeOf(G.prototype,c.M1.prototype),G.prototype.isEmpty=function(){return 0==this.len()},G.prototype.MinX=function(){var t=null;return this.forEach(function(e){(!t||e[0]=i)},k.prototype.IntersectRightMin=function(t,e,o){return o.clear(),this.forEach(function(i,n){if(!e||!e.has(n)){var r=c.NRt(t,i);c.EyR(r)||o.set(n,i[0]=i)},k.prototype.IntersectDownMin=function(t,e,o){return o.clear(),this.forEach(function(i,n){if(!e||!e.has(n)){var r=c.NRt(t,i);c.EyR(r)||o.set(n,i[1]0?s=p:(p=c.BOf(r)-c.TOf(a))<0&&(s=p);break;case 1:var f=c.ROf(l)-c.LOf(h);l[0]=a[0]=h[0],l[2]=f,a[2]=0,this.Intersect(l,i,u)&&(a=this.Union(u.rgO));var g=c.LOf(r)-c.ROf(a);g>0?s=g:(g=c.ROf(r)-c.LOf(a))<0&&(s=g)}if(s)switch(e){case 0:case 1:n=-s}}return n},k.prototype.Shift=function(t,e,o){var i=null;t.forEach(function(t){(i=this.get(t))&&c.ORt(i,e,o)},this)},k.orderElementRectByStart=function(t,e){return t.Start-e.Start},k.prototype.ToBlocks=function(t,e,o){var i=[];switch(t){case 0:this.forEach(function(t,o){e&&!e.has(o)||i.push(new U(o,c.LOf(t),c.ROf(t)))},this);break;case 1:this.forEach(function(t,o){e&&!e.has(o)||i.push(new U(o,c.TOf(t),c.BOf(t)))},this)}return n(o)&&i.sort(o),i},P.prototype.GetCache=function(t){return this.oSurfaceElementsArrange.Cache.GetCache(t)},P.ToVector=function(t,e,o){return t=t.slice(),n(e)&&t.sort(function(t,i){return e.call(o,t,i)}),t},P.prototype.orderElementByOutAll=function(t,e){return this.GetCache(e).OutAll.len()-this.GetCache(t).OutAll.len()},P.prototype.showTemp=function(t){t.forEach(function(t,e){t.Caption=""+e,t.Shape={normal:{fillColor:"rgba(255,0,0,0.5)"}}},this)},P.prototype.Init=function(){if(this.Input.clear(),!this.Elements.isEmpty()){this.Elements.forEach(function(t){this.GetCache(t).collectAll(this)},this);var t=P.ToVector(this.Elements.byO(),this.orderElementByOutAll,this),e=new c.Arr;t.forEach(function(t){e.has(t)||(this.Input.add(t),e.push(this.GetCache(t).OutAll))},this)}return this},P.prototype.PreArrange=function(){this.preArrange(this.Input,this.Loc),this.getArrangeCompact()&&this.compact(),this.getArrangeAlign()&&this.align(),this.optimize()},P.toRect=function(t,e){return[t[0],t[1],e.cx,e.cy]},P.prototype.setArrangeLoc=function(t,e,o,i){(this.GetCache(t).Group||[t]).forEach(function(t){o&&e&&o.set(t,e.slice()),i&&i.add(t)})},P.prototype.getArrangeCount=function(t){var e=new c.Arr;return t.forEach(function(t){e.push(t,this.GetCache(t).OutAll)},this),e.len()},P.prototype.addElementGroup=function(t,e){e.add(t);var o=this.GetCache(t).Group;o&&e.push(o)},P.prototype.nextLoc=function(t,e){switch(this.getArrangeDir()){case 0:t[1]+=e.cy;break;case 1:t[0]+=e.cx}},P.prototype.nextDown=function(t,e){switch(this.getArrangeDir()){case 0:t[0]=c.ROf(t);break;case 1:t[1]=c.BOf(t)}t[2]=e.cx,t[3]=e.cy},P.prototype.nextRight=function(t,e){switch(this.getArrangeDir()){case 0:t[0]=c.ROf(t),t[2]=e[2],t[1]=e[1],t[3]=e[3];break;case 1:t[1]=c.BOf(t),t[3]=e[3],t[0]=e[0],t[2]=e[2]}},P.prototype.isArranged=function(t,e){var o=!0;switch(this.getArrangeDir()){case 0:o=t[0]>=e[0];break;case 1:o=t[1]>=e[1]}return o},P.prototype.preAllocateDownRight=function(t,e){var o=[0,0];t.forEach(function(t){if(!e.get(t)){var i=this.Size.get(t);this.setArrangeLoc(t,P.toRect(o,i),e),this.nextLoc(o,i)}},this);var i=e.union();return{cx:i[2],cy:i[3]}},P.prototype.preArrange=function(t,e){e.clear();if(h(C=t.first())){var o=new c.Arr,i=new c.Arr;for(this.setArrangeLoc(C,P.toRect([0,0],this.Size.get(C)),e,o),C=t.next(C);C;C=t.next(C))this.setArrangeLoc(C,null,null,i);for(var n=this.getArrangeCount(o),r=0,s=n*(n-1),l=this.getArrangeDir(),a=!0;a;){a=!1;for(var u=0;u1){for(var l=[],s=0;sa.End){for(var c=new U(null,a.End,u.Start),n=s+1;n1&&this.rgArrangementCache.push(e.Init())}}},x.prototype.PreArrange=function(){this.rgArrangementCache.forEach(function(t){t.PreArrange()})},x.prototype.DoArrange=function(){this.rgArrangementCache.forEach(function(t){t.DoArrange()})},I.prototype.getArrangeDir=function(){return this.oDefArrange.dir||0},I.prototype.getArrangeDX=function(){return this.oDefArrange.dx||0},I.prototype.getArrangeDY=function(){return this.oDefArrange.dy||0},I.prototype.getArrangeAlign=function(){return h(this.oDefArrange.align)?~~this.oDefArrange.align:1},I.prototype.getArrangeCompact=function(){return this.oDefArrange.compact},I.prototype.onArranging=function(){this.Cache.ResetCache()},I.prototype.onArrange=function(){this.Cache.ResetCache()},I.prototype.Arrange=function(t){var e=null;-2&this.getArrangeDir()||!l(t)&&!(e=this.oSE.Item(t))||(this.onArranging(),this.Cache.Collect(e),this.Cache.PreArrange(),this.Cache.DoArrange(),this.onArrange())},c.expO({Count:null},t.prototype),c.expO(c.Mrg({Options:null,Index:null,Position:null},c.Surface.ElementOptions),g.prototype),c.expO({Count:null},O.prototype),c.expO(c.Mrg({Options:null,Index:null},c.Surface.LinkOptions),m.prototype),{Elements:t,Element:g,Links:O,Link:m,SV:A,CSurfaceElementsArrange:I}}()),c.Mrg(c.Surface.SV,function(){function t(t){this.oSV=t,this.rgVO=new c.M1,this.mP2O=new Map,this.rtLyt=this.doL()}return t.expandGlyphRect=function(t,e){return[t[0]-e,t[1]+(t[3]-e)/2,e,e]},t.prototype.doL=function(){function e(t){return t}function o(i,a){n.push(i,e((a=a||i.getClient()).slice()));var u,c,p,f=a[1]+(r?0:a[3]),g=i.getVisibleChild();return l>0&&(g||i.hasVisibleChild())&&n.set(i.getExpandGlyph(),e(t.expandGlyphRect(a,l))),g&&(u=a[0]+s,g.forEach(function(t){c=(p=t.getClient())[3],f=o(t,t.oO.client=[u,r?f-c-h:f+h,p[2],c])})),f}var i=this.oSV,n=this.rgVO,r=i.isC(),s=i.getIndent(),h=i.getMarginY(),l=i.getExpandGlyphSize();return r&&(e=t.r2C),i.oSE.forEach(function(t){t.isVisible()&&!t.oP&&o(t)}),t.toR(n),n.union()},t.toR=function(t){t&&t.forEach(function(t){for(var e=0,o=t.length;e