/* @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(){return Math.max.apply(0,arguments)}function o(){return Math.min.apply(null,arguments)}function i(){}function n(t){return t instanceof Array}function r(t){return t instanceof g.Arr}function s(t){return t instanceof Function}function h(t){return t instanceof ClipboardEvent}function l(t){return t instanceof g.Surface.Element}function a(t){return Math.round(t)}function u(t){return null!=t}function c(t){return null==t}function p(t,e,o){return c(t)?~~o:g.s2F(t,e)}var f,g=g||window.exontrol,y=g.G,d=g.UR,S="pos",v="imageSize",C="client";g.Def.Surface={},g.Shapes.Surface={},g.Mrg(g,function(){function t(t,e){this.init(t,e)}return t.prototype.init=function(t,e){var o=new g.Surface.SV;if(this.oSV=o,this.oSV.oT=this,this.oVS=new g.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 g.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.oSV.oLts,this.oCW=new g.CW(t,{AllowXChg:0,ScrollBars:g.Def.Surface.scrollBars}),this.oCW.oT=this,this.Shortcuts=this.oCW.oSts,d&&(this.oUR=new d.M({oC:this,cU:f.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),g.DPR.Reg(this),this.Refresh()},t.version="3.2",t.type="Surface",t.LinkControlPointEnum={exNoControlPoint:0,exStartControlPoint:1,exEndControlPoint:2,exControlPoint:4,exMiddleControlPoint:8,exOrthoArrange:16},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},d&&(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,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))}),g.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 g.Lay.Save(this.onlayout,this,t)},t.prototype.SetLayout=function(t,e){g.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 g.Format(t,e||0)}var e="",o=g.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){l(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}),f=g.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=i,t.prototype.SetAllowUndoRedo=i,t.prototype.GetUndoRedoQueueLength=i,t.prototype.SetUndoRedoQueueLength=i,t.prototype.CanUndo=i,t.prototype.CanRedo=i,t.prototype.StartBlockUndoRedo=i,t.prototype.EndBlockUndoRedo=i,t.prototype.BlockUndoRedo=function(t,e){s(t)&&(this.StartBlockUndoRedo(),t.call(e||this),this.EndBlockUndoRedo())},t.prototype.Undo=i,t.prototype.Redo=i,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)},g.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()},g.CW.prototype.SetCanvas=function(t,e){return g.ComboBox.implExHost(t,"onselchange")}(g.CW.prototype.SetCanvas)),g.expO({Layout:null,Statistics:null},t.prototype),{Surface:t}}()),g.Mrg(g.Surface,function(){function t(t){this.init(t)}function a(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 g.Arr,this.Out=new Map,this.In=new Map,this.Build(t)}function R(){this.Group=null,this.In=new g.Arr,this.InAll=new g.Arr,this.Out=new g.Arr,this.OutAll=new g.Arr}function w(){this.rgGroups=[],this.rgCache=new Map}function b(t){var e=new g.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 g.Arr,this.Start=e||0,this.End=o||0,u(t)&&this.Elements.add(t)}function G(){var t=new g.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function P(){var t=new g.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function k(t,e){this.oSurfaceElementsArrange=t,this.Origin=e,this.Elements=new g.Arr,this.Groups=new w,this.Size=new Map,this.Input=new b(this),this.Loc=new P,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=g.Mrg(g.Def.Surface.defArrange,o),this.Cache=new x(this)}return t.prototype.init=function(t){this.oSV=t,this.mK2I=null,this.rgE=new g.Arr,this.rgE.onRemove=t.onDelElement.bind(t),["bU","eU"].forEach(function(e){this[e]=t[e].bind(t)},this),["forEach","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 g.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:l(t)?e=this.rgE.has(t)?t:null:c(e=function(t){var e=t.mK2I;return c(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,o=g.Arr.empty;if(t&&(e=t,l(t)?e=[t]:r(t)&&(e=t.rgE),n(e))){o=new g.Arr,e.forEach(function(t){o.ann(this.Item(t))},this);for(var i=0;i1&&t!=e-1&&this.SetPosition(e-1),t},a.prototype.BringForward=function(){var t=this.GetPosition(),e=this.oSE.GetCount();return e>1&&t+11&&t>0&&this.SetPosition(0),t},a.prototype.SendBackward=function(){var t=this.GetPosition();return this.oSE.GetCount()>1&&t>0&&this.SetPosition(t-1),t},a.prototype.GetKey=function(){return this.oO.key},a.prototype.SetKey=function(t){this.bU(),this.oSE.resK2I(),this.oO.key=t,this.eU()},a.prototype.getKey=function(){var t=this.GetKey();return(t=u(t)?t.toString():"")||this.getPlainCaption()},a.prototype.GetVisible=function(){return this.oO.visible},a.prototype.SetVisible=function(t){this.bU(),this.oO.visible=t,this.eU(!0)},a.prototype.getVisible=function(){return c(this.GetVisible())||this.GetVisible()},a.prototype.isVisible=function(){return this.GetVisible()||c(this.GetVisible())},a.prototype.GetEnabled=function(){return this.oO.enabled},a.prototype.SetEnabled=function(t){this.bU(),this.oO.enabled=t,this.eU()},a.prototype.getEnabled=function(){return c(this.GetEnabled())||this.GetEnabled()},a.prototype.isEnabled=function(){return!!this.getEnabled()&&(!this.oP||this.oP.isEnabled())},a.prototype.GetSelectable=function(){return this.oO.selectable},a.prototype.SetSelectable=function(t){this.bU(),this.oO.selectable=t,this.eU()},a.prototype.getSelectable=function(){return c(this.GetSelectable())||this.GetSelectable()},a.prototype.isSelectable=function(){return this.getSelectable()},a.prototype.GetCaption=function(){return this.oO.caption},a.prototype.SetCaption=function(t){this.bU(),this.oSE.resK2I(),this.oO.caption=t,this.eU(!0)},a.prototype.getCaption=function(){return this.GetCaption()},a.prototype.getPlainCaption=function(){return g.H.TextNoHTML(this.getCaption())},a.prototype.GetFormatText=function(){return this.oO.formatText},a.prototype.SetFormatText=function(t){this.bU(),this.oO.formatText=t,this.eU()},a.prototype.getFormatText=function(){var t=this.GetFormatText();return u(t)?~~t:this.getView().getFormatText()},a.prototype.GetPad=function(){return this.oO.pad},a.prototype.SetPad=function(t){this.bU(),this.oO.pad=t,this.eU()},a.prototype.getPad=function(){var t=this.GetPad();return u(t)?g.pad2A(t):this.getView().getPad()},a.prototype.GetImage=function(){return this.oO.image},a.prototype.SetImage=function(t){this.bU(),this.oO.image=t,this.eU(!0)},a.prototype.getImage=function(){var t=this.GetImage();return u(t)?t.toString():""},a.prototype.GetImageSize=function(){return this.oO.imageSize},a.prototype.SetImageSize=function(t){this.bU(),this.oO.imageSize=t,this.eU(!0)},a.prototype.getImageSize=function(){var t=this.GetImageSize();return void 0!==t?t:this.getView().getImageSize()},a.prototype.GetImageAlign=function(){return this.oO.imageAlign},a.prototype.SetImageAlign=function(t){this.bU(),this.oO.imageAlign=t,this.eU(!0)},a.prototype.getImageAlign=function(){var t=this.GetImageAlign();return u(t)?g.ToI(t,2):this.getView().getImageAlign()},a.prototype.gCnt=function(t,e){var o=this.getPad(),i=g.HP.Measure(this.getImage(),this.getImageSize(),t),n=g.PRt(e.slice(),o,-1),r=null;if(u(i))switch(this.getImageAlign()){case 3:(r=n.slice())[1]=g.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]=g.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}},a.prototype.draw=function(t,e,o){var i,n=!this.isEnabled();n&&g.H.lA++,t.selClip(e),i=this.gCnt(t,e),t.drawHTMLText(this.getCaption(),i.rtCaption,o.formatText||this.getFormatText(),o.tfi&&g.ToTFI(o.tfi)),t.drawHTMLPicture(this.getImage(),i.rtImage,this.getImageSize()),t.resClip(),n&&--g.H.lA},a.prototype.GetShape=function(){return this.oO.shape},a.prototype.SetShape=function(t){this.bU(),this.oO.shape=t,this.eU(!0)},a.prototype.GetCursor=function(){return this.oO.cursor},a.prototype.SetCursor=function(t){this.bU(),this.oO.cursor=t,this.eU()},a.prototype.GetClient=function(){return this.oO.client},a.prototype.SetClient=function(t){this.bU(),this.oO.client=t,this.eU(!0)},a.prototype.getContentSize=function(t){var o={width:0,height:0},i=this.getPad(),n=this.getView().toShape(this),r=g.H.Measure(t,this.getCaption(),null,this.getFormatText(),n.tfi&&g.ToTFI(n.tfi)),s=g.HP.Measure(this.getImage(),this.getImageSize(),t);return u(r)&&(o.width+=r.width+1,o.height+=r.height+1),u(s)&&(this.getImageAlign()>=2?(o.width=e(o.width,s.width),o.height&&(o.height+=i[1]),o.height+=s.height):(o.height=e(o.height,s.height),o.width&&(o.width+=i[0]),o.width+=s.width)),o.width+=i[0]<<1,o.height+=i[1]<<1,o},a.prototype.getClient=function(){var t,e=g.C2R(this.GetClient()||32);return this.getAutoSize()&&(t=this.getView().gAS(this),e[2]=t.width,e[3]=t.height),e},a.prototype.GetParent=function(){return this.oP},a.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);u(o)&&(o.remove(this),this.resOwnCol()),(this.oP=e)&&this.ownCol(!0).add(this),this.eU(!0)}}},a.prototype.canParent=function(t){return!(t==this.oP||t&&t.isChildOf(this))},a.prototype.isChildOf=function(t){for(var e=this;e&&e!=t;)e=e.oP;return e==t},a.prototype.hasOptsP=function(){var t=null,e=this.oO.parent;return e&&(e=this.oSE.Item(e))&&this.canParent(e)&&(t=e),t},a.prototype.ownCol=function(t){var e=null;return this.oP&&(e=this.oP.rgC,t&&!e&&(this.oP.rgC=e=new g.Arr)),e},a.prototype.resOwnCol=function(){u(this.oP)&&u(this.oP.rgC)&&0==this.oP.rgC.len()&&(this.oP.rgC=null)},a.prototype.dscn=function(){return this.oSE.dscn(this)},a.prototype.GetExpand=function(){return this.oO.expand},a.prototype.SetExpand=function(t){t!=this.isExpanded()&&(this.bU(),this.oO.expand=t,this.eU(!0))},a.prototype.isExpanded=function(){return!(!c(this.GetExpand())&&!this.GetExpand())},a.prototype.ToggleExpand=function(){this.SetExpand(!this.isExpanded())},a.prototype.GetAutoSize=function(){return this.oO.autoSize},a.prototype.SetAutoSize=function(t){this.bU(),this.oO.autoSize=t,this.eU(!0)},a.prototype.getAutoSize=function(){return this.GetAutoSize()},a.prototype.GetResizable=function(){return this.oO.resizable},a.prototype.SetResizable=function(t){this.bU(),this.oO.resizable=t,this.eU(!0)},a.prototype.getResizable=function(){return!(!c(this.GetResizable())&&!this.GetResizable())},a.prototype.isResizable=function(){return this.getResizable()&&!this.getAutoSize()},a.prototype.GetMovable=function(){return this.oO.movable},a.prototype.SetMovable=function(t){this.bU(),this.oO.movable=t,this.eU(!0)},a.prototype.getMovable=function(){return!(!c(this.GetMovable())&&!this.GetMovable())},a.prototype.isMovable=function(){return this.getMovable()},a.prototype.hasVisibleChild=function(){var t=null;return this.rgC&&this.rgC.forEachU(function(e){return e.getVisible()&&(t=e),t}),t},a.prototype.getVisibleChild=function(){var t;return this.rgC&&this.isExpanded()&&this.rgC.forEach(function(e){e.getVisible()&&(t=t||[]).push(e)}),t},a.prototype.hasChild=function(){return this.rgC&&this.rgC.len()},a.prototype.getRoot=function(){for(var t=this;t.oP;)t=t.oP;return t},a.prototype.getLevel=function(){for(var t=0,e=this;e=e.oP;)t++;return t},a.prototype.getCollapsedParent=function(){for(var t=null,e=this;e.oP;)(e=e.oP).isExpanded()||(t=e);return t||this},a.prototype.getExpandGlyph=function(){return this.eG=this.eG||{expand:this}},a.prototype.IsArrangeGroup=function(){var t;return(this.oP||this.rgC)&&(t=this.getRoot().dscn()),t},a.prototype.isVisibleEx=function(){return this.isVisible()&&(!this.oP||this.oP.isExpanded()&&this.oP.isVisibleEx())},a.prototype.ArrangeLoc=function(){var t=[0,0,0,0];return this.isVisibleEx()&&(t=this.getClient()),t},a.prototype.ArrangeSize=function(){var t=this.ArrangeLoc();return{cx:t[2],cy:t[3]}},a.prototype.ArrangeTo=function(t){var e=this.getClient(),o=e.slice();e[0]=y.X(t),e[1]=y.Y(t),this.SetClient(e),this.getView().onMoveElement(this,o)},a.prototype.toString=function(){return this.getKey()||this.oSE.indexOf(this)},a.prototype.EnsureVisible=function(){for(var t=this;t=t.oP;)t.SetExpand(!0);this.getView().EnsureVisibleClient(this)},a.prototype.genID=function(){var t=this.GetKey();return c(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},a.prototype.coO=function(){var t=g.Cpy(this.oO);return t[C]=this.getClient(),t.position=this.GetPosition(),l(t.parent)&&(t.parent=t.parent.genID()),t},d&&(a.prototype.scUR=function(t){t.o=this.oSE,t.i=this.genID()},a.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()}}},a.prototype.mvUR=function(t,e){e&&(this.scUR(t,!0),t.d={from:g.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())})},a.prototype.uUR=function(t,e,o){this.scUR(t,!0),(t.d=d.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())})},a.prototype.StartUpdateElement=function(){return this.getView().gUR()&&this.coO()},a.prototype.suo=a.prototype.StartUpdateElement,a.prototype.EndUpdateElement=function(t){t&&this.getView().nUR(f.UpdateElement,function(e){this.uUR(e,t,this.coO())},this)},a.prototype.euo=a.prototype.EndUpdateElement,a.prototype.UpdateElement=function(t,e){if(s(t)){var o=this.StartUpdateElement();t.call(e||this),this.EndUpdateElement(o)}}),O.prototype.init=function(t){this.oSV=t,this.rgL=new g.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","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 g.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 g.Surface.Link}(t)?(e=function(t){var e=t.mK2I;return c(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):g.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(),g.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]},g.Surface.Link.F.f2o(o,function(t,e,o){g.Surface.Link.F.isF(o)&&(r[t]=e)}),g.Surface.Link.FLink.f2o(o,function(t,e,o){var i=o.sWith(g.Surface.Link.FCollapsedLink);if(i&&(o=o.substr(g.Surface.Link.FCollapsedLink.length),t=g.F.l1st(g.Surface.Link.FLink.toN(o))),g.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 c(e)&&(!(e=t.getPlainCaption()).trim()||g.IsI(e)||e.length>4)&&(e=t.GetIndex()),e}var e=[],o=this.oFL;return this.rgL.forEachI(function(i){i.oF&&i.oT&&e.push(function(e){var i=g.B.quoteC(e.getCaption()),n=g.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(g.Surface.Link.FCollapsedLink+h,s[h]);return e==o&&n.set("focus",null),i+=g.B.quoteF(n)}(i))}),g.B.quoteS(e)},O.prototype.nextID=function(t){function o(){for(var t="";this.Item(t=i+ ++this.__nextID););return t}this.__nextID=this.__nextID||0;var i="_l",n=o.call(this);if(u(t)){n=[n],t=e(0,g.ToI(t,1)-1);for(var r=0;rs;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=g.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()),g.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,g.DrawTextFormatEnum.exTextAlignCenter|g.DrawTextFormatEnum.exTextAlignVCenter)}o.rurEFPaint=V,o.rurEFOpts=function(t,e){e.visible=!1,e.limitClient=!1},o.rurDrag=function(t){T&&T.SetVisible(t.from!=t.to);var e={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y};s.call(this,e,b),t.frame=this.htR(x,e.dx,e.dy,k),!o.rurEFPaint&&V.call(this,t,this.gCtx(),this.rtCA(t.frame,!1)),i(t)},o.rurCancel=function(t){r(!0)},o.rurDrop=function(t){r();var e=s.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,k);if(C)g.EyR(o)||this.onRURChange(this.orurDC=this.onRURCreate(o,p));else if(v){var i=l(v)?n(t):void 0,u="Smoothless";void 0!==i&&w.forEach(function(t){l(t)&&t.oP!=i&&(u="Smooth")}),this[u].call(this,function(){this.bU();var t=null;R&&(t=new g.M1,w.forEach(function(e){t.set(e,e.getClient())})),w.forEach(function(t){(!R||v==t||l(v)&&this.isSelected(t))&&(!E&&l(t)&&(t=t.getRoot()),this.onRURApplyClient(t,this.htR(x,e.dx,e.dy,t.getClient()))),void 0!==i&&(a=a||h.call(this,w)).get(t)&&this.onRURApplyParent(t,i)},this),l(i)&&(i.SetExpand(!0),this.EnsureVisibleOnExpand(v)),R&&this.onRURResize(v,t),this.onRURChange(v,b),this.eU()},this)}}}}else if(m=C||this.rurAllowMove(v,p)){var D=this.Lyt().rgVO,F=this.getExpandGlyphSize(),M=null;o.rurOnlyAO=v,o.rurDragStart=function(t){M=this.p2O,this.p2O=function(t){var e=this.ptCA(t,!0);return D.p2O(y.X(e),this.Lyt().y2C(y.Y(e)),v)}},o.rurDragEnd=function(t){this.p2O=M||this.p2O},o.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(y.C2R(this.ptCA(f,!0),0,0),p)))&&(d={o:v,ht:68,new:!0},b.set(v,v.getClient()));var o=this.Lyt(),n={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y},r=function(){},h=this.onRL;this.getAlignObjectsToGridLines()||(e=r),s.call(this,n,b),D=o.rgVO,this.onRL=r,this.bU(),l(v)&&D.setZOrd(v,D.len()),b.forEach(function(t,i){if(!R||v==i||l(v)&&this.isSelected(i)){var r;(function(t,e,o,i,n){l(t)&&(!t.isResizable()&&34!=e||!t.isMovable()&&34==e)&&(e=0),e&&t.SetClient(this.htR(e,o,i,n))}).call(this,i,d.ht,n.dx,n.dy,t),i.oP&&e(i),D.set(i,o.r2C(i.getClient())),F>0&&D.get(r=i.getExpandGlyph())&&D.set(r,o.r2C(A.Layout.expandGlyphRect(i.getClient(),F)))}},this),!C&&R&&this.onRURResize(v,b,D),this.resVO(),this.eU(),this.onRL=h,i(t)},o.rurDrop=function(t){r();var e=n(t),o="Smoothless";void 0!==e&&w.forEach(function(t){l(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||h.call(this,w)).get(t)&&(l(t)&&!t.isMovable()||this.onRURApplyParent(t,e))},this),l(e)&&(e.SetExpand(!0),this.EnsureVisibleOnExpand(v)),!C&&R&&this.onRURResize(v,b),this.onRURChange(v,C?null:b),this.eU()},this)},o.rurCancel=function(t){r(!0),this.bU(),b.forEach(function(t,e){this.onRURApplyClient(e,t)},this),C&&v.Remove(),this.eU()}}m&&this.rurDrag(t,o)}},A.prototype.rurDragDrop=function(t,e){var o=this.p2O(this.gPtr(t));this.isSable(o)&&g.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(g.GP.Get(e.rurName,this.getCursors()))}})},A.prototype.rurLink=function(t,e){var o=this.gPtr(t),i=this.p2O(o);l(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 g.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([y.X(e)+y.X(o),this.Lyt().y2C(y.Y(e))+y.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)?f:d}var n,r,s,h,a,u,c,p,f=new g.Arr,d=new g.Arr,v=[0,0],C=[1,1];"m"==i?(u=~~l.substr(1))>0&&u0&&u=0&&c=0?(a=y.LPR(s,h,.5),O.splice(p,0,a.slice()),O.splice(p,0,a.slice()),r=o(s,h),c?(r.push(c,c+1),c-1>=0&&o(O[c-1],O[c]).push(c-1,c)):(r.push(c+1,c+2),c+30&&o=0&&h0&&(h=e(0,t.drag.current.x-g.ROf(r)));var l=t.drag.current.y-g.TOf(r);l>0&&(l=e(0,t.drag.current.y-g.BOf(r))),(h||l)&&this.rurScrollD(h,l),clearTimeout(R);var y=(this.p2O(t.drag.current)||{}).expand;if(y&&!y.isExpanded()){var d=this;R=setTimeout(function(){d.bU(),y.SetExpand(!0),n(),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,n(),u(A)&&A.SetClient(this.rtCA(a.frame,!1));break;case 4:case 5:clearTimeout(R),this.orurOnlyAO=null,i(this),u(m)&&m.call(L,a),m=null,u(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 u(o)&&(e=y.R2C(this.Lyt().o2R(o))),e},A.prototype.focusRectAbs=function(t){var e=y.Rect(t.from,t.to);if(!g.EyR(e)){var o=this.Lyt(),i=o.r2O(e);i.length&&i.forEach(function(t){e=g.URt(e,o.o2R(t))}),e=o.r2C(e)}return e},A.prototype.onRURCreate=function(t,e){var o,n=this.onAddElement;return this.onAddElement=i,o=this.oSE.Create(t),this.onAddElement=n,o},A.prototype.rurAllowMove=function(t,e){return l(t)},A.prototype.allowRur=function(t,e){return u(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"+g.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),g.H.P2A(this,y.X(t),y.Y(t))},A.prototype.onSetAO=function(t){function e(e){var o=i.getShape(e);o&&(!g.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}),!g.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;l(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(s(t))if(this.getSmooth()){var o=this.getSmooth(),i=null,n=null;if(o>0&&(g.A.Cancel(this.sSA),i=this.getVO(),n=this.Lyt(),this.bU()),u(this.rgVO)&&this.rgVO.clean(),t.call(e||this),o>0){var r=this.uSR;this.uSR(),this.uSR=function(){},this.rgVO=i,this.oLyt=n,this.eU(),this.oLyt=null,this.rgVO=null,this.uSR=r;var h=this.origin(),l=this.getVO(),a=this.Lyt();new g.Arr(i.diff(l)).rforEach(function(t){var e=i.get(t),o=l.get(t),r=t.expand||t;if((!e||!o)&&r.oP&&r.oSE.Item(r)){var s=r.oP;if(!e){for(;s&&!(e=i.get(s.getExpandGlyph()));)s=s.oP;e&&i.push(t,y.C2R(y.R2C(e)))}if(!o){for(;s&&!(o=l.get(s.getExpandGlyph()));)s=s.oP;o&&l.push(t,y.C2R(y.R2C(o)))}}!e&&i.push(t,n.o2R(t,h)||y.C2R(y.R2C(o))),!o&&l.push(t,a.o2R(t,h)||y.C2R(y.R2C(e)))}),this.rgVL=null,(this.rgVO=i).morph(l,{inv:this.invAO,refresh:this.Refresh,thisArg:this,name:this.sSA,onXDoL:!1,duration:o})}}else g.A.Cancel(this.sSA),t.call(e||this)},A.prototype.Smoothless=function(t,e){s(t)&&t.call(e||this)},A.prototype.Lyt=function(){if(!this.oLyt){var t,e=this.gCtx();e&&(t=g.TFI.bCTX(e,this.getTfi())),this.oLyt=new A.Layout(this),e&&g.TFI.eCTX(e,t)}return this.oLyt},A.prototype.getVO=function(){return this.rgVO||(this.rgVO=this.Lyt().scroll(this.GetScrollRect(),this.origin()))},A.prototype.getVL=function(){if(c(this.rgVL)){var t=this.getVO(),e=this.Lyt(),o=this.origin(),i=this.GetScrollRect(),n=new g.Arr;this.getShowLinks()&&(g.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&&g.NRt(i,g.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:y.X(t),y:y.Y(t)},i=this.GetScroll(),n=this.GetInsideRect(!0),r=this.sR;return c(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 y.Rect(this.ptCA(y.R2C(t,17),e),this.ptCA(y.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&&g.IsA(t)?this.oT.GetScrollBars()!=g.ScrollBarsEnum.exNoScroll&&(i=t):(i=o?null===t?s:i?g.URt(i,s):s:h,i=g.URt(this.Lyt().rtLayout,i)),i=i||h,this.aPO()&&(e=[0,0,g.ROf(i),g.BOf(i)],this.isC()&&(e[3]=-(e[1]=g.TOf(i))),i=g.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+g.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 c(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(),i=this.getZoomLevels();return c(t)&&(t=100),e(i[0],o(i[i.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],i=new g.Arr;return g.ToS(this.GetZoomLevels(),"25,35,50,65,75,80,90,100,110,125,150,175,200,250,300,400,500").split(",").forEach(function(t){i.push(e(10,o(1e3,g.ToN(t,100))))}),i.isEmpty()||(t=i.byO()).sort(function(t,e){return t-e}),t},A.prototype.zoomOnWheel=function(t){var i=!1,n=g.WhelInc(t);if(n){var r=this.getZoomLevels(),s=100*this.getScale(),h=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:u(r)&&r.call(h,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=u(t),n=u(e);if(i||n){o=o||this.rOrg();var r=100*this.getScale(),s=this.GetInsideRect(!0),h=this.ptCA(e,!1),l={x:s[0]+s[2]*o[0],y:s[1]+s[3]*o[1]};((i&=r!=t)||(n&=h.x!=l.x||h.y!=l.y))&&(g.A.Cancel("soom"),g.A.Progress(function(o){this.bU(),i&&this.SetZoom(r+(t-r)*o),n&&(h=this.ptCA(e,!1),this.rurScrollD((h.x-l.x)*o,(h.y-l.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 i=c(t);if(t=t||this.Lyt().rtLayout,c(t))this.Home();else if(!g.EyR(t)){var n=this.GetInsideRect(!0),r=this.getScale(),s=o(n[2]/t[2],n[3]/t[3]),h=this.rOrg(),l=e(t,h);i&&s>r?s=null:s1),t.rgSel=null),r&&(t.rgSel=t.rgSel||new g.Arr).push(e)),i|=n!=t.isSelected(e);return i}var n=!1,s=!o&&(this.isToggleSel()||this.isToggleCtrlSel()&&2&this.oSelEv.modifier),h=this.valueToElements(t);r(h)?s?h.forEach(function(t){n|=i(this,t,s)},this):(n=!h.equal(this.rgSel))&&(this.isSingleSel()?i(this,h.last()):(this.rgSel=new g.Arr,h.forEach(function(t){this.isSable(t)&&this.rgSel.push(t)},this))):n=i(this,h,s),n&&(r(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==g.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.drawS=function(t,e){c(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();(c(o)||o<0)&&(o=r.length);for(var s,h=e||0,l=r.length,a=0;h1){var n,r,s=this.toShape("multiSel");s&&(o=g.Format(o,0),n=t.sizeHTMLText(o),r=y.C2R(y.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=g.ORt(e.slice(),-e[0],-e[1]),i=this.isC(),n=e[1],r=g.BOf(e),s=e[3];return i&&(n=s+n,r-=s),{lA:e[0],tA:n,rA:g.ROf(e),bA:r,lC:o[0],tC:o[1],rC:g.ROf(o),bC:g.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&&g.ToI(e.width,1)&&(t.save(),u(e.width)&&(t.lineWidth=e.width),u(e.color)&&(t.strokeStyle=e.color),u(e.style)&&t.setLineDash(g.IsA(e.style)?e.style:[e.style]),u(e.cap)&&(t.lineCap=e.cap),u(e.join)&&(t.lineJoin=e.join),t.beginPath(),o.call(i,e),t.stroke(),t.restore())},A.prototype.drawA=function(t){if(this.getShowAxes()){var e=this.acTL();A.dGL(t,this.getAxes(),function(){var o=0,i=0;(o>=e.lA&&o=e.rA&&o=e.tA&&i=e.bA&&i1&&A.dGL(t,i,function(){for(t=y;t<=d;t+=g)f(a(t));for(var t=S;t<=v;t+=g)p(u(t))})}if(this.getShowGridLines()){var n=this.acTL(),r=n.lC,s=n.rC,h=n.tC,l=n.bC,a=n.x.bind(n),u=n.y.bind(n);!this.islow()&&i(this.getMinorGridLines()),i(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=v.get(t);return void 0==e&&v.set(t,e=S.get(t)||C.o2R(t,O)),e}function o(t,e){return t?e?g.Inh(t,e):t:e}var i,n,r,s,h,l,a,u=g.L,c=this,p=c.oSL,f=!c.isReadOnly()&&p.oFL||null,d=c.getSel(),S=c.getVO(),v=new g.M1,C=c.Lyt(),O=c.origin(),m=c.getLink(),L=c.getCollapsedLink(),E=function(t,e){return e},R=t.drawDir;d.len()&&(i=c.getLinkStartFrom(),n=c.getLinkEndTo(),r=c.getLinkUnselected(),(i||n)&&d.forEach(function(t){p.linksOf(t).forEach(function(e){e.getFrom()==t&&i&&(s=s||new g.Arr).push(e),e.getTo()==t&&n&&(h=h||new g.Arr).push(e)})}),(s||h||r)&&(E=function(t,e){return s&&s.has(t)?e=o(i,e):h&&h.has(t)?e=o(n,e):r&&(e=o(r,e)),e})),t.drawDir=function(t,e,o,i,n){function r(t,e){t&&(a=a||new Map).set(t,y.C2R(e,6,6))}var s=n.link,h=s.getCustomPath(),u=n.p||t,c=o&&s.rgCP;if(h&&(s.oSL.oFL==s&&s.oSL.oSV.orurDC==s&&(h=s.sCP(h)),u=s.cp2P(h,u[0],u[u.length-1])),s==f)for(var p,g,d,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}(f,(l=u)[0],l[l.length-1]),v=0,C=l.length;v1){for(var s=0;s<4;s++)t[s]=o(t[s]);t[2]=e(n,t[2]),t[3]=e(n,t[3])}return t}.call(this,g.HitTest.Resize(t,o,i,n,r))},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,o,i,r,s=t.e;n(s)&&(o=this.oSE.nextID(s.length),i=new Map,s.forEach(function(t,e){i.set(t.key,t.key=o[e])},this),s.forEach(function(t){u(t.parent)&&(t.parent=i.get(t.parent))},this),e=this.offP(t),s.forEach(function(t){e&&t.client&&g.ORt(t.client,e[0],e[1]),this.oSE.Add(t)},this),n(r=t.l)&&r.forEach(function(t,e){t.key=this.oSL.nextID(),t.from=i.get(t.from),t.to=i.get(t.to),this.oSL.Add(t)},this))},A.prototype.aCCP=function(){return g.EVis(this.GetCanvas())},A.prototype.Cut=function(){this.aCCP()&&(this.Copy(),this.RemoveSelection())},A.prototype.Copy=function(){if(this.aCCP()){var t=g.win.event,e=JSON.stringify(this.onCopy());h(t)?(g.SEP(t),t.clipboardData.setData("text/plain",e)):g.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 i=this.IntersectWith(t);return i&&(this.Start=o(this.Start,t.Start),this.End=e(this.End,t.End),this.Elements.push(t.Elements)),i},Object.addPrototypeOf(G.prototype,g.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)},P.prototype.IntersectRightMin=function(t,e,o){return o.clear(),this.forEach(function(i,n){if(!e||!e.has(n)){var r=g.NRt(t,i);g.EyR(r)||o.set(n,i[0]=i)},P.prototype.IntersectDownMin=function(t,e,o){return o.clear(),this.forEach(function(i,n){if(!e||!e.has(n)){var r=g.NRt(t,i);g.EyR(r)||o.set(n,i[1]0?s=c:(c=g.BOf(r)-g.TOf(a))<0&&(s=c);break;case 1:var p=g.ROf(l)-g.LOf(h);l[0]=a[0]=h[0],l[2]=p,a[2]=0,this.Intersect(l,i,u)&&(a=this.Union(u.rgO));var f=g.LOf(r)-g.ROf(a);f>0?s=f:(f=g.ROf(r)-g.LOf(a))<0&&(s=f)}if(s)switch(e){case 0:case 1:n=-s}}return n},P.prototype.Shift=function(t,e,o){var i=null;t.forEach(function(t){(i=this.get(t))&&g.ORt(i,e,o)},this)},P.orderElementRectByStart=function(t,e){return t.Start-e.Start},P.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,g.LOf(t),g.ROf(t)))},this);break;case 1:this.forEach(function(t,o){e&&!e.has(o)||i.push(new U(o,g.TOf(t),g.BOf(t)))},this)}return s(o)&&i.sort(o),i},k.prototype.GetCache=function(t){return this.oSurfaceElementsArrange.Cache.GetCache(t)},k.ToVector=function(t,e,o){return t=t.slice(),s(e)&&t.sort(function(t,i){return e.call(o,t,i)}),t},k.prototype.orderElementByOutAll=function(t,e){return this.GetCache(e).OutAll.len()-this.GetCache(t).OutAll.len()},k.prototype.showTemp=function(t){t.forEach(function(t,e){t.Caption=""+e,t.Shape={normal:{fillColor:"rgba(255,0,0,0.5)"}}},this)},k.prototype.Init=function(){if(this.Input.clear(),!this.Elements.isEmpty()){this.Elements.forEach(function(t){this.GetCache(t).collectAll(this)},this);var t=k.ToVector(this.Elements.byO(),this.orderElementByOutAll,this),e=new g.Arr;t.forEach(function(t){e.has(t)||(this.Input.add(t),e.push(this.GetCache(t).OutAll))},this)}return this},k.prototype.PreArrange=function(){this.preArrange(this.Input,this.Loc),this.getArrangeCompact()&&this.compact(),this.getArrangeAlign()&&this.align(),this.optimize()},k.toRect=function(t,e){return[t[0],t[1],e.cx,e.cy]},k.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)})},k.prototype.getArrangeCount=function(t){var e=new g.Arr;return t.forEach(function(t){e.push(t,this.GetCache(t).OutAll)},this),e.len()},k.prototype.addElementGroup=function(t,e){e.add(t);var o=this.GetCache(t).Group;o&&e.push(o)},k.prototype.nextLoc=function(t,e){switch(this.getArrangeDir()){case 0:t[1]+=e.cy;break;case 1:t[0]+=e.cx}},k.prototype.nextDown=function(t,e){switch(this.getArrangeDir()){case 0:t[0]=g.ROf(t);break;case 1:t[1]=g.BOf(t)}t[2]=e.cx,t[3]=e.cy},k.prototype.nextRight=function(t,e){switch(this.getArrangeDir()){case 0:t[0]=g.ROf(t),t[2]=e[2],t[1]=e[1],t[3]=e[3];break;case 1:t[1]=g.BOf(t),t[3]=e[3],t[0]=e[0],t[2]=e[2]}},k.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},k.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,k.toRect(o,i),e),this.nextLoc(o,i)}},this);var i=e.union();return{cx:i[2],cy:i[3]}},k.prototype.preArrange=function(t,e){e.clear();if(u(C=t.first())){var o=new g.Arr,i=new g.Arr;for(this.setArrangeLoc(C,k.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),h=this.getArrangeDir(),l=!0;l;){l=!1;for(var a=0;a1){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 u(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()||!c(t)&&!(e=this.oSE.Item(t))||(this.onArranging(),this.Cache.Collect(e),this.Cache.PreArrange(),this.Cache.DoArrange(),this.onArrange())},g.expO({Count:null},t.prototype),g.expO(g.Mrg({Options:null,Index:null,Position:null},g.Surface.ElementOptions),a.prototype),g.expO({Count:null},O.prototype),g.expO(g.Mrg({Options:null,Index:null},g.Surface.LinkOptions),m.prototype),{Elements:t,Element:a,Links:O,Link:m,SV:A,CSurfaceElementsArrange:I}}()),g.Mrg(g.Surface.SV,function(){function t(t){this.oSV=t,this.rgVO=new g.M1,this.mP2O=new Map,this.rtLayout=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