/* @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 p.Arr}function n(t){return t instanceof Function}function s(t){return t instanceof c.Element}function r(t){return t instanceof c.Pool}function h(t){return t instanceof c.PoolHeader}function l(t){return t instanceof c.PoolSplitter}function a(){return Math.max.apply(0,arguments)}var p=p||window.exontrol,u=p.G,c=p.Surface,f=c.prototype,g=c.SV,d=p.UR,S=p.Def.UR.Surface;p.Swimlane=c,p.Mrg(S,{AddPool:"AddPool",RemovePool:"RemovePool",MovePool:"MovePool",UpdatePool:"UpdatePool"}),c.Options.spools=null,f.exports=function(t){return function(){t.apply(this,arguments);var e=this.oSV;null!=e&&["GetPools"].forEach(function(t){t in this||(this[t]=e[t].bind(e))},this)}}(f.exports),f.GetStatistics=function(t){function e(t,e){return p.Format(t,e||0)}return function(){var o=t.apply(this,arguments),i=this.oSV,n=o.indexOf("\nElement:");return o.slice(0,n)+"\nPool: "+e(i.Lyt().lPools())+"/"+e(i.oSP.GetCount())+o.slice(n)}}(f.GetStatistics),p.expO({statistics:null},f,null,!0),f.defAA=function(){return"fit(Shift+MButton,Ctrl+MButton,Alt+MButton),zoom(MButton),select(Shift,Ctrl),link(Alt)[toggle],create[pool](Ctrl+Alt),create[element](Alt),move,resize-header,resize-lane,resize-phase,scroll"},f.roAA=function(){return"scroll,zoom,fit,select"},Object.defineProperty(f,"Pools",{get:function(){return this.GetPools()}}),f.Pool=function(t){return this.oSV.oSP.Item(t)},f.Lane=function(t,e){var o=this.oSV.oSP.Item(t);return o&&o.Lane(e)},f.Phase=function(t,e){var o=this.oSV.oSP.Item(t);return o&&o.Phase(e)},g.prototype.iObj=function(t){return function(){t.apply(this,arguments),this.oSP=new c.Pools(this)}}(g.prototype.iObj),g.prototype.onRurClick=function(t){return function(e){!r(e)&&t.apply(this,arguments)}}(g.prototype.onRurClick),g.prototype.onAddPool=function(t){this.onRL()},g.prototype.onDelPool=function(t){this.onRL()},g.prototype.onMovePool=function(t,e){},g.prototype.defShp=function(t){return function(){return"Border(pool,lane,phase),Button(header),"+t.apply(this,arguments)}}(g.prototype.defShp),g.prototype.defCrs=function(t){return function(){return t.apply(this,arguments)}}(g.prototype.defCrs),g.prototype.drawS=function(t){return function(e,o){if(0==o){var i=this.Lyt().lPools();this.drawO(e,0,i),this.drawL(e),this.drawO(e,i),this.drawLCP(e)}else t.call(this,e,o)}}(g.prototype.drawS),g.prototype.allowResizeCursor=function(t){return function(e){return h(e)?this.gAA().Has("resize-header",e):l(e)&&"lanes"in e?this.gAA().Has("resize-lane",e):l(e)&&"phases"in e?this.gAA().Has("resize-phase",e):t.call(this,e)}}(g.prototype.allowResizeCursor),g.prototype.rurActionExtra=function(t){return function(e,o){function i(t,e){var o;e?o=n:n||(o=n=!n),o&&this.onRURPool(t,e)}t.call(this,e,o);var n,s=this.p2HT(this.gPtr(e)),r=this.isC();if(s)switch(o.rurName){case"resize-header":if(h(s.o)){var a=s.o,c=this.getShape("frameDrag"),f=a.ht(),g=a.getClient(),y=a.size,d=new p.M1;if(a.pool.getMoveObj().forEach(function(t){d.set(t,t.getClient())}),o.rurAllowUpdateScrollRange=!0,c){E=null;p.EyO(c)&&(c=null);function S(t,e,o,i){E=E||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(){c?e.drawShape(n,c.normal||c):a?a.drawHeader(e,n):e.drawFrameRect(n)},this)}o.rurEFPaint=S,o.rurEFOpts=function(t,e){e.visible=!1},o.rurDrag=function(t){null!=E&&E.SetVisible(t.from!=t.to);var e=t.to.x-t.from.x,i=t.to.y-t.from.y;t.frame=this.htR(f,e,r?-i:i,g,[0,0]),r&&(t.frame[1]+=i),null==o.rurEFPaint&&S.call(this,t,this.gCtx(),this.rtCA(t.frame,!1))},o.rurDrop=function(t){i.call(this,a.pool,0);var e=t.to.x-t.from.x,o=t.to.y-t.from.y,n=this.htR(f,e,r?-o:o,g,[0,0]);this.Smooth(function(){this.bU(),a.setClient(n,y,d),this.eU()},this),i.call(this,a.pool,1)}}else o.rurDrag=function(t){i.call(this,a.pool,0);var e=t.to.x-t.from.x,o=t.to.y-t.from.y,n=this.htR(f,e,r?-o:o,g,[0,0]);this.bU(),a.setClient(n,y,d),this.eU()},o.rurDrop=function(t){i.call(this,a.pool,1)},o.rurCancel=function(t){this.bU(),a.setClient(g,y,d),this.eU(),i.call(this,a.pool,2)};this.rurDrag(e,o)}break;case"resize-lane":if(l(s.o)&&"lanes"in s.o){var C=s.o,f=s.ht,P=C.pool,c=this.getShape("frameDrag"),v=P.getClient(),R=P.getLanesRect(v),g=C.lanes.getClient(C.index,R);if(o.rurAllowUpdateScrollRange=!0,c){E=null;p.EyO(c)&&(c=null);function S(t,e,o,i){E=E||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(){c?e.drawShape(n,c.normal||c):e.drawFrameRect(n)},this)}o.rurEFPaint=S,o.rurEFOpts=function(t,e){e.visible=!1},o.rurDrag=function(t){null!=E&&E.SetVisible(t.from!=t.to);var e=t.to.x-t.from.x,i=t.to.y-t.from.y;t.frame=this.htR(f,e,r?-i:i,g,[0,0]),r&&(t.frame[1]+=i),null==o.rurEFPaint&&S.call(this,t,this.gCtx(),this.rtCA(t.frame,!1))},o.rurDrop=function(t){if(i.call(this,P,0),this.bU(),(t.to.xp.ROf(v))&&!P.oLanes.isCreateHT(t.from.x,t.from.y,P.getLanesRect(v)))C.lanes.remove(C.index);else{var e=t.to.x-t.from.x,o=t.to.y-t.from.y,n=this.htR(f,e,r?-o:o,g,[0,0]);C.lanes.setClient(C.index,R,n)}this.eU(),i.call(this,P,1)}}else o.rurDrag=function(t){i.call(this,P,0);var e=t.to.x-t.from.x,o=t.to.y-t.from.y,n=this.htR(f,e,r?-o:o,g,[0,0]);this.bU(),C.lanes.setClient(C.index,P.getLanesRect(P.getClient()),n),this.eU()},o.rurDrop=function(t){var o=this.ptCA(this.gPtr(e),!0);P.oLanes.isCreateHT(u.X(o),u.Y(o),P.getLanesRect(P.getClient()))||(t.to.xp.ROf(v))&&(this.bU(),C.lanes.remove(C.index),this.eU()),i.call(this,P,1)},o.rurCancel=function(t){this.bU(),C.lanes.setClient(C.index,P.getLanesRect(P.getClient()),g),this.eU(),i.call(this,P,2)};this.rurDrag(e,o)}break;case"resize-phase":if(l(s.o)&&"phases"in s.o){var b=s.o,f=s.ht,P=b.pool,c=this.getShape("frameDrag"),v=P.getClient(),m=P.getPhasesRect(v),g=b.phases.getClient(b.index,m);if(o.rurAllowUpdateScrollRange=!0,c){var E=null;p.EyO(c)&&(c=null);function S(t,e,o,i){E=E||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(){c?e.drawShape(n,c.normal||c):e.drawFrameRect(n)},this)}o.rurEFPaint=S,o.rurEFOpts=function(t,e){e.visible=!1},o.rurDrag=function(t){null!=E&&E.SetVisible(t.from!=t.to),t.frame=this.htR(f,t.to.x-t.from.x,t.to.y-t.from.y,g,[0,0]),null==o.rurEFPaint&&S.call(this,t,this.gCtx(),this.rtCA(t.frame,!1))},o.rurDrop=function(t){if(i.call(this,P,0),this.bU(),(t.to.yp.BOf(v))&&!P.oPhases.isCreateHT(t.from.x,t.from.y,P.getPhasesRect(v)))b.phases.remove(b.index,m,n);else{var e=t.to.x-t.from.x,o=t.to.y-t.from.y,n=this.htR(f,e,o,g,[0,0]);b.phases.setClient(b.index,m,n)}this.eU(),i.call(this,P,1)}}else o.rurDrag=function(t){i.call(this,P,0);var e=t.to.x-t.from.x,o=t.to.y-t.from.y,n=this.htR(f,e,o,g,[0,0]);this.bU(),b.phases.setClient(b.index,P.getPhasesRect(P.getClient()),n),this.eU()},o.rurDrop=function(t){var o=this.ptCA(this.gPtr(e),!0);P.oPhases.isCreateHT(u.X(o),u.Y(o),P.getPhasesRect(P.getClient()))||(t.to.yp.BOf(v))&&(this.bU(),b.phases.remove(b.index),this.eU()),i.call(this,P,1)},o.rurCancel=function(t){this.bU(),b.phases.setClient(b.index,P.getPhasesRect(P.getClient()),g),this.eU(),i.call(this,P,2)};this.rurDrag(e,o)}}}}(g.prototype.rurActionExtra),g.prototype.onRURApplyClient=function(t){return function(e,o,i){return t.call(this,e,o,i||r(e))}}(g.prototype.onRURApplyClient),g.prototype.onRURResize=function(t){return function(e,o,i){if(t.apply(this,arguments),r(e)&&o instanceof p.M1){var n=e,s=o.get(n),h=n.getClient(),l=this.getExpandGlyphSize();if(s&&h){var a=this.Lyt(),u=s[2]?h[2]/s[2]:null,c=s[3]?h[3]/s[3]:null;o.forEach(function(t,e){if(e!=n){var o,r=t.slice();null!=u&&(r[0]=h[0]+u*(t[0]-s[0])),null!=c&&(r[1]=h[1]+c*(t[1]-s[1])),i?(r=a.r2C(r),i.set(e,r),l>0&&i.get(o=e.getExpandGlyph())&&i.set(o,g.Layout.expandGlyphRect(r,l))):e.SetClient(r)}},this)}}}}(g.prototype.onRURResize),g.prototype.onRURChange=function(t){return function(e,o){t.apply(this,arguments),o?o.forEach(function(t,e){r(e)&&(p.EqR(e.getClient(),t)||this.onMovePool(e,t))},this):r(e)&&this.onAddPool(e)}}(g.prototype.onRURChange),g.prototype.onRURDragStart=function(t){return function(e,o){if(t.call(this,e,o),!this.orurDC)switch(e){case"resize-header":case"resize-lane":case"resize-phase":var i=this.p2HT(this.gPtr(o));i&&(this.orurDC=i.o.pool)}}}(g.prototype.onRURDragStart),g.prototype.onRURCreate=function(t){return function(o,i){if(i&&void 0!==i.get("pool")){var n,s=this.onAddPool;return this.onAddPool=e,n=this.oSP.Create(o),this.onAddPool=s,n}if(!i||void 0!==i.get("element"))return t.call(this,o,i)}}(g.prototype.onRURCreate),g.prototype.onRURPool=function(t,e){},g.prototype.rurAllowMove=(g.prototype.rurAllowMove,function(t,e){var o=s(t),i=r(t);return!(!o&&!i)&&(!e||void 0!==e.get("pool")&&i||void 0!==e.get("element")&&o)}),g.prototype.p2E=function(t){var e=this.ptCA(t,!0),o=u.X(e),i=u.Y(e);return this.Lyt().rgVO.rforEachU(function(t,e){return s(e)&&p.PInR(o,i,t)&&e||null})},g.prototype.p2P=function(t){var e=this.ptCA(t,!0),o=u.X(e),i=u.Y(e);return this.Lyt().rgVO.rforEachU(function(t,e){return r(e)&&p.PInR(o,i,t)&&e||null})},g.prototype.p2LP=function(t){var e=this.p2P(t);return e&&e.p2LP(this.ptCA(t,!0))},g.prototype.toClick=function(t){return function(e,o){t.apply(this,arguments);var i=this.gPtr(e),n=this.p2LP(i);o.pool=this.p2P(i),o.lane=n&&n.l||null,o.phase=n&&n.p||null}}(g.prototype.toClick),g.prototype.getChange=function(t){return function(e,o){var i=t.call(this,e,o);return i.element=s(o)?o:null,i.pool=r(o)?o:null,i}}(g.prototype.getChange),g.prototype.getMoveObj=function(t){return function(e,o){var i=t.call(this,e,o);return r(e)&&(i=e.getMoveObj()),i}}(g.prototype.getMoveObj),g.prototype.Clear=function(t){return function(){this.bU(),t.apply(this,arguments),this.oSP.Clear(),this.eU()}}(g.prototype.Clear),g.prototype.toObjs=function(t){var e=null;if(null!=t)if(t==this.oSE)e=this.oSE.rgE.rgE;else if(t==this.oSP)e=this.oSP.rgP.rgE;else{e=new p.Arr;var n=this.oSE.Item(t)||this.oSP.Item(t);null!=n?e.add(n):(o(t)||i(t))&&t.forEach(function(t){(t=this.oSE.Item(t)||this.oSP.Item(t))&&e.add(t)},this),e=e.byO()}return e},g.prototype.GetPools=function(){return this.oSP},g.prototype.GetSpools=function(){return this.oSP.Save()},g.prototype.SetSpools=function(t){this.oSP.Load(t)},g.prototype.nAA=function(t){return function(){var e=t.apply(this,arguments);return e.Has=function(t){return function(e,o){var i=t.call(this,e,o);if(i&&o&&n(o.getType)){i=!1;for(var s=o.getType(),r=0,h=this.rgA.length;!i&&r1&&t!=e-1&&this.SetPosition(e-1),t},e.prototype.BringForward=function(){var t=this.GetPosition(),e=this.oSP.GetCount();return e>1&&t+11&&t>0&&this.SetPosition(0),t},e.prototype.SendBackward=function(){var t=this.GetPosition();return this.oSP.GetCount()>1&&t>0&&this.SetPosition(t-1),t},e.prototype.GetKey=function(){return this.oO.key},e.prototype.SetKey=function(t){this.bU(),this.oSP.resK2I(),this.oO.key=t,this.eU()},e.prototype.getKey=function(){return p.ToS(this.GetKey(),"")},e.prototype.GetVisible=function(){return this.oO.visible},e.prototype.SetVisible=function(t){this.bU(),this.oO.visible=t,this.eU(!0)},e.prototype.getVisible=function(){return null==this.GetVisible()||this.GetVisible()},e.prototype.isVisible=function(){return!!this.getVisible()&&(null==this.oP||this.oP.isVisible())},e.prototype.isVisible=function(){return this.GetVisible()||null==this.GetVisible()},e.prototype.GetEnabled=function(){return this.oO.enabled},e.prototype.SetEnabled=function(t){this.bU(),this.oO.enabled=t,this.eU()},e.prototype.getEnabled=function(){return null==this.GetEnabled()||this.GetEnabled()},e.prototype.isEnabled=function(){return!!this.getEnabled()&&(null==this.oP||this.oP.isEnabled())},e.prototype.p2HT=function(t){var e=this.getClient(),o=this.oLanes.p2HT(t,this.getLanesRect(e));if(!o&&!(o=this.oPhases.p2HT(t,this.getPhasesRect(e))))for(var i=this.rgHeaders.length,n=i-1;!o&&n>=0;n--)o=this.rgHeaders[n].p2HT(t,e);return o},e.prototype.LP=function(t,e,o){o=o||this;var i,n=this.getClient(),s=e&&this.oPhases.forEach(this.getPhasesRect(n),function(t,i){return e.call(o,t,i)}),r=t&&this.oLanes.forEach(this.getLanesRect(n),function(e,i){return t.call(o,e,i)});return r&&((i=i||{}).l=r),s&&((i=i||{}).p=s),i},e.prototype.toLP=function(t,e){function o(t,e){var o=-1;return null==t?o=-1:p.IsS(t)||p.IsS(t.c)?(t=t.caption||t,e.forEach(function(e){e.caption==t&&(o=e.index)})):o=p.ToI(t.index,~~t),o}var i=this.oLanes.getSplitters(),n=this.oPhases.getSplitters(),s=o(t,i),r=o(e,n);return this.LP(function(t,e){return e.index==s&&(e.client=t)&&e},function(t,e){return e.index==r&&(e.client=t)&&e})},e.prototype.p2LP=function(t){var e=u.X(t),o=u.Y(t);return this.LP(function(t,e){return o>=t[1]&&o=t[0]&&ee&&t.push(n.getMoveObj()))},this),t.byO()},e.prototype.GetHeaders=function(){var t=[];return this.rgHeaders.forEach(function(e){t.push(e.save())}),p.B.quoteS(t)},e.prototype.SetHeaders=function(t){this.bU(),this.oO.headers=t,this.rgHeaders=[],null==t&&(t="left,right,top,bottom");var e=new p.Arr;p.B.split(t).forEach(function(t){var o=c.PoolHeader.isValid(t.caption);if(o&&!e.has(o)){e.add(o);var i=new c.PoolHeader(this,o);i.load(t.flags),this.rgHeaders.push(i)}},this),this.eU(!0)},e.prototype.GetExcludeHeaders=function(){return this.oO.excludeHeaders},e.prototype.SetExcludeHeaders=function(t){this.bU(),this.oO.excludeHeaders=t,this.eU(!0)},e.prototype.getExcludeHeaders=function(){return null==this.GetExcludeHeaders()||this.GetExcludeHeaders()},e.prototype.GetLanes=function(){return this.oLanes.save()},e.prototype.SetLanes=function(t){this.bU(),this.oLanes.load(this.oO.lanes=t),this.eU(!0)},e.prototype.GetPhases=function(){return this.oPhases.save()},e.prototype.SetPhases=function(t){this.bU(),this.oPhases.load(this.oO.phases=t),this.eU(!0)},e.prototype.yA2C=function(t,e){return this.getView().isC()&&(t=2*(e=this.getClient())[1]+e[3]-t),t},e.prototype.Lane=function(t){return this.toLP(t).l},e.prototype.Phase=function(t){return this.toLP(null,t).p},e.prototype.genID=function(){var t=this.GetKey();return null==t&&this.SetKey(t=function(){var t=this.oSP,e=this.getKey();return e&&t.Item(e)==this||(e=t.nextID()),e}.call(this)),t},e.prototype.coO=function(){var t=p.Cpy(this.oO);return t.headers=this.GetHeaders(),t.lanes=this.GetLanes(),t.phases=this.GetPhases(),t},d&&(e.prototype.scUR=function(t){t.o=this.oSP,t.i=this.genID()},e.prototype.arUR=function(t){this.scUR(t),t.d=this.coO(),t.Do=function(t){(this.del?!t:t)?this.o.Remove(this.i):this.o.Add(this.d).EnsureVisible()}},e.prototype.mvUR=function(t,e){e&&(this.scUR(t,!0),t.d={from:p.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())})},e.prototype.uUR=function(t,e,o){this.scUR(t,!0),(t.d=d.diff(e,o))&&(t.Do=function(t){var e=this.o.Item(this.i);e&&(e.SetOptions(t?this.d.from:this.d.to),e.EnsureVisible())})},e.prototype.StartUpdatePool=function(){if(this.getView().gUR()){var t=[];return this.getMoveObj().forEach(function(e){t.push(function(t){return{o:t,coO:t==this?t.coO():t.suo()}}.call(this,e))},this),t}},e.prototype.suo=e.prototype.StartUpdatePool,e.prototype.EndUpdatePool=function(t){t&&(o(t)?t.forEach(function(t){t.o.euo(t.coO)}):this.getView().nUR(S.UpdatePool,function(e){this.uUR(e,t,this.coO())},this))},e.prototype.euo=e.prototype.EndUpdatePool,e.prototype.UpdatePool=function(t,e){if(n(t)){var o=this.StartUpdatePool();t.call(e||this),this.EndUpdatePool(o)}}),h.prototype.isVisible=function(){return this.size>0},h.prototype.getClient=function(t){var e=!t&&this.pool.getView().isC(),o=(t=t||this.pool.getClient()).slice(),i=this.size,n=this.type;switch(e&&("top"==n?n="bottom":"bottom"==n&&(n="top")),n){case"left":o[2]=i;break;case"right":o[0]=p.ROf(o)-(o[2]=i);break;case"top":o[3]=i;break;case"bottom":o[1]=p.BOf(o)-(o[3]=i)}return o},h.prototype.setClient=function(t,e,o){function i(){this.size=t[2]}function n(){this.size=t[3],this.pool.getView().isC()&&(s[1]-=h,h=-h)}var s,r=0,h=0;switch(null==e&&(e=this.size),o&&(s=o.get(this.pool))&&(s=s.slice()),this.type){case"left":r=t[2]-e,s&&(s[2]=a(0,s[2]+r)),i.call(this);break;case"right":r=e-t[2],s&&(s[0]+=r,s[2]=a(0,s[2]-r)),i.call(this);break;case"top":h=t[3]-e,s&&(s[3]=a(0,s[3]+h)),n.call(this);break;case"bottom":h=e-t[3],s&&(s[1]+=h,s[3]=a(0,s[3]-h)),n.call(this)}o&&o.forEach(function(t,e){e.SetClient(e==this.pool?s:p.ORt(t.slice(),r,h))},this)},h.prototype.inflateHT=function(){return 24},h.prototype.getHTClient=function(t){var e=(t=t||this.pool.getClient()).slice(),o=this.size,i=this.inflateHT();switch(this.type){case"left":e[0]+=o,e[2]=0,p.IRt(e,0,i);break;case"right":e[0]=p.ROf(e)-o,e[2]=0,p.IRt(e,0,i);break;case"top":e[1]+=o,e[3]=0,p.IRt(e,i,0);break;case"bottom":e[1]=p.BOf(e)-o,e[3]=0,p.IRt(e,i,0)}return e},h.prototype.getType=function(){return this.type},h.isValid=function(t){var e=null;if(t)switch(t=t.toString().trim().toLowerCase()){case"left":case"right":case"top":case"bottom":e=t}return e},h.prototype.getShapeType=function(){return"header"},h.prototype.allowResize=function(){return this.pool.getView().gAA().Has("resize-header",this)},h.prototype.getResizeHT=function(t){t=t||this.pool.getClient();var e=this.getHTClient(t),o=this.inflateHT(),i=null,n=null;switch(this.type){case"left":case"right":(i=e.slice())[3]=o,(n=e.slice())[1]=p.BOf(n)-(n[3]=o);break;case"top":case"bottom":(i=e.slice())[2]=o,(n=e.slice())[0]=p.ROf(n)-(n[2]=o)}return i&&n?[i,n]:[]},h.prototype.ht=function(){var t=0;switch(this.type){case"left":t=36;break;case"right":t=33;break;case"top":t=66;break;case"bottom":t=18}return t},h.prototype.p2HT=function(t,e){var o=null;if(this.allowResize()){for(var i=!1,n=u.X(t),s=this.pool.yA2C(u.Y(t),e),r=this.getResizeHT(e),h=r.length-1;!i&&h>=0;h--)i=p.PInfR(n,s,r[h]);i||this.isVisible()&&(i=p.PInfR(n,s,this.getHTClient(e))),i&&(o={o:this,ht:this.ht()})}return o},h.prototype.inflateRect=function(t){if(this.isVisible())switch(this.type){case"left":t[0]-=this.size,t[2]+=this.size;break;case"right":t[2]+=this.size;break;case"top":t[1]-=this.size,t[3]+=this.size;break;case"bottom":t[3]+=this.size}return t},h.drawResizeHT=function(t,e,o,i){t.save(),t.setLineDash([2,2]),t.drawLine(e,o,i||"rgba(0,0,0,0.25)"),t.restore()},h.prototype.drawResizeHT=function(t,e){this.getResizeHT(e).forEach(function(e){h.drawResizeHT(t,u.R2C(e,17),u.R2C(e,68))})},h.prototype.getCreateLPHT=function(t,e){var o=null;if(t&&this.isVisible()){var i=p.Def.HT.inflate[0],n=p.Def.HT.inflate[1];switch(this.type){case"left":this.pool.oLanes.allowCreate()&&(o=[p.LOf(t)+4,p.BOf(t)-n,a(0,this.size-8),e?2*n:0]);break;case"right":this.pool.oLanes.allowCreate()&&(o=[p.ROf(t)-(this.size-4),p.BOf(t)-n,a(0,this.size-8),e?2*n:0]);break;case"top":this.pool.oPhases.allowCreate()&&(o=[p.ROf(t)-i,p.TOf(t)+4,e?2*i:0,a(0,this.size-8)]);break;case"bottom":this.pool.oPhases.allowCreate()&&(o=[p.ROf(t)-i,p.BOf(t)-(this.size-4),e?2*i:0,a(0,this.size-8)])}}return o},h.prototype.drawCreateLPHT=function(t,e){var o=this.pool.getView().getVO().get(this.pool);if(o){switch(this.type){case"left":case"right":e=p.NRt(e,this.pool.getLanesRect(o));break;case"top":case"bottom":e=p.NRt(e,this.pool.getPhasesRect(o))}var i=this.getCreateLPHT(e);i&&h.drawResizeHT(t,u.R2C(i,17),u.R2C(i,68),"rgba(0,0,0,0.5)")}},h.prototype.draw=function(t,e){var o=this.getClient(e),i=this.allowResize();this.isVisible(),this.isVisible()&&(this.drawHeader(t,o),i&&this.drawCreateLPHT(t,o)),i&&this.drawResizeHT(t,e)},h.prototype.GetShape=function(){return this.shape},h.prototype.getShape=function(){return this.pool.getView().getShape(this)},h.prototype.drawHeader=function(t,e){var o=this.getShape();o&&t.drawShape(e,o.normal||o),this.drawHeaderCaps(t,e)},h.prototype.drawHeaderCaps=function(t,e){var o=this.pool.getView(),i=null,n=null,s=null,r=null;switch(this.type){case"left":case"right":n=o.getShape("lane"),i=this.pool.oLanes,s=this.pool.getLanesRect(e);break;case"top":case"bottom":n=o.getShape("phase"),i=this.pool.oPhases,s=this.pool.getPhasesRect(e)}i&&(r=i.gCnt(s))&&r.rgSplitters.forEach(function(e){var h=r.rgSize[e.index];if(h){i.init(s,h);var l=p.DrawTextFormatEnum.exTextAlignCenter|p.DrawTextFormatEnum.exTextAlignVCenter|p.DrawTextFormatEnum.exTextWordEllipsis,a=o.getShape(e.shape)||n;null!=a&&(a=a.normal||a)&&null!=a.formatText&&(l=a.formatText),t.drawHTMLText(e.caption,s,l),i.next(s,h)}})},h.prototype.save=function(){var t=new Map;return this.isVisible()&&t.set("size",this.size),p.IsS(this.shape)&&t.set("shape",this.shape),p.B.quoteC(this.type)+p.B.quoteF(t)},h.prototype.load=function(t){if(t instanceof Map){var e=t.get("size");this.size=null!=e?p.ToN(e):0,e=t.get("shape"),this.shape=null!=e?p.ToS(e):null}},l.prototype.GetIndex=function(){return this.index},l.prototype.GetCaption=function(){return this.caption},l.prototype.SetCaption=function(t){this.caption=t;var e=this.phases||this.lanes;e&&e.save(e.oContent,!1)},l.prototype.GetSize=function(){var t=this.getClient();return t&&t[this.phases?2:3]},l.prototype.SetSize=function(t){var e,o=this.phases||this.lanes;this.pool&&o&&(e=this.getClient())&&(e[this.phases?2:3]=a(0,t),o.setClient(this.index,this.pool[this.phases?"getPhasesRect":"getLanesRect"].call(this.pool,this.pool.getClient()),e),o.save(o.oContent,!1))},l.prototype.getClient=function(){return(this.phases||this.lanes).forEach(this.pool[this.phases?"getPhasesRect":"getLanesRect"].call(this.pool,this.pool.getClient()),function(t,e){return e==this&&t},this)},l.prototype.GetShape=function(){return this.shape},l.prototype.SetShape=function(t){this.shape=t;var e=this.phases||this.lanes;e&&e.save(e.oContent,!1)},p.expO({Index:null,Caption:null,Size:null,Shape:null},l.prototype),f.prototype.getType=function(){return this.h?"phases":"lanes"},f.prototype.allowResize=function(){return this.pool.getView().gAA().Has(this.h?"resize-phase":"resize-lane",this)},f.prototype.allowCreate=function(){return this.allowResize()},f.prototype.genCaption=function(t){return t=t||0,this.h?String.fromCharCode(t+"A".charCodeAt(0)):(t+1).toString()},f.prototype.genSplitterOpts=function(t,e,o,i){var n={pool:this.pool,caption:t,size:e,shape:o,index:i};return n[this.getType()]=this,n},f.prototype.onCreate=function(t){t=t||0;var e=this.genSplitterOpts(this.genCaption(t),t?0:null,null,t),o=this.pool.oSP,i=o[this.h?"OnCreatePhase":"OnCreateLane"];return n(i)&&i.call(o,e)&&(e=null),e},f.prototype.getSplitters=function(){function t(t,o,i){var n=new l(this.genSplitterOpts(t,o,i,e.length));return e.push(n),n}var e=[],o=null;if(p.B.split(this.content||this.genCaption(0)).forEach(function(e){var i=e.flags?e.flags.get("size"):null,n=e.flags?e.flags.get("shape"):null;o=t.call(this,e.caption,null!=i?a(0,p.ToN(i)):null,n)},this),this.allowCreate()&&(!o||0!==o.size)){var i=this.onCreate(e.length);i&&t.call(this,i.caption,e.length?0:null,i.shape)}return e},f.prototype.getSize=function(t){return t[this.h?p.w:p.h]},f.prototype.gCnt=function(t){if(!this.oContent||this.oContent.size!=this.getSize(t)){var e=this.getSize(t),o=0,i=0,n=0,s=0,r=this.getSplitters(),h=[];if(o=r.length)if(r.forEach(function(t){null==t.size?i++:n+=t.size}),i||n){var l=100,s=0;(!i||n>100)&&(l=n),n<100&&(s=(100-n)*e/100/i),r.forEach(function(t){h.push(null==t.size?s:t.size*e/l)})}else for(var a=0;a=0;s--)i=p.PInR(t,e,this.pool.rgHeaders[s].getCreateLPHT(o,!0));return i},f.prototype.p2HT=function(t,e,o){var i=null,n=u.X(t),s=this.pool.yA2C(u.Y(t),e),r=this.isCreateHT(n,s,e);if(r||p.PInR(n,s,e)){var h=o?34:this.h?4:64,l=o?0:this.h?p.Def.HT.inflate[0]:0,a=o?0:this.h?0:p.Def.HT.inflate[1],c=null;if(this.forEach(e,function(t,e){var o=p.P2HT(n,s,p.IRt(t.slice(),l,a),2*l,2*a);if(o&&(h==(o&h)||p.EyR(t)))return c=t,i={o:e,ht:h}},this),!o&&i&&c){var f=null,g=i.o.index+1,y=this.oContent.rgSize.length;for(!r&&this.allowCreate()&&y--;g=0&&!this.oContent.rgSize[o];o--);o>=0&&(e=o)}}return e},f.prototype.remove=function(t){if(this.oContent&&t>=0){var e=this.oContent.rgSplitters.length;if(t2&&t+1==e-1);if(o&&!i){var n=this.avalN0Sized(t);null!=n&&(this.oContent.rgSize[n]+=o)}if(this.oContent.rgSize.splice(t,1),this.oContent.rgSplitters.splice(t,1),this.save(this.oContent,!0),i){var s=this.pool.getClient();this.init(s,a(0,this.getSize(s)-o)),this.pool.SetClient(s)}}}},p.expO({Count:null},t.prototype),p.expO(p.Mrg({Options:null,Index:null,Position:null},c.PoolOptions),e.prototype),{Pools:t,Pool:e,PoolHeader:h,PoolSplitters:f,PoolSplitter:l}}()),g.Layout.prototype.doL=function(t){return function(){return this.oSV.oSP.forEach(function(t){t.isVisible()&&this.rgVO.set(t,this.r2C(t.getClient()))},this),g.Layout.toR(this.rgVO),t.apply(this,arguments)}}(g.Layout.prototype.doL),g.Layout.prototype.p2HT=function(t){return function(e){var o=t.call(this,e);if(!o||r(o.o)){for(var i=null,n=null,s=this.rgVO.toA(),a=this.lPools()-1;!i&&a>=0;a--)r(n=s[a])&&(i=n.p2HT(e));i&&(!o||34==o.ht||l(i.o)||h(i.o)&&i.o.size)&&(!l(i.o)||o&&n==o.o)&&(o=i)}return o}}(g.Layout.prototype.p2HT),g.Layout.prototype.lPools=function(){var t=0,e=!1;return this.rgVO.forEachU(function(o,i){return(e=r(i))&&t++,!e}),t};var C={pool:null,lane:null,phase:null};p.Mrg(c.ElementOptions,C),c.Element.prototype.GetPool=function(){var t=this.getClient(),e=this.oSE.oSV.oSP;return e&&e.rgP.rforEachU(function(e){return p.NRt(t,e.getClient())&&e})||null},c.Element.prototype.SetPool=function(t){this.Center(t,null,null)},c.Element.prototype.GetLane=function(){var t=this.GetPool(),e=t&&t.p2LP(u.R2C(this.getClient()));return e&&e.l||null},c.Element.prototype.SetLane=function(t){this.Center(null,t,null)},c.Element.prototype.GetPhase=function(){var t=this.GetPool(),e=t&&t.p2LP(u.R2C(this.getClient()));return e&&e.p||null},c.Element.prototype.SetPhase=function(t){this.Center(null,null,t)},c.Element.prototype.Center=function(t,e,o){var i,n=this.oSE.oSV.oSP,s=n&&(n.Item(t)||this.GetPool());s&&(i=this.getClient(),this.SetClient(u.C2R(u.R2C(s.clientLP(null!=e?e:this.GetLane(),null!=o?o:this.GetPhase())),i[2],i[3])))},p.expO(C,c.Element.prototype),p.Shapes.Swimlane=p.Shapes.Surface,t.Swimlane=c});