function setBodyCursor(n){$("body").css("cursor",n);document.body.style.cursor=n}function adjustPosition(n){return Math.round(n)+.5}function getViewerWin(){return WaveViewer.getManager().getViewerWindow()}function openViewerPage(n){setupLocations();new WaveViewer.ViewerPage(n)}function setupLocations(){var n=Project.LOCATION.STAGING;switch(document.domain){case"staging-www.systemvision.com":n=Project.LOCATION.STAGING;break;case"app.systemvision.com":n=Project.LOCATION.PRODUCTION;break;case"test.systemvision.com":n=Project.LOCATION.TEST}new Project.Settings(n,"1.0")}function exec(){var t,n,i,e;if(Project.Utility.startTrace("application starts"),setupLocations(),surface=new Schematic.Surface(SCHEMATIC_ID,Project.Settings.SCH_GRID_SPACING),t=new WaveViewer.ViewerWindow(VIEWER_WINDOW_ID,!0,surface),sidebar_manager=new Sidebar.Manager(t),surface.setSidebarManager(sidebar_manager),n=new Sidebar.SimulationMenu(surface,t,SIMULATION_SIDEBAR_ID),t.setSimulationSidebar(n),surface.setSimulationSidebar(n),Project.Settings.isProductionMode()||(file_sidebar=new Sidebar.FileMenu(sidebar_manager,surface,n,FILE_SIDEBAR_ID),sidebar_manager.addSidebar(file_sidebar,Sidebar.Orientation.LEFT)),!testMode){i=null;surface.isSharedDesign()||(i=jQuery.Deferred(),addLoadingAppDeferred(i));var r=Project.ComponentDataManager.SVWEB_LIB,u=new Project.ComponentDataManager(this.surface,r),f=new Sidebar.ComponentBrowser(surface,u,r,COMPONENT_BROWSER_SIDEBAR_ID,i);surface.setComponentDataManager(u);surface.setComponentBrowserSidebar(f);surface.setFileSidebar(file_sidebar);sidebar_manager.addSidebar(f,Sidebar.Orientation.LEFT)}sidebar_manager.addSidebar(n,Sidebar.Orientation.RIGHT);$(document).ready(function(){defaultLeftSidebar=testMode?FILE_SIDEBAR_ID:COMPONENT_BROWSER_SIDEBAR_ID;defaultRightSidebar=SIMULATION_SIDEBAR_ID;surface.isSharedDesign()?(sidebar_manager.hideSidebarForSession(COMPONENT_BROWSER_SIDEBAR_ID),sidebar_manager.hideSidebarForSession(FILE_SIDEBAR_ID),sidebar_manager.hideSidebarForSession(SIMULATION_SIDEBAR_ID),sidebar_manager.toggleLeftSidebarVisibility(!0),sidebar_manager.toggleRightSidebarVisibility(),$(TOGGLE_LEFT_SIDEBAR).hide(),$(TOGGLE_RIGHT_SIDEBAR).hide(),sidebar_manager.setEditingMode(surface.getEditingMode())):sidebar_manager.setInitialState(defaultLeftSidebar,defaultRightSidebar);$(window).resize(function(){sidebar_manager.resizeComponents()});$.when.apply($,loadingAppDeferredArray).done(function(){var n=!1;loadingAppDeferredArray.forEach(function(t){t.state()=="pending"&&(n=!0)});n?$.when.apply($,loadingAppDeferredArray).done(function(){finishAppInit()}):finishAppInit()})});$(MAIN_EDITOR).kendoSplitter({orientation:"vertical",panes:[{collapsible:!1},{collapsible:!0,collapsed:!0,resizable:!0,size:"30%"}],layoutChange:function(){sidebar_manager.resizeComponents(!0)}});e=new Messaging.Handler(surface,n);$(document).bind("keydown",function(n){var i=!1,t;n.keyCode===8&&(t=n.srcElement||n.target,i=t.tagName.toUpperCase()==="INPUT"&&(t.type.toUpperCase()==="TEXT"||t.type.toUpperCase()==="PASSWORD"||t.type.toUpperCase()==="FILE")||t.tagName.toUpperCase()==="TEXTAREA"?t.readOnly||t.disabled:!0);i&&n.preventDefault()})}function getSchematic(){return surface}function getFileSidebar(){return file_sidebar}function addLoadingAppDeferred(n){loadingAppDeferredArray.push(n)}function isAppLoading(){return loadingAppDeferredArray.length!=0}function showLoadingMessage(n){n&&$(LOADING_MESSAGE_TEXT).html("<h4>"+n+"<\/h4>");var t=surface.getSidebarManager();$(LOADING_CONTENT).css({top:"0px",bottom:$(VIEWER_PANE).height()+"px",left:t.getVisibleWidth(Sidebar.Orientation.LEFT)+"px",right:t.getVisibleWidth(Sidebar.Orientation.RIGHT)+"px"});$(LOADING_CONTENT).fadeIn("slow");$(LOADING_MESSAGE).fadeIn("slow");$(".intercom-container").hide()}function hideLoadingMessage(){$(LOADING_CONTENT).fadeOut("slow",function(){Messaging.Handler.sendSetFocusMessage()})}function finishAppInit(){loadingAppDeferredArray=[];hideLoadingMessage();Project.Utility.trace("hide splash",!0);surface.isSharedDesign()&&$(SCHEMATIC_PANE).height($(window).height())}function resizeIframe(n,t){n.style.height=window.innerHeight-t+"px"}function initIframe(n,t){resizeIframe(n,t);window.onresize=function(){resizeIframe(n,t)}}var BaseWire,Schematic,DesignBrowser,svw,Messaging,PATH_SEPARATOR,ProbeModule,WaveViewer,Markers,ServerStructures,Operations,Sidebar,json_parse,__extends,Dmb,Project;(function(n){var i=function(){function i(r,u){if(i.APIBASE)throw new Error("Settings Already Initialized");i.DEVELOPER_MODE=!1;switch(r){case t.LOCAL:i.APIBASE="https://localhost:44300/";i.DEVELOPER_MODE=!0;break;case t.PRODUCTION:i.APIBASE="https://api.systemvision.com/";i.PINSTYLIN="https://app.systemvision.com/bundles/pinstyle";break;case t.TEST:i.APIBASE="https://api-test.systemvision.com/";i.PINSTYLIN="https://app-test.systemvision.com/bundles/pinstyle";break;case t.STAGING:i.WEBBASE="https://stage.systemvision.com/";i.APIBASE="https://staging-api.systemvision.com/";i.DEVELOPER_MODE=!0;break;case t.DEV2:i.APIBASE="https://dev2.systemvision.com/";i.DEVELOPER_MODE=!0}i.APIVERSION=u;i.checkForViaDesigner();n.Settings.isProductionMode()&&$(document).bind("contextmenu",function(){return!1})}return i.APIURI=function(){return i.APIBASE+"api/"+i.APIVERSION},i.isSVWeb=function(){return!i.FOR_TRIAD},i.isProductionMode=function(){return!i.DEVELOPER_MODE},i.checkForViaDesigner=function(){var t,n;i.FOR_TRIAD=!1;t=$(".creds p:first");n&&(n=t.html(),n&&(i.FOR_TRIAD=n.indexOf("viadesigner.com")>-1))},i.notify=function(n,t){window.Intercom&&(t?window.Intercom("trackEvent",n,t):window.Intercom("trackEvent",n));ga&&ga("send","event","application",n)},i.notifyEventSim=function(n){ga&&ga("send","event","simulation",n)},i.WEBBASE="https://www.systemvision.com/",i.APIKEY="97814435-7337-4390-be35-86ca540f7a1b",i.PINSTYLIN="https://staging-www.systemvision.com/bundles/pinstyle",i.SCH_GRID_SPACING=10,i.DISABLE_STD_UI_MESSAGING=!1,i.FOR_TRIAD=!1,i.UUID=$.cookie("svtu"),i.DEVELOPER_MODE=!1,i}(),t;n.Settings=i,function(n){n[n.LOCAL=0]="LOCAL";n[n.PRODUCTION=1]="PRODUCTION";n[n.STAGING=2]="STAGING";n[n.DEV2=3]="DEV2";n[n.TEST=4]="TEST"}(n.LOCATION||(n.LOCATION={}));t=n.LOCATION})(Project||(Project={})),function(n){var i,e,t,l,u,r,o,h,s,f,c;(function(n){n[n.HORIZONTAL=0]="HORIZONTAL";n[n.VERTICAL=1]="VERTICAL";n[n.DIAGONAL=2]="DIAGONAL"})(n.ORIENTATION||(n.ORIENTATION={}));i=n.ORIENTATION;e=function(){function n(){}return n.toString=function(n){return n==i.HORIZONTAL?"HORIZONTAL":n==i.VERTICAL?"VERTICAL":n==i.DIAGONAL?"DIAGONAL":"UNDEFINED"},n.orthogonal=function(n){return n==i.HORIZONTAL?i.VERTICAL:n==i.VERTICAL?i.HORIZONTAL:n==i.DIAGONAL?i.DIAGONAL:-1},n}();n.Orientation=e,function(n){n[n.NORTH=0]="NORTH";n[n.SOUTH=1]="SOUTH";n[n.EAST=2]="EAST";n[n.WEST=3]="WEST";n[n.CENTER=4]="CENTER"}(n.QUADRANT||(n.QUADRANT={}));t=n.QUADRANT,function(n){n[n.NORTH=0]="NORTH";n[n.SOUTH=1]="SOUTH";n[n.EAST=2]="EAST";n[n.WEST=3]="WEST";n[n.NORTH_EAST=4]="NORTH_EAST";n[n.SOUTH_EAST=5]="SOUTH_EAST";n[n.NORTH_WEST=6]="NORTH_WEST";n[n.SOUTH_WEST=7]="SOUTH_WEST"}(n.COMPASS_POSITION||(n.COMPASS_POSITION={}));l=n.COMPASS_POSITION;u=function(){function n(){}return n.toString=function(n){return n==t.NORTH?"NORTH":n==t.SOUTH?"SOUTH":n==t.EAST?"EAST":n==t.WEST?"WEST":n==t.CENTER?"CENTER":"UNDEFINED"},n.opposite=function(n){return n==t.NORTH?t.SOUTH:n==t.SOUTH?t.NORTH:n==t.EAST?t.WEST:n==t.WEST?t.EAST:n==t.CENTER?t.CENTER:-1},n.orientation=function(n){return n==t.NORTH||n==t.SOUTH?i.VERTICAL:n==t.EAST||n==t.WEST?i.HORIZONTAL:n==t.CENTER?i.HORIZONTAL:-1},n.orthogonalOrientation=function(n){return n==t.NORTH||n==t.SOUTH?i.HORIZONTAL:n==t.EAST||n==t.WEST?i.VERTICAL:n==t.CENTER?i.VERTICAL:-1},n.rotatedQuadrant=function(n,i){switch(i){case Project.ROTATION.ROT_0:return n;case Project.ROTATION.ROT_90:switch(n){case t.NORTH:return t.EAST;case t.SOUTH:return t.WEST;case t.EAST:return t.SOUTH;case t.WEST:return t.NORTH}break;case Project.ROTATION.ROT_180:switch(n){case t.NORTH:return t.SOUTH;case t.SOUTH:return t.NORTH;case t.EAST:return t.WEST;case t.WEST:return t.EAST}break;case Project.ROTATION.ROT_270:switch(n){case t.NORTH:return t.WEST;case t.SOUTH:return t.EAST;case t.EAST:return t.NORTH;case t.WEST:return t.SOUTH}}return n},n}();n.Quadrant=u;r=function(){function n(n,t){this.x=n;this.y=t}return n.prototype.clone=function(){return new n(this.x,this.y)},n.prototype.toString=function(){return this.x+","+this.y},n.prototype.isEqual=function(n){return this.x==n.x&&this.y==n.y?!0:!1},n.prototype.isAlmostEqual=function(n,t){return t==null&&(t=1e-5),Math.abs(this.x-n.x)<t&&Math.abs(this.y-n.y)<t?!0:!1},n.prototype.isDiagonal=function(n){return this.x==n.x||this.y==n.y?!1:!0},n.prototype.distance=function(n){if(this.x==n.x)return Math.abs(this.y-n.y);if(this.y==n.y)return Math.abs(this.x-n.x);var t=Math.pow(this.x-n.x,2),i=Math.pow(this.y-n.y,2);return Math.sqrt(t+i)},n.prototype.isNorthOf=function(n){return n.y>this.y?!0:!1},n.prototype.isSouthOf=function(n){return!this.isNorthOf(n)},n.prototype.isWestOf=function(n){return n.x>this.x?!0:!1},n.prototype.isEastOf=function(n){return!this.isWestOf(n)},n.prototype.quadrant=function(n){if(this.x==n.x&&this.y==n.y)return t.CENTER;var i=n.x-this.x,r=n.y-this.y;return Math.abs(i)<=Math.abs(r)?r<=0?t.NORTH:t.SOUTH:i>=0?t.EAST:t.WEST},n.prototype.placeOnGrid=function(n){this.x=this.toGrid(this.x,n);this.y=this.toGrid(this.y,n)},n.prototype.placeXOnGrid=function(n){this.x=this.toGrid(this.x,n)},n.prototype.placeYOnGrid=function(n){this.y=this.toGrid(this.y,n)},n.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y)},n.prototype.isInteger=function(){var n=this.clone();return n.round(),n.isEqual(this)?!0:!1},n.prototype.isAlmostInteger=function(n){var t=this.clone();return t.round(),t.isAlmostEqual(this,n)?!0:!1},n.prototype.add=function(n,t){this.addOrSubtract(!0,n,t)},n.prototype.subtract=function(n,t){this.addOrSubtract(!1,n,t)},n.prototype.scale=function(n){this.x*=n;this.y*=n},n.prototype.isInsideBox=function(n,t,i,r){return n<=this.x&&this.x<=i&&t<=this.y&&this.y<=r?!0:!1},n.prototype.addOrSubtract=function(t,i,r){var u,f,e;i instanceof n?(e=i,u=e.x,f=e.y):(u=i,f=r);t?(this.x+=u,this.y+=f):(this.x-=u,this.y-=f)},n.prototype.getTransform=function(n){var t=n.x-this.x,i=n.y-this.y;return"T"+t+","+i},n.prototype.dump=function(n,t){t?Project.Utility.dump(n,t+" x = "+this.x+", y = "+this.y):Project.Utility.dump(n,"x = "+this.x+", y = "+this.y)},n.prototype.toGrid=function(n,t){var i=n%t,r=t/2;return i<r?n-i:n-i+t},n}();n.Point=r;o=function(){function n(n,t){this.point1=n.clone();this.point2=t.clone()}return n.prototype.clone=function(){return new n(this.point1.clone(),this.point2.clone())},n.prototype.toPath=function(){return"M"+this.point1.toString()+"L"+this.point2.toString()},n.prototype.extendPath=function(n){return this.point1.isAlmostEqual(n)?"L"+this.point2.toString():"L"+this.point1.toString()+"L"+this.point2.toString()},n.prototype.getOrient=function(){return this.isHorizontal()?i.HORIZONTAL:this.isVertical()?i.VERTICAL:i.DIAGONAL},n.prototype.isEqual=function(n){return this.point1.isEqual(n.point1)&&this.point2.isEqual(n.point2)},n.prototype.isDiagonal=function(){return this.point1.isDiagonal(this.point2)},n.prototype.isHorizontal=function(){return this.point1.y==this.point2.y},n.prototype.isVertical=function(){return this.point1.x==this.point2.x},n.prototype.isExtension=function(n){return this.isZeroLength()||n.isZeroLength()?!1:this.isDiagonal()||n.isDiagonal()?!1:this.getOrient()==n.getOrient()&&this.point2.isEqual(n.point1)?!0:!1},n.prototype.contains=function(n){return this.isHorizontal()?n.y!=this.point1.y?!1:this.point1.x<=n.x&&n.x<=this.point2.x||this.point2.x<=n.x&&n.x<=this.point1.x?!0:!1:this.isVertical()?n.x!=this.point1.x?!1:this.point1.y<=n.y&&n.y<=this.point2.y||this.point2.y<=n.y&&n.y<=this.point1.y?!0:!1:!1},n.prototype.length=function(){return this.point1.distance(this.point2)},n.prototype.isZeroLength=function(){return this.point1.isAlmostEqual(this.point2)?!0:!1},n.prototype.placeOnGrid=function(n){this.point1.placeOnGrid(n);this.point2.placeOnGrid(n)},n.prototype.placePoint1OnGrid=function(n){this.point1.placeOnGrid(n);this.isHorizontal()?this.point2.y=this.point1.y:this.isVertical()&&(this.point2.x=this.point1.x)},n.prototype.placePoint2OnGrid=function(n){this.point2.placeOnGrid(n);this.isHorizontal()?this.point1.y=this.point2.y:this.isVertical()&&(this.point1.x=this.point2.x)},n.prototype.offsetFromPoint1=function(n){return this.offsetFromPoint(n,1)},n.prototype.offsetFromPoint2=function(n){return this.offsetFromPoint(n,2)},n.prototype.round=function(){this.point1.round();this.point2.round()},n.prototype.getClosest=function(n){var t,i,u;if(this.isHorizontal())t=n.x,i=this.point1.y;else if(this.isVertical())t=this.point1.x,i=n.y;else return n;return u=new r(t,i),this.clip(u)},n.prototype.getClosestToGrid=function(n,t){var i=n.clone();return i.placeOnGrid(t),this.getClosest(i)},n.prototype.getDistanceFrom=function(n){var t=this.getClosest(n);return n.distance(t)},n.prototype.isWithinBox=function(t,i){return this.isHorizontal()?this.point1.y<t.y-i||this.point1.y>t.y+i?!1:n.isWithin(this.point1.x,this.point2.x,t.x,i):this.isVertical()?this.point1.x<t.x-i||this.point1.x>t.x+i?!1:n.isWithin(this.point1.y,this.point2.y,t.y,i):!1},n.prototype.transform=function(n,t){this.point1.add(n,t);this.point2.add(n,t)},n.isWithin=function(n,t,i,r){var u=i-r,f=i+r;return n<f&&t>u||t<f&&n>u?!0:!1},n.prototype.clip=function(n){if(this.isHorizontal()){var t=this.point1.x,i=this.point2.x,e=n.x;return t<i?e<t?new r(t,n.y):e>i?new r(i,n.y):n:e<i?new r(i,n.y):e>t?new r(t,n.y):n}if(this.isVertical()){var u=this.point1.y,f=this.point2.y,o=n.y;return u<f?o<u?new r(n.x,u):o>f?new r(n.x,f):n:o<f?new r(n.x,f):o>u?new r(n.x,u):n}return n},n.prototype.offsetFromPoint=function(n,t){var i,u,f,e,o,s,h;return this.isHorizontal()?(i=this.point1.x,u=this.point2.x,i>u&&(h=u,u=i,i=h,t=t==1?2:1),t==1?(f=i+n,f>u&&(f=u)):(f=u-n,f<i&&(f=i)),new r(f,this.point1.y)):this.isVertical()?(e=this.point1.y,o=this.point2.y,e>o&&(h=o,o=e,e=h,t=t==1?2:1),t==1?(s=e+n,s>o&&(s=o)):(s=o-n,s<e&&(s=e)),new r(this.point1.x,s)):t==1?this.point2.clone():this.point1.clone()},n.prototype.dump=function(n,t){Project.Utility.dumpHeading(n,t);Project.Utility.dump(n,"Orientation is "+e.toString(this.getOrient()));this.point1.dump(n,"Point1:");this.point2.dump(n,"Point2:")},n}();n.Segment=o;h=function(){function n(n,t,i){this.createSegments(n,t,i)}return n.prototype.toPath=function(){var n=this.seg1.toPath();return this.drawSeg2&&(n+=this.seg2.extendPath(this.seg1.point2)),n},n.prototype.changeEndPoint=function(n,t){n&&!n.isEqual(this.seg2.point2)&&this.changeSegments(n,t)},n.prototype.placeSeg1OnGrid=function(n){if(!(n<=0)&&this.numSegs()!=0){var t=this.seg1.getOrient();t==i.HORIZONTAL?(this.seg1.point2.placeXOnGrid(n),this.seg2.point1.x=this.seg1.point2.x,this.seg2.point2.x=this.seg1.point2.x):t==i.VERTICAL&&(this.seg1.point2.placeYOnGrid(n),this.seg2.point1.y=this.seg1.point2.y,this.seg2.point2.y=this.seg1.point2.y)}},n.prototype.changeOrientation=function(){var n=e.orthogonal(this.seg1Orient),t;n!=this.seg1Orient&&this.drawSeg1&&this.drawSeg2&&(t=this.middlePoint(this.seg1.point1,this.seg2.point2,n),this.seg1.point2=t,this.seg2.point1=t.clone(),this.seg1Orient=n)},n.prototype.setOrientation=function(n){this.seg1Orient==i.HORIZONTAL?n==i.VERTICAL&&this.changeOrientation():this.seg1Orient==i.VERTICAL&&n==i.HORIZONTAL&&this.changeOrientation()},n.prototype.removeSeg1=function(){var n=null;return this.drawSeg1&&(n=this.seg1.clone(),this.seg1Orient=e.orthogonal(this.seg1Orient),this.connectionQuadrant=this.seg1.point2.quadrant(this.seg1.point1),this.drawSeg2?this.seg1=this.seg2.clone():(this.drawSeg1=!1,this.seg1.point1=this.seg1.point2.clone()),this.drawSeg2=!1,this.seg2.point1=this.seg1.point2.clone(),this.seg2.point2=this.seg1.point2.clone()),n},n.prototype.numSegs=function(){return this.drawSeg2?2:this.drawSeg1?1:0},n.prototype.getSeg1=function(){return this.seg1.clone()},n.prototype.getSeg2=function(){return this.seg2.clone()},n.prototype.combinedLength=function(){var n=0;return this.drawSeg2&&(n+=this.seg2.length()),this.drawSeg1&&(n+=this.seg1.length()),n},n.prototype.isZeroLength=function(n){return this.numSegs()==0?!0:n>0&&this.zeroSegLength(1,n)&&this.zeroSegLength(2,n)?!0:!1},n.prototype.dump=function(n,t){Project.Utility.dumpHeading(n,t);this.seg1.dump(n,"Segment1");this.seg2.dump(n,"Segment2");Project.Utility.dump(n,"drawSeg1 = "+this.drawSeg1+", drawSeg2 = "+this.drawSeg2);Project.Utility.dump(n,+"seg1Orient = "+e.toString(this.seg1Orient));Project.Utility.dump(n,"sticky = "+this.isSeg1OrientSticky);Project.Utility.dump(n,+"connectionQuadrant = "+u.toString(this.connectionQuadrant))},n.prototype.createSegments=function(t,r,f){if(t.round(),r.round(),this.connectionQuadrant=f,t.isDiagonal(r)){this.drawSeg1=!0;this.drawSeg2=!0;this.setSeg1Orient(t,r,!0);var e=this.middlePoint(t,r,this.seg1Orient);this.seg1=new o(t,e);this.seg2=new o(e,r)}else t.isEqual(r)?(this.drawSeg1=!1,this.seg1Orient=u.orientation(f)):t.y==r.y?(this.drawSeg1=!0,this.seg1Orient=i.HORIZONTAL):t.x==r.x&&(this.drawSeg1=!0,this.seg1Orient=i.VERTICAL),this.drawSeg2=!1,this.seg1=new o(t,r),this.seg2=new o(r,r);this.isSeg1OrientSticky=t.distance(r)>=n.STICKYRADIUS?!0:!1},n.prototype.changeSegments=function(t,r){if(this.seg1.point1.distance(t)<n.STICKYRADIUS&&(this.isSeg1OrientSticky=!1),this.seg1.point1.isDiagonal(t)){this.drawSeg1=!0;this.drawSeg2=!0;r||this.setSeg1Orient(this.seg1.point1,t,!this.isSeg1OrientSticky);var f=this.middlePoint(this.seg1.point1,t,this.seg1Orient);this.seg1.point2=f;this.seg2.point1=f.clone();this.seg2.point2=t.clone()}else this.seg1.point1.isEqual(t)?(this.drawSeg1=!1,this.seg1Orient=u.orientation(this.connectionQuadrant)):this.seg1.point1.y==t.y?(this.drawSeg1=!0,this.isSeg1OrientSticky||(this.seg1Orient=i.HORIZONTAL)):this.seg1.point1.x==t.x&&(this.drawSeg1=!0,this.isSeg1OrientSticky||(this.seg1Orient=i.VERTICAL)),this.drawSeg2=!1,this.seg1.point2=t.clone(),this.seg2.point1=t.clone(),this.seg2.point2=t.clone();this.seg1.point1.distance(t)>=n.STICKYRADIUS&&(this.isSeg1OrientSticky=!0)},n.prototype.middlePoint=function(n,t,u){return u==i.VERTICAL?new r(n.x,t.y):new r(t.x,n.y)},n.prototype.setSeg1Orient=function(n,t,i){this.conflictingQuadrant(n,t,this.connectionQuadrant)?this.seg1Orient=u.orthogonalOrientation(this.connectionQuadrant):i&&(this.seg1Orient=u.orientation(n.quadrant(t)))},n.prototype.conflictingQuadrant=function(n,i,r){return r==t.NORTH&&n.isNorthOf(i)?!0:r==t.SOUTH&&n.isSouthOf(i)?!0:r==t.EAST&&n.isEastOf(i)?!0:r==t.WEST&&n.isWestOf(i)?!0:!1},n.prototype.zeroSegLength=function(n,t){var i;if(n==1&&this.numSegs()>0){if(i=this.seg1.length(),i*2>=t)return!1}else if(n==2&&this.numSegs()>1&&(i=this.seg2.length(),i*2>=t))return!1;return!0},n.STICKYRADIUS=10,n}();n.RightAnglePair=h;s=function(){function n(n,t){this.idx1=null;this.idx2=null;this.idx1=n;this.idx2=t}return n.prototype.setIdx1=function(n){this.idx1=n},n.prototype.setIdx2=function(n){this.idx2=n},n.prototype.setIndices=function(n,t){this.idx1=n;this.idx2=t},n.prototype.getIdx1=function(){return this.idx1},n.prototype.getIdx2=function(){return this.idx2},n.prototype.getWidth=function(){return this.idx1==-1||this.idx2==-1?-1:this.idx1!=null&&this.idx2!=null?Math.abs(this.idx1-this.idx2)+1:null},n.prototype.getBusString=function(){var n="[";return n+=this.idx1>=0?this.idx1:"x",n+=":",n+=this.idx2>=0?this.idx2:"x",n+"]"},n.prototype.getBitString=function(){var n="[";return n+=this.idx1>=0?this.idx1:"x",n+"]"},n.prototype.clone=function(){return new n(this.idx1,this.idx2)},n.prototype.isCompatible=function(n){var t=this.getWidth(),i=n.getWidth();return t==-1||i==-1||t==i?!0:!1},n.prototype.containsIndex=function(n){return this.idx1==n||this.idx2==n?!0:this.idx2==null?!1:this.idx1==-1||this.idx2==-1?!0:this.idx1>this.idx2&&this.idx1>n&&n>this.idx2?!0:this.idx1<this.idx2&&this.idx1<n&&n<this.idx2?!0:!1},n}();n.BusIndices=s,function(n){n[n.WIRE=0]="WIRE";n[n.BIT=1]="BIT";n[n.BUS=2]="BUS"}(n.BUSTYPE||(n.BUSTYPE={}));f=n.BUSTYPE;c=function(){function n(n){this.prefix=null;this.type=f.WIRE;this.indices=null;this.bitIdx=null;this.isLegal=!0;this.errMsg=null;this.baseName=n}return n.prototype.getBaseName=function(){return this.baseName},n.prototype.getType=function(){return this.type},n.prototype.isBus=function(){return this.type==f.BUS},n.prototype.isBit=function(){return this.type==f.BIT},n.prototype.isWire=function(){return this.type==f.WIRE},n.prototype.getPrefix=function(){return this.prefix},n.prototype.setPrefix=function(n){this.prefix=n},n.prototype.getIndices=function(){return this.isBit()&&(this.indices=new s(this.bitIdx,null)),this.indices},n.parse=function(t){var i=new n(t),r=t.indexOf("["),c=t.indexOf("]"),u,e,o,h;return r>0&&c>r?(i.prefix=t.substring(0,r),u=t.substr(r+1,c-r-1),e=u.indexOf(":"),e>0?(i.type=f.BUS,o=u.substr(0,e),h=u.substr(e+1),o.toLowerCase()=="x"&&(o="-1"),h.toLowerCase()=="x"&&(h="-1"),i.indices=new s(parseInt(o),parseInt(h))):(i.type=f.BIT,i.bitIdx=parseInt(u))):i.prefix=t,i},n}();n.BusName=c}(BaseWire||(BaseWire={})),function(n){var s=function(){function n(){}return n}(),u,f,e,i,o,t,r;n.ViewBox=s;u=function(){function n(){}return n}();n.GridData=u;f=function(){function f(){}return f.eventToPoint=function(n,t){var i=null;return n!=null&&t!=null&&(i=n.getSurface().screenToSch(t.pageX,t.pageY)),i},f.finishAnimation=function(n){var t=n.status(),i;t&&t.length>0&&(i=t[0].anim,n.status(i,1))},f.intersectRect=function(n,t){return n==null||t==null?!1:!(t.x1>n.x2||t.x2<n.x1||t.y1>n.y2||t.y2<n.y1)},f.isPointInsideBoundingRect=function(n,t,i){var f,o,s,h,r,u;return n?(n instanceof e?(r=n,f=r.x1,s=r.y1,o=r.x2,h=r.y2):(u=n,f=u.x,s=u.y,o=u.x2,h=u.y2),t>=f&&t<=o&&i>=s&&i<=h):!1},f.accumulateBoundingRect=function(n,t){return n==null?t:(t&&(t.x1<n.x1&&(n.x1=t.x1),t.y1<n.y1&&(n.y1=t.y1),t.x2>n.x2&&(n.x2=t.x2),t.y2>n.y2&&(n.y2=t.y2)),n.width=Math.abs(n.x2-n.x1),n.height=Math.abs(n.y2-n.y1),n)},f.roundBoundingRect=function(n){n.height=Math.round(n.height);n.width=Math.round(n.width);n.x1=Math.round(n.x1);n.y1=Math.round(n.y1);n.x2=Math.round(n.x2);n.y2=Math.round(n.y2)},f.getSVGViewbox=function(n){var r,t,i;return n?(r=/viewbox="(-?\d+),(-?\d+),(\d+),(\d+)"/,t=n.match(r),t==null||t.length!=5)?null:(i=new s,i.x=parseInt(t[1]),i.y=parseInt(t[2]),i.width=parseInt(t[3]),i.height=parseInt(t[4]),i):null},f.scaleSVGWidthAndHeight=function(n,t,i){if(!n)return null;var r=/width="(\d+)"/,u=/height="(\d+)"/;return n.match(r)&&(n=n.replace(r,'width="'+Math.round(t.width*i)+'"')),n.match(u)&&(n=n.replace(u,'height="'+Math.round(t.height*i)+'"')),n},f.addViewboxToSVG=function(n,t){var i,u,f,e,o,r,s,h;if(t===void 0&&(t=null),n==null||n=="")return n;if(i=n.toLowerCase(),t==null){if(r=i.indexOf('viewbox="'),r>-1)return n;u="0";f="0";r=i.indexOf('width="');e=i.substring(r+7,i.indexOf('"',r+7));r=i.indexOf('height="');o=i.substring(r+8,i.indexOf('"',r+8))}else u=t.x1.toString(),f=t.y1.toString(),e=t.width.toString(),o=t.height.toString();return s=/(viewbox="-?\d+,-?\d+,\d+,\d+")/,n.match(s)?n=n.replace(s,'viewbox="'+u+","+f+","+e+","+o+'"'):(h=i.indexOf("width="),n=[n.slice(0,h),' viewbox="'+u+","+f+","+e+","+o+'" ',n.slice(h)].join("")),n},f.dumpHeading=function(n,t){if(t){var i=f.getIndent(n);f.dump(0,i+"+++ "+t+" +++")}},f.dump=function(n,t){if(t){var i=f.getIndent(n);console.log(i+t)}},f.getIndent=function(n){for(var t="",i=0;i<n;i++)t+="  ";return t},f.createUUID=function(){for(var n=[],i="0123456789abcdef",t=0;t<36;t++)n[t]=i.substr(Math.floor(Math.random()*16),1);return n[14]="4",n[19]=i.substr(n[19]&3|8,1),n[8]=n[13]=n[18]=n[23]="-",n.join("")},f.getUserID=function(){var n=$.cookie("svwid");return n==null&&(n=0),n},f.uniqNameInArray=function(n,t){for(var i=0;i<t.length;++i)if(n==t[i].uniqName)return!0;return!1},f.pointToTransform=function(n,t){return"...T"+n+", "+t},f.endsWith=function(n,t){return n.indexOf(t,n.length-t.length)!==-1},f.getIllegalConnectionMsg=function(n,t){var r,o;if(!n||!t)return null;if(r=f.getWire(n),o=f.getWire(t),r&&o&&r==o)return r.isBus()?"Cannot connect a bus to itself":"Cannot connect a wire to itself";var i=null,u=f.getObjWidth(n),e=f.getObjWidth(t);return u!=null&&e!=null?u!=-1&&e!=-1&&u!=e&&(i="Cannot connect different size buses without a bus tap"):u!=null||e!=null?(i="Cannot connect a ",i+=f.getObjTypeString(n),i+=" to a ",i+=f.getObjTypeString(t)):i=f.areMatchingTechnologies(n,t)?null:f.isIsolatedGround(n,t)?null:"Cannot connect different technologies.  Insert a converter block",i},f.isIsolatedGround=function(n,t){return f.isGround(n)||f.isConnectedOnlyToGround(n)?!0:f.isGround(t)||f.isConnectedOnlyToGround(t)?!0:!1},f.isGround=function(t){if(t instanceof n.Pin){var i=t;return i.getComponent().isGroundOrReferenceComponent()}return!1},f.isConnectedOnlyToGround=function(n){var t=null,i;return n instanceof BaseWire.WireSegment?(i=n,t=i.getWire()):n instanceof BaseWire.Wire&&(t=n),t&&t.getForcedName()&&t.getNumConnectedPins()==1?!0:!1},f.areMatchingTechnologies=function(n,t){var i=f.getTechnology(n),r=f.getTechnology(t);return i==r?!0:!1},f.getTechnology=function(n){var t=f.getPin(n),i,r;return t?f.getPinTechnology(t.getType(),t.getSubtype()):n instanceof BaseWire.WireSegment?(i=n,i.getTechnology()):n instanceof BaseWire.Wire?(r=n,r.getTechnology()):null},f.getPinTechnology=function(t,i){var r=i.toLowerCase();return t==n.PIN_TYPE.SIGNAL?r.indexOf("std_logic")==0?n.TECHNOLOGY.DIGITAL:r=="real"?n.TECHNOLOGY.REAL:r=="integer"?n.TECHNOLOGY.INTEGER:r=="bit"?n.TECHNOLOGY.BIT:r=="boolean"?n.TECHNOLOGY.BOOLEAN:n.TECHNOLOGY.OTHER_SIG:t==n.PIN_TYPE.QUANTITY?n.TECHNOLOGY.QUANTITY:r=="electrical"?n.TECHNOLOGY.ELEC:r=="rotational_velocity"?n.TECHNOLOGY.ROT_VEL:r=="rotational"?n.TECHNOLOGY.ROT:r=="translational"?n.TECHNOLOGY.TRAN:r=="magnetic"?n.TECHNOLOGY.MAGNETIC:r=="fluidic"?n.TECHNOLOGY.FLUIDIC:r=="thermal"?n.TECHNOLOGY.THERMAL:n.TECHNOLOGY.OTHER_TERM},f.getObjWidth=function(t){var r=null,u,f,i;return t instanceof n.Pin?(u=t,r=u.getVectorWidth()):t instanceof BaseWire.WireSegment?(f=t,i=f.getWire(),i&&(r=i.isBit()?null:i.getWidth())):t instanceof BaseWire.Wire&&(i=t,r=i.isBit()?null:i.getWidth()),r},f.getObjTypeString=function(t){var u,i,r;return t instanceof n.Pin?(u=t,u.isVector()?"vector pin":"scalar pin"):t instanceof BaseWire.WireSegment?(i=t,i.isBus()?"bus":i.getWire()&&i.getWire().isBit()?"bit":"wire"):t instanceof BaseWire.Wire?(r=t,r.isBus()?"bus":r.isBit()?"bit":"wire"):"unknown type"},f.getWire=function(t){var i=null,r,u;return t instanceof BaseWire.WireSegment?(r=t,i=r.getWire()):t instanceof BaseWire.Wire?i=t:t instanceof n.Pin&&(u=t,i=u.getWire()),i},f.getPin=function(t){var i=null,u,r,f;return t instanceof BaseWire.WireSegment?(u=t,r=u.getWire(),r&&(i=r.getAnyConnectedPin())):t instanceof BaseWire.Wire?(r=t,i=r.getAnyConnectedPin()):t instanceof BaseWire.Net?(f=t,i=f.getAnyConnectedPin()):t instanceof n.Pin&&(i=t),i},f.getClassName=function(n){var t=/function (.{1,})\(/.exec(n.constructor.toString());return t&&t.length>1?t[1]:""},f.checkForNull=function(t,i,r,u){return!t&&i?(f.showErrorInConsole(r+" expected value is null = but result is "+i,u),n.NULL_CHECK.ONE_NULL):t&&!i?(f.showErrorInConsole(r+" expected value is "+t+"  = but result is null",u),n.NULL_CHECK.ONE_NULL):!t&&!i?n.NULL_CHECK.BOTH_NULL:n.NULL_CHECK.NOT_NULL},f.showErrorInConsole=function(n,t){t&&console.log(n)},f.comparePrimitives=function(t,i,r,u,e){if(f.checkForNull(t,i,name,!0)==n.NULL_CHECK.ONE_NULL)return f.showErrorInConsole(o,e),!1;if(f.checkForNull(t,i,name,!0)==n.NULL_CHECK.BOTH_NULL)return!0;if(typeof t=="string"||typeof t=="boolean")return f.comparePrimitiveType(t,i,r,u,e);if(typeof t=="number")return f.compareNumbers(t,i,r,u,e);var o="For "+u+" parameter "+r+" type support is not implemented";return f.showErrorInConsole(o,e),!1},f.comparePrimitiveType=function(t,i,r,u,e){var o="For "+u+" parameter "+r+" expected value is "+t+" but result is "+i;return f.checkForNull(t,i,name,!0)==n.NULL_CHECK.ONE_NULL?(f.showErrorInConsole(o,e),!1):f.checkForNull(t,i,name,!0)==n.NULL_CHECK.BOTH_NULL?!0:i!=t?(f.showErrorInConsole(o,e),!1):!0},f.compareNumbers=function(t,i,r,u,e){var o="For "+u+" parameter "+r+" expected value is "+t+" but result is "+i;return f.checkForNull(t,i,name,!0)==n.NULL_CHECK.ONE_NULL?(f.showErrorInConsole(o,e),!1):f.checkForNull(t,i,name,!0)==n.NULL_CHECK.BOTH_NULL?!0:Math.abs(i-t)>3?(f.showErrorInConsole(o,e),!1):!0},f.compareArrays=function(t,i,r,u,e,o){var s,h,c;if(f.checkForNull(t,i,u,e)==n.NULL_CHECK.ONE_NULL)return!1;if(f.checkForNull(t,i,u,e)==n.NULL_CHECK.BOTH_NULL)return!0;if(t.length!=i.length)return f.showErrorInConsole("Arrays with name "+u+" have different length: "+t.length+" and "+i.length,e),!1;for(s=0;s<t.length;s++)if(h=t[s],c=i[s],!h.compareTo(c,u+"["+s+"]",!1,o)&&!f.findEqualObject(i,h,u+"["+s+"]",o,!1)){var l=f.getName(h,r),a=f.getName(c,r),v=l?l:a?a:"";return f.showErrorInConsole(" For expected "+v+" element of "+u+" is not found",e),!1}return!0},f.compareMaps=function(t,i,r,u){var e,o,s;if(f.checkForNull(t,i,r,u)==n.NULL_CHECK.ONE_NULL)return!1;if(f.checkForNull(t,i,r,u)==n.NULL_CHECK.BOTH_NULL)return!0;for(e in t)if(o=t[e],s=i[e],o!=s)return f.showErrorInConsole(" For expected "+e+" element of "+r+" is not found",u),!1;return!0},f.comparePromitiveArrays=function(t,i,r,u){var e,o,s,h;if(f.checkForNull(t,i,r,u)==n.NULL_CHECK.ONE_NULL)return!1;if(f.checkForNull(t,i,r,u)==n.NULL_CHECK.BOTH_NULL)return!0;if(t.length!=i.length)return f.showErrorInConsole("Arrays with name "+r+" have different length: "+t.length+" and "+i.length,u),!1;for(e=0;e<t.length;e++)if(o=t[e],s=i[e],o!=s&&!f.findEqualPrimitiveObject(i,o))return h=o?o:s?s:"",f.showErrorInConsole(" For expected "+h+" element of "+r+" is not found",u),!1;return!0},f.getName=function(n,t){return n.hasOwnProperty(t)?n[t]:null},f.findEqualObject=function(n,t,i,r,u){for(var e,f=0;f<n.length;f++)if(e=n[f],t.compareTo(e,i,u,r))return!0;return!1},f.findEqualPrimitiveObject=function(n,t){for(var r,i=0;i<n.length;i++)if(r=n[i],t!=r)return!0;return!1},f.dumpState=function(n,t,i,r){var e=f.getIndent(i),u="\n"+e+n+": ",t=JSON.stringify(this);return t&&(u+=t),r&&console.log(u),u},f.pauseEvent=function(n){return n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault(),n.cancelBubble=!0,n.returnValue=!1,!1},f.convertToLegalVHDLName=function(n,t){return!n||n.length==0?n:(n=n.trim().replace("+","_plus_"),n[0]=="-"&&(n="_minus_"+n.substr(1)),n=n.replace(/[^a-zA-Z0-9]/g,"_").replace(/_+/g,"_").replace(/^_+/,"").replace(/_+$/,""),n!=""&&$.isNumeric(n.charAt(0))&&(n=t+n),n)},f.isEntryField=function(n){if(!n)return!1;var t=n.tagName.toLowerCase();return t=="svg"?!1:t=="input"||t=="text"||t=="textarea"||t=="checkbox"?!0:!1},f.getHost=function(n){return n.substring(0,n.indexOf("/",n.indexOf("//")+2))},f.removeProtocolFromUrl=function(n){var t=n.indexOf("://")+3;return t==2?n:n.substr(t)},f.isSameDomain=function(n,t){var i,r,u,e;return!n||!t?!1:(i=f.removeProtocolFromUrl(n).split("."),r=f.removeProtocolFromUrl(t).split("."),!i||!r)?!1:(u=i.length,e=r.length,u<2||e<2)?!1:i[u-1]==r[e-1]&&i[u-2]==r[e-2]},f.getOffsets=function(n,t){t=t||window.event;var i=t.pageX-n.offset().left,r=t.pageY-n.offset().top;return{offsetX:i,offsetY:r}},f.updatePerfectScrollBar=function(n,t){return n?(t||n.perfectScrollbar(),n.perfectScrollbar("update")):null},f.isIE=function(){return navigator.appName=="Microsoft Internet Explorer"?!0:navigator.appName=="Netscape"&&new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)!=null?!0:!1},f.getUniqId=function(){return"application_uniq_id_"+f.GLOBAL_ID_INDEX++},f.hoverEventWithToFront=function(n,t,i){var r=!1;f.isIE()?n.hover(function(n){r||(t(n),r=!0)},function(n){i(n);r=!1}):n.hover(t,i)},f.drawProbe=function(n,t,i){var r=n.path(ProbeModule.Probe.PROBE_PATH);return r.attr("opacity",t),r.node.setAttribute("class",i),r},f.convertNewlinesToHTML=function(n){return n.replace(/(\r\n|\n|\r)/gm,"<br>")},f.wrapLines=function(n,t){var i,u,n;t===void 0&&(t=60);try{if(n.length<t)return n;n=n.replace(/<br>/gm,"<br />");var r="",o=n.split("<br />"),e=!1;for(i=0,u=o;i<u.length;i++)n=u[i],e&&(r+="<br />"),r+=n.length>t?f.splitLine(n,t):n,e=!0;return r}catch(s){return n}},f.splitLine=function(n,t){for(var f=new RegExp("\\S[\\s\\S]{0,"+t+"}\\S(?=\\s|$)","g"),i="",r,u=!1;(r=f.exec(n))!=null;)u&&(i+="<br/>"),i+=r[0],u=!0;return i},f.splitVector=function(n){var r=n.match(/\(([^)]+)\)/),u,t,i;if(!r||r.length<2)return null;for(u=r[1],t=u.split(","),i=0;i<t.length;++i)t[i]=t[i].trim();return t},f.toGridDataArray=function(n){var i,t;if(!n||!n[0])return null;for(i=new Array(n[0].length),t=0;t<n[0].length;++t)i[t]=new u,i[t].independent=n[0][t],n[1]&&(i[t].dependent=n[1][t]);return i},f.toVector=function(n,t){for(var u,i="(",r=0,f=n;r<f.length;r++)u=f[r],i+=t==0?u.independent:u.dependent,i+=",";return i.substr(0,i.length-1)+")"},f.getClipboardText=function(n){var i=null,t=n.originalEvent.clipboardData,r;return t&&t.getData?(r=t.getData("text/plain"),r&&(i=r.toString())):(t=window.clipboardData,t&&t.getData&&(i=t.getData("Text"))),i.replace(/\x0D/g,"")},f.xor=function(n,t){return n?!t:t},f.getMoreInfoHtml=function(n,t,i){return t===void 0&&(t="#31404d"),i===void 0&&(i="0"),'<div class="vertical_spacer_10"><\/div><div id="'+n+'" class="more_info"><div class="more_info_icon"><\/div><div class="more_info_link" style="color: '+t+"; padding-top: "+i+'">More Info<\/div><div class="clear"><\/div><\/div>'},f.setTooltip=function(n,t){var i,r;i=typeof n=="string"?$(n):n;r=i.qtip("api");r?r.set("content.text",t):i.qtip({content:{text:t},show:{delay:Schematic.Surface.TTIP_DELAY},style:{classes:"svw-tooltip"}})},f.fixViewerAndSidebarZIndex=function(){var i=o.getKendoWindowMaxZIndex(),t=parseInt($(VIEWER_PANE).css("z-index")),n;isNaN(t)&&(t=10050);i>=t&&(n=i+5,$(VIEWER_PANE).css("z-index",n),$(LEFT_SIDEBAR).css("z-index",n),$(RIGHT_SIDEBAR).css("z-index",n))},f.initSiPrefixAndExponentArrays=function(){t=[];t.push(new i("F","f",-15,1e-15,1));t.push(new i("P","p",-12,1e-12,2));t.push(new i("N","n",-9,1e-9,3));t.push(new i("U","u",-6,1e-6,4));t.push(new i("M","m",-3,.001,5));t.push(new i("","",0,1,9));t.push(new i("K","K",3,1e3,6));t.push(new i("MEG","Meg",6,1e6,0));t.push(new i("G","G",9,1e9,7));t.push(new i("T","T",12,1e12,8));r=i.copyArray(t);r.sort(i.sortRegexOrder);r.pop()},f.convertExponentToSIPrefix=function(n){var u=n.toUpperCase(),s=new RegExp("E","g"),e=s.exec(u),f,r,i,o;if(!e)return n;for(f=Number(u.substr(e.index+1,u.length)),r=Number(u.substr(0,e.index)),i=1;i<t.length;++i)if(f<t[i].exp)return r*=Math.pow(10,f-t[i-1].exp),r+t[i-1].displaySiPrefix;return o=t.length-1,r*=Math.pow(10,f-t[o].exp),r+t[o].displaySiPrefix},f.convertSIPrefixToExponent=function(n){for(var t=n.toUpperCase(),i=0,u=r;i<u.length;i++){var f=u[i],o=new RegExp(f.siPrefix,"g"),e=o.exec(t);if(e)return t=t.substr(0,e.index).trim(),t+"e"+f.exp}return n},f.convertNumberSuffix=function(n,t){return t?f.convertExponentToSIPrefix(n):f.convertSIPrefixToExponent(n)},f.convertSIPrefixToNumber=function(n){var t,i;for(n=n.toUpperCase(),t=0,i=r;t<i.length;t++){var u=i[t],e=new RegExp(u.siPrefix,"g"),f=e.exec(n);if(f)return Number(n.substr(0,f.index))*u.num}return Number(n)},f.getPrecision=function(n){var r=n.toString().split("."),i=r[0],t=r[1];return t?(t=f.roundFractionalPart(t),i=="0"||i=="+0"||i=="-0"?(t=Number(t).toString(),t.length):i.length+t.length):i.length},f.roundFractionalPart=function(n){var r=(n.match(/0000000/g)||[]).length,u=(n.match(/9999999/g)||[]).length,t,i;return r==0&&u==0?n:(t=Number("0."+n),t*=1e7,t=Math.round(t),t/=1e7,t==0)?"0":(i=t.toString(),i=i.split(".")[1],t.toString().split(".")[1])},f.startTrace=function(n){this.isStartTrace=!0;this.trace(n,!0)},f.traceOnly=function(n){f.isProductionMode()||console.info(n)},f.trace=function(n,t){var h,u,e,s,o,i,r;(t===void 0&&(t=!0),!f.isProductionMode()&&f.showTracing)&&(h=this.isStartTrace,this.isStartTrace=!1,h?(this.showInConsole("\n==========================="),i="Start from "+n+": "+this.displayTime(null,new Date),r="Start from "+n+": "+this.displayTime(null,new Date),this.showInConsole(i),this.startTime=new Date,this.prevTime=this.startTime,this.baseTime=this.startTime,this.report=i):(u=new Date,t&&(e=this.displayTime(this.baseTime,u),this.baseTime=u),s=this.displayTime(this.prevTime,u),o=this.displayTime(this.startTime,u),this.prevTime=u,i=n+":  ",r=n+":  ",this.baseOnly?t&&(i+=" <strong>"+e+"<\/strong>",i+=" (<strong>"+o+")<\/strong>",r+=e,r+=" ("+o+")",this.putToConsole&&this.showInConsole(r),this.report+="<br>"+i):(i+="<strong>"+s+"<\/strong>",r+=s,e&&(i+=" base: <strong>"+e+"<\/strong>",r+=" base: "+e),i+=" (<strong>"+o+")<\/strong>",r+=" ("+o+")",this.putToConsole&&this.showInConsole(r),this.report+="<br>"+i)))},f.showInConsole=function(n){!f.isProductionMode()&&f.putToConsole&&console.log(n)},f.isProductionMode=function(){return n.Settings.isProductionMode()},f.timeBetween=function(n,t){var h=n.getTime(),c=t.getTime(),i=c-h,u="",o,f,e;if(i<1e3)return i+" ms";o=i%1e3;i=i/1e3;f=Math.floor(i%60);i=i/60;e=Math.floor(i%60);i=i/60;var s=Math.floor(i%24),l=Math.floor(i/24),r=!1;return l>0&&(u+="days + ' days ",r=!0),s>0&&(u+=s+" hours ",r=!0),(e>0||r)&&(u+=e+" min ",r=!0),(f>0||r)&&(u+=f+" s ",r=!0),u+(o+" ms")},f.displayTime=function(n,t){var f="";if(n)return this.timeBetween(n,t);var e=t.getHours(),i=t.getMinutes(),r=t.getSeconds(),u=t.getMilliseconds(),s="",o="";return i<10&&(s="0"+i),r<10&&(o="0"+r),u<10&&(o="0"+u),f+=e+":"+i+":"+r+":"+u+" ",f+(e>11?"PM":"AM")},f.getPropTypFromMinTypMax=function(t){var i="";if(t.Typical)i=t.Typical;else if(!t.Minimum||t.Typical||t.Maximum)if(t.Minimum||t.Typical||!t.Maximum)if(t.Minimum&&!t.Typical&&t.Maximum){var r=new n.PropertyFormatter,u=r.SIUnitPrefixes2Double(t.Maximum),f=r.SIUnitPrefixes2Double(t.Minimum);i=((u+f)/2).toString()}else i="";else i=t.Maximum;else i=t.Minimum;return i},f.isReferenceComponent=function(n,t){return(f.endsWith(n.toLowerCase(),"_ref")||n.toLowerCase()=="ground")&&t.toLowerCase()=="svweblib"?!0:!1},f.GLOBAL_ID_INDEX=0,f.ScrollbarProperties={axis:"yx",theme:"3d-dark",autoDraggerLength:!0,scrollInertia:0,scrollbarPosition:"inside",autoHideScrollbar:!0,advanced:{updateOnBrowserResize:!0,updateOnContentResize:!0,autoExpandHorizontalScroll:!0,autoExpandVerticalScroll:!0}},f.showTracing=!1,f.putToConsole=!0,f.report="",f.baseOnly=!0,f.isStartTrace=!1,f}();n.Utility=f;e=function(){function n(n,t,i,r){if(n)if($.isNumeric(n))this.x1=n,this.y1=t,this.x2=i,this.y2=r,this.width=Math.abs(i-this.x1),this.height=Math.abs(r-t);else{var u=n;this.x1=u.x;this.y1=u.y;this.x2=u.x2;this.y2=u.y2;this.width=u.width;this.height=u.height}}return n.prototype.round=function(){this.x1=Math.round(this.x1);this.y1=Math.round(this.y1);this.x2=Math.round(this.x2);this.y2=Math.round(this.y2);this.width=Math.round(this.width);this.height=Math.round(this.height)},n}();n.BoundingRect=e;i=function(){function n(n,t,i,r,u){this.siPrefix=n;this.displaySiPrefix=t;this.exp=i;this.num=r;this.regexOrder=u}return n.sortRegexOrder=function(n,t){return n=n.regexOrder,t=t.regexOrder,n<t?-1:n>t?1:0},n.copyArray=function(n){for(var u,i=[],t=0,r=n;t<r.length;t++)u=r[t],i.push(u);return i},n}();o=function(){function t(){}return Object.defineProperty(t,"CommonKendoWindowOptions",{get:function(){return{actions:["Close"],animation:{open:{effects:"fade:in",duration:10},close:{effects:"fade:out",duration:10}},visible:!1,modal:!1,draggable:!0,resizable:!0}},enumerable:!0,configurable:!0}),t.maximizeKendoWindowSpace=function(n,t){t===void 0&&(t=!0);n.find(".k-window-titlebar, .k-window-actions, .k-window-title").css("font-size","12px");n.find(".k-window-titlebar, .k-window-actions").css("height","10px").css("padding-top","0px");n.find(".k-block>.k-header, .k-window-titlebar").css("height","10px").css("padding-top","0px").css("padding-bottom","0px");t&&n.find("div.k-window-content").css("padding","2px 2px 0 2px")},t.getKendoWindowMaxZIndex=function(){var n=1;return $(".k-window").each(function(){var t=$(this).css("z-index"),i;t&&$.isNumeric(t)&&(i=+t,i>n&&(n=i))}),n},t.openLargeKendoWindow=function(t,i,r){var u=t.data("kendoWindow");u&&u.destroy();u=t.kendoWindow().data("kendoWindow");var e=Math.min(surface.getVisibleWidth()-40,900),o=Math.min(surface.getVisibleHeight()-120,800),f={title:i,minWidth:Math.min(200,e),maxWidth:e,minHeight:Math.min(100,o),maxHeight:o};f=$.extend({},n.KendoHelper.CommonKendoWindowOptions,f);u.setOptions(f);u.content(r);var s=surface.getSidebarManager(),h=s.getVisibleWidth(Sidebar.Orientation.LEFT),c=s.getVisibleWidth(Sidebar.Orientation.RIGHT);h==c?(u.center(),t.parent().css({top:"60px"})):t.parent().css({top:"60px",left:h==0?"20px":"220px"});u.open()},t}();n.KendoHelper=o;f.initSiPrefixAndExponentArrays()}(Project||(Project={})),function(n){(function(n){n[n.OBJECT_NAME=0]="OBJECT_NAME";n[n.NUMBER=1]="NUMBER"})(n.QUERY_FIELD_TYPE||(n.QUERY_FIELD_TYPE={}));var t=n.QUERY_FIELD_TYPE,i=function(){function i(n){this.OBJNAME_DIV="#objname";this.validatorDelay=250;n?this.design=n:$('<input id="objname" type="text" spellcheck="false">').appendTo(document.body)}return i.prototype.queryObjName=function(n,i,r,u,f){f===void 0&&(f=null);this.queryField(t.OBJECT_NAME,n,i,r,u,f)},i.prototype.queryNumber=function(n,i,r,u,f,e,o){this.queryField(t.NUMBER,n,i,r,u,f,e,o)},i.prototype.queryField=function(i,r,u,f,e,o,s,h){var l=this,c,a,v;s===void 0&&(s=null);h===void 0&&(h=null);this.hideQueryField(!1);i==t.OBJECT_NAME&&this.design&&(this.design.getWireBar().disable(),this.design.getSymbolBar().disable());c=$(this.OBJNAME_DIV);c.css({left:f,top:e,position:"absolute"});a=n.KendoHelper.getKendoWindowMaxZIndex();v=a+1e3;c.css({zIndex:v});c.blur();c.val("");c.show("bounce",{distance:3,times:1},350,function(){var a,f,e;c.val(r);c.focus();o==null?c.select():(a=c[0],a.setSelectionRange(0,o));f=function(){u(c.val());s&&c.qtip("destroy");l.hideQueryField(!0);i==t.OBJECT_NAME&&l.design&&(l.design.getWireBar().enable(),l.design.getSymbolBar().enable());c.unbind(".inputField");$(SCHEMATIC).off("click.inputField")};c.focusout(f);$(SCHEMATIC).on("click.inputField",function(n){f(n)});c.keypress(function(t){t.which==n.Design.EnterKey&&f(t)});s&&(e=l,c.bind("keyup.inputField",function(t){if(t.which!=n.Design.TabKey){var i=t;clearTimeout(e.validatorTimer);e.validatorTimer=setTimeout(function(){var n=i.currentTarget.value;s(c,n,h)},e.validatorDelay)}}))})},i.prototype.hideQueryField=function(n){var t=$(this.OBJNAME_DIV);n?t.hide("fade",{},300):t.hide();t.unbind("focusout");t.unbind("keypress")},i}();n.InputField=i}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i;(function(n){n[n.BTN1=0]="BTN1";n[n.BTN2=1]="BTN2"})(n.BUTTON||(n.BUTTON={}));var u=n.BUTTON,t=function(){function n(){}return n.prototype.init=function(n,t,i,r,u){var e=this.createDiv(i),f;$(document.body).append(e);this.createDialog(n);this.defineEvents();$("#"+this.msg_id).html(t);f=this.win.wrapper;f.find(".k-window-action").css("visibility","hidden");r!=null&&u!=null?f.css({top:u,left:r}):f.css("left",window.innerWidth/2-f.width()/2)},n.prototype.createDiv=function(n){for(var i="<div id = '"+this.dlg_id+"' ><div id = '"+this.msg_id+"' > <\/div><br><div>",t=0;t<n.length;++t)i+="<button id = '"+this.btn_ids[t]+"' class='k-button'>"+n[t]+"<\/button>&nbsp;";return i+"<\/div><\/div>"},n.prototype.queryUser=function(){return this.win.open(),this.deferred=jQuery.Deferred(),this.deferred},n.prototype.createDialog=function(n){var t=Math.min(surface.getVisibleWidth()-40,700);this.win=$("#"+this.dlg_id).kendoWindow({animation:{open:{effects:"slideIn:down fadeIn",duration:500},close:{effects:"slide:up fadeOut",duration:500}},draggable:!0,minWidth:300,maxWidth:t,modal:this.modal,resizable:!1,title:n,visible:!1}).data("kendoWindow").center()},n.prototype.defineEvents=function(){throw new Error("defineEvents() needs to be defined by derived class");},n.prototype.close=function(){this.win.destroy()},n.DLG_MSG_ID="multiBtnMsg",n.DLG_BTN_PREFIX_ID="multiBtnBtn",n}(),r=function(n){function i(r,u,f,e,o,s){var h,c;for(n.call(this),this.dlg_id=i.DLG_ID,this.msg_id=t.DLG_MSG_ID,this.btn_ids=[],h=0;h<f.length;++h)this.btn_ids.push(t.DLG_BTN_PREFIX_ID+h);this.modal=!0;this.init(r,u,f,e,o);f.length==1&&(s=0);s!=null&&(c=t.DLG_BTN_PREFIX_ID+s,setTimeout(function(){$("#"+c).focus()},800))}return __extends(i,n),i.prototype.defineEvents=function(){for(var i=this,n=0;n<this.btn_ids.length;++n)$("#"+this.btn_ids[n]).on("click",function(n){var r=n.currentTarget.id.substr(t.DLG_BTN_PREFIX_ID.length);i.deferred.resolve(r);i.win.destroy()})},i.DLG_ID="multiBtnModalDialog",i}(t);n.MultiBtnModalDialog=r;i=function(n){function i(r,u,f,e,o){var s,h;for(n.call(this),s=i.INSTANCE_COUNTER++,this.dlg_id=i.DLG_ID+"_"+s,this.msg_id=t.DLG_MSG_ID+"_"+s,this.btn_ids=[],h=0;h<f.length;++h)this.btn_ids.push(t.DLG_BTN_PREFIX_ID+h+"_"+s);this.init(r,u,f,e,o)}return __extends(i,n),i.prototype.defineEvents=function(){for(var i=this,n=0;n<this.btn_ids.length;++n)$("#"+this.btn_ids[n]).on("click",function(n){var r=n.currentTarget.id.substr(t.DLG_BTN_PREFIX_ID.length);r=r.substr(0,1);i.deferred.resolve(r);i.win.destroy()})},i.DLG_ID="multiBtnNonModalDialog",i.INSTANCE_COUNTER=1,i}(t);n.MultiBtnNonModalDialog=i}(Project||(Project={})),function(n){(function(n){n[n.NONE=0]="NONE";n[n.LEGAL=1]="LEGAL";n[n.ILLEGAL=2]="ILLEGAL"})(n.CONNECTION_TYPE||(n.CONNECTION_TYPE={}));var t=n.CONNECTION_TYPE,i=function(){function i(n){this.inWiringMode=!1;this.startConnObj=null;this.overConnObj=null;this.forceConnection=!1;this.wire=null;this.wireActiveSegs=null;this.wireSeg=null;this.design=n}return i.prototype.setWireMode=function(n){this.inWiringMode=!0;this.wireActiveSegs=n;this.setDefaultCursor()},i.prototype.terminateWiring=function(t,i){if(i&&this.wireSeg&&this.wireSeg.connectEnd2(i),this.inWiringMode=!1,this.wire&&this.wire.getNumSegments()==0&&(this.wire.remove(),this.wire=null),this.wire&&!this.wire.getNet()){var u=new n.Net(this.design,this.wire),r=this.design.getUndoManager();r.getActiveCommand()&&r.addToStartState(u)}this.reset();this.design.getConnMgr().finalize()},i.prototype.cancelWiring=function(){if(!this.wireSeg&&this.startConnObj instanceof Project.Pin){var n=this.startConnObj;n.getConnection()||n.show()}this.terminateWiring(null,null)},i.prototype.inWireMode=function(){return this.inWiringMode},i.prototype.setStartConn=function(n){this.startConnObj=n},i.prototype.clearStartConn=function(){this.startConnObj=null},i.prototype.mouseOverPin=function(n){this.inWiringMode&&n!=this.startConnObj&&(this.overConnObj=n,this.forceConnection=!1)},i.prototype.mouseOverWireSegment=function(n,t,i){if(this.inWiringMode){if(this.overConnObj instanceof Project.Pin){var r=this.overConnObj;if(r.isEventInside(t))return}this.overConnObj=n;i==null&&(i=!1);this.forceConnection=i}},i.prototype.getConnectionType=function(i){var o=t.NONE,r=null,f,e,s,u,h;return this.overConnObj instanceof Project.Pin?(f=this.overConnObj,f.isEventInside(i)&&(r=f)):this.overConnObj instanceof n.WireSegment&&(e=this.overConnObj,(this.forceConnection||e.isEventInside(i))&&(r=e)),r||(s=Project.Utility.eventToPoint(this.design,i),u=this.design.findCloseWireSegOrPin(s,Project.Settings.SCH_GRID_SPACING,this.startConnObj),u&&(r=u,this.overConnObj=u)),r&&(h=this.getIllegalConnectionMsg(r),o=h==null?t.LEGAL:t.ILLEGAL),o},i.prototype.getIllegalConnectionMsg=function(n){if(this.inWireMode()){var t=this.getWire();return t&&t.getNumSegments()==0&&this.startConnObj instanceof Project.Pin?Project.Utility.getIllegalConnectionMsg(this.startConnObj,n):Project.Utility.getIllegalConnectionMsg(t,n)}return null},i.prototype.okToShowConnectTTip=function(n){return n&&this.wireActiveSegs&&this.getWire()==n.getWire()&&this.wireActiveSegs.getRightAnglePair().combinedLength()<2*Project.Settings.SCH_GRID_SPACING?!1:!0},i.prototype.showConnectTTip=function(n,t,i,r){if(n&&t){var f="top right",u="bottom left";r&&(f=u,u="top right");this.destroyConnectTTip();$(n).qtip({content:{text:t},position:{my:f,at:u},show:{delay:i,ready:!0},style:{classes:"schematic-connect-ttip svw-tooltip"}})}},i.prototype.destroyConnectTTip=function(){$(".schematic-connect-ttip").qtip("destroy")},i.prototype.getConnectObj=function(){return this.overConnObj},i.prototype.ignoreThisObj=function(n){return this.inWiringMode&&n==this.startConnObj?!0:!1},i.prototype.setWire=function(n){this.wire=n},i.prototype.getWire=function(){return this.wire},i.prototype.setDefaultCursor=function(){this.inWiringMode?setBodyCursor("default"):setBodyCursor("auto")},i.prototype.setConnectCursor=function(n){n?setBodyCursor("crosshair"):setBodyCursor("not-allowed")},i.prototype.updateWireSegEnds=function(n){this.wireSeg?n.connectEnd1(this.wireSeg):n.connectEnd1(this.startConnObj);this.wireSeg=n},i.prototype.resetForceFlag=function(){this.forceConnection=!1},i.prototype.reset=function(){this.startConnObj=null;this.overConnObj=null;this.wire=null;this.wireSeg=null;setBodyCursor("auto");this.destroyConnectTTip();this.forceConnection=!1;this.wireActiveSegs=null},i}();n.WiringManager=i}(BaseWire||(BaseWire={})),function(n){var r,t,i;(function(n){n[n.ERROR_MESSAGE=0]="ERROR_MESSAGE";n[n.INVALID_PROP_ERROR_MESSAGE=1]="INVALID_PROP_ERROR_MESSAGE";n[n.WARNING_MESSAGE=2]="WARNING_MESSAGE";n[n.INFO_MESSAGE=3]="INFO_MESSAGE";n[n.LOG_MESSAGE=4]="LOG_MESSAGE"})(n.MessageType||(n.MessageType={}));r=n.MessageType;t=function(){function n(){}return n}();n.StatusMessage=t;i=function(){function t(){}return t.getNotificationJQ=function(){return $("#"+t.NOTIFICATION_ID)},t.addToList=function(n){n&&this.messageList.push(n)},t.removeFromList=function(n){n&&this.messageList.splice($.inArray(n,this.messageList),1)},t.getMessageList=function(){return t.messageList},t.createNotification=function(){t.getNotificationJQ().length<1&&($("body").append('<span id="'+t.NOTIFICATION_ID+'"> <\/span>'),t.getNotificationJQ().hide())},t.showErrorMessage=function(i,r){var u,f;r===void 0&&(r=!1);t.createNotification();n.Settings.notify("design error",{"error message":i});u=!0;r&&(u=!1);f=t.getNotificationJQ().kendoNotification({stacking:"down",show:this.onShow,button:!0,autoHideAfter:0,hideOnClick:u}).data("kendoNotification");i=this.format(i);f.show(i,"error");this.addToList(f)},t.format=function(t){return t.indexOf("<br")!=-1||t.indexOf("<div")!=-1?t:t.indexOf("\r")!=-1||t.indexOf("\n")!=-1?n.Utility.convertNewlinesToHTML(t):this.wordWrap(t)},t.wordWrap=function(n){for(var e,u,c,h=n.split("<br>"),f=0,i=0;i<h.length;i++)e=h[i].length,e>f&&(f=e);if(u="",c="&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp",f>t.MAX_LINE_LENGTH){var l=n.replace("<br>"," "),o=l.split(" "),s=0,r="";for(i=0;i<o.length;i++)r+=o[i],s=r.length,r+=" ",s>t.MAX_LINE_LENGTH&&i<o.length-2&&(u+=r+"<br>"+c,r="",s=0);u+=r}else u=n;return u},t.onShow=function(t){var i,e;if(!$("."+t.sender._guid)[1]){var r=t.element.parent(),o=r.width(),h=r.height(),s=$(window).width(),c=$(window).height(),u,f;f=Math.floor(s/2-o/2);u=100;t.element.parent().css({top:u,left:f});i=5e4;e=n.KendoHelper.getKendoWindowMaxZIndex();i=e+1e3;t.element.parent().css({zIndex:i})}},t.showInvalidPropMessage=function(n){this.invalidPropNotification=$("#invalidPropNotification").kendoNotification({stacking:"down",show:this.onShow,button:!0,autoHideAfter:0,hideOnClick:!1}).data("kendoNotification");this.invalidPropNotification.error(n)},t.showWarningMessage=function(n,i){var r;i?(r=t.getNotificationJQ().kendoNotification({stacking:"down",show:this.onShow,button:!0,autoHideAfter:0,hideOnClick:!1}).data("kendoNotification"),this.addToList(r)):r=t.getNotificationJQ().kendoNotification({stacking:"down",show:this.onShow}).data("kendoNotification");r.warning(n);this.addToList(r)},t.showLogMessage=function(i){var u=n.Utility.convertNewlinesToHTML(i),r=t.getNotificationJQ().kendoNotification({stacking:"down",show:this.onShow,button:!0,autoHideAfter:0}).data("kendoNotification");r.show(u,"info");this.addToList(r)},t.showInfoMessage=function(n,i,r,u){i===void 0&&(i=!0);r===void 0&&(r=5e3);u===void 0&&(u=null);var e=u?u:this.onShow,f=t.getNotificationJQ().kendoNotification({stacking:"down",show:e,autoHideAfter:i?r:0}).data("kendoNotification");f.show(n,"info");this.addToList(f)},t.removeAllMessages=function(){this.removeInvalidPropMessage();this.messageList.forEach(function(n){n.hide()});this.messageList=[]},t.removeInvalidPropMessage=function(){this.invalidPropNotification&&this.invalidPropNotification.hide()},t.writeToConsole=function(n){if(n==null||n==""){console.log("No message");return}var t=n.replace(/<br \/>+/g,"\n");console.log(t)},t.prototype.getErrorLine=function(n){var t,i;return n?(t=n.indexOf("Error"),t>0&&(n=n.substr(t)),i=n.indexOf("\n"),i>0)?n.substr(0,i):n:n},t.invalidPropNotification=null,t.NOTIFICATION_ID="notification",t.MAX_LINE_LENGTH=60,t.messageList=[],t}();n.MessageManager=i}(Project||(Project={})),function(n){var t=function(){function n(){this.errorMsg=""}return n.prototype.ErrorDoubleFormat=function(){return this.errorMsg='Invalid "real" format - please re-enter the value. <br /><br /> Acceptable unit prefixes (from small to large) are: f, p, n, u, m, K, Meg, G, and T. <br /><br />Notes:<br />These prefixes are not case-sensitive.<br />Do not add units.<br />',this.errorMsg},n.prototype.ErrorTimeFormat=function(){return this.errorMsg='Invalid "time" format - please re-enter the value. <br /><br /> Acceptable unit prefixes (from small to large) are: f, p, n, u, m, K, Meg, G, and T. <br /><br />Notes:<br />These prefixes are not case-sensitive.<br />',this.errorMsg},n.prototype.ErrorIntegerFormat=function(){return this.errorMsg='Invalid "integer" format - please re-enter the value. <br /><br />Acceptable prefixes (from small to large) are: K, Meg, and G. <br /><br />Notes:<br />These values are not case-sensitive.<br />Do not include fractional values or units.',this.errorMsg},n.prototype.ErrorBooleanFormat=function(){return this.errorMsg='Invalid "boolean" format - please re-enter the value. <br /><br />Acceptable values are: true or false. Notes:<br />These values are not case-sensitive.',this.errorMsg},n.prototype.ErrorBitFormat=function(){return this.errorMsg="Invalid \"bit\" format - please re-enter the value. <br /><br />Acceptable values are: '0' or '1'. <br /><br /> Notes:<br />These values are not case-sensitive and single quotes are optional.",this.errorMsg},n.prototype.ErrorStdLogicFormat=function(){return this.errorMsg="Invalid \"std_logic\" format - please re-enter the value. <br /><br />Acceptable values are: 'X', '0', '1', 'Z', 'W', 'L', 'H', or '-'. <br /><br /> Notes:<br />These values are not case-sensitive and single quotes are optional.",this.errorMsg},n.prototype.ErrorUnrecognizedFormat=function(){return this.errorMsg="Invalid parameter type. Valid parameter types are: real (or real subtype), time, integer, bit, boolean, and std_logic.",this.errorMsg},n.prototype.ErrorNoValue=function(){return this.errorMsg="Invalid specification in Maximum Ratings table: <br /><br /> Value parameter must be specified",this.errorMsg},n.prototype.ErrorNoTypical=function(){return this.errorMsg="Invalid specification in Electrical Characteristics table: <br /><br /> Parameter does not have a Typical value",this.errorMsg},n.prototype.ErrorNoMaximum=function(){return this.errorMsg="Invalid specification in Electrical Characteristics table: <br /><br /> If Minimum value is supplied, Maximum value must also be supplied",this.errorMsg},n.prototype.ErrorNoMinimum=function(){return this.errorMsg="Invalid specification in Electrical Characteristics table: <br /><br /> If Maximum value is supplied, Minimum value must also be supplied",this.errorMsg},n.prototype.ErrorTypMax=function(){return this.errorMsg="Invalid specification in Electrical Characteristics table: <br /><br /> Typical value must be <= Maximum value",this.errorMsg},n.prototype.ErrorMinTyp=function(){return this.errorMsg="Invalid specification in Electrical Characteristics table: <br /><br /> Minimum value must be <= Typical value",this.errorMsg},n.prototype.ErrorMinTypMax=function(){return this.errorMsg="Invalid specification in Electrical Characteristics table: <br /><br /> Minimum value must be <= Typical value, which must be <= Maximum value",this.errorMsg},n}();n.PropertyEditorMessages=t}(Project||(Project={})),function(n){var t=function(){function t(){this.propertyEditorMessages=new n.PropertyEditorMessages}return t.prototype.ValidateInputValue=function(n,t,i){i===void 0&&(i=!1);var r=n.toLowerCase();return t==""?"":r=="real"?this.CheckRealValue(t)!=null?t:this.propertyEditorMessages.ErrorDoubleFormat():r=="time"?this.CheckTimeValue(t,i)!=null?t:this.propertyEditorMessages.ErrorTimeFormat():r=="integer"?this.CheckIntegerValue(t)!=null?t:this.propertyEditorMessages.ErrorIntegerFormat():r=="std_logic"?this.CheckStdLogicValue(t)!=null?t:this.propertyEditorMessages.ErrorStdLogicFormat():r=="boolean"?this.CheckBooleanValue(t)!=null?t:this.propertyEditorMessages.ErrorBooleanFormat():r=="bit"?this.CheckBitValue(t)!=null?t:this.propertyEditorMessages.ErrorBitFormat():t},t.prototype.CheckRealValue=function(n){if(!n||n.length==0)return null;var t=n.toString().toUpperCase();return t?(this.IsSIPrefix(t)&&(t=t.match("MEG")?t.substr(0,t.length-3):t.substr(0,t.length-1)),isNaN(Number(t))?null:n):null},t.prototype.CheckTimeValue=function(n,t){if((t===void 0&&(t=!1),!n||n.length==0)||(n=this.removeTimePrefix(n),n=this.splitSIPrefix(n)[0],!n||n==""||n.length==0))return null;var i=Number(n);return!isNaN(i)&&(!t||i>=0)?n:null},t.prototype.CheckIntegerValue=function(n){var t=n.toString().toUpperCase();return t?(this.IsIntSIPrefix(t)&&(t=t.match("MEG")?t.substr(0,t.length-3):t.substr(0,t.length-1)),isNaN(Number(t))?null:this.IsInt(t)?n:null):null},t.prototype.CheckStdLogicValue=function(n){var t=n.toString().toUpperCase();return this.IsStdLogic(t)?n:null},t.prototype.CheckBitValue=function(n){return this.IsBit(n)?n:null},t.prototype.CheckBooleanValue=function(n){var t=n.toString().toUpperCase();return this.IsBoolean(t)?n:null},t.prototype.IsInt=function(n){var t=n.indexOf("E"),i=n.substring(0,t!=-1?t:n.length),r;return t!=-1&&n.charAt(t+1)=="-"&&(r=n.substring(t+2,n.length),i/Math.pow(10,r)<.99)?!1:!isNaN(parseInt(i.toString()))&&parseFloat(i.toString())==parseInt(i.toString())},t.prototype.IsSIPrefix=function(n){var t=n.toUpperCase();return t.length>1&&(t.match(/K$/)||t.match(/MEG$/)||t.match(/G$/)||t.match(/T$/)||t.match(/M$/)||t.match(/U$/)||t.match(/N$/)||t.match(/P$/)||t.match(/F$/))?!0:!1},t.prototype.IsIntSIPrefix=function(n){var t=n.toUpperCase();return t.length>1&&(t.match(/K$/)||t.match(/MEG$/)||t.match(/G$/))?!0:!1},t.prototype.IsStdLogic=function(n){return n=="X"||n=="'X'"||n=="Z"||n=="'Z'"||n=="W"||n=="'W'"||n=="L"||n=="'L'"||n=="H"||n=="'H'"||n=="0"||n=="'0'"||n=="1"||n=="'1'"||n=="-"||n=="U"||n=="'U'"?!0:!1},t.prototype.IsBit=function(n){return n=="0"||n=="'0'"||n=="1"||n=="'1'"?!0:!1},t.prototype.IsBoolean=function(n){return n=="TRUE"||n=="'TRUE'"||n=="FALSE"||n=="'FALSE'"?!0:!1},t.prototype.removeTimePrefix=function(n){var i=n.toUpperCase(),t=i.match(/S$|SEC$/);return t?n.substr(0,t.index):n},t.prototype.addTimePrefix=function(n){return n=this.removeTimePrefix(n),n+"s"},t.prototype.splitSIPrefix=function(n){var i=n.toUpperCase(),t=i.match(/MEG$|[T|G|K|M|U|N|P|F]$/);return t?[n.substr(0,t.index),n.substr(t.index,n.length-1)]:[n]},t.prototype.Double2SIUnitPrefixes=function(n){var t=n;return t>=1e3&&t<1e6?(t/1e3).toString()+"K":t>=1e6&&t<1e9?(t/1e6).toString()+"Meg":t>=1e9&&t<1e12?(t/1e9).toString()+"G":t>=1e12?(t/1e12).toString()+"T":t<1&&t>=.001?(t*1e3).toString()+"m":t<=.001&&t>=1e-6?(t*1e6).toString()+"u":t<=1e-6&&t>=1e-9?(t*1e9).toString()+"n":t<=1e-9&&t>=1e-12?(t*1e12).toString()+"p":t<=1e-12&&t>0?(t*1e15).toString()+"f":n.toString()},t.prototype.SIUnitPrefixes2Double=function(n){var t=n.toUpperCase();return t.match(/K$/)?parseFloat(t)*1e3:t.match(/MEG$/)?parseFloat(t)*1e6:t.match(/G$/)?parseFloat(t)*1e9:t.match(/T$/)?parseFloat(t)*1e12:t.match(/M$/)?parseFloat(t)*.001:t.match(/U$/)?parseFloat(t)*1e-6:t.match(/N$/)?parseFloat(t)*1e-9:t.match(/P$/)?parseFloat(t)*1e-12:t.match(/F$/)?parseFloat(t)*1e-15:parseFloat(t)},t.prototype.CheckFormValues=function(){var n="Symbol labels must be least two characters, can be alpha-numeric (no spaces), must begin with a letter, and can contain internal, non-sequential underscores";return $.validator.addMethod("modelNameRegex",function(n){var t=n.split(" ");return t.length>1||n.indexOf("__")!=-1||n.charAt(n.length-1)=="_"?!1:(/^[a-z][a-z_0-9]+$/i.test(n)&&$(GRID_VAL_MSG).fadeOut(200,function(){}),/^[a-z][a-z_0-9]+$/i.test(n))},n),$(SYMBOL_LABEL_FORM).validate({errorPlacement:function(n){var t=$(PROP_GRID_WINDOW),i=t.position(),r=i.top+-10,u=i.left+2*t.width()/3;$(GRID_VAL_MSG).css({position:"absolute",left:u+"px",top:r+"px","max-width":"300px","max-height":"150px",width:"auto"});$(GRID_VAL_MSG).fadeIn(200,function(){});$(GRID_VAL_MSG).html(n.text)},rules:{compLabelInput:{required:!0,modelNameRegex:!0}},messages:{compLabelInput:{required:"Please enter a symbol label",modelNameRegex:n}}}),$(SYMBOL_LABEL_FORM).validate().form()?"true":"false"},t.prototype.GetPropertyType=function(n){var t={integer:"integer",real:"real",std_logic:"std_logic",boolean:"boolean",bit:"bit",time:"time",delay_length:"time",energy:"real",power:"real",periodicity:"real",real_across:"real",real_through:"real",energy_vector:"real_vector",power_vector:"real_vector",periodicity_vector:"real_vector",real_across_vector:"unspecified_vector'across;",real_through_vector:"unspecified_vector'through;",voltage:"real",current:"real",charge:"real",resistance:"real",conductance:"real",capacitance:"real",mmf:"real",electric_flux:"real",electric_flux_density:"real",electric_field_strength:"real",magnetic_flux:"real",magnetic_flux_density:"real",magnetic_field_strength:"real",inductance:"real",reluctance:"real",voltage_vector:"electrical_vector'across;",current_vector:"electrical_vector'through;",mmf_vector:"magnetic_vector'across;",magnetic_flux_vector:"magnetic_vector'through;",charge_vector:"real_vector",resistance_vector:"real_vector",conductance_vector:"real_vector",capacitance_vector:"real_vector",electric_flux_vector:"real_vector",electric_flux_density_vector:"real_vector",electric_field_strength_vector:"real_vector",magnetic_flux_density_vector:"real_vector",magnetic_field_strength_vector:"real_vector",inductance_vector:"real_vector",reluctance_vector:"real_vector",displacement:"real",force:"real",velocity:"real",acceleration:"real",mass:"real",stiffness:"real",damping:"real",momentum:"real",angle:"real",torque:"real",angular_velocity:"real",angular_acceleration:"real",moment_inertia:"real",angular_momentum:"real",angular_stiffness:"real",angular_damping:"real",displacement_vector:"translational_vector'across;",force_vector:"translational_vector'through;",velocity_vector:"translational_velocity_vector'across;",force_velocity_vector:"translational_velocity_vector'through;",angle_vector:"rotational_vector'across;",torque_vector:"rotational_vector'through;",angular_velocity_vector:"rotational_velocity_vector'across;",torque_velocity_vector:"rotational_velocity_vector'through;",acceleration_vector:"real_vector",mass_vector:"real_vector",stiffness_vector:"real_vector",damping_vector:"real_vector",momentum_vector:"real_vector",angular_acceleration_vector:"real_vector",moment_inertia_vector:"real_vector",angular_momentum_vector:"real_vector",angular_stiffness_vector:"real_vector",angular_damping_vector:"real_vector",illuminance:"real",luminous_flux:"real",luminous_intensity:"real",irradiance:"real",luminous_intensity_vector:"radiant_vector'across;",luminous_flux_vector:"radiant_vector'through;",illuminance_vector:"real_vector",irradiance_vector:"real_vector",temperature:"real",heat_flow:"real",thermal_capacitance:"real",thermal_resistance:"real",thermal_conductance:"real",temperature_vector:"thermal_vector'across;",heat_flow_vector:"thermal_vector'through;",thermal_capacitance_vector:"real_vector",thermal_resistance_vector:"real_vector",thermal_conductance_vector:"real_vector",pressure:"real",vflow_rate:"real",mass_flow_rate:"real",volume:"real",density:"real",viscosity:"real",fresistance:"real",fconductance:"real",fcapacitance:"real",inertance:"real",cfresistance:"real",cfcapacitance:"real",cfinertance:"real",cfconductance:"real",pressure_vector:"fluidic_vector'across;",vflow_rate_vector:"fluidic_vector'through;",mass_flow_rate_vector:"compressible_fluidic_vector'through;",volume_vector:"real_vector",density_vector:"real_vector",viscosity_vector:"real_vector",fresistance_vector:"real_vector",fconductance_vector:"real_vector",fcapacitance_vector:"real_vector",inertance_vector:"real_vector",cfresistance_vector:"real_vector",cfconductance_vector:"real_vector",cfcapacitance_vector:"real_vector",cfinertance_vector:"real_vector",real_vector:"real_vector",time_vector:"time_vector",integer_vector:"integer_vector"};return t[n]?t[n]:"otherType"},t}();n.PropertyFormatter=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(){function t(n){this.surface=n}return t.prototype.defineUndoEvents=function(t){var i=this;t.on("keydown",function(t){var i=t.ctrlKey||t.metaKey;(t.which==n.Design.YKey||t.which==n.Design.ZKey)&&i&&t.preventDefault()});t.on("keyup",function(t){var r=t.ctrlKey||t.metaKey;t.which==n.Design.ZKey&&r?i.surface.getDesign().undo(t):t.which==n.Design.YKey&&r&&i.surface.getDesign().redo(t)})},t}(),i;n.UndoableSection=t;i=function(t){function i(n){t.call(this,n);this.window=null;this.contents=null;this.visible=!1;this.pinned=!1;this.grids={};this.schematicToolbarHeight=$(SCHEMATIC_TOOLBAR).outerHeight()}return __extends(i,t),i.prototype.defineEvents=function(){var t=this,o,r,f,u,e;if(this.comp!=null&&this.properties!=null){o=this.window.find(".k-i-unpinned");o.click(function(){t.pin()});r=$(i.COMP_LABEL_INPUT);r.on("blur change",function(){t.updateInstName(r.val())});r.on("keydown",function(i){if(i.which==n.Design.TabKey&&i.shiftKey){i.preventDefault();var r=t.getLastSelectableElement();r&&r.focus()}});r.on("keyup",function(r){r.which==n.Design.TabKey?t.handleTabKey($(i.COMP_LABEL_INPUT)):r.which!=n.Design.EnterKey||t.pinned||t.close()});this.defineUndoEvents(r);f=$(i.COMP_VISIBILITY);f.on("click",function(){t.comp.setInstNameVisibility(!t.comp.getInstNameVisibility());t.comp.getInstNameVisibility()?f.attr("src",i.VISIBILITY_ALL_ICON):f.attr("src",i.VISIBILITY_NONE_ICON)});for(u=0;u<this.properties.length;u++){this.properties[u].defineEvents();e=this.properties[u].getSelectableElement();e.on("keydown",function(i){if(i.which==n.Design.TabKey&&!i.shiftKey){var u=t.getDiv($("#"+i.currentTarget.id)),f=t.getLastVisibleDiv();u.is(f)&&(i.preventDefault(),r.focus())}});e.on("keyup",function(r){var u="#"+r.currentTarget.id,f;$(u).parent().qtip("hide");r.which==n.Design.TabKey?t.handleTabKey($(u)):(f=r,clearTimeout(t.timer),t.timer=setTimeout(function(){var e=u.substring(i.PROP_PREFIX.length),f=t.findProperty(e);f&&f.validate()&&(r.which!=n.Design.EnterKey||t.pinned||t.close())},250))});this.defineUndoEvents(e);this.properties[u].setDefaultTooltip()}this.setEditingMode(this.surface.getEditingMode())}},i.prototype.getDiv=function(n){return n.closest('div[id^="'+i.PROP_DIV_PREFIX_ID+'"]')},i.prototype.getLastVisibleDiv=function(){return $(i.PROP_CONTENT).find(":visible:last").closest("div[id^="+i.PROP_DIV_PREFIX_ID+"]")},i.prototype.getLastSelectableElement=function(){var n=this.getLastVisibleDiv(),t=n.find("input:visible");return t.length>0?t.first():n.find("img:visible").first()},i.prototype.handleTabKey=function(n){var t=this.numPixelsAboveViewableArea(n);if(t>0){this.scrollToProperty(-t);return}t=this.numPixelsBelowViewableArea(n);t>0&&this.scrollToProperty(t)},i.prototype.numPixelsAboveViewableArea=function(n){return $(PROPERTY_EDITOR).offset().top-n.offset().top+$(".prop_editor_text").height()},i.prototype.numPixelsBelowViewableArea=function(n){return n.offset().top+n.parent().height()-($(PROPERTY_EDITOR).offset().top+$(PROPERTY_EDITOR).innerHeight())},i.prototype.scrollToProperty=function(n){$(PROPERTY_EDITOR).animate({scrollTop:$(PROPERTY_EDITOR).scrollTop()+n},100)},i.prototype.setEditingMode=function(n){switch(n){case Schematic.EditingMode.EDITABLE:this.enableEditing();break;case Schematic.EditingMode.DESIGN_EXPLORATION:this.enableParameterChanges();break;case Schematic.EditingMode.RESULTS_VIEWING:this.disableEditing()}},i.prototype.isOpen=function(){return this.visible},i.prototype.open=function(){var u=this,t,r;if(!this.isOpen()){this.window&&this.window.length>0&&this.window.remove();t={actions:["Unpinned","Close"],close:this.onClose,title:"Property Editor"};t=$.extend({},n.KendoHelper.CommonKendoWindowOptions,t);r=$('<div id="'+PROPERTY_EDITOR_ID+'"><\/div>').appendTo(document.body).kendoWindow(t).data("kendoWindow");this.window=$(PROPERTY_EDITOR).parent();$(PROPERTY_EDITOR).data("kendoWindow").wrapper.find(".k-block>.k-header, .k-window-titlebar, .k-window-title").on("dblclick",function(n){n.stopPropagation()});n.KendoHelper.maximizeKendoWindowSpace(this.window);this.window.addClass(i.PROP_EDITOR_WINDOW_CLASS);r.open();this.visible=!0;this.pinned=!1;this.refresh(!0)}},i.prototype.closeOrClear=function(){this.pinned?this.clear():this.close()},i.prototype.closeIfUnpinned=function(){this.pinned||this.close()},i.prototype.getMaxWindowHeight=function(){return surface.getVisibleHeight()-this.schematicToolbarHeight-i.WINDOW_HEIGHT_BUFFER},i.prototype.fitInSchematic=function(){var n=this.getMaxWindowHeight();return this.window.outerHeight()>n&&this.window.outerHeight(n),this.window.outerHeight()},i.prototype.setInitialWindowPosition=function(){var n=surface.schToScreen(this.comp.getCenter()),r=sidebar_manager.getVisibleWidth(Sidebar.Orientation.RIGHT),i=$(window).width()-r,u=surface.getVisibleHeight(),f=this.window.outerWidth(),t=this.fitInSchematic();n.x+f<i&&n.y+t<u?this.window.css({left:n.x,top:n.y}):n.x+f<i&&n.y+t>=u?n.y-t>this.schematicToolbarHeight?this.window.css({left:n.x,top:n.y-t}):this.window.css({left:n.x,top:this.schematicToolbarHeight}):n.x+f>=i&&n.y+t<u?this.window.css({right:i+r-n.x,top:n.y}):n.y-t>this.schematicToolbarHeight?this.window.css({right:i+r-n.x,top:n.y-t}):this.window.css({right:i+r-n.x,top:this.schematicToolbarHeight})},i.prototype.adjustTopAndHeight=function(){var t=$(i.PROP_CONTENT);this.window.innerHeight(t.height()+i.WINDOW_TITLE_HEIGHT+i.WINDOW_SCROLLBAR_HEIGHT);var r=this.fitInSchematic(),u=this.window.offset().top,n=surface.getVisibleHeight();u+this.window.outerHeight()>n&&this.window.css({top:n-r})},i.prototype.pin=function(){var t=this,n=this.window.find(".k-i-unpinned");n.length>0&&(this.pinned=!0,n.unbind("click"),n.removeClass("k-i-unpinned"),n.addClass("k-i-pinned"),n.click(function(){t.unpin()}))},i.prototype.unpin=function(){var t=this,n=this.window.find(".k-i-pinned");n.length>0&&(this.pinned=!1,n.unbind("click"),n.removeClass("k-i-pinned"),n.addClass("k-i-unpinned"),$(i.EMPTY_MESSAGE).length>0?this.closeOrClear():n.click(function(){t.pin()}))},i.prototype.addPropToGrids=function(n,t){this.grids[n]||(this.grids[n]=[]);this.grids[n].push(t)},i.prototype.getGridData=function(t){for(var u,i=this.grids[t],f=new Array(i.length),r=0;r<i.length;++r)u=this.properties[i[r]],f[u.getGridColumn()]=n.Utility.splitVector(u.getValue());return f},i.prototype.getAllGridData=function(t){for(var i,u,r=this.grids[t],e,o=new Array(r.length),s=new Array(r.length),f=0;f<r.length;++f)i=this.properties[r[f]],u=i.getGridColumn(),u==0&&(e=i),o[u]=i.getDisplayName(),s[u]=n.Utility.splitVector(i.getValue());return{firstCol:e,titles:o,data:s}},i.prototype.initGrids=function(){var i,t,r;for(t in this.grids)i=this.getAllGridData(t),i.firstCol.initGrid(i.titles,n.Utility.toGridDataArray(i.data));for(t in this.grids)r=this.properties[this.grids[t][0]],r.shouldBeVisible()||r.setPropVisible(!1)},i.prototype.findGridCompProperty=function(n,t){var i,r;if(!this.grids[n])return null;for(i=0;i<this.grids[n].length;++i)if(r=this.properties[this.grids[n][i]],t==r.getGridColumn())return r;return null},i.prototype.refresh=function(t){var f,i,r,e,u;if(this.isOpen()){for(this.closeAllTips(),f=$(PROPERTY_EDITOR).data("kendoWindow"),f.content(this.contents),this.grids={},i=0;i<this.properties.length;++i)r=this.properties[i],r instanceof n.TableCompProperty&&(e=r,this.addPropToGrids(e.getGridName(),i));this.initGrids();this.defineEvents();this.properties.forEach(function(n){n.shouldBeEnabled()||n.setPropEnabled(!1)});t?this.setInitialWindowPosition():this.adjustTopAndHeight();u=this.findFirstInvalidProperty();u&&this.focusOnPropValue(u)}},i.prototype.clear=function(){if(this.isOpen()){this.updateFieldWithFocus();var n=$(PROPERTY_EDITOR).data("kendoWindow");n.content('<div id="'+i.EMPTY_MESSAGE_ID+'">'+i.EMPTY_MESSAGE_TEXT+"<\/div>");this.adjustTopAndHeight();this.closeAllTips()}},i.prototype.onClose=function(){var n=surface.getPropertyEditor();n.close(!1)},i.prototype.close=function(n){n===void 0&&(n=!0);this.isOpen()&&(this.updateFieldWithFocus(),n&&$(PROPERTY_EDITOR).data("kendoWindow").close(),$(PROPERTY_EDITOR).empty(),this.visible=!1,this.pinned=!1,this.closeAllTips())},i.prototype.findProperty=function(t){var r,u,i;if(t==n.TableCompProperty.EDIT_CELL_SUFFIX)return r=$(n.TableCompProperty.EDIT_CELL).attr("grid-name"),u=parseInt($(n.TableCompProperty.EDIT_CELL).attr("grid-column")),this.findGridCompProperty(r,u);for(i=0;i<this.properties.length;++i)if(t==this.properties[i].Name)return this.properties[i];return null},i.prototype.updateFieldWithFocus=function(){var t,n,u,f,r;if(this.isOpen()&&(t=$(document.activeElement),t&&t.length!=0)){if(n=t[0],n.id=="component_label_input"){this.updateInstName(n.value);return}u=i.PROP_PREFIX_ID.length;n.id.substring(0,u)==i.PROP_PREFIX_ID&&(f=n.id.substring(u),r=this.findProperty(f),r&&r.setValueOnClose()&&r.setValue(n.value))}},i.prototype.updateInstName=function(t){var u=this,r=this.comp.getInstName(),i;r!=t&&(i=this.comp.setInstName(t),$.when(i).done(function(){if(i.state()=="resolved"){var t=surface.getDesign(),f=t.getUndoManager();f.startUndoableCommand(n.RenameComponentCommand,t,r);f.finishUndoableCommand(u.comp.getInstName())}}))},i.prototype.updateErrorMessageLink=function(t,i){var u=$("#invalidPropListDiv"),r;u&&u.is(":visible")&&(r=$("#invalidPropLink_"+this.comp.getInstName()+"_"+t),r&&(i?r.show():(r.hide(),$(".invalidPropLink:visible").length==0&&n.MessageManager.removeInvalidPropMessage())))},i.prototype.validateAll=function(){for(var n=0;n<this.properties.length;n++)this.properties[n].validate()},i.prototype.findFirstInvalidProperty=function(){for(var n=0;n<this.properties.length;++n)if(!this.properties[n].validate(!1))return this.properties[n].Name;return null},i.prototype.update=function(n){var u,t,r;for(this.comp=n,u=this.comp.getInstNameVisibility()?i.VISIBILITY_ALL_ICON:i.VISIBILITY_NONE_ICON,this.contents='<div id="'+i.PROP_CONTENT_ID+'"><div>'+this.comp.getTitle()+"<\/div>",this.contents+='<div class="input-group input input-group-sm" style="width: 100%"><span class="input-group-addon prop_editor_label" style="width: 60px">Label<\/span><input id="component_label_input" type="text" class="form-control undoable '+i.PROP_EDITOR_NAME_CLASS+' prop_editor_data" spellcheck=false value = "'+this.comp.getInstName()+'"><span class="input-group-addon prop_editor_label" style="width: 18px;"><img src="'+u+'" class="visibility_icon" style="opacity: 0.8" id="component_visibility"><\/i><\/span><\/div>',this.properties=this.comp.getProperties(),t=0;t<this.properties.length;t++)r=this.properties[t].getHtml(),r&&(this.contents+=r);this.contents+="<\/div>";this.refresh(!1)},i.prototype.getInstName=function(){return this.comp==null?null:this.comp.getInstName()},i.prototype.setInstNameValue=function(n){$(i.COMP_LABEL_INPUT).val(n)},i.prototype.focusOnInstName=function(){$(i.COMP_LABEL_INPUT).focus();$(i.COMP_LABEL_INPUT).select()},i.prototype.setPropValue=function(n,t){for(var i=0;i<this.properties.length;++i)if(n==this.properties[i].Name){this.properties[i].setElementValue(t);break}},i.prototype.focusOnPropValue=function(n){$(i.PROP_PREFIX+n).focus();$(i.PROP_PREFIX+n).select()},i.prototype.enableEditing=function(){$("."+i.PROP_EDITOR_NAME_CLASS).prop("disabled",!1);$("."+i.PROP_EDITOR_VALUE_CLASS).prop("disabled",!1)},i.prototype.enableParameterChanges=function(){$("."+i.PROP_EDITOR_NAME_CLASS).prop("disabled",!0);$("."+i.PROP_EDITOR_VALUE_CLASS).prop("disabled",!1)},i.prototype.disableEditing=function(){$("."+i.PROP_EDITOR_NAME_CLASS).prop("disabled",!0);$("."+i.PROP_EDITOR_VALUE_CLASS).prop("disabled",!0)},i.prototype.closeAllTips=function(){$(".qtip").qtip("destroy")},i.WINDOW_TITLE_HEIGHT=27,i.WINDOW_SCROLLBAR_HEIGHT=20,i.WINDOW_HEIGHT_BUFFER=2,i.PROP_HEIGHT_PADDING=8,i.PROP_CONTENT_ID="property_editor_content",i.PROP_CONTENT="#"+i.PROP_CONTENT_ID,i.COMP_LABEL_INPUT="#component_label_input",i.COMP_VISIBILITY="#component_visibility",i.PROP_DIV_PREFIX_ID="property_div_",i.PROP_DIV_PREFIX="#"+i.PROP_DIV_PREFIX_ID,i.PROP_PREFIX_ID="property_",i.PROP_PREFIX="#"+i.PROP_PREFIX_ID,i.PROP_VISIBILITY_PREFIX_ID="property_visibility_",i.PROP_VISIBILITY_PREFIX="#"+i.PROP_VISIBILITY_PREFIX_ID,i.PROP_EDITOR_WINDOW_CLASS="prop_editor_window",i.PROP_EDITOR_NAME_CLASS="prop_editor_name",i.PROP_EDITOR_VALUE_CLASS="prop_editor_value",i.PINNED_IMG="/Content/images/pinned.png",i.UNPINNED_IMG="/Content/images/unpinned.png",i.VISIBILITY_ALL_ICON="/Content/images/eyeOpen.png",i.VISIBILITY_VALUE_ICON="/Content/images/eyeHalfOpen.png",i.VISIBILITY_NONE_ICON="/Content/images/eyeHidden.png",i.EMPTY_MESSAGE_ID="prop_editor_empty_message",i.EMPTY_MESSAGE="#"+i.EMPTY_MESSAGE_ID,i.EMPTY_MESSAGE_TEXT="Select a component to see its properties",i}(t);n.PropertyEditor=i}(Project||(Project={})),function(n){var t=function(){function t(n){this.st=$(t.SYMBOL_BAR);this.surface=n;this.enabled=!0;this.setup()}return t.prototype.show=function(n){if(this.enabled){this.comp=n;var r=this.comp.getSymbolBarLocation(),t=this.surface.schToScreen(r.x,r.y),f=r.pos,u=this.st.width(),i=this.st.height();this.showAnimate(.4);switch(f){case BaseWire.COMPASS_POSITION.NORTH:this.st.css("top",t.y-i);this.st.css("left",t.x-u/2);break;case BaseWire.COMPASS_POSITION.EAST:this.st.css("top",t.y-i/2);this.st.css("left",t.x);break;case BaseWire.COMPASS_POSITION.SOUTH:this.st.css("top",t.y);this.st.css("left",t.x-u/2);break;case BaseWire.COMPASS_POSITION.WEST:this.st.css("top",t.y-i/2);this.st.css("left",t.x-u);break;case BaseWire.COMPASS_POSITION.NORTH_EAST:this.st.css("top",t.y-i);this.st.css("left",t.x);break;case BaseWire.COMPASS_POSITION.SOUTH_EAST:this.st.css("top",t.y);this.st.css("left",t.x)}}},t.prototype.hide=function(n){var t=this;n?this.st.stop().animate({opacity:0},800,function(){t.st.hide()}):this.st.stop().hide()},t.prototype.enable=function(){this.enabled=!0},t.prototype.disable=function(){this.enabled=!1;this.hide()},t.prototype.showAnimate=function(n){this.st.show();this.st.stop().animate({opacity:n},100)},t.prototype.setup=function(){var i=this;this.st.hover(function(){i.showAnimate(1)},function(){i.hide(!0)});$(t.XMIRROR_BUTTON).css("background-image",t.XMIRROR_ICON);$(t.YMIRROR_BUTTON).css("background-image",t.YMIRROR_ICON);$(t.ROTATE_BUTTON).click(function(){var t=i.comp.getMirror();t==n.MIRROR.MIRROR_NONE?i.comp.rotate(n.ROTATION.ROT_90):i.comp.rotate(n.ROTATION.ROT_MINUS90)});n.Utility.setTooltip(t.ROTATE_BUTTON,t.ROTATE_TTIP_TEXT);$(t.YMIRROR_BUTTON).click(function(){var t=i.comp.getRotation();t==n.ROTATION.ROT_0||t==n.ROTATION.ROT_180?i.comp.yMirror():i.comp.xMirror()});n.Utility.setTooltip(t.YMIRROR_BUTTON,t.YMIRROR_TTIP_TEXT);$(t.XMIRROR_BUTTON).click(function(){var t=i.comp.getRotation();t==n.ROTATION.ROT_0||t==n.ROTATION.ROT_180?i.comp.xMirror():i.comp.yMirror()});n.Utility.setTooltip(t.XMIRROR_BUTTON,t.XMIRROR_TTIP_TEXT)},t.SYMBOL_BAR="#symTools",t.ROTATE_BUTTON="#rotateButton",t.XMIRROR_BUTTON="#xMirrorButton",t.YMIRROR_BUTTON="#yMirrorButton",t.ROTATE_TTIP_TEXT="Rotate Clockwise",t.XMIRROR_TTIP_TEXT="Flip Vertical",t.YMIRROR_TTIP_TEXT="Flip Horizontal",t.XMIRROR_ICON="url(/Content/images/flip_x_axis.gif)",t.YMIRROR_ICON="url(/Content/images/flip_y_axis.gif)",t}();n.SymbolBar=t}(Project||(Project={})),function(n){var t=function(){function t(n){this.wb=$(t.WIRE_BAR);this.surface=n;this.wireSeg=null;this.point=null;this.enabled=!0;this.setup()}return t.prototype.show=function(i,r,u){this.enabled&&(this.wireSeg=i,this.point=r,this.editable=u,this.showAnimate(.6),u?(this.wireSeg.getOrient()==BaseWire.ORIENTATION.VERTICAL?(this.orient=BaseWire.ORIENTATION.VERTICAL,this.wireSeg.isBus()?$(t.ATTACHWIRE_BUTTON).css("background-image",t.VERTICAL_WIRE_ICON):$(t.ATTACHWIRE_BUTTON).css("background-image",t.VERTICAL_WIRE_ICON)):(this.orient=BaseWire.ORIENTATION.HORIZONTAL,this.wireSeg.isBus()?$(t.ATTACHWIRE_BUTTON).css("background-image",t.HORIZONTAL_WIRE_ICON):$(t.ATTACHWIRE_BUTTON).css("background-image",t.HORIZONTAL_WIRE_ICON)),this.wireSeg.isBus()?n.Utility.setTooltip(t.ATTACHWIRE_BUTTON,t.BUS_TTIP_TEXT):this.wireSeg.canConnectProbe()&&n.Utility.setTooltip(t.ATTACHWIRE_BUTTON,t.WIRE_TTIP_TEXT)):$(t.ATTACHWIRE_BUTTON).css("background-image",""),this.moveTo(r))},t.prototype.moveTo=function(n){this.orient==BaseWire.ORIENTATION.VERTICAL?this.wb.css({left:n.x+16,top:n.y-8}):this.wb.css({left:n.x-7,top:n.y-25})},t.prototype.hide=function(n){var t=this;n?this.wb.stop().animate({opacity:0},800,function(){t.wb.hide()}):this.wb.stop().hide()},t.prototype.enable=function(){this.enabled=!0},t.prototype.disable=function(){this.enabled=!1;this.hide()},t.prototype.showAnimate=function(n){this.wb.show();this.wb.stop().animate({opacity:n},100)},t.prototype.setup=function(){var i=this;this.wb.hover(function(){WaveViewer.SVWEventHandler.getIsMoving()||i.showAnimate(1)},function(){i.hide(!0)});$(t.ATTACHWIRE_BUTTON).click(function(n){new BaseWire.WireActiveSegments(i.surface.getDesign(),n,i.wireSeg);i.hide(!1);i.surface.getDesign().clearSelection()});n.Utility.setTooltip(t.ATTACHWIRE_BUTTON,t.WIRE_TTIP_TEXT)},t.WIRE_BAR="#wireTools",t.ATTACHWIRE_BUTTON="#attachWireButton",t.WIRE_TTIP_TEXT="Start New Wire Connected to this Wire",t.BUS_TTIP_TEXT="Start New Bus Connected to this Bus",t.PROBE_TTIP_TEXT="Attach Waveform Probe to this Wire",t.VERTICAL_WIRE_ICON="url(/Content/images/wire_connect_x.gif)",t.HORIZONTAL_WIRE_ICON="url(/Content/images/wire_connect_y.gif)",t}();n.WireBar=t}(Project||(Project={})),function(n){var t,u,f,i,r;(function(n){n[n.NONE=0]="NONE";n[n.NORMAL=1]="NORMAL";n[n.ERROR=2]="ERROR"})(n.QUICK_CONNECT_HIGHLIGHT||(n.QUICK_CONNECT_HIGHLIGHT={}));t=n.QUICK_CONNECT_HIGHLIGHT;u=function(){function u(t,i,r,f){var o;if(this.probeList=[],this.design=null,this.paper=null,this.path=null,this.indicatorPath=null,this.selected=!1,this.overlay=null,this.end1Connection=null,this.end2Connection=null,this.end1QuickConnect=null,this.end2QuickConnect=null,this.uniqName=null,this.technology=Project.TECHNOLOGY.ELEC,this.zeroLength=!1,this.typeBus=!1,this.visible=!0,this.wireBarVisible=!1,this.bbox_tol=14,this.design=t,this.paper=t.getPaper(),this.wire=null,i instanceof n.Segment)o=i,o.round(),this.seg=o.clone(),r?(this.typeBus=!0,this.uniqName=this.design.createUniqName(u.BUS_NAME_PREFIX)):this.uniqName=this.design.createUniqName(u.WS_NAME_PREFIX),f&&(this.technology=f);else{var e=i,s=new n.Point(e.x1,e.y1),h=new n.Point(e.x2,e.y2);this.seg=new n.Segment(s,h);this.uniqName=e.uniqName;this.typeBus=e.isBus==!0;e.technology&&(this.technology=e.technology)}this.zeroLength=this.seg.isZeroLength()?!0:!1;this.draw();this.buildOverlay();this.defineEvents();this.addToDesign()}return u.prototype.remove=function(){this.removeInternal(!1)},u.prototype.removeForWireDelete=function(){this.removeInternal(!0)},u.prototype.highlight=function(){this.path.node.removeAttribute("class");this.path.node.setAttribute("class",this.getClass(!0))},u.prototype.crossHighlight=function(){this.specialHighlight(Schematic.Surface.CROSS_HIGHLIGHT_COLOR,"0.5")},u.prototype.errorHighlight=function(n){this.specialHighlight(Schematic.Surface.ERROR_HIGHLIGHT_COLOR,"1");n&&this.showQuickConnect(n,t.ERROR)},u.prototype.specialHighlight=function(n,t){this.toFront();Project.Utility.finishAnimation(this.indicatorPath);this.indicatorPath.attr("stroke",n);this.indicatorPath.animate({opacity:t},300)},u.prototype.unhighlight=function(){this.path.node.removeAttribute("class");this.path.node.setAttribute("class",this.getClass(!1));Project.Utility.finishAnimation(this.indicatorPath);var n=this.seg.toPath();this.indicatorPath.attr({path:n});this.isSelected()?this.indicatorPath.animate({stroke:Schematic.Surface.SELECTION_COLOR},300):this.indicatorPath.animate({opacity:"0"},300)},u.prototype.highlightNet=function(){if(this.wire&&this.wire.getNet()){var n=null;this.wire.isBit()&&(n=this.wire.getBitIndex());this.wire.getNet().highlight(n,this.wire)}},u.prototype.unhighlightNet=function(){this.wire&&this.wire.getNet()&&this.wire.getNet().unhighlight()},u.prototype.select=function(n){this.toFront();this.bothEndsToFront();this.indicatorPath.attr("stroke",Schematic.Surface.SELECTION_COLOR);n==null||n==!0?this.indicatorPath.animate({opacity:"1"},300):this.indicatorPath.attr("opacity","1");this.selected=!0},u.prototype.deselect=function(n){this.path&&(n==null||n==!0?this.indicatorPath.animate({opacity:"0"},300):this.indicatorPath.attr("opacity","0"),this.selected=!1)},u.prototype.isSelected=function(){return this.selected},u.prototype.hide=function(){this.wire.removeNametag();this.path.hide();this.indicatorPath.hide();this.overlay.hide();this.hideQuickConnects();this.visible=!1},u.prototype.show=function(){this.path.show();this.indicatorPath.show();this.overlay.show();this.wire.buildNametag();this.visible=!0},u.prototype.isVisible=function(){return this.visible},u.prototype.getTechnology=function(){return this.technology},u.prototype.setTechnology=function(n){var t,i;for(this.technology!=n&&(this.technology=n,this.path.node.removeAttribute("class"),this.path.node.setAttribute("class",this.getClass(!1)),this.setQuickConnectTechnology()),t=1;t<=2;++t)i=this.getConnection(t),i!=null&&i.setTechnology()},u.prototype.getClass=function(n){return this.design.getCssClassMgr().getWireSegmentClass(this.getTechnology(),this.isBus(),n)},u.prototype.getSegment=function(){return this.seg},u.prototype.getOrient=function(){return this.seg.getOrient()},u.prototype.isBus=function(){return this.typeBus},u.prototype.isBit=function(){return this.getWire()&&this.getWire().isBit()?!0:!1},u.prototype.getBoundingRect=function(){var i,n,t;if(!this.overlay||(i=this.overlay.node,!i))return null;try{return n=i.getBBox(),n&&(n.width!=0||n.height!=0)?(t=new Project.BoundingRect(n),t.x2=n.x+n.width,t.y2=n.y+n.height,t):null}catch(r){return null}},u.prototype.isInsideBox=function(n,t,i,r){return this.seg.point1.isInsideBox(n,t,i,r)&&this.seg.point2.isInsideBox(n,t,i,r)?!0:!1},u.prototype.isZeroLength=function(){return this.zeroLength},u.prototype.isEventInside=function(n){var t=Project.Utility.eventToPoint(this.design,n);return this.isPointInside(t)},u.prototype.isPointInside=function(n){var t=this.getBoundingRect();return Project.Utility.isPointInsideBoundingRect(t,n.x,n.y)},u.prototype.getOverlappingEnds=function(){for(var r,t,i=[],n=1;n<=2;n++)this.getConnection(n)||(r=this.getEndLocation(n),t=this.design.findObjectUnderPoint(r,this),t&&(t instanceof Project.Pin||t instanceof u)&&i.push(n));return i},u.prototype.getWire=function(){return this.wire},u.prototype.associateWire=function(n){this.wire=n;this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.getNet=function(){return this.wire?this.wire.getNet():null},u.prototype.connectEnd1=function(n){n&&this.connectEnd(n,1)},u.prototype.connectEnd2=function(n){n&&this.connectEnd(n,2)},u.prototype.disconnectEnd1=function(){this.end1Connection&&this.end1Connection.disconnectWireSegment(this,1);this.removeConnection(1)},u.prototype.disconnectEnd2=function(){this.end2Connection&&this.end2Connection.disconnectWireSegment(this,2);this.removeConnection(2)},u.prototype.attachConnection=function(n,t){t==1?this.end1Connection=n:this.end2Connection=n;this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.removeConnection=function(n){n==1?this.end1Connection=null:this.end2Connection=null;this.removeQuickConnect(n);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.getConnection=function(n){return n==1?this.end1Connection:this.end2Connection},u.prototype.getEnd=function(n){return this.getConnection(1)==n?1:this.getConnection(2)==n?2:-1},u.prototype.canConnectProbe=function(){return!0},u.prototype.addProbe=function(n){this.probeList.push(n);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX);n.makePencilVisible()},u.prototype.removeProbe=function(n){var t=this.probeList.indexOf(n);t>=0&&this.probeList.splice(t,1);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},u.prototype.getProbes=function(){return this.probeList},u.prototype.getWaveboxes=function(n){for(var r,i,t=0;t<this.probeList.length;t++)r=this.probeList[t],r&&(i=r.getWavebox(),i&&!Project.Utility.uniqNameInArray(i.getUniqName(),n)&&n.push(i))},u.prototype.getNumProbes=function(){return this.probeList.length},u.prototype.getUniqName=function(){return this.uniqName},u.prototype.getEndLocation=function(n){var t=this.getExactEndLocation(n);return t.round(),t},u.prototype.getExactEndLocation=function(n){return n==1?this.seg.point1.clone():this.seg.point2.clone()},u.prototype.getMiddleLocation=function(){var t=this.seg.point1.clone(),i=this.seg.point2.clone(),r,u;return this.seg.isHorizontal()?(r=t.x<i.x?t:i,u=t.x<i.x?i:t,new n.Point(r.x+(u.x-r.x)/2,r.y)):this.seg.isVertical()?(r=t.y<i.y?t:i,u=t.y<i.y?i:t,new n.Point(r.x,r.y+(u.y-r.y)/2)):null},u.prototype.getQuadrant=function(n){var t=n==1?2:1,i=this.getEndLocation(n),r=this.getEndLocation(t);return i.quadrant(r)},u.prototype.getClosest=function(n){return this.seg.getClosest(n)},u.prototype.getClosestScreen=function(n){var t=Project.Utility.eventToPoint(this.design,n),i=this.getClosest(t);return this.design.getSurface().schToScreen(i)},u.prototype.getClosestSch=function(n){var t=Project.Utility.eventToPoint(this.design,n);return this.getClosest(t)},u.prototype.getClosestToGrid=function(n,t){return this.seg.getClosestToGrid(n,t)},u.prototype.getDistanceFrom=function(n){return this.seg.getDistanceFrom(n)},u.prototype.moveEndTo=function(n,t){n.round();t==1?this.seg.point1=n.clone():this.seg.point2=n.clone();this.zeroLength=this.seg.isZeroLength()?!0:!1;this.updateLocation(t)},u.prototype.dragRelative=function(n,t){this.seg.transform(n,t);this.updateLocation()},u.prototype.shorten=function(n,t){if(!this.isZeroLength()){t==null&&(t=1);var i;i=n==1?this.seg.offsetFromPoint1(t*Project.Settings.SCH_GRID_SPACING):this.seg.offsetFromPoint2(t*Project.Settings.SCH_GRID_SPACING);this.moveEndTo(i,n)}},u.prototype.createConnectedWireSegment=function(t,i){t.round();var e=new n.Segment(t,this.getEndLocation(i)),r=new u(this.design,e,this.isBus(),this.getTechnology()),f=this.getConnection(i);return f&&(f.moveTo(t),f.replaceWireSegment(r,1,this,i)),r.wire=this.wire,r.wire&&r.wire.addWireSegment(r),this.connectWireSegmentEnds(i,r,2),this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS),r},u.prototype.connectWireSegmentEnds=function(t,i,r){var u=this.getConnection(t),f=i.getConnection(r),e;u&&f?u.merge(f):u?u.connectToWireSegment(i,r):f?f.connectToWireSegment(this,t):(e=new n.Connection(this.design),e.connectToWireSegment(this,t),e.connectToWireSegment(i,r));this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.getConnectedWireSegments=function(n){var t,i,f,r,u;if(!(n.indexOf(this)>=0))for(n.push(this),t=1;t<=2;++t)if(i=this.getConnection(t),i!=null)for(f=i.getNumConnectedWireSegments(),r=0;r<f;++r)u=i.getWireSegment(r),u!=this&&u.getConnectedWireSegments(n)},u.prototype.getAnyConnectedPin=function(){for(var t,n=1;n<=2;++n)if(t=this.getConnection(n),t!=null&&t.getNumConnectedPins()>0)return t.getPin(0);return null},u.prototype.getNumConnectedPins=function(){for(var t,i=0,n=1;n<=2;++n)t=this.getConnection(n),t!=null&&(i+=t.getNumConnectedPins());return i},u.prototype.getSaveData=function(){var n=new r;return n.uniqName=this.uniqName,n.isBus=this.isBus(),n.x1=Math.round(this.seg.point1.x),n.y1=Math.round(this.seg.point1.y),n.x2=Math.round(this.seg.point2.x),n.y2=Math.round(this.seg.point2.y),n.technology=this.technology,n},u.prototype.restore=function(n){n.uniqName==this.uniqName&&(this.seg.point1.x=n.x1,this.seg.point1.y=n.y1,this.seg.point2.x=n.x2,this.seg.point2.y=n.y2,this.updateLocation(),this.zeroLength=this.seg.isZeroLength())},u.prototype.getCloneData=function(){return new i(this)},u.prototype.appendConnectedPins=function(n){this.end1Connection&&this.end1Connection.appendConnectedPins(n);this.end2Connection&&this.end2Connection.appendConnectedPins(n)},u.prototype.getForcedName=function(){for(var t,i,n=1;n<=2;n++)if(t=this.getConnection(n),t&&(i=t.getForcedNetName(),i))return i;return null},u.prototype.split=function(t){var f=t.getLocation(),e=this.seg.point1,r=f,o=this.seg.point2,s=new n.Segment(e,r),h=new n.Segment(r,o),i;return this.removeGraphics(),this.seg=s,this.draw(),this.buildOverlay(),this.defineEvents(),i=new u(this.design,h,this.isBus(),this.getTechnology()),this.end2Connection&&this.end2Connection.replaceWireSegment(i,2,this,2),i.wire=this.wire,i.wire&&i.wire.addWireSegment(i),t.connectToWireSegment(this,2),t.connectToWireSegment(i,1),this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS),i},u.prototype.dump=function(n,t){Project.Utility.dumpHeading(n,t);this.seg.dump(n);this.end1Connection&&Project.Utility.dump(n,"end1 connection: "+this.end1Connection.dump(n));this.end2Connection&&Project.Utility.dump(n,"end2 connection: "+this.end2Connection.dump(n));Project.Utility.dump(n,"uniqName = "+this.uniqName)},u.prototype.draw=function(){var n=this.seg.toPath(),t;return this.path?(this.path.attr({path:n}),this.indicatorPath.attr({path:n}),this.dragQuickConnects()):(this.indicatorPath=this.paper.path(n),this.path=this.paper.path(n),this.path.node.setAttribute("class",this.getClass(!1)),t=this.isBus()?u.BUS_INDICATOR_WIDTH:u.WIRE_INDICATOR_WIDTH,this.indicatorPath.attr({stroke:Schematic.Surface.SELECTION_COLOR,"stroke-width":t,"stroke-linejoin":"round","stroke-linecap":"round",opacity:0})),this.path},u.prototype.buildOverlay=function(){if(this.path){var n=this.path.getBBox(),t,i,r,u;this.seg.isZeroLength()?(t=n.x,i=n.y,r=n.width,u=n.height):this.seg.isHorizontal()?(t=n.x,i=n.y-this.bbox_tol/2,r=n.width,u=this.bbox_tol):this.seg.isVertical()?(t=n.x-this.bbox_tol/2,i=n.y,r=this.bbox_tol,u=n.height):(t=n.x,i=n.y,r=n.width,u=n.height);this.overlay?this.overlay.attr({x:t,y:i,width:r,height:u}):(this.overlay=this.paper.rect(t,i,r,u),this.overlay.attr("opacity","0"),this.overlay.attr("fill","#ffff00"))}},u.prototype.removeInternal=function(n){var i=null,t;if(this.wire&&(i=this.wire.getNet()),n||i===null||i.unhighlight(),!this.isVisible())for(t=0;t<this.probeList.length;t++)this.probeList[t].show();this.probeList=[];this.removeGraphics();this.removeFromDesign();!n&&this.wire&&(this.wire.removeWireSegment(this,n),this.wire.removeIfEmpty());this.disconnect();this.design.getWireBar().hide(!1);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.removeGraphics=function(){this.path&&(this.path.remove(),this.path=null);this.indicatorPath&&(this.indicatorPath.remove(),this.indicatorPath=null);this.overlay&&(this.overlay.remove(),this.overlay=null);this.removeQuickConnect(1);this.removeQuickConnect(2)},u.prototype.showQuickConnects=function(){var n,i;if(surface.isEditable())for(n=1;n<=2;++n)i=this.getConnection(n),!i||i.getNumConnectedWireSegments()>=2?this.showQuickConnect(n,t.NONE):this.removeQuickConnect(n)},u.prototype.dragQuickConnects=function(){var n,t;this.end1QuickConnect&&(n=this.getEndLocation(1),this.end1Connection?(this.end1QuickConnect.attr("cx",n.x),this.end1QuickConnect.attr("cy",n.y)):(t=this.getQuickConnectSize(),this.end1QuickConnect.attr("x",n.x-t),this.end1QuickConnect.attr("y",n.y-t)));this.end2QuickConnect&&(n=this.getEndLocation(2),this.end2Connection?(this.end2QuickConnect.attr("cx",n.x),this.end2QuickConnect.attr("cy",n.y)):(t=this.getQuickConnectSize(),this.end2QuickConnect.attr("x",n.x-t),this.end2QuickConnect.attr("y",n.y-t)))},u.prototype.hideQuickConnects=function(){this.end1QuickConnect&&this.end1QuickConnect.animate({opacity:0},400);this.end2QuickConnect&&this.end2QuickConnect.animate({opacity:0},400)},u.prototype.removeQuickConnect=function(n){n==1&&this.end1QuickConnect?(this.end1QuickConnect.remove(),this.end1QuickConnect=null):n==2&&this.end2QuickConnect&&(this.end2QuickConnect.remove(),this.end2QuickConnect=null)},u.prototype.showQuickConnect=function(n,i){var r=2,u;if(i==t.ERROR)this.getConnection(n)||(r=10);else{if(u=this.seg.length(),u<20)return;i!=t.NORMAL||this.getConnection(n)||(r=5)}n==1?(this.end1QuickConnect||(this.end1QuickConnect=this.createQuickConnectGraphic(n)),this.end1QuickConnect.animate({opacity:1,"stroke-width":r},400),this.end1QuickConnect.toFront()):(this.end2QuickConnect||(this.end2QuickConnect=this.createQuickConnectGraphic(n)),this.end2QuickConnect.animate({opacity:1,"stroke-width":r},400),this.end2QuickConnect.toFront())},u.prototype.quickConnectsToFront=function(){this.end1QuickConnect&&this.end1QuickConnect.toFront();this.end2QuickConnect&&this.end2QuickConnect.toFront()},u.prototype.setQuickConnectTechnology=function(){this.end1QuickConnect&&this.end1QuickConnect.node.removeAttribute("class");this.end2QuickConnect&&this.end2QuickConnect.node.removeAttribute("class");var n=this.getQuickConnectClass();this.end1QuickConnect&&this.end1QuickConnect.node.setAttribute("class",n);this.end2QuickConnect&&this.end2QuickConnect.node.setAttribute("class",n)},u.prototype.createQuickConnectGraphic=function(n){var i=this.getEndLocation(n),t;if(this.getConnection(n))t=this.design.getPaper().circle(i.x,i.y,4);else{var r=this.getQuickConnectSize(),f=i.x-r,e=i.y-r,u=r*2,o=u;t=this.design.getPaper().rect(f,e,u,o)}return t.attr("stroke-width","2"),t.attr("opacity",0),t.toFront(),t.node.setAttribute("class",this.getQuickConnectClass()),this.defineQuickConnectEvents(t,n),t},u.prototype.getQuickConnectClass=function(){return this.design.getCssClassMgr().getQuickConnectClass(this.getTechnology())},u.prototype.defineQuickConnectEvents=function(t,i){var r=this;Project.Utility.hoverEventWithToFront(t,function(n){r.hoverInQuickConnect(n,t,i)},function(){r.hoverOutQuickConnect()});t.mousedown(function(t){var u,f;surface.isEditable()&&(r.removeQuickConnect(i),r.design.getWireMgr().destroyConnectTTip(),r.design.getWireMgr().inWireMode()||(u=r.attemptConnectionAtEnd(i),u||(f=new n.WireActiveSegments(r.design,t,r),WaveViewer.SVWEventHandler.setIsMoving(f)),r.design.clearSelection()))})},u.prototype.attemptConnectionAtEnd=function(n){var e=!1,o=this.getConnection(n),r,i,f;if(!o||o.getNumConnections()==1){var s=this.getEndLocation(n),t=this.design.findCloseWireSegOrPin(s,2,this);t&&(e=!0,r=Project.Utility.getIllegalConnectionMsg(this,t),r?Project.MessageManager.showInfoMessage(r,!0):t instanceof u&&t.getWire()!=this.getWire()?(i=t,this.design.getUndoManager().startUndoableCommand(Project.ModifyWireCommand,this.design,this.getWire()),this.design.getUndoManager().addToStartState(i.getWire()),this.connectEndToWireSegment(i,n),this.getWire().merge(i.getWire()),this.design.getConnMgr().finalize(),this.design.getUndoManager().finishUndoableCommand(null)):t instanceof Project.Pin&&(f=t,this.design.getUndoManager().startUndoableCommand(Project.MoveComponentCommand,this.design,f.getComponent()),f.tryToConnect(0,0),this.design.getConnMgr().finalize(),this.design.getUndoManager().finishUndoableCommand(null)))}return e},u.prototype.hoverInQuickConnect=function(n,t,i){surface.isEditable()&&this.design.isHoverEnabled()&&this.mouseOverQuickConnect(t,n,i)},u.prototype.hoverOutQuickConnect=function(){surface.isEditable()&&this.design.isHoverEnabled()&&(setBodyCursor("default"),this.design.getWireMgr().destroyConnectTTip(),this.hideQuickConnects(),this.design.getWireMgr().resetForceFlag())},u.prototype.mouseOverQuickConnect=function(n,i,r){var f=this.design.getWireMgr();this.design.getWireBar().hide();f.mouseOverWireSegment(this,i,!0);var o=!1,s=0,e=f.getIllegalConnectionMsg(this);e==null&&(o=!0,this.showQuickConnect(r,t.NORMAL),f.inWireMode()||(e=this.isBus()?u.BUS_TTIP_TEXT:u.WIRE_TTIP_TEXT,s=Schematic.Surface.TTIP_DELAY));f.setConnectCursor(o);f.showConnectTTip(n.node,e,s)},u.prototype.getQuickConnectSize=function(){return this.isBus()?Project.Pin.SIZE_VECTOR:Project.Pin.SIZE_SCALAR},u.prototype.crossHighlightInViewer=function(n){WaveViewer.getManager().getCrossHighlightManager().crossHighlightBySchematicElement(this.getWire().getNamePrefix(),!1,n)},u.prototype.getWireBarLocation=function(n){var f=this.getClosestScreen(n),i=f.clone(),t=this.getBoundingRect(),r,u;return t&&(r=surface.schToScreen(t.x1,t.y1),u=surface.schToScreen(t.x2,t.y2),this.isVertical()?i.x+=(u.x-r.x)/2:i.y-=(u.y-r.y)/2),i},u.prototype.defineEvents=function(){var n=this,t=this.design.getWireMgr();if(this.overlay&&(this.dragWireSegHandler=new f(this.design,this),this.overlay.mousemove(function(t){if(n.wireBarVisible&&n.isSelected()){var i=n.getWireBarLocation(t);i&&n.design.getWireBar().moveTo(i)}}),this.overlay.hover(function(t){n.hoverIn(t)},function(){n.hoverOut()}),surface.isEditable())){this.overlay.mousedown(function(i){if(Messaging.Handler.sendSetFocusMessage(),!t.inWireMode()){var r;r=i.shiftKey?n.wire:n;n.design.getSelectionManager().isSelected(r)?n.design.getSurface().clearFocus():(n.design.selectObject(r,i),n.dragWireSegHandler.setSkipSelection())}});var i=function(i,r,u){return t.inWireMode()||n.dragWireSegHandler.dragStart(i,r,u),{}},r=function(i,r,u,f,e){return t.inWireMode()||n.dragWireSegHandler.dragMove(i,r,u,f,e),{}},u=function(i){return t.inWireMode()||n.dragWireSegHandler.dragEnd(i),{}};this.overlay.drag(r,i,u)}},u.prototype.hoverIn=function(t){var i,r,u,f,e,o;!WaveViewer.SVWEventHandler.getIsMoving()&&this.design.isHoverEnabled()&&(this.crossHighlightInViewer(!0),i=this.design.getWireMgr(),i.mouseOverWireSegment(this,t),r=!1,u=i.getIllegalConnectionMsg(this),u==null&&(r=!0,this.showQuickConnects()),surface.isEditable()&&(f=this.getClosestSch(t),i.setConnectCursor(r),r==!1&&i.okToShowConnectTTip(this)&&(e=this.design.getSurface().getTTipNode(),this.design.getSurface().moveTTipRect(f.x,f.y-10),i.showConnectTTip(e,u,0))),i.inWireMode()||(this.wireBarVisible=!0,this.design.getSymbolBar().hide(),this.nametagOnMouseover(),Project.Utility.isIE()||this.toFront(),this.highlightNet(),this.isSelected()&&this.showWireBar(t),surface.isEditable()&&(o=this.design.getSelectionManager(),this.isSelected()&&o.getNumSelected()>1?setBodyCursor("move"):this.getOrient()==n.ORIENTATION.VERTICAL?setBodyCursor("w-resize"):setBodyCursor("n-resize"))))},u.prototype.showWireBar=function(n){var t=this.getWireBarLocation(n);t&&this.design.getWireBar().show(this,t,surface.isEditable())},u.prototype.hoverOut=function(){if(!WaveViewer.SVWEventHandler.getIsMoving()&&this.design.isHoverEnabled()){this.crossHighlightInViewer(!1);var n=this.design.getWireMgr();this.wireBarVisible=!1;this.unhighlightNet();this.design.getWireBar().hide(!0);setBodyCursor("default");this.hideQuickConnects();this.nametagOnMouseout();n.destroyConnectTTip()}},u.prototype.disconnect=function(){for(var t,n=1;n<=2;++n)t=this.getConnection(n),t&&t.disconnectWireSegment(this,n)},u.prototype.updateLocation=function(n){var t,i,n,r,u;for(this.draw(),t=1,i=2,n&&(t=n,i=n),n=t;n<=i;++n)r=this.getConnection(n),r&&(u=this.getEndLocation(n),r.moveTo(u));this.buildOverlay();this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.outputDebug=function(){var n=this.uniqName,i,r,t,u;if(n+=" pt1 = ("+this.seg.point1.x+", "+this.seg.point1.y+")",n+="    pt2 = ("+this.seg.point2.x+", "+this.seg.point2.y+")",console.log(n),this.end1Connection){for(n=this.end1Connection.getUniqName()+"  {",r=this.end1Connection.getNumConnectedWireSegments(),t=0;t<r;++t)t>0&&(n+=", "),u=this.end1Connection.getWireSegment(t),n+=u.getUniqName();n+="}";i=this.end1Connection.getLocation();i.isAlmostEqual(this.seg.point1)||(n+="******** CONNECTION DOT 1 AT WRONG LOCATION  ************",n+="   ("+i.x+", "+i.y+")")}else n="NC1 ";if(this.end2Connection){for(n+="   "+this.end2Connection.getUniqName()+" {",r=this.end2Connection.getNumConnectedWireSegments(),t=0;t<r;++t)t>0&&(n+=", "),u=this.end2Connection.getWireSegment(t),n+=u.getUniqName();n+="}";i=this.end2Connection.getLocation();i.isAlmostEqual(this.seg.point2)||(n+="******** CONNECTION DOT 2 AT WRONG LOCATION  ************",n+="   ("+i.x+", "+i.y+")")}else n+="   NC2 ";console.log(n)},u.prototype.queryNetName=function(n,t){surface.isEditable()&&this.wire&&this.wire.getNet()&&(this.design.getWireBar().hide(),this.wire.getNet().queryNetName(n,t,this))},u.prototype.isVertical=function(){return this.seg.isVertical()},u.prototype.nametagOnlyVisibleOnHover=function(){if(this.design.getSelectionManager().isPasteActive())return!1;var t=this.design.getNametagVisibility(),n=this.wire.getNet();return n&&!n.isGroundOrReferenceNet()&&(t==Project.NAMETAG_VISIBILITY.NONE||t==Project.NAMETAG_VISIBILITY.CHOSEN&&!n.hasUserSpecifiedName())},u.prototype.nametagOnMouseover=function(){this.nametagOnlyVisibleOnHover()?this.wire.buildNametag(!0,this,!0,!0):this.wire.buildNametag(!1,null,!1,!0)},u.prototype.nametagOnMouseout=function(){this.nametagOnlyVisibleOnHover()?this.wire.removeNametag(!0):this.wire.buildNametag()},u.prototype.connectEnd=function(n,t){var i,r;n instanceof Project.Pin?(i=n,this.connectEndToPin(i,t)):n instanceof u&&(r=n,this.connectEndToWireSegment(r,t))},u.prototype.connectEndToPin=function(t,i){var r,u,f;this.isBus()&&t.getVectorWidth()>0&&this.wire&&this.wire.getWidth()==-1&&this.wire.setBusIndices(t.getVectorIndices().clone());r=t.getConnection();u=this.getConnection(i);r&&u?u.merge(r):r?r.connectToWireSegment(this,i):u?u.connectToPin(t):(f=new n.Connection(this.design),f.connectToPin(t),f.connectToWireSegment(this,i));this.wire&&this.wire.getForcedName()&&this.updateGroundComponentToMatchTechnology();this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},u.prototype.connectEndToWireSegment=function(t,i){var u=this.getEndLocation(i),f=t.getEndLocation(1),e=t.getEndLocation(2),r;f.isAlmostEqual(u)?this.connectWireSegmentEnds(i,t,1):e.isAlmostEqual(u)?this.connectWireSegmentEnds(i,t,2):(r=this.getConnection(i),r||(r=new n.Connection(this.design),r.connectToWireSegment(this,i)),t.split(r));this.wire&&this.wire.getForcedName()&&this.updateGroundComponentToMatchTechnology();this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.toFront=function(){this.path.toFront();this.overlay.toFront();this.quickConnectsToFront()},u.prototype.bothEndsToFront=function(){for(var t,u,i,r,n=1;n<=2;++n)if(t=this.getConnection(n),t!=null)for(u=t.getNumConnectedWireSegments(),i=0;i<u;++i)r=t.getWireSegment(i),r!=this&&r.toFront()},u.prototype.addToDesign=function(){this.design.addWireSegment(this)},u.prototype.removeFromDesign=function(){this.design.removeWireSegment(this)},u.prototype.renameInDesign=function(n){this.design.renameWireSegment(this,n)},u.prototype.existsInDesign=function(){return this.design.wireSegmentExists(this)},u.prototype.updateGroundComponentToMatchTechnology=function(){var t,i,r,e,u,f,o,n;if(this.wire&&(t=[],this.wire.appendConnectedPins(t),t.length>0)){for(i=null,r=0,e=t;r<e.length;r++)if(n=e[r],!n.getComponent().isGroundOrReferenceComponent()){i=n;break}for(i||(i=t[0]),u=i.getTechnology(),f=0,o=t;f<o.length;f++)n=o[f],n.getComponent().isGroundOrReferenceComponent()&&n.getTechnology()!=u&&n.changeTechnology(u);this.wire.setTechnology(u)}},u.WIRE_INDICATOR_WIDTH=12,u.BUS_INDICATOR_WIDTH=16,u.WS_NAME_PREFIX="_ws_",u.BUS_NAME_PREFIX="_bs_",u.WIRE_TTIP_TEXT="Start new connection from this point",u.BUS_TTIP_TEXT="Start new bus connected to this point",u}();n.WireSegment=u;f=function(){function t(n,t){this.skipSelection=!1;this.design=n;this.wireSeg=t;this.wireDragSeg=null}return t.prototype.setSkipSelection=function(){this.skipSelection=!0},t.prototype.dragStart=function(){this.origSeg=this.wireSeg.getSegment().clone();WaveViewer.SVWEventHandler.setIsMoving(this.wireSeg);this.diffX=0;this.diffY=0;this.firstMovement=!0;this.design.getSelectionManager().isPasteActive()&&this.setSkipSelection();this.design.getSelectionManager().isPasteActive()||this.design.getUndoManager().startUndoableCommand(Project.ModifyWireCommand,this.design,this.wireSeg.getWire())},t.prototype.dragMove=function(t,i){if((t!=0||i!=0)&&typeof this.firstMovement!="undefined"){this.firstMovement&&(this.initDragWireSegment(),this.design.getWireBar().disable(),this.design.getSymbolBar().disable(),this.wireSeg.unhighlightNet(),this.wireSeg.hideQuickConnects(),this.firstMovement=!1);var o=this.design.getSurface().getScale(),r=t*o,u=i*o,f=r-this.diffX,e=u-this.diffY,s=this.design.getSelectionManager();s.getNumSelected()==1?this.wireSeg.getOrient()==n.ORIENTATION.VERTICAL?(e=0,u=0,setBodyCursor("w-resize")):(f=0,r=0,setBodyCursor("n-resize")):setBodyCursor("move");this.wireSeg.dragRelative(f,e);this.diffX=r;this.diffY=u;this.dragWireSegment(f,e)}},t.prototype.dragEnd=function(n){var e=this,t=0,i=0,u=this.wireSeg.getSegment(),r,f;(this.design.getWireBar().enable(),this.design.getSymbolBar().enable(),typeof this.firstMovement!="undefined")&&(r=u.point1.clone(),r.placeOnGrid(Project.Settings.SCH_GRID_SPACING),t=r.x-u.point1.x,i=r.y-u.point1.y,this.doubleClickDetector?(this.doubleClickDetector=!1,this.wireSeg.queryNetName(n.pageX+10,n.pageY+10)):this.doubleClickDetector=!0,window.setTimeout(function(){e.doubleClickDetector=!1},DOUBLE_CLICK_SPEED),t==0&&i==0?this.skipSelection||(n.shiftKey?this.design.selectObject(this.wireSeg.getWire(),n):this.design.selectObject(this.wireSeg,n)):(this.wireSeg.dragRelative(t,i),this.wireSeg.getSegment().round(),this.wireSeg.dragRelative(0,0),this.origSeg.isEqual(this.wireSeg.getSegment())||(this.doubleClickDetector=!1)),this.wireSeg.isSelected()&&this.wireSeg.showWireBar(n),this.firstMovement?this.design.getUndoManager().clearActiveCommand():(this.finalizeDragWireSegment(t,i),this.design.getConnMgr().finalize(),!this.design.getSelectionManager().isPasteActive()&&this.design.getUndoManager().getActiveCommand()&&this.design.getUndoManager().finishUndoableCommand(null)),f=this.wireSeg.existsInDesign(),f&&(this.wireSeg.isEventInside(n)?(this.wireSeg.showQuickConnects(),this.wireSeg.isSelected()&&this.wireSeg.showWireBar(n)):setBodyCursor("default")),WaveViewer.SVWEventHandler.setIsMoving(null),this.skipSelection=!1)},t.prototype.initDragWireSegment=function(){var t=this.design.getSelectionManager();t.getNumSelected()==1?this.wireDragSeg=new n.WireDragSegment(this.design,this.wireSeg):t.initDragSelectedSet(this.wireSeg)},t.prototype.dragWireSegment=function(n,t){var i=this.design.getSelectionManager();i.getNumSelected()==1?this.wireDragSeg&&this.wireDragSeg.drag():i.dragSelectedSet(this.wireSeg,n,t)},t.prototype.finalizeDragWireSegment=function(n,t){var i=this.design.getSelectionManager();i.getNumSelected()==1?this.wireDragSeg&&this.wireDragSeg.finalize(n,t):i.finalizeDragSelectedSet(this.wireSeg,n,t)},t}();i=function(){function t(t){this.busIndices=null;this.busType=n.BUSTYPE.WIRE;this.seg=t.getSegment().clone();this.technology=t.getTechnology();var i=t.getNet();this.netName=i?i.getName():null;t.getWire()&&(t.isBus()||t.isBit())&&(this.busIndices=t.getWire().getBusIndices().clone(),this.busType=t.isBus()?n.BUSTYPE.BUS:n.BUSTYPE.BIT)}return t}();n.WireSegmentCloneData=i;r=function(){function n(){}return n.prototype.compareTo=function(n,t,i){var r=t+PATH_SEPARATOR+this.uniqName;return Project.Utility.comparePrimitives(this.uniqName,n.uniqName,"uniqName",t,i)?Project.Utility.comparePrimitives(this.isBus,n.isBus,"isBus",r,i)?Project.Utility.comparePrimitives(this.x1,n.x1,"x1",r,i)?Project.Utility.comparePrimitives(this.y1,n.y1,"y1",r,i)?Project.Utility.comparePrimitives(this.x2,n.x2,"x2",r,i)?Project.Utility.comparePrimitives(this.y2,n.y2,"y2",r,i)?!0:!1:!1:!1:!1:!1:!1},n.prototype.dumpState=function(n,t){var i=JSON.stringify(this);return Project.Utility.dumpState("wireSegs",i,n,t)},n}();n.WireSegmentState=r}(BaseWire||(BaseWire={})),function(n){var e=function(){function i(r,u){var h,e,s,f,o,c;if(this.wireSegmentList=[],this.design=null,this.uniqName=null,this.hasForcedName=!1,this.busType=n.BUSTYPE.WIRE,this.busIndices=null,this.design=r,this.net=null,this.nametag=new t(this.design,this),u==null||u instanceof n.WireSegment||u instanceof i||u instanceof Project.Pin)this.uniqName=this.design.createUniqName(i.NAME_PREFIX),this.getForcedName()&&(this.hasForcedName=!0),u instanceof n.WireSegment?(h=u,this.addWireSegment(h)):u instanceof i?(e=u,(e.isBus()||e.isBit())&&(this.busIndices=e.getBusIndices().clone(),this.busType=e.getBusType())):u instanceof Project.Pin&&(s=u,s.isVector()&&(this.busType=n.BUSTYPE.BUS,this.busIndices=s.getVectorIndices().clone()));else{if(f=u,this.uniqName=f.uniqName,f.busType==n.BUSTYPE.BUS?this.setBusIndices(new n.BusIndices(f.busIdx1,f.busIdx2)):f.busType==n.BUSTYPE.BIT?this.setBitIndex(f.busIdx1):this.busType=n.BUSTYPE.WIRE,f.wireSegments)for(o=0;o<f.wireSegments.length;++o)c=new n.WireSegment(this.design,f.wireSegments[o]),this.addWireSegment(c);this.restoreNametag(f.nametag)}this.addToDesign()}return i.prototype.getBusType=function(){return this.busType},i.prototype.getBusIndices=function(){return this.busIndices},i.prototype.setBusIndices=function(t){this.busIndices=t;this.busType=n.BUSTYPE.BUS},i.prototype.setBitIndex=function(t){this.busType=n.BUSTYPE.BIT;t instanceof n.BusIndices?(this.busIndices=t,this.busIndices.setIdx2(null)):this.busIndices=new n.BusIndices(t,null)},i.prototype.getBitIndex=function(){return this.busIndices?this.busIndices.getIdx1():-1},i.prototype.isBus=function(){return this.busType==n.BUSTYPE.BUS},i.prototype.isBit=function(){return this.busType==n.BUSTYPE.BIT},i.prototype.clearBitIndex=function(){this.busType=n.BUSTYPE.WIRE;this.busIndices=null},i.prototype.getWidth=function(){return this.isBus()?this.busIndices.getWidth():this.isBit()?1:null},i.prototype.getIndicesString=function(){return this.isBit()?this.busIndices.getBitString():this.isBus()?this.busIndices.getBusString():""},i.prototype.hasForcedWidth=function(){var n,t,i;if(!this.isBus())return!1;for(n=[],this.appendConnectedPins(n),t=0;t<n.length;++t)if(i=n[t],i.getVectorWidth()>0)return!0;return!1},i.prototype.remove=function(){for(var n=0;n<this.wireSegmentList.length;n++)this.wireSegmentList[n].removeForWireDelete();this.wireSegmentList=[];this.net&&(this.net.removeWire(this),this.net.deselect(),this.net.unhighlight());this.removeNametag();this.removeFromDesign()},i.prototype.removeIfEmpty=function(){if(this.wireSegmentList.length==0){var n=this.net;this.remove();n&&n.removeIfEmpty()}},i.prototype.addWireSegment=function(n){this.wireSegmentList.push(n);n.associateWire(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.removeWireSegment=function(n,t){var i,r,u,f;t===void 0&&(t=!1);i=this.wireSegmentList.indexOf(n);i>=0&&this.wireSegmentList.splice(i,1);t||(r=this.nametag.getWireSegment(),r&&r.getUniqName()==n.getUniqName()&&(u=this.nametag.getBoundingRectCenter(),u&&(f=this.getClosestWireSegment(u),f?this.buildNametag(!1,f):this.removeNametag())));this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.getSegments=function(){return this.wireSegmentList},i.prototype.getNumSegments=function(){return this.wireSegmentList.length},i.prototype.highlight=function(n){if(n>0){if(this.isBit()&&this.getBitIndex()!=n)return;if(this.isBus()&&!this.getBusIndices().containsIndex(n))return}for(var t=0;t<this.wireSegmentList.length;t++)this.wireSegmentList[t].highlight()},i.prototype.crossHighlight=function(n){if(n>0){if(this.isBit()&&this.getBitIndex()!=n)return;if(this.isBus()&&!this.getBusIndices().containsIndex(n))return}for(var t=0;t<this.wireSegmentList.length;t++)this.wireSegmentList[t].crossHighlight()},i.prototype.unhighlight=function(){for(var n=0;n<this.wireSegmentList.length;n++)this.wireSegmentList[n].unhighlight()},i.prototype.select=function(n){for(var t=0;t<this.wireSegmentList.length;t++)this.wireSegmentList[t].select(n)},i.prototype.deselect=function(n){for(var t=0;t<this.wireSegmentList.length;t++)this.wireSegmentList[t].deselect(n)},i.prototype.isSelected=function(){for(var n=0;n<this.wireSegmentList.length;n++)if(!this.wireSegmentList[n].isSelected())return!1;return!0},i.prototype.merge=function(n){var t,r,i;if(n!=null&&this!=n){for(t=n.wireSegmentList.length-1;t>=0;--t)r=n.wireSegmentList[t],this.addWireSegment(r);n.removeAllWireSegments();this.isBus()&&this.getWidth()==-1&&n.isBus()&&this.setBusIndices(n.getBusIndices());i=n.getNet();n.getNet()!=null&&(i.removeWire(n),this.net.merge(i));n.removeFromDesign();this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)}},i.prototype.splitDisconnectedWires=function(){var t=this.getDisconnectedWireSegmentArrays(),i,u,e,f,n,r;if(t!=null&&(i=t.length,i!=0))if(this.hasForcedName)for(u=!1,n=0;n<i;++n)r=this.isWireSegArrayForced(t[n]),r==null?this.unsetForcedNet(t[n],i==1):(u&&this.setForcedNet(t[n],!1,r),u=!0);else for(e=0,f=null,this.getNet()&&this.getNet().hasUserSpecifiedName()&&(f=this.getNet().getNamePrefix()),n=0;n<i;++n)r=this.isWireSegArrayForced(t[n]),r==null?i>1&&this.splitWire(t[n],n,f,++e):this.setForcedNet(t[n],i==1,r)},i.prototype.getNet=function(){return this.net},i.prototype.associateNet=function(n){this.net=n;this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.getName=function(){if(this.net){var n=this.net.getNamePrefix(),t=this.getIndicesString();return n+t}return null},i.prototype.getNamePrefix=function(){return this.net?this.net.getNamePrefix():null},i.prototype.getUniqName=function(){return this.uniqName},i.prototype.getForcedName=function(){for(var i,t,n=0;n<this.wireSegmentList.length;n++)if(i=this.wireSegmentList[n],t=i.getForcedName(),t)return t;return null},i.prototype.setForcedNetName=function(n){this.hasForcedName=!0;n&&this.net&&this.net.setNamePrefix(n)},i.prototype.getClosestWireSegment=function(n){for(var t,i,f,r=null,u=0;u<this.wireSegmentList.length;u++){if(t=this.wireSegmentList[u],i=t.getDistanceFrom(n),i==0)return t;(!r||i<f)&&(f=i,r=t)}return r},i.prototype.segmentInWire=function(n){for(var t=0;t<this.wireSegmentList.length;++t)if(n.getUniqName()==this.wireSegmentList[t].getUniqName())return!0;return!1},i.prototype.getNametag=function(){return this.nametag},i.prototype.getNametagColor=function(n){return(n.indexOf("svw_wire")==0&&(n=n.substring(8).trim()),i.TechnologyColors[n])?i.TechnologyColors[n]:i.TechnologyColors.svw_wire_elec},i.prototype.initNametag=function(){this.net&&!this.net.isGroundOrReferenceNet()&&this.nametag.initWireSegment(this.wireSegmentList)},i.prototype.clearNametag=function(){this.nametag.clear()},i.prototype.restoreNametag=function(n){n&&n.wireSegUniqName&&this.nametag.restore(n);this.net&&this.net.buildNametags()},i.prototype.calcNametag=function(t,i,r){var f=new u,o=this.nametag.getBoundingRect(),e;if(!t&&o&&r==this.nametag.isVertical()){if(f.textAnchor="end",f.point=new n.Point(o.x2,(o.y1+o.y2)/2),e=this.nametag.getWireSegmentBoundingRect(),!e)return null;r?(f.point.x+=i.x1-e.x1,i.height==e.height&&(f.point.y+=i.y1-e.y1)):(f.point.y+=i.y1-e.y1,i.width==e.width&&(f.point.x+=i.x1-e.x1))}else r?(f.point=new n.Point(i.x1,(i.y1+i.y2)/2),f.textAnchor="end"):(f.point=new n.Point((i.x1+i.x2)/2,i.y1+15),f.textAnchor="center");return f},i.prototype.buildNametag=function(n,t,i,r){var c,e,o,u,s,f,h;if((n===void 0&&(n=!1),t===void 0&&(t=null),i===void 0&&(i=!1),r===void 0&&(r=!1),c=this,this.net&&!this.net.isGroundOrReferenceNet()&&surface.areNametagsReadable())&&this.nametag.getWireSegment()&&this.wireSegmentList&&this.wireSegmentList.length!=0){if(t)e=t.getBoundingRect(),o=t.isVertical();else{if(u=this.nametag.getWireSegment(),!this.segmentInWire(u)&&(this.clearNametag(),this.initNametag(),u=this.nametag.getWireSegment(),!u))return;e=u.getBoundingRect();o=u.isVertical()}(this.removeNametag(),e)&&(s=this.design.getNametagVisibility(),i||s!=Project.NAMETAG_VISIBILITY.NONE&&(s!=Project.NAMETAG_VISIBILITY.CHOSEN||this.net.hasUserSpecifiedName()))&&(f=this.calcNametag(t,e,o),f&&this.nametag.isPointValid(f.point)||(this.clearNametag(),this.initNametag(),f=this.calcNametag(t,e,o)),h=this.getNametagColor(this.wireSegmentList[0].getClass(!1)),this.nametag.draw(f.point,this.getName(),f.textAnchor,h,n,i,r),i||(t?this.setNametagSeg(t):this.nametag.updateWireSegment(),this.setNametagBoundingRect()))}},i.prototype.removeNametag=function(n){n===void 0&&(n=!1);this.nametag.remove(n)},i.prototype.getNametagBoundingRect=function(){return this.nametag.getBoundingRect()},i.prototype.setNametagBoundingRect=function(){this.nametag.setBoundingRect()},i.prototype.getNametagSeg=function(){return this.nametag.getWireSegment()},i.prototype.setNametagSeg=function(n){this.nametag.setWireSegment(n)},i.prototype.getWireSegment=function(n){for(var t=0;t<this.wireSegmentList.length;++t)if(n==this.wireSegmentList[t].getUniqName())return this.wireSegmentList[t];return null},i.prototype.getWaveboxes=function(n){for(var i,t=0;t<this.wireSegmentList.length;++t)i=this.wireSegmentList[t],i&&i.getWaveboxes(n)},i.prototype.getSaveData=function(){var t,u,n,i,f;if(this.wireSegmentList.length>0){for(t=-1,u=-1,this.isBus()?(t=this.getBusIndices().getIdx1(),u=this.getBusIndices().getIdx2()):this.isBit()&&(t=this.getBitIndex()),n=new r,n.uniqName=this.uniqName,n.busType=this.busType,n.busIdx1=t,n.busIdx2=u,n.nametag=this.nametag.getSaveData(),n.wireSegments=[],i=0;i<this.wireSegmentList.length;++i)f=this.wireSegmentList[i].getSaveData(),n.wireSegments.push(f);return n}return null},i.prototype.restore=function(t){var e,i,u,f,r,o;if(t&&t.uniqName==this.uniqName&&t.wireSegments){for(i=this.wireSegmentList.length-1;i>=0;--i)e=this.wireSegmentList[i].getUniqName(),Project.Utility.uniqNameInArray(e,t.wireSegments)||this.wireSegmentList[i].remove();for(i=0;i<t.wireSegments.length;++i){for(u=t.wireSegments[i],f=!1,r=0;r<this.wireSegmentList.length;++r)if(u.uniqName==this.wireSegmentList[r].getUniqName()){this.wireSegmentList[r].restore(u);f=!0;break}f||(this.existsInDesign()||this.addToDesign(),o=new n.WireSegment(this.design,u),this.addWireSegment(o))}this.restoreNametag(t.nametag)}},i.prototype.appendConnectedPins=function(n){for(var t=0;t<this.wireSegmentList.length;++t)this.wireSegmentList[t].appendConnectedPins(n)},i.prototype.getBoundingRect=function(){for(var i,n=null,t=0;t<this.wireSegmentList.length;t++)i=this.wireSegmentList[t].getBoundingRect(),n=Project.Utility.accumulateBoundingRect(n,i);return n},i.prototype.validateConnectionObjects=function(n){for(var l,e,u,f,o,s,h,r="",i=[],c=[],t=0;t<this.wireSegmentList.length;++t)for(l=this.wireSegmentList[t],e=1;e<=2;++e)u=l.getConnection(e),u&&jQuery.inArray(u,i)==-1&&(i.push(u),f=u.getLocation(),o=f.x+"_"+f.y,c.push(o));for(t=0;t<i.length;++t){s=i[t].validateLocation();s!=""&&(r+=s);var f=i[t].getLocation(),o=f.x+"_"+f.y,a=jQuery.inArray(o,c,t+1);a>=0&&(h=i[a],r+="\n",r+="Connection objects at the same location",i[t].dump(0,i[t].getUniqName()),h.dump(0,h.getUniqName()))}return n&&r&&Project.MessageManager.showErrorMessage(r),r},i.prototype.setTechnology=function(n){for(var t=0;t<this.wireSegmentList.length;t++)this.wireSegmentList[t].setTechnology(n)},i.prototype.getTechnology=function(){return this.wireSegmentList&&this.wireSegmentList.length>0?this.wireSegmentList[0].getTechnology():null},i.prototype.getAnyConnectedPin=function(){for(var t,n=0;n<this.wireSegmentList.length;n++)if(t=this.wireSegmentList[n].getAnyConnectedPin(),t)return t;return null},i.prototype.getNumConnectedPins=function(){for(var t=0,n=0;n<this.wireSegmentList.length;n++)t+=this.wireSegmentList[n].getNumConnectedPins();return t},i.prototype.dump=function(n,t){var r,i;for(Project.Utility.dumpHeading(n,t),r=0,this.wireSegmentList&&(r=this.wireSegmentList.length),Project.Utility.dump(n,'Wire with name "'+this.getName()+'" contains '+r+" wire segments"),i=0;i<r;i++)this.wireSegmentList[i].dump(n+1,"Wire Segment "+i)},i.prototype.getDisconnectedWireSegmentArrays=function(){var n,t,i,r,f,u;if(this.wireSegmentList.length==0)return null;for(n=[],t=0,n[t]=[],i=this.wireSegmentList[0],i.getConnectedWireSegments(n[t]),r=1;r<this.wireSegmentList.length;r++){for(f=!1,i=this.wireSegmentList[r],u=0;u<=t;++u)if(n[u].indexOf(i)>=0){f=!0;break}f||(++t,n[t]=[],i.getConnectedWireSegments(n[t]))}return n},i.prototype.unsetForcedNet=function(t,r){var f,u,e;r?(this.getNet().getNumWires()==1?(f=n.Net.generateUniqueName(this.design),this.getNet().setNamePrefix(f)):(this.getNet().removeWire(this),new n.Net(this.design,this)),this.hasForcedName=!1):(u=new i(this.design,this),e=new n.Net(this.design,u),this.removeWireSegmentArray(t),u.assignWireSegmentArray(t),u.initNametag(),u.buildNametag())},i.prototype.setForcedNet=function(n,t,r){if(t)this.getNet().getNumWires()==1?this.getNet().setNamePrefix(r):(this.getNet().removeWire(this),this.assignWireToForcedNet(this,r)),this.hasForcedName=!0;else{var u=new i(this.design,this);this.removeWireSegmentArray(n);u.assignWireSegmentArray(n);this.assignWireToForcedNet(u,r);u.hasForcedName=!0}},i.prototype.assignWireToForcedNet=function(t,i){var r=this.design.findNetByName(i);r?r.addWire(t):new n.Net(this.design,t,i)},i.prototype.splitWire=function(t,r,u,f){var e,o,s;r==0?e=this.getNet():(o=new i(this.design,this),this.removeWireSegmentArray(t),o.assignWireSegmentArray(t),e=new n.Net(this.design,o));u!=null&&(s=this.getSplitWireName(u,f),s!=null&&e.setNamePrefix(s));this.clearNametag();this.initNametag();this.buildNametag()},i.prototype.removeAllWireSegments=function(){this.wireSegmentList=[];this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.removeWireSegmentArray=function(n){for(var i,t=0;t<n.length;++t)i=n[t],this.removeWireSegment(i)},i.prototype.assignWireSegmentArray=function(n){for(var i,t=0;t<n.length;++t)i=n[t],this.addWireSegment(i)},i.prototype.isWireSegArrayForced=function(n){var t,r,i;if(n)for(t=0;t<n.length;++t)if(r=n[t],i=r.getForcedName(),i!=null)return i;return null},i.prototype.getSplitWireName=function(n,t){var i=n+"_"+t.toString();return this.design.findNetByName(i)!=null&&(i=null),i},i.prototype.addToDesign=function(){this.design.addWire(this)},i.prototype.removeFromDesign=function(){this.design.removeWire(this)},i.prototype.renameInDesign=function(n){this.design.renameWire(this,n)},i.prototype.existsInDesign=function(){return this.design.wireExists(this)},i.TechnologyColors={svw_wire_elec:"#3b4449",svw_wire_rv:"#ac640c",svw_wire_qty:"#228b22",svw_wire_dig_sig:"blue"},i.NAME_PREFIX="_w_",i}(),u,t,f,i,r;n.Wire=e;u=function(){function n(){}return n}();t=function(){function t(n,t){this.label=null;this.brect=null;this.wireSegment=null;this.wireSegmentBRect=null;this.vertical=null;this.design=n;this.wire=t;this.dragNametagHandler=new f(n,t)}return t.prototype.initWireSegment=function(n){var t,r,i,u,f,e;if(this.wireSegment==null){for(t=null,r=0,i=0;i<n.length;i++)(u=n[i].getBoundingRect(),u!=null)&&(f=u.width,e=u.height,(t==null||f>r||e>r)&&(t=n[i],r=Math.max(f,e)));t&&this.setWireSegment(t)}},t.prototype.getLabel=function(){return this.label},t.prototype.getBoundingRect=function(){return this.brect},t.prototype.getBoundingRectCenter=function(){return this.brect?new n.Point((this.brect.x2+this.brect.x1)/2,(this.brect.y2+this.brect.y1)/2):null},t.prototype.setBoundingRect=function(){this.brect=this.label?new Project.BoundingRect(this.label.getBBox()):null},t.prototype.isVertical=function(){return this.vertical},t.prototype.getSaveData=function(){return new i(this)},t.prototype.restore=function(n){this.setWireSegment(this.wire.getWireSegment(n.wireSegUniqName));this.brect=new Project.BoundingRect(n.x1,n.y1,n.x2,n.y2)},t.prototype.clear=function(){this.wireSegment=null;this.brect=null},t.prototype.getWireSegment=function(){return this.wireSegment},t.prototype.getWireSegmentBoundingRect=function(){return this.wireSegmentBRect},t.prototype.setWireSegment=function(n){this.wireSegment=n;this.updateWireSegment()},t.prototype.updateWireSegment=function(){this.wireSegment?(this.wireSegmentBRect=this.wireSegment.getBoundingRect(),this.vertical=this.wireSegment.isVertical()):(this.wireSegment=null,this.wireSegmentBRect=null,this.vertical=null)},t.prototype.isPointValid=function(n){return n&&!isNaN(n.x)&&!isNaN(n.y)&&n.x>0&&n.y>0},t.prototype.draw=function(n,t,i,r,u,f,e){var o=this;this.label=this.design.getPaper().text(n.x,n.y,t);this.label.attr({"text-anchor":i,fill:r,"font-size":12,opacity:0});e&&this.label.attr({"font-weight":"bold"});this.design.getSurface().isEditable()&&!f&&(this.label.attr("cursor","move"),this.dragNametagHandler.init(this.label));u?this.label.animate({opacity:1},300):this.label.attr("opacity",1);this.label.hover(function(){o.design.getSymbolBar().hide();o.design.getWireBar().hide()},function(){})},t.prototype.remove=function(n){var t=this;this.label&&(n?this.label.animate({opacity:0},300,null,function(){t.label.remove();t.label=null}):(this.label.remove(),this.label=null))},t}();n.WireNametag=t;f=function(){function t(n,t){this.doubleClickDetector=!1;this.design=n;this.wire=t}return t.prototype.init=function(n){var t=this;this.nametag=n;var i=function(n,i,r){return t.dragStart(n,i,r),{}},r=function(n,i,r,u,f){return t.dragMove(n,i,r,u,f),{}},u=function(n){return t.dragEnd(n),{}};this.nametag.drag(r,i,u)},t.prototype.dragStart=function(){(Messaging.Handler.sendSetFocusMessage(),WaveViewer.SVWEventHandler.setIsMoving(this.nametag),this.design.getSurface().isEditable())&&(this.design.getUndoManager().startUndoableCommand(Project.MoveWireNametagCommand,this.design,this.wire),this.diffX=0,this.diffY=0,this.nametagSeg=this.wire.getNametagSeg(),this.design.getSelectionManager().clearSelection())},t.prototype.dragMove=function(n,t){if((n!=0||t!=0)&&this.design.getSurface().isEditable()){this.diffX==0&&this.diffY==0&&this.wire.crossHighlight();var i=this.design.getSurface().getScale(),r=n*i,u=t*i,f=r-this.diffX,e=u-this.diffY;this.nametag.transform(Project.Utility.pointToTransform(f,e));this.diffX=r;this.diffY=u}},t.prototype.dragEnd=function(t){var u=this,i,r;(WaveViewer.SVWEventHandler.setIsMoving(null),this.design.getSurface().isEditable())&&(this.wire.unhighlight(),this.diffX==0&&this.diffY==0?(this.design.getUndoManager().clearActiveCommand(),this.doubleClickDetector?(this.doubleClickDetector=!1,r=this.design.getSurface().schToScreen(this.nametag.attr("x"),this.nametag.attr("y")),this.wire&&this.wire.getNet()&&(this.design.getWireBar().hide(),this.wire.getNet().queryNetName(t.pageX+10,t.pageY+10,this.nametagSeg))):this.doubleClickDetector=!0,window.setTimeout(function(){u.doubleClickDetector=!1},DOUBLE_CLICK_SPEED)):(this.wire.setNametagBoundingRect(),i=this.wire.getNametagBoundingRect(),r=new n.Point((i.x2+i.x1)/2,(i.y2+i.y1)/2),r.round(),this.wire.setNametagSeg(this.wire.getClosestWireSegment(r)),this.wire.buildNametag(),this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS),this.design.getUndoManager().finishUndoableCommand(this.wire.getNametag())))},t}();i=function(){function n(n){var i,t;this.wireSegUniqName=null;this.x1=null;this.y1=null;this.x2=null;this.y2=null;i=n.getWireSegment();i&&(this.wireSegUniqName=i.getUniqName());t=n.getBoundingRect();t&&(this.x1=t.x1,this.y1=t.y1,this.x2=t.x2,this.y2=t.y2)}return n}();n.WireNametagState=i;r=function(){function n(){this.netName=null}return n.prototype.compareTo=function(n,t,i,r){var u=t+PATH_SEPARATOR+this.uniqName;return Project.Utility.comparePrimitives(this.uniqName,n.uniqName,"uniqName",t,i)?Project.Utility.comparePrimitives(this.netName,n.netName,"netName",u,i)?Project.Utility.comparePrimitives(this.busType,n.busType,"busType",u,i)?Project.Utility.comparePrimitives(this.busIdx1,n.busIdx1,"busIdx1",u,i)?Project.Utility.comparePrimitives(this.busIdx2,n.busIdx2,"busIdx2",u,i)?Project.Utility.compareArrays(this.wireSegments,n.wireSegments,"uniqName",u+"/wireSegments",i,r)?!0:!1:!1:!1:!1:!1:!1},n.prototype.dumpState=function(n,t){var i=JSON.stringify(this);return Project.Utility.dumpState("wires",i,n,t)},n}();n.WireState=r}(BaseWire||(BaseWire={})),function(n){var i=function(){function i(t,r,u){var s,e,f,h,o,c;if(this.wireList=[],this.name=null,this.design=null,this.typeBus=!1,this.design=t,r instanceof n.Wire)s=r,e=u,this.typeBus=s.isBus(),this.name=e&&e!=""?e:i.generateUniqueName(this.design,this.isBus()),this.addWire(s);else if(f=r,h=typeof u=="boolean"?u:!0,this.name=f.name,this.typeBus=f.isBus==!0,h&&f.wires)for(o=0;o<f.wires.length;++o)c=new n.Wire(this.design,f.wires[o]),this.addWire(c);this.initNametags();this.buildNametags();this.addToDesign()}return i.generateUniqueName=function(n,t){return t?n.createUniqName(i.BUS_NAME_PREFIX):n.createUniqName(i.NET_NAME_PREFIX)},i.prototype.isBus=function(){return this.typeBus},i.prototype.hasBits=function(){for(var n=0;n<this.wireList.length;n++)if(this.wireList[n].isBit())return!0;return!1},i.prototype.getBusCount=function(){for(var t=0,n=0;n<this.wireList.length;n++)this.wireList[n].isBus()&&++t;return t},i.prototype.getBitCount=function(){for(var t=0,n=0;n<this.wireList.length;n++)this.wireList[n].isBit()&&++t;return t},i.prototype.isGroundOrReferenceNet=function(){return this.getName()===this.getForcedName()},i.prototype.remove=function(){for(var n=0;n<this.wireList.length;n++)this.wireList[n].remove();this.wireList=[];this.removeFromDesign()},i.prototype.removeIfEmpty=function(){this.wireList.length==0&&this.remove()},i.prototype.containsWire=function(n){return!n||!this.wireList?!1:this.wireList.indexOf(n)!=-1},i.prototype.addWire=function(n){n&&(this.wireList.push(n),n.associateNet(this));this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.queryNetName=function(n,t,i){var e=this,r=i.getWire();if(r){if(r.getForcedName()=="0"){this.design.getInputField().hideQueryField(!0);return}var o=function(r){e.setNameWithPrompt(r,n,t,i)},u=r.getName(),f=null;this.isBus()&&(f=u.lastIndexOf("["));this.design.getInputField().queryObjName(u,o,n,t,f)}},i.prototype.removeWire=function(n){n.removeNametag();var t=this.wireList.indexOf(n);t>=0&&this.wireList.splice(t,1);this.wireList.length==0&&this.removeFromDesign()},i.prototype.getNumWires=function(){return this.wireList.length},i.prototype.getWires=function(){return this.wireList},i.prototype.highlight=function(n,t){var u=null,r,i;for(this.isGroundOrReferenceNet()&&t&&(u=t.getTechnology()),r=0;r<this.wireList.length;r++)if(i=this.wireList[r],t&&i!=t){if(u!=null&&i.getTechnology()!=u)continue;i.crossHighlight(n)}else i.highlight(n)},i.prototype.crossHighlight=function(n){for(var t=0;t<this.wireList.length;t++)this.wireList[t].crossHighlight(n)},i.prototype.unhighlight=function(){for(var n=0;n<this.wireList.length;n++)this.wireList[n].unhighlight()},i.prototype.select=function(n){for(var t=0;t<this.wireList.length;t++)this.wireList[t].select(n)},i.prototype.deselect=function(n){for(var t=0;t<this.wireList.length;t++)this.wireList[t].deselect(n)},i.prototype.merge=function(n){var t,i;if(n!=null&&this!=n){for(t=n.wireList.length-1;t>=0;--t)i=n.wireList[t],this.addWire(i),n.removeWire(i);this.buildNametags();n.removeFromDesign()}},i.prototype.getName=function(){return this.wireList.length>0&&(this.isBus()||this.hasBits())?this.wireList[0].getName():this.name},i.prototype.getNamePrefix=function(){return this.name},i.prototype.setNamePrefix=function(n){var t,i;this.name!=n&&(t=this.design.findNetByName(n),t?(i=t,i.merge(this)):this.renamePrefix(n))},i.prototype.hasUserSpecifiedName=function(){var r=this.getNamePrefix(),n,t;return n=this.isBus()?i.BUS_NAME_PREFIX:i.NET_NAME_PREFIX,t=new RegExp("^"+n+"[0-9]+$"),r.match(t)==null?!0:!1},i.prototype.getForcedName=function(){for(var i,t,n=0;n<this.wireList.length;n++)if(i=this.wireList[n],t=i.getForcedName(),t)return t;return null},i.prototype.initNametags=function(){for(var n=0;n<this.wireList.length;n++)this.wireList[n].initNametag()},i.prototype.clearNametags=function(){for(var n=0;n<this.wireList.length;n++)this.wireList[n].clearNametag()},i.prototype.buildNametags=function(n){var i,t;if(n===void 0&&(n=!1),i=this.design.getNametagVisibility(),this.isGroundOrReferenceNet()||i==Project.NAMETAG_VISIBILITY.NONE||i==Project.NAMETAG_VISIBILITY.CHOSEN&&!this.hasUserSpecifiedName()){this.removeNametags(!1);return}for(t=0;t<this.wireList.length;t++)this.wireList[t].buildNametag(n)},i.prototype.removeNametags=function(n){n===void 0&&(n=!1);for(var t=0;t<this.wireList.length;t++)this.wireList[t].removeNametag(n)},i.prototype.getSaveData=function(){var n,i,r;if(this.hasAtLeastOneWireSegment()){for(n=new t,n.name=this.name,n.isBus=this.typeBus,n.wires=[],i=0;i<this.wireList.length;++i)r=this.wireList[i].getSaveData(),r&&n.wires.push(r);return n}return null},i.prototype.getConnectedPins=function(){for(var t=[],n=0;n<this.wireList.length;++n)this.wireList[n].appendConnectedPins(t);return t},i.prototype.getBoundingRect=function(){for(var i,n=null,t=0;t<this.wireList.length;t++)i=this.wireList[t].getBoundingRect(),n=Project.Utility.accumulateBoundingRect(n,i);return n},i.prototype.findWireSegmentUnderPoint=function(n,t){var u,i,r;if(this.wireList)for(u=0;u<this.wireList.length;++u)if(i=this.wireList[u].getSegments(),i)for(r=0;r<i.length;++r)if(i[r]!=t&&i[r].isPointInside(n))return i[r];return null},i.prototype.findWireSegmentsInsideBox=function(n,t,i,r){var o=[],e,u,f;if(this.wireList)for(e=0;e<this.wireList.length;++e)if(u=this.wireList[e].getSegments(),u)for(f=0;f<u.length;++f)u[f].isInsideBox(n,t,i,r)&&o.push(u[f]);return o},i.prototype.setTechnology=function(){var t=this.getAnyConnectedPin(),i,n;if(t)if(this.getNamePrefix()=="0")for(n=0;n<this.wireList.length;n++)i=this.wireList[n],t=i.getAnyConnectedPin(),t&&i.setTechnology(t.getTechnology());else for(n=0;n<this.wireList.length;n++)this.wireList[n].setTechnology(t.getTechnology())},i.prototype.getAnyConnectedPin=function(){for(var t,n=0;n<this.wireList.length;n++)if(t=this.wireList[n].getAnyConnectedPin(),t)return t;return null},i.prototype.dump=function(n,t){var r,i;for(Project.Utility.dumpHeading(n,t),r=0,this.wireList&&(r=this.wireList.length),Project.Utility.dump(n,'Net with name "'+this.name+'" contains '+r+" wire(s)"),i=0;i<r;i++)this.wireList[i].dump(n+1,"Wire "+i)},i.prototype.hasAtLeastOneWireSegment=function(){for(var t,n=0;n<this.wireList.length;++n)if(t=this.wireList[n].getSegments(),t&&t.length>0)return!0;return!1},i.prototype.renamePrefix=function(n){var t=this.name;this.name=n;this.renameInDesign(t);t==Project.Pin.FORCED_NET_NAME&&(this.clearNametags(),this.initNametags());this.buildNametags()},i.prototype.renamePrefixWithUndo=function(n,t){this.design.getUndoManager().startUndoableCommand(Project.RenameNetCommand,this.design,t);this.renamePrefix(n);this.design.getUndoManager().finishUndoableCommand(n)},i.prototype.setNameWithPrompt=function(t,i,r,u){var e=u.getWire(),f;t!=e.getName()&&(f=n.BusName.parse(t),this.isBus()||this.hasBits()||f.isBus()||f.isBit()?this.setBusBitNameWithPrompt(f,i,r,u):this.setSimpleNameWithPrompt(t,i,r,u))},i.prototype.setSimpleNameWithPrompt=function(n,t,i,r){var o=this,u=Project.Utility.convertToLegalVHDLName(n,"wire_"),s,e,f,h;if(n==""){f="Must specify a net name";Project.MessageManager.showErrorMessage(f);return}if(u==""){f='Specified net name "'+n+'" cannot be converted to a legal name';Project.MessageManager.showErrorMessage(f);return}if(n!=u&&(u=this.getUniqueNetName(u),f="Specified net name was changed to be compatible with VHDL-AMS",Project.MessageManager.showInfoMessage(f)),this.name.toLowerCase()==u.toLowerCase()){this.renamePrefixWithUndo(u,r.getWire());return}s=this.design.findNetByName(u);s?(e=s,e.isBus()||e.hasBits()?(f=this.getErrStringBadBit(e.getName(),u),Project.MessageManager.showErrorMessage(f)):this.renameInUse(e,r.getWire(),u)):this.getNumWires()==1?this.renamePrefixWithUndo(u,r.getWire()):this.getForcedName()!=null?(this.splitWithUndo(r.getWire(),u),this.unhighlight()):(f="<p>This design has multiple wires on net <b>"+this.name+"<\/b>. Do you want to:<\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Rename net <b>"+this.getName()+"<\/b> to net <b>"+u+"<\/b><\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Split off the selected wire to create net <b>"+u+"<\/b><\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Cancel<\/p>",h=new Project.MultiBtnModalDialog("Multiple Wires on Net",f,["Rename Net","Split Off Wire","Cancel"]),jQuery.when(h.queryUser()).done(function(n){switch(parseInt(n)){case Project.BUTTON.BTN1:o.renamePrefixWithUndo(u,r.getWire());break;case Project.BUTTON.BTN2:o.splitWithUndo(r.getWire(),u);o.unhighlight()}}))},i.prototype.setBusBitNameWithPrompt=function(n,t,i,r){var u=r.getWire(),e,f,o;if(this.validateBusBitName(n,u)){if(e=n.getPrefix(),this.name.toLowerCase()==e.toLowerCase()){f=null;u.isBus()||(this.isBus()?n.isBit()||(f=this.getErrStringBadBit(this.getName(),n.getPrefix())):this.hasBits()&&this.getNumWires()>1&&!n.isBit()&&(f=this.getErrStringBadBit(this.getName(),n.getPrefix())));f?Project.MessageManager.showErrorMessage(f):this.renameBusBitWithUndo(n,u);return}o=this.design.findNetByName(e);o?this.renameBusBitInUse(n,o,u):this.getNumWires()==1?this.renameBusBitWithUndo(n,u):this.getForcedName()!=null?this.splitBusBitWithUndo(u,n):this.renameSplitBusBits(e,n,u)}},i.prototype.renameInUse=function(n,t,i){var r=this,o,u,f,e;if(!Project.Utility.areMatchingTechnologies(n,t)){o="This net cannot be renamed to <b>"+i+"<\/b> since that name is already in use for a different technology";Project.MessageManager.showErrorMessage(o);return}u=n.getName();f="";f+=u!=i?"<p>Net names are case insensitive and this design already has a net with the name <b>"+u+"<\/b>. ":"<p>This design already has a net with the name <b>"+i+"<\/b>. ";this.getNumWires()==1?(f+="If you rename this net to <b>"+u+"<\/b>, they will both be treated as the same net when you simulate. Do you want to continue with this renaming?<\/p>",e=new Project.MultiBtnModalDialog("Net Name Exists",f,["Yes","No"],null,null,0)):(f+="You can choose to:<\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Rename net <b>"+this.getName()+"<\/b> to net <b>"+u+"<\/b><\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Move the selected wire to net <b>"+u+"<\/b><\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Cancel<\/p>",e=new Project.MultiBtnModalDialog("Net Name Exists",f,["Rename Net","Move Wire","Cancel"]));jQuery.when(e.queryUser()).done(function(u){switch(parseInt(u)){case Project.BUTTON.BTN1:r.design.getUndoManager().startUndoableCommand(Project.MergeNetsCommand,r.design,t);t.clearBitIndex();n.merge(r);r.design.getUndoManager().finishUndoableCommand(i);n.crossHighlight();break;case Project.BUTTON.BTN2:r.getNumWires()>1&&(r.removeWire(t),n.addWire(t),n.buildNametags())}})},i.prototype.validateBusBitName=function(n,t){var i=null,f=n.getPrefix(),r=this.isBus()?"bus":"bit",e=Project.Utility.convertToLegalVHDLName(f,r),u;return n.setPrefix(e),(f="")?i="Must specify a "+r+" name":e==""?(i="Specified "+r+' name "',i+=n.getBaseName(),i+='" cannot be converted to a legal name'):r=="bus"?t.isBus()&&(n.isBus()?t.hasForcedWidth()&&(u=n.getIndices(),u.isCompatible(t.getBusIndices())||(i=this.getErrStringBadWidth(n.getPrefix(),u.getWidth(),t.getBusIndices().getWidth()))):i=this.getErrStringBadBus()):n.isBus()&&(i="Cannot specify a bus name for a net that is not a bus"),i?(Project.MessageManager.showErrorMessage(i),!1):!0},i.prototype.renameBusBitInUse=function(n,t,i){var u,f,r,e;if(this.validateBusBitInUse(n,t)){if(!n.isBit()&&this.hasBits()){this.renameInUse(t,i,n.getPrefix());return}if(u=this.design.getUndoManager(),u.startUndoableCommand(Project.MergeNetsCommand,this.design,i),n.isBit()){for(this.setBusBitIndices(i,n),f=0;f<this.wireList.length;f++)r=this.wireList[f],r==i||r.isBit()||r.isBus()||(u.addToStartState(r),this.setBusBitIndices(r,n));t.merge(this);e=n.getIndices().getIdx1();t.highlight(e)}else n.isBus()&&t.hasBits()?(this.setBusBitIndices(i,n),t.merge(this),t.highlight()):(this.setBusBitIndices(i,n),t.merge(this),t.highlight());u.finishUndoableCommand(n)}},i.prototype.validateBusBitInUse=function(n,t){var i=null;return this.isBus()?t.isBus()||t.hasBits()||(i=this.getErrStringBadNet(t.getName())):t.isBus()||t.hasBits()?n.isBit()||(i=this.getErrStringBadBit(t.getName(),n.getPrefix())):n.isBit()&&(i="Cannot specify a bus name for a net that is not a bus"),i?(Project.MessageManager.showErrorMessage(i),!1):!0},i.prototype.renameSplitBusBits=function(n,t,i){var h=this,e,o,r,u,f,s,c;i.isBit()&&!t.isBit()?this.splitBusBitWithUndo(i,t):(e=this.getBusCount(),o=this.getBitCount(),i.isBus()?(o>0&&e>1?(r="Multiple Buses and Bits With the Same Name",u="This design has several buses and bits named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename all of them to <b>"+n+"<\/b> <br>or just this bus?",f="Rename All Buses and Bits"):e>1?(r="Multiple Buses With the Same Name",u="This design has several buses named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename all of them to <b>"+n+"<\/b> <br>or just this bus?",f="Rename All Buses"):o>1?(r="Bus and Bits With the Same Name",u="This design has this bus and other bits named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename all of them to <b>"+n+"<\/b> <br>or just this bus?",f="Rename This Bus and All Bits"):(r="Bus and Bit With the Same Name",u="This design has this bus and one bit named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename both of them to <b>"+n+"<\/b> <br>or just this bus?",f="Rename This Bus and Bit"),s="Rename This Bus"):(e>0&&o>1?(r="Multiple Buses and Bits With the Same Name",u="This design has several buses and bits named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename all of them to <b>"+n+"<\/b> <br>or just this bit?",f="Rename All Buses and Bits"):o>1?(r="Multiple Bits With the Same Name",u="This design has several bits named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename all of them to <b>"+n+"<\/b> <br>or just this bit?",f="Rename All Bits"):e>1?(r="Buses and Bit With the Same Name",u="This design has this bit and other buses named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename all of them to <b>"+n+"<\/b> <br>or just this bit?",f="Rename This Bit and All Buses"):(r="Buses and Bit With the Same Name",u="This design has this bit and one bus named <b>"+t.getPrefix()+"<\/b>.<br>Do you want to rename both of them to <b>"+n+"<\/b> <br>or just this bit?",f="Rename This Bit and Bus"),s="Rename This Bit"),c=new Project.MultiBtnModalDialog(r,u,[f,s]),jQuery.when(c.queryUser()).done(function(n){n==Project.BUTTON.BTN1?h.renameBusBitWithUndo(t,i):h.splitBusBitWithUndo(i,t)}))},i.prototype.renameBusBit=function(n,t){var i=n.getPrefix();this.setBusBitIndices(t,n);this.renamePrefix(i)},i.prototype.renameBusBitWithUndo=function(n,t){this.design.getUndoManager().startUndoableCommand(Project.RenameNetCommand,this.design,t);this.renameBusBit(n,t);this.design.getUndoManager().finishUndoableCommand(n)},i.prototype.setBusBitIndices=function(n,t){n.isBus()?n.setBusIndices(t.getIndices().clone()):t.isBit()?n.setBitIndex(t.getIndices().clone()):n.clearBitIndex()},i.prototype.split=function(n,t){if(!n||this.getNumWires()<2||n.getNet()!=this)return null;this.removeWire(n);var r=this.design.findNetByName(t);return r||(r=new i(this.design,n,t)),r},i.prototype.splitWithUndo=function(n,t){this.design.getUndoManager().startUndoableCommand(Project.SplitNetCommand,this.design,n);var i=this.split(n,t);return this.design.getUndoManager().finishUndoableCommand(t),i},i.prototype.splitBusBit=function(n,t){var r=t.getPrefix(),i=this.split(n,r);return i?(i.setBusBitIndices(n,t),i.buildNametags(),this.unhighlight(),i):i},i.prototype.splitBusBitWithUndo=function(n,t){this.design.getUndoManager().startUndoableCommand(Project.SplitNetCommand,this.design,n);var i=this.splitBusBit(n,t);return this.design.getUndoManager().finishUndoableCommand(t),i},i.prototype.getErrStringBadBit=function(n,t){var i="This design has a bus named "+n+". ";return i+="Cannot rename a net to "+t+" without ",i+("specifying a bit index such as "+t+"[3]")},i.prototype.getErrStringBadBus=function(){return"Illegal bus name specified.  The bus name must include the bus indices. \nFor example, output[4:1]"},i.prototype.getErrStringBadWidth=function(n,t,i){var r="Incorrect bus width specified ("+t+"). ";return r+="The bus must have a width of "+i+" bits.",r+("\n(For example, "+n+"["+i+":1]).")},i.prototype.getErrStringBadNet=function(n){var t="This design has a net named "+n+"";return t+" that is not a bus.\nCannot rename a bus to the same name."},i.prototype.getUniqueNetName=function(n){for(var i=n,t=1;this.design.findNetByName(n);)n=i+"_"+t,++t;return n},i.prototype.addToDesign=function(){this.design.addNet(this)},i.prototype.removeFromDesign=function(){this.design.removeNet(this)},i.prototype.renameInDesign=function(n){this.design.renameNet(this,n)},i.prototype.existsInDesign=function(){return this.design.netExists(this)},i.NET_NAME_PREFIX="net",i.BUS_NAME_PREFIX="bus",i}(),t;n.Net=i;t=function(){function n(){}return n.prototype.compareTo=function(n,t,i,r){var u=t+PATH_SEPARATOR+this.name;return Project.Utility.comparePrimitives(this.name,n.name,"name",t,i)?Project.Utility.comparePrimitives(this.isBus,n.isBus,"isBus",u,i)?Project.Utility.compareArrays(this.wires,n.wires,"uniqName",u+"/wires",i,r)?!0:!1:!1:!1},n.prototype.dumpState=function(n,t){var i=JSON.stringify(this);return Project.Utility.dumpState("nets",i,n,t)},n}();n.NetState=t}(BaseWire||(BaseWire={})),function(n){var i=function(){function i(t,r){var s,e,h,u,c,o,l,f;if(this.uniqName=null,this.location=null,this.dot=null,this.design=t,this.connectedWireSegments=[],this.connectedPins=[],this.wireSegmentEnds=[],r){if(this.uniqName=r.uniqName,this.location=new n.Point(r.x,r.y),r.wireSegNames)for(u=0;u<r.wireSegNames.length;++u)s=r.wireSegNames[u],e=this.design.findObjectByUniqName(s),e&&(h=r.wireSegEnds[u],this.connectToWireSegment(e,h));if(r.compInstNames)for(u=0;u<r.compInstNames.length;++u)c=r.compInstNames[u],o=this.design.findCompByInstName(c),o&&(l=r.pinNames[u],f=o.getPinByName(l),f&&(this.connectToPin(f),f.getForcedNetName()&&this.getWire()&&this.getWire().setForcedNetName()))}else this.uniqName=this.design.createUniqName(i.NAME_PREFIX);this.addToDesign()}return i.prototype.highlight=function(){},i.prototype.unhighlight=function(){},i.prototype.connectToPin=function(n){this.connectedPins.push(n);n.attachConnection(this);this.location==null&&(this.location=n.getLocation().clone());this.updateConnectionDot();this.design.getConnMgr().manage(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},i.prototype.disconnectPin=function(n){this.removePin(n)&&(n.removeConnection(),this.updateConnectionDot());this.design.getConnMgr().manage(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},i.prototype.removePin=function(n){if(n!=null){var t=this.connectedPins.indexOf(n);if(t>=0)return this.connectedPins.splice(t,1),!0}return!1},i.prototype.connectToWireSegment=function(n,t){this.connectedWireSegments.push(n);this.wireSegmentEnds.push(t);n.attachConnection(this,t);this.location==null&&(this.location=n.getEndLocation(t));this.updateConnectionDot();this.design.getConnMgr().manage(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.disconnectWireSegment=function(n,t){this.removeWireSeg(n,t)&&(n.removeConnection(t),this.updateConnectionDot());this.design.getConnMgr().manage(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.replaceWireSegment=function(n,t,i,r){this.removeWireSeg(i,r);i.removeConnection(r);this.connectedWireSegments.push(n);this.wireSegmentEnds.push(t);n.attachConnection(this,t);this.design.getConnMgr().manage(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.remove=function(){for(var t,i,r,n=this.connectedWireSegments.length-1;n>=0;--n)t=this.connectedWireSegments[n],i=this.wireSegmentEnds[n],this.disconnectWireSegment(t,i);for(this.connectedWireSegments=[],this.wireSegmentEnds=[],n=this.connectedPins.length-1;n>=0;--n)r=this.connectedPins[n],this.disconnectPin(r);this.connectedPins=[];this.design.getConnMgr().manage(this)},i.prototype.merge=function(n){for(var i,r,u,t=0;t<n.connectedWireSegments.length;++t)i=n.connectedWireSegments[t],r=n.wireSegmentEnds[t],this.connectToWireSegment(i,r);for(t=0;t<n.connectedPins.length;++t)u=n.connectedPins[t],this.connectToPin(u);n.removeConnectionDot();n.connectedWireSegments=[];n.wireSegmentEnds=[];n.connectedPins=[];n.removeFromDesign();this.design.getConnMgr().manage(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},i.prototype.mergeInlineWireSegments=function(n){var o=null,s,f,h,e;if(this.areTwoWireSegmentsInline()){var i=this.getWireSegment(0),t=this.getWireSegment(1),r=this.getWireSegmentEnd(0),u=this.getWireSegmentEnd(1);n&&n==t&&(t=i,i=n,s=u,u=r,r=s);i.removeConnection(r);t.removeConnection(u);this.connectedPins=[];this.connectedWireSegments=[];this.wireSegmentEnds=[];this.removeIfNotNeeded();f=u==1?2:1;h=t.getEndLocation(f);i.moveEndTo(h,r);e=t.getConnection(f);e&&e.replaceWireSegment(i,r,t,f);o=i;t.remove()}return o},i.prototype.removeOverlappingWireSegments=function(){for(var s=this.getTwoOverlappingWireSegmentsIdx(),t,l,u;s.length==2;){var n=null,r=null,f=null,h=null,i=null,c=null,e=s[0],o=s[1],a=this.getWireSegment(e).getSegment().length(),v=this.getWireSegment(o).getSegment().length();a>v?(n=this.getWireSegment(e),f=this.getWireSegmentEnd(e),r=this.getWireSegment(o),h=this.getWireSegmentEnd(o)):(n=this.getWireSegment(o),f=this.getWireSegmentEnd(o),r=this.getWireSegment(e),h=this.getWireSegmentEnd(e));t=h==1?2:1;i=r.getConnection(t);c=r.getEndLocation(t);this.getNumConnectedWireSegments()==2&&this.getNumConnectedPins()==0?(n.moveEndTo(c,f),r.remove(),i&&this.merge(i),n.isZeroLength()&&(t=f==1?2:1,u=n.getConnection(t),n.remove(),u&&this.merge(u))):(r.remove(),i&&(t=f==1?2:1,l=n.getEndLocation(t),l.isEqual(i.getLocation())?(u=n.getConnection(t),u?i.merge(u):i.connectToWireSegment(n,t)):n.split(i)));s=this.getTwoOverlappingWireSegmentsIdx()}},i.prototype.manageZeroLengthWires=function(){for(var i,t=[],n=0;n<this.connectedWireSegments.length;++n)if(i=this.connectedWireSegments[n],i.isZeroLength()){t.indexOf(i)<0&&t.push(i);var u=this.wireSegmentEnds[n],f=u==1?2:1,r=i.getConnection(f);r&&r!=this&&this.merge(r)}if(t.length>1)for(n=1;n<t.length;++n)i=t[n],this.deleteZeroLengthWire(i);t.length==0?this.getNumConnectedWireSegments()==0&&this.getNumConnectedPins()>1&&this.createZeroLengthWire():(this.getNumConnectedWireSegments()>2||this.getNumConnectedPins()<2)&&(this.deleteZeroLengthWire(t[0]),this.getNumConnectedPins()<2&&this.removeIfNotNeeded());this.updateConnectionDot()},i.prototype.finalize=function(){this.removeIfNotNeeded()&&(this.updateConnectionDot(),this.adjustLocation())},i.prototype.getUniqName=function(){return this.uniqName},i.prototype.getNumConnections=function(){return this.connectedWireSegments.length+this.connectedPins.length},i.prototype.getNumConnectedPins=function(){return this.connectedPins.length},i.prototype.getNumConnectedWireSegments=function(){return this.connectedWireSegments.length},i.prototype.getWire=function(){return this.connectedWireSegments.length>0?this.connectedWireSegments[0].getWire():null},i.prototype.getWireSegment=function(n){return n>=0&&n<this.connectedWireSegments.length?this.connectedWireSegments[n]:null},i.prototype.getWireSegmentEnd=function(n){return n>=0&&n<this.connectedWireSegments.length?this.wireSegmentEnds[n]:-1},i.prototype.getPin=function(n){return n>=0&&n<this.connectedPins.length?this.connectedPins[n]:null},i.prototype.getZeroLengthWire=function(){return this.getNumConnectedWireSegments()==2&&this.getWireSegment(0)==this.getWireSegment(1)?this.getWireSegment(0):null},i.prototype.getOtherWireSegment=function(n){for(var t=0;t<this.connectedWireSegments.length;++t)if(this.connectedWireSegments[t]!=n)return this.connectedWireSegments[t];return null},i.prototype.getConnectedWireSegment=function(n){for(var i,t=0;t<this.connectedWireSegments.length;++t)if(i=this.connectedWireSegments[t],n.containsWireSegment(i))return i;return null},i.prototype.containsWireSegment=function(n){for(var t=0;t<this.connectedWireSegments.length;++t)if(n==this.connectedWireSegments[t])return!0;return!1},i.prototype.getNetNamePrefix=function(){var t=null,n;return this.connectedWireSegments.length>0&&(n=this.connectedWireSegments[0].getWire(),n&&(t=n.getNamePrefix())),t},i.prototype.appendConnectedPins=function(n){for(var t=0;t<this.connectedPins.length;++t)n.indexOf(this.connectedPins[t])==-1&&n.push(this.connectedPins[t])},i.prototype.getForcedNetName=function(){for(var i,t,n=0;n<this.connectedPins.length;++n)if(i=this.connectedPins[n],t=i.getForcedNetName(),t)return t;return null},i.prototype.getLocation=function(){return this.location.clone()},i.prototype.hideConnectionDot=function(){this.dot&&this.dot.hide()},i.prototype.showConnectionDot=function(){this.dot&&this.dot.show()},i.prototype.isBusConnection=function(){var n=this.getWire();return n?n.isBus():!1},i.prototype.moveTo=function(n){this.location=n.clone();this.location.round();this.dot&&this.dot.moveTo(n)},i.prototype.select=function(n){this.dot&&this.dot.select(n)},i.prototype.deselect=function(n){this.dot&&this.dot.deselect(n)},i.prototype.finishAnimation=function(){this.dot&&this.dot.finishAnimation()},i.prototype.setTechnology=function(){this.dot&&this.dot.setTechnology(this.getTechnology())},i.prototype.validateLocation=function(n){var t="",f=!0,i=this.location,r,e,u;for(i.isAlmostInteger()||(t="<br>Error with connection object '"+this.getUniqName()+"'"+("Connection is at   "+i.x+","+i.y+" which is not an integer location")),this.getNumConnections()==0&&(t="<br>Error with connection object '"+this.getUniqName()+"'"+("Connection is at   "+i.x+","+i.y+" but has no connections")),r=0;r<this.connectedWireSegments.length;++r){var o=this.connectedWireSegments[r],s=this.wireSegmentEnds[r],u=o.getEndLocation(s);i.isEqual(u)||(f&&(t+="<br>Error with connection object '"+this.getUniqName()+"'",f=!1),t+="<br>",t+="Wire segment '"+o.getUniqName()+"'",t+=" at end '"+s+"' does not match",t+="<br>",t+="Connection is at   "+i.x+","+i.y,t+="<br>",t+=" Wire segment is at "+u.x+","+u.y,t+="<br>")}for(r=0;r<this.connectedPins.length;++r)e=this.connectedPins[r],u=e.getLocation(),i.isEqual(u)||(f&&(t+="<br>Error with connection object '"+this.getUniqName()+"'",f=!1),t+="<br>",t+="Pin '"+e.getName(),t+="' on component '"+e.getComponent().getInstName()+"' does not match",t+="<br>",t+="Connection is at "+i.x+","+i.y,t+="<br>",t+="Pin is at        "+u.x+","+u.y,t+="<br>");return n&&t!=""&&Project.MessageManager.showErrorMessage(t),t},i.prototype.getSaveData=function(){var n=new t,r,i,u,f;for(n.uniqName=this.uniqName,n.x=Math.round(this.location.x),n.y=Math.round(this.location.y),n.wireSegNames=[],n.wireSegEnds=[],n.compInstNames=[],n.pinNames=[],i=0;i<this.connectedWireSegments.length;++i)r=this.connectedWireSegments[i].getUniqName(),n.wireSegNames.push(r),n.wireSegEnds.push(this.wireSegmentEnds[i]);for(i=0;i<this.connectedPins.length;++i)u=this.connectedPins[i].getName(),f=this.connectedPins[i].getComponent().getInstName(),n.compInstNames.push(f),n.pinNames.push(u);return n},i.prototype.dump=function(n){Project.Utility.dump(n,"Connection: "+this.uniqName);this.location.dump(n,"location: ");Project.Utility.dump(n,"Number of connected wire segments: "+this.connectedWireSegments.length);Project.Utility.dump(n,"Number of connected pins: "+this.connectedPins.length);this.dumpZeroLengthWires(n)},i.prototype.dumpZeroLengthWires=function(n){for(var t,i=0;i<this.connectedWireSegments.length;++i)if(t=this.connectedWireSegments[i],t.isZeroLength())if(this.connectedWireSegments.length!=2)Project.Utility.dump(n,"#########  ZERO-LENGTH WIRE NOT THE ONLY WIRE!!!");else if(t.getConnection(1)!=this||t.getConnection(2)!=this)Project.Utility.dump(n,"#########  ZERO-LENGTH WIRE NOT CONNECTED AT BOTH ENDS!!!");else{Project.Utility.dump(n,"***** Found zero-length wire: "+t.getUniqName());break}},i.prototype.updateConnectionDot=function(){var t=this.getNumConnections();this.isBusConnection()||(this.getZeroLengthWire()!=null&&(t-=2),t>2?this.dot==null?this.dot=new n.ConnectionDot(this.design,this.location,this.getTechnology()):this.dot.show():this.dot&&this.removeConnectionDot())},i.prototype.removeConnectionDot=function(){this.dot&&(this.dot.remove(),this.dot=null)},i.prototype.getTechnology=function(){var n,t;return this.connectedPins.length>=1?(n=this.connectedPins[0],n.getTechnology()):this.connectedWireSegments.length>=1?(t=this.connectedWireSegments[0],t.getTechnology()):void 0},i.prototype.adjustLocation=function(){var n,t,i;this.connectedPins.length>=1?(n=this.connectedPins[0],this.location=n.getLocation().clone()):this.connectedWireSegments.length>=1&&(t=this.connectedWireSegments[0],i=this.wireSegmentEnds[0],this.location=t.getEndLocation(i))},i.prototype.correctLocation=function(){var t,n,i,r;for(this.connectedPins.length>=1?t=this.getPin(0).getLocation():this.connectedWireSegments.length>=1&&(i=this.getWireSegment(0),r=this.getWireSegmentEnd(0),t=i.getEndLocation(r)),this.moveTo(t),n=0;n<this.connectedWireSegments.length;++n)i=this.connectedWireSegments[n],r=this.wireSegmentEnds[n],i.moveEndTo(t,r);this.manageZeroLengthWires()},i.prototype.removeIfNotNeeded=function(){var n,t,i;return this.getNumConnections()==1&&(this.connectedPins.length==1?(n=this.connectedPins[0],n.removeConnection(),this.connectedPins=[]):(t=this.connectedWireSegments[0],i=this.wireSegmentEnds[0],t.removeConnection(i),this.connectedWireSegments=[],this.wireSegmentEnds=[])),this.getNumConnections()==0?(this.removeFromDesign(),!1):!0},i.prototype.removeWireSeg=function(n,t){for(var r,u,i=0;i<this.connectedWireSegments.length;++i)if(r=this.connectedWireSegments[i],u=this.wireSegmentEnds[i],r==n&&u==t)return this.connectedWireSegments.splice(i,1),this.wireSegmentEnds.splice(i,1),!0;return!1},i.prototype.deleteZeroLengthWire=function(n){n.removeConnection(1);n.removeConnection(2);this.removeWireSeg(n,1);this.removeWireSeg(n,2);n.remove()},i.prototype.createZeroLengthWire=function(){var u=this.getLocation(),f=new n.Segment(u,u),r=!1,t,i,e;return this.getNumConnectedPins()>0&&(r=this.getPin(0).isVector()),t=new n.WireSegment(this.design,f,r,this.getTechnology()),this.connectedWireSegments.push(t),this.wireSegmentEnds.push(1),this.connectedWireSegments.push(t),this.wireSegmentEnds.push(2),t.attachConnection(this,1),t.attachConnection(this,2),i=new n.Wire(this.design,t),r&&(this.getPin(0).getVectorWidth()>0?i.setBusIndices(this.getPin(0).getVectorIndices().clone()):this.getNumConnectedPins()>1&&i.setBusIndices(this.getPin(1).getVectorIndices().clone())),e=new n.Net(this.design,i),this.design.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS),t},i.prototype.areTwoWireSegmentsInline=function(){return this.getNumConnectedWireSegments()!=2||this.getNumConnectedPins()!=0?!1:this.inlineOrOverlapping(!0,0,1)},i.prototype.getTwoOverlappingWireSegmentsIdx=function(){for(var i,u,e,r=[],n=[],f=this.getNumConnectedWireSegments(),t=0;t<f;++t)for(i=t+1;i<f;++i)this.inlineOrOverlapping(!1,t,i)&&(n.indexOf(t)==-1&&n.push(t),n.indexOf(i)==-1&&n.push(i));return n.length>2?(u=this.getLongest(n),e=this.getLongest(n,u),r.push(u),r.push(e)):n.length==2&&(r=n),r},i.prototype.getLongest=function(n,t){for(var r,u=-1,f=-1,i=0;i<n.length;++i)i!=t&&(r=this.getWireSegment(i).getSegment().length(),r>u&&(u=r,f=i));return f},i.prototype.inlineOrOverlapping=function(n,t,i){var r=this.getWireSegment(t),u=this.getWireSegment(i);if(r.isZeroLength()||u.isZeroLength()||r.getOrient()!=u.getOrient())return!1;var e=this.getWireSegmentEnd(t),o=this.getWireSegmentEnd(i),s=e==1?2:1,h=r.getEndLocation(s),c=o==1?2:1,l=u.getEndLocation(c),f=this.getLocation();return f.quadrant(h)==f.quadrant(l)?n?!1:!0:n?!0:!1},i.prototype.addToDesign=function(){this.design.addConnection(this)},i.prototype.removeFromDesign=function(){this.design.removeConnection(this)},i.prototype.renameInDesign=function(n){this.design.renameConnection(this,n)},i.prototype.existsInDesign=function(){return this.design.connectionExists(this)},i.NAME_PREFIX="_conn_",i}(),t;n.Connection=i;t=function(){function n(){}return n.prototype.compareTo=function(n,t,i){var r=t+PATH_SEPARATOR+this.uniqName;return Project.Utility.comparePrimitives(this.uniqName,n.uniqName,"uniqName",t,i)?Project.Utility.comparePrimitives(this.x,n.x,"x",r,i)?Project.Utility.comparePrimitives(this.y,n.y,"y",r,i)?Project.Utility.comparePromitiveArrays(this.wireSegNames,n.wireSegNames,r,i)?Project.Utility.comparePromitiveArrays(this.wireSegEnds,n.wireSegEnds,r,i)?Project.Utility.comparePromitiveArrays(this.compInstNames,n.compInstNames,r,i)?Project.Utility.comparePromitiveArrays(this.pinNames,n.pinNames,r,i)?!0:!1:!1:!1:!1:!1:!1:!1},n.prototype.dumpState=function(n,t){var i=JSON.stringify(this);return Project.Utility.dumpState("connections",i,n,t)},n}();n.ConnectionState=t}(BaseWire||(BaseWire={})),function(n){var t=function(){function n(n,t,i){this.graphic=null;this.SIZE=4;this.design=n;this.technology=i;this.graphic=n.getPaper().circle(t.x,t.y,this.SIZE);this.graphic.attr("stroke-width","1");this.graphic.node.setAttribute("class",this.getClass());this.graphic.toFront()}return n.prototype.remove=function(){this.graphic.remove()},n.prototype.moveTo=function(n){this.graphic.attr({cx:n.x,cy:n.y})},n.prototype.hide=function(){this.graphic.hide()},n.prototype.show=function(){this.graphic.show()},n.prototype.select=function(){},n.prototype.deselect=function(){},n.prototype.finishAnimation=function(){Project.Utility.finishAnimation(this.graphic)},n.prototype.setTechnology=function(n){this.technology!=n&&(this.technology=n,this.graphic.node.removeAttribute("class"),this.graphic.node.setAttribute("class",this.getClass()))},n.prototype.getClass=function(){return this.design.getCssClassMgr().getConnectionDotClass(this.technology)},n}();n.ConnectionDot=t}(BaseWire||(BaseWire={})),function(n){var t=function(){function n(n){this.connArr=[];this.ignoreConnChanges=!1;this.validationErrorDetected=!1;this.design=n;this.clear();this.finalizeEnabled=!0}return n.prototype.manage=function(n){this.ignoreConnChanges||n&&this.connArr.indexOf(n)<0&&this.connArr.push(n)},n.prototype.ignoreChanges=function(){this.ignoreConnChanges=!0},n.prototype.acceptChanges=function(){this.ignoreConnChanges=!1},n.prototype.enableFinalize=function(){this.finalizeEnabled=!0},n.prototype.disableFinalize=function(){this.finalizeEnabled=!1},n.prototype.finalize=function(){var r,f,s,t,h,c,u,e,i,o,n,l;if(this.finalizeEnabled){for(this.ignoreChanges(),r=this.connArr.length,f=this.getWireArr(),n=0;n<f.length;++n)s=f[n],s.splitDisconnectedWires();for(n=0;n<r;++n)t=this.connArr[n],t.existsInDesign()&&t.manageZeroLengthWires();for(n=0;n<r;++n)t=this.connArr[n],t.existsInDesign()&&t.mergeInlineWireSegments();for(this.acceptChanges(),n=0;n<r;++n)t=this.connArr[n],t.existsInDesign()&&t.removeOverlappingWireSegments();for(r=this.connArr.length,this.ignoreChanges(),n=0;n<r;++n)t=this.connArr[n],t.existsInDesign()&&t.mergeInlineWireSegments();for(n=0;n<r;++n)if(t=this.connArr[n],t.existsInDesign())for(t.finalize(),h=t.getNumConnectedPins(),i=0;i<h;++i)c=t.getPin(i),u=c.getComponent(),u.hasAllConnections()&&!u.isSelected()&&u.resetHighlight();for(e=this.design.getSimulationData().getWaveboxArray(),i=0;i<e.length;i++)for(o=e[i].getProbes(),n=0;n<o.length;++n)l=o[n],l.updateConnection();this.clear();this.validate()}},n.prototype.clear=function(){this.connArr=[];this.acceptChanges()},n.prototype.getWireArr=function(){for(var r,n,t=[],u=this.connArr.length,i=0;i<u;++i)r=this.connArr[i],r.existsInDesign()&&(n=r.getWire(),n&&t.indexOf(n)<0&&t.push(n));return t},n.prototype.validate=function(){var t=!Project.Settings.isProductionMode(),n;this.validationErrorDetected&&(t=!1);n=this.design.validateEmptyObjects(t);n!=""&&(this.validationErrorDetected=!0);n=this.design.validateAllConnectionObjects(t);n!=""&&(this.validationErrorDetected=!0);this.checkForIntegerLocations()},n.prototype.checkForIntegerLocations=function(){for(var o,s,i,h,r,u,f,t,e=this.design.getCompArray(),n=0;n<e.length;++n)t=e[n].getCenter(),t.isAlmostInteger()||e[n].dump(0,"Component not at an integer location");for(o=this.design.getNetArray(),n=0;n<o.length;++n)for(s=o[n].getWires(),i=0;i<s.length;++i)for(h=s[i].getSegments(),r=0;r<h.length;r++)u=h[r],u.getExactEndLocation(1).isAlmostInteger()&&u.getExactEndLocation(2).isAlmostInteger()||u.dump(0,"Wire Segment not at an integer location");for(f=this.design.getConnectionArray(),n=0;n<f.length;++n)t=f[n].getLocation(),t.isAlmostInteger()||f[n].dump(0,"Connection not at an integer location")},n}();n.ConnectionManager=t}(BaseWire||(BaseWire={})),function(n){var r,i,t,f,u;(function(n){n[n.HIDDEN=0]="HIDDEN";n[n.PROBE=1]="PROBE";n[n.WAVEBOX=2]="WAVEBOX";n[n.PROBE_AND_WAVEBOX=3]="PROBE_AND_WAVEBOX"})(n.VisibilityState||(n.VisibilityState={}));r=n.VisibilityState,function(n){n[n.WIRE=0]="WIRE";n[n.COMPONENT=1]="COMPONENT";n[n.WIRE_TO_COMPONENT=2]="WIRE_TO_COMPONENT";n[n.COMPONENT_TO_WIRE=3]="COMPONENT_TO_WIRE";n[n.SIMULATION_TYPE=4]="SIMULATION_TYPE";n[n.SIMULATION_DESCRIPTION=5]="SIMULATION_DESCRIPTION";n[n.TRANSFORMATION=6]="TRANSFORMATION";n[n.COMPONENT_WF_NAME=7]="COMPONENT_WF_NAME";n[n.COLOR=8]="COLOR";n[n.CURSORS=9]="CURSORS";n[n.WAVEBOX_STATE=10]="WAVEBOX_STATE";n[n.PLOT_MODE=11]="PLOT_MODE";n[n.X_ZOOM=12]="X_ZOOM";n[n.Y_ZOOM=13]="Y_ZOOM";n[n.ZOOM=14]="ZOOM";n[n.CALCULATOR=15]="CALCULATOR";n[n.DETACH=16]="DETACH";n[n.BEFORE_NEW_SIMULATION=17]="BEFORE_NEW_SIMULATION"}(n.ChangeEvents||(n.ChangeEvents={}));i=n.ChangeEvents;t=function(){function t(i,r,u,f,e){this.waveBox=null;this.uniqName=null;this.index=0;this.visible=!0;this.opacity=t.OPACITY_UNHIGHLIGHT;this.design=i;this.waveBox=u;this.index=r;var o=new n.ProbePlotState(i,this,u.getPlotState());this.visible=!1;this.uniqName=this.design.createUniqName("_probe_");this.createProbeObjectAndPlot(f,e);this.addToDesign()}return t.prototype.createProbeObjectAndPlot=function(t,i){var r=!0,f=!0,e,o,u;if(t)t instanceof Project.Component?(e=t,this.waveBox.resetWavebox(),this.probeObject=new n.ComponentProbeObject(this,this.design,e,i),this.probeObject.prepareToChooseWaveform(e,!0,null,this.index),r=!1,f=!1):t instanceof BaseWire.WireSegment?(o=t,this.probeObject=new n.WireSegProbeObject(this,this.design,o,i),this.probeObject.prepareToChooseWaveform(o,!0,null,this.index),r=!1,f=!1):(u=t,r=i,u instanceof ServerStructures.WireProbeState?this.probeObject=new n.WireSegProbeObject(this,this.design,u,i):u instanceof ServerStructures.ComponentProbeState?this.probeObject=new n.ComponentProbeObject(this,this.design,u,i):this.initDetachedProbe(t));else{this.probeObject=null;r=!1;return}r?n.getWaveBoxManager().updateSingleWavebox(this.waveBox):f&&this.waveBox.updateTitle(!1)},t.prototype.init=function(){this.probeGraphics=new u(this);this.visible=!0},t.prototype.initByState=function(t,i,r){t&&this.init();this.setColor(r);t instanceof ServerStructures.WireProbeState?this.probeObject=new n.WireSegProbeObject(this,this.design,t,i):t instanceof ServerStructures.ComponentProbeState?this.probeObject=new n.ComponentProbeObject(this,this.design,t,i):this.initDetachedProbe(t)},t.prototype.initByLocation=function(n,t){t&&this.waveBox.notify(i.COLOR,this.index,t);this.init();this.moveTo(n.x,n.y)},t.prototype.initByProbeObject=function(n,t,r){r&&this.waveBox.notify(i.COLOR,this.index,r);this.init();this.setNewProbeObject(n,t)},t.prototype.initDetachedProbe=function(n){this.uniqName=n.uniqName;this.detach()},t.prototype.detach=function(){var t=this.getColor(),n;this.removeGraphic();this.probeObject&&(this.probeObject.removeFromProbeObject(),this.probeObject=null);this.waveBox.notify(i.DETACH,this.index);n=this.waveBox.getWaveboxCenterOnSchematic();this.initByLocation(n,t);this.hide();setBodyCursor("auto");this.waveBox.updateProbeButton()},t.prototype.isAttached=function(){return this.probeObject==null?!1:this.probeObject.isAttached()},t.prototype.setNewProbeObject=function(t,i){var e,f,r,u;this.probeObject?(e=this.probeObject,f=null,this.probeObject.isTheSameProbeObject(t)&&(f=this.probeObject.getWaveformHandle()),t instanceof BaseWire.WireSegment?(r=t,this.probeObject=new n.WireSegProbeObject(this,this.design,r,i),this.cleanPreviousProbeObject(e,this.probeObject),this.probeObject.prepareToChooseWaveform(r,!1,f,this.index)):t instanceof Project.Component&&(u=t,this.probeObject=new n.ComponentProbeObject(this,this.design,u,i),this.cleanPreviousProbeObject(e,this.probeObject),this.probeObject.prepareToChooseWaveform(u,!1,f,this.index))):t instanceof BaseWire.WireSegment?(r=t,this.probeObject=new n.WireSegProbeObject(this,this.design,r,i),this.probeObject.prepareToChooseWaveform(r,!0,null,this.index)):t instanceof Project.Component&&(u=t,this.probeObject=new n.ComponentProbeObject(this,this.design,u,i),this.probeObject.prepareToChooseWaveform(u,!0,null,this.index))},t.prototype.cleanPreviousProbeObject=function(n,t){n&&(t&&t.switchFromProbe(n),n.removeFromProbeObject())},t.prototype.updateColors=function(n){this.setColor(n)},t.prototype.setComponentWaveformName=function(t,r){this.waveBox.notify(i.COMPONENT_WF_NAME,this.index,t)&&(r&&this.waveBox.notify(i.TRANSFORMATION,this.index,r),n.getWaveBoxManager().updateSingleWavebox(this.waveBox))},t.prototype.getComponentWaveformName=function(){return this.waveBox.getComponentWaveformName(this.index)},t.prototype.remove=function(n){this.removeGraphic();this.probeObject&&this.probeObject.removeFromProbeObject();n&&this.waveBox.remove(!1);this.removeFromDesign()},t.prototype.moveTo=function(n,i){this.probeGraphics&&this.probeGraphics.moveTo(n,i);var r=n+t.PROBE_WBOX_X_OFFSET,u=i+t.PROBE_WBOX_Y_OFFSET;this.setLineStartPosition(r,u);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},t.prototype.getLocationOfTip=function(){return this.probeGraphics?this.probeGraphics.getLocationOfTip():new BaseWire.Point(0,0)},t.prototype.getLocationOfEnd=function(){return this.probeGraphics.getLocationOfEnd()},t.prototype.getBoundingRect=function(){if(!this.isVisible()||!this.design.getSurface().isLoadingDesign()&&!this.getWavebox().isPinnedToSchematic())return null;if(this.probeGraphics){var n=this.probeGraphics.getBoundingRect(),t=this.getWavebox().getBoundingRect();return Project.Utility.accumulateBoundingRect(t,n)}return this.getWavebox().getBoundingRect()},t.prototype.hide=function(){this.probeGraphics&&this.probeGraphics.hide();this.visible=!1},t.prototype.show=function(){this.probeGraphics&&this.probeGraphics.show();this.visible=!0},t.prototype.isVisible=function(){return this.visible},t.prototype.getVisibility=function(){return this.visible?r.PROBE:r.HIDDEN},t.prototype.setVisibility=function(n){n==r.PROBE?this.show():this.hide()},t.prototype.highlight=function(){this.probeGraphics&&this.probeGraphics.highlight();this.probeObject.hideBar()},t.prototype.unhighlight=function(){this.probeGraphics&&this.probeGraphics.unhighlight()},t.prototype.makePencilVisible=function(){this.probeGraphics&&this.probeGraphics.makePencilVisible()},t.prototype.makePencilTransparent=function(){this.probeGraphics&&this.probeGraphics.makePencilTransparent()},t.prototype.highlightPencil=function(){this.probeGraphics&&this.probeGraphics.highlightPencil()},t.prototype.unhighlightPencil=function(){this.probeGraphics&&this.probeGraphics.unhighlightPencil()},t.prototype.removeGraphic=function(){this.probeGraphics&&(this.probeGraphics.remove(),this.probeGraphics=null)},t.prototype.makePencilUniquelyVisible=function(){this.probeObject&&this.probeObject.makePencilUniquelyVisible()},t.prototype.makeAnotherPencilUniquelyVisible=function(){this.probeObject&&this.probeObject.makeAnotherPencilUniquelyVisible()},t.prototype.getProbeObjectName=function(){return this.probeObject?this.probeObject.getProbeObjectName():null},t.prototype.getWavebox=function(){return this.waveBox},t.prototype.toFront=function(n){n===void 0&&(n=!0);this.isAttached()&&(this.probeGraphics.toFront(n),this.makePencilUniquelyVisible())},t.prototype.getUniqName=function(){return this.uniqName},t.prototype.updateConnection=function(){this.probeObject&&this.probeObject.updateConnection()},t.prototype.cancelMoving=function(){this.design.getUndoManager().cancelCommand("Move Probe");n.getWaveBoxManager().closeWaveformDialog(!0,null)},t.prototype.getSaveData=function(){var t=this.getLocationOfTip(),n=new ServerStructures.EmptyProbeState,i;return this.probeObject&&(n=this.probeObject.getSaveData()),n.uniqName=this.uniqName,n.x=Math.round(t.x),n.y=Math.round(t.y),i=this.waveBox.getProbePlotState(this.index),n},t.prototype.getProbeState=function(){var n=null,t;return n=this.probeObject?this.probeObject.getSaveData():new ServerStructures.EmptyProbeState,n.probeIndex=this.index,n.uniqName=this.uniqName,t=this.getLocationOfTip(),t&&(n.x=Math.round(t.x),n.y=Math.round(t.y)),n},t.prototype.dump=function(n){Project.Utility.dump(n,"Probe: "+this.uniqName)},t.prototype.getColor=function(){return this.waveBox.getProbeColor(this.index)},t.prototype.setColor=function(n){n&&(this.waveBox.notify(i.COLOR,this.index,n),this.probeGraphics&&this.probeGraphics.setColor(n))},t.prototype.getClass=function(){return this.design.getCssClassMgr().getProbeClass(this.getTechnology())},t.prototype.getTechnology=function(){return Project.TECHNOLOGY.ELEC},t.prototype.transform=function(n,t){this.probeGraphics&&this.probeGraphics.transform(n,t)},t.prototype.restore=function(t){this.uniqName=t.uniqName;this.probeObject?this.probeObject instanceof n.WireSegProbeObject&&t instanceof ServerStructures.WireProbeState?this.probeObject.restore(t):this.probeObject instanceof n.ComponentProbeObject&&t instanceof ServerStructures.ComponentProbeState?this.probeObject.restore(t):(this.cleanPreviousProbeObject(this.probeObject,null),this.createProbeObjectAndPlot(t,!1)):this.createProbeObjectAndPlot(t,!1)},t.prototype.isNearObject=function(n){var t=this.highlightOverObj(n),i,r;if(t){if(t instanceof BaseWire.WireSegment||t instanceof Project.Component)return t.highlight(),t}else{if(i=this.design.findCloseWireSegment(this.getLocationOfTip(),!1),i)return i.highlight(),i;if(r=this.design.findCloseComponent(this.getLocationOfTip()),r)return r.highlight(),r}return null},t.prototype.attachToWireSegment=function(n){if(n&&n.canConnectProbe()){var t=this.getLocationOfTip(),i=n.getClosest(t);this.setNewProbeObject(n,i)}n.unhighlight()},t.prototype.attachToComponent=function(n){if(n){var t=n.getCenter();this.setNewProbeObject(n,t)}n.unhighlight()},t.prototype.highlightOverObj=function(n){var i=this.getLocationOfTip(),t=this.design.findObjectUnderPoint(i);return t!=n&&(n&&n instanceof BaseWire.WireSegment?n.unhighlight():n&&n instanceof Project.Component&&n.unhighlight(),t&&(t instanceof BaseWire.WireSegment?t.highlight():t instanceof Project.Component&&(t.highlight(),this.toFront()))),t},t.prototype.addToDesign=function(){this.design.addProbe(this)},t.prototype.removeFromDesign=function(){this.design.removeProbe(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},t.prototype.renameInDesign=function(n){this.design.renameProbe(this,n);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},t.prototype.existsInDesign=function(){return this.design.probeExists(this)},t.prototype.getWaveBoxSimulationId=function(){return this.waveBox.getSimulationId()},t.prototype.getWaveformName=function(){return this.waveBox.getProbePlotState(this.index).getFullWaveformName()},t.prototype.getWaveform=function(){return this.waveBox.getWaveContainer().getProbeWaveform(this.index)},t.prototype.updateProbeEndPosition=function(){this.probeGraphics&&this.probeGraphics.updateLineEndPosition()},t.prototype.setProbeEndPositions=function(n){this.probeGraphics&&this.probeGraphics.setLineEndPosition(n)},t.prototype.getProbeEndPosition=function(){return this.probeGraphics?this.probeGraphics.getLineEndPosition():null},t.prototype.hideGraphics=function(){this.probeGraphics&&this.probeGraphics.hide()},t.prototype.showGraphics=function(){this.probeGraphics&&this.probeGraphics.show()},t.prototype.setLineStartPosition=function(n,t,i){this.probeGraphics&&this.probeGraphics.setLineStartPosition(n,t,i)},t.PROBE_PATH="M25.31,2.872l-3.384-2.127c-0.854-0.536-1.979-0.278-2.517,0.576l-1.334,2.123l6.474,4.066l1.335-2.122C26.42,4.533,26.164,3.407,25.31,2.872zM6.555,21.786l6.474,4.066L23.581,9.054l-6.477-4.067L6.555,21.786zM5.566,26.952l-0.143,3.819l3.379-1.787l3.14-1.658l-6.246-3.925L5.566,26.952z",t.PROBE_TIP_X_OFFSET=-6,t.PROBE_TIP_Y_OFFSET=-31,t.PROBE_WBOX_X_OFFSET=18,t.PROBE_WBOX_Y_OFFSET=-29,t.LINE_SHIFT=20,t.ANIMATION_TIME=300,t.OPACITY_HIGHLIGHT=1,t.OPACITY_UNHIGHLIGHT=.6,t.OPACITY_TIME=400,t}();n.Probe=t;f=function(){function n(){this.probeIndex=0;this.cursorStates=[]}return n.prototype.compareTo=function(n,t,i,r){var u=t+PATH_SEPARATOR+this.uniqName;return Project.Utility.comparePrimitives(this.uniqName,n.uniqName,"uniqName",t,i)?Project.Utility.comparePrimitives(this.x,n.x,"x",u,i)?Project.Utility.comparePrimitives(this.y,n.y,"y",u,i)?Project.Utility.comparePrimitives(this.wireSegName,n.wireSegName,"wireSegName",u,i)?Project.Utility.comparePrimitives(this.waveboxWidth,n.waveboxWidth,"waveboxWidth",u,i)?Project.Utility.comparePrimitives(this.waveboxHeight,n.waveboxHeight,"waveboxHeight",u,i)?Project.Utility.comparePrimitives(this.waveboxIsVisible,n.waveboxIsVisible,"waveboxIsVisible",u,i)?Project.Utility.comparePrimitives(this.xmin,n.xmin,"xmin",u,i)?Project.Utility.comparePrimitives(this.xmax,n.xmax,"xmax",u,i)?n.simulationType!=null&&this.simulationType!=null&&!Project.Utility.comparePrimitives(this.simulationType,n.simulationType,"simulationType",u,i)?!1:n.transformName!=null&&this.transformName!=null&&!Project.Utility.comparePrimitives(this.transformName,n.transformName,"transformName",u,i)?!1:Project.Utility.comparePrimitives(this.isViewAllForX,n.isViewAllForX,"isViewAllForX",u,i)?Project.Utility.compareArrays(this.cursorStates,n.cursorStates,"",u+"/cursorStates",i,r)?!0:!1:!1:!1:!1:!1:!1:!1:!1:!1:!1:!1},n}();n.ProbeStateOld=f;u=function(){function i(n){this.pencil=null;this.overlay=null;this.pencilTransparency=!1;this.probe=n;this.design=n.design;this.waveBox=n.getWavebox();this.createGraphic();this.defineEvents()}return i.prototype.createGraphic=function(){this.pencil=Project.Utility.drawProbe(this.design.getPaper(),this.probe.opacity,this.probe.getClass());this.overlay=this.design.getPaper().rect(0,0,35,35);this.overlay.attr("opacity","0");this.overlay.attr("fill","#ffff00");this.line=new n.ProbeLine(this.probe);this.setColor(this.probe.getColor())},i.prototype.setColor=function(n){this.pencil&&(n?(this.pencil.node.removeAttribute("class"),this.pencil.attr({fill:n})):this.pencil.node.setAttribute("class",this.probe.getClass()));this.line&&this.line.updateLineColor(n)},i.prototype.remove=function(){this.pencil&&this.pencil.remove();this.overlay&&this.overlay.remove();this.line&&this.line.remove()},i.prototype.moveTo=function(n,i){var r=n+t.PROBE_TIP_X_OFFSET,u=i+t.PROBE_TIP_Y_OFFSET;this.pencil.transform("T"+r+","+u);this.overlay.transform("T"+r+","+u)},i.prototype.getLocationOfTip=function(){var n=this.pencil.getBBox();return new BaseWire.Point(n.x,n.y2)},i.prototype.getLocationOfEnd=function(){var n=this.pencil.getBBox();return new BaseWire.Point(n.x+t.PROBE_WBOX_X_OFFSET,n.y2+t.PROBE_WBOX_Y_OFFSET)},i.prototype.hide=function(){this.pencil.hide();this.overlay.hide();this.line&&this.line.hideLine()},i.prototype.show=function(){this.pencil.show();this.overlay.show();this.line&&this.line.showLine()},i.prototype.getBoundingRect=function(){return new Project.BoundingRect(this.pencil.getBBox())},i.prototype.isPencilTransparent=function(){return this.pencilTransparency},i.prototype.highlightPencil=function(){this.isPencilTransparent()||(this.probe.opacity=t.OPACITY_HIGHLIGHT,this.pencil&&this.pencil.animate({opacity:this.probe.opacity},t.OPACITY_TIME))},i.prototype.unhighlightPencil=function(){this.isPencilTransparent()||(this.probe.opacity=t.OPACITY_UNHIGHLIGHT,this.pencil&&this.pencil.animate({opacity:this.probe.opacity},t.OPACITY_TIME))},i.prototype.makePencilTransparent=function(){this.pencil.attr({opacity:0,"stroke-opacity":0});this.pencilTransparency=!0},i.prototype.makePencilVisible=function(){this.pencil.attr({opacity:this.probe.opacity,"stroke-opacity":this.probe.opacity});this.pencilTransparency=!1},i.prototype.toFront=function(n){n===void 0&&(n=!0);this.probe.isAttached()&&(this.line&&n&&this.line.toFront(),this.pencil.toFront(),this.overlay.toFront())},i.prototype.highlight=function(){this.isPencilTransparent()||(this.highlightPencil(),this.line&&this.line.highlight())},i.prototype.unhighlight=function(){this.isPencilTransparent()||(this.unhighlightPencil(),this.line&&this.line.unhighlight())},i.prototype.transform=function(n,i){if(i){var r=Raphael.animation({transform:n},t.ANIMATION_TIME);this.pencil.animate(r);this.overlay.animate(r)}else this.pencil.transform(n),this.overlay.transform(n);n!="...T0,0"&&this.probe.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},i.prototype.defineEvents=function(){var t=this,r;this.overlay.hover(function(){t.design.isHoverEnabled()&&(setBodyCursor("move"),t.highlight())},function(){t.design.isHoverEnabled()&&(setBodyCursor("default"),t.unhighlight())});r=!1;this.overlay.mousedown(function(){r=!0;t.probe.probeObject instanceof n.ComponentProbeObject&&(r=t.waveBox.isVisible());t.waveBox.showOnTop();t.design.getSurface().clearFocus()});var u,f,i,e=function(){return WaveViewer.SVWEventHandler.setIsMoving(t),t.design.getUndoManager().startUndoableCommand(Project.MoveProbeCommand,t.design,t.waveBox),u=f=0,i=t.probe.highlightOverObj(null),t.toFront(),t.waveBox.shadeWaveformsForProbe(t.probe.index),$(document).bind("keydown.probeMoveEvent",function(n){n.which==Project.Design.EscKey&&t.probe.cancelMoving()}),{}},o=function(n,r){var e,c;t.probe.makeAnotherPencilUniquelyVisible();var o=t.design.getSurface().getScale(),s=n*o,h=r*o,l=s-u,a=h-f;return t.transform(Project.Utility.pointToTransform(l,a)),u=s,f=h,e=t.getLocationOfEnd(),t.line&&t.line.setLineStartPosition(e.x,e.y),c=i,i=t.probe.isNearObject(c),{}},s=function(){var n=i;return i=t.probe.isNearObject(n),i?i instanceof BaseWire.WireSegment?t.probe.attachToWireSegment(i):i instanceof Project.Component&&(r?t.probe.attachToComponent(i):(r=!0,i.unhighlight(),t.design.getUndoManager().finishUndoableCommand(t.waveBox,"MoveProbeCommand"))):t.waveBox.detachProbe(t.probe,!0),WaveViewer.SVWEventHandler.setIsMoving(null),t.toFront(),t.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX),$(document).unbind(".probeMoveEvent"),{}};this.overlay.drag(o,e,s)},i.prototype.updateLineEndPosition=function(){this.line&&this.line.updateLineEndPosition()},i.prototype.setLineEndPosition=function(n){this.line&&this.line.setLineEndPosition(n)},i.prototype.getLineEndPosition=function(){return this.line?this.line.getLineEndPosition():this.waveBox.getWaveboxCenterOnSchematic()},i.prototype.getLineStartPosition=function(){return this.line?this.line.getLineStartPosition():this.waveBox.getWaveboxCenterOnSchematic()},i.prototype.setLineStartPosition=function(n,t,i){this.line&&this.line.setLineStartPosition(n,t,i)},i}();n.ProbeGraphics=u}(ProbeModule||(ProbeModule={})),function(n){var t=function(){function t(n,t,i){this.isProbeCreationStart=!1;this.mockProbe=null;this.fromShematic=!0;this.mouseupFirstClickDone=!1;this.probePaper=null;this.currentProbeIndex=0;this.ghostPath=null;this.surface=n;this.buttonId=t;i&&(this.waveBox=i,this.fromShematic=!1);this.start()}return t.prototype.start=function(){this.defineEvents();Project.Utility.setTooltip(this.buttonId,"Place a Waveform Probe");this.prepareWaveboxButton()},t.prototype.isWaveBoxButtonEnabled=function(){var n=this.surface.getDesign();return n&&!n.isEmpty()},t.prototype.defineEvents=function(){var n=this;$(this.buttonId).mousedown(function(t){n.isWaveBoxButtonEnabled()&&(n.isInProbeCreation()||(n.createMockProbeAndStartMoving(t),n.mouseupFirstClickDone=!1))});this.fromShematic||$(this.buttonId).hover(function(){setBodyCursor("move")},function(){setBodyCursor("auto")})},t.prototype.createProbeGhost=function(){var i=document.createElement("div"),r;i.id=t.PROBE_GHOST_ID;$(i).width(t.ProbeSymbolWidth).height(t.ProbeSymbolWidth);$(i).appendTo("body");this.probePaper=Raphael(i,t.ProbeSymbolWidth,t.ProbeSymbolHeight);r=this.surface.getDesign().getCssClassMgr().getProbeClass(Project.TECHNOLOGY.ELEC);this.ghostPath=Project.Utility.drawProbe(this.probePaper,n.Probe.OPACITY_HIGHLIGHT,r);this.setMouseUpEventListenerForGhost()},t.prototype.setMouseUpEventListenerForGhost=function(){var n=this;$(t.PROBE_GHOST).on("mouseup.probeEvent",function(t){if(n.isWaveBoxButtonEnabled()){t.preventDefault();var i=n.mockProbe.isNearObject(n.previousObject);i?n.createProbe(i,t):(!n.fromShematic||n.mouseupFirstClickDone)&&(n.cancelProbeCreation(),n.fromShematic||n.waveBox.updateProbeButton());n.mouseupFirstClickDone=!0}})},t.prototype.getTooltipForWaveboxButton=function(){return this.isWaveBoxButtonEnabled()?"Create a Waveform Probe":"Cannot Create a Waveform Probe for an Empty Design"},t.prototype.getTooltipText=function(n,t){return n==this.buttonId?this.getTooltipForWaveboxButton():t},t.prototype.removeProbeGhost=function(){$(t.PROBE_GHOST).remove()},t.prototype.showProbeGhost=function(n,i,r){var u=$(t.PROBE_GHOST),f=1/this.surface.getScale(),e=f*t.ProbeSymbolWidth,o=f*t.ProbeSymbolHeight;u.width(e).height(o);u.children(t.PROBE_GHOST+"> svg").width(e).height(o);this.probePaper.setViewBox(0,0,t.ProbeSymbolWidth,t.ProbeSymbolHeight,!1);u.css({"z-index":50800,cursor:t.EMPTY_CURSOR,position:"absolute",left:n.pageX+i*f,top:n.pageY+r*f});u.show()},t.prototype.prepareWaveboxButton=function(){var n=this;$(this.buttonId).draggable({start:function(){n.mouseupFirstClickDone=!1}})},t.prototype.createMockProbeAndStartMoving=function(n){var i=this.surface.getDesign();(n.preventDefault(),this.isWaveBoxButtonEnabled())&&(this.startProbeCreation(),setBodyCursor(t.EMPTY_CURSOR),WaveViewer.SVWEventHandler.setIsMoving(this),this.createProbeGhost(),this.showProbeGhost(n,t.shiftX,t.shiftY),this.mockProbe=this.createProbeByEvent(this.surface.getDesign(),null,n,null),this.mockProbe.makePencilTransparent(),this.addMockProbeListeners(),this.setColorForGhost(this.mockProbe.getColor()))},t.prototype.setColorForGhost=function(n){this.ghostPath&&n&&(this.ghostPath.node.removeAttribute("class"),this.ghostPath.attr({fill:n}))},t.prototype.addMockProbeListeners=function(){var n=this;$(document).on("mousemove.probeEvent",function(i){n.showProbeGhost(i,t.shiftX,t.shiftY);var r=surface.screenToSch(new BaseWire.Point(i.pageX,i.pageY));n.mockProbe.moveTo(r.x,r.y);n.previousObject=n.mockProbe.isNearObject(n.previousObject)});$(document).bind("keydown.probeEvent",function(t){t.which==Project.Design.EscKey&&n.cancelProbeCreation()})},t.prototype.cancelProbeCreation=function(){this.finishProbeCreation()},t.prototype.createProbe=function(n,t){var i=this.mockProbe.getColor(),r;this.finishProbeCreation();r=this.createProbeByEvent(this.surface.getDesign(),n,t,i);n.unhighlight()},t.prototype.finishProbeCreation=function(){var r=this.surface.getDesign(),i;$(document).unbind(".probeEvent");$(SCHEMATIC).unbind(".probeEvent");$(t.PROBE_GHOST).unbind(".probeEvent");this.removeProbeGhost();this.mockProbe&&(i=this.fromShematic?!0:!1,this.mockProbe.remove(i),this.mockProbe=null,this.fromShematic&&n.getWaveBoxManager().ignoreMockProbe());this.endProbeCreation();this.previousObject=null;this.mouseupFirstClickDone=!1;WaveViewer.SVWEventHandler.setIsMoving(null);setBodyCursor("default");this.waveBox&&this.waveBox.updateProbeButton()},t.prototype.startProbeCreation=function(){this.isProbeCreationStart=!0},t.prototype.endProbeCreation=function(){this.isProbeCreationStart=!1},t.prototype.isInProbeCreation=function(){return this.isProbeCreationStart},t.prototype.createProbeByEvent=function(n,t,i,r){var u=surface.screenToSch(new BaseWire.Point(i.pageX,i.pageY));return this.createProbeAtLocation(n,t,u,r)},t.prototype.createProbeAtLocation=function(t,i,r,u){var f=null;return f=this.waveBox?this.waveBox:new n.WaveBox(t,!0,null),i&&(this.fromShematic?t.getUndoManager().startUndoableCommand(Project.AddWaveboxCommand,t,f):t.getUndoManager().startUndoableCommand(Project.AddProbeCommand,t,f)),f.initProbeByObjectOrLocation(i,r,u,this.currentProbeIndex)},t.ProbeSymbolHeight=35,t.ProbeSymbolWidth=35,t.PROBE_GHOST_ID="probeGhostSym",t.PROBE_GHOST="#"+t.PROBE_GHOST_ID,t.ICON_WIDTH=30,t.EMPTY_CURSOR="url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjbQg61aAAAADUlEQVQYV2P4//8/IwAI/QL/+TZZdwAAAABJRU5ErkJggg=='), 'none'",t.shiftX=n.Probe.PROBE_TIP_X_OFFSET,t.shiftY=n.Probe.PROBE_TIP_Y_OFFSET,t.GLOBAL_INDEX=0,t}();n.ProbeButton=t}(ProbeModule||(ProbeModule={})),function(n){var t=function(){function t(n){var t=this,i,r;this.startX=0;this.endX=0;this.startY=0;this.endY=0;this.probe=n;this.updateLineEndPosition();this.line.mousedown(function(){t.probe.toFront();t.probe.getWavebox().showOnTop()});i=function(){t.highlight();t.probe.toFront(!1);t.probe.highlightPencil()};r=function(){t.unhighlight();t.probe.unhighlightPencil();t.line.toFront()};Project.Utility.hoverEventWithToFront(this.line,i,r)}return t.prototype.toFront=function(){this.line.toFront()},t.prototype.setLineStartPosition=function(n,t,i){n!=null&&(this.startX=n);t!=null&&(this.startY=t);this.drawLine(i)},t.prototype.setLineEndPosition=function(t,i){this.endX=t.x;this.endY=t.y+this.probe.index*n.Probe.LINE_SHIFT;this.drawLine(i)},t.prototype.getLineEndPosition=function(){return new BaseWire.Point(this.endX,this.endY)},t.prototype.getLineStartPosition=function(){return new BaseWire.Point(this.startX,this.startY)},t.prototype.drawLine=function(n){var t="M "+this.startX+" "+this.startY;t+=" L "+this.endX+" "+this.endY;this.line?n?this.line.animate({path:t},n,"linear"):this.line.attr("path",t):this.line=surface.getPaper().path(t)},t.prototype.updateLineEndPosition=function(n){var i=this.probe.getWavebox().getSurface();if(i){var t=this.probe.getWavebox().getWaveboxWindowJQ(),r=t.position(),u=t.width(),f=t.height(),e=r.left+u/2,o=r.top+f/2,s=i.screenToSch(e,o);this.setLineEndPosition(s,n)}},t.prototype.updateLineColor=function(n){n&&this.line.attr({stroke:n})},t.prototype.hideLine=function(){this.line&&this.line.hide()},t.prototype.showLine=function(){this.line&&this.line.show()},t.prototype.remove=function(){this.line&&this.line.remove()},t.prototype.highlight=function(){this.line&&this.line.attr("stroke-width","5")},t.prototype.unhighlight=function(){this.line&&this.line.attr("stroke-width","1")},t.prototype.getLineBBox=function(){return this.line.getBBox()},t}();n.ProbeLine=t}(ProbeModule||(ProbeModule={})),function(n){var t=function(){function t(n,t){this.plotData=!0;this.previousWaveformHandler=null;this.isNew=!1;this.probe=n;this.design=t}return t.prototype.getWaveformHandle=function(){return this.waveformHandle},t.prototype.setNewWaveform=function(){var t=WaveViewer.getManager().getWaveformInfoFromCache(this.probe.getWaveBoxSimulationId(),this.waveformHandle,null,!0);if(t){var i=t.getSignalName(),u=this.probe.getWavebox().getSimulationType(!0),r=u==Project.SIMULATION_TYPE.FREQUENCY_DOMAIN,f=WaveViewer.WaveUtils.extractCompWfName(i,r),e=r?WaveViewer.WaveUtils.extractTransformedName(i):null;this.probe.setComponentWaveformName(f,e)}n.getWaveBoxManager().closeWaveformDialog(!0,null)},t.prototype.openWaveformDialog=function(t,i,r,u){this.previousWaveformHandler=u;this.isNew=r;var f=this.design.getSurface().schToScreen(t),o=this.design.getSidebarManager().getRightEdgePosition(),e=Math.abs(o-f.x);e<n.WaveBox.WAVEBOX_WIDTH+20&&(f.x-=Math.abs(e-n.WaveBox.WAVEBOX_WIDTH-20));n.getWaveBoxManager().openWaveformDialog(f,this.probe,r,u,i)},t.prototype.finishWaveformSelection=function(t,i){if(t)this.waveformHandle=t,this.setNewWaveform(),this.design.getUndoManager().finishUndoableCommand(this.probe.getWavebox(),"MoveProbeCommand");else if(this.isNew){this.isNew=!1;n.getWaveBoxManager().closeWaveformDialog(!0,null);var r=this.design.getUndoManager().getActiveCommand();this.design.getUndoManager().clearActiveCommand();r&&r.getCommandClassName()==Project.AddWaveboxCommand.prototype.getCommandClassName()?this.probe.remove(!0):this.probe.detach()}else if(this.previousWaveformHandler)this.design.getUndoManager().clearActiveCommand(),this.waveformHandle=this.previousWaveformHandler,this.makePencilUniquelyVisible(),this.setNewWaveform();else if(i&&(i.which==Project.Design.EscKey||i.which==1)){this.probe.cancelMoving();return}},t}();n.ProbeObject=t}(ProbeModule||(ProbeModule={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r,u){t.call(this,n,i);this.wireSeg=null;this.wire=null;this.addEvents=!0;this.init(r,u)}return __extends(i,t),i.prototype.init=function(n,t){var r,u,i,f;n?n instanceof BaseWire.WireSegment?(this.wireSeg=n,t instanceof BaseWire.Point?this.locate(t):(r=t,u=Project.Utility.eventToPoint(this.design,r),this.locate(u))):(this.plotData=t,i=n,this.probe.uniqName=i.uniqName,i.wireSegName&&(this.wireSeg=this.design.findObjectByUniqName(i.wireSegName)),f=new BaseWire.Point(i.x,i.y),this.locate(f)):(this.plotData=!1,this.locate(t));this.wireSeg&&(this.wireSeg.addProbe(this.probe),this.wire=this.wireSeg.getWire())},i.prototype.locate=function(n){if(this.wireSeg){var t=this.wireSeg.getClosest(n);this.probe.moveTo(t.x,t.y)}else this.probe.moveTo(n.x,n.y)},i.prototype.getProbeObjectName=function(){return this.wireSeg&&this.wireSeg.getWire()?this.wireSeg.getWire().getName().toLowerCase():null},i.prototype.removeFromProbeObject=function(){this.wireSeg&&this.wireSeg.removeProbe(this.probe);this.wireSeg=null;this.wire=null;this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},i.prototype.prepareToChooseWaveform=function(t,i,r){var h=t,c=this.probe.getLocationOfTip(),e=h.getNet().getName(),u=this.probe.getWavebox(),o=this.probe.getWavebox().getSimulationId(),s,f;o?(s=u.getSimulationType(!0),s==Project.SIMULATION_TYPE.TIME_DOMAIN?(n.getWaveBoxManager().updateSingleWavebox(u),u.updateTitle(!0),this.design.getUndoManager().finishUndoableCommand(u,"AddProbeCommand")):(f=WaveViewer.getManager().getWaveformNodes(o,e),f==null||f.length==0?(u.updateTitle(!0),this.design.getUndoManager().finishUndoableCommand(u,"AddProbeCommand")):this.openWaveformDialog(c,e,i,r))):(u.updateTitle(!0),this.design.getUndoManager().finishUndoableCommand(u,"AddProbeCommand"))},i.prototype.updateConnection=function(){if(this.wireSeg){var n=this.probe.getLocationOfTip();this.wireSeg.existsInDesign()?this.wireSeg.getDistanceFrom(n)>1&&this.locate(n):this.wire.existsInDesign()?(this.wireSeg=this.wire.getClosestWireSegment(n),this.locate(n)):this.probe.getWavebox().detachProbe(this.probe,!1)}},i.prototype.hideBar=function(){this.design.getWireBar().hide()},i.prototype.getProbeObjectData=function(n){n.wireSegName=this.wireSeg?this.wireSeg.getUniqName():null},i.prototype.restore=function(n){this.probe.uniqName=n.uniqName;n.wireSegName?(this.wireSeg=this.design.findObjectByUniqName(n.wireSegName),this.wire=this.wireSeg.getWire()):(this.wireSeg=null,this.wire=null);var t=new BaseWire.Point(n.x,n.y);this.locate(t)},i.prototype.getClosestPoint=function(n){var t=this.probe.getLocationOfTip();return n.getClosest(t)},i.prototype.isTheSameType=function(n){return n?(n instanceof BaseWire.WireSegment)?!0:!1:!1},i.prototype.isTheSameProbeObject=function(n){return n?(n instanceof BaseWire.WireSegment)?this.wireSeg==n:!1:!1},i.prototype.switchFromProbe=function(t){var r=!1;return!t,t instanceof i?this.wireSeg&&this.wireSeg==t.wireSeg||(this.probe.getWavebox().notify(n.ChangeEvents.WIRE,this.probe.index),r=!0):(this.probe.getWavebox().notify(n.ChangeEvents.COMPONENT_TO_WIRE,this.probe.index),this.probe.getWavebox().notify(n.ChangeEvents.WIRE,this.probe.index),r=!0),r},i.prototype.needToChangeProbeObject=function(n){if(!n||!this.wireSeg)return!0;if(n instanceof BaseWire.WireSegment){var t=n;return this.wireSeg.getWire()!=t.getWire()?!0:this.wireSeg!=t?!0:!1}return!0},i.prototype.makePencilUniquelyVisible=function(){},i.prototype.makeAnotherPencilUniquelyVisible=function(){},i.prototype.isAttached=function(){return this.wireSeg!=null},i.prototype.getSaveData=function(){var t=this.probe.getLocationOfTip(),n=new ServerStructures.WireProbeState;return n.probeIndex=this.probe.index,n.uniqName=this.probe.uniqName,n.x=Math.round(t.x),n.y=Math.round(t.y),n.wireSegName=this.wireSeg?this.wireSeg.getUniqName():null,n},i}(n.ProbeObject);n.WireSegProbeObject=t}(ProbeModule||(ProbeModule={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r,u){t.call(this,n,i);this.component=null;this.init(r,u)}return __extends(i,t),i.prototype.init=function(n,t){var r,u,i,f;n?n instanceof Project.Component?(this.component=n,t instanceof BaseWire.Point?this.locate(t):(r=t,u=Project.Utility.eventToPoint(this.design,r),this.locate(u),this.plotData=!1)):(this.plotData=t,i=n,this.probe.uniqName=i.uniqName,i.compInstName&&(this.component=this.design.findCompByInstName(i.compInstName)),f=new BaseWire.Point(i.x,i.y),this.locate(f)):(this.plotData=!1,this.locate(t));this.component&&this.component.addProbe(this.probe)},i.prototype.locate=function(n){if(this.component){var t=this.component.getCenter();this.probe.moveTo(t.x,t.y);this.probe.toFront()}else this.probe.moveTo(n.x,n.y)},i.prototype.getProbeObjectName=function(){return this.component?this.component.getInstName().toLowerCase():null},i.prototype.removeFromProbeObject=function(){this.component&&this.component.removeProbe(this.probe);this.component=null;this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},i.prototype.updateConnection=function(){if(this.component){var n=this.probe.getLocationOfTip();this.component.existsInDesign()?this.component.getDistanceFrom(n)>1&&this.locate(n):this.probe.getWavebox().detachProbe(this.probe,!1)}},i.prototype.hideBar=function(){},i.prototype.getProbeObjectData=function(n){n.compInstName=this.component?this.component.getInstName():null},i.prototype.restore=function(n){this.component=n.compInstName?this.design.findCompByInstName(n.compInstName):null;var t=new BaseWire.Point(n.x,n.y);this.locate(t)},i.prototype.getClosestPoint=function(n){var i=this.probe.getLocationOfTip(),t=n.getCenter();return t.subtract(i),t},i.prototype.isTheSameType=function(n){return n?(n instanceof Project.Component)?!0:!1:!1},i.prototype.isTheSameProbeObject=function(n){return n?(n instanceof Project.Component)?this.component==n:!1:!1},i.prototype.switchFromProbe=function(t){var r=!1;return!t,t instanceof i?this.component&&this.component==t.component||(this.probe.getWavebox().notify(n.ChangeEvents.COMPONENT,this.probe.index),r=!0):(this.probe.getWavebox().notify(n.ChangeEvents.WIRE_TO_COMPONENT,this.probe.index),this.probe.getWavebox().notify(n.ChangeEvents.COMPONENT,this.probe.index),r=!0),r},i.prototype.needToChangeProbeObject=function(){return!0},i.prototype.prepareToChooseWaveform=function(n,t,i){var f=n,s=f.getCenter(),e=f.getInstName(),r=this.probe.getWavebox(),o=this.probe.getWavebox().getSimulationId(),u;o?(u=WaveViewer.getManager().getWaveformNodes(o,e),u==null||u.length==0?(r.updateTitle(!0),this.design.getUndoManager().finishUndoableCommand(r,"AddProbeCommand")):this.openWaveformDialog(s,e,t,i)):(r.updateTitle(!0),this.design.getUndoManager().finishUndoableCommand(r,"AddProbeCommand"))},i.prototype.makePencilUniquelyVisible=function(){this.component&&this.component.makePencilUniquelyVisible(this.probe)},i.prototype.makeAnotherPencilUniquelyVisible=function(){this.component&&this.component.makeAnotherPencilUniquelyVisible(this.probe)},i.prototype.isAttached=function(){return this.component!=null},i.prototype.getSaveData=function(){var t=this.probe.getLocationOfTip(),n=new ServerStructures.ComponentProbeState,i;return n.probeIndex=this.probe.index,n.uniqName=this.probe.uniqName,n.x=Math.round(t.x),n.y=Math.round(t.y),n.compInstName=this.component?this.component.getInstName():null,i=this.probe.getWavebox().getProbePlotState(this.probe.index),n.compWfName=i.getCompWfName(),n},i}(n.ProbeObject);n.ComponentProbeObject=t}(ProbeModule||(ProbeModule={})),function(n){var t=function(){function t(n,t,i){this.yRange=null;this.isViewAllForY=!0;this.showPoints=!1;this.color=null;this.transformName=WaveViewer.WaveManager.SCALAR_DBMAG;this.compWfName=null;this.probeIndex=-1;this.design=n;this.probe=t;this.probeIndex=t.index;this.sourceInfo=WaveViewer.SourceInfo.createSourceInfoForProbe(this.probeIndex,this.getContainerUniqName());this.waveBoxPlotState=i;this.waveBoxPlotState.addProbePlotState(this.probeIndex,this)}return t.prototype.getTransformName=function(){return this.transformName},t.prototype.setTransformName=function(n){return n?this.transformName!=n?(this.resetPlotInfo(!1),this.transformName=n,!0):!1:!1},t.prototype.setComponentWfName=function(n){return n?this.compWfName!=n?(this.resetPlotInfo(!1),this.compWfName=n,this.probe.getWavebox().markAsDirty(),!0):!0:!1},t.prototype.findComponentWaveformName=function(){var r="i",u=this.probe.getProbeObjectName(),t,i;if(!u)return r;var n=WaveViewer.getManager().getComponentInfoList(this.waveBoxPlotState.getSimulationId(),u),e=this.waveBoxPlotState.getSimulationType(!0),f=e==Project.SIMULATION_TYPE.FREQUENCY_DOMAIN;if(n&&n.length>0){for(t=0;t<n.length;t++)if(i=WaveViewer.WaveUtils.extractCompWfName(n[t].getSignalName(),f),i&&i==r)return i;return WaveViewer.WaveUtils.extractCompWfName(n[0].getSignalName(),f)}return""},t.prototype.getCompWfName=function(){return this.compWfName?this.compWfName:this.findComponentWaveformName()},t.prototype.getFullWaveformName=function(){return this.probe.probeObject instanceof n.ComponentProbeObject?this.createFullWaveformNameForComponent():this.createWaveformNameForWire()},t.prototype.createFullWaveformNameForComponent=function(){var t=this.probe.getProbeObjectName(),n,i;return t?(n=this.getCompWfName(),!n||n=="")?t:(i=this.waveBoxPlotState.getSimulationType(!0),i==Project.SIMULATION_TYPE.FREQUENCY_DOMAIN?t+PATH_SEPARATOR+n+PATH_SEPARATOR+this.getTransformName():t+PATH_SEPARATOR+n):null},t.prototype.createWaveformNameForWire=function(){var n=this.probe.getProbeObjectName(),t;return n?(t=this.waveBoxPlotState.getSimulationType(!0),t==Project.SIMULATION_TYPE.FREQUENCY_DOMAIN?n+PATH_SEPARATOR+this.getTransformName():n):null},t.prototype.getColor=function(){return this.color||(this.color=WaveViewer.SVW_Colors.getNewColor(this.probe.getWavebox().getWaveContainer())),this.color},t.prototype.getYVisibleRange=function(){return this.yRange},t.prototype.getViewAllForY=function(){return this.isViewAllForY},t.prototype.resetPlotInfo=function(){this.yRange=null;this.isViewAllForY=!0},t.prototype.notify=function(t,i,r){var u=!0;switch(t){case n.ChangeEvents.WIRE_TO_COMPONENT:this.resetPlotInfo(!1);this.compWfName=null;break;case n.ChangeEvents.COMPONENT_TO_WIRE:this.resetPlotInfo(!1);this.compWfName=null;break;case n.ChangeEvents.COMPONENT:this.resetPlotInfo(!1);this.compWfName=null;break;case n.ChangeEvents.WIRE:this.resetPlotInfo(!1);break;case n.ChangeEvents.TRANSFORMATION:u=this.setTransformName(i);break;case n.ChangeEvents.COMPONENT_WF_NAME:u=this.setComponentWfName(i);r.resetPlotState(!0,!0);break;case n.ChangeEvents.COLOR:this.color=i;break;case n.ChangeEvents.Y_ZOOM:this.setYZoom(i,r)}return u},t.prototype.setYZoom=function(n,t){this.yRange=n;this.isViewAllForY=t},t.prototype.setProbeAttributes=function(n){n instanceof ServerStructures.ComponentProbeState&&(this.compWfName=n.compWfName)},t.prototype.getContainerUniqName=function(){return this.probe.getWavebox()?this.probe.getWavebox().getUniqName():WaveViewer.SourceInfo.VIEWER_CONTAINER_NAME},t.prototype.setWaveformState=function(n){this.color=n.color;this.yRange=n.yAxis.range;this.isViewAllForY=n.yAxis.isViewAll;this.showPoints=n.showPoints;n instanceof ServerStructures.ProbeWaveformState&&(this.transformName=n.transformName,this.sourceInfo=WaveViewer.SourceInfo.createSourceInfoForProbe(this.probeIndex,this.getContainerUniqName()))},t.prototype.getWaveformState=function(){if(this.probe.isAttached()){var n=new ServerStructures.ProbeWaveformState;return n.color=this.getColor(),n.probeIndex=this.probe.index,n.showPoints=this.showPoints,n.transformName=this.transformName,n.yAxis=this.yRange?ServerStructures.YAxisState.createYAxisState(this.yRange,this.isViewAllForY,!0):ServerStructures.YAxisState.createYAxisState(null,!0,!0),n}return null},t.prototype.resetState=function(){this.yRange=WaveViewer.YWaveRange.getEmptyRange();this.isViewAllForY=!0;this.showPoints=!1},t.prototype.getWaveformDataRequestElemClient=function(n,t,i,r,u){var e=this.getFullWaveformName(),f=WaveViewer.getManager().getWaveformInfoFromCache(t,null,e,!0),o,s;return f?(o=f.getWaveformHandle()?f.getWaveformHandle():e,s=u?new WaveViewer.SourceInfo(this.sourceInfo.waveformState,u,!0):this.sourceInfo,WaveViewer.WaveUtils.createWaveformDataRequestElem(t,o,i,r,!0,f.wdbId,this.getColor(),WaveViewer.PAN_DIRECTION.NONE,WaveViewer.WaveUtils.isBus(f.getWaveformType()),n,s)):null},t.prototype.getWaveformType=function(n){var i=this.getFullWaveformName(),t=WaveViewer.getManager().getWaveformInfoFromCache(n,null,i,!1);return t?t.getWaveformType():WaveViewer.WaveManager.ANALOG_WF},t.prototype.getWfExpression=function(n){var i=this.getFullWaveformName(),t=WaveViewer.getManager().getWaveformInfoFromCache(n,null,i,!0),r;return t?(r=t.getWaveformHandle()?t.getWaveformHandle():i,"[["+n+"."+r+"]]"):null},t}();n.ProbePlotState=t}(ProbeModule||(ProbeModule={})),function(n){var t,f,i,r,u;(function(n){n[n.SINGLE_ROW=0]="SINGLE_ROW";n[n.SEPARATE_ROWS=1]="SEPARATE_ROWS";n[n.CALCULATOR=2]="CALCULATOR"})(n.PlotMode||(n.PlotMode={}));t=n.PlotMode;f=function(){function f(i,r){this.plotMode=t.SEPARATE_ROWS;this.simulationType=Project.SIMULATION_TYPE.NONE;this.xAxisState=new ServerStructures.XAxisState;this.cursorStates=[];this.simulationDescription=null;this.simulationId=null;this.probePlotStates=[];this.calcWfPlotStates=[];this.design=i;this.waveBox=r;this.calcWfPlotStates=[];this.calcWfPlotStates.push(new n.CalcWfPlotState(i,this,0,r));this.setSimulationTypeAndSimulationDescription(Project.SIMULATION_TYPE.NONE)}return f.prototype.getPlotMode=function(){return this.plotMode},f.prototype.addProbePlotState=function(n,t){this.probePlotStates[n]=t},f.prototype.getProbeColor=function(n){return this.probePlotStates[n].getColor()},f.prototype.getTitles=function(t,u){var l,s,b,h,a,v,k,f,y,p,e;u===void 0&&(u=-1);var o=[],w=this.getServerRows(),c=!0;for(f=0;f<w.length;f++)for(l=w[f],e=0;e<l.waveformStates.length;e++)s=l.waveformStates[e],s instanceof ServerStructures.ProbeWaveformState?(c=!0,b=u==s.probeIndex,h=new i(s.probeIndex,b),h.color=s.color,h.wfTitle=this.getProbePlotState(s.probeIndex).getFullWaveformName(),a=new r(!0),a.titles.push(h),o.push(a)):s instanceof ServerStructures.CalculatorWaveformState&&(c=!1,v=this.calcWfPlotStates[0].getTitleInfoBlock(u),v&&o.push(v));if(k=t&&this.waveBox.getWaveContainer().isEmpty()?n.WaveBox.NO_DATA:"",o.length>1&&c)for(f=0;f<o.length;f++)for(y=k,p=o[f],f!=o.length-1&&(y+="; "),e=0;e<p.titles.length;e++)p.titles[e].wfTitle+=y;return o},f.prototype.testAndSetPlotMode=function(n){var i;if(this.hasCalcWaveform()){if(!n)return;if(i=this.calcWfPlotStates[0].getOperationApplicability(this.calcWfPlotStates[0].getFunction(),this.getSimulationId()),i!=WaveViewer.CalculatorOperation.ALLOW){this.setPlotMode(t.SEPARATE_ROWS);return}}else this.getPlotMode()!=t.SEPARATE_ROWS&&(this.canPlotInSingleRow()||this.setPlotMode(t.SEPARATE_ROWS))},f.prototype.canPlotInSingleRow=function(){var u=this.getProbePlotState(0),f=this.getProbePlotState(1),n,t,i,r;return u&&f&&(n=WaveViewer.getManager().getWaveformInfoFromCache(this.getSimulationId(),null,u.getFullWaveformName(),!1),t=WaveViewer.getManager().getWaveformInfoFromCache(this.getSimulationId(),null,f.getFullWaveformName(),!1),n&&t)?(i=WaveViewer.WorkOptions.getWorkOptionsByType(n.getWaveformType()),r=WaveViewer.WorkOptions.getWorkOptionsByType(t.getWaveformType()),i.canPlotWithType(r.workType)&&r.canPlotWithType(i.workType)):!1},f.prototype.getServerRows=function(n){var e,u,o,i,s,h,c,f,r;if(n===void 0&&(n=!1),e=[],i=new ServerStructures.WaveboxRowState,i.waveformStates=[],n&&this.testAndSetPlotMode(!0),this.plotMode==t.SEPARATE_ROWS)for(u=0;u<this.waveBox.probes.length;u++)i=new ServerStructures.WaveboxRowState,i.waveformStates=[],o=this.waveBox.probes[u],o.isAttached()&&(f=this.getProbePlotState(o.index),r=f.getWaveformState(),r&&i.waveformStates.push(r)),i.waveformStates&&i.waveformStates.length>0&&e.push(i);else if(this.plotMode==t.SINGLE_ROW){for(i=new ServerStructures.WaveboxRowState,i.waveformStates=[],u=0;u<this.waveBox.probes.length;u++)o=this.waveBox.probes[u],o.isAttached()&&(f=this.getProbePlotState(o.index),r=f.getWaveformState(),r&&i.waveformStates.push(r));e.push(i)}else if(this.plotMode==t.CALCULATOR){if(i=new ServerStructures.WaveboxRowState,i.waveformStates=[],s=this.waveBox.probes[0],h=this.waveBox.probes[1],!s||!h)return e;s.isAttached()&&h.isAttached()?(c=this.calcWfPlotStates[0].getWaveformState(),c&&i.waveformStates.push(c)):s.isAttached()?(f=this.getProbePlotState(s.index),r=f.getWaveformState(),r&&i.waveformStates.push(r)):h.isAttached()&&(f=this.getProbePlotState(h.index),r=f.getWaveformState(),r&&i.waveformStates.push(r));e.push(i)}return e},f.prototype.setPlotMode=function(n){this.plotMode=n},f.prototype.getSimulationId=function(){return this.simulationId},f.prototype.getVisibleXRange=function(){return this.xAxisState.range},f.prototype.getViewAllForX=function(){return this.xAxisState.isViewAll},f.prototype.getCursorStates=function(){return this.cursorStates},f.prototype.getCompWfName=function(n){return this.getProbePlotState(n).getCompWfName()},f.prototype.getFunction=function(){return this.calcWfPlotStates[0].getFunction()},f.prototype.getCalculatorMenuItemName=function(n){return this.waveBox.hasDetachedProbe()?null:this.calcWfPlotStates[0].getWfNameWithFunction(n)},f.prototype.getCalculatorMenuItemBlock=function(n){return this.waveBox.hasDetachedProbe()?null:this.calcWfPlotStates[0].getCalculatorMenuItemBlock(n)},f.prototype.getOperationApplicability=function(n){return this.calcWfPlotStates[0]?this.calcWfPlotStates[0].getOperationApplicability(n.function,this.getSimulationId()):WaveViewer.CalculatorOperation.NOT_ALLOW},f.prototype.getSimulationType=function(n){if(!n||this.simulationType&&this.simulationType!=Project.SIMULATION_TYPE.NONE)return this.simulationType;if(this.simulationDescription)return this.simulationDescription.simulationType;var t=this.design.getLatestSimulation();return t?t.simulationType:Project.SIMULATION_TYPE.TIME_DOMAIN},f.prototype.getProbePlotState=function(n){return this.probePlotStates[n]},f.prototype.resetPlotInfo=function(n){n&&(this.xAxisState=ServerStructures.XAxisState.createXAxisState(null,null,!0))},f.prototype.resetCalcPlotInfo=function(){this.calcWfPlotStates&&this.calcWfPlotStates[0]&&this.calcWfPlotStates[0].resetPlotInfo()},f.prototype.resetPlotState=function(n,t){this.testAndSetPlotMode(t);n?this.resetPlotInfo(!1):(this.switchToDualTrace(),this.resetPlotInfo(!0));this.resetCalcPlotInfo()},f.prototype.prepareToNewSimulation=function(n){var t=!0,i=this.getSimulationType(!0);i!=Project.SIMULATION_TYPE.NONE&&i!=n&&(t=!1);this.resetPlotState(t,!1);this.simulationType=n},f.prototype.setSimulationTypeAndSimulationDescription=function(n){if(n==Project.SIMULATION_TYPE.NONE)this.simulationType=Project.SIMULATION_TYPE.NONE;else{var t=this.design.getLatestSimulationByType(n);t&&this.setSimulationDescription(t,!0)}},f.prototype.setSimulationDescription=function(n,t){if(n){if(t){var i=!0;return this.getSimulationType(!0)!=n.simulationType&&(i=!1),this.simulationDescription=n,this.simulationType=n.simulationType,this.simulationId=this.simulationDescription.simulationId,this.resetPlotState(i,!1),!0}if(this.simulationType==Project.SIMULATION_TYPE.NONE||n.simulationType==this.simulationType)return this.simulationId&&this.simulationId!=n.simulationId&&this.resetPlotInfo(!0),this.simulationDescription=n,this.simulationId=this.simulationDescription.simulationId,!0}return!1},f.prototype.isCorrectSimulationDescription=function(){return this.simulationDescription&&this.simulationDescription.simulationId},f.prototype.notify=function(i,r,u,f){var o=!0,e;switch(i){case n.ChangeEvents.WIRE_TO_COMPONENT:this.resetPlotState(!0,!1);break;case n.ChangeEvents.COMPONENT_TO_WIRE:this.resetPlotState(!0,!0);break;case n.ChangeEvents.COMPONENT:this.resetPlotState(!0,!1);break;case n.ChangeEvents.WIRE:this.resetPlotState(!0,!0);break;case n.ChangeEvents.SIMULATION_TYPE:this.setSimulationTypeAndSimulationDescription(u);break;case n.ChangeEvents.BEFORE_NEW_SIMULATION:this.prepareToNewSimulation(u);break;case n.ChangeEvents.SIMULATION_DESCRIPTION:o=this.setSimulationDescription(u,f);break;case n.ChangeEvents.COMPONENT_WF_NAME:f=this;break;case n.ChangeEvents.WAVEBOX_STATE:this.updateByWaveboxState();break;case n.ChangeEvents.PLOT_MODE:this.setPlotMode(u);break;case n.ChangeEvents.ZOOM:this.updateByZoomState();break;case n.ChangeEvents.CURSORS:this.setCursorStates(u);break;case n.ChangeEvents.CALCULATOR:this.setPlotMode(t.CALCULATOR);break;case n.ChangeEvents.DETACH:this.switchToDualTrace()}return WaveViewer.SourceInfo.isProbeIndex(r)&&(e=this.getProbePlotState(r),e&&e.notify(i,u,f)),this.calcWfPlotStates&&this.calcWfPlotStates[0]&&(i==n.ChangeEvents.COLOR?WaveViewer.SourceInfo.isProbeIndex(r)||this.calcWfPlotStates[0].notify(i,u,f):this.calcWfPlotStates[0].notify(i,u,f)),o},f.prototype.switchToDualTrace=function(){this.plotMode==t.CALCULATOR&&this.setPlotMode(t.SEPARATE_ROWS)},f.prototype.setPlotModeByState=function(n){var r=n.rowStates,i,u;return!r||r.length==0?t.SEPARATE_ROWS:r.length>1?t.SEPARATE_ROWS:(i=r[0].waveformStates,!i||i.length==0)?t.SEPARATE_ROWS:i.length>1?t.SINGLE_ROW:(u=i[0],u?u instanceof ServerStructures.ProbeWaveformState?t.SEPARATE_ROWS:u instanceof ServerStructures.CalculatorWaveformState?t.CALCULATOR:t.SEPARATE_ROWS:t.SEPARATE_ROWS)},f.prototype.setState=function(n){var e,t,f,u,i,o,r;for(this.cursorStates=n.cursorStates,this.xAxisState=ServerStructures.XAxisState.createXAxisState(n.xAxis.range,n.xAxis.isViewAll),this.simulationType=n.simulationType,t=0;t<n.probeStates.length;t++)e=n.probeStates[t],r=this.getProbePlotState(t),r.setProbeAttributes(e);for(this.setPlotMode(this.setPlotModeByState(n)),t=0;t<n.rowStates.length;t++)for(f=n.rowStates[t],u=0;u<f.waveformStates.length;u++)i=f.waveformStates[u],i instanceof ServerStructures.ProbeWaveformState&&(o=i.probeIndex,r=this.getProbePlotState(o),r.setWaveformState(i)),i instanceof ServerStructures.CalculatorWaveformState&&this.calcWfPlotStates[0].setWaveformState(i)},f.prototype.updateByWaveboxState=function(){var t=this.waveBox.getWaveContainerState(),n;this.cursorStates=t.cursorStates;n=t.getXVisibleState();this.xAxisState=ServerStructures.XAxisState.createXAxisState(n.range,n.isViewAll)},f.prototype.updateByZoomState=function(){var s=this.waveBox.getWaveContainerState(),h=s.getXVisibleState(),f,t,c,e,i,r,u,o;for(this.xAxisState=ServerStructures.XAxisState.createXAxisState(h.range,h.isViewAll),f=s.getRowStates(),t=0;t<f.length;t++)for(c=f[t],e=c.getWaveformStates(),i=0;i<e.length;i++)r=e[i],u=r.getSourceInfo(),u&&u.forProbe&&(o=u.objectIndex,o>=0&&this.getProbePlotState(o).notify(n.ChangeEvents.Y_ZOOM,r.yVisibleRange,r.isViewAllForY))},f.prototype.setCursorStates=function(n){this.cursorStates=n},f.prototype.resetState=function(){this.cursorStates=[];this.xAxisState=ServerStructures.XAxisState.createXAxisState(null,!0,!0);for(var n=0;n<this.probePlotStates.length;n++)this.probePlotStates[n].resetState()},f.prototype.getContainerRequest=function(n,t){for(var f,e,r=new ServerStructures.ContainerDataRequest(n),u=this.getServerRows(),o=WaveViewer.WaveUtils.getRequestRange(this.xAxisState,this.xAxisState.isViewAll),i=0;i<u.length;i++)f=u[i],e=this.getRowRequest(i,f,o,t),r.putRowRequest(e);return r},f.prototype.getYAxisStates=function(){for(var r,t=[],i=this.getServerRows(),n=0;n<i.length;n++)r=i[n],this.fillYAxisStatesForRow(n,r,t);return t},f.prototype.getPlotInfo=function(n,t){var i=new u;return t||(t=this.waveBox.getUniqName()),i.containerRequest=this.getContainerRequest(n,t),i.yAxisStates=this.getYAxisStates(),i.xAxisState=WaveViewer.WaveUtils.getRequestRange(this.xAxisState,this.xAxisState.isViewAll),i.cursorStates=this.cursorStates,i},f.prototype.addExpressionRequestElement=function(n){this.hasCalcWaveform()&&this.calcWfPlotStates[0].addExpressionRequestElement(this.getSimulationId(),n)},f.prototype.setCalcWfCredentials=function(n){this.calcWfPlotStates[0]&&n&&this.calcWfPlotStates[0].setCalcWfCredentials(n)},f.prototype.getRowRequest=function(n,t,i,r){for(var e,a,s,h,f,o=new ServerStructures.RowDataRequest(n),c=i.range.xmin,l=i.range.xmax,u=0;u<t.waveformStates.length;u++)e=t.waveformStates[u],e instanceof ServerStructures.ProbeWaveformState?(a=e.probeIndex,s=this.getProbePlotState(a),s&&(f=s.getWaveformDataRequestElemClient(u,this.simulationId,c,l,r),o.putWaveformElement(f))):e instanceof ServerStructures.CalculatorWaveformState&&(h=this.calcWfPlotStates[0],h&&(f=h.getWaveformDataRequestElemClient(u,this.simulationId,c,l,r),f&&o.putWaveformElement(f)));return o},f.prototype.hasCalcWaveform=function(){return this.plotMode==t.CALCULATOR},f.prototype.fillYAxisStatesForRow=function(n,t,i){var u,f,h,e,s,r,o;for(i[n]=[],u=0;u<t.waveformStates.length;u++)f=t.waveformStates[u],f instanceof ServerStructures.ProbeWaveformState?(h=f.probeIndex,e=this.getProbePlotState(h),e&&(r=e.getYVisibleRange(),r&&(o=ServerStructures.YAxisState.createYAxisState(r,e.getViewAllForY(),!0),i[n].push(o)))):f instanceof ServerStructures.CalculatorWaveformState&&(s=this.calcWfPlotStates[0],s&&(r=s.getYVisibleRange(),r&&(o=ServerStructures.YAxisState.createYAxisState(r,s.getViewAllForY(),!0),i[n].push(o))))},f.prototype.getProbesColors=function(){for(var i,t=[],n=0;n<this.probePlotStates.length;n++)i=this.probePlotStates[n],t.push(i.getColor());return t},f}();n.WaveBoxPlotState=f;i=function(){function n(n,t){this.shade=!1;this.probeIndex=-1;this.shade=t;this.probeIndex=n}return n.SIGN_INDEX=100,n}();n.TitleInfo=i;r=function(){function n(n){this.titles=[];this.forProbe=!0;this.forProbe=n}return n}();n.TitleInfoBlock=r;u=function(){function n(){this.yAxisStates=[];this.cursorStates=[]}return n.prototype.getYAxisStates=function(n){return this.yAxisStates.length==0?null:this.yAxisStates[n]&&this.yAxisStates[n].length==0?null:this.yAxisStates[n]},n}();n.WaveboxPlotInfo=u}(ProbeModule||(ProbeModule={})),function(n){var t=function(){function t(n,t,i,r){this.yRange=null;this.isViewAllForY=!0;this.showPoints=!1;this.color=null;this.wfIndex=-1;this.probeIndices=[];this.function=ServerStructures.CalculatorFunction.ADD;this.design=n;this.waveBox=r;this.wfIndex=i;this.sourceInfo=WaveViewer.SourceInfo.createSourceInfoForCalcWf(i,this.getContainerUniqName(),this.probeIndices);this.waveBoxPlotState=t;this.initState()}return t.prototype.initState=function(){var t,n;for(this.probeIndices=[],t=2,n=0;n<t;n++)this.probeIndices.push(n);this.resetPlotInfo()},t.prototype.setWaveformState=function(n){var t=n.color?n.color:this.getColor();this.color=t;this.function=n.function;this.probeIndices=n.probeIndices;this.showPoints=n.showPoints;this.yRange=n.yAxis.range;this.isViewAllForY=n.yAxis.isViewAll;this.resultId=n.resultId;this.handle=n.handle},t.prototype.addExpressionRequestElement=function(n,t){var i,f,u,h;if(!this.resultId||!this.handle){i=new ServerStructures.ExpressionRequestElemClient;i.divisions=WaveViewer.ViewerRequests.getNumDivsForRequest(!1);i.xmin=null;i.xmax=null;i.name=this.getWfNameWithFunction(this.function);f=WaveViewer.WdbInfo.getExpressionWdbId();i.wdbId=f;i.containerUniqName=this.getContainerUniqName();var e=this.waveBoxPlotState,o=e.getProbePlotState(0).getWfExpression(n),s=e.getProbePlotState(1).getWfExpression(n),r=WaveViewer.CalculatorOperation.getOperation(this.function);r&&(u=r.sign,h=r.directOrder?o+u+s:s+u+o,i.expression=h,t.ExprRequests.push(i))}},t.prototype.setCalcWfCredentials=function(n){this.resultId=n.resultId;this.handle=n.handle},t.prototype.clearCalcWfCredentials=function(){this.resultId=null;this.handle=null},t.prototype.getFullWaveformName=function(){return this.getWfNameWithFunction(this.function)},t.prototype.getWfNameWithFunction=function(n){var r="",u=WaveViewer.CalculatorOperation.getOperation(n),f=" "+u.sign+" ",t,i;if(this.probeIndices){if(u.directOrder)for(t=0;t<this.probeIndices.length;t++)i=t==0?"":f,r+=i+this.waveBoxPlotState.getProbePlotState(t).getFullWaveformName();else for(t=this.probeIndices.length-1;t>=0;t--)i=t==this.probeIndices.length-1?"":f,r+=i+this.waveBoxPlotState.getProbePlotState(t).getFullWaveformName();return r}return null},t.prototype.getCalculatorMenuItemBlock=function(n){var f=WaveViewer.CalculatorOperation.getOperation(n),e=" "+f.sign+" ",i,t,r,u;if(this.probeIndices)if(i=new SVWebContextMenu.ColoredBlock,f.directOrder)for(t=0;t<this.probeIndices.length;t++)t!=0&&(r=new SVWebContextMenu.ColoredElement(e,WaveViewer.SVW_Colors.SIGN_COLOR,!0),i.items.push(r)),u=this.createColoredElement(t),i.items.push(u);else for(t=this.probeIndices.length-1;t>=0;t--)t!=this.probeIndices.length-1&&(r=new SVWebContextMenu.ColoredElement(e,WaveViewer.SVW_Colors.SIGN_COLOR,!0),i.items.push(r)),u=this.createColoredElement(t),i.items.push(u);return i},t.prototype.createColoredElement=function(n){var t=this.waveBoxPlotState.getProbePlotState(n),i=WaveViewer.WaveUtils.limitNameForMenu(t.getFullWaveformName()),r=t.getColor();return new SVWebContextMenu.ColoredElement(i,r)},t.prototype.getColor=function(){if(!this.color){var n=this.waveBoxPlotState.getProbesColors();this.color=WaveViewer.SVW_Colors.getDifferentColor(this.waveBox.getWaveContainer(),n)}return this.color},t.prototype.getYVisibleRange=function(){return this.yRange},t.prototype.getViewAllForY=function(){return this.isViewAllForY},t.prototype.resetPlotInfo=function(){this.yRange=null;this.isViewAllForY=!0;this.showPoints=!1;this.clearCalcWfCredentials()},t.prototype.notify=function(t,i,r){switch(t){case n.ChangeEvents.WIRE_TO_COMPONENT:this.resetPlotInfo();break;case n.ChangeEvents.COMPONENT_TO_WIRE:this.resetPlotInfo();break;case n.ChangeEvents.COMPONENT:this.resetPlotInfo();break;case n.ChangeEvents.WIRE:this.resetPlotInfo();break;case n.ChangeEvents.COLOR:this.color=i;break;case n.ChangeEvents.Y_ZOOM:this.setYZoom(i,r);break;case n.ChangeEvents.CALCULATOR:this.setFunction(i)}return!0},t.prototype.setYZoom=function(n,t){this.yRange=n;this.isViewAllForY=t},t.prototype.getContainerUniqName=function(){return this.waveBox?this.waveBox.getUniqName():WaveViewer.SourceInfo.VIEWER_CONTAINER_NAME},t.prototype.setFunction=function(n){this.function!=n&&this.clearCalcWfCredentials();this.function=n},t.prototype.getFunction=function(){return this.function},t.prototype.getTitleInfoBlock=function(t){var i,r,e;t===void 0&&(t=-1);var f=!0,u=new n.TitleInfoBlock(!1),o=WaveViewer.CalculatorOperation.getOperation(this.function),s=o.sign;if(o.directOrder)for(i=0;i<this.probeIndices.length;i++)r=this.probeIndices[i],e=t==r,f?f=!1:u.titles.push(this.createSignTitleInfo(s)),u.titles.push(this.createTitleInfo(r,e,!1));else for(i=this.probeIndices.length-1;i>=0;i--)r=this.probeIndices[i],e=t==r,f?f=!1:u.titles.push(this.createSignTitleInfo(s)),u.titles.push(this.createTitleInfo(r,e,!1));return u},t.prototype.createTitleInfo=function(t,i,r){var f=this.waveBoxPlotState.getProbePlotState(t),u=new n.TitleInfo(t,i);return u.color=f.getColor(),u.wfTitle=f.getFullWaveformName(),r&&(u.wfTitle+=";"),u},t.prototype.createSignTitleInfo=function(t){var i=new n.TitleInfo(n.TitleInfo.SIGN_INDEX,!1);return i.color=WaveViewer.SVW_Colors.SIGN_COLOR,i.wfTitle=t,i},t.prototype.getWaveformState=function(){var n=new ServerStructures.CalculatorWaveformState;return n.color=this.getColor(),n.probeIndices=this.probeIndices,n.showPoints=this.showPoints,n.function=this.function,n.yAxis=this.yRange?ServerStructures.YAxisState.createYAxisState(this.yRange,this.isViewAllForY,!0):ServerStructures.YAxisState.createYAxisState(null,!0,!0),n.resultId=this.resultId,n.handle=this.handle,n},t.prototype.getWaveformDataRequestElemClient=function(n,t,i,r,u){var o=this.getFullWaveformName(),e,f;return(e=u?new WaveViewer.SourceInfo(this.sourceInfo.waveformState,u,!1):this.sourceInfo,f=this.getWfInfo(),!f)?null:WaveViewer.WaveUtils.createWaveformDataRequestElem(f.getSimulationId(),f.getWaveformHandle(),i,r,!0,f.wdbId,this.getColor(),WaveViewer.PAN_DIRECTION.NONE,WaveViewer.WaveUtils.isBus(f.getWaveformType()),n,e)},t.prototype.getWfInfo=function(){var n,t;return this.resultId&&this.handle?(n=WaveViewer.getManager().getWaveformInfoFromCache(this.resultId,this.handle,null,!1),n||(t=WaveViewer.WdbInfo.getExpressionWdbId(),n=new WaveViewer.WaveformInfo(this.resultId,t),n.setExpressionPreMetadata(this.getWfNameWithFunction(this.function),this.handle,WaveViewer.WaveManager.ANALOG_WF,this.resultId),WaveViewer.getManager().putWaveformInfoToCache(n)),n):null},t.prototype.getOperationApplicability=function(n,t){return t?this.canApplyMathOperations()?n==ServerStructures.CalculatorFunction.MULTIPLY?WaveViewer.CalculatorOperation.ALLOW:n==ServerStructures.CalculatorFunction.ADD||n==ServerStructures.CalculatorFunction.SUBTRACT||n==ServerStructures.CalculatorFunction.SUBTRACT_OPPOSITE?WaveViewer.CalculatorOperation.ALLOW:n==ServerStructures.CalculatorFunction.DIVIDE||n==ServerStructures.CalculatorFunction.DIVIDE_OPPOSITE?this.canDivide(n):WaveViewer.CalculatorOperation.NOT_ALLOW:WaveViewer.CalculatorOperation.NOT_ALLOW:WaveViewer.CalculatorOperation.ALLOW},t.prototype.canDivideSingle=function(n){return n.canDivide()?WaveViewer.CalculatorOperation.ALLOW:"Invalid operation - denominator waveform contains only zero values"},t.prototype.canApplyMathOperations=function(){var u=this.waveBoxPlotState.getProbePlotState(0),f=this.waveBoxPlotState.getProbePlotState(1),n,t,i,r;return u&&f&&(n=WaveViewer.getManager().getWaveformInfoFromCache(this.waveBoxPlotState.getSimulationId(),null,u.getFullWaveformName(),!1),t=WaveViewer.getManager().getWaveformInfoFromCache(this.waveBoxPlotState.getSimulationId(),null,f.getFullWaveformName(),!1),n&&t)?(i=WaveViewer.WorkOptions.getWorkOptionsByType(n.getWaveformType()),r=WaveViewer.WorkOptions.getWorkOptionsByType(t.getWaveformType()),i.canApplyMathOperations(r)&&r.canApplyMathOperations(i)):!0},t.prototype.canDivide=function(n){var t,i,r,u;if(n!=ServerStructures.CalculatorFunction.DIVIDE&&n!=ServerStructures.CalculatorFunction.DIVIDE_OPPOSITE)return WaveViewer.CalculatorOperation.ALLOW;if(t=this.waveBoxPlotState.getProbePlotState(0),i=this.waveBoxPlotState.getProbePlotState(1),t&&i&&(r=WaveViewer.getManager().getWaveformInfoFromCache(this.waveBoxPlotState.getSimulationId(),null,t.getFullWaveformName(),!1),u=WaveViewer.getManager().getWaveformInfoFromCache(this.waveBoxPlotState.getSimulationId(),null,i.getFullWaveformName(),!1),r&&u)){if(n==ServerStructures.CalculatorFunction.DIVIDE)return this.canDivideSingle(u);if(n==ServerStructures.CalculatorFunction.DIVIDE_OPPOSITE)return this.canDivideSingle(r)}return WaveViewer.CalculatorOperation.ALLOW},t}();n.CalcWfPlotState=t}(ProbeModule||(ProbeModule={})),function(n){var t=function(){function t(t,i,r,u){var f,c,o,a,l,s,e,h;this.path=null;this.path_anim=null;this.wireMgr=null;this.conn1Pin=null;this.conn1Wire=null;this.typeBus=!1;this.technology=Project.TECHNOLOGY.ELEC;this.connDot=null;this.gotMovement=!1;this.ignoreMovement=!1;this.firstSegmentCommitted=!1;this.design=t;this.paper=this.design.getPaper();this.canvas=this.paper.canvas;this.wireMgr=this.design.getWireMgr();this.wireMgr.setWireMode(this);r==null||(r instanceof n.WireSegment?(f=r,this.typeBus=f.isBus(),this.conn1Wire=f,c=Project.Utility.eventToPoint(t,i),e=f.getClosestToGrid(c,Project.Settings.SCH_GRID_SPACING),this.technology=this.conn1Wire.getTechnology(),o=-1,a=!1,f.getEndLocation(1).isEqual(e)?o=1:f.getEndLocation(2).isEqual(e)&&(o=2),o>0?(l=o==1?2:1,s=f.getQuadrant(l)):s=f.getOrient()==n.ORIENTATION.VERTICAL?n.QUADRANT.SOUTH:n.QUADRANT.WEST,this.activeSegs=new n.RightAnglePair(e,e,s),this.wireMgr.setStartConn(this.conn1Wire),this.wireMgr.setWire(this.conn1Wire.getWire()),this.typeBus||this.createConnectionDot(f,e)):u instanceof Project.Pin&&(this.conn1Pin=u,this.conn1Pin.isVector()&&(this.typeBus=!0),this.technology=this.conn1Pin.getTechnology(),s=this.conn1Pin.getQuadrant(),e=this.conn1Pin.getLocation(),this.activeSegs=new n.RightAnglePair(e,e,s),this.wireMgr.setStartConn(this.conn1Pin),h=null,this.conn1Pin.getConnection()&&(h=this.conn1Pin.getConnection().getWire()),h==null&&(h=new n.Wire(this.design,this.conn1Pin)),this.wireMgr.setWire(h)));this.defineEvents()}return t.prototype.getRightAnglePair=function(){return this.activeSegs},t.prototype.defineEvents=function(){var t=this,i=!1,r=!1;this.design.getWireBar().disable();this.design.getSymbolBar().disable();$(this.canvas).bind("mousemove.wiringEvents",function(n){t.ignoreMovement||(t.updateSegment(n),t.gotMovement=!0)});$(this.canvas).bind("mousedown.wiringEvents",function(u){if(t.gotMovement&&(u.which==1||u.which==3)){if(r=!1,t.activeSegs.isZeroLength(Project.Settings.SCH_GRID_SPACING)){if(t.firstSegmentCommitted){t.eventsComplete();t.wireMgr.cancelWiring();return}r=!0}if(i||u.which==3)i=!1,r?(t.eventsComplete(),t.wireMgr.cancelWiring()):t.wireMgr.inWireMode()&&t.terminateWire(u,null);else{if(i=!0,!r){var f=t.wireMgr.getConnectionType(u);f==n.CONNECTION_TYPE.LEGAL?t.terminateWire(u,t.wireMgr.getConnectObj()):f==n.CONNECTION_TYPE.NONE&&(t.startUndoableCommand(),t.commitSegment(u),t.finishUndoableCommand(t.wireMgr.getWire()))}window.setTimeout(function(){i=!1},DOUBLE_CLICK_SPEED)}}});$(document).bind("keydown.wiringEvents",function(n){n.which==Project.Design.EscKey&&(t.eventsComplete(),t.wireMgr.cancelWiring())});$(this.canvas).bind("mouseup.wiringEvents",function(i){if(WaveViewer.SVWEventHandler.setIsMoving(null),t.gotMovement){var r=t.wireMgr.getConnectionType(i);r==n.CONNECTION_TYPE.LEGAL&&t.terminateWire(i,t.wireMgr.getConnectObj())}})},t.prototype.eventsComplete=function(){this.deleteActiveSegs();$(this.canvas).unbind(".wiringEvents");$(document).unbind(".wiringEvents");this.design.getWireBar().enable();this.design.getSymbolBar().enable();WaveViewer.SVWEventHandler.setIsMoving(null)},t.prototype.updateSegment=function(n){var t,i;n&&(t=Project.Utility.eventToPoint(this.design,n),this.activeSegs.changeEndPoint(t),this.activeSegs.isZeroLength(0)||(i=this.activeSegs.toPath(),this.drawActiveSegs(i)))},t.prototype.drawActiveSegs=function(n){this.path==null?(this.path=this.paper.path(n),this.setActiveSegAttr(this.path),this.design.unconnectedPinsToFront()):this.path.attr({path:n})},t.prototype.setActiveSegAttr=function(n){n.node.setAttribute("class",this.getClass())},t.prototype.deleteActiveSegs=function(){this.path&&(this.path.remove(),this.path=null);this.path_anim&&(this.path_anim.remove(),this.path_anim=null);this.connDot&&(this.connDot.remove(),this.connDot=null)},t.prototype.getClass=function(){return this.design.getCssClassMgr().getActiveWireSegmentClass(this.technology,this.typeBus)},t.prototype.commitSegment=function(n){var t=this,r=this.activeSegs.getSeg2(),u,i,f,e;(this.activeSegs.placeSeg1OnGrid(Project.Settings.SCH_GRID_SPACING),u=this.activeSegs.getSeg2(),i=this.activeSegs.removeSeg1(),this.connDot&&(this.connDot.remove(),this.connDot=null),i&&!i.isZeroLength())&&(this.startUndoableCommand(),this.createWireSegment(i),this.firstSegmentCommitted=!0,this.activeSegs.isZeroLength(0)||(f=r.toPath(),e=r.point1.getTransform(u.point1),this.deleteActiveSegs(),this.path_anim=this.paper.path(f),this.setActiveSegAttr(this.path_anim),this.ignoreMovement=!0,this.path_anim.animate({transform:e},300,"linear",function(){t.path_anim&&(t.path_anim.remove(),t.path_anim=null,t.updateSegment(n),t.ignoreMovement=!1)})))},t.prototype.commitLastSegments=function(n){var t,i,r;(this.activeSegs.changeEndPoint(n),t=this.activeSegs.numSegs(),t!=0)&&(this.design.getUndoManager().startUndoableCommand(Project.AddWireSegmentCommand,this.design,this.wireMgr.getWire()),i=this.activeSegs.getSeg1(),this.createWireSegment(i),t==2&&(r=this.activeSegs.getSeg2(),this.createWireSegment(r)))},t.prototype.terminateWire=function(t,i){var f,u,o,s,h,e,r,c;i||(f=this.wireMgr.getConnectionType(t),f==n.CONNECTION_TYPE.LEGAL&&(i=this.wireMgr.getConnectObj()));i?(u=null,i instanceof n.WireSegment?(o=i,s=Project.Utility.eventToPoint(this.design,t),u=o.getClosestToGrid(s,Project.Settings.SCH_GRID_SPACING),this.commitLastSegments(u),h=i,r=h.getWire(),this.design.getUndoManager().addToStartState(r),r.merge(this.wireMgr.getWire()),this.wireMgr.setWire(r)):i instanceof Project.Pin&&(e=i,u=e.getLocation(),this.commitLastSegments(u),e.getConnection()&&(r=e.getConnection().getWire(),r!=null&&(r.merge(this.wireMgr.getWire()),this.wireMgr.setWire(r))))):f!=n.CONNECTION_TYPE.ILLEGAL&&(this.commitSegment(t),this.commitSegment(t));this.eventsComplete();f==n.CONNECTION_TYPE.ILLEGAL?(this.wireMgr.cancelWiring(),this.design.getUndoManager().clearActiveCommand()):(c=this.wireMgr.getWire(),this.wireMgr.terminateWiring(t,i),this.finishUndoableCommand(c))},t.prototype.createWireSegment=function(t){var i=new n.WireSegment(this.design,t,this.typeBus,this.technology);this.wireMgr.getWire().addWireSegment(i);this.wireMgr.updateWireSegEnds(i)},t.prototype.createConnectionDot=function(t,i){for(var u,r=1;r<=2;++r)if(t.getEndLocation(r).isAlmostEqual(i)&&(u=t.getConnection(r),!u||u.getNumConnections()<2))return;this.connDot=new n.ConnectionDot(this.design,i,this.technology)},t.prototype.startUndoableCommand=function(){var n=this.design.getUndoManager(),t;n.getActiveCommand()||(this.conn1Wire?n.startUndoableCommand(Project.AddWireSegmentCommand,this.design,this.conn1Wire.getWire()):(t=this.wireMgr.getWire(),t&&t.getNumSegments()>0?n.startUndoableCommand(Project.AddWireSegmentCommand,this.design,t):this.conn1Pin&&n.startUndoableCommand(Project.AddNetCommand,this.design,null)))},t.prototype.finishUndoableCommand=function(n){var t=this.design.getUndoManager();t.getActiveCommand()&&t.finishUndoableCommand(n)},t}();n.WireActiveSegments=t}(BaseWire||(BaseWire={})),function(n){var t=function(){function t(t,i){this.wireDragSet=null;var u=i.getConnection(),r=[];r.push(i);this.wireDragSet=new n.WireDragSet(t,r,u)}return t.prototype.drag=function(n,t){this.wireDragSet.drag(n,t)},t.prototype.finalize=function(n,t){return this.wireDragSet.finalize(n,t)},t.prototype.finishAnimation=function(){this.wireDragSet.finishAnimation()},t}();n.WireDragPin=t}(BaseWire||(BaseWire={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(){function t(n,t,i){this.design=n;this.wireSeg=t;this.end=i;this.orient=this.wireSeg.getOrient();this.conn=this.wireSeg.getConnection(this.end);this.startPt=this.wireSeg.getEndLocation(this.end)}return t.prototype.drag=function(){},t.prototype.finalize=function(){},t.prototype.addToWire=function(n){var t=this.wireSeg.getWire();t&&t.addWireSegment(n)},t.getWireSegmentInQuadrant=function(n,t){for(var r,u,i=0;i<n.getNumConnectedWireSegments();++i)if((r=n.getWireSegment(i),u=n.getWireSegmentEnd(i),!r.isZeroLength())&&r.getQuadrant(u)==t)return new e(r,u);return null},t.getOppEndConnection=function(n,t){var i=t==1?2:1;return n.getConnection(i)},t.prototype.getOrthogonalWireSegmentList=function(t){var i,r;return i=this.orient==n.ORIENTATION.VERTICAL?t==1?n.QUADRANT.WEST:n.QUADRANT.EAST:t==1?n.QUADRANT.NORTH:n.QUADRANT.SOUTH,r=this.conn,this.getWireSegmentList(r,i)},t.prototype.getInlineWireSegmentList=function(n,t){var r=n.getEndLocation(t),i=t==1?2:1,u=n.getEndLocation(i),f=r.quadrant(u),e=n.getConnection(i);return this.getWireSegmentList(e,f)},t.prototype.getWireSegmentList=function(n,i){for(var u=[],r,f,e;n;)r=t.getWireSegmentInQuadrant(n,i),r?(u.push(r),f=r.wireSeg,e=r.end,n=t.getOppEndConnection(f,e)):n=null;return u},t.getEndPoint=function(n){var t=n.length;if(t==0)return null;var i=n[t-1],r=i.wireSeg,u=i.end,f=u==1?2:1;return r.getEndLocation(f)},t.isEndPointConnected=function(n){var t=n.length;if(t>0){var i=n[t-1],u=i.wireSeg,f=i.end,e=f==1?2:1,r=u.getConnection(e);if(r&&r.getNumConnections()>1)return!0}return!1},t.prototype.wireEndConn=function(t,i){for(var u,r=1;r<=2;++r)if(t.getEndLocation(r).isAlmostEqual(i))return u=t.getConnection(r),u||(u=new n.Connection(this.design),u.connectToWireSegment(t,r)),u;return null},t.prototype.findWireSegment=function(n,t){for(var u,r,i=0;i<n.length;++i)if(u=n[i],r=u.wireSeg,r.getSegment().contains(t))return r;return null},t.prototype.connectToWireSegment=function(t,i){var u=this.wireEndConn(t,i),r;u?u.connectToWireSegment(this.wireSeg,this.end):(r=new n.Connection(this.design),r.connectToWireSegment(this.wireSeg,this.end),t.split(r))},t}(),i,u,r,f,o,e;n.DragConnection=t;i=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.DragNoConnection=i;u=function(i){function r(r,u,f){var e,o;i.call(this,r,u,f);this.wsaeList=[];this.inlineStartPt=null;this.inlineEndPt=null;this.inlineEndHasConn=!1;this.connDot=null;this.seg1=null;this.region=0;this.connDotToHide=null;this.connWireSeg=this.conn.getOtherWireSegment(this.wireSeg);this.connEnd=this.connWireSeg.getEnd(this.conn);this.wsaeList=this.getInlineWireSegmentList(this.connWireSeg,this.connEnd);this.wsaeList.length>0&&(e=this.connEnd==1?2:1,this.inlineStartPt=this.connWireSeg.getEndLocation(e),this.inlineEndPt=t.getEndPoint(this.wsaeList),this.inlineEndHasConn=t.isEndPointConnected(this.wsaeList),u.isBus()||(this.connDot=new n.ConnectionDot(this.design,this.inlineStartPt,u.getTechnology()),this.connDot.hide()),this.seg1=new n.Segment(this.inlineStartPt,this.inlineEndPt),o=this.connWireSeg.getConnection(e),o.getNumConnections()<4&&!u.isBus()&&(this.connDotToHide=o))}return __extends(r,i),r.prototype.drag=function(){var n=this.wireSeg.getEndLocation(this.end);this.region=this.getRegion(n);this.region==0?(this.connDot&&this.connDot.hide(),this.connDotToHide&&this.connDotToHide.showConnectionDot()):(this.connDotToHide&&this.connDotToHide.hideConnectionDot(),this.region==1?this.connDot&&(this.connDot.moveTo(n),this.connDot.show()):this.inlineEndHasConn?this.connDot&&(this.connDot.moveTo(this.inlineEndPt),this.connDot.show()):this.connDot&&this.connDot.hide());this.connWireSeg.moveEndTo(n,this.connEnd);return},r.prototype.finalize=function(){var r,t,i,n,u;if(this.connDot&&this.connDot.remove(),this.connDotToHide&&this.connDotToHide.showConnectionDot(),this.design.getConnMgr().manage(this.conn),this.connWireSeg.isZeroLength())n=this.connEnd==1?2:1,r=this.connWireSeg.getConnection(n),this.design.getConnMgr().manage(r);else if(this.region==1)this.conn.disconnectWireSegment(this.wireSeg,this.end),t=this.wireSeg.getEndLocation(this.end),i=this.findWireSegment(this.wsaeList,t),this.connectToWireSegment(i,t),this.connWireSeg.remove();else if(this.region==2){n=this.connEnd==1?2:1;u=this.connWireSeg.getConnection(n);u.disconnectWireSegment(this.connWireSeg,n);this.connWireSeg.moveEndTo(this.inlineEndPt,n);var f=this.wsaeList.length,e=this.wsaeList[f-1],i=e.wireSeg,o=this.wireEndConn(i,this.inlineEndPt);o.connectToWireSegment(this.connWireSeg,n)}return},r.prototype.getRegion=function(t){return this.inlineStartPt==null?0:this.seg1.contains(t)?1:this.seg1.getOrient()==n.ORIENTATION.VERTICAL?t.y>this.inlineStartPt.y&&this.startPt.y>this.inlineStartPt.y||t.y<this.inlineStartPt.y&&this.startPt.y<this.inlineStartPt.y?0:2:t.x>this.inlineStartPt.x&&this.startPt.x>this.inlineStartPt.x||t.x<this.inlineStartPt.x&&this.startPt.x<this.inlineStartPt.x?0:2},r}(t);n.DragWireSegConnection=u;r=function(t){function i(i,r,u){t.call(this,i,r,u);var f=this.wireSeg.getEndLocation(this.end),e=new n.Segment(f,f);this.newWireSeg=new n.WireSegment(this.design,e,this.wireSeg.isBus(),this.wireSeg.getTechnology())}return __extends(i,t),i.prototype.drag=function(){var n=this.wireSeg.getEndLocation(this.end);this.newWireSeg.moveEndTo(n,2);return},i.prototype.finalize=function(){if(this.newWireSeg.isZeroLength())this.newWireSeg.remove();else{var n=this.newWireSeg.getEndLocation(1);this.conn.moveTo(n);this.conn.connectToWireSegment(this.newWireSeg,1);this.conn.disconnectWireSegment(this.wireSeg,this.end);this.wireSeg.connectWireSegmentEnds(this.end,this.newWireSeg,2);this.addToWire(this.newWireSeg)}return},i}(t);n.DragPinConnection=r;f=function(i){function r(r,u,f){i.call(this,r,u,f);this.side1WSList=[];this.side2WSList=[];this.side1EndPoint=null;this.side2EndPoint=null;this.side1EndHasConn=!1;this.side2EndHasConn=!1;this.region=0;this.connDot=null;this.duplicateDot=null;this.conn=this.wireSeg.getConnection(this.end);this.side1WSList=this.getOrthogonalWireSegmentList(1);this.side2WSList=this.getOrthogonalWireSegmentList(2);this.side1WSList.length==0?(this.side1EndPoint=this.conn.getLocation(),this.side1EndHasConn=!0):(this.side1EndPoint=t.getEndPoint(this.side1WSList),this.side1EndHasConn=t.isEndPointConnected(this.side1WSList));this.side2WSList.length==0?(this.side2EndPoint=this.conn.getLocation(),this.side2EndHasConn=!0):(this.side2EndPoint=t.getEndPoint(this.side2WSList),this.side2EndHasConn=t.isEndPointConnected(this.side2WSList));var e=this.conn.getLocation(),o=new n.Segment(e,e);this.newWireSeg=new n.WireSegment(this.design,o,this.wireSeg.isBus(),this.wireSeg.getTechnology());this.wireSeg.isBus()||(this.conn.hideConnectionDot(),this.connDot=new n.ConnectionDot(this.design,this.conn.getLocation(),this.wireSeg.getTechnology()),this.conn.getNumConnectedWireSegments()>3&&(this.duplicateDot=new n.ConnectionDot(this.design,this.conn.getLocation(),this.wireSeg.getTechnology())))}return __extends(r,i),r.prototype.drag=function(){var n=this.wireSeg.getEndLocation(this.end),t=this.getRegion(n);t!=this.region&&(this.region=t,this.region==-2?(this.newWireSeg.moveEndTo(this.side1EndPoint,1),this.connDot&&(this.side1EndHasConn?(this.connDot.show(),this.connDot.moveTo(this.side1EndPoint)):this.connDot.hide())):this.region==2?(this.newWireSeg.moveEndTo(this.side2EndPoint,1),this.connDot&&(this.side2EndHasConn?(this.connDot.show(),this.connDot.moveTo(this.side2EndPoint)):this.connDot.hide())):(this.newWireSeg.moveEndTo(this.conn.getLocation(),1),this.newWireSeg.moveEndTo(this.conn.getLocation(),2),this.connDot&&this.connDot.show()));this.region==-1||this.region==1?this.connDot&&this.connDot.moveTo(n):this.newWireSeg.moveEndTo(n,2);return},r.prototype.finalize=function(){this.conn&&this.conn.deselect(!1);var n=this.wireSeg.getEndLocation(this.end);if(this.connDot&&(this.connDot.remove(),this.duplicateDot&&this.duplicateDot.remove(),this.conn.showConnectionDot()),this.startPt.isEqual(n)){this.newWireSeg.remove();return}this.conn.moveTo(this.startPt);this.newWireSeg.isZeroLength()?this.finalizeNoNewSegment(n):this.finalizeWithWireSegment()},r.prototype.getRegion=function(t){return this.orient==n.ORIENTATION.VERTICAL?t.isWestOf(this.side1EndPoint)?-2:t.isEastOf(this.side2EndPoint)?2:t.isWestOf(this.startPt)?-1:1:t.isNorthOf(this.side1EndPoint)?-2:t.isSouthOf(this.side2EndPoint)?2:t.isNorthOf(this.startPt)?-1:1},r.prototype.finalizeNoNewSegment=function(n){this.newWireSeg.remove();this.conn.disconnectWireSegment(this.wireSeg,this.end);var t;if(t=this.region==-1?this.findWireSegment(this.side1WSList,n):this.findWireSegment(this.side2WSList,n),!t){console.log("No wire segment found for region = "+this.region);return}this.connectToWireSegment(t,n)},r.prototype.finalizeWithWireSegment=function(){var n,t,i,r,u,f;this.addToWire(this.newWireSeg);this.region==-2?(n=this.side1WSList,t=this.side1EndPoint):(n=this.side2WSList,t=this.side2EndPoint);r=n.length;r==0?i=this.conn:(u=n[r-1],f=u.wireSeg,i=this.wireEndConn(f,t));i.connectToWireSegment(this.newWireSeg,1);this.conn.disconnectWireSegment(this.wireSeg,this.end);this.newWireSeg.connectWireSegmentEnds(2,this.wireSeg,this.end)},r}(t);n.DragConnDotConnection=f;o=function(){function n(n,t){this.design=n;this.paper=this.design.getPaper();this.wireSeg=t;t.getWire().removeNametag();this.end1DragConn=this.createDragConnection(1);this.end2DragConn=this.createDragConnection(2)}return n.prototype.createDragConnection=function(n){var t=this.wireSeg.getConnection(n),e,o;return t?(e=t.getNumConnectedWireSegments(),o=t.getNumConnectedPins(),o==0&&e==1?new i(this.design,this.wireSeg,n):o==0&&e==2?this.inlineWireSegments(t)?new r(this.design,this.wireSeg,n):new u(this.design,this.wireSeg,n):o==1&&e==1?new r(this.design,this.wireSeg,n):new f(this.design,this.wireSeg,n)):new i(this.design,this.wireSeg,n)},n.prototype.drag=function(){this.end1DragConn&&this.end1DragConn.drag();this.end2DragConn&&this.end2DragConn.drag()},n.prototype.finalize=function(n,t){this.drag();this.end1DragConn&&this.end1DragConn.finalize(n,t);this.end2DragConn&&this.end2DragConn.finalize(n,t);this.wireSeg.getWire().buildNametag()},n.prototype.inlineWireSegments=function(n){var r=n.getNumConnectedWireSegments(),t,i;return r==2&&(t=n.getWireSegment(0),i=n.getWireSegment(1),t.getOrient()==i.getOrient())?!0:!1},n}();n.WireDragSegment=o;e=function(){function n(n,t){this.wireSeg=n;this.end=t}return n}();n.WireSegmentAndEnd=e}(BaseWire||(BaseWire={})),function(n){var t=function(){function t(t,i,r){this.path=null;this.anchor=null;this.anchorConn=null;this.dragSet=null;this.dragConn=null;this.dragPins=[];this.dragWireSegs=[];this.dragWireEnds=[];this.wireSeg1=null;this.wireSeg2=null;this.wireSeg1ThisEnd=-1;this.wireSeg2ThisEnd=-1;this.quad=n.QUADRANT.CENTER;this.design=t;this.paper=this.design.getPaper();this.dragSet=i;this.dragConn=r;this.splitPinsWireSegs();this.init();this.draw()}return t.prototype.drag=function(){var n,t;this.dragConn&&this.dragSegs&&this.path&&(n=this.wireSeg2!=null,this.dragSegs.changeEndPoint(this.getExactLocation(),n),t=this.dragSegs.toPath(),this.path.attr({path:t}))},t.prototype.finalize=function(n,t,i){var o=this,r=jQuery.Deferred(),u,e,f;return!this.dragConn||!this.dragSegs||!this.path?(r.resolve(),r):(this.drag(n,t),u=this.getExactLocation(),u.add(n,t),u.round(),e=this.wireSeg2!=null,this.dragSegs.changeEndPoint(u,e),f=this.dragSegs.toPath(),i==null||i==!0?this.path.animate({path:f},300,"linear",function(){o.commit();r.resolve()}):(this.path.attr({path:f}),this.commit(),r.resolve()),r)},t.prototype.finishAnimation=function(){this.dragConn&&this.dragSegs&&this.path&&(Project.Utility.finishAnimation(this.path),this.commit())},t.prototype.splitPinsWireSegs=function(){var i,t,r;if(this.dragConn)for(i=0;i<this.dragSet.length;++i)t=this.dragSet[i],t instanceof Project.Pin?this.dragPins.push(t):t instanceof n.WireSegment?(r=t,this.dragWireSegs.push(r),this.dragWireEnds.push(r.getEnd(this.dragConn))):console.log("Internal error in splitPinsWireSegs - bad type")},t.prototype.getExactLocation=function(){return this.dragPins.length>0?this.dragPins[0].getExactLocation():this.dragWireSegs[0].getExactEndLocation(this.dragWireEnds[0])},t.prototype.setQuadrant=function(){this.quad=this.dragPins.length>0?this.dragPins[0].getQuadrant():n.QUADRANT.NORTH},t.prototype.getNonDraggingWireSegment=function(){for(var t,n=0;n<this.dragConn.getNumConnectedWireSegments();++n)if(t=this.dragConn.getWireSegment(n),this.dragWireSegs.indexOf(t)==-1)return t;return null},t.prototype.init=function(){var i,r,n,o,t;if(this.dragConn){if(i=this.dragConn.getNumConnections(),r=this.dragSet.length,i==0||i==1){console.log("Internal error with wireDragSeg - bad connection");return}if(r>i){console.log("Internal error with wireDragSeg - too many objects");return}if(n=this.getNonDraggingWireSegment(),r+1==i&&n!=null){var u=n.getEnd(this.dragConn),f=u==1?2:1,e=n.getConnection(f);this.hasExactlyTwoWireSegs(e)?(this.wireSeg1=n,this.wireSeg1ThisEnd=u,this.wireSeg2=this.getOtherWireSeg(n,e),this.wireSeg2ThisEnd=this.wireSeg2.getEnd(e),o=this.wireSeg2ThisEnd==1?2:1,this.anchor=this.wireSeg2.getEndLocation(o),this.anchorConn=this.wireSeg2.getConnection(o),this.wireSeg1.hide(),this.wireSeg2.hide(),t=this.wireSeg1.getConnection(this.wireSeg1ThisEnd),t&&t.hideConnectionDot()):(this.wireSeg1=n,this.wireSeg1ThisEnd=u,this.wireSeg1.hide(),this.anchor=n.getEndLocation(f),this.anchorConn=n.getConnection(f),t=this.wireSeg1.getConnection(this.wireSeg1ThisEnd),t&&t.hideConnectionDot())}else this.anchor=this.dragConn.getLocation(),this.anchorConn=this.dragConn;this.setQuadrant()}},t.prototype.commit=function(){if(this.anchor&&this.path&&this.dragSegs){this.design.suspendDirtyCalls();this.design.getConnMgr().manage(this.anchorConn);this.design.getConnMgr().manage(this.dragConn);var n=this.dragSegs.numSegs();this.wireSeg1&&this.wireSeg2?n==2?this.convert2SegsTo2():n==1?this.convert2SegsTo1():this.convert2SegsTo0():this.wireSeg1?n==2?this.convert1SegTo2():n==1?this.convert1SegTo1():this.convert1SegTo0():n==2?this.convert0SegsTo2():n==1&&this.convert0SegsTo1();this.design.restoreDirtyCalls();this.path.remove();this.path=null}},t.prototype.hasExactlyTwoWireSegs=function(n){return n&&n.getNumConnections()==2&&n.getNumConnectedWireSegments()==2?!0:!1},t.prototype.getOtherWireSeg=function(n,t){var i=t.getWireSegment(0);return i==n?t.getWireSegment(1):i},t.prototype.draw=function(){var t,i,r;this.dragConn&&this.anchor&&(t=this.dragConn.getLocation(),this.dragSegs=new n.RightAnglePair(this.anchor,t,this.quad),this.wireSeg2&&this.dragSegs.setOrientation(this.wireSeg2.getOrient()),i=this.dragSegs.toPath(),this.path=this.paper.path(i),r=this.design.getCssClassMgr().getWireSegmentClass(this.getTechnology(),this.dragConn.isBusConnection(),!1),this.path.node.setAttribute("class",r))},t.prototype.convert2SegsTo2=function(){var n=this.dragSegs.getSeg1(),t,i;this.wireSeg2.moveEndTo(n.point2,this.wireSeg2ThisEnd);t=this.wireSeg1ThisEnd==1?2:1;this.wireSeg1.moveEndTo(n.point2,t);i=this.dragSegs.getSeg2();this.wireSeg1.moveEndTo(i.point2,this.wireSeg1ThisEnd);this.wireSeg1.show();this.wireSeg2.show()},t.prototype.convert2SegsTo1=function(){var r=this.dragSegs.getSeg1(),n,t,i;this.wireSeg2.moveEndTo(r.point2,this.wireSeg2ThisEnd);n=this.wireSeg2.getConnection(this.wireSeg2ThisEnd);n.merge(this.dragConn);this.wireSeg1.remove();this.wireSeg2.show();t=this.wireSeg2ThisEnd==1?2:1;i=this.wireSeg2.getConnection(t);this.design.getConnMgr().manage(i)},t.prototype.convert2SegsTo0=function(){this.anchorConn?this.anchorConn.getNumConnectedWireSegments()>1||this.dragConn.getNumConnectedWireSegments()>1?(this.anchorConn.merge(this.dragConn),this.wireSeg1.remove(),this.wireSeg2.remove()):(this.wireSeg2ThisEnd==1?(this.wireSeg2.disconnectEnd1(),this.dragConn.connectToWireSegment(this.wireSeg2,1)):(this.wireSeg2.disconnectEnd2(),this.dragConn.connectToWireSegment(this.wireSeg2,2)),this.anchorConn.merge(this.dragConn),this.wireSeg2.moveEndTo(this.anchor,this.wireSeg2ThisEnd),this.wireSeg1.remove(),this.wireSeg2.show()):(this.wireSeg1.remove(),this.wireSeg2.remove())},t.prototype.convert1SegTo2=function(){var n=this.dragSegs.getSeg1(),t=this.dragSegs.getSeg2();this.wireSeg1.moveEndTo(n.point2,this.wireSeg1ThisEnd);this.wireSeg1.createConnectedWireSegment(t.point2,this.wireSeg1ThisEnd);this.wireSeg1.show()},t.prototype.convert1SegTo1=function(){var n=this.dragSegs.getSeg1();this.wireSeg1.moveEndTo(n.point2,this.wireSeg1ThisEnd);this.wireSeg1.show()},t.prototype.convert1SegTo0=function(){this.anchorConn?this.anchorConn.getNumConnectedWireSegments()>1||this.dragConn.getNumConnectedWireSegments()>1?(this.anchorConn.merge(this.dragConn),this.wireSeg1.remove()):(this.anchorConn.merge(this.dragConn),this.wireSeg1.moveEndTo(this.anchor,this.wireSeg1ThisEnd),this.wireSeg1.show()):this.wireSeg1.remove()},t.prototype.convert0SegsTo2=function(){var i=this.dragConn.getWire(),u,t;this.disconnectDragSet();this.dragConn.moveTo(this.anchor);var e=this.dragSegs.getSeg1(),o=this.dragSegs.getSeg2(),r=this.dragConn.getZeroLengthWire(),f=this.dragConn.isBusConnection();r?(this.dragConn.disconnectWireSegment(r,2),r.moveEndTo(e.point2,2),t=new n.WireSegment(this.design,o,f,this.getTechnology()),r.connectWireSegmentEnds(2,t,1),this.connectDragSet(t,2),i&&i.addWireSegment(t)):(u=new n.WireSegment(this.design,e,f,this.getTechnology()),this.dragConn.connectToWireSegment(u,1),t=new n.WireSegment(this.design,o,f,this.getTechnology()),u.connectWireSegmentEnds(2,t,1),this.connectDragSet(t,2),i&&(i.addWireSegment(u),i.addWireSegment(t)))},t.prototype.convert0SegsTo1=function(){var r=this.dragConn.getWire(),i;this.disconnectDragSet();this.dragConn.moveTo(this.anchor);var u=this.dragSegs.getSeg1(),t=this.dragConn.getZeroLengthWire(),f=this.dragConn.isBusConnection();t?(this.dragConn.disconnectWireSegment(t,2),t.moveEndTo(u.point2,2),this.connectDragSet(t,2)):(i=new n.WireSegment(this.design,u,f,this.getTechnology()),this.dragConn.connectToWireSegment(i,1),this.connectDragSet(i,2),r&&r.addWireSegment(i))},t.prototype.disconnectDragSet=function(){for(var n=0;n<this.dragPins.length;++n)this.dragConn.disconnectPin(this.dragPins[n]);for(n=0;n<this.dragWireSegs.length;++n)this.dragConn.disconnectWireSegment(this.dragWireSegs[n],this.dragWireEnds[n])},t.prototype.connectDragSet=function(t,i){var u=new n.Connection(this.design),r;for(u.connectToWireSegment(t,i),r=0;r<this.dragPins.length;++r)u.connectToPin(this.dragPins[r]);for(r=0;r<this.dragWireSegs.length;++r)u.connectToWireSegment(this.dragWireSegs[r],this.dragWireEnds[r])},t.prototype.getTechnology=function(){var n=Project.TECHNOLOGY.ELEC,t,i;return this.dragConn&&(t=this.dragConn.getPin(0),t?n=t.getTechnology():(i=this.dragConn.getWireSegment(0),i&&(n=i.getTechnology()))),n},t}();n.WireDragSet=t}(BaseWire||(BaseWire={})),function(n){var i,e,t,f,r,u;(function(n){n[n.NONE=0]="NONE";n[n.CHOSEN=1]="CHOSEN";n[n.ALL=2]="ALL"})(n.NAMETAG_VISIBILITY||(n.NAMETAG_VISIBILITY={}));i=n.NAMETAG_VISIBILITY,function(n){n[n.BOTH_NULL=0]="BOTH_NULL";n[n.ONE_NULL=1]="ONE_NULL";n[n.NOT_NULL=2]="NOT_NULL"}(n.NULL_CHECK||(n.NULL_CHECK={}));e=n.NULL_CHECK,function(n){n[n.CLEAN=0]="CLEAN";n[n.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS=1]="DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS";n[n.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS=2]="DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS";n[n.DIRTY_SIM_SETTINGS=3]="DIRTY_SIM_SETTINGS";n[n.DIRTY_WAVEBOX=4]="DIRTY_WAVEBOX"}(n.DIRTY_FLAG||(n.DIRTY_FLAG={}));t=n.DIRTY_FLAG;f=function(){function f(r,u,f){this.nametagVisibility=i.CHOSEN;this.prefixObj={};this.designObjs={};this.selMgr=null;this.ceSelMgr=null;this.connMgr=null;this.changeTracker=null;this.changeTrackerContext=null;this.migratedFlag=!1;this.isGetDbCompByComponentId=!0;this.autoResizing=!1;this.noData=!1;appInsights.trackEvent("Creating Design");this.surface=r;this.paper=r.getPaper();this.symbolBar=u;this.wireBar=f;this.wireMgr=new BaseWire.WiringManager(this);this.cssClassMgr=new n.CssClassManager(this);this.setName(this.createUniqName("design"));this.designID="";this.revisionID="";this.version=-1;this.comps=[];this.nets=[];this.connections=[];this.simulationData=new n.DesignSimulationData(this);this.defineEvents();this.dirtyFlag=t.CLEAN;this.dirtyFlagSuspended=!1;this.skipValidation=!0;this.hoverEventsEnabled=!0;this.selMgr=new n.SelectionManager(this);this.ceSelMgr=new n.CeSelectionManager;this.connMgr=new BaseWire.ConnectionManager(this);this.undoManager=new n.UndoManager;this.undoManager.addCallback(this.syncDirtyWithUndo,this);this.lastSavedUndoId=this.undoManager.getCurrentId();this.surface.clearFocus()}return f.prototype.getInputField=function(){return this.inputField||(this.inputField=new n.InputField(this)),this.inputField},f.prototype.getPaper=function(){return this.paper},f.prototype.getSurface=function(){return this.surface},f.prototype.getName=function(){return this.name},f.prototype.setName=function(n){this.name!=n&&(this.name=n,this.setDirty(t.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS),this.surface.updateDesignName(n))},f.prototype.getLandingPageHost=function(){return this.landingPageHost},f.prototype.setLandingPageHost=function(n){this.landingPageHost=n},f.prototype.getLandingPageURL=function(){return this.landingPageURL},f.prototype.setLandingPageURL=function(n){this.landingPageURL=n},f.prototype.setDescription=function(n){this.description=n},f.prototype.setTags=function(n){this.tags=n},f.prototype.getDesignID=function(){return this.designID},f.prototype.setDesignID=function(n){this.designID=n},f.prototype.getRevisionID=function(){return this.revisionID},f.prototype.setRevisionID=function(n){this.revisionID=n;var t=this.getSimulationData();t&&t.setRevisionID(n)},f.prototype.getUserID=function(){return this.userID},f.prototype.setUserID=function(n){this.userID=n},f.prototype.isMigrated=function(){return this.migratedFlag},f.prototype.setMigrated=function(){this.migratedFlag=!0;this.version=n.VersionTracer.CURRENT_DESIGN_VERSION},f.prototype.clearMigrated=function(){this.migratedFlag=!1},f.prototype.getSymbolBar=function(){return this.symbolBar},f.prototype.getSidebarManager=function(){return this.surface.getSidebarManager()},f.prototype.getVersion=function(){return this.version},f.prototype.getWireBar=function(){return this.wireBar},f.prototype.getWireMgr=function(){return this.wireMgr},f.prototype.getCssClassMgr=function(){return this.cssClassMgr},f.prototype.getConnMgr=function(){return this.connMgr},f.prototype.trackChanges=function(n,t){this.changeTracker=n;this.changeTrackerContext=t},f.prototype.cancelTrackChanges=function(){this.changeTracker=null;this.changeTrackerContext=null},f.prototype.getLatestSimulationResultInfo=function(){var n=this.simulationData.getLatestSimulation();return n?n.getSimulationResultInfo():null},f.prototype.getLatestSimulationParameters=function(t){t===void 0&&(t=!1);var i=this.simulationData.getLatestSimulation();return!t&&!i?null:t&&(!i||i.hasResults())&&(this.simulationData.addSimulation(new n.Simulation(this)),i=this.simulationData.getLatestSimulation(),!i)?null:i.getSimulationParameters()},f.prototype.getSimulationData=function(){return this.simulationData},f.prototype.getLatestSimulationType=function(){var t=this.getLatestSimulationParameters();return t?t.getActiveSimulation():n.SIMULATION_TYPE.NONE},f.prototype.getMousePosition=function(){return new BaseWire.Point(this.mousePageX,this.mousePageY)},f.prototype.getMousePositionWithDelta=function(n,t){return new BaseWire.Point(this.mousePageX+n,this.mousePageY+t)},f.prototype.getNametagVisibility=function(){return this.nametagVisibility},f.prototype.setNametagVisibility=function(n){this.nametagVisibility=n;this.nametagVisibility!=i.NONE?this.buildNametags():this.removeNametags()},f.prototype.updateNametagVisibility=function(){switch(this.nametagVisibility){case i.NONE:this.nametagVisibility=i.CHOSEN;this.buildNametags(!0);break;case i.CHOSEN:this.nametagVisibility=i.ALL;this.buildNametags(!0);break;case i.ALL:this.nametagVisibility=i.NONE;this.removeNametags(!0)}},f.prototype.buildNametags=function(n){var t;if(n===void 0&&(n=!1),this.nametagVisibility!=i.NONE){for(t=0;t<this.comps.length;t++)this.comps[t].buildNametag(n);for(t=0;t<this.nets.length;t++)this.nets[t].buildNametags(n)}},f.prototype.removeNametags=function(n){var t;for(n===void 0&&(n=!1),t=0;t<this.comps.length;t++)this.comps[t].removeNametag(n);for(t=0;t<this.nets.length;t++)this.nets[t].removeNametags(n)},f.prototype.addComponent=function(i){n.Settings.notify("component added");this.comps.push(i);this.addObject(i,i.getInstName());this.setDirty(t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},f.prototype.removeComponent=function(n){var i=this.comps.indexOf(n);i>=0&&this.comps.splice(i,1);this.removeObject(n,n.getInstName());this.setDirty(t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},f.prototype.renameComponent=function(n,i){this.removeRef(i,n);this.addRef(n.getInstName(),n);i.toLowerCase()==n.getInstName().toLowerCase()?this.setDirty(t.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS):this.setDirty(t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},f.prototype.componentExists=function(n){var t=this.comps.indexOf(n);return t>=0?!0:!1},f.prototype.unconnectedPinsToFront=function(){for(var n=0;n<this.comps.length;n++)this.comps[n].unconnectedPinsToFront()},f.prototype.addNet=function(n){this.nets.push(n);this.addObject(n,n.getNamePrefix());this.setDirty(t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},f.prototype.removeNet=function(n){var i=this.nets.indexOf(n);i>=0&&this.nets.splice(i,1);this.removeObject(n,n.getNamePrefix());this.setDirty(t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},f.prototype.renameNet=function(n,i){this.removeRef(i,n);this.addRef(n.getNamePrefix(),n);this.setDirty(t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)},f.prototype.netExists=function(n){var t=this.nets.indexOf(n);return t>=0?!0:!1},f.prototype.addWire=function(n){this.addObject(n,n.getUniqName())},f.prototype.removeWire=function(n){this.removeObject(n,n.getUniqName())},f.prototype.renameWire=function(){},f.prototype.wireExists=function(n){var t=n.getUniqName(),i=this.createUniqRefName(t,n);return this.designObjs.hasOwnProperty(i)?!0:!1},f.prototype.addWireSegment=function(n){this.addObject(n,n.getUniqName())},f.prototype.removeWireSegment=function(n){this.removeObject(n,n.getUniqName())},f.prototype.renameWireSegment=function(){},f.prototype.wireSegmentExists=function(n){var t=n.getUniqName(),i=this.createUniqRefName(t,n);return this.designObjs.hasOwnProperty(i)?!0:!1},f.prototype.addConnection=function(n){this.connections.push(n);this.addObject(n,n.getUniqName())},f.prototype.removeConnection=function(n){var t=this.connections.indexOf(n);t>=0&&this.connections.splice(t,1);this.removeObject(n,n.getUniqName())},f.prototype.renameConnection=function(){},f.prototype.connectionExists=function(n){var t=this.connections.indexOf(n);return t>=0?!0:!1},f.prototype.addProbe=function(n){this.addMetaObject(n,n.getUniqName())},f.prototype.removeProbe=function(n){this.removeMetaObject(n,n.getUniqName())},f.prototype.renameProbe=function(){},f.prototype.probeExists=function(n){return this.getSimulationData().probeExists(n)},f.prototype.addWaveBox=function(n){this.getSimulationData().addWaveBox(n);this.addMetaObject(n,n.getUniqName())},f.prototype.removeWaveBox=function(n){this.getSimulationData().removeWavebox(n);this.removeMetaObject(n,n.getUniqName())},f.prototype.waveBoxExists=function(n){return this.getSimulationData().waveBoxExists(n)},f.prototype.renameWaveBox=function(){},f.prototype.addObject=function(n,i){this.addRef(i,n);this.setDirty(t.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS);this.runChangeTrackerAddObj(n)},f.prototype.removeObject=function(n,i){this.removeRef(i,n);this.setDirty(t.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS);this.selMgr.deselectObject(n);this.runChangeTrackerRemoveObj(n)},f.prototype.addMetaObject=function(n,i){this.addRef(i,n);this.setDirty(t.DIRTY_WAVEBOX);this.runChangeTrackerAddObj(n)},f.prototype.removeMetaObject=function(n,i){this.removeRef(i,n);this.setDirty(t.DIRTY_WAVEBOX);this.selMgr.deselectObject(n);this.runChangeTrackerRemoveObj(n)},f.prototype.runChangeTrackerAddObj=function(n){this.changeTracker&&this.changeTracker(this.changeTrackerContext,n,!0)},f.prototype.runChangeTrackerRemoveObj=function(n){this.changeTracker&&this.changeTracker(this.changeTrackerContext,n,!1)},f.prototype.findCompByInstName=function(n){var t=this.createUniqCompName(n);return this.designObjs.hasOwnProperty(t)?this.designObjs[t]:null},f.prototype.findNetByName=function(n){var t=this.createUniqNetName(n);return this.designObjs.hasOwnProperty(t)?this.designObjs[t]:null},f.prototype.findObjectByUniqName=function(n){return this.designObjs.hasOwnProperty(n)?this.designObjs[n]:null},f.prototype.findObjectUnderPoint=function(n,t){for(var r,u,i=0;i<this.nets.length;++i)if(this.nets[i]!=t&&(r=this.nets[i].findWireSegmentUnderPoint(n,t),r))return r;for(i=0;i<this.comps.length;++i)if(this.comps[i]!=t&&(u=this.comps[i].findPinUnderPoint(n,t),u))return u;for(i=0;i<this.comps.length;++i)if(this.comps[i]!=t&&this.comps[i].isPointInside(n))return this.comps[i];return null},f.prototype.findCloseWireSegment=function(n,t,i){for(var f,e,o=null,s=1e3,h=this.surface.getConnectionTolerance(),u=this.getWireSegmentArray(),r=0;r<u.length;r++)t&&u[r].isBus()||u[r]==i||(f=u[r].getSegment(),f.isWithinBox(n,h)&&(e=f.getDistanceFrom(n),e<s&&(s=e,o=u[r])));return o},f.prototype.findCloseComponent=function(n,t){for(var r,f,e=null,o=1e3,s=this.surface.getConnectionTolerance(),u=this.getCompArray(),i=0;i<u.length;i++)(r=u[i],r!=t)&&r.isWithinBox(n,s)&&(f=r.getDistanceFrom(n),f<o&&(o=f,e=u[i]));return e},f.prototype.findCloseWireSegOrPin=function(n,t,i){var u=this.findCloseWireSegment(n,!1,i),f,r;return u&&u.getDistanceFrom(n)<t?u:(f=this.findCloseComponent(n,i),f&&(r=f.getClosestPin(n),r&&r!=i&&r.getLocation().distance(n)<t))?r:void 0},f.prototype.selectObject=function(n,t){this.surface.clearFocus();t&&t.ctrlKey?this.selMgr.toggleSelectObject(n):t&&t.shiftKey?this.selMgr.addSelectObject(n):this.selMgr.selectObject(n)},f.prototype.clearSelection=function(){this.selMgr.clearSelection()},f.prototype.getSingleSelectedComponent=function(){return this.selMgr.getSingleSelectedComponent()},f.prototype.deleteSelection=function(){this.selMgr.deleteSelection()},f.prototype.copySelection=function(){this.selMgr.copySelection()},f.prototype.cutSelection=function(){this.selMgr.cutSelection()},f.prototype.pasteSelection=function(){this.selMgr.pasteSelection(!1,!0)},f.prototype.save=function(){surface.disableControls();var n=this.surface.saveDesign();return n.done(function(n){surface.enableControls();switch(n){case Schematic.DesignSavedState.NOT_NEEDED:break;case Schematic.DesignSavedState.SERVER_ERROR:break;default:Messaging.Handler.sendDesignSavedMessage()}}),n},f.prototype.areaSelect=function(t,i){var c=this,u,e,o=0,s=0,r,h;this.getWireBar().disable();this.getSymbolBar().disable();this.disableHoverEvents();r=n.Utility.eventToPoint(this,i);h=this.paper.rect(r.x,r.y,0,0);h.attr("opacity","1");$(document).bind("mousemove.selectEvents",function(t){var i=n.Utility.eventToPoint(c,t);i.x<r.x?(u=i.x,o=r.x-i.x):(u=r.x,o=i.x-r.x);i.y<r.y?(e=i.y,s=r.y-i.y):(e=r.y,s=i.y-r.y);h.attr({x:u,y:e,width:o,height:s});setBodyCursor("copy")});$(document).bind("mouseup.selectEvents",function(){o!=0&&s!=0&&c.selMgr.areaSelect(u,e,u+o,e+s);c.terminateAreaSelect(h)});$(document).bind("keydown.selectEvents",function(n){n.which==f.EscKey&&c.terminateAreaSelect(h)})},f.prototype.terminateAreaSelect=function(n){$(document).unbind(".selectEvents");n.remove();this.getWireBar().enable();this.getSymbolBar().enable();this.enableHoverEvents();setBodyCursor("default")},f.prototype.getSelectionManager=function(){return this.selMgr},f.prototype.getCeSelectionManager=function(){return this.ceSelMgr},f.prototype.crossHighlight=function(t,i){var r=this.getObjFromName(t,i),u,f;r instanceof n.Component?(u=r,u.crossHighlight()):r instanceof BaseWire.Net&&(f=r,f.crossHighlight())},f.prototype.crossUnhighlight=function(t,i){var r=this.getObjFromName(t,i),u,f;r instanceof n.Component?(u=r,u.unhighlight()):r instanceof BaseWire.Net&&(f=r,f.unhighlight())},f.prototype.getObjFromName=function(n,t){if(!n)return null;n=n.trim();var i=n.indexOf(PATH_SEPARATOR);return t||i>-1?(i>-1&&(n=n.substr(0,i)),this.findCompByInstName(n)):this.findNetByName(n)},f.prototype.getComponentsInsideBox=function(n,t,i,r){for(var f,e=[],u=0;u<this.comps.length;++u)f=this.comps[u],f.isInsideBox(n,t,i,r)&&e.push(f);return e},f.prototype.getWireSegmentsInsideBox=function(n,t,i,r){for(var e,o,f=[],u=0;u<this.nets.length;++u)e=this.nets[u],o=e.findWireSegmentsInsideBox(n,t,i,r),jQuery.merge(f,o);return f},f.prototype.placeComponent=function(t,i,r){var e,o,s,u,f;return r===void 0&&(r=!1),e=!1,i||(i=this.surface.getViewBoxCorner(),o=this.getSidebarManager(),s=this.surface.getScale(),i.x+=o.getVisibleWidth(Sidebar.Orientation.LEFT)*s,i.x+=10,i.y+=10,e=!0),this.getUndoManager().startUndoableCommand(n.AddComponentCommand,this,null,n.COMMAND_STEP.FIRST),u=new n.Component(this,t),this.getUndoManager().finishUndoableCommand(u),e&&(f=u.getCenterOffset(),f.x>0&&(i.x+=f.x),f.y>0&&(i.y+=f.y)),this.getUndoManager().startUndoableCommand(n.MoveComponentCommand,this,u,n.COMMAND_STEP.LAST),u.moveTo(i.x,i.y),r&&(u.tryToConnect(0,0),u.buildConnectedNametags(),this.connMgr.finalize()),this.getUndoManager().finishUndoableCommand(i),this.selectObject(u),u},f.prototype.replaceComponent=function(n,t,i,r){var f=this.findCompByInstName(n),u,e,o;f||console.log('Did not find instance with name "'+n+'"');u=null;e=surface.getComponentDataManager();u=e.getComponent(t,i);o=f.replace(u);r&&r(o)},f.prototype.getUniqNamePrefix=function(n,t){var i="uniq",r;return n&&n!=""?i=n:t&&t!=""&&(i=t),r=i.slice(-1),isNaN(r)||(i+="_"),i},f.prototype.getNextUniqueName=function(n,t){var i=this.getUniqNamePrefix(n,t);return i+this.nextIndex(i,!1)},f.prototype.createUniqName=function(n,t){var i=this.getUniqNamePrefix(n,t);return i+this.nextIndex(i,!0)},f.prototype.suspendCompHighlights=function(){for(var n=0;n<this.comps.length;n++)this.comps[n].hideHighlightBox(!1,!1)},f.prototype.restoreCompHighlights=function(){for(var n=0;n<this.comps.length;n++)this.comps[n].showHighlightBox(null,!1)},f.prototype.suspendConnectionDots=function(){for(var n=0;n<this.connections.length;++n)this.connections[n].hideConnectionDot()},f.prototype.restoreConnectionDots=function(){for(var n=0;n<this.connections.length;++n)this.connections[n].showConnectionDot()},f.prototype.isEmpty=function(){var n=!0;return this.comps.length>0?n=!1:this.nets.length>0&&(n=!1),n},f.prototype.getSaveData=function(){var t,e,o,i,s,h,f;for(this.fixForcedConnections(),t=new r,t.Version=n.VersionTracer.CURRENT_DESIGN_VERSION,t.Name=this.getName(),t.LandingPageHost=this.landingPageHost,t.LandingPageURL=this.landingPageURL,t.comps=[],t.nets=[],t.connections=[],t.prefixes=[],i=0;i<this.comps.length;++i)e=this.comps[i].getSaveData(),e&&t.comps.push(e);for(i=0;i<this.nets.length;++i)o=this.nets[i].getSaveData(),o&&t.nets.push(o);for(i=0;i<this.connections.length;++i)s=this.connections[i].getSaveData(),s&&t.connections.push(s);t.simulationData=this.simulationData.getSaveData();for(h in this.prefixObj)f=new u,f.prefix=h,f.value=this.prefixObj[h],t.prefixes.push(f);return t.Image=this.generateSVGImage(),t},f.prototype.generateSVGImage=function(){var f='<?xml-stylesheet type="text/css" href="'+n.Settings.PINSTYLIN+'" ?>',e,r,t;try{e=this.getSurface().hideGrid();this.getSurface().hideTTipRect();this.selMgr.suspendSelection();this.suspendCompHighlights();r=this.getNametagVisibility();r!=i.NONE&&this.setNametagVisibility(i.NONE);this.simulationData.suspendProbeVisibility();t=this.getBoundingRect();t==null&&(t=new n.BoundingRect(100,100,200,200));var u=10,o=Math.round(t.x1)-u,s=Math.round(t.y1)-u,h=Math.round(t.width)+2*u,c=Math.round(t.height)+2*u;f+=this.paper.toSVG(o,s,h,c);this.getSurface().showGrid(e);this.getSurface().showTTipRect();this.selMgr.restoreSelection();this.restoreCompHighlights();r!=i.NONE&&this.setNametagVisibility(r);this.simulationData.restoreProbeVisibility()}catch(l){console.log("Error creating an SVG image of the design: "+l);f+='<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" version="1.1"><\/svg>'}finally{return f}},f.prototype.getSaveSimulationData=function(){return this.simulationData.getSaveData()},f.prototype.isAutoresizing=function(){return this.autoResizing},f.prototype.load=function(t,i){var u=this,r=jQuery.Deferred(),f;n.Utility.trace("load in design.ts",!0);try{this.autoResizing=!0;$.when(this.loadDesignData(t)).done(function(n){n==Schematic.DesignLoadStatus.LOAD_OK?$.when(u.loadDesignComplete(i)).done(function(n){r.resolve(n)}):(u.loadDesignComplete(i),r.resolve(n))})}catch(e){f="There was an error loading this design: "+e;n.MessageManager.showErrorMessage(f);this.loadDesignComplete(i);r.resolve(Schematic.DesignLoadStatus.LOAD_FAILED_LOADING_DESIGN)}return r.promise()},f.prototype.compInRefList=function(n,t,i){if(!n)return!1;for(var r=0;r<n.length;++r)if(n[r].library==t&&n[r].componentId==i)return!0;return!1},f.prototype.getMissingComps=function(n){for(var t,f=surface.getComponentDataManager(),r=[],i=0,u=n;i<u.length;i++)t=u[i],f.getComponent(t.library,t.componentId)||r.push(t);return r},f.prototype.showMissingCompsMessage=function(t){for(var r,u="The following components could not be loaded:<br>",i=0,f=t;i<f.length;i++)r=f[i],u+='<div style="padding-left: 20px">'+r.instName+": "+r.compName+"<\/div>";n.MessageManager.showErrorMessage(u)},f.prototype.loadDesignData=function(t){var f=this,u=jQuery.Deferred(),s=this.surface.getComponentDataManager(),e,o,i,r;if(this.suspendDirtyCalls(),this.undoManager.disable(),this.setName(t.Name),this.setLandingPageHost(t.LandingPageHost),this.setLandingPageURL(t.LandingPageURL),this.designID=t.DesignID,this.revisionID=t.RevisionID,this.version=t.Version,this.userID=t.UserID,n.Utility.trace("loadDesignData starts in design.ts",!0),t.prefixes)for(i=0;i<t.prefixes.length;++i){var h=t.prefixes[i],c=h.prefix,l=h.value;this.prefixObj[c]=l}if(n.Utility.trace("Prefixes restored",!1),t.comps){for(e=Schematic.DesignLoadStatus.LOAD_OK,o=[],i=0;i<t.comps.length;++i)r=t.comps[i],s.getComponent(r.library,r.componentId,!1)||this.compInRefList(o,r.library,r.componentId)||o.push(new n.ComponentReference(r.library,r.componentId));$.when(s.getByList(o)).done(function(){var r=f.getMissingComps(t.comps),i;r.length>0&&(f.showMissingCompsMessage(r),e=Schematic.DesignLoadStatus.LOAD_FAILED_MISSING_COMPONENT);i={design:f,saveData:t};$.when.apply(i,u).done(function(){var r=i.design,t=i.saveData;f.restoreComponents(t.comps);$.when(f.postComponentRestore(t)).done(function(t){e!=Schematic.DesignLoadStatus.LOAD_OK?u.resolve(e):t?u.resolve(Schematic.DesignLoadStatus.LOAD_OK):u.resolve(Schematic.DesignLoadStatus.LOAD_FAILED_NO_SIMULATION_DATA);n.Utility.trace("postComponentRestore completes",!0)})})})}else this.version=n.VersionTracer.CURRENT_DESIGN_VERSION,u.resolve(Schematic.DesignLoadStatus.LOAD_OK);return u.promise()},f.prototype.postComponentRestore=function(t){var r,u,i,f;if(n.Utility.trace("Post components restore starts",!1),r=jQuery.Deferred(),t.nets)for(i=0;i<t.nets.length;++i)u=t.nets[i],this.restoreNet(u);if(n.Utility.trace("Nets restored",!1),t.connections){for(i=0;i<t.connections.length;++i)f=t.connections[i],this.restoreConnection(f);n.Utility.trace("Connections restored",!1)}return this.correctSplitConnections(),n.Utility.trace("updateWireSegmentClasses starts",!1),this.updateWireSegmentClasses(),n.Utility.trace("updateConnectionDotClasses starts",!1),this.updateConnectionDotClasses(),n.Utility.trace("buildNametags starts",!1),this.buildNametags(),t.simulationData?(n.Utility.trace("Loading simulation data starts",!0),$.when(this.simulationData.load(t.simulationData)).done(function(t){n.Utility.trace("Loading simulation data ends",!0);r.resolve(t)})):r.resolve(!0),r.promise()},f.prototype.correctSplitConnections=function(){for(var n,i=this.getWireSegmentArray(),t=0;t<i.length;++t)n=i[t],n.getConnection(1)&&n.getConnection(1)==n.getConnection(2)&&!n.isZeroLength()&&n.getConnection(1).correctLocation()},f.prototype.loadDesignComplete=function(t){var i=jQuery.Deferred(),r;return this.restoreDirtyCalls(),this.undoManager.enable(),this.checkDesignVersion(),$.when(this.loadAndPlotResults()).done(function(n){n?i.resolve(Schematic.DesignLoadStatus.LOAD_OK):i.resolve(Schematic.DesignLoadStatus.LOAD_FAILED_PLOTTING_RESULTS)}),this.getConnMgr().clear(),this.skipValidation||this.validateAllConnectionObjects()==""||(r="This design contains slight alignment problems between",r+="\nthe wires and the components.  It should be drawn again.",n.MessageManager.showErrorMessage(r),this.skipValidation=!0),this.adjustSizeAndPosition(),this.autoResizing=!1,this.noData&&(ProbeModule.getWaveBoxManager().updateWaveboxesWithoutData(),this.noData=!1),ProbeModule.getWaveBoxManager().pinWaveboxesToSchematic(),this.surface.clearFocus(),t&&t.resolve(),i.promise()},f.prototype.adjustSizeAndPosition=function(){ProbeModule.getWaveBoxManager().pinWaveboxesToSchematic();this.zoomToFitComplete()},f.prototype.zoomToFitComplete=function(){var n=null,t=null,i=0;do{if(++i==5)return;if(n=this.getBoundingRect(),!n)return;this.getSurface().zoomToFit(n);t=this.getBoundingRect()}while(this.needToFit(n,t))},f.prototype.needToFit=function(n,t){return!n||!t?!0:Math.round(n.height)!=Math.round(t.height)?!0:Math.round(n.width)!=Math.round(t.width)?!0:!1},f.prototype.checkDesignVersion=function(){this.version!=n.VersionTracer.CURRENT_DESIGN_VERSION?this.setDirty(t.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS):this.clearDirty()},f.prototype.updateWireSegmentClasses=function(){for(var n=0;n<this.nets.length;++n)this.nets[n].setTechnology()},f.prototype.updateConnectionDotClasses=function(){for(var n=0;n<this.connections.length;++n)this.connections[n].setTechnology()},f.prototype.getUniqueSimulations=function(){var n;return this.surface?(n=this.getSimulationData(),!n)?null:n.getUniqueSimulations():null},f.prototype.getLatestSimulation=function(){var n=this.getUniqueSimulations();return n?n.getLatestDesignSimulation():null},f.prototype.getLatestSimulationByType=function(t){var i=this.getUniqueSimulations();return i?t==n.SIMULATION_TYPE.NONE?i.getLatestDesignSimulation():i.getSimulation(t):null},f.prototype.canSwitchSimulationType=function(){var n=this.getUniqueSimulations();return!n||!n.hasAllResults()?!1:!0},f.prototype.loadAndPlotResults=function(){var t=jQuery.Deferred(),i;return(WaveViewer.getManager().hideViewer(),!surface||!surface.getSimulationSidebar())?(t.resolve(!0),t.promise()):(i=this.getUniqueSimulations(),i&&i.hasAnyResults())?($.when(surface.getSimulationSidebar().showResultsForLoadedDesign(i)).done(function(n){t.resolve(n)}),t.promise()):(surface.isEditable()?this.hasWaveBoxes()&&(n.MessageManager.showInfoMessage('This design has no simulation data. To view waveforms,<br>run a simulation by clicking the "Play" button on the right.',!0,8e3),this.noData=!0):surface.getSidebarManager().disableAndCloseViewerWindow(),t.resolve(!0),t.promise())},f.prototype.getCompArray=function(){return this.comps},f.prototype.getNetArray=function(){return this.nets},f.prototype.getConnectionArray=function(){return this.connections},f.prototype.hasWaveBoxes=function(){var n=!1;return this.getSimulationData()&&(n=this.getSimulationData().hasWaveboxes()),n},f.prototype.validateEmptyObjects=function(t){for(var e,f,o,s,u,h,r="",i=0;i<this.nets.length;++i)f=this.nets[i],f.getNumWires()==0&&(r+="<br>Error - net contains no wires: "+f.getName());for(e=this.getWireArray(),i=0;i<e.length;++i)u=e[i],u.getNumSegments()==0?r+="<br>Error - wire contains no wire segments: "+u.getUniqName():(f=u.getNet(),f?f.existsInDesign()||(r+="<br>Error - wire contains a net that doesn't exist: "+u.getUniqName()):r+="<br>Error - wire is not associated with a net: "+u.getUniqName());for(o=this.getWireSegmentArray(),i=0;i<o.length;++i)s=o[i],u=s.getWire(),u||(r+="<br>Error - wire segment is not associated with a wire: "+s.getUniqName());for(i=0;i<this.connections.length;++i)h=this.connections[i],h.getNumConnections()==0&&(r+="<br>Error - connection has no connected objects: "+h.getUniqName());return t&&r&&n.MessageManager.showErrorMessage(r),r},f.prototype.validateAllConnectionObjects=function(t){for(var u,i="",r=0;r<this.connections.length;++r)u=this.connections[r].validateLocation(),u!=""&&(i+=u);return t&&i&&n.MessageManager.showErrorMessage(i),i},f.prototype.validateObjectsAreConnected=function(){for(var a,r,h,v,y,e,c,l,u=this,f="",o=[],s=[],i="",t=0;t<this.comps.length;t++)this.comps[t].hasAllConnections()||(a=this.comps[t].getInstName(),e=n.Utility.createUUID(),o.push(e),i+='<div class="errorMessageLink" id="',i+=e+'" name="'+a+'">',i+="<strong>"+a+"<\/strong><\/div>",this.comps[t].showHighlightBox(n.HIGHLIGHT_STATE.ERROR));for(o.length>0&&(f+="All pins on all components must be connected to wires in order to run a simulation<br/><br/>",f+=o.length==1?"The following component has one or more pins that are not connected to a wire:<br/>"+i:"The following components have one or more pins that are not connected to a wire:<br/>"+i,f+="<br/>"),i="",r=this.getWireSegmentArray(),t=0;t<r.length;t++)if(h=r[t].getOverlappingEnds(),h.length>0)for(v=r[t].getUniqName(),y=v,r[t].getNet()&&(y=r[t].getNet().getName()),e=n.Utility.createUUID(),s.push(e),i+='<div class="errorMessageLink" id="',i+=e+'" name="'+v+'"" ends="'+h+'">',i+="<strong>"+y+"<\/strong><\/div>",c=0;c<h.length;c++)r[t].errorHighlight(h[c]);if(s.length>0&&(f+=s.length==1?"The following wire is not connected:<br/>"+i:"The following wires are not connected:<br/>"+i),f!=""){for(this.surface.zoomToFit(this.getBoundingRect()),n.MessageManager.showErrorMessage(f,!0),t=0;t<o.length;t++)l=$("#"+o[t]),l.click(function(n){var i=n.currentTarget.attributes.name.value,t;u.clearSelection();t=u.findCompByInstName(i);t&&u.selectObject(t)});for(t=0;t<s.length;t++)l=$("#"+s[t]),l.click(function(n){var f=n.currentTarget.attributes.name.value,r=n.currentTarget.attributes.ends.value.split(","),t,i;if(u.clearSelection(),t=u.findObjectByUniqName(f),t){for(i=0;i<r.length;i++)t.errorHighlight(+r[i]);u.selectObject(t)}});return!1}return!0},f.prototype.validateComponentProperties=function(){for(var u,f,r,t=this,e='<div id="invalidPropListDiv">',o=!1,i=0;i<this.comps.length;i++)for(u=this.comps[i].validate(),f=this.comps[i].getInstName(),r=0;r<u.length;r++)e+='<div class="errorMessageLink invalidPropLink" id="invalidPropLink_'+f+"_"+u[r]+'" name="'+f+'"><b>'+f+": "+u[r]+"<\/b> has an invalid value.<\/div>",this.comps[i].showHighlightBox(n.HIGHLIGHT_STATE.ERROR),o=!0;return(e+="<\/div>",o)?(this.surface.zoomToFit(this.getBoundingRect()),n.MessageManager.showInvalidPropMessage(e),$(".invalidPropLink").click(function(n){var f,i,r,u;for($(".qtip").qtip("hide"),f=n.currentTarget.attributes.name.value,t.clearSelection(),i=0;i<t.comps.length;i++)if(r=t.comps[i],f===r.getInstName()&&!r.isGroundOrReferenceComponent()){t.selectObject(t.comps[i]);t.comps[i].showPropWindow(null,!0);u=t.surface.getPropertyEditor();u.open();u.validateAll();break}}),!1):!0},f.prototype.validateGroundConnection=function(){for(var i,t=0;t<this.comps.length;t++)if(this.comps[t].isGroundOrReferenceComponent()||this.comps[t].getCompName()=="thermal_ambient_reference")return!0;for(t=0;t<this.comps.length;t++)if(this.comps[t].hasTerminalPin())return i="This design does not have a ground symbol.",i+="<br>Please connect a ground symbol before simulating.",n.MessageManager.showErrorMessage(i),!1;return!0},f.prototype.validate=function(){if(this.comps.length==0){var t="Design has no components.";return t+="<br>Please add and connect one or more components before simulating...",n.MessageManager.showErrorMessage(t),!1}return this.validateObjectsAreConnected()&&this.validateComponentProperties()&&this.validateGroundConnection()},f.prototype.getOrphanTerminals=function(){for(var f,t,r,u=[],i=0;i<this.nets.length;++i)f=this.nets[i],t=f.getConnectedPins(),t&&t.length==1&&(r=t[0],r.getType()==n.PIN_TYPE.TERMINAL&&u.push(r));return u},f.prototype.setDirty=function(n){!this.dirtyFlagSuspended&&this.surface.isEditable()&&(this.setDirtyFlag(n),Messaging.Handler.sendDesignDirtyMessage())},f.prototype.suspendDirtyCalls=function(){this.dirtyFlagSuspended=!0},f.prototype.restoreDirtyCalls=function(){this.dirtyFlagSuspended=!1},f.prototype.setDirtyFlag=function(n){if(this.dirtyFlag!=t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS)switch(n){case t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS:this.dirtyFlag=t.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS;return;case t.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS:this.dirtyFlag=n;return;case t.DIRTY_SIM_SETTINGS:case t.DIRTY_WAVEBOX:this.dirtyFlag==t.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS||(this.dirtyFlag=n);return}},f.prototype.clearDirty=function(){this.dirtyFlag=t.CLEAN;Messaging.Handler.sendDesignCleanMessage();this.lastSavedUndoId=this.undoManager.getCurrentId()},f.prototype.isDirty=function(){return this.dirtyFlag!=t.CLEAN},f.prototype.getDirtyFlag=function(){return this.dirtyFlag},f.prototype.syncDirtyWithUndo=function(n){n.lastSavedUndoId==n.undoManager.getCurrentId()&&n.clearDirty()},f.prototype.disableHoverEvents=function(){this.hoverEventsEnabled=!1},f.prototype.enableHoverEvents=function(){this.hoverEventsEnabled=!0},f.prototype.isHoverEnabled=function(){return this.hoverEventsEnabled},f.prototype.getBoundingRect=function(){for(var f,e,u,r,o,t=null,i=0;i<this.comps.length;i++)f=this.comps[i].getOverlay(),t=n.Utility.accumulateBoundingRect(t,new n.BoundingRect(f.getBBox()));for(i=0;i<this.nets.length;i++)e=this.nets[i].getBoundingRect(),t=n.Utility.accumulateBoundingRect(t,e);if(this.hasWaveBoxes())for(u=this.simulationData.getWaveboxArray(),r=0;r<u.length;r++)o=u[r].getBoundingRect(),t=n.Utility.accumulateBoundingRect(t,o);return t},f.prototype.dump=function(t,i){var r,u;n.Utility.dumpHeading(t,i);var f=this.comps.length,e=this.nets.length,o=this.connections.length;for(n.Utility.dump(t,"Design name = "+this.name),n.Utility.dump(t,"Design contains "+f+" components, "+e+" nets, "+o+" connections and "+this.simulationData.getNumWaveBoxes()+" waveBoxes."),r=0;r<f;r++)this.comps[r].dump(t+1,this.comps[r].getInstName());for(r=0;r<e;r++)this.nets[r].dump(t+1,"Net"+r);for(r=0;r<o;r++)this.connections[r].dump(t+1,"Connection"+r);this.simulationData.dump(t);for(u in this.prefixObj)n.Utility.dump(t,"Prefix "+u+" has value "+this.prefixObj[u])},f.prototype.nextIndex=function(n,t){n=n.toLowerCase();for(var i=this.prefixObj.hasOwnProperty(n)?this.prefixObj[n]+1:1;this.findCompByInstName(n+i)||this.findNetByName(n+i);)i+=1;return t&&(this.prefixObj[n]=i),i},f.prototype.addRef=function(n,t){var i=this.createUniqRefName(n,t);this.designObjs[i]=t},f.prototype.removeRef=function(n,t){var i=this.createUniqRefName(n,t);this.designObjs.hasOwnProperty(i)&&delete this.designObjs[i]},f.prototype.createUniqRefName=function(t,i){var r=t;return i&&i instanceof BaseWire.Net?r=this.createUniqNetName(t):i&&i instanceof n.Component&&(r=this.createUniqCompName(t)),r},f.prototype.restoreComponents=function(t){var u=this,r,i;n.Utility.trace("Start restore components",!1);r=surface.getComponentDataManager();i="";t&&(t.forEach(function(t){var e=r.getComponent(t.library,t.componentId),f;e&&(f=new n.Component(u,e,t.instName,t.instNameVisibility),f.restore(t),surface.isEditable()&&(i+=f.getCriticalDeprecationMessage(e)),n.Utility.trace("Component "+f.getCompName()+" restored",!1))}),i.length>0&&n.MessageManager.showWarningMessage("The following components have been deprecated. It is strongly<br>recommended that you replace them with the latest version.<br>"+i,!0));n.Utility.trace("All components restored",!0)},f.prototype.restoreNet=function(n){var t=new BaseWire.Net(this,n)},f.prototype.restoreConnection=function(n){var t=new BaseWire.Connection(this,n)},f.prototype.getComponentByComponentId=function(t,i,r){var u="?library="+t+"&componentId="+r;return $.ajax({dataType:"json",beforeSend:function(t){t.setRequestHeader("TOKEN_HEADER",n.Settings.APIKEY)},url:n.Settings.APIURI()+"/components/"+u})},f.prototype.undo=function(n){n!=null&&n.preventDefault();this.undoManager.undo()},f.prototype.redo=function(n){n!=null&&n.preventDefault();this.undoManager.redo()},f.prototype.defineEvents=function(){var t=this,i=this.surface.getBackgroundClass();$(i).mousedown(function(n){if(!n.shiftKey&&(t.clearSelection(),t.surface.isEditable())){var i=t.surface.getSidebarManager();i.getVisibleWidth(Sidebar.Orientation.LEFT)>0&&t.getSidebarManager().openSidebarByName(COMPONENT_BROWSER_SIDEBAR_ID)}});$(document).off(".schematicEvents");$(document).bind("mousemove.schematicEvents",function(n){t.mousePageX=n.pageX;t.mousePageY=n.pageY});$(document).bind("keydown.schematicEvents",function(i){var u,r;if(t.surface.isEditable()&&(u=$(MAIN_EDITOR).find(".k-splitbar"),u.is(document.activeElement)&&t.surface.clearFocus(),document.activeElement==document.body||!n.Utility.isEntryField(document.activeElement))){if(r=i.ctrlKey||i.metaKey,i.which==f.BackspaceKey||i.which==f.DeleteKey)return t.deleteSelection(),!1;if(i.which==f.CKey&&r)return t.copySelection(),!1;if(i.which==f.XKey&&r)return t.cutSelection(),!1;if(i.which==f.VKey&&r)return t.pasteSelection(),!1;if(i.which==f.SKey&&r)return t.save(),!1;if(i.which==f.ZKey&&r)return t.undo(i),!1;if(i.which==f.YKey&&r)return t.redo(i),!1;if(i.which==f.F11Key)return surface.toggleFullscreen(),!1}})},f.prototype.createUniqCompName=function(n){return"_comp_"+n.toLowerCase()},f.prototype.createUniqNetName=function(n){return"_net_"+n.toLowerCase()},f.prototype.getWireArray=function(){for(var i,r=[],u=BaseWire.Wire.NAME_PREFIX,f=new RegExp("^"+u+"[0-9]+$"),t=Object.getOwnPropertyNames(this.designObjs),n=0;n<t.length;++n)t[n].match(f)!=null&&(i=this.designObjs[t[n]],i instanceof BaseWire.Wire&&r.push(i));return r},f.prototype.getWireSegmentArray=function(){for(var i,r=[],u=BaseWire.WireSegment.WS_NAME_PREFIX,f=new RegExp("^"+u+"[0-9]+$"),e=BaseWire.WireSegment.BUS_NAME_PREFIX,o=new RegExp("^"+e+"[0-9]+$"),t=Object.getOwnPropertyNames(this.designObjs),n=0;n<t.length;++n)(t[n].match(f)!=null||t[n].match(o)!=null)&&(i=this.designObjs[t[n]],i instanceof BaseWire.WireSegment&&r.push(i));return r},f.prototype.getUndoManager=function(){return this.undoManager},f.prototype.hideViewerWindow=function(){WaveViewer.getManager().hideViewer()},f.prototype.getSVGElements=function(n){var t=n.replace(/\s+</g,"<"),i=(new DOMParser).parseFromString(t,"text/xml");return this.getPaper().importSVG(i)},f.prototype.fixForcedConnections=function(){for(var n,i,t=0;t<this.nets.length;++t)(n=this.nets[t],n.isBus())||(i=n.getForcedName(),i&&i!=n.getNamePrefix()&&n.setNamePrefix(i))},f.prototype.dumpDesignState=function(t,i){var r=this.getSaveData(),f=i?i:this.getName(),u="";if(n.VersionTracer.CURRENT_DESIGN_VERSION<=5){var e=JSON.stringify(r.comps),o=JSON.stringify(r.connections),s=JSON.stringify(r.nets),h=JSON.stringify(r.prefixes),c=JSON.stringify(r.simulationData),l=JSON.stringify(r.Name);console.log("------------- Design "+f+"-----------------");u=t?"public startDesignState: any = { ":"public endDesignState: any = { ";u+="\ncomps: "+e+",\nconnections: "+o+",\nName: "+l+",\nnets: "+s+",\nprefixes: "+h+",\nsimulationData: "+c+",\nVersion: "+r.Version+"};\n";console.log(u);console.log("=====================================================")}else n.MessageManager.showErrorMessage("dumpDesignState() function is not defined for design version "+n.VersionTracer.CURRENT_DESIGN_VERSION);return Sidebar.DumpEditor.addToTestData(u,t),u},f.BackspaceKey=8,f.TabKey=9,f.EnterKey=13,f.EscKey=27,f.SpaceKey=32,f.DeleteKey=46,f.CKey=67,f.SKey=83,f.VKey=86,f.XKey=88,f.YKey=89,f.ZKey=90,f.F11Key=122,f}();n.Design=f;r=function(){function t(){}return t.prototype.compareTo=function(t){return n.Utility.compareArrays(this.comps,t.comps,"compName","comps",!0,this.Version)?n.Utility.compareArrays(this.connections,t.connections,"uniqName","connections",!0,this.Version)?n.Utility.compareArrays(this.nets,t.nets,"name","nets",!0,this.Version)?n.Utility.comparePrimitives(this.Name,t.Name,"Name","comp",!0)?n.Utility.comparePrimitives(this.Version,t.Version,"Version",this.Name,!0)?!0:!1:!1:!1:!1:!1},t}();n.DesignState=r;u=function(){function n(){}return n}();n.PrefixPair=u}(Project||(Project={})),function(n){(function(n){n[n.ELEC=0]="ELEC";n[n.ROT_VEL=1]="ROT_VEL";n[n.MAGNETIC=2]="MAGNETIC";n[n.QUANTITY=3]="QUANTITY";n[n.DIGITAL=4]="DIGITAL";n[n.REAL=5]="REAL";n[n.INTEGER=6]="INTEGER";n[n.BOOLEAN=7]="BOOLEAN";n[n.BIT=8]="BIT";n[n.ROT=10]="ROT";n[n.TRAN=11]="TRAN";n[n.THERMAL=12]="THERMAL";n[n.FLUIDIC=13]="FLUIDIC";n[n.OTHER_SIG=14]="OTHER_SIG";n[n.OTHER_TERM=15]="OTHER_TERM"})(n.TECHNOLOGY||(n.TECHNOLOGY={}));var t=n.TECHNOLOGY,i=function(){function n(n){this.wireSegmentClasses={};this.activeWireSegmentClasses={};this.pinIndicatorClasses={};this.connectionDotClasses={};this.quickConnectClasses={};this.probeClasses={};this.design=n;this.init()}return n.prototype.getDesign=function(){return this.design},n.prototype.getWireSegmentClass=function(n,t,i){var r;return r=t?i?"svw_bus_highlighted ":"svw_bus ":i?"svw_wire_highlighted ":"svw_wire ",r+this.wireSegmentClasses[n]},n.prototype.getActiveWireSegmentClass=function(n,t){var i;return i=t?"svw_active_bus_seg ":"svw_active_wire_seg ",i+this.activeWireSegmentClasses[n]},n.prototype.getPinIndicatorClass=function(n){return"svw_sym_pin_indicator "+this.pinIndicatorClasses[n]},n.prototype.getConnectionDotClass=function(n){return"svw_conn_dot "+this.connectionDotClasses[n]},n.prototype.getQuickConnectClass=function(n){return"svw_quick_connect "+this.quickConnectClasses[n]},n.prototype.getProbeClass=function(n){return"svw_probe "+this.probeClasses[n]},n.prototype.getSymPinArrowClass=function(n){return this.getArrowClass(n)},n.prototype.getSymPinWhiskerClass=function(n){return this.getWhiskerClass(n)},n.prototype.getSymPinIndicatorClass=function(n){return this.getIndicatorClass(n)},n.prototype.init=function(){var n,i;for(n in t)if(i=parseInt(n),!isNaN(i))switch(i){case t.ELEC:this.wireSegmentClasses[n]="svw_wire_elec";this.activeWireSegmentClasses[n]="svw_active_wire_seg_elec";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_elec";this.connectionDotClasses[n]="svw_conn_dot_elec";this.quickConnectClasses[n]="svw_quick_connect_elec";this.probeClasses[n]="svw_probe_elec";break;case t.ROT_VEL:this.wireSegmentClasses[n]="svw_wire_rv";this.activeWireSegmentClasses[n]="svw_active_wire_seg_rv";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_rv";this.connectionDotClasses[n]="svw_conn_dot_rv";this.quickConnectClasses[n]="svw_quick_connect_rv";this.probeClasses[n]="svw_probe_rv";break;case t.ROT:this.wireSegmentClasses[n]="svw_wire_r";this.activeWireSegmentClasses[n]="svw_active_wire_seg_r";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_r";this.connectionDotClasses[n]="svw_conn_dot_r";this.quickConnectClasses[n]="svw_quick_connect_r";this.probeClasses[n]="svw_probe_r";break;case t.TRAN:this.wireSegmentClasses[n]="svw_wire_t";this.activeWireSegmentClasses[n]="svw_active_wire_seg_t";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_t";this.connectionDotClasses[n]="svw_conn_dot_t";this.quickConnectClasses[n]="svw_quick_connect_t";this.probeClasses[n]="svw_probe_t";break;case t.THERMAL:this.wireSegmentClasses[n]="svw_wire_th";this.activeWireSegmentClasses[n]="svw_active_wire_seg_th";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_th";this.connectionDotClasses[n]="svw_conn_dot_th";this.quickConnectClasses[n]="svw_quick_connect_th";this.probeClasses[n]="svw_probe_th";break;case t.FLUIDIC:this.wireSegmentClasses[n]="svw_wire_flu";this.activeWireSegmentClasses[n]="svw_active_wire_seg_flu";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_flu";this.connectionDotClasses[n]="svw_conn_dot_flu";this.quickConnectClasses[n]="svw_quick_connect_flu";this.probeClasses[n]="svw_probe_flu";break;case t.MAGNETIC:this.wireSegmentClasses[n]="svw_wire_mag";this.activeWireSegmentClasses[n]="svw_active_wire_seg_mag";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_mag";this.connectionDotClasses[n]="svw_conn_dot_mag";this.quickConnectClasses[n]="svw_quick_connect_mag";this.probeClasses[n]="svw_probe_mag";break;case t.QUANTITY:this.wireSegmentClasses[n]="svw_wire_qty";this.activeWireSegmentClasses[n]="svw_active_wire_seg_qty";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_qty";this.connectionDotClasses[n]="svw_conn_dot_qty";this.quickConnectClasses[n]="svw_quick_connect_qty";this.probeClasses[n]="svw_probe_qty";break;case t.DIGITAL:this.wireSegmentClasses[n]="svw_wire_dig_sig";this.activeWireSegmentClasses[n]="svw_active_wire_seg_dig_sig";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_dig_sig";this.connectionDotClasses[n]="svw_conn_dot_dig_sig";this.quickConnectClasses[n]="svw_quick_connect_dig_sig";this.probeClasses[n]="svw_probe_dig_sig";break;case t.REAL:this.wireSegmentClasses[n]="svw_wire_real_sig";this.activeWireSegmentClasses[n]="svw_active_wire_seg_real_sig";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_real_sig";this.connectionDotClasses[n]="svw_conn_dot_real_sig";this.quickConnectClasses[n]="svw_quick_connect_real_sig";this.probeClasses[n]="svw_probe_real_sig";break;case t.INTEGER:this.wireSegmentClasses[n]="svw_wire_int_sig";this.activeWireSegmentClasses[n]="svw_active_wire_seg_int_sig";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_int_sig";this.connectionDotClasses[n]="svw_conn_dot_int_sig";this.quickConnectClasses[n]="svw_quick_connect_int_sig";this.probeClasses[n]="svw_probe_int_sig";break;case t.BOOLEAN:this.wireSegmentClasses[n]="svw_wire_bool_sig";this.activeWireSegmentClasses[n]="svw_active_wire_seg_bool_sig";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_bool_sig";this.connectionDotClasses[n]="svw_conn_dot_bool_sig";this.quickConnectClasses[n]="svw_quick_connect_bool_sig";this.probeClasses[n]="svw_probe_bool_sig";break;case t.BIT:this.wireSegmentClasses[n]="svw_wire_bit_sig";this.activeWireSegmentClasses[n]="svw_active_wire_seg_bit_sig";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_bit_sig";this.connectionDotClasses[n]="svw_conn_dot_bit_sig";this.quickConnectClasses[n]="svw_quick_connect_bit_sig";this.probeClasses[n]="svw_probe_bit_sig";break;case t.OTHER_TERM:this.wireSegmentClasses[n]="svw_wire_other_term";this.activeWireSegmentClasses[n]="svw_active_wire_seg_other_term";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_other_term";this.connectionDotClasses[n]="svw_conn_dot_other_term";this.quickConnectClasses[n]="svw_quick_connect_other_term";this.probeClasses[n]="svw_probe_other_term";break;case t.OTHER_SIG:this.wireSegmentClasses[n]="svw_wire_other_sig";this.activeWireSegmentClasses[n]="svw_active_wire_seg_other_sig";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_other_sig";this.connectionDotClasses[n]="svw_conn_dot_other_sig";this.quickConnectClasses[n]="svw_quick_connect_other_sig";this.probeClasses[n]="svw_probe_other_sig";break;default:this.wireSegmentClasses[n]="svw_wire_other_sig";this.activeWireSegmentClasses[n]="svw_active_wire_seg_other_sig";this.pinIndicatorClasses[n]="svw_sym_pin_indicator_other_sig";this.connectionDotClasses[n]="svw_conn_dot_other_sig";this.quickConnectClasses[n]="svw_quick_connect_other_sig";this.probeClasses[n]="svw_probe_other_sig"}},n.prototype.getWhiskerClass=function(n){var t="svw_sym_pin_whisker_",i=[];typeof n=="string"&&(n=n.toLowerCase(),n.indexOf("_vector")>-1&&(i=n.split("_vector"),n=i[0].toLowerCase()));switch(n){case"electrical":return t+"elec";case"rotational":return t+"r";case"rotational_velocity":return t+"rv";case"translational":return t+"t";case"translational_velocity":return t+"tv";case"thermal":return t+"th";case"magnetic":return t+"mag";case"fluidic":return t+"flu";case"compressible_fluidic":return t+"cflu";case"radiant":return t+"rad";case 1:return t+"qty";case"std_logic":return t+"dig_sig";case"real":return t+"real_sig";case"integer":return t+"int_sig";case"boolean":return t+"bool_sig";case"bit":return t+"bit_sig"}return t+"other_term"},n.prototype.getIndicatorClass=function(n){var t="svw_sym_pin_indicator_",i=[];typeof n=="string"&&(n=n.toLowerCase(),n.indexOf("_vector")>-1&&(i=n.split("_vector"),n=i[0].toLowerCase()));switch(n){case"electrical":return t+"elec";case"rotational":return t+"r";case"rotational_velocity":return t+"rv";case"translational":return t+"t";case"translational_velocity":return t+"tv";case"thermal":return t+"th";case"magnetic":return t+"mag";case"fluidic":return t+"flu";case"compressible_fluidic":return t+"cflu";case"radiant":return t+"rad";case 1:return t+"qty";case"std_logic":return t+"dig_sig";case"real":return t+"real_sig";case"integer":return t+"int_sig";case"boolean":return t+"bool_sig";case"bit":return t+"bit_sig"}return t+"other_term"},n.prototype.getArrowClass=function(n){var t="svw_sym_arrow_",i=[];typeof n=="string"&&(n=n.toLowerCase(),n.indexOf("_vector")>-1&&(i=n.split("_vector"),n=i[0].toLowerCase()));switch(n){case 1:return t+"qty";case"std_logic":return t+"dig_sig";case"real":return t+"real_sig";case"integer":return t+"int_sig";case"boolean":return t+"bool_sig";case"bit":return t+"bit_sig"}return t+"other_sig"},n.prototype.getTerminalSubtype=function(n){switch(n){case t.ELEC:return"electrical";case t.ROT_VEL:return"rotational_velocity";case t.ROT:return"rotational";case t.TRAN:return"translational";case t.MAGNETIC:return"magnetic";case t.FLUIDIC:return"fluidic";case t.THERMAL:return"thermal";default:return null}},n}();n.CssClassManager=i}(Project||(Project={})),function(n){var u=function(){function u(n){this.busSegments=null;this.pasteActive=!1;this.pasteCount=0;this.wireSegNetNameMap={};this.dragWireSegArr=null;this.dragConnArr=null;this.wireDragSetArr=null;this.design=n;this.selectedSet=[];this.clipboard=[];this.pasteActive=!1}return u.prototype.getSingleSelectedComponent=function(){return this.getNumSelected()==1&&this.selectedSet[0]instanceof n.Component?this.selectedSet[0]:null},u.prototype.getAnySelectedWireSegment=function(){var n=this.getSelectedWireSegments();return n!=null&&n.length>0?n[0]:null},u.prototype.getNumSelected=function(){return this.selectedSet.length},u.prototype.getSelectedSet=function(){return this.selectedSet},u.prototype.selectObject=function(n){this.clearSelection();this.select(n)},u.prototype.toggleSelectObject=function(n){this.isSelected(n)?this.removeFromSelection(n):this.addToSelection(n)},u.prototype.addSelectObject=function(n){this.isSelected(n)||this.addToSelection(n)},u.prototype.deselectObject=function(n){this.isSelected(n)&&this.removeFromSelection(n)},u.prototype.clearSelection=function(){if(!this.pasteActive){for(var n=0;n<this.getNumSelected();++n)this.selectedSet[n].deselect();this.selectedSet=[]}},u.prototype.deleteSelection=function(t){var r,i,u,f;for(t===void 0&&(t=!0),t&&this.design.getUndoManager().startUndoableCommand(n.DeleteSelectionCommand,this.design,null),r=this.getNumSelected()-1;r>=0;--r)i=this.selectedSet[r],i instanceof n.Component?(u=i,u.crossHighlightInViewer(!1),u.remove(),this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)):i instanceof BaseWire.WireSegment&&(f=i,f.crossHighlightInViewer(!1),f.remove(),this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS));this.selectedSet=[];this.design.getConnMgr().finalize();t&&this.design.getUndoManager().finishUndoableCommand(null)},u.prototype.areaSelect=function(n,t,i,r){var f,e,u;for(f=this.design.getComponentsInsideBox(n,t,i,r),e=this.design.getWireSegmentsInsideBox(n,t,i,r),u=0;u<f.length;++u)this.addToSelection(f[u]);for(u=0;u<e.length;++u)this.addToSelection(e[u])},u.prototype.toggleAreaSelect=function(n,t,i,r){var f,e,u;for(f=this.design.getComponentsInsideBox(n,t,i,r),e=this.design.getWireSegmentsInsideBox(n,t,i,r),u=0;u<f.length;++u)this.toggleSelectObject(f[u]);for(u=0;u<e.length;++u)this.toggleSelectObject(e[u])},u.prototype.suspendSelection=function(){for(var t=0;t<this.getNumSelected();++t)this.selectedSet[t]instanceof n.Component||this.selectedSet[t].deselect(!1)},u.prototype.restoreSelection=function(){for(var t=0;t<this.getNumSelected();++t)this.selectedSet[t]instanceof n.Component||this.selectedSet[t].select(!1)},u.prototype.copySelection=function(){this.getNumSelected()>0&&this.copySelectedSet(!1)},u.prototype.cutSelection=function(){this.getNumSelected()>0&&(this.copySelectedSet(!0),this.deleteSelection())},u.prototype.pasteSelection=function(t,i){var f,e,r;if(this.clipboard.length!=0){this.pasteActive?(++this.pasteCount,this.terminatePaste()):this.pasteCount=0;f=this.design.getSurface();this.pasteFromClipboard();this.clearCopiedNames();e=this.selectedSet;this.selectClonedSet();var u=this.getSelectedSetBoundingRect(),s=(u.x1+u.x2)/2,h=(u.y1+u.y2)/2,c=new BaseWire.Point(s,h),o=f.screenToSch(this.design.getMousePosition());i&&(r=o.clone(),r.subtract(c),r.add(this.pasteCount*n.Settings.SCH_GRID_SPACING,this.pasteCount*n.Settings.SCH_GRID_SPACING),this.moveSelectedSet(r.x,r.y));this.definePasteEvents(o,e,t)}},u.prototype.isPasteActive=function(){return this.pasteActive},u.prototype.initDragSelectedSet=function(){var r,i,t,u;for(this.finishAnimationSelectedSet(),r=this.design.getUndoManager(),r.clearActiveCommand(),r.startUndoableCommand(n.MoveSelectionCommand,this.design,null),this.setSelectedConnections(),this.setWireSegmentsToMove(),this.wireDragSetArr=[],i=this.getWireSegPinArray(),t=0;t<i.length;++t)u=new BaseWire.WireDragSet(this.design,i[t].wireSegsPins,i[t].conn),this.wireDragSetArr.push(u)},u.prototype.dragSelectedSet=function(t,i,r){for(var f,e,o,u=0;u<this.getNumSelected();++u)f=this.selectedSet[u],f instanceof n.Component&&(e=f,e!=t&&e.dragRelative(i,r,!1));for(u=0;u<this.dragWireSegArr.length;++u)o=this.dragWireSegArr[u],o!=t&&o.dragRelative(i,r,!1);for(u=0;u<this.wireDragSetArr.length;++u)this.wireDragSetArr[u].drag(i,r)},u.prototype.finalizeDragSelectedSet=function(n,t,i){var r,u;for(this.dragSelectedSet(n,t,i),r=0;r<this.wireDragSetArr.length;++r)this.wireDragSetArr[r].finalize(0,0,!1);u=this.design.getUndoManager();u.getActiveCommand()&&u.finishUndoableCommand(null);this.dragConnArr=null;this.dragWireSegArr=null;this.wireDragSetArr=null},u.prototype.finishAnimationSelectedSet=function(){},u.prototype.addToSelection=function(n){this.isSelected(n)||this.select(n)},u.prototype.removeFromSelection=function(t){var f,u,r,i;if(this.isSelected(t))if(t instanceof BaseWire.Wire)for(f=t,u=f.getSegments(),i=0;i<u.length;++i)u[i].deselect(),r=this.selectedSet.indexOf(u[i]),r>=0&&this.selectedSet.splice(r,1);else for(t.deselect(),r=this.selectedSet.indexOf(t),r>=0&&this.selectedSet.splice(r,1),i=0;i<this.selectedSet.length;++i)this.selectedSet[i]instanceof n.Component&&this.selectedSet[i].select()},u.prototype.isSelected=function(t){var u,r,i;if(t instanceof BaseWire.Wire){for(u=t,r=u.getSegments(),i=0;i<r.length;++i)if(!r[i].isSelected())return!1;return!0}return t instanceof BaseWire.WireSegment&&t.isSelected()||t instanceof n.Component&&t.isSelected()?!0:!1},u.prototype.select=function(n,t){var u,r,i;if(n)if(n instanceof BaseWire.Wire)for(u=n,r=u.getSegments(),i=0;i<r.length;++i)r[i].isSelected()||(r[i].select(t),this.selectedSet.push(r[i]));else n.select(t),this.selectedSet.push(n)},u.prototype.setSelectedConnections=function(){var r,i,o,f,s,u,t,e;for(this.dragConnArr=[],r=0;r<this.getNumSelected();++r)if(i=this.selectedSet[r],i instanceof n.Component)for(o=i,f=o.getPins(),t=0;t<f.length;++t)this.addUniqConn(this.dragConnArr,f[t].getConnection());else if(i instanceof BaseWire.Wire)for(s=i,u=s.getSegments(),t=0;t<u.length;++t)this.addUniqConn(this.dragConnArr,u[t].getConnection(1)),this.addUniqConn(this.dragConnArr,u[t].getConnection(2));else i instanceof BaseWire.WireSegment&&(e=i,this.addUniqConn(this.dragConnArr,e.getConnection(1)),this.addUniqConn(this.dragConnArr,e.getConnection(2)))},u.prototype.getBoundaryConnections=function(){var i,r,t,u,f,n;for(this.dragConnArr==null&&this.setSelectedConnections(),i=[],r=0;r<this.dragConnArr.length;++r){for(t=this.dragConnArr[r],u=!1,n=0;n<t.getNumConnectedWireSegments();++n)if(f=t.getWireSegment(n),this.dragWireSegArr.indexOf(f)==-1){this.addUniqConn(i,t);u=!0;break}if(!u)for(n=0;n<t.getNumConnectedPins();++n)if(!t.getPin(n).getComponent().isSelected()){this.addUniqConn(i,t);break}}return i},u.prototype.setWireSegmentsToMove=function(){var r,t,u,i,f,o,s,e,n;for(this.dragConnArr==null&&this.setSelectedConnections(),this.dragWireSegArr=this.getSelectedWireSegments(),r=0;r<this.dragConnArr.length;++r)for(t=this.dragConnArr[r],t.getWire().removeNametag(),u=0;u<t.getNumConnectedWireSegments();++u)if(n=t.getWireSegment(u),this.dragWireSegArr.indexOf(n)==-1){if(i=[],this.getSinglyConnectedWireSegments(t,n,i),f=i.length,f>0&&(o=i[f-1],s=o.conn,this.dragConnArr.indexOf(s)>=0))for(e=0;e<f;++e)n=i[e].wireSeg,this.dragWireSegArr.indexOf(n)==-1&&this.dragWireSegArr.push(n);this.isZeroLengthWireSegWithSelectedPins(n)&&this.dragWireSegArr.indexOf(n)==-1&&this.dragWireSegArr.push(n)}},u.prototype.getSelectedWireSegments=function(){for(var i,n,r=[],t=0;t<this.getNumSelected();++t)i=this.selectedSet[t],i instanceof BaseWire.WireSegment&&(n=i,(!n.isZeroLength()||this.isZeroLengthWireSegWithSelectedPins(n))&&this.addUniqWireSegment(r,n));return r},u.prototype.getSinglyConnectedWireSegments=function(n,t,i){var u;if(!t.isZeroLength()){var e=t.getEnd(n),o=e==1?2:1,r=t.getConnection(o),s=new f(t,r);if(i.push(s),r){if(r.getNumConnectedWireSegments()!=2||r.getNumConnectedPins()!=0)return;u=r.getOtherWireSegment(t);this.getSinglyConnectedWireSegments(r,u,i)}else return}},u.prototype.isZeroLengthWireSegWithSelectedPins=function(n){var i,t,r,u;if(!n.isZeroLength())return!1;for(i=n.getConnection(1),t=0;t<i.getNumConnectedPins();++t)if(r=i.getPin(t),u=r.getComponent(),!u.isSelected())return!1;return!0},u.prototype.getWireSegPinArray=function(){for(var t,i,u,n,f,h,o=[],s=this.getBoundaryConnections(),r=0;r<s.length;++r){for(t=s[r],i=new e(t),n=0;n<t.getNumConnectedWireSegments();++n)u=t.getWireSegment(n),this.dragWireSegArr.indexOf(u)>=0&&i.addWireSeg(u);for(n=0;n<t.getNumConnectedPins();++n)f=t.getPin(n),h=f.getComponent(),h.isSelected()&&i.addPin(f);o.push(i)}return o},u.prototype.addUniqConn=function(n,t){t&&n.indexOf(t)==-1&&n.push(t)},u.prototype.addUniqWireSegment=function(n,t){t&&n.indexOf(t)==-1&&n.push(t)},u.prototype.getSelectedSetBoundingRect=function(){for(var i,u,f,e,t=null,r=0;r<this.getNumSelected();++r)i=this.selectedSet[r],i instanceof n.Component?(u=i,f=u.getOverlay(),t=n.Utility.accumulateBoundingRect(t,new n.BoundingRect(f.getBBox()))):i instanceof BaseWire.WireSegment&&(e=i,t=n.Utility.accumulateBoundingRect(t,e.getBoundingRect()));return t},u.prototype.copySelectedSet=function(t){var s=[],r,i,u,f;for(this.clipboard=[],r=0;r<this.getNumSelected();++r)if(i=this.selectedSet[r],i instanceof n.Component)u=i,f=u.getCloneData(),t||(f.instName=null),this.clipboard.push(f),this.copyComponentConnections(s,u);else if(i instanceof BaseWire.WireSegment){var e=i,h=e.getCloneData(),o=e.getWire();(!t||o&&o.getNet()&&!o.isSelected())&&(h.netName=null);this.clipboard.push(h);this.copyWireSegmentConnections(s,e)}},u.prototype.copyComponentConnections=function(n,t){for(var f,i,u=t.getPins(),r=0;r<u.length;++r)f=u[r],i=f.getConnection(),i&&n.indexOf(i.getUniqName())==-1&&(n.push(i.getUniqName()),this.copyConnectionData(i))},u.prototype.copyWireSegmentConnections=function(n,t){for(var i,r=1;r<=2;++r)i=t.getConnection(r),i&&n.indexOf(i.getUniqName())==-1&&(n.push(i.getUniqName()),this.copyConnectionData(i))},u.prototype.copyConnectionData=function(n){var u,p,f,e,o,h,c,l,s,a,v,y;if(n){for(p=0,f=new t(n),u=0;u<n.getNumConnectedPins();++u)e=n.getPin(u),o=e.getComponent(),o.isSelected()&&(h=this.selectedSet.indexOf(o),c=e.getName(),l=new i(h,c),f.addConn(l));for(u=0;u<n.getNumConnectedWireSegments();++u)s=n.getWireSegment(u),s.isSelected()&&(a=this.selectedSet.indexOf(s),v=n.getWireSegmentEnd(u),y=new r(a,v),f.addConn(y));f.getNumConn()>1&&this.clipboard.push(f)}},u.prototype.pasteFromClipboard=function(){this.clonedSet=[];this.design.getConnMgr().disableFinalize();this.pasteComponentsWireSegments();this.pasteConnections();this.pasteCreateWiresNets();this.design.trackChanges(this.designChangeCB,this);this.design.getConnMgr().enableFinalize();this.design.getConnMgr().finalize();this.design.cancelTrackChanges()},u.prototype.designChangeCB=function(t,i,r){if(t.clonedSet&&(i instanceof n.Component||i instanceof BaseWire.WireSegment))if(r)t.clonedSet.push(i);else{var u=t.clonedSet.indexOf(i);u>=0&&t.clonedSet.splice(u,1)}},u.prototype.pasteComponentsWireSegments=function(){var r,i,u,e,t,o,f;for(this.wireSegNetNameMap={},this.busSegments={},r=0;r<this.clipboard.length;++r)i=this.clipboard[r],i instanceof n.ComponentCloneData?(u=i,e=new n.Component(this.design,u.dbComp,u.instName,null),e.restore(u),this.clonedSet.push(e)):i instanceof BaseWire.WireSegmentCloneData&&(t=i,o=t.busType==BaseWire.BUSTYPE.BUS,f=new BaseWire.WireSegment(this.design,t.seg,o,t.technology),this.clonedSet.push(f),(o||t.busType==BaseWire.BUSTYPE.BIT)&&(this.busSegments[f.getUniqName()]=t.busIndices),this.wireSegNetNameMap[f.getUniqName()]=t.netName)},u.prototype.pasteConnections=function(){for(var r,u,i,n=0;n<this.clipboard.length;++n)r=this.clipboard[n],r instanceof t&&(u=r,i=new BaseWire.Connection(this.design),i.moveTo(u.location),this.design.getConnMgr().manage(i),this.pasteConnectObjects(i,u))},u.prototype.pasteConnectObjects=function(t,u){for(var s,c,l,h,e,a,o=u.connArr,f=0;f<o.length;++f)o[f]instanceof i?(s=o[f],e=this.clonedSet[s.compIdx],e instanceof n.Component?(c=e,l=c.getPinByName(s.pinName),t.connectToPin(l)):console.log("Internal error - expected component in pasteConnectObjects")):o[f]instanceof r&&(h=o[f],e=this.clonedSet[h.wireSegIdx],e instanceof BaseWire.WireSegment?(a=e,t.connectToWireSegment(a,h.end)):console.log("Internal error - expected wire segment in pasteConnectObjects"))},u.prototype.pasteCreateWiresNets=function(){for(var s,t,n,u,f,e,o,i,h,r=0;r<this.clonedSet.length;++r)if(s=this.clonedSet[r],s instanceof BaseWire.WireSegment&&(t=s,!t.getWire())){for(n=new BaseWire.Wire(this.design),u=this.busSegments[t.getUniqName()],u&&(t.isBus()?n.setBusIndices(u):n.setBitIndex(u)),f=[],t.getConnectedWireSegments(f),e=0;e<f.length;++e)n.addWireSegment(f[e]);if(o=n.getForcedName(),o)n.setForcedNetName(),i=this.design.findNetByName(o),i?i.addWire(n):i=new BaseWire.Net(this.design,n,o);else{h=null;try{h=this.wireSegNetNameMap[t.getUniqName()]}catch(c){}i=new BaseWire.Net(this.design,n,h)}i.removeNametags()}},u.prototype.selectClonedSet=function(){var n,t;for(this.clearSelection(),n=0;n<this.clonedSet.length;++n)t=this.clonedSet[n],this.select(t,!1)},u.prototype.moveSelectedSet=function(t,i){for(var u,r=0;r<this.selectedSet.length;++r)u=this.selectedSet[r],(u instanceof n.Component||u instanceof BaseWire.WireSegment)&&u.dragRelative(t,i)},u.prototype.moveSelectedSetOnGrid=function(){for(var f,i,e,r,u=null,t=0;t<this.selectedSet.length;++t)if(i=this.selectedSet[t],i instanceof n.Component){f=i;u=f.getCenter();break}if(u==null)for(t=0;t<this.selectedSet.length;++t)if(i=this.selectedSet[t],i instanceof BaseWire.WireSegment){e=i;u=e.getExactEndLocation(1);break}return r=u.clone(),r.placeOnGrid(n.Settings.SCH_GRID_SPACING),r.subtract(u),this.moveSelectedSet(r.x,r.y),r},u.prototype.definePasteEvents=function(t,i,r){var u=this,e=this.design.getSurface(),f=this.design.getPaper().canvas;this.pasteActive=!0;this.design.getWireBar().disable();this.design.getSymbolBar().disable();$(f).bind("mousemove.pasteEvents",function(n){var r=e.screenToSch(n.pageX,n.pageY),i=r.clone();i.subtract(t);u.moveSelectedSet(i.x,i.y);t=r});$(document).bind("keydown.pasteEvents",function(t){t.which==n.Design.EscKey&&(u.pasteEventsComplete(),u.deleteSelection(!1),u.selectFromArray(i))});r?$(f).bind("mouseup.pasteEvents",function(){u.terminatePaste()}):$(f).bind("mousedown.pasteEvents",function(){u.terminatePaste()})},u.prototype.terminatePaste=function(){this.pasteEventsComplete();this.moveSelectedSetOnGrid();this.buildSelectedNetsNametags();this.design.getUndoManager().startUndoableCommand(n.PasteSelectionCommand,this.design,null);var t=this.getSingleSelectedComponent();t&&(t.tryToConnect(0,0),this.design.getConnMgr().finalize());this.design.getUndoManager().finishUndoableCommand(null)},u.prototype.pasteEventsComplete=function(){var n=this.design.getPaper().canvas;this.pasteActive=!1;$(n).unbind(".pasteEvents");$(document).unbind(".pasteEvents");this.design.getWireBar().enable();this.design.getSymbolBar().enable()},u.prototype.buildSelectedNetsNametags=function(){for(var i,u,n,r=[],t=0;t<this.clonedSet.length;++t)i=this.clonedSet[t],i instanceof BaseWire.WireSegment&&(u=i,n=u.getWire(),$.inArray(n.getName(),r)==-1&&(n.clearNametag(),n.initNametag(),n.buildNametag(),r.push(n.getName())))},u.prototype.selectFromArray=function(n){for(var t=0;t<n.length;++t)this.select(n[t],!1)},u.prototype.clearCopiedNames=function(){for(var t,r,u,i=0;i<this.clipboard.length;++i)t=this.clipboard[i],t instanceof n.ComponentCloneData?(r=t,r.instName=null):t instanceof BaseWire.WireSegmentCloneData&&(u=t,u.netName=null)},u}();n.SelectionManager=u;var f=function(){function n(n,t){this.wireSeg=n;this.conn=t}return n}(),e=function(){function n(n){this.wireSegsPins=[];this.conn=null;this.conn=n}return n.prototype.addPin=function(n){this.wireSegsPins.push(n)},n.prototype.addWireSeg=function(n){this.wireSegsPins.push(n)},n}(),t=function(){function n(n){this.location=n.getLocation();this.connArr=[]}return n.prototype.addConn=function(n){this.connArr.push(n)},n.prototype.getNumConn=function(){return this.connArr.length},n}(),i=function(){function n(n,t){this.compIdx=n;this.pinName=t}return n}(),r=function(){function n(n,t){this.wireSegIdx=n;this.end=t}return n}(),o=function(){function n(n,t){this.wireSeg=n;this.busIndices=t}return n}()}(Project||(Project={})),function(n){var i,t,r,u;(function(n){n[n.EDITABLE=0]="EDITABLE";n[n.DESIGN_EXPLORATION=1]="DESIGN_EXPLORATION";n[n.RESULTS_VIEWING=2]="RESULTS_VIEWING"})(n.EditingMode||(n.EditingMode={}));i=n.EditingMode,function(n){n[n.NOT_NEEDED=0]="NOT_NEEDED";n[n.SERVER_ERROR=1]="SERVER_ERROR";n[n.NEW_REVISION=2]="NEW_REVISION";n[n.UPDATED_REVISION=3]="UPDATED_REVISION";n[n.UPDATED_SIMULATION=4]="UPDATED_SIMULATION"}(n.DesignSavedState||(n.DesignSavedState={}));t=n.DesignSavedState,function(n){n[n.LOAD_OK=0]="LOAD_OK";n[n.LOAD_FAILED_CLEARING_DESIGN=1]="LOAD_FAILED_CLEARING_DESIGN";n[n.LOAD_FAILED_LOADING_DESIGN=2]="LOAD_FAILED_LOADING_DESIGN";n[n.LOAD_FAILED_MISSING_COMPONENT=3]="LOAD_FAILED_MISSING_COMPONENT";n[n.LOAD_FAILED_NO_SIMULATION_DATA=4]="LOAD_FAILED_NO_SIMULATION_DATA";n[n.LOAD_FAILED_PLOTTING_RESULTS=5]="LOAD_FAILED_PLOTTING_RESULTS"}(n.DesignLoadStatus||(n.DesignLoadStatus={}));r=n.DesignLoadStatus;u=function(){function u(n,t,r){this.containerID=null;this.sharedDesign=!1;this.schematicToolbar=null;this.symbolBar=null;this.propertyEditor=null;this.wireBar=null;this.ttipRect=null;this.prevScale=1;this.designNameChangeCallback=null;this.waitingOnSite=!1;this.simulationSidebar=null;this.editingMode=i.EDITABLE;this.BACKGROUND="schematicbackground";this.PAPER_WIDTH=12002;this.PAPER_HEIGHT=8002;this.loadingDesign=!1;this.msg="This design has unsaved changes.<br>Are you sure you want to continue without saving?";this.wheelZoomNow=!1;var u=jQuery.Deferred();addLoadingAppDeferred(u);this.surfaceDiv=$("#"+n);this.paper=Raphael(n,this.PAPER_WIDTH,this.PAPER_HEIGHT);this.drawBackground();this.showGrid();this.createTTipRect();this.defineInitialViewBox();(r==null||r==!0)&&(this.symbolBar=new Project.SymbolBar(this),this.wireBar=new Project.WireBar(this));this.createDesign();this.schematicToolbar=new Project.SchematicToolbar(this);this.defineEvents();typeof sharedDesignID!="undefined"&&sharedDesignID!=null&&sharedDesignID!=""?$.when(this.loadSharedDesign(sharedDesignID,u)).done(function(){u&&u.resolve()}):u.resolve();this.dlIFrameSchematic=$("<iframe>",{id:"idown",src:""}).hide().appendTo("body")}return u.prototype.getContainerID=function(){return this.containerID},u.prototype.setContainerID=function(n){this.containerID=n},u.prototype.getPaper=function(){return this.paper},u.prototype.getSurfaceAsJQuery=function(){return this.surfaceDiv},u.prototype.getDesign=function(){return this.design},u.prototype.isSharedDesign=function(){return this.sharedDesign},u.prototype.getSimulationSidebar=function(){return this.simulationSidebar},u.prototype.setSimulationSidebar=function(n){this.simulationSidebar=n},u.prototype.getComponentDataManager=function(){return this.componentDataManager},u.prototype.setComponentDataManager=function(n){this.componentDataManager=n},u.prototype.getComponentBrowserSidebar=function(){return this.componentBrowserSidebar},u.prototype.getFileSidebar=function(){return this.fileSidebar},u.prototype.setComponentBrowserSidebar=function(n){this.componentBrowserSidebar=n},u.prototype.setFileSidebar=function(n){this.fileSidebar=n},u.prototype.createPropertyEditor=function(){this.propertyEditor=new Project.PropertyEditor(this)},u.prototype.getPropertyEditor=function(){return this.propertyEditor||this.createPropertyEditor(),this.propertyEditor},u.prototype.getDlIFrameSchematic=function(){return this.dlIFrameSchematic},u.prototype.setEditingMode=function(n){this.editingMode=n;this.getSidebarManager()&&this.getSidebarManager().setEditingMode(n);this.schematicToolbar.setEditingMode(n)},u.prototype.getEditingMode=function(){return this.editingMode},u.prototype.isEditable=function(){return this.getEditingMode()==i.EDITABLE},u.prototype.updateDesignName=function(n){this.designNameChangeCallback!=null&&this.designNameChangeCallback(n)},u.prototype.updateDesignInfo=function(n,t,i){n&&n.length>0&&this.design.setName(n);t&&t.length>0&&i&&i.length>0&&(this.design.setLandingPageHost(t),this.design.setLandingPageURL(i));this.waitingOnSite&&(this.waitingOnSite=!1,this.shareDesignInternal())},u.prototype.registerDesignNameChangeCallback=function(n){this.designNameChangeCallback=n},u.prototype.isDesignDirty=function(){return this.getDesign()!=null&&this.getDesign().isDirty()},u.prototype.isLoadingDesign=function(){return this.loadingDesign},u.prototype.enableControls=function(n){n===void 0&&(n=!0);this.simulationSidebar!=null&&this.simulationSidebar.enableControls();n&&kendo.ui.progress($(MAIN_EDITOR),!1)},u.prototype.disableControls=function(n){n===void 0&&(n=!0);this.simulationSidebar!=null&&this.simulationSidebar.disableControls();n&&kendo.ui.progress($(MAIN_EDITOR),!0)},u.prototype.okToClearDesign=function(n){var t=jQuery.Deferred(),i;return n!=null&&n==!0||!this.isDesignDirty()?(t.resolve(!0),t.promise()):(i=new Project.MultiBtnModalDialog("Confirm",this.msg,["Yes","No"]),jQuery.when(i.queryUser()).done(function(n){t.resolve(n==Project.BUTTON.BTN1)}),t.promise())},u.prototype.clearDesign=function(n){var t=this,i=jQuery.Deferred();return $.when(this.okToClearDesign(n).done(function(n){n&&(t.paper.clear(),ProbeModule.getWaveBoxManager().removeAllWaveboxes(!1),Project.MessageManager.removeAllMessages(),t.drawBackground(),t.createTTipRect(),delete t.design,t.createDesign(),t.sidebarManager.clear(),t.defineInitialViewBox());i.resolve(n)})),i.promise()},u.prototype.clearFocus=function(){try{var n=document.activeElement;n.blur()}catch(t){}},u.prototype.loadDesign=function(n,t,i){var u=this,f=jQuery.Deferred();return $.when(this.clearDesign(i).done(function(i){i?(u.loadingDesign=!0,$.when(u.design.load(n,t)).done(function(n){u.sidebarManager.clear();u.isSharedDesign()||u.simulationSidebar.updateSimulationParameters();f.resolve(n);u.loadingDesign=!1})):f.resolve(r.LOAD_FAILED_CLEARING_DESIGN)})),f.promise()},u.prototype.initSharedDesign=function(){this.sharedDesign=!0;this.setEditingMode(n.EditingMode.RESULTS_VIEWING)},u.prototype.loadSharedDesign=function(n,t){var i=this,r=jQuery.Deferred();return this.loadingDesign=!0,this.initSharedDesign(),$.ajaxSetup({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID}}),$.ajax({url:Project.Settings.APIURI()+"/sharedDesigns?sharedID="+n,dataType:"json",type:"GET",contentType:"application/json;charset=utf-8",success:function(n){if(!n){Project.MessageManager.showErrorMessage("Could not find design");r.resolve();i.loadingDesign=!1;return}$.when(i.loadDesign(n,t,!0)).done(function(){i.showLandingPageButton();r.resolve();i.loadingDesign=!1})},error:function(n,t){t=surface.getAjaxErrorMessage(n,t);Project.MessageManager.showErrorMessage("Error: "+t);r.resolve();this.loadingDesign=!1}}),r.promise()},u.prototype.showLandingPageButton=function(){var t=this.design.getLandingPageHost(),f=this.design.getLandingPageURL(),i,e,r,n;f&&f.length!=0&&t&&t.length!=0&&((t=t.toLowerCase(),i=document.referrer,i||(i=""),e=Project.Utility.getHost(i).toLowerCase(),Project.Utility.isSameDomain(t,e)&&i.indexOf(e+"/design")==0&&(r=document.location,r&&r.ancestorOrigins&&r.ancestorOrigins.length==1))||(n=$(u.LANDING_PAGE_BUTTON),n.html('<a href="'+Project.Settings.WEBBASE+f+'" target="_blank" class="link_button no_select">View in systemvision.com<\/a>'),n.css({bottom:$(VIEWER_PANE).height()+u.LANDING_PAGE_BUTTON_OFFSET+"px",right:u.LANDING_PAGE_BUTTON_OFFSET+"px",display:"block"}),n.mousedown(function(){n.css({bottom:$(VIEWER_PANE).height()+u.LANDING_PAGE_BUTTON_OFFSET-2+"px",right:u.LANDING_PAGE_BUTTON_OFFSET-2+"px","box-shadow":"none"})}),n.mouseup(function(){n.css({bottom:$(VIEWER_PANE).height()+u.LANDING_PAGE_BUTTON_OFFSET+"px",right:u.LANDING_PAGE_BUTTON_OFFSET+"px","box-shadow":"5px 5px 15px -5px"})})))},u.prototype.updateLandingPageButton=function(){var n=$(u.LANDING_PAGE_BUTTON);n&&n.html()&&n.html().length!=0&&n.css("bottom",$(VIEWER_PANE).height()+u.LANDING_PAGE_BUTTON_OFFSET)},u.prototype.saveDesign=function(){if(!this.isEditable())return this.getNotNeededPromise();if(this.design.isMigrated())return this.design.clearMigrated(),this.createNewDesignRevision(!0);var t=this.design.getDirtyFlag(),n=this.design.getUserID()!=Project.Utility.getUserID();switch(t){case Project.DIRTY_FLAG.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS:return this.design.getDesignID().length==0||n||this.design.getSimulationData().hasResultData()?this.createNewDesignRevision():this.updateDesignRevision();case Project.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS:return n?this.createNewDesignRevision():this.updateDesignRevision();case Project.DIRTY_FLAG.DIRTY_WAVEBOX:case Project.DIRTY_FLAG.DIRTY_SIM_SETTINGS:return n?this.createNewDesignRevision():this.updateDesignSimulation();default:return this.getNotNeededPromise()}},u.prototype.getNotNeededPromise=function(){var n=jQuery.Deferred();return n.resolve(t.NOT_NEEDED),n.promise()},u.prototype.shareDesign=function(){var t=this,n;this.design.isEmpty()?Project.MessageManager.showWarningMessage("Cannot share an empty design"):(n=this.design.save(),n.done(function(){t.shareDesignInternal()}))},u.prototype.shareDesignInternal=function(){var n=this.design.getLandingPageHost(),t=this.design.getLandingPageURL(),i;n&&t?(i=new Project.ShareUrlDialog("Share Design","landingPageHost="+n+"&landingPageURL="+t),i.show()):this.waitingOnSite=!0},u.prototype.getBackgroundClass=function(){return"."+this.BACKGROUND},u.prototype.showGrid=function(n){if(n==null)this.showOptimalGrid(!0);else{var t=$(this.paper.canvas);n==u.GRID_ALL_LINES?(this.zoomIndex>-1?t.css("background-image",u.BACKGROUND_IMAGE_MAJOR_AND_MINOR_1):t.css("background-image",u.BACKGROUND_IMAGE_MAJOR_AND_MINOR_2),this.updateBackgroundImage()):n==u.GRID_MAJOR_LINES?(t.css("background-image",u.BACKGROUND_IMAGE_MAJOR_ONLY),this.updateBackgroundImage()):(n==u.GRID_OFF||n==u.GRID_FORCED_OFF)&&this.hideGrid();this.gridState=n}return this.gridState},u.prototype.hideGrid=function(){var t=this.gridState,n;return this.gridState=u.GRID_FORCED_OFF,n=$(this.paper.canvas),n.css("background-image",""),t},u.prototype.moveTTipRect=function(n,t){this.ttipRect.attr({x:n,y:t})},u.prototype.hideTTipRect=function(){this.ttipRect.hide()},u.prototype.showTTipRect=function(){this.ttipRect.show()},u.prototype.getTTipNode=function(){return this.ttipRect.node},u.prototype.elementToBack=function(n){n.toBack()},u.prototype.getViewBoxCorner=function(){return new BaseWire.Point(this.vboxX,this.vboxY)},u.prototype.isPointVisible=function(n,t){var i=n instanceof BaseWire.Point?n:new BaseWire.Point(n,t);var r=this.vboxX,u=this.vboxY,f=r+this.getDivWidth(),e=u+this.getDivHeight(!1);return i.x>r&&i.x<f&&i.y>u&&i.y<e?!0:!1},u.prototype.setCenter=function(n,t){var i;i=n instanceof BaseWire.Point?n:new BaseWire.Point(n,t);this.vboxX=i.x-this.getDivWidth()/2;this.vboxY=i.y-this.getDivHeight(!0)/2;this.setViewBox()},u.prototype.zoomToFit=function(n,t,i,r,f){var o,s,h,c,l,e;if(n){l=!0;$.isNumeric(n)?(o=n,h=t,s=i,c=r,f!=null&&f==!1&&(l=!1)):(e=n,o=e.x1,h=e.y1,s=e.x2,c=e.y2,t!=null&&t==!1&&(l=!1));var p=this.getSidebarManager(),v=this.getVisibleWidth(),y=this.getDivHeight(!1)-2*$(SCHEMATIC_TOOLBAR).height();var w=this.minZoomIdx(v,s-o),b=this.minZoomIdx(y,c-h),a=Math.min(w,b);l&&a>u.ZOOM_TO_FIT_MAX&&(a=u.ZOOM_TO_FIT_MAX);this.applyZoomIndex(a);this.vboxX=(o+s)/2-this.getScale()*(v/2);this.vboxX-=this.getScale()*p.getVisibleWidth(Sidebar.Orientation.LEFT);this.vboxY=(h+c)/2-this.getScale()*(y/2);this.vboxY-=this.getScale()*$(SCHEMATIC_TOOLBAR).height();this.zoomViewBox()}},u.prototype.getScale=function(){return this.scale},u.prototype.screenToSch=function(n,t){var i,r,u;return i=n instanceof BaseWire.Point?n:new BaseWire.Point(n,t),r=this.getSurfaceAsJQuery().offset(),i.subtract(r.left,r.top),i.scale(this.getScale()),u=this.getViewBoxCorner(),i.add(u),i},u.prototype.schToScreen=function(n,t){var i,u,r;return i=n instanceof BaseWire.Point?n.clone():new BaseWire.Point(n,t),u=this.getViewBoxCorner(),i.subtract(u),i.scale(1/this.getScale()),r=this.getSurfaceAsJQuery().offset(),i.add(r.left,r.top),i},u.prototype.getConnectionTolerance=function(){var n=this.getScale()*25;return n<10&&(n=10),n},u.prototype.setSidebarManager=function(n){this.sidebarManager=n},u.prototype.getSidebarManager=function(){return this.sidebarManager},u.prototype.drawBackground=function(){var r=this.paper.width,f=this.paper.height,n=this.paper.rect(0,0,r,f),t,i;n.attr("fill","#ff0000");n.attr("opacity","0");n.node.setAttribute("class",this.BACKGROUND);t=$(this.paper.canvas);t.css("background-image",u.BACKGROUND_IMAGE_MAJOR_AND_MINOR_1);i=u.BACKGROUND_IMAGE_SIZE+"px "+u.BACKGROUND_IMAGE_SIZE+"px";t.css("background-size",i)},u.prototype.showOptimalGrid=function(n){(n||this.gridState!=u.GRID_FORCED_OFF)&&(this.zoomIndex<-10?this.showGrid(u.GRID_MAJOR_LINES):this.showGrid(u.GRID_ALL_LINES))},u.prototype.createTTipRect=function(){this.ttipRect=this.paper.rect(0,0,1,1);this.ttipRect.attr("opacity","0");this.ttipRect.toBack()},u.prototype.createDesign=function(){this.design=new Project.Design(this,this.symbolBar,this.wireBar)},u.prototype.defineInitialViewBox=function(){this.vboxX=this.PAPER_WIDTH/2;this.vboxY=this.PAPER_HEIGHT/2;this.vboxWidth=this.PAPER_WIDTH;this.vboxHeight=this.PAPER_HEIGHT;this.zoomIndex=0;this.scale=1;this.prevScale=1;this.setViewBox()},u.prototype.nextZoomIndex=function(n){var t=this.zoomIndex;if(n>0){if(this.zoomIndex==u.ZOOM_MAX)return null;++t}else{if(this.zoomIndex==u.ZOOM_MIN)return null;--t}return t},u.prototype.minZoomIdx=function(n,t){for(var e=t/n,r=u.SCALE_ARRAY.length,f=r,i=r-1;i>=0;--i)if(u.SCALE_ARRAY[i]>=e){f=i;break}return f-u.SCALE_ZOOM_INDEX_OFFSET},u.prototype.wheelZoom=function(n,t){Project.Pin.hideLabels();ProbeModule.getWaveBoxManager().enableResizingMode();var i=Project.Utility.getOffsets(this.getSurfaceAsJQuery(),n),r=i.offsetX,u=i.offsetY;this.wheelZoomNow=!0;this.zoom(r,u,t)},u.prototype.buttonZoom=function(n){var t=this.getDivWidth()/2,i=this.getDivHeight(!1)/2;this.zoom(t,i,n)},u.prototype.updateBackgroundImage=function(){var t=$(this.paper.canvas),n=u.SCALED_IMAGE_SIZES[this.zoomIndex+u.SCALE_ZOOM_INDEX_OFFSET],r=n+"px "+n+"px";t.css("background-size",r);var i=this.getScale(),f=-1*(this.vboxX/i%n),e=-1*(this.vboxY/i%n),o=f+"px "+e+"px";t.css("background-position",o)},u.prototype.areNametagsReadable=function(){return this.zoomIndex>=u.LOWEST_READABLE_ZOOM_INDEX},u.prototype.zoom=function(n,t,i){var y=this.nextZoomIndex(i),r,c,e,l,s,a,f,h,v,o,p,w;if(y!=null){if(this.applyZoomIndex(y),this.zoomIndex==u.LOWEST_READABLE_ZOOM_INDEX-1){for(r=0,c=this.design.getCompArray();r<c.length;r++)f=c[r],f.removeNametag();for(e=0,l=this.design.getNetArray();e<l.length;e++)o=l[e],o.removeNametags()}else if(this.zoomIndex==u.LOWEST_READABLE_ZOOM_INDEX){for(s=0,a=this.design.getCompArray();s<a.length;s++)f=a[s],f.buildNametag();for(h=0,v=this.design.getNetArray();h<v.length;h++)o=v[h],o.buildNametags()}p=n*(this.prevScale-this.getScale());w=t*(this.prevScale-this.getScale());this.zoomViewBox(p,w)}},u.prototype.zoomViewBox=function(n,t){this.setViewBox(n,t,!1);this.showOptimalGrid(!1)},u.prototype.applyZoomIndex=function(n){this.prevScale=this.getScale();this.zoomIndex=n;this.scale=u.SCALE_ARRAY[this.zoomIndex+u.SCALE_ZOOM_INDEX_OFFSET];this.vboxWidth=this.PAPER_WIDTH*this.getScale();this.vboxHeight=this.PAPER_HEIGHT*this.getScale()},u.prototype.setViewBox=function(n,t,i){var f,e,r,u,o,s;i===void 0&&(i=!0);f=this.vboxX;e=this.vboxY;n!=null&&t!=null&&(this.vboxX+=n,this.vboxY+=t);this.vboxX<0?this.vboxX=0:(r=this.PAPER_WIDTH-this.getScale()*this.getDivWidth(),this.vboxX>r&&(this.vboxX=r));this.vboxY<0?this.vboxY=0:(u=this.PAPER_HEIGHT-this.getScale()*this.getDivHeight(!0),this.vboxY>u&&(this.vboxY=u));this.paper.setViewBox(this.vboxX,this.vboxY,this.vboxWidth,this.vboxHeight,!1);i?(o=(f-this.vboxX)/this.getScale(),s=(e-this.vboxY)/this.getScale(),ProbeModule.getWaveBoxManager().updateWaveboxesByPan(o,s)):ProbeModule.getWaveBoxManager().updateWaveboxesByZoom(this.prevScale,this.getScale());this.updateBackgroundImage()},u.prototype.mouseDrag=function(n){var r=Project.Utility.getOffsets(this.getSurfaceAsJQuery(),n),t=r.offsetX,i=r.offsetY,e=n.pageX,o=n.pageY,s=Math.abs(e-t),h=Math.abs(o-i),u,f;s>200||h>200||(u=(this.dragInitialPosX-t)*(this.vboxWidth/this.PAPER_WIDTH),f=(this.dragInitialPosY-i)*(this.vboxHeight/this.PAPER_HEIGHT),this.setViewBox(u,f),this.dragInitialPosX=t,this.dragInitialPosY=i)},u.prototype.getDivWidth=function(){var n=$(SCHEMATIC_PANE).width();return n>=this.PAPER_WIDTH&&(n=500),n},u.prototype.getDivHeight=function(n){var t=$(SCHEMATIC_PANE).height();return t==0?t=$(window).height():n&&(t+=$(VIEWER_PANE).height()),t>=this.PAPER_HEIGHT&&(t=500),t},u.prototype.getVisibleWidth=function(){var n=this.getSidebarManager();return this.getDivWidth()-n.getVisibleWidth(Sidebar.Orientation.LEFT)-n.getVisibleWidth(Sidebar.Orientation.RIGHT)},u.prototype.getVisibleHeight=function(){var n=$(window).height();return this.splitterHeight||(this.splitterHeight=$(MAIN_EDITOR).find(".k-splitbar-vertical").outerHeight()),WaveViewer.getManager().getChildBrowserWindow()==null&&(n-=getViewerWin().getViewerWindowHeight()+this.splitterHeight),n},u.prototype.getWheelTimeout=function(){return Project.Utility.isIE()?2e3:1e3},u.prototype.defineEvents=function(){var i=this,t=$(this.paper.canvas.parentNode),r=this,u=this.getWheelTimeout(),n;t.mousewheel(function(n,t){clearTimeout($.data(this,"timer"));$.data(this,"timer",setTimeout(function(){ProbeModule.getWaveBoxManager().disableResizingMode();r.wheelZoomNow=!1;ProbeModule.getWaveBoxManager().updateWaveboxesAfterZoom()},u));r.wheelZoom(n,t);n.preventDefault()});t.mousedown(function(n){(n.preventDefault(),Messaging.Handler.sendSetFocusMessage(),WaveViewer.SVWEventHandler.getIsMoving())||(n.ctrlKey||n.shiftKey?i.getDesign().areaSelect(t,n):i.pan(t,n))});n=document;n.onfullscreenchange=function(){surface.fullscreenHandler()};n.onwebkitfullscreenchange=function(){surface.fullscreenHandler()};n.onmozfullscreenchange=function(){surface.fullscreenHandler()};n.onmsfullscreenchange=function(){surface.fullscreenHandler()}},u.prototype.pan=function(n,t){var i=this,r=!1,u=Project.Utility.getOffsets(n,t);this.dragInitialPosX=u.offsetX;this.dragInitialPosY=u.offsetY;setBodyCursor("move");$(document).bind("mousemove.panEvents",function(t){(t.ctrlKey||t.shiftKey)&&($(document).unbind(".panEvents"),i.getDesign().areaSelect(n,t));r||(i.getDesign().getWireBar().disable(),i.getDesign().getSymbolBar().disable(),r=!0,i.getDesign().disableHoverEvents());i.mouseDrag(t)});$(document).bind("mouseup.panEvents",function(){$(document).unbind(".panEvents");r&&(i.getDesign().getWireBar().enable(),i.getDesign().getSymbolBar().enable(),r=!1);i.getDesign().enableHoverEvents();setBodyCursor("default")})},u.prototype.createNewDesignRevision=function(n){var r=this,u,i,f;return n===void 0&&(n=!1),u=jQuery.Deferred(),ProbeModule.getWaveBoxManager().setResetMode(),n||this.design.getDesignID()==""||this.design.getSimulationData().cleanSimulations(),i=this.design.getSaveData(),ProbeModule.getWaveBoxManager().clearResetMode(),i.UserID=Project.Utility.getUserID(),i.DesignID=this.design.getDesignID(),i.RevisionID=this.design.getRevisionID(),f=Project.Settings.APIURI()+"/designs",this.containerID!=null&&(f+="?containerID="+this.containerID),$.ajax({url:f,dataType:"json",contentType:"application/json;charset=utf-8",type:"POST",data:JSON.stringify(i),headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID},success:function(n){r.design.setDesignID(n.DesignID);r.design.setRevisionID(n.RevisionID);r.design.setUserID(Project.Utility.getUserID());r.design.clearDirty();u.resolve(t.NEW_REVISION)},error:function(n,i){i=surface.getAjaxErrorMessage(n,i);Project.MessageManager.showErrorMessage("Error: "+i);u.resolve(t.SERVER_ERROR)}}),u.promise()},u.prototype.updateDesignRevision=function(){var u=this,i=jQuery.Deferred(),n=this.design.getSaveData(),r;return n.UserID=Project.Utility.getUserID(),n.DesignID=this.design.getDesignID(),n.RevisionID=this.design.getRevisionID(),r=Project.Settings.APIURI()+"/designs",this.containerID!=null&&(r+="?containerID="+this.containerID),$.ajax({url:r,dataType:"json",contentType:"application/json;charset=utf-8",type:"PUT",data:JSON.stringify(n),headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID},success:function(){u.design.clearDirty();i.resolve(t.UPDATED_REVISION)},error:function(n,r){r=surface.getAjaxErrorMessage(n,r);Project.MessageManager.showErrorMessage("Error: "+r);i.resolve(t.SERVER_ERROR)}}),i.promise()},u.prototype.updateDesignSimulation=function(){var i=this,n=jQuery.Deferred();return $.ajax(Project.Settings.APIURI()+"/designs?designID="+this.design.getDesignID()+"&revisionID="+this.design.getRevisionID(),{dataType:"json",contentType:"application/json;charset=utf-8",type:"PUT",data:JSON.stringify(this.design.getSaveSimulationData()),headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID},success:function(){i.design.clearDirty();n.resolve(t.UPDATED_SIMULATION)},error:function(i,r){r=surface.getAjaxErrorMessage(i,r);Project.MessageManager.showErrorMessage("Error: "+r);n.resolve(t.SERVER_ERROR)}}),n.promise()},u.prototype.getAjaxErrorMessage=function(n,t){try{var i=JSON.parse(n.responseText);return i?i.Message&&i.Message.length>0?i.Message:t:t}catch(r){return n&&n.statusText&&n.statusText.length>0?n.statusText:t}},u.prototype.toggleFullscreen=function(){var n=document.getElementById("sv-app")||document.body,t=document,i;this.isFullScreen()?document.exitFullscreen?document.exitFullscreen():t.msExitFullscreen?t.msExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():document.webkitExitFullscreen&&t.webkitExitFullscreen():(i=n.requestFullScreen||n.webkitRequestFullScreen||n.mozRequestFullScreen||n.msRequestFullscreen,i.call(n))},u.prototype.fullscreenHandler=function(){var t=this,n;this.isFullScreen()?this.schematicToolbar.fullscreenIconOn():this.schematicToolbar.fullscreenIconOff();n=Project.Utility.isIE()?800:200;setTimeout(function(){t.storePinStateAndZoomToFit()},n)},u.prototype.isFullScreen=function(){var n=document;return n.fullscreenElement||n.msFullscreenElement||n.mozFullScreen||n.webkitIsFullScreen},u.prototype.storePinStateAndZoomToFit=function(){var n=ProbeModule.getWaveBoxManager().storePinState();this.zoomToFit(this.getDesign().getBoundingRect())},u.ComputeScaleArray=function(n){for(var r=n.length,i=[],t=0;t<r;++t)i[t]=u.BACKGROUND_IMAGE_SIZE/n[t];return i},u.SELECTION_COLOR="#ccff66",u.CROSS_HIGHLIGHT_COLOR="#3fe224",u.WARNING_HIGHLIGHT_COLOR="#ff8888",u.ERROR_HIGHLIGHT_COLOR="#ffdede",u.TTIP_DELAY=500,u.ZOOM_TO_FIT_MAX=7,u.LOWEST_READABLE_ZOOM_INDEX=-7,u.BACKGROUND_IMAGE_MAJOR_AND_MINOR_1="url(/Content/images/grid_100X100.png)",u.BACKGROUND_IMAGE_MAJOR_AND_MINOR_2="url(/Content/images/grid_60X60.png)",u.BACKGROUND_IMAGE_MAJOR_ONLY="url(/Content/images/grid_50X50_no_minor_lines.png)",u.BACKGROUND_IMAGE_SIZE=50,u.SCALED_IMAGE_SIZES=[20,21,22,23,24,25,26,28,30,32,34,36,38,41,45,50,55,62,71,83,100,140,190,250,350],u.SCALE_ARRAY=u.ComputeScaleArray(u.SCALED_IMAGE_SIZES),u.SCALE_ZOOM_INDEX_OFFSET=15,u.ZOOM_MIN=-u.SCALE_ZOOM_INDEX_OFFSET,u.ZOOM_MAX=u.SCALED_IMAGE_SIZES.length-u.SCALE_ZOOM_INDEX_OFFSET-1,u.GRID_FORCED_OFF=0,u.GRID_OFF=1,u.GRID_MAJOR_LINES=2,u.GRID_ALL_LINES=3,u.LANDING_PAGE_BUTTON="#landing_page_button",u.LANDING_PAGE_BUTTON_OFFSET=15,u}();n.Surface=u}(Schematic||(Schematic={})),function(n){var i=function(){function i(n){this.surface=n;this.toolbar=new t($(SCHEMATIC_TOOLBAR));this.defineEvents();this.init();var r=new ProbeModule.ProbeButton(n,i.WAVEBOX_BUTTON)}return i.prototype.setEditingMode=function(n){n==Schematic.EditingMode.RESULTS_VIEWING?($(i.SAVE_BUTTON).hide(),$(i.UNDO_BUTTON).hide(),$(i.REDO_BUTTON).hide()):($(i.SAVE_BUTTON).show(),$(i.UNDO_BUTTON).show(),$(i.REDO_BUTTON).show())},i.prototype.init=function(){n.Utility.setTooltip(i.DEVELOPERS_BUTTON,"Developers' Tools");n.Utility.setTooltip(i.SAVE_BUTTON,"Save");n.Utility.setTooltip(i.NAMETAGS_BUTTON,this.getNametagTooltipText());n.Utility.setTooltip(i.UNDO_BUTTON,"Undo");n.Utility.setTooltip(i.REDO_BUTTON,"Redo");n.Utility.setTooltip(i.ZOOM_IN_BUTTON,"Zoom In");n.Utility.setTooltip(i.ZOOM_OUT_BUTTON,"Zoom Out");n.Utility.setTooltip(i.ZOOM_FIT_BUTTON,"Zoom To Fit");n.Utility.setTooltip(i.WAVEBOX_BUTTON,"Create a Wavebox");n.Utility.setTooltip(i.SHARE_BUTTON,"Share Design");n.Utility.setTooltip(i.FS_BUTTON,"Enter Fullscreen Mode");n.Utility.setTooltip(i.APP_HELP_BUTTON,"Show Help Dialog");n.Settings.isProductionMode()&&$(i.DEVELOPERS_BUTTON).hide();this.toolbar.getElement().show()},i.prototype.getNametagTooltipText=function(){var i=this.surface.getDesign().getNametagVisibility(),t;switch(i){case n.NAMETAG_VISIBILITY.NONE:t="No";break;case n.NAMETAG_VISIBILITY.CHOSEN:t="Chosen";break;case n.NAMETAG_VISIBILITY.ALL:t="All"}return t+" Labels Visible"},i.prototype.defineEvents=function(){var t=this;this.toolbar.defineEvents();$(i.DEVELOPERS_BUTTON).click(function(){var n=t.surface.getSidebarManager();n.openSidebarByName(FILE_SIDEBAR_ID)});$(i.SAVE_BUTTON).click(function(){t.surface.getDesign().save()});$(i.NAMETAGS_BUTTON).click(function(){t.surface.getDesign().updateNametagVisibility();n.Utility.setTooltip(i.NAMETAGS_BUTTON,t.getNametagTooltipText())});$(i.UNDO_BUTTON).click(function(){t.surface.getDesign().undo()});$(i.REDO_BUTTON).click(function(){t.surface.getDesign().redo()});$(i.ZOOM_IN_BUTTON).click(function(){t.surface.buttonZoom(1)});$(i.ZOOM_OUT_BUTTON).click(function(){t.surface.buttonZoom(-1)});$(i.ZOOM_FIT_BUTTON).click(function(){t.surface.storePinStateAndZoomToFit()});$(i.SHARE_BUTTON).click(function(){t.surface.shareDesign();n.Settings.notify("design shared")});$(i.FS_BUTTON).click(function(){t.surface.toggleFullscreen()});$(i.APP_HELP_BUTTON).click(function(){var t=new n.AppViewHelp;t.initMainBrowser()})},i.prototype.fullscreenIconOn=function(){var t=$(i.FS_BUTTON).children().children()[0];$(t).attr("src",i.FULLSCREEN_ICON_ON);n.Utility.setTooltip(i.FS_BUTTON,"Exit Fullscreen Mode")},i.prototype.fullscreenIconOff=function(){var t=$(i.FS_BUTTON).children().children()[0];$(t).attr("src",i.FULLSCREEN_ICON_OFF);n.Utility.setTooltip(i.FS_BUTTON,"Enter Fullscreen Mode")},i.DEVELOPERS_BUTTON="#developers_button",i.SAVE_BUTTON="#save_button",i.NAMETAGS_BUTTON="#nametags_button",i.UNDO_BUTTON="#undo_button",i.REDO_BUTTON="#redo_button",i.ZOOM_IN_BUTTON="#zoom_in_button",i.ZOOM_OUT_BUTTON="#zoom_out_button",i.ZOOM_FIT_BUTTON="#zoom_fit_button",i.WAVEBOX_BUTTON="#wavebox_button",i.SHARE_BUTTON="#share_button",i.FS_BUTTON="#fs_button",i.APP_HELP_BUTTON="#app_help_button",i.FULLSCREEN_ICON_ON="/Content/images/fullscreen-on.png",i.FULLSCREEN_ICON_OFF="/Content/images/fullscreen-off.png",i.ICON_WIDTH=30,i}(),t;n.SchematicToolbar=i;t=function(){function n(n){this.element=n}return n.prototype.getElement=function(){return this.element},n.prototype.fadeIn=function(){this.element.stop().animate({opacity:n.FADE_IN_OPACITY},300)},n.prototype.fadeOut=function(){this.element.stop().animate({opacity:n.FADE_OUT_OPACITY},300)},n.prototype.defineEvents=function(){var n=this;this.element.bind("click",function(){Messaging.Handler.sendSetFocusMessage()});this.element.bind("mouseenter",function(){n.fadeIn()});this.element.bind("mouseleave",function(){n.fadeOut()})},n.prototype.undefineEvents=function(){this.element.css("opacity",n.FADE_OUT_OPACITY);this.element.unbind("mouseeenter mouseleave")},n.prototype.reset=function(n,t){this.element.css(n,t);this.fadeOut();this.defineEvents()},n.FADE_IN_OPACITY=.8,n.FADE_OUT_OPACITY=.4,n}();n.FadingElement=t}(Project||(Project={})),function(n){var e,o,s,h,i,r,u,t,c,f;(function(n){n[n.Signal=0]="Signal";n[n.Quantity=1]="Quantity";n[n.Terminal=2]="Terminal"})(n.PinType||(n.PinType={}));e=n.PinType,function(n){n[n.In=0]="In";n[n.Out=1]="Out";n[n.Inout=2]="Inout";n[n.None=3]="None"}(n.PinMode||(n.PinMode={}));o=n.PinMode,function(n){n[n.North=0]="North";n[n.South=1]="South";n[n.East=2]="East";n[n.West=3]="West"}(n.PinOrientation||(n.PinOrientation={}));s=n.PinOrientation,function(n){n[n.NONE=0]="NONE";n[n.VALUE=1]="VALUE";n[n.ALL=2]="ALL"}(n.PROPERTY_VISIBILITY||(n.PROPERTY_VISIBILITY={}));h=n.PROPERTY_VISIBILITY;i=function(){function n(){}return n}();n.Revision=i;r=function(){function t(){}return t.getLib=function(t){return t.Lib=="Work"?n.ComponentDataManager.USER_LIB:t.Lib},t}();n.ComponentVhdlDto=r;u=function(){function n(){}return n}();n.CompPin=u;t=function(){function n(n){var t,u,r,f,i;if(this.visibleValues=[],this.enabledValues=[],n){if(n.name!=null&&(this.name=n.name),n.visibleValues!=null)for(t=0,u=n.visibleValues;t<u.length;t++)i=u[t],this.visibleValues.push(i);if(n.enabledValues!=null)for(r=0,f=n.enabledValues;r<f.length;r++)i=f[r],this.enabledValues.push(i)}}return n}();n.CompPropertyMetadataChild=t,function(n){n[n.MAGNITUDE=0]="MAGNITUDE";n[n.PHASE=1]="PHASE"}(n.AC_PROPERTY||(n.AC_PROPERTY={}));c=n.AC_PROPERTY;f=function(){function n(n){var i,u,o,r,f,e;if(this.displayName=null,this.displayVisibility=!0,this.tooltip=null,this.parents=[],this.children=[],this.flipDisplayValue=!1,this.radioDisplayValues={},this.gridName=null,this.gridColumn=null,this.monoIncreasing=!1,this.firstValueReadOnly=!1,this.acProperty=null,n){if(n.displayName!=null&&(this.displayName=n.displayName),n.displayVisibility!=null&&(this.displayVisibility=n.displayVisibility),n.tooltip!=null&&(this.tooltip=n.tooltip),n.parents!=null&&(this.parents=n.parents),n.children!=null)for(i=0,u=n.children;i<u.length;i++)o=u[i],this.children.push(new t(o));if(n.flipDisplayValue!=null&&(this.flipDisplayValue=n.flipDisplayValue),n.radioDisplayValues!=null)for(r=0,f=n.radioDisplayValues;r<f.length;r++)e=f[r],this.radioDisplayValues[e.value]=e.displayValue;n.gridName!=null&&(this.gridName=n.gridName);n.gridColumn!=null&&(this.gridColumn=n.gridColumn);n.monoIncreasing!=null&&(this.monoIncreasing=n.monoIncreasing);n.firstValueReadOnly!=null&&(this.firstValueReadOnly=n.firstValueReadOnly);n.acProperty!=null&&(this.acProperty=n.acProperty)}}return n}();n.CompPropertyMetadata=f}(Project||(Project={})),function(n){var r=function(){function t(){}return t.create=function(i,r){var f=r.getLibrary()==n.ComponentDataManager.SVWEB_LIB&&(r.getTitle()=="Magnetic Core"||r.getTitle().indexOf("Function Generator")!=-1),u=t.validator.GetPropertyType(i.Type.toLowerCase());return n.BooleanCompProperty.isCorrectType(u)?new n.BooleanCompProperty(i,r):n.RadioCompProperty.isCorrectType(u)?f?new n.RadioCompProperty(i,r):new n.NumberCompProperty(i,r):n.TableCompProperty.isCorrectType(u)?new n.TableCompProperty(i,r):new n.NumberCompProperty(i,r)},t.validator=new n.PropertyFormatter,t}(),t,i;n.CompPropertyFactory=r;t=function(){function n(n,t,i){this.property=n;this.visibleValues=t;this.enabledValues=i}return n}();i=function(){function i(t,i){t===void 0&&(t=null);i===void 0&&(i=null);this.parents=[];this.children=[];this.instValue=null;t&&(this.Id=t.Id,this.Name=t.Name,this.Description=t.Description,this.Type=t.Type,this.Typical=n.Utility.getPropTypFromMinTypMax(t),this.PropVisibility=t.PropVisibility,this.Metadata=t.Metadata);this.comp=i}return i.prototype.getHtml=function(){return null},i.prototype.getElementValue=function(){return null},i.prototype.setElementValue=function(){},i.prototype.validate=function(n){return n===void 0&&(n=!0),null},i.prototype.setValueOnClose=function(){return!1},i.prototype.getDisplayName=function(){return this.Metadata&&this.Metadata.displayName?this.Metadata.displayName:this.Name.toUpperCase()},i.prototype.getDisplayVisibility=function(){return!this.Metadata||this.Metadata&&this.Metadata.displayVisibility},i.prototype.getElement=function(){return $(n.PropertyEditor.PROP_PREFIX+this.Name)},i.prototype.getSelectableElement=function(){return this.getElement()},i.prototype.getDivElement=function(){return $(n.PropertyEditor.PROP_DIV_PREFIX+this.Name)},i.prototype.getVisibilityElement=function(){return $(n.PropertyEditor.PROP_VISIBILITY_PREFIX+this.Name)},i.prototype.setParentsAndChildren=function(n){var i=this;this.Metadata&&this.Metadata.children&&(this.Metadata.children.forEach(function(r){for(var u=0;u<n.length;++u)r.name==n[u].Name&&i.children.push(new t(n[u],r.visibleValues,r.enabledValues))}),this.Metadata.parents.forEach(function(t){for(var r=0;r<n.length;++r)t==n[r].Name&&i.parents.push(n[r])}))},i.prototype.defineEvents=function(){var n=this;this.getVisibilityElement().on("click",function(t){n.setVisibility(t)})},i.prototype.getVisibility=function(){switch(this.getVisibilityElement().attr("src")){case n.PropertyEditor.VISIBILITY_VALUE_ICON:return n.PROPERTY_VISIBILITY.VALUE;case n.PropertyEditor.VISIBILITY_ALL_ICON:return n.PROPERTY_VISIBILITY.ALL;default:return n.PROPERTY_VISIBILITY.NONE}},i.prototype.getVisibilityIcon=function(){switch(this.PropVisibility){case n.PROPERTY_VISIBILITY.VALUE:return n.PropertyEditor.VISIBILITY_VALUE_ICON;case n.PROPERTY_VISIBILITY.ALL:return n.PropertyEditor.VISIBILITY_ALL_ICON;default:return n.PropertyEditor.VISIBILITY_NONE_ICON}},i.prototype.setVisibility=function(t){var i="#"+t.currentTarget.id,r=this.getValue();switch(this.PropVisibility){case n.PROPERTY_VISIBILITY.VALUE:this.PropVisibility=n.PROPERTY_VISIBILITY.ALL;this.comp.setInstProp(this.Name,r,n.PROPERTY_VISIBILITY.ALL);$(i).attr("src",n.PropertyEditor.VISIBILITY_ALL_ICON);break;case n.PROPERTY_VISIBILITY.ALL:this.PropVisibility=n.PROPERTY_VISIBILITY.NONE;this.comp.setInstProp(this.Name,r,n.PROPERTY_VISIBILITY.NONE);$(i).attr("src",n.PropertyEditor.VISIBILITY_NONE_ICON);break;default:this.PropVisibility=n.PROPERTY_VISIBILITY.VALUE;this.comp.setInstProp(this.Name,r,n.PROPERTY_VISIBILITY.VALUE);$(i).attr("src",n.PropertyEditor.VISIBILITY_VALUE_ICON)}},i.prototype.setInstValue=function(n){this.instValue=n;this.setExtraParentInstValue()},i.prototype.getValue=function(){return this.instValue==null?this.Typical.toLowerCase():this.instValue},i.prototype.setValue=function(t,i){var u,r,f;i===void 0&&(i=!0);t!=this.instValue&&this.validate()&&(u=new n.PropertyData(this.comp.getInstName(),this.Name,this.instValue),r=surface.getDesign().getUndoManager(),i&&r.startUndoableCommand(n.UpdatePropertyCommand,this.comp.getDesign(),u),f=this.getVisibility(),this.instValue=t,this.comp.setInstProp(this.Name,t,f),i&&r.finishUndoableCommand(t))},i.prototype.setExtraParentInstValue=function(){if(this.Metadata&&this.Metadata.acProperty==n.AC_PROPERTY.MAGNITUDE){var t=this.comp.getACCheckbox();t.setInstValue(this.instValue=="0.0"?"false":"true")}},i.prototype.setExtraParentElementValue=function(){if(this.Metadata&&this.Metadata.acProperty==n.AC_PROPERTY.MAGNITUDE){var t=this.comp.getACCheckbox();t.setElementValue(this.instValue=="0.0"?"false":"true")}},i.prototype.finishSetElementValue=function(){this.children.forEach(function(n){n.property.setPropEnabled(n.property.shouldBeEnabled());n.property.setPropVisible(n.property.shouldBeVisible())});this.setExtraParentElementValue();surface.getPropertyEditor().adjustTopAndHeight();this.comp.buildNametag()},i.prototype.isChildVisible=function(n){for(var t=0;t<this.children.length;++t)if(n.Name==this.children[t].property.Name)return this.children[t].visibleValues.length==0||$.inArray(this.getValue(),this.children[t].visibleValues)!=-1;return!0},i.prototype.shouldBeVisible=function(){var t=this,n=!0;return this.parents.forEach(function(i){if(!i.isChildVisible(t)){n=!1;return}}),n},i.prototype.setPropVisible=function(n){var t=this.getDivElement();n?t.show():t.hide()},i.prototype.isChildEnabled=function(n){for(var t=0;t<this.children.length;++t)if(n.Name==this.children[t].property.Name)return this.children[t].enabledValues.length==0||$.inArray(this.getValue(),this.children[t].enabledValues)!=-1;return!0},i.prototype.shouldBeEnabled=function(){var t=this,n=!0;return this.parents.forEach(function(i){if(!i.isChildEnabled(t)){n=!1;return}}),n},i.prototype.setPropEnabled=function(n){this.getElement().prop("disabled",!n)},i.prototype.setDefaultTooltip=function(){var t,n;t=this.Metadata&&this.Metadata.tooltip?this.Metadata.tooltip:this.Description;n=this.getDivElement();n.qtip("destroy");n.qtip({content:t,style:{classes:"svw-tooltip"}});n.removeClass("has-error")},i.prototype.showErrorTooltip=function(n){var t=this.getDivElement();t.qtip("destroy");t.qtip({content:n,style:{classes:"svw-tooltip"}});t.qtip("show");t.addClass("has-error")},i.validator=new n.PropertyFormatter,i}();n.CompProperty=i}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){n===void 0&&(n=null);i===void 0&&(i=null);t.call(this,n,i)}return __extends(i,t),i.isCorrectType=function(n){return n=="boolean"},i.prototype.getHtml=function(){var r=this.getVisibilityIcon(),i=this.getValueWithFlip(),t='<div id="'+n.PropertyEditor.PROP_DIV_PREFIX_ID+this.Name+'" class="input-group input input-group-sm" style="width: 100%; padding-top: 10px; height: 18px;';return this.shouldBeVisible()||(t+=" display: none;"),t+='"><label><input id="'+n.PropertyEditor.PROP_PREFIX_ID+this.Name+'" name="'+n.PropertyEditor.PROP_PREFIX_ID+this.Name+'" type="checkbox" class="prop_editor_checkbox '+n.PropertyEditor.PROP_EDITOR_VALUE_CLASS+'" style="width: 18px; margin: 0" value="'+this.getValue()+'" ',i=="true"&&(t+="checked "),t+='><img id="'+n.PropertyEditor.PROP_PREFIX_ID+this.Name+'_img" src="'+this.getImgSrc(i)+'" tabindex="0"><\/label><span class="prop_editor_text" style="padding-left: 5px">'+this.getDisplayName()+"<\/span>",this.getDisplayVisibility()&&(t+='<span class="input-group-addon prop_editor_label" style="width: 18px; height: 18px !important; border-left: 1px solid #cccccc; border-radius: 3px; float: right"><img src="'+r+'" style="opacity: 0.8" class="visibility_icon" id="'+n.PropertyEditor.PROP_VISIBILITY_PREFIX_ID+this.Name+'"><\/span>'),t+"<\/div>"},i.prototype.getImgSrc=function(n){var t=surface.isEditable();return n=="true"?t?i.CHECKED_IMG:i.CHECKED_GREY_IMG:t?i.DEFAULT_IMG:i.DEFAULT_GREY_IMG},i.prototype.getSelectableElement=function(){return $(n.PropertyEditor.PROP_PREFIX+this.Name).next()},i.prototype.getElementValue=function(){return this.getElementValueBoolean()?"true":"false"},i.prototype.setElementValue=function(n){var t,i,r;n||(n=this.Typical.toLowerCase());this.instValue=n;t=n;this.Metadata&&this.Metadata.flipDisplayValue&&(t=n=="true"?"false":"true");i=t=="true"?!0:!1;r=this.getSelectableElement();r.attr("src",this.getImgSrc(t));this.getElement().prop("checked",i);this.finishSetElementValue()},i.prototype.getElementValueBoolean=function(){return this.getElement().attr("checked")!=undefined},i.prototype.getElementValueWithFlip=function(){var n=this.getElementValue();return!this.Metadata||!this.Metadata.flipDisplayValue?n:n=="true"?"false":"true"},i.prototype.getValueWithFlip=function(){var n=this.getValue();return!this.Metadata||!this.Metadata.flipDisplayValue?n:n=="true"?"false":"true"},i.prototype.getToggledValue=function(){return this.getValueWithFlip()=="true"?"false":"true"},i.prototype.validate=function(){return!0},i.prototype.defineEvents=function(){t.prototype.defineEvents.call(this);var i=this;if(surface.isEditable()){this.getSelectableElement().on("click",function(){i.setValue(i.getToggledValue())});this.getSelectableElement().on("keyup",function(t){t.which==n.Design.SpaceKey&&i.setValue(i.getToggledValue())})}},i.DEFAULT_IMG="/Content/images/checkbox.png",i.DEFAULT_GREY_IMG="/Content/images/checkboxGrey.png",i.CHECKED_IMG="/Content/images/checkboxChecked.png",i.CHECKED_GREY_IMG="/Content/images/checkboxGreyChecked.png",i}(n.CompProperty);n.BooleanCompProperty=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r,u){var e,o,f;t.call(this,null,u);e=u.getTitle();this.Name="extra_prop_use_as_ac_source";this.Description="Check this to select this component as the AC Source for use in frequency domain simulations. This sets default values for AC Magnitude and AC Phase.";this.Type="boolean";o=this.comp.getInstPropValue(i.Name);this.Typical="false";this.PropVisibility=0;this.Metadata=new n.CompPropertyMetadata;this.Metadata.displayName="Use as AC "+e.substr(0,e.indexOf("Function Generator")-1)+" Source";this.Metadata.displayVisibility=!1;f=new n.CompPropertyMetadataChild;f.name=i.Name;f.visibleValues.push("true");this.Metadata.children.push(f);i.Metadata.parents.push(this.Name);this.acMag=i;f=new n.CompPropertyMetadataChild;f.name=r.Name;f.visibleValues.push("true");this.Metadata.children.push(f);r.Metadata.parents.push(this.Name);this.acPhase=r}return __extends(i,t),i.prototype.setInstValue=function(n){this.instValue=n},i.prototype.setValue=function(t){var r,u;this.instValue=t.toLowerCase();var e=this.instValue=="true",f=new n.PropertyData(this.comp.getInstName(),this.acMag.Name,this.acMag.getValue()),i=surface.getDesign().getUndoManager();i.startUndoableCommand(n.UpdatePropertyCommand,this.comp.getDesign(),f,n.COMMAND_STEP.FIRST);r=e?"1.0":"0.0";this.comp.setInstProp(this.acMag.Name,r);this.acMag.setValue(r);i.finishUndoableCommand(r);f=new n.PropertyData(this.comp.getInstName(),this.acPhase.Name,this.acPhase.getValue());i.startUndoableCommand(n.UpdatePropertyCommand,this.comp.getDesign(),f,n.COMMAND_STEP.LAST);u="0.0";this.comp.setInstProp(this.acPhase.Name,u);this.acPhase.setValue(u);i.finishUndoableCommand(u);this.finishSetElementValue()},i}(n.BooleanCompProperty);n.ACCompProperty=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){t.call(this,i,r);this.DistType=i.DistType;this.Maximum=i.Maximum;this.Minimum=i.Minimum;this.Units=i.Units;n.CompProperty.validator.GetPropertyType(i.Type.toLowerCase())=="time"&&n.Utility.endsWith(i.Typical,"s")&&(this.Typical=i.Typical.substring(0,i.Typical.length-1))}return __extends(i,t),i.prototype.getHtml=function(){var i=this.getVisibilityIcon(),t='<div id="'+n.PropertyEditor.PROP_DIV_PREFIX_ID+this.Name+'"';return this.shouldBeVisible()||(t+=' style="display: none"'),t+='><div class="prop_editor_text">'+this.getDisplayName()+'<\/div><div class="input-group input input-group-sm" style="width: 100%"><input id="'+n.PropertyEditor.PROP_PREFIX_ID+this.Name+'" name="'+n.PropertyEditor.PROP_PREFIX_ID+this.Name+'" type="text" class="form-control prop_editor_data '+n.PropertyEditor.PROP_EDITOR_VALUE_CLASS+'" spellcheck="false" value="'+this.getValue()+'"><span class="input-group-addon prop_editor_label" style="width: 60px">'+this.Units+"<\/span>",this.getDisplayVisibility()&&(t+='<span class="input-group-addon prop_editor_label" style="width: 18px;"><img src="'+i+'" style="opacity: 0.8" class="visibility_icon" id="'+n.PropertyEditor.PROP_VISIBILITY_PREFIX_ID+this.Name+'"><\/span>'),t+"<\/div><\/div>"},i.prototype.getElementValue=function(){return this.getElement().val()},i.prototype.setElementValue=function(n){n||(n=this.Typical);this.instValue=n;this.getElement().val(n);this.finishSetElementValue()},i.prototype.validate=function(t){var r,i,e,o;t===void 0&&(t=!0);var s=this.getElement().parent(),u=this.getElementValue(),f=surface.getPropertyEditor();if(u.trim()=="")return t&&(this.showErrorTooltip("Input box must not be empty or contain just spaces"),f.updateErrorMessageLink(this.Name,!0)),!1;for(r=this.comp.getProperties(),i=0;i<r.length;i++)if(e=!1,n.CompProperty.validator.GetPropertyType(r[i].Type.toLowerCase())=="time"&&(n.Utility.endsWith(u,"s")?e=!0:s.hasClass("has-error")&&this.setDefaultTooltip()),this.Name==r[i].Name&&(u!=r[i].getValue()||e==!0))return o=n.CompProperty.validator.ValidateInputValue(n.CompProperty.validator.GetPropertyType(r[i].Type),u),o.match("^Invalid")?(t&&(this.showErrorTooltip(o),f.updateErrorMessageLink(this.Name,!0)),!1):(this.setDefaultTooltip(),f.updateErrorMessageLink(this.Name,!1),!0);return!0},i.prototype.setValueOnClose=function(){return!0},i.prototype.defineEvents=function(){t.prototype.defineEvents.call(this);var i=this;this.getElement().on("blur change",function(){i.setValue(i.getElementValue())});this.getElement().on("keyup",function(t){var u="#"+t.currentTarget.id,r;t.which!=n.Design.TabKey&&(r=t,clearTimeout(i.timer),i.timer=setTimeout(function(){i.validate()},250))})},i}(n.CompProperty);n.NumberCompProperty=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.isCorrectType=function(n){return n=="integer"},i.prototype.getHtml=function(){var f=this.getVisibilityIcon(),t='<div id="'+n.PropertyEditor.PROP_DIV_PREFIX_ID+this.Name+'" class="input-group input input-group-sm" style="width: 100%; padding-top: 5px;"',r,u,i;this.shouldBeVisible()||(t+=" display: none;");t+='><div class="prop_editor_text">'+this.getDisplayName();this.getDisplayVisibility()&&(t+='<span class="input-group-addon prop_editor_label" style="width: 18px; height: 16px !important; border-left: 1px solid #cccccc; border-radius: 3px; float: right"><img src="'+f+'" style="opacity: 0.8" class="visibility_icon" id="'+n.PropertyEditor.PROP_VISIBILITY_PREFIX_ID+this.Name+'"><\/span>');t+='<\/div><table style="border: 0; width: 100%"><tr>';r=0;for(i in this.Metadata.radioDisplayValues)t+='<td><div class="prop_editor_radio_div"><label><input id="'+n.PropertyEditor.PROP_PREFIX_ID+this.Name+i+'" name="'+n.PropertyEditor.PROP_PREFIX_ID+this.Name+'" type="radio" class="prop_editor_radio '+n.PropertyEditor.PROP_EDITOR_VALUE_CLASS+'" value="'+i+'"><img class="prop_editor_radio_img" src="'+this.getImgSrc(i,this.getValue())+'" tabindex="0"><\/label><\/div><\/td>',++r;t+="<\/tr><tr>";u=100/r;for(i in this.Metadata.radioDisplayValues)t+='<td style="font-size: 11px; text-align: center; vertical-align: text-top; width: '+u+'%">'+this.Metadata.radioDisplayValues[i]+"<\/td>";return t+"<\/tr><\/table><\/div>"},i.prototype.getImgSrc=function(n,t){var r=surface.isEditable();return n==t?r?i.SELECTED_IMG:i.SELECTED_GREY_IMG:r?i.DEFAULT_IMG:i.DEFAULT_GREY_IMG},i.prototype.getSelectedElement=function(){return $("input:radio[name="+n.PropertyEditor.PROP_PREFIX_ID+this.Name+"]:checked")},i.prototype.getElementValue=function(){return this.getSelectedElement().val()},i.prototype.getElementFromKey=function(t){return $(n.PropertyEditor.PROP_PREFIX+this.Name+t)},i.prototype.setElementValue=function(t){var r,i,u;t||(t=this.Typical);this.instValue=t;$("input:radio[name="+n.PropertyEditor.PROP_PREFIX_ID+this.Name+"]").prop("checked",!1);$("input:radio[name="+n.PropertyEditor.PROP_PREFIX_ID+this.Name+'][value="'+t+'"]').prop("checked",!0);for(r in this.Metadata.radioDisplayValues)i=this.getElementFromKey(r),u=i.next(),u.attr("src",this.getImgSrc(i.val(),t));this.finishSetElementValue()},i.prototype.validate=function(){return!0},i.prototype.defineEvents=function(){var i,u,r;if(t.prototype.defineEvents.call(this),i=this,surface.isEditable())for(u in this.Metadata.radioDisplayValues){r=i.getElementFromKey(u);r.on("click",function(){i.setValue(i.getElementValue())});r.parent().find("img").on("keyup",function(t){if(t.which==n.Design.SpaceKey){var r=$(t.currentTarget).parent().find(":input");i.setValue(r.val())}})}},i.DEFAULT_IMG="/Content/images/radioButton.png",i.DEFAULT_GREY_IMG="/Content/images/radioButtonGrey.png",i.SELECTED_IMG="/Content/images/radioButtonSelected.png",i.SELECTED_GREY_IMG="/Content/images/radioButtonGreySelected.png",i}(n.CompProperty);n.RadioCompProperty=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i);this.originalValue=null;this.options=null;this.gridName=null;this.gridColumn=null;this.userChangingValue=!1;this.DistType=n.DistType;this.Maximum=n.Maximum;this.Minimum=n.Minimum;this.Units=n.Units}return __extends(i,t),i.isCorrectType=function(n){return n=="integer_vector"||n=="real_vector"||n=="time_vector"},i.prototype.getGridName=function(){return this.gridName},i.prototype.setGridName=function(){this.gridName=this.Metadata?this.Metadata.gridName:this.Name},i.prototype.getGridColumn=function(){return this.gridColumn},i.prototype.setGridColumn=function(){this.gridColumn=this.Metadata?this.Metadata.gridColumn:0},i.prototype.getHtml=function(){if(this.setGridName(),this.setGridColumn(),this.Metadata&&this.Metadata.gridColumn!=0)return null;return'<div id="'+n.PropertyEditor.PROP_DIV_PREFIX_ID+this.gridName+'" style="padding-top: 10px; width: 190px"><div style="width: 190px; height; 20px;"><input class="btn btn-xs prop-editor-plus-button" type="button" id="'+n.PropertyEditor.PROP_PREFIX_ID+this.gridName+i.INSERT_ROW_SUFFIX+'" title="Adds a row after the selected cell, or at the end of the table if no cell is selected" /><input class="btn btn-xs prop-editor-minus-button" type="button" id="'+n.PropertyEditor.PROP_PREFIX_ID+this.gridName+i.DELETE_ROW_SUFFIX+'" title="Deletes the row of the selected cell" /><\/div><div style="padding-top: 5px"><\/div><div id="'+n.PropertyEditor.PROP_PREFIX_ID+this.gridName+'"><\/div><\/div>'},i.prototype.getElementValue=function(t,i){var r,u,o;if(t===void 0&&(t=this.gridColumn),i===void 0&&(i=!1),this.isSingleColumn()&&t==1)return null;var s=this.getElement().data("kendoGrid"),f=s.dataSource.data(),e=[];for(r=0;r<f.length;r++)u=t==0?f[r].independent.toString():f[r].dependent.toString(),i&&(u=n.CompProperty.validator.addTimePrefix(u)),e.push(u);return o=e.join(","),"("+o+")"},i.prototype.getElementFirstValue=function(){var n=this.getElement().data("kendoGrid").dataSource.data();return n.length==0?null:this.gridColumn==0?n[0].independent.toString():n[0].dependent.toString()},i.prototype.setElementValue=function(t){var i,e,f;t||(t=this.Typical);this.instValue=t;var o=surface.getPropertyEditor(),r=o.getGridData(this.gridName),s=n.Utility.splitVector(t),u=[];for(i=0;i<r[this.gridColumn].length;++i)r[this.gridColumn][i]=s[i],u.push({index:(i+1).toString(),independent:r[0][i],dependent:r[1]?r[1][i]:null});e=this.getElement().data("kendoGrid");f=new kendo.data.DataSource;u=this.removeTimePrefixes(u);f.data(u);this.userChangingValue||this.setDataSource(e,f);this.disableReadOnlyCells();this.finishSetElementValue()},i.prototype.setDataSource=function(n,t){var i=this.getElement();i.hide();n.setDataSource(t);i.show()},i.prototype.validate=function(){return!0},i.prototype.setValueOnClose=function(){return!0},i.prototype.getDisplayName=function(){var n=this.Units&&this.Units.length>0?this.Units:"No Units";return this.Metadata&&this.Metadata.displayName?this.Metadata.displayName:"<div>"+this.Name.toUpperCase()+"<br>["+n+"]<\/div>"},i.prototype.getDivElement=function(){return $(n.PropertyEditor.PROP_DIV_PREFIX+this.gridName)},i.prototype.getElement=function(){return $(n.PropertyEditor.PROP_PREFIX+this.gridName)},i.prototype.removeTimePrefix=function(t){return n.CompProperty.validator.removeTimePrefix(t)},i.prototype.removeTimePrefixes=function(n){var i,u,r,f,t;if(this.Type=="time_vector")for(i=0,u=n;i<u.length;i++)t=u[i],t.independent=this.removeTimePrefix(t.independent);if(this.otherProperty&&this.otherProperty.Type=="time_vector")for(r=0,f=n;r<f.length;r++)t=f[r],t.dependent=this.removeTimePrefix(t.dependent);return n},i.prototype.isTimeVector=function(){return this.Type=="time_vector"},i.prototype.addIndexes=function(n){for(var t=0;t<n.length;++t)n[t].index=(t+1).toString();return n},i.prototype.updateGridIndexes=function(){var t=this.getElement().data("kendoGrid"),n=t.dataSource.data(),i=new kendo.data.DataSource;n=this.addIndexes(n);i.data(n);this.setDataSource(t,i);this.disableReadOnlyCells()},i.prototype.addTimePrefix=function(t){return n.CompProperty.validator.addTimePrefix(t)},i.prototype.initGrid=function(t,r){var u=this,f,e;r=this.removeTimePrefixes(r);r=this.addIndexes(r);f=surface.getPropertyEditor();this.setOtherProperty(f.findGridCompProperty(this.gridName,1));this.otherProperty&&this.otherProperty.setOtherProperty(this);e=this.isSingleColumn()?[{field:"index",title:"ROW #",headerAttributes:{style:"font-size: 11px; padding: 5px; vertical-align: text-top; text-align: center"},attributes:{style:"font-size: 12px"},width:50,editor:function(n,t){n.text(t.model.index)}},{field:"independent",title:t[0],headerAttributes:{style:"font-size: 11px; padding: 5px;"},attributes:{style:"font-size: 12px"},width:120,editor:u.cellEditor}]:[{field:"independent",title:t[0],headerAttributes:{style:"font-size: 11px; padding: 5px;"},attributes:{style:"font-size: 12px"},width:85,editor:u.cellEditor},{field:"dependent",title:t[1],headerAttributes:{style:"font-size: 11px; padding: 5px;"},attributes:{style:"font-size: 12px"},width:85,editor:u.cellEditor}];this.getElement().kendoGrid({dataSource:r,columns:e,scrollable:!0,navigatable:!0,resizable:!1,selectable:!0,editable:!0,height:180});$(n.PropertyEditor.PROP_PREFIX+this.gridName+i.INSERT_ROW_SUFFIX).click(function(){u.insertRow()});$(n.PropertyEditor.PROP_PREFIX+this.gridName+i.DELETE_ROW_SUFFIX).click(function(){u.deleteRow()});this.disableReadOnlyCells()},i.prototype.setCellReadOnly=function(n,t){var i=$('tr[data-uid="'+n+'"] td:nth-child('+(t.gridColumn+1)+")");i&&i.css("color","#999")},i.prototype.disableReadOnlyCells=function(){var t=this,n=this.getElement().data("kendoGrid").dataSource.data();n[0]&&this.isFirstValueReadOnly()&&this.setCellReadOnly(n[0].uid,this);n[0]&&this.otherProperty&&this.otherProperty.isFirstValueReadOnly()&&this.setCellReadOnly(n[0].uid,this.otherProperty);this.isSingleColumn()&&n.forEach(function(n){t.setCellReadOnly(n.uid,t)})},i.getGridName=function(t){var i=t.id.substr(n.PropertyEditor.PROP_PREFIX_ID.length),r=i.indexOf("_active_cell");return r>-1&&(i=i.substring(0,r)),i},i.prototype.cellEditor=function(t,r){var o=$(t).closest("[id^="+n.PropertyEditor.PROP_PREFIX_ID+"]")[0],e=i.getGridName(o),s=r.field=="independent"?0:1,h=r.field=="independent"?r.model.independent:r.model.dependent,a=surface.getPropertyEditor(),u=a.findGridCompProperty(e,s),c,v,l,f;if(u.isFirstValueReadOnly()&&(c=o.parentElement.rowIndex,v=$(n.PropertyEditor.PROP_PREFIX+e).data("kendoGrid"),c==0)){t.html('<div style="padding-left: 4px">'+h+"<\/div>");return}u.options=r;u.originalValue=h;l='<input type="text" id="'+i.EDIT_CELL_ID+'" data-text-field="ValueName" data-value-field="ValueName" data-bind="value:'+r.field+'" style="width: 75px" grid-name="'+e+'" grid-column="'+s+'" />';$(l).appendTo(t);f=$(i.EDIT_CELL);f.focus(function(){$(this).select()});f.change(function(){var n=$(i.EDIT_CELL).val().trim();u.setValue(n)});f.on("paste",function(n){u.loadClipboardData(n)})},i.prototype.isSingleColumn=function(){return this.otherProperty==null},i.prototype.setOtherProperty=function(n){this.otherProperty=n},i.prototype.getValidationType=function(){switch(this.Type){case"integer_vector":return"integer";case"real_vector":return"real";case"time_vector":return"time"}return"real"},i.prototype.isColumnValid=function(){for(var i=this.getElement().data("kendoGrid").dataSource.data(),r=this.getValidationType(),u,t=0;t<i.length-1;++t)if(u=this.gridColumn==0?n.CompProperty.validator.ValidateInputValue(r,i[t].independent):n.CompProperty.validator.ValidateInputValue(r,i[t].dependent),u.match("Invalid"))return!1;return!0},i.prototype.removeErrorClass=function(t){var r=t+1,u=$(n.PropertyEditor.PROP_PREFIX+this.gridName+" tr > :nth-child("+r+")").removeClass(i.GRID_CELL_ERROR)},i.prototype.validateValue=function(t){this.isTimeVector()&&(t=this.removeTimePrefix(t));var i=n.CompProperty.validator.ValidateInputValue(this.getValidationType(),t);return i.match("Invalid")?{value:t,validState:1,result:i}:t.trim().length==0?{value:t,validState:2,result:i}:(t=n.Utility.convertNumberSuffix(t,this.isTimeVector()),{value:t,validState:0,result:i})},i.prototype.setValue=function(n,r,u){var s,h;if(r===void 0&&(r=!0),u===void 0&&(u=!1),u){t.prototype.setValue.call(this,n,r);return}var e=this.validateValue(n),n=e.value,c=e.validState,l=e.result,f=this.getDivElement().find(".k-edit-cell");switch(c){case 0:f.removeClass(i.GRID_CELL_ERROR);var o=this.getElement().data("kendoGrid"),a=f.closest("tr"),v=o.dataItem(a);if(v.set(this.gridColumn==0?"independent":"dependent",n),s=o.dataSource.data(),!this.validateMonoIncreasing(s,this.gridColumn)){this.showErrorTooltip("Values must be monotonically increasing");f.addClass(i.GRID_CELL_ERROR);return}this.isColumnValid()&&(h=this.getElementValue(this.gridColumn,this.isTimeVector()),this.setDefaultTooltip(),this.removeErrorClass(this.gridColumn),this.userChangingValue=!0,t.prototype.setValue.call(this,h),this.userChangingValue=!1);break;case 1:this.showErrorTooltip(l);f.addClass(i.GRID_CELL_ERROR);break;case 2:this.showErrorTooltip("Value must not be empty or contain just spaces");f.addClass(i.GRID_CELL_ERROR)}},i.prototype.validateMonoIncreasing=function(t,i){if(!this.Metadata||!this.Metadata.monoIncreasing)return!0;for(var r=0;r<t.length-1;++r)if(i==0){if(n.Utility.convertSIPrefixToNumber(t[r].independent)>=n.Utility.convertSIPrefixToNumber(t[r+1].independent))return!1}else if(n.Utility.convertSIPrefixToNumber(t[r].dependent)>=n.Utility.convertSIPrefixToNumber(t[r+1].dependent))return!1;return!0},i.prototype.isFirstValueReadOnly=function(){return this.Metadata&&this.Metadata.firstValueReadOnly},i.prototype.setVectorValues=function(){var t=this.getElementValue(),n=null;this.otherProperty&&(n=this.otherProperty.getElementValue());this.setValue(t,!1,!0);n&&this.otherProperty.setValue(n,!1,!0)},i.prototype.keepFirstValue=function(t){if(!this.isFirstValueReadOnly())return!1;var i=n.Utility.convertSIPrefixToNumber(t),r=n.Utility.convertSIPrefixToNumber(this.getElementFirstValue());return r!=i},i.prototype.validatePasteValue=function(t,i,r){var f;if(r===void 0&&(r=null),!t)return 2;var u=this.validateValue(t),t=u.value,e=u.validState,o=u.result;return e==1&&(f="Invalid value in pasted data: row "+i,r&&(f+=", column "+r),n.MessageManager.showErrorMessage(f)),e},i.prototype.validatePasteMonoIncreasing=function(t){if(!this.validateMonoIncreasing(t,this.gridColumn)){var i="Pasted data";return this.isSingleColumn()||(i+=", column "+(this.gridColumn+1)+","),i+=" is not monotonically increasing",n.MessageManager.showErrorMessage(i),!1}return!0},i.prototype.loadClipboardData=function(t){var o=n.Utility.getClipboardText(t),h,c,d,g,e,i,v,l,a;if(o)if(o.match(/\t/g)){if(t.stopPropagation(),t.preventDefault(),this.isSingleColumn()){n.MessageManager.showErrorMessage("Could not paste multiple columns of data into a single column table");return}var f=[],r=o.split(/\n/gm),u=r[0].split(/\t/g),s=!1,y=this.keepFirstValue(u[this.gridColumn]),p=this.otherProperty.keepFirstValue(u[this.otherProperty.gridColumn]),b=this.isFirstValueReadOnly(),k=this.otherProperty.isFirstValueReadOnly();if(b&&k&&n.Utility.xor(y,p)){n.MessageManager.showErrorMessage("The first row is read-only. The first row of pasted data should either be equivalent<br> to the first row of table data, or the values should both be different.");return}for((y&&p||y&&!k||!b&&p)&&(f.push({index:"",independent:this.gridColumn==0?this.getElementFirstValue():this.otherProperty.getElementFirstValue(),dependent:this.gridColumn==0?this.otherProperty.getElementFirstValue():this.getElementFirstValue()}),s=!0),e=!1,i=0;i<r.length;++i){if(u=r[i].split(/\t/g),h=this.validatePasteValue(u[0],i+1,1),h==1)return;if(c=this.validatePasteValue(u[1],i+1,2),c==1)return;if(i<r.length-1&&(h==2||c==2)){e=!0;continue}h==0&&c==0&&(u[0]=n.Utility.convertNumberSuffix(u[0],this.isTimeVector()),u[1]=n.Utility.convertNumberSuffix(u[1],this.isTimeVector()),f.push({index:"",independent:u[0],dependent:u[1]}))}if(!this.validatePasteMonoIncreasing(f))return;if(!this.otherProperty.validatePasteMonoIncreasing(f))return;e&&n.MessageManager.showWarningMessage("Rows with empty values were skipped");s&&n.MessageManager.showInfoMessage("First row table values were kept because one or both are read-only");l=this.getElementValue(0);d=this.getElementValue(1);this.setValue(n.Utility.toVector(f,this.gridColumn),!1,!0);this.otherProperty.setValue(n.Utility.toVector(f,this.otherProperty.gridColumn),!1,!0);a=this.getElementValue(0);g=this.getElementValue(1);this.setUndo(l,a,d,g)}else if(o.match(/\n/gm)){if(t.stopPropagation(),t.preventDefault(),!this.isSingleColumn()){n.MessageManager.showErrorMessage("Could not paste single column of data into a multi-column table");return}var f=[],r=o.split(/\n/gm),w=0,s=!1;for(this.keepFirstValue(r[0])&&(f.push({index:"1",independent:this.getElementFirstValue(),dependent:""}),w=1,s=!0),e=!1,i=0;i<r.length;++i,++w){if(v=this.validatePasteValue(r[i],i+1),v==1)return;if(i<r.length-1&&v==2){e=!0;continue}v==0&&(r[i]=n.Utility.convertNumberSuffix(r[i],this.isTimeVector()),f.push({index:(w+1).toString(),independent:r[i],dependent:""}))}if(!this.validatePasteMonoIncreasing(f))return;e&&n.MessageManager.showWarningMessage("Rows with an empty value were skipped");s&&n.MessageManager.showInfoMessage("The first row table value was kept because it is read-only");l=this.getElementValue(0);this.setValue(n.Utility.toVector(f,this.gridColumn),!1,!0);a=this.getElementValue(0);this.setUndo(l,a)}},i.prototype.insertRow=function(){var o,s,k,h,d,g;if(this.getElement().find("."+i.GRID_CELL_ERROR).length>0){n.MessageManager.showWarningMessage("Please correct the invalid values in the table before inserting a row");return}var u=this.getElement().data("kendoGrid"),t=u.dataSource.data(),c=n.CompProperty.validator,l=this.isSingleColumn(),a=0,v=0,f=[],e=[],r=-1;if(t.length>0)if(r=u.dataSource.indexOf(u.dataItem(u.select())),r==-1&&(r=t.length-1),f=c.splitSIPrefix(t[r].independent),o=Number(f[0]),l||(e=c.splitSIPrefix(t[r].dependent),s=Number(e[0])),t.length>r+1)var y=this.getNewMiddleValues(t,r,o,s),a=y.indepNew,v=y.depNew;else if(t.length==1)var p=this.getNewSecondValues(t,r,o,s),a=p.indepNew,v=p.depNew;else if(t.length>1)var w=this.getNewLastValues(t,r,o,s),a=w.indepNew,v=w.depNew;var nt=this.getElementValue(0),tt=this.getElementValue(1),it=n.Utility.getPrecision(a),b=a.toPrecision(it).toString();f.length>1&&(b+=f[1]);k=n.Utility.getPrecision(v);h=v.toPrecision(k).toString();l&&e.length>1&&(h+=e[1]);u.dataSource.insert(r+1,{independent:b,dependent:h});this.updateGridIndexes();d=this.getElementValue(0);g=this.getElementValue(1);this.setVectorValues();this.setUndo(nt,d,tt,g)},i.prototype.getNewMiddleValues=function(t,i,r,u){var h=n.CompProperty.validator.splitSIPrefix(t[i+1].independent),c=Number(h[0]),e=r+(c-r)/2,f,o,s;return this.getValidationType()=="integer"&&(e=Math.round(e)),f=0,this.isSingleColumn()||(o=n.CompProperty.validator.splitSIPrefix(t[i+1].dependent),s=Number(o[0]),f=u+(s-u)/2,this.getValidationType()=="integer"&&(f=Math.round(f))),{indepNew:e,depNew:f}},i.prototype.getNewSecondValues=function(t,i,r,u){var f=1,e=1,o,s;return r!=0&&(o=n.CompProperty.validator.splitSIPrefix(t[i].independent),f=Number(o[0])*2,this.getValidationType()=="integer"&&(f=Math.round(f))),this.isSingleColumn()||u==0||(s=n.CompProperty.validator.splitSIPrefix(t[i].dependent),e=Number(s[0])*2,this.getValidationType()=="integer"&&(e=Math.round(e))),{indepNew:f,depNew:e}},i.prototype.getNewLastValues=function(t,i,r,u){var f=0,e=0,s=n.CompProperty.validator.splitSIPrefix(t[i-1].independent),o;return f=r*2-Number(s[0]),this.getValidationType()=="integer"&&(f=Math.round(f)),this.isSingleColumn()||(o=n.CompProperty.validator.splitSIPrefix(t[i-1].dependent),e=u*2-Number(o[0]),this.getValidationType()=="integer"&&(e=Math.round(e))),{indepNew:f,depNew:e}},i.prototype.deleteRow=function(){var t,r,u,f,e,o;if(this.getElement().find("."+i.GRID_CELL_ERROR).length>0){n.MessageManager.showWarningMessage("Please correct the invalid values in the table before deleting a row");return}if(t=this.getElement().data("kendoGrid"),t.dataSource.view().length<=1){n.MessageManager.showWarningMessage("Cannot delete the last row in the table");return}r=t.dataItem(t.select());r?this.isFirstValueReadOnly()&&r==r.parent()[0]?n.MessageManager.showWarningMessage("Cannot delete the first row"):(u=this.getElementValue(0),f=this.getElementValue(1),t.dataSource.remove(r),this.updateGridIndexes(),e=this.getElementValue(0),o=this.getElementValue(1),this.setVectorValues(),this.setUndo(u,e,f,o)):n.MessageManager.showWarningMessage("Select a row to delete")},i.prototype.setUndo=function(t,i,r,u){var e,f;r===void 0&&(r=null);u===void 0&&(u=null);var o=this.isSingleColumn(),c=o?n.COMMAND_STEP.SINGLE:n.COMMAND_STEP.FIRST,s=this.Name,h=null;o||(s=this.gridColumn==0?this.Name:this.otherProperty.Name,h=this.gridColumn==1?this.Name:this.otherProperty.Name);e=new n.PropertyData(this.comp.getInstName(),s,t);f=surface.getDesign().getUndoManager();f.startUndoableCommand(n.UpdatePropertyCommand,this.comp.getDesign(),e,c);f.finishUndoableCommand(i);o||(e=new n.PropertyData(this.comp.getInstName(),h,r),f.startUndoableCommand(n.UpdatePropertyCommand,this.comp.getDesign(),e,n.COMMAND_STEP.LAST),f.finishUndoableCommand(u))},i.prototype.setDefaultTooltip=function(){var n,t,e=surface.getPropertyEditor(),i,r='<u style="color: white">Column',u="<\/u><br>",f;this.isSingleColumn()?i=this.Description:(this.gridColumn==0?(n=this,t=e.findGridCompProperty(this.gridName,1)):(n=e.findGridCompProperty(this.gridName,0),t=this),i=n.Metadata.tooltip&&t.Metadata.tooltip?r+"1"+u+n.Metadata.tooltip+"<br><br>"+r+"2"+u+t.Metadata.tooltip:n.Metadata.tooltip?n.Metadata.tooltip:t.Metadata.tooltip?t.Metadata.tooltip:r+"1"+u+n.Description+"<br><br>"+r+"2"+u+t.Description);i+="<br><br>Hint: Replace table data with values copied from a spreadsheet by selecting any editable cell in the table and typing Ctrl-V/Cmd-V.";f=this.getDivElement();f.qtip("destroy");f.qtip({content:i,style:{classes:"svw-tooltip"}});f.removeClass("has-error")},i.EDIT_CELL_SUFFIX="edit_cell",i.EDIT_CELL_ID=n.PropertyEditor.PROP_PREFIX_ID+i.EDIT_CELL_SUFFIX,i.EDIT_CELL="#"+i.EDIT_CELL_ID,i.INSERT_ROW_SUFFIX="_insert_row",i.DELETE_ROW_SUFFIX="_delete_row",i.GRID_CELL_ERROR="grid_cell_error",i}(n.CompProperty);n.TableCompProperty=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(){function n(){}return n}(),r,t,u;n.AllLibComponents=i;r=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.InitialData=r;t=function(){function n(n,t){this.library=n;this.componentId=t}return n}();n.ComponentReference=t;u=function(){function i(){this.categories=[];this.partnerCategories=[];this.components=[];this.svwComponentIndexes={};this.userComponentIndexes={};this.partnerComponentIndexes={};this.compsByCategory={};this.favorites=[];this.searchResults=[];this.svWebLibDeferred=jQuery.Deferred();this.userDeferred=jQuery.Deferred();this.partnerDeferred=jQuery.Deferred();$.ajaxSetup({headers:{TOKEN_HEADER:n.Settings.APIKEY}});this.partnerCategories=[];this.partnerCategories.push("Coilcraft")}return i.prototype.getCategories=function(){return this.categories},i.prototype.getPartnerCategories=function(){return this.partnerCategories},i.prototype.hasComponents=function(){return $.isEmptyObject(this.components)},i.prototype.getComponents=function(){return this.components},i.prototype.getNumSearchResults=function(){return this.searchResults.length},i.prototype.getSearchResults=function(){var t=this,n;return this.searchResults.length==0?null:(n=[],this.searchResults.forEach(function(i){var r=t.getComponent(i.library,i.componentId);r&&n.push(r)}),n)},i.prototype.getCompIndexesByCategory=function(n){return n==Sidebar.ComponentBrowser.MY_FAVORITES_CATEGORY?this.favorites:this.compsByCategory[n]},i.prototype.getCompIndex=function(n,t){switch(n){case i.USER_LIB:return this.userComponentIndexes[t];case i.SVWEB_LIB:return this.svwComponentIndexes[t];case i.PARTNER_LIB:return this.partnerComponentIndexes[t]}return null},i.prototype.setCompIndex=function(n,t,r){switch(n){case i.USER_LIB:this.userComponentIndexes[t]=r;break;case i.SVWEB_LIB:this.svwComponentIndexes[t]=r;break;case i.PARTNER_LIB:this.partnerComponentIndexes[t]=r}},i.prototype.getComponent=function(t,i,r){var f,u;if(r===void 0&&(r=!0),f=this.getCompIndex(t,i),f!=null)return this.components[f];if(r)for(u=0;u<this.components.length;++u)if(t==n.ComponentVhdlDto.getLib(this.components[u])&&i==this.components[u].ComponentId)return this.components[u];return null},i.prototype.addToCollection=function(t){t.Img=n.Utility.addViewboxToSVG(t.Img);t.UserFavorite=!1;this.components.push(t);this.reconstruct()},i.prototype.updateCollection=function(t){var i=this.getCompIndex(n.ComponentVhdlDto.getLib(t),t.ComponentId);i!=null&&i!=-1&&(this.components[i]=t,this.reconstruct())},i.prototype.deleteFromCollection=function(n,t){var i=this.getCompIndex(n,t);i!=null&&i!=-1&&(this.components.splice(i,1),this.buildCollections())},i.prototype.addFavorite=function(n,t){this.favorites.push(this.getCompIndex(n,t))},i.prototype.deleteFavorite=function(n,t){var i=this.getCompIndex(n,t),r;i!=null&&i!=-1&&(r=this.favorites.indexOf(i),r!=-1&&this.favorites.splice(r,1))},i.prototype.isSVWebLoading=function(){return this.svWebLibDeferred.state()=="pending"},i.prototype.isUserLoading=function(){return this.userDeferred.state()=="pending"},i.prototype.isPartnerLoading=function(){return this.partnerDeferred.state()=="pending"},i.prototype.reconstruct=function(){this.components.sort(this.sortComponents);this.buildCollections()},i.prototype.initSearchIndex=function(){this.searchIndex=lunr(function(){this.field("Title");this.field("Tags")});this.searchIndex.ref("ComponentId");var n=function(n){return n};this.searchIndex.pipeline.remove(lunr.stemmer);this.searchIndex.pipeline.remove(lunr.trimmer);this.searchIndex.pipeline.remove(lunr.stopWordFilter)},i.prototype.addToSearchIndex=function(n){var t=n.Name.split(" ");this.searchIndex.add(n)},i.prototype.removeFromSearchIndex=function(n){this.searchIndex.remove(n)},i.prototype.buildCollections=function(){var t=this;this.svwComponentIndexes={};this.userComponentIndexes={};this.partnerComponentIndexes={};this.compsByCategory={};this.favorites=[];this.initSearchIndex();this.components.forEach(function(i,r){t.isDeprecated(i)||(t.addToSearchIndex(i),t.setCompIndex(n.ComponentVhdlDto.getLib(i),i.ComponentId,r),i.Categories.forEach(function(n){$.isEmptyObject(t.compsByCategory[n])&&(t.compsByCategory[n]=[]);t.compsByCategory[n].indexOf(r)==-1&&t.compsByCategory[n].push(r)}),i.UserFavorite&&t.favorites.indexOf(r)==-1&&t.favorites.push(r))})},i.prototype.sortComponents=function(n,t){return n=n.Title.toLowerCase(),t=t.Title.toLowerCase(),n<t?-1:n>t?1:0},i.prototype.isDeprecated=function(n){return n.Revisions&&n.Revisions.length>1&&n.ComponentId!=n.Revisions[n.Revisions.length-1].ComponentId},i.prototype.sortCategories=function(n,t){n=n.toLowerCase();t=t.toLowerCase();var r=i.MY_COMP_CATEGORY.toLowerCase();return n==r?-1:t==r?1:n<t?-1:n>t?1:0},i.prototype.addComponents=function(t,r){var u=this;r===void 0&&(r=!1);t&&t.forEach(function(t){var f=u.getCompIndex(n.ComponentVhdlDto.getLib(t),t.ComponentId);f===undefined?(t.Img=n.Utility.addViewboxToSVG(t.Img),r&&(t.UserFavorite=!0),t.Title||(t.Title=i.DEFAULT_COMP_TITLE),u.components.push(t)):r&&(u.components[f].UserFavorite=!0)})},i.prototype.loadInitialData=function(){var t=this,i=jQuery.Deferred();return this.categories.length>0?(i.resolve(t.categories),i.promise()):($.ajax({url:n.Settings.APIURI()+"/initialize",dataType:"json",type:"GET",contentType:"application/json;charset=utf-8",success:function(n){if(!n)return i.resolve();t.categories=n.SVWebCategories.concat(n.UserCategories);t.categories.sort(t.sortCategories);t.addComponents(n.SVWebComponents,!0);t.addComponents(n.UserComponents,!0);t.addComponents(n.PartnerComponents,!0);t.reconstruct();i.resolve()},error:function(){i.resolve()}}),i.promise())},i.prototype.loadComponents=function(t,r){var u=this,f=n.Settings.APIURI()+"/components";return t!=i.USER_LIB&&(f+="?library="+t),$.ajax({url:f,dataType:"json",type:"GET",contentType:"application/json;charset=utf-8",success:function(n){u.addComponents(n);u.reconstruct();r.resolve();r===u.svWebLibDeferred&&u.partnerDeferred.resolve()},error:function(){r.resolve()}}),r.promise()},i.prototype.loadUserComponents=function(){return this.loadComponents(i.USER_LIB,this.userDeferred)},i.prototype.loadSVWebLibComponents=function(){return this.loadComponents(i.SVWEB_LIB,this.svWebLibDeferred)},i.prototype.loadPartnerComponents=function(){return this.partnerDeferred.promise()},i.prototype.getByList=function(t){var r=this,i=jQuery.Deferred();return!t||t.length==0?(i.resolve(),i.promise()):(n.Utility.trace("Start loading components",!0),$.ajax({url:n.Settings.APIURI()+"/components",dataType:"json",data:JSON.stringify(t),type:"POST",contentType:"application/json;charset=utf-8",success:function(t){t&&(r.addComponents(t.SVWebComponents),r.addComponents(t.UserComponents),r.addComponents(t.PartnerComponents),r.reconstruct());n.Utility.trace("Components have finished loading",!0);i.resolve()},error:function(){n.Utility.trace("There was an error loading components",!0);i.resolve()}}),i.promise())},i.prototype.search=function(r){var u=this,f=this.searchIndex.search(r);this.searchResults=[];f&&f.length>0&&f.forEach(function(r){var f=u.getComponent(i.SVWEB_LIB,r.ref),o,e,s,h;if(f==null&&(f=u.getComponent(i.USER_LIB,r.ref)),f==null&&(f=u.getComponent(i.PARTNER_LIB,r.ref)),f==null){console.debug("Error getting search results for : "+r.ref);return}for(f.Title||(f.Title=i.DEFAULT_COMP_TITLE),o=!1,e=0,s=f.Categories;e<s.length;e++)if(h=s[e],h.match(/Datasheet Model Templates/i)){o=!0;break}o||u.searchResults.push(new t(n.ComponentVhdlDto.getLib(f),f.ComponentId))});this.reconstruct()},i.prototype.deleteComponent=function(t,i){var u=this,r=jQuery.Deferred(),f=n.Settings.APIURI()+"/components/?library="+t+"&componentId="+i;return $.ajax({headers:{TOKEN_HEADER:"97814435-7337-4390-be35-86ca540f7a1b",userID:n.Utility.getUserID()},url:f,dataType:"json",type:"DELETE",data:null,contentType:"application/json;charset=utf-8",success:function(){u.deleteFromCollection(t,i);r.resolve()},error:function(){r.resolve()}}),r.promise()},i.prototype.displayTime=function(){var r="",n=new Date,u=n.getHours(),f=n.getMinutes(),e=n.getSeconds(),t=f.toString(),i=e.toString();return f<10&&(t="0"+t),e<10&&(i="0"+i),r+=u+":"+t+":"+i+" ",r+(u>11?"PM":"AM")},i.SVWEB_LIB="SVWebLib",i.USER_LIB="UserLib",i.PARTNER_LIB="PartnerLib",i.DMB_CATEGORY="DMB User Components",i.MY_COMP_CATEGORY="My Components",i.DEFAULT_COMP_TITLE="Unnamed Component",i}();n.ComponentDataManager=u}(Project||(Project={})),function(n){var u=function(){function n(){}return n}(),t,i,r;n.DesignSimplifiedViewModel=u;t=function(){function n(n,t){var i=n.indexOf(t);this.revisionID=n.substring(0,i);this.designID=$("#"+this.revisionID+r.DESIGN_ID_SUFFIX).val()}return n}();n.DesignAndRevisionIDs=t;i=function(){function n(){this.designs=[];$.ajaxSetup({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID}})}return n.prototype.getAllDesigns=function(){var n=$.Deferred(),t=this;return $.ajax({url:Project.Settings.APIURI()+"/designs",dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(i){t.designs=i;n.resolve()},error:function(i,r){t.designs=[];r=surface.getAjaxErrorMessage(i,r);Project.MessageManager.showErrorMessage("Error: "+r);n.resolve()}}),n.promise()},n}();n.DesignBrowserModel=i;r=function(){function n(n,t,i){this.surface=n;this.sidebarManager=t;this.simulationSidebar=i;this.container=$('<div id="design_browser_dialog"><\/div>');$(document.body).append(this.container)}return n.prototype.show=function(){var u=this,t,r;this.initContainer();this.surface.disableControls();this.container.css("top",$(window).height()/2-this.container.height()/2);this.container.css("left",$(window).width()/2-this.container.width()/2);this.container.css("display","block");this.container.append('<div id="loading_designs_text">Loading designs...<\/div>');t=new i;r=this;t.getAllDesigns().then(function(){var f,o,e,i;for(r.surface.enableControls(),t.designs.sort(function(n,t){return n=new Date(n.Timestamp),t=new Date(t.Timestamp),t<n?-1:t>n?1:0}),$("#loading_designs_text").remove(),f=$('<div id="design_list" style="overflow: auto; height: '+(u.container.height()-30)+'px"><\/div>'),o=1,i=0;i<t.designs.length;i++)e=$('<div style="padding: 5px"><table style="width: 100%"><tr><td style="width: 31px"><i id="'+t.designs[i].DesignID+n.REVISION_ICON_SUFFIX+'" class="btn icon-caret-right"><\/i><\/td><td style="text-align: left"><a id="'+t.designs[i].LatestRevisionID+n.GET_LATEST_SUFFIX+'">'+t.designs[i].Name+'<\/a><td style="text-align: right"><button type="button" id="'+t.designs[i].DesignID+n.DESIGN_DELETE_SUFFIX+'" class="btn small_app_button icon-trash">&nbspDelete<\/button><input type="hidden" id="'+t.designs[i].LatestRevisionID+n.DESIGN_ID_SUFFIX+'" value="'+t.designs[i].DesignID+'"><\/td><\/tr><tr><td><\/td><td><span id="'+t.designs[i].DesignID+n.REVISIONS_SUFFIX+'"><\/span><\/td><td><\/td><\/table><\/div> '),o++%2==1&&e.addClass("sidebar_alternate_row"),f.append(e);for($("#design_browser_dialog").append(f),i=0;i<t.designs.length;i++)$("#"+t.designs[i].DesignID+n.REVISION_ICON_SUFFIX).click(function(n){r.openRevisions(n)}),$("#"+t.designs[i].LatestRevisionID+n.GET_LATEST_SUFFIX).click(function(t){Project.Utility.startTrace("get design in designBrowser.ts ");r.getDesign(t,n.GET_LATEST_SUFFIX)}),$("#"+t.designs[i].DesignID+n.DESIGN_DELETE_SUFFIX).click(function(t){r.deleteDesign(t,n.DESIGN_DELETE_SUFFIX)})})},n.prototype.initContainer=function(){var t=this,n;this.container.empty();n=$("<div><\/div>");n.append('<div style="float: left">Browse designs<\/div>');n.append('<i id="design_browser_exit" class="icon-remove" style="float: right"><\/i>');n.append('<p style="line-height: 10px;">&nbsp<\/p>');this.container.append(n);this.container.append('<hr class="hr_sidebar"/>');this.container.draggable();$("#design_browser_exit").click(function(){t.container.css("display","none")})},n.prototype.getDesign=function(n,i){var r=this,u=jQuery.Deferred();r.surface.okToClearDesign().then(function(f){if(f){r.surface.disableControls(!1);showLoadingMessage(LOADING_DESIGN);var e=new t(n.currentTarget.id,i);$.ajax({url:Project.Settings.APIURI()+"/designs",data:e,dataType:"json",type:"GET",contentType:"application/json;charset=utf-8",success:function(n){if(!n){hideLoadingMessage();Project.MessageManager.showErrorMessage("Could not find design");return}r.surface.loadDesign(n,u,!0)},error:function(n,t){hideLoadingMessage();t=surface.getAjaxErrorMessage(n,t);Project.MessageManager.showErrorMessage("Error: "+t)},complete:function(){r.surface.enableControls(!1)}})}});u.then(function(){hideLoadingMessage()})},n.prototype.deleteDesign=function(n,t){var r=this,i=n.currentTarget.id,u=i.indexOf(t);i=i.substring(0,u);r.surface.disableControls();$.ajax({url:Project.Settings.APIURI()+"/designs?designID="+i,dataType:"json",type:"DELETE",contentType:"application/json;charset=utf-8",error:function(n,t){t=surface.getAjaxErrorMessage(n,t);Project.MessageManager.showErrorMessage("Error: "+t)},complete:function(){r.show()}})},n.prototype.deleteDesignRevision=function(n,i){var r=this,u=new t(n.currentTarget.id,i);r.surface.disableControls();$.ajax({url:Project.Settings.APIURI()+"/designs?designID="+u.designID+"&revisionID="+u.revisionID,dataType:"json",type:"DELETE",contentType:"application/json;charset=utf-8",error:function(n,t){t=surface.getAjaxErrorMessage(n,t);Project.MessageManager.showErrorMessage("Error: "+t)},complete:function(){r.show()}})},n.prototype.openRevisions=function(t){var r=this,i=t.currentTarget.id,u=i.indexOf(n.REVISION_ICON_SUFFIX);i=i.substring(0,u);r.surface.disableControls();$.ajax({url:Project.Settings.APIURI()+"/designs?designID="+i,dataType:"json",type:"GET",contentType:"application/json;charset=utf-8",success:function(t){var e,u,o,s,f;if(t&&t.length!=0){for(t.sort(function(n,t){return n=new Date(n.DateModified),t=new Date(t.DateModified),t<n?-1:t>n?1:0}),e=$("#"+i+n.REVISIONS_SUFFIX),u=0;u<t.length;++u)o=r.getDateTimeString(t[u].DateModified),s='<a id="'+t[u].RevisionID+n.REVISION_LINK_SUFFIX+'">'+o+'<\/a>&nbsp;&nbsp;&nbsp;&nbsp;<a><i id="'+t[u].RevisionID+n.REVISION_DELETE_SUFFIX+'" class="icon-trash"><\/i><\/a><input type="hidden" id="'+t[u].RevisionID+n.DESIGN_ID_SUFFIX+'" value="'+t[u].DesignID+'"><br>',e.append(s),$("#"+t[u].RevisionID+n.REVISION_LINK_SUFFIX).click(function(t){r.getDesign(t,n.REVISION_LINK_SUFFIX)}),$("#"+t[u].RevisionID+n.REVISION_DELETE_SUFFIX).click(function(t){r.deleteDesignRevision(t,n.REVISION_DELETE_SUFFIX)});f=$("#"+i+n.REVISION_ICON_SUFFIX);f.unbind();f.removeClass("icon-caret-right");f.addClass("icon-caret-down");f.click(function(){r.closeRevisions(i)})}else Project.MessageManager.showErrorMessage("No revisions found")},complete:function(){r.surface.enableControls()}})},n.prototype.closeRevisions=function(t){var u=this,r=$("#"+t+n.REVISIONS_SUFFIX),i=$("#"+t+n.REVISION_ICON_SUFFIX);r.hide();i.removeClass("icon-caret-down");i.addClass("icon-caret-right");i.unbind();i.click(function(){r.show();i.removeClass("icon-caret-right");i.addClass("icon-caret-down");i.unbind();i.click(function(){u.closeRevisions(t)})})},n.prototype.getDateTimeString=function(n){var t=n.indexOf("+");return t==-1?n:n.substring(0,t-1)},n.DESIGN_ID_SUFFIX="_designID",n.REVISION_ICON_SUFFIX="_revision_icon",n.REVISIONS_SUFFIX="_revisions",n.GET_LATEST_SUFFIX="_get_latest",n.DESIGN_DELETE_SUFFIX="_design_delete",n.REVISION_LINK_SUFFIX="_revision_link",n.REVISION_DELETE_SUFFIX="_revision_delete",n}();n.Browser=r}(DesignBrowser||(DesignBrowser={})),function(n){var r=function(){function i(n){this.dialog=null;this.tests=[];this.surface=n;this.testIdx=0;this.numFailed=0;this.dialogContent="";this.createDialog()}return i.prototype.runCheckInTests=function(){this.createCheckInTestList();this.runTests()},i.prototype.runTests=function(){var n=this,r,t,u,i;for(this.openDialog(),r=jQuery.Deferred(),u=performance.now(),i=0;i<this.tests.length;++i)t=i==0?r.then(function(){return n.testIdx=0,n.runCurrentTest()}):t.then(function(){return++n.testIdx,n.runCurrentTest()});t=t.then(function(){var t=performance.now();n.summarizeTests();n.addTimeDiffToDialg(t,u);n.finalizeTests()});r.resolve()},i.prototype.runCurrentTest=function(){var n=this,t=jQuery.Deferred(),r,i;return this.testIdx>0&&this.addToDialog("<br><br>"),r=this.testIdx+1,this.addToDialog("Running test "+r+" of "+this.tests.length+" ..."),i=performance.now(),$.when(this.copyDesign(this.tests[this.testIdx])).done(function(r){var u,f,e;r?(u=performance.now(),n.addToDialog("<br>...Design copy passed"),n.addTimeDiffToDialg(u,i),f=n.tests[n.testIdx].getLocalDesignID(),e=n.tests[n.testIdx].getLocalRevisionID(),$.when(n.loadDesign(f,e,null)).done(function(r){if(r){var o=performance.now();n.addToDialog("<br>...Design load passed");n.addTimeDiffToDialg(o,u);$.when(n.simulateDesign(f,e)).done(function(r){var u,f;r?(u=performance.now(),n.addToDialog("<br>...Simulation passed"),n.addTimeDiffToDialg(u,o),$.when(n.plotResults()).done(function(r){if(r){var f=performance.now();n.addToDialog("<br>...Results plotting passed");n.addTimeDiffToDialg(f,u);n.addToDialog("<br>...Total time");n.addTimeDiffToDialg(f,i);n.deleteCopiedDesign(n.tests[n.testIdx]);t.resolve(!0)}else n.addToDialog("<br>...PLOTTING FAILED"),n.tests[n.testIdx].fail("Plotting Failed"),++n.numFailed,n.deleteCopiedDesign(n.tests[n.testIdx]),t.resolve(!1)})):(f=n.getSimulationError(),n.addToDialog("<br>...SIMULATION FAILED"),n.addToDialog("<br>"+f),n.tests[n.testIdx].fail("Simulation Failed: "+f),++n.numFailed,n.deleteCopiedDesign(n.tests[n.testIdx]),t.resolve(!1))})}else n.addToDialog("<br>...DESIGN LOAD FAILED"),n.tests[n.testIdx].fail("Design Load Failed"),++n.numFailed,n.deleteCopiedDesign(n.tests[n.testIdx]),t.resolve(!1)})):(n.addToDialog("<br>...DESIGN COPY FAILED"),n.tests[n.testIdx].fail("Design Copy Failed"),++n.numFailed,t.resolve(!1))}),t.promise()},i.prototype.copyDesign=function(t){var r=this,i=jQuery.Deferred();return $.ajax(n.Settings.APIURI()+"/designs?fromUser="+t.getUserID()+"&fromRevision="+t.getRevisionID()+"&toUser="+n.Settings.UUID,{dataType:"json",contentType:"application/json;charset=utf-8",type:"POST",data:null,headers:{TOKEN_HEADER:n.Settings.APIKEY,TOKEN:"5",userID:n.Settings.UUID},success:function(n){n?(r.saveCopiedDesign(n,t),i.resolve(!0)):(console.log("Error copying test design"),i.resolve(!1))},error:function(){console.log("Error copying test design");i.resolve(!1)}}),i.promise()},i.prototype.deleteCopiedDesign=function(t){var i=jQuery.Deferred();return!t.getLocalDesignID()||!t.getLocalRevisionID()?(i.resolve(),i.promise()):($.ajax(n.Settings.APIURI()+"/designs?designID="+t.getLocalDesignID()+"&revisionID="+t.getLocalRevisionID(),{dataType:"json",contentType:"application/json;charset=utf-8",type:"DELETE",data:null,headers:{TOKEN_HEADER:n.Settings.APIKEY,TOKEN:"5",userID:n.Settings.UUID},success:function(){i.resolve(!0)},error:function(){i.resolve(!1)}}),i.promise())},i.prototype.saveCopiedDesign=function(n,t){t.saveCopy(n.DesignID,n.RevisionID)},i.prototype.loadDesign=function(t,i,r){var f=this,u=jQuery.Deferred();return $.ajax(n.Settings.APIURI()+"/designs?designID="+t+"&revisionID="+i,{dataType:"json",contentType:"application/json;charset=utf-8",type:"GET",data:null,headers:{TOKEN_HEADER:n.Settings.APIKEY,TOKEN:"5",userID:n.Settings.UUID},success:function(n){n?$.when(f.surface.loadDesign(n,r,!0)).done(function(n){n==Schematic.DesignLoadStatus.LOAD_OK||n==Schematic.DesignLoadStatus.LOAD_FAILED_NO_SIMULATION_DATA?u.resolve(!0):(console.log("Error opening test design"),u.resolve(!1))}):(console.log("Error opening test design"),u.resolve(!1))},error:function(){console.log("Error opening test design");u.resolve(!1)}}),u.promise()},i.prototype.simulateDesign=function(){var n=jQuery.Deferred(),t=this.surface.getSimulationSidebar(),i=t.getSimulator();return i.setStateChangeCallback(this.stateChangeCB,this,n),t.getPlayStopButton().trigger("click"),n.promise()},i.prototype.plotResults=function(){var n=jQuery.Deferred(),t=this.surface.getSimulationSidebar();return t.setPlotCompleteCallback(this.plotCompleteCB,this,n),n.promise()},i.prototype.stateChangeCB=function(t,i,r){if(r==n.SimulationResultsState.NOT_RUNNING){var f=t.surface.getSimulationSidebar(),u=f.getSimulator();u.hasError()||!u.hasWaveformData()?i.resolve(!1):i.resolve(!0)}},i.prototype.plotCompleteCB=function(n,t,i){t.resolve(i)},i.prototype.getSimulationError=function(){var n=this.surface.getSimulationSidebar(),t=n.getSimulator();return t.getErrorMessage()},i.prototype.summarizeTests=function(){var n,t;if(this.numFailed>0)for(this.numFailed==1?this.addToDialog("<br><br>The following test failed:"):this.addToDialog("<br><br>The following "+this.numFailed+" tests failed:"),n=0;n<this.tests.length;++n)this.tests[n].getStatus()||(t=n+1,this.addToDialog("<br>Test "+t+" failed: "+this.tests[n].getErrorMsg()));else this.addToDialog("<br><br>All Tests Passed")},i.prototype.finalizeTests=function(){var n=this.surface.getSimulationSidebar(),t=n.getSimulator();t.clearStateChangeCallback();n.clearPlotCompleteCallback()},i.prototype.addTest=function(t){var u,f;if(t){var i=t.getDesignID(),r=t.getRevisionID(),e=n.Settings.UUID;i!=""&&r!=""&&(u=this.addToTestList(i,r,e),f=this.getTestString(u),console.log("Add the following line to the createCheckInTestList function in designTestManager.ts"),console.log(f))}},i.prototype.getTestString=function(n){var t="";return n<this.tests.length&&(t+='this.addToTestList("'+this.tests[n].getDesignID()+'", "'+this.tests[n].getRevisionID()+'", "'+this.tests[n].getUserID()+'");'),t},i.prototype.addToTestList=function(n,i,r){var u=new t(n,i,r);return this.tests.push(u),this.tests.length-1},i.prototype.createCheckInTestList=function(){this.tests=[];this.addToTestList("cc633aee-0e83-4bd7-9b2d-78f5f8f36921","ad308640-9667-41ce-9efa-d558ab88d257","d4ea1fdd-583c-4efc-b78c-be22a47453e4");this.addToTestList("d71064f1-0844-4302-9001-1e8fc02081f2","db8aa909-ae5c-4aa1-a5f8-1356b97e3873","d4ea1fdd-583c-4efc-b78c-be22a47453e4");this.addToTestList("4faf2bda-f9c5-41f2-a140-0b99d9a682a0","3b5c11ad-12a3-4030-84fe-e852977a6877","d4ea1fdd-583c-4efc-b78c-be22a47453e4")},i.prototype.createDialog=function(){function r(){t.closeDialog()}var i=this,n,t;this.dialogContent='<div id="designTest"><\/div>';n={visible:!1,title:"Design Tests",modal:!1,resizable:!0,width:250,height:500,open:function(){this.wrapper.css({top:50,left:300})},close:r,animation:{open:{effects:"slideIn:down fadeIn",duration:200}},deactivate:function(){i.closeDialog()},actions:["Close"]};this.dialog=$("<div><\/div>").appendTo(document.body).kendoWindow(n).data("kendoWindow");this.dialog.content(this.dialogContent);t=this},i.prototype.openDialog=function(){this.dialog.open()},i.prototype.closeDialog=function(){this.dialog.destroy()},i.prototype.addToDialog=function(n){this.dialogContent+=n;this.dialog.content(this.dialogContent)},i.prototype.addTimeDiffToDialg=function(n,t){var i=((n-t)/1e3).toFixed(1);this.addToDialog(" - "+i+"s")},i}(),t,i;n.DesignTestManager=r;t=function(){function n(n,t,r){this.designID=n;this.revisionID=t;this.userID=r;this.localCopyDesignID=null;this.localCopyRevisionID=null;this.testStatus=new i}return n.prototype.saveCopy=function(n,t){this.localCopyDesignID=n;this.localCopyRevisionID=t},n.prototype.getUserID=function(){return this.userID},n.prototype.getDesignID=function(){return this.designID},n.prototype.getRevisionID=function(){return this.revisionID},n.prototype.getLocalDesignID=function(){return this.localCopyDesignID},n.prototype.getLocalRevisionID=function(){return this.localCopyRevisionID},n.prototype.fail=function(n){this.testStatus.fail(n)},n.prototype.getStatus=function(){return this.testStatus.getStatus()},n.prototype.getErrorMsg=function(){return this.testStatus.getErrorMsg()},n}();n.TestData=t;i=function(){function n(){this.pass=!0;this.errorMsg=""}return n.prototype.fail=function(n){this.pass=!1;this.errorMsg=n},n.prototype.getStatus=function(){return this.pass},n.prototype.getErrorMsg=function(){return this.errorMsg},n}();n.TestStatus=i}(Project||(Project={})),function(n){var t=function(){function t(t){this._numPassed=0;this._numFailed=0;this._msgPassed="";this._msgFailed="";this.tests=[];this.testAssertion=new n.ClientTestAssertions(this);this.bogusTestDelay=100;this.surface=t;this.testIdx=0;this.clientTestShowResults=new n.ClientTestShowResults(this);$.ajaxSetup({headers:{TOKEN_HEADER:n.Settings.APIKEY}})}return t.prototype.runAllTests=function(){this.preTestStartup();this.clientTestShowResults.showTestsRunningDialog();this.runTests()},t.prototype.runTests=function(){var i=this,e,o,s,h,c,l,a,v,f,r,u;for(this.waitIndicator=setInterval(function(){$("#clientTests").html('<p><span style="color:green;font-weight:bold">Running client-side tests...<\/span><br>').slideDown(1700,function(){$("#clientTests").hide()})},2e3),n.Settings.UUID==n.CeUtility.SCOTT_ID&&(e=new n.TestCompPromotion(this,surface),this.addToTestList(e)),o=new n.TestModelEditor(this,surface),this.addToTestList(o),s=new n.TestSchToVhdl(this,surface),this.addToTestList(s),h=new n.TestPropertyEditor(this),this.addToTestList(h),c=new n.TestDMB(this),this.addToTestList(c),l=new n.TestCssClassManager(this),this.addToTestList(l),a=new n.TestSymbolEditor(this,surface),this.addToTestList(a),v=new n.TestCeUtilities(this),this.addToTestList(v),f=jQuery.Deferred(),u=0;u<this.tests.length;u++)r=u==0?f.then(function(){return i.testIdx=0,i.runCurrentTest()}):r.then(function(){return++i.testIdx,i.runCurrentTest()});r=r.then(function(){t.showFlow&&console.log("All tests are complete");i.clientTestShowResults.showResults(!1);i.postTestCleanup()});f.resolve()},t.prototype.runCurrentTest=function(){var n=this,i=jQuery.Deferred();return $.when(this.tests[this.testIdx].runTests()).done(function(){t.showFlow&&console.log("Test"+n.testIdx+" for "+n.tests[n.testIdx].testId+" complete");i.resolve(!0)}),i.promise()},t.prototype.addToTestList=function(n){return this.tests.push(n),this.tests.length-1},t.prototype.preTestStartup=function(){n.Settings.DISABLE_STD_UI_MESSAGING=!0},t.prototype.postTestCleanup=function(){t.showFlow&&console.log("In post test cleanup method");clearInterval(this.waitIndicator);n.Settings.DISABLE_STD_UI_MESSAGING=!1;n.MessageManager.removeAllMessages()},Object.defineProperty(t.prototype,"numPassed",{get:function(){return this._numPassed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numFailed",{get:function(){return this._numFailed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"msgPassed",{get:function(){return this._msgPassed},set:function(n){this._msgPassed=n},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"msgFailed",{get:function(){return this._msgFailed},set:function(n){this._msgFailed=n},enumerable:!0,configurable:!0}),t.prototype.incrementNumPassed=function(){this._numPassed++},t.prototype.incrementNumFailed=function(){this._numFailed++},t.showFlow=!1,t}();n.ClientTestManager=t}(Project||(Project={})),function(n){var i=function(){function n(n){this.testNotes="";this.tol=.001;this.testManager=n;this.clientTestResults=new t}return n.prototype.testIdNotes=function(n,t){this.testNotes=n;t&&(this.clientTestDataContainer=t)},n.prototype.assertEqualString=function(n,t){this.clientTestResults.setExpectedResult(n);this.clientTestResults.setReturnVal(t);t===n?this.processAssert(!0):this.processAssert(!1)},n.prototype.assertEqualValue=function(n,t,i){i||(i=this.tol);this.clientTestResults.setExpectedResult(n);this.clientTestResults.setReturnVal(t);var r=parseFloat(t),u=parseFloat(n);Math.abs(r-u)<i?this.processAssert(!0):this.processAssert(!1)},n.prototype.assertIsTrue=function(n){this.clientTestResults.setReturnVal(n);n?this.processAssert(!0):this.processAssert(!1)},n.prototype.assertIsFalse=function(n){this.clientTestResults.setReturnVal(n);n?this.processAssert(!1):this.processAssert(!0)},n.prototype.processAssert=function(n){var i=this.clientTestResults.getExpectedResult(),r=this.clientTestResults.getReturnVal(),t="";n?(t='"'+this.testNotes+'"'+this.getPassIndicator(),this.testManager.msgPassed+=t,this.testManager.incrementNumPassed()):(t='"'+this.testNotes+': Expected "'+i+'"; Received "'+r+'"'+this.getFailIndicator(),this.testManager.msgFailed+=t,this.testManager.incrementNumFailed())},n.prototype.getPassIndicator=function(){return'<span style="color: #00CC33;" > Passed<\/span><br/>'},n.prototype.getFailIndicator=function(){return'<span style="color: red;" > Failed<\/span><br/>'},n}(),t;n.ClientTestAssertions=i;t=function(){function n(){}return n.prototype.getReturnVal=function(){return this.returnVal},n.prototype.getExpectedResult=function(){return this.expectedResult},n.prototype.setReturnVal=function(n){this.returnVal=n},n.prototype.setExpectedResult=function(n){this.expectedResult=n},n}();n.ClientTestResults=t}(Project||(Project={})),function(n){var t=function(){function n(){}return n.prototype.getTestClass=function(){return this.testClass},n.prototype.getTestVal=function(){return this.testVal},n.prototype.getTestType=function(){return this.testType},n.prototype.getReturnVal=function(){return this.returnVal},n.prototype.getExpectedResult=function(){return this.expectedResult},n.prototype.setTestId=function(n){this.testId=n},n.prototype.setTestClass=function(n){this.testClass=n},n.prototype.setTestVal=function(n){this.testVal=n},n.prototype.setTestType=function(n){this.testType=n},n.prototype.setReturnVal=function(n){this.returnVal=n},n.prototype.setExpectedResult=function(n){this.expectedResult=n},n}();n.ClientTestDataContainer=t}(Project||(Project={})),function(n){var t=function(){function n(n){this.dialog=null;this.clientTestManager=n;this.dialogContent="";this.createDialog()}return n.prototype.showTestsRunningDialog=function(){this.openDialog();this.addToDialog("Running client-side tests...")},n.prototype.showResults=function(n){var i=this;this.clearDialog();this.addToDialog("<button id=btnShowAll class='k-button'>Show All<\/button><br/>");setTimeout(function(){$("#btnShowAll").on("click",function(){i.showResults(!0)})},1e3);var r=this.clientTestManager.numFailed+" Tests Failed<br/>",u=this.clientTestManager.numPassed+" Tests Passed<br/>",t="";n?t="<u><b>Test Log<\/b><\/u><\/br/>"+this.clientTestManager.msgFailed+this.clientTestManager.msgPassed:this.clientTestManager.msgFailed&&(t=this.clientTestManager.msgFailed);t="<br/><u><b>Summary<\/b><\/u><br/>"+r+u+"<br/>"+t;this.addToDialog(t)},n.prototype.createDialog=function(){function r(){t.closeDialog()}var i=this,n,t;this.dialogContent='<div id="clientTests"><\/div>';n={visible:!1,title:"Client Tests",modal:!1,resizable:!0,width:700,height:500,open:function(){this.wrapper.css({top:50,left:300})},close:r,animation:{open:{effects:"slideIn:down fadeIn",duration:200}},deactivate:function(){i.closeDialog()},actions:["Close"]};this.dialog=$("<div><\/div>").appendTo(document.body).kendoWindow(n).data("kendoWindow");this.dialog.content(this.dialogContent);t=this},n.prototype.openDialog=function(){this.dialog.open()},n.prototype.closeDialog=function(){this.dialog.destroy()},n.prototype.addToDialog=function(n){this.dialogContent+=n;this.dialog.content(this.dialogContent)},n.prototype.clearDialog=function(){this.dialogContent="";this.dialog.content(this.dialogContent)},n}();n.ClientTestShowResults=t}(Project||(Project={})),function(n){(function(n){n[n.GOOD_IMAGE=0]="GOOD_IMAGE";n[n.GOOD_TEXT=1]="GOOD_TEXT";n[n.LARGE_IMAGE=2]="LARGE_IMAGE"})(n.IMAGE_TEST_DATA||(n.IMAGE_TEST_DATA={}));var t=n.IMAGE_TEST_DATA,i=function(){function i(){}return i.getSvg=function(){return'<svg viewbox="0,0,120,80" style="overflow: hidden; position: relative;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="120" version="1.1" height="80"><rect transform="matrix(1,0,0,1,0,0)" x="20" y="0" width="80" height="80" rx="0" ry="0" fill="#ffffff" stroke="#000000" stroke-width="3" r="0" class="svw_sym svw_sym_shape svw_sym_outline"><\/rect><path transform="matrix(1,0,0,1,-40,-20)" fill="none" stroke="#000" d="M40,80L60,80Z" stroke-width="3" opacity="1"  class="svw_sym svw_sym_pin_whisker_elec"><\/path><path transform="matrix(1,0,0,1,-40,-100)" fill="none" stroke="#000" d="M40,120L60,120Z" stroke-width="3" opacity="1"  class="svw_sym svw_sym_pin_whisker_elec"><\/path><path transform="matrix(1,0,0,1,-40,-60)" fill="none" stroke="#000" d="M160,100L140,100Z" stroke-width="3" opacity="1" class="svw_sym svw_sym_pin_whisker_elec"><\/path><text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal bold 12px/normal Arial;" x="38" y="-5" text-anchor="start"   stroke="none" fill="#000000"  class="svw_sym_text"><tspan dy="0">Opamp<\/tspan><\/text><text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal normal 10px/normal Arial;" x="24" y="22" text-anchor="start"   stroke="none" fill="#000000"  class="svw_sym_text"><tspan dy="0">inm<\/tspan><\/text><text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal normal 10px/normal Arial;" x="24" y="64" text-anchor="start"   stroke="none" fill="#000000"  class="svw_sym_text"><tspan dy="0">inp<\/tspan><\/text><text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal normal 10px/normal Arial;" x="80" y="44" text-anchor="start"   stroke="none" fill="#000000"  class="svw_sym_text"><tspan dy="0">out<\/tspan><\/text><\/svg>'},i.getImage=function(n){switch(n){case t.GOOD_IMAGE:return"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw8PDw4MDRAUDxAQDg8PDxAODw8NEA8NFBQWFxQUFRQYHCghGBolGxQWITElJSkrLjAwFx8zODMsNygtLisBCgoKDg0OGBAQGzgcHxwsLCwrLCw2LCwsLCwsLCwsLCwsLCssLCwsLCwsLCwsLCwsLCs3LCsrLDcrLCwsKyssN//AABEIAQYAwAMBIgACEQEDEQH/xAAcAAEAAQUBAQAAAAAAAAAAAAAAAgEDBQYHCAT/xABJEAABAwIDAwgFCAcGBwEAAAABAAIDBBEFEiEGBzETIkFRYXGBkRQyUpKhCBUjQnKCotEzYnOxssHCJENTY2STNFR1g7Ph8CX/xAAYAQEBAQEBAAAAAAAAAAAAAAAAAwIBBP/EACARAQACAgIDAQEBAAAAAAAAAAABEQIDE0ESIWExUTL/2gAMAwEAAhEDEQA/AO4oiICIiCiqqIgqioqoKLH4hiGQ5Gau6TxA/wDa+6Z+VrndTSfILUHTEkknUm571jPKmM8qfW+dztXEnvKrFUvbq1xHjceS+PlE5RStHybLh9cJRY6OHEdBHWF9q1Klqcj2u6iL93SttVsMrWwyuBERabEUHvA4qx6WL2ug+pFFjrqSAiIgIiICIqIKoiIKIqog857U7S49g2My1lUdJnc2MFz6Oelb6rGdRAPHRwJv069s2L2upcWphU0ps4c2aFxHKQydTh0jqPSvt2iwGmxCnfR1jA+N47nMd0PYehwXm7EaSu2TxZj4nZ2EZo3atjqqUnnMeOgjp6jY9SD0/VMzMewcXNcB3kLRTL0Fblg+JR1dPBWQG8c8TZWX0OVwvYjoI4LB7R4K/MaiAZgdXsGpB6wOlS2xMxcJbcZmLhiOWTlljTP0dKlHIXENaC5x4BouT4Lz283kytLd72Rji5wC3pYHZzB3RfTTD6QizW8cgPX2rPL064mI9vVrxmI9qqEj7BSWk70Nq/myifO2xle4RQAi45VwJuR1AAnwt0qijD7zN48eHNMENpat4u1hN2xtP15LfAdK0vdFVYtU1k1bK90lNNcTPmJAdI31eSFrXHDSwt3LW9gtkZcYqH1lY5zoeUJkc4nPUS8S0HoGup8B2ejcHwtkLGMY0Na0BrWtFg1o4ABBkqUGwuvoUWtspICIqIKqiqiCiKqogqiIgIiIC5lv/wAHE+E+lAc+kmZJfp5J5yPHm5p+6umrAbfUvLYViUVr5qOe1/aDCQfMBBp3ye8VM2FPpnm5pal7G/sXgPb+Iv8AJdPXB/k01P02JQ34xQSAdzngn8QXeUHzT0EMmskTHnrc0EqVPSRx/o2NZ9loar6jI8NBc42A4lcqHKhJFiZcX15jdOt35KdPiwJs8Ze0ajxXPKHPKGRedF52+UHipfWU1EDzYoeVcOuSRxHwDB5r0NMeavL+8b+0bRyxO5zfSKWG36uWPMPMuWmnZ93uDimpKaC2rI25u2Q6uPmSt8Y2wWDwJuizoQVREQEREBERBRERAVURAREQF8G0AvR1Y/00/wDA5fesTtbMI8Pr5CbBtHUG/wD23IOG/JuP/wCjWD/Qk+Usf5r0QvP/AMmuG9ZXyezSxs96S/8AQvQCAsLtDUWyR9Bu4/uCzSwW1NO4sbM0XyXDrewen/7rWc/xjP8AyxPLJyqxfpKekrzeTzeTccLnL4Df6ri3w4j9684Y5rtRJ/1Fnwyr0hhNK6OnAeLOcS9w6r8B5Lzftf8ARbTyE6f26md4ObGf6l6sfx6sfx6LwP1Qs0sHgTuaFnF1oREQEREBERBRFVUQFVUVUBERAWp71aoRYJiTz9anMQ75CGf1LbFzD5QtfyeENh6airiZb9RgdIT5sb5oMH8mqktFiVR7UkEV/shzv6gu1rmnyfqHksG5U8aiqml16gGxjw+jJ8V0tAVCFVEGDrNl6aQlzc0RPHkyMvkeCvYds/TwEPAL3jg6Q5rdw4LLIs+GN3TPhjd0hKNF5h3zMMGOOmA1dHTzDtLRl/oXp93BefPlE0GWqoqoD14XxOPax2YfxnyWmnYtnpQWgjUHUdxWxBc/3cV/LUVJLe5dBHf7QFj8QVv7DogkiIgIiICIiCiIiCqKiqgIiIC8+/KPxfPV0lA06QQumf1cpKbAd4az8S9ASSBrS9xs1oLnE6ANGpJXmPZ9hx/aXl3guifUOqHg9FLDbI0juaxvig9B7FYUaLDqGjIs6KnjD+j6UjM/8RKzTnAAk6AanuVV8WMuIgkI6h5XF1yXJmoY6pxRzichyt6LcSrcWIyNN81+x2qxHLpy6h5vP5y3KkqRI0OHcR1FX1gtmZC7lerm+eqzqtjNxa+M3FhXKd/2FGXDBO0a007JD+zddjvi5p8F1ZYnaTC2VdNPSyerNE+N3YHC1/DitNOSbkMUzUhgJ50EzmgX/u32cD5lw8F2qmfcBeXt2da+gxV1HNzeUL6eQHgJmElvxBH3l6UwmfM0IMoiIgIiICIiCiIiAqqiqgIioSg53vy2k9Cwt1PG601aTA23EQ2vK7ys376wnyeNm+RpZsVkbZ9S4xQk/wDLMPOI73j8AWg7aYhLtHjrKWldeLlBS0xF3NETSTJNYdB5zu4Bek8Kw+OlghpIBljhjbGwfqtFvNB9ahLGHNcxwuHAgjsKmiDRcVwieFxytdJH9VzAXED9YDgvkpKOolOVkTu9zSxo7yV0RFKdMWjOmLfHhNAKeMMvdxN3u63fkvtRFSIpWIoUJW3Cmi668077sCdRYkzEIbtbU2kzD6lVHbN5gNd5rrOwePNq6aCoaf0jAXAfVkGjm+BBX0b0dmPnLD5oGj6Zn00B/wA5oOniCW+K45ub2gMFQ/DpTZshL4g7TLM31m69YH4UHpWN1wprH4bUZmhZBAREQEREBERAREQFzrfbtd834eaaF1qmszRMsedHB/eP7NOaO13Yt/q6lkMb5pXBkcbHPe9xsGsaLknwXmKd8+1WOgNzMie6zeB9HoIzqe/W/wBp6DfPk97JcnFJjUzbPmDoaYG+kIPPf4kWHY09a7OrFDSRwRR08LQyOJjY42DQNY0WA8gr6AiIgIiogjJK1ou4gDtVuKrjcbNcCergtdxKsLpXXOjSWgdQC+bl+1TnZ7SnZ7bki+TC6gyRNeeOoPaQvrVIVibW5mXC80b3tnZMMxJuIU12R1D+WY5vCOqBu8ePreJ6l6bWqbwdmGYlRTUjrB5GeF5+pO31T3dB7CUGL2B2jZWU0NQ3TMLPb7Eg0c3z/eFvcT7heX92eOyYdXPoKm8bZJDG5r7DkqlugJ77ZfJej8Kq8zQgyqKgVUBERAREQERYba/aGLDKKevm1EbbMZexlmPqMHefhcoOX/KB2yyRtwSndz5A2SrLT6sXFkR7SQHHsA61sO5LY/5vofS522qqwNkcCCHRU/GOPXgfrHvA6Fy/dhs7LjuKyYjX/SQxSekVLnA5ZZj+jiHZpcj2W26QvTCAiIgIiICoqog1DaKglje6ZjS+NxucouWO6bgdHasVSNlmcGRsc49xAHeehdEVLKU6rm0Z1XN2+fD6XkomR3uQNT1uOpX0oiqsKEjbhTRB5938bI8lI3GIG2a8tjqQ0erJwZJ46NPaB1rZt1W1nplM0SO+nhtHKLi7vZf4j4grpOO4XFVQS00zc0crCx462nq7V5hgdPs9iz4pbljHZH2BAmpXateO3ge8EIPVVNLmCvrXdn8SbIxjmuDmuAc1wNw5p4ELYWm6CqIiAiIgLzfvk2mkxbEY8JoryxQSCKNkevL1h0c4dgvlHc49K6tve2v+a8PcInWqqnNDT2IzM058v3R8SFyzc1sySTi0rdGl0dNfTncHyDu1aPFcmahyZqLds2F2Yjwqhhoo7FwGeeQC3K1DgMzu7QAdgC2Fabmf7R94pmf7TveKxyJ8nxuSLTcz/ad7xTM/2ne8U5Dk+NyRabd/tO94pmf7TveKchyfG5ItNu/2ne8UzP8AaPvFOQ5PjckWm5n+073il3+073inIcvxuSLTcz/aPvFMz/ad7xTkOT43JFpt3+073imZ/tO94pyHJ8bi4LlW+7Y30yl9NgbeopQXWAJdJT8Xs04kesO4jpWyZn+073ihz9JJ7ySnIcnxy7cztVocNldzowXwEnjF9Znhe/cexd3oKgOaF5g25wWTB8RZVUoyRPdy1OQOax314j2dnU5dz2J2gZV08NRGebI0Ei9yx3BzT2g3C3E2pE23hFCN1wprrooveGgucQAASSTYADiSpLmW/bar0KgFFC609bdhsbFlMP0jvHRviepByfarE5dpMaDICeRzcjT3BtHSsJLpCOgnV3iAu34fRx08UdPCMscTAxg/VH81z3cxs7yNO/EpW2kqOZDfi2nB1P3nDyaF0lRzm5RzyuaERFhgREQEREBERAREQEREBERARURBgduNnm4jRSU2nKj6SBx+rM3gO4i48VzDdHtC6lqnYdNdrZXHIHXBjqW6FpB4XAt3gLty4lvewJ1JWR4lBzWTuDiW6ZKtut/EAHvBVMJ6U1z09FYZU5mhZJc73d7RispYajg4jLI32ZW6OH8/ELoMTrhVVSJXlvamuftDjxbETyJkEEJGuSkjvmf48533gu5b29oPQMJqZGuyyzD0aGxsc8gNyO5ocfBcp3IYPYVGIvHH+zxEjo0dIR+EeBXMpqHMpqHVKeFsbGRRgNYxrWMaOAaBYBXLqKLzvMldLqN0ugldLqKIJXS6iiCV0uoogldLqKIJJdRRBJFFEEkUUQSusNthgor6KekPrObmiJ+rM3Vp/l4lZdEt2JpxXc9jbqarfQS3a2a5aHXBbUM4i3WQD7oXo3DJ8zQvM+8qhfh+LCsg5olLaqM2sBKDzx5i5+0u9bI4o2eGKZhu2RjXt7iLr0RNvRE25d8o/GM9TR4c06RRGokH+ZIS1o7w1p95blsjhopKClprWc2Jpf8AtXc5/wASVyvaY/OO1MrDzmGubFY6jk4AGuFj0WjPmV2q6nsnpPbPSV0uo3S6kildLqN0ugldLqN0ugldLqN0ugldLqN0ugldLqN0ugldLqN0ugldLqN1S6Cd0uoKt0ErpdQuq3QaJvkw3laBtQBzqaZribXPJP5rh5lp8Fd3I4rno+QJ1glcwfs3c5vxLh4LZ8doxUUtTTnXlYJGeJabfGy5PuTrSytmg6JIM33mOFvg4+Strn0vrn0+bd44T466oPtVc473Zh/Wu2XXEN1zeSxcxP8AWDKiPXTnN4/wldsusbf1Pb+p3S6hdLqdp2uXVLqF0ullp3S6hdLpZa5dLq3dLpZa5dLq3dLpZad1W6t3S6WWndVurd0ullrl0urd1W6Fp3S6hdLoWndLq3dVuhaYK4ZsP9DjwiaLN5eqiA6mgPt/CF3AFcQ2TPKbQhzdR6XVu09m0mqrq7W1dvo2jj+atppXu5rBWGYHgOQnFye4CQjwXYrrUvlF7NkimxiNvqgU1RYfVJJicfEub4tU932Oisoo8xvLCBDKL6mw5rvEfEFNsdm6O21XS6t3S6gha5dLq3dLoWuXS6t3S6Frt0urV0uha7dUurd0uha7dLq1dLoWu3S6tXS6Frt0urV0uha7dLq1dLoWu3S6tXS6FvmxzEBTU1RUn+6ie8drgOaPE2XL9yuHmSulqDq2KEi/+ZIRb4ByyO97HQGR4bGec8iWa3QwXyNPedfALc9zuzxpqJj5G2knPLPBGoBFmD3dfEr06oqLejVFRbp2NYXDWU81HUNzRTMLHjgbHgQegg2I7QvLs8FZs3ibopRmbw6mVNKTzXt7dPA3C9XrAbY7I0mLQej1bNRcxTMsJYXHpaerrB0KpMWpMW0XB8ZgrIxNTPD2niODmHqc3oK+7MuYY9uvxnCpDPRZ6mNouJqS7ZAOp0V83lmC+Gg3kVsB5OqibMW6OzAwSg9ttPgvPlpnpDLTPTruZMy0Wi3mUT9JWSwnpu0SN82m/wAFmKXbPDZPVqmDskD4j+IBTnDKOkpwyjpsWZMyx0WL0z/Unid3Ss/NfU2Zp1BB7iCs+2fa/mTMrWdMyFruZMytZkzLgu5kzK1mTMui7mTMrWZM6C7mTMvnfUMbq5zW/acB+9fHPjlJHq+pib3ys/NKl32ymZMy1iq25w2PQ1IeeqNkknxAt8Vha7ehTNuIIZJT0F5bE3+Z+C1GGU9OxhlPToOZYHavauDD4zmIfOR9HCDqT1u9lq51V7cYpWu5GlbyebQNpWOfIR9rU+Issxsxunrat4mxFxgYXXc0uEk8nebkN8bnsVcdX9Vx0/1jNhdnZsZrnVdUC+Fsmedx4SSaWiHZw7gO1elcLpMjRovi2e2fhpImQQRiONg5rWjzJ6yetZ9jbK70JIiICxmL7PUVYLVlLDP1GWJjnDuda48FREGmYnuVwaa5jZNTE/4E1x7sgcLdy1ut+T/Ef+HxB7eyaBsnxa5qIgwtVuFrW3LKyBw/WbKw/AFa/XbqsQgNzPT6dLZJwf8AxoiDD1WA10PGoGnsyzfksXLU1TDlM8nhLIiIUgK6p4cvJ/uyfmvqjp6t4LuXPXrLKiJRS3UelRcZ3/dlkXz/ADhU/wCPL/uyfmqolFLkM1VJoJ3/AHpZFkYMCrJdBONfall/JEQplKLdlWy68tAB9qUn+BZum3LVLrF9ZE0fqxyPPxsiIMzRbkoNOXrJHdfJRsi/fmWz4XulwmKxMRmI6Z5HPv4Cw+CIg3PDMAp6duSCJkTeqNjWD4BZaKmaOCIgvgKqIg//2Q==";case t.GOOD_TEXT:return"data:text/plain;base64,Mi8yNi8yMDEzIC0gQWRkaXRpb25hbCBIZWxwIE5vdGVzDQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCg0KV2hlbiBhIG1vZGVsIGlzIHNhdmVkLCBpdCBjYW5ub3QgYmUgZGVsZXRlZCBpbW1lZGlhdGVseSB3aXRob3V0IGZpcnN0IHNlbGVjdGluZyBhbnkgb3RoZXIgbW9kZWwsIHRoZW4gc2VsZWN0aW5nIHRoZSBuZXdseSBzYXZlZCBtb2RlbC4NCg0KV2hlbiBhIG1vZGVsIGlzIHNhdmVkLCBib3RoIGEgbW9kZWwgYW5kIGEgc3ltYm9sIGZvciB0aGUgbW9kZWwgYXJlIGF1dG9tYXRpY2FsbHkgZ2VuZXJhdGVkIGFuZCBhcmUgYXZhaWxhYmxlIHdpdGggdGhlIHN0YW5kYXJkDQpTeXN0ZW1WaXNpb24gc3ltYm9sIGJyb3dzZXIuDQoNCkluIGFkZGl0aW9uIHRvIHRoZSBNb2RlbCBOYW1lIGFuZCBQZXJ0ICMgaW5mb3JtYXRpb24sIHRoZSBtb2RlbCBzb3VyY2UgYWxzbyBjb250YWlucyBhbnkgQ29tbWVudHMgc3VwcGxpZWQgd2hlbiBjcmVhdGluZyB0aGUgbW9kZWwuDQoNCklmIGEgbW9kZWwgYWxyZWFkeSBleGlzdHMgaW4geW91ciBsb2NhbCBTeXN0ZW1WaXNpb24gbGlicmFyeSwgYnV0IHdhcyBub3QgZ2VuZXJhdGVkIGJ5IHRoZSBEYXRhc2hlZXQgTW9kZWwgQnVpbGRlciwgYSBuZXcgbW9kZWwgbmFtZSBtdXN0IGJlIHN1cHBsaWVkIGFzIGl0IGNhbm5vdCBiZSBvdmVyLXdyaXR0ZW4uDQoNCk9uIHRoZSBvdGhlciBoYW5kLCBhbmQgbW9kZWwgY3JlYXRlZCBieSB0aGUgRGF0YXNoZWV0IE1vZGVsIEJ1aWxkZXIgY2FuIGJlIG92ZXItd3JpdHRlbiBieSB0eXBpbmcgaW4gYSBNb2RlbCBOYW1lIHRoYXQgbWF0Y2hlcyBhbg0KZXhpc3RpbmcgbW9kZWwuIEluIHRoaXMgaW5zdGFuY2UsIGJvdGggdGhlIERhdGFzaGVldCBNb2RlbCBCdWlsZGVyIGRhdGEgYXMgd2VsbCBhcyB0aGUgYWN0dWFsIG1vZGVsIGFuZCBzeW1ib2wgZmlsZXMgaW4gU3lzdGVtVmlzaW9uIHdpbGwgYmUgb3Zlci13cml0dGVuLg0KDQpPbmNlIGEgbW9kZWwgaXMgY3JlYXRlZCwgaWYgeW91IHdvdWxkIGxpa2UgdG8gY2hhbmdlIGFueSBwYXJhbWV0ZXJzIGluIHRoZSBtb2RlbCwgeW91IG11c3QgcmVjcmVhdGUgaXQgdXNpbmcgdGhlIERhdGFzaGVldCBNb2RlbCBCdWlsZGVyLiBUaGUgZ2VuZXJhdGVkIG1vZGVsIHBhcmFtZXRlcnMgYXJlIGZpeGVkIHdpdGhpbiB0aGUgbW9kZWwuIElmIHlvdSBkZXNpcmUgYSBtb2RlbCB3aG9zZSB2YWx1ZXMgY2FuIGJlIGNoYW5nZWQgb24gdGhlIHNjaGVtYXRpYywgeW91IHNob3VsZCBpbnN0ZWFkIHVzZSB0aGUgY29ycmVzcG9uZGluZyBtb2RlbHMgd2l0aCB0aGUgIl9kYXRhc2hlZXQiIHN1ZmZpeCB0aGF0IGFyZSBhdmFpbGFibGUgaW4gdGhlIHN0YW5kYXJkIFN5c3RlbVZpc2lvbiBsaWJyYXJpZXMuDQoNClRoZSBEYXRhc2hlZXQgTW9kZWwgQnVpbGRlciB3aWxsIHN0b3JlIGFsbCB0aGUgbW9kZWxzIHlvdSBoYXZlIGNyZWF0ZWQsIGZvciBhbnkgU3lzdGVtVmlzaW9uIHByb2plY3RzIHlvdSBhcmUgd29ya2luZyBvbi4gVGhpcyBhbGxvd3MgeW91IHRvIHJlZ2VuZXJhdGUgYW55IG1vZGVsIHlvdSBoYXZlIGNyZWF0ZWQgZm9yIG9uZSBwcm9qZWN0IGZvciB1c2UgaW4gYW5vdGhlciBwcm9qZWN0Lg0KDQpUaGUgcHVsbGRvd24gbW9kZWwgc2VsZWN0aW9uIGNvbnRyb2wgZG9lcyBub3QgYWxsb3cgeW91IHRvIHR5cGUgaW50byBpdCBhbmQgc2VhcmNoIGZvciBhIG1vZGVsIC0geW91IG11c3QgY2xpY2sgb24gdGhlIGFycm93IGFuZCB1c2UgdGhlIGRyb3Bkb3duIGZlYXR1cmUgdG8gc2VsZWN0IGEgbW9kZWwuDQoNClRoZSBEYXRhc2hlZXQgTW9kZWwgQnVpbGRlciBkaXNhYmxlcyB0aGUgcGFnZSBicm93c2luZyBmdW5jdGlvbmFsaXR5IG9mIHRoZSBhbHQtbGVmdC1hcnJvdywgYWx0LXJpZ2h0LWFycm93LCBhbmQgYmFja3NwYWNlIGtleXMuIFRoaXMgaGVscHMgYXZvaWQgdW5pbnRlbnRpb25hbCBwYWdlIGNoYW5naW5nIGFuZCBwb3NzaWJseSBsb3NpbmcgeW91ciBpbnB1dHMuIA0KDQoNCg=="}},i.getTestPaper=function(){return Raphael("testPaper",100,80)},i.removeTestPaper=function(n){n.remove()},i.getTemplateModelSource=function(){return"-------------------------------------------------------------------------------\r\n-- Model Title: Model Template \r\n-- Entity Name: model_template \r\n-- Author: My Name, Affiliation \r\n-- Created: 2015/06/07 \r\n-- Last update: \r\n-------------------------------------------------------------------------------\r\n-- Description: This description will appear as a tooltip when component is hovered in browser \r\n-- \r\n-- Additional description info can be placed here. It will also be available in the tooltip \r\n-------------------------------------------------------------------------------\r\n \r\nlibrary IEEE;\r\n-- The 'use' clause allows direct access to items in a given library (e.g. for items related to a given technology type) \r\nuse IEEE.electrical_systems.all;\r\n \r\n-- The entity specifies how this model interfaces with the outside world \r\nentity model_template is\r\n \r\n\t-- Generics are the parameters that the user of the model can change from the schematic \r\n\t-- An example of a generic called 'res' of type 'resistance' with units 'Ohm' is shown below \r\n\t-- generic (\r\n\t\t-- res : resistance); -- Generic description [Ohm]\r\n \r\n\t-- Ports represent the pins for the model. These pins are used to connect to other models in the schematic \r\n\t-- An example of two pins, p1 and p2, are specified below. These pins are of type terminal (which means they consist of \r\n\t-- both across and through aspects, and will obey conservation laws). They are also of the electrical subtype (nature) \r\n\t-- which means that the across aspect is voltage and the through aspect is current \r\n\t-- port (\r\n\t\t-- terminal p1, p2 : electrical);\r\n \r\nend entity model_template;\r\n \r\n-- The architecture specifies the functionality of the model \r\narchitecture default of model_template is\r\n \r\n\t-- 'Branch' quantities can be used to assign identifiers to across and through pin aspects so they can be used in equations\r\n\t-- In the example below, 'v' and 'i' are assigned as the respective across and through aspects for both p1 and p2 \r\n\t-- quantity v across i through p1 to p2;\r\n \r\nbegin\r\n \r\n\t-- Equation(s) that govern the model behavior\r\n\t-- Example below shows enforcement of Ohm's law using quantities 'v' and 'i', and generic 'res' \r\n\t\t-- v == i*res;\r\n \r\nend architecture default;\r\n \r\n"},i.getResistorModelSource=function(){return"-------------------------------------------------------------------------------\r\n-- Model Title: Resistor \r\n-- Entity Name: Resistor \r\n-- Author: Scott, MGC \r\n-- Created: 2015/06/07 \r\n-- Last update: \r\n-------------------------------------------------------------------------------\r\n-- Description: This is a resistance effect model \r\n-- \r\n-- This model can be used to model a resistance whose value can be set by the user \r\n-------------------------------------------------------------------------------\r\n \r\nlibrary IEEE;\r\n-- The 'use' clause allows direct access to items in a given library (e.g. for items related to a given technology type) \r\nuse IEEE.electrical_systems.all;\r\n \r\n-- The entity specifies how this model interfaces with the outside world \r\nentity Resistor is\r\n \r\n\t-- Generics are the parameters that the user of the model can change from the schematic \r\n\t-- An example of a generic called 'res' of type 'resistance' with units 'Ohm' is shown below \r\n\t-- generic (\r\n\t\t-- res : resistance); -- Generic description [Ohm]\r\n \r\n\t-- Ports represent the pins for the model. These pins are used to connect to other models in the schematic \r\n\t-- An example of two pins, p1 and p2, are specified below. These pins are of type terminal (which means they consist of \r\n\t-- both across and through aspects, and will obey conservation laws). They are also of the electrical subtype (nature) \r\n\t-- which means that the across aspect is voltage and the through aspect is current \r\n\t-- port (\r\n\t\t-- terminal p1, p2 : electrical);\r\n \r\nend entity Resistor;\r\n \r\n-- The architecture specifies the functionality of the model \r\narchitecture default of Resistor is\r\n \r\n\t-- 'Branch' quantities can be used to assign identifiers to across and through pin aspects so they can be used in equations\r\n\t-- In the example below, 'v' and 'i' are assigned as the respective across and through aspects for both p1 and p2 \r\n\t-- quantity v across i through p1 to p2;\r\n \r\nbegin\r\n \r\n\t-- Equation(s) that govern the model behavior\r\n\t-- Example below shows enforcement of Ohm's law using quantities 'v' and 'i', and generic 'res' \r\n\t\t-- v == i*res;\r\n \r\nend architecture default;\r\n \r\n"},i.getResistorImageSource=function(){return'<svg viewbox="0,0,120,80" style="overflow: hidden; position: relative;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="120" version="1.1" height="80"><rect transform="matrix(1,0,0,1,20,0)" x="0" y="0" width="80" height="80" rx="0" ry="0" fill="#ffffff" stroke="#000000" stroke-width="3" r="0" class="svw_sym svw_sym_shape svw_sym_outline"><\/rect><path transform="matrix(-1,0,0,-1,150,110)" fill="none" stroke="#000" d="M150,70L130,70Z" stroke-width="3" opacity="1"  class="svw_sym svw_sym_pin_whisker_elec"><\/path><path transform="matrix(1,0,0,1,-30,-40)" fill="none" stroke="#000" d="M150,80L130,80Z" stroke-width="3" opacity="1"  class="svw_sym svw_sym_pin_whisker_elec"><\/path><text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal bold 12px/normal Arial;" x="24" y="17" text-anchor="start"   stroke="none" fill="#000000"  class="svw_sym_text"><tspan dy="0">CE RES 10K<\/tspan><\/text><text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal normal 10px/normal Arial;" x="26" y="42" text-anchor="start"   stroke="none" fill="#000000"  class="svw_sym_text"><tspan dy="0">p1<\/tspan><\/text><text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal normal 10px/normal Arial;" x="82" y="42" text-anchor="start"   stroke="none" fill="#000000"  class="svw_sym_text"><tspan dy="0">p2<\/tspan><\/text><\/svg>'},i.getTestComponentModelSource=function(){return"-------------------------------------------------------------------------------\r\n-- Model Title: Test Component \r\n-- Entity Name: Test_Component \r\n-- Author: My Name, Affiliation \r\n-- Created: 2016/08/19 \r\n-- Last update: \r\n-------------------------------------------------------------------------------\r\n-- Description: This description will appear as a tooltip when component is hovered in browser \r\n-- \r\n-- Additional description info can be placed here. It will also be available in the tooltip \r\n-------------------------------------------------------------------------------\r\n \r\nlibrary IEEE;\r\n-- The 'use' clause allows direct access to items in a given library (e.g. for items related to a given technology type) \r\nuse IEEE.electrical_systems.all;\r\n \r\n-- The entity specifies how this model interfaces with the outside world \r\nentity Test_Component is\r\n \r\n\t-- Generics are the parameters that the user of the model can change from the schematic \r\n\t-- An example of a generic called 'res' of type 'resistance' with units 'Ohm' is shown below \r\n\t-- generic (\r\n\t\t-- res : resistance); -- Generic description [Ohm]\r\n \r\n\t-- Ports represent the pins for the model. These pins are used to connect to other models in the schematic \r\n\t-- An example of two pins, p1 and p2, are specified below. These pins are of type terminal (which means they consist of \r\n\t-- both across and through aspects, and will obey conservation laws). They are also of the electrical subtype (nature) \r\n\t-- which means that the across aspect is voltage and the through aspect is current \r\n\t-- port (\r\n\t\t-- terminal p1, p2 : electrical);\r\n \r\nend entity Test_Component;\r\n \r\n-- The architecture specifies the functionality of the model \r\narchitecture default of Test_Component is\r\n \r\n\t-- 'Branch' quantities can be used to assign identifiers to across and through pin aspects so they can be used in equations\r\n\t-- In the example below, 'v' and 'i' are assigned as the respective across and through aspects for both p1 and p2 \r\n\t-- quantity v across i through p1 to p2;\r\n \r\nbegin\r\n \r\n\t-- Equation(s) that govern the model behavior\r\n\t-- Example below shows enforcement of Ohm's law using quantities 'v' and 'i', and generic 'res' \r\n\t\t-- v == i*res;\r\n \r\nend architecture default;\r\n \r\n"},i.getComponentDefault=function(){var t=new n.CeComponent,i,r,u,f,e;return t.Title="Test Component",t.Name="Test_Component",t.PartNumber=t.Name,t.Comments="Comment for DMB comp",t.Prefix="u",t.Src=this.getTemplateModelSource(),t.Lib="UserLib",t.ShowComponent=!1,t.Tags="Test Comp",t.Url="comp URL",t.Visibility=n.CE_VISIBILITY.PUBLIC,t.DateModified="Date Modified",t.CreationDate="Date Created",t.BaseName="",t.Author=n.Settings.UUID,t.Status=n.CE_STATUS.DONE,t.ComponentId="TestCompId",t.Cx=100,t.Cy=100,t.ModelType=n.CE_MODEL_TYPE.VHDL,t.Img=this.getResistorImageSource(),i=[],i.push("My Components"),i.push("Shared Components"),t.Categories=i,t.Description="Description of test comp",t.DescriptionToolTip="TT for test comp",r=[],r.push(new n.CeArchitecture("Default")),r.push(new n.CeArchitecture("Advanced")),t.Architectures=r,u=[],u.push(new n.CePin("p1",n.CE_PIN_TYPE.TERMINAL,"electrical",n.CE_PIN_MODE.NONE,1,"","",0,20,n.CE_PIN_ORIENTATION.WEST)),u.push(new n.CePin("p2",n.CE_PIN_TYPE.TERMINAL,"electrical",n.CE_PIN_MODE.NONE,2,"","",80,20,n.CE_PIN_ORIENTATION.EAST)),t.Pins=u,f=[],f.push(new n.CeProperty("res","resistance","1.0","","",n.CE_DIST_TYPE.NONE,"Resistance value","Ohms",n.CE_PROP_VISIBILITY.NONE)),f.push(new n.CeProperty("esl","inductance","1.0n","","",n.CE_DIST_TYPE.NONE,"Series Inductance value","H",n.CE_PROP_VISIBILITY.NONE)),t.Properties=f,e=[],e.push(new n.CeRevision("TestCompId","Revision description",!1,"Revision Date")),t.Revisions=e,t},i}();n.ClientTestInputData=i}(Project||(Project={})),function(n){var t=function(){function t(t,i){this.isUpdate=!1;this.testId="testModelEditor";this.clientTestManager=t;this.surface=i;this.clientTestResults=new n.ClientTestResults}return t.prototype.runTests=function(){var t=this,u=this,i=$.Deferred(),f=this.getDbTestComp(),r;return $.when(f).done(function(){n.ClientTestManager.showFlow&&console.log("GET comp complete");r=t.postPutDbTestComp();$.when(r).done(function(){var r,f,e,o;n.ClientTestManager.showFlow&&console.log("Post/Put comp complete");t.modelEditor=new n.ModelEditor(t.surface,n.ClientTestInputData.getComponentDefault(),!0,n.CE_MODEL_TYPE.VHDL,!0);r=5e3;f=3e3;t.clientTestResults.setExpectedResult("model_template");e=t.parseComp(n.ClientTestInputData.getTemplateModelSource(),t.clientTestResults);$.when(e).done(function(){n.ClientTestManager.showFlow&&console.log("After initial parse");t.clientTestManager.testAssertion.testIdNotes("ModelEditor: Test initial name (model_template)");t.clientTestManager.testAssertion.assertEqualString("model_template",t.clientTestResults.getReturnVal());setTimeout(function(){t.clientTestManager.testAssertion.testIdNotes("ModelEditor: Test final name (Resistor)");t.clientTestResults.setExpectedResult("Resistor");var r=t.modelEditor.updateModelSourceWithName(n.ClientTestInputData.getResistorModelSource());o=t.parseComp(r,t.clientTestResults);$.when(o).done(function(){t.clientTestManager.testAssertion.assertEqualString("Resistor",t.clientTestResults.getReturnVal());n.ClientTestManager.showFlow&&console.log("After final parse");setTimeout(function(){u.cleanup();i.resolve()},f)})},r)})})}),i.promise()},t.prototype.cleanup=function(){this.modelEditor.closeModelEditorDialog();this.deleteComp(n.ClientTestInputData.getComponentDefault().ComponentId)},t.prototype.getDbTestComp=function(){var n=$.Deferred();return setTimeout(function(){n.resolve()},this.clientTestManager.bogusTestDelay),n.promise()},t.prototype.postPutDbTestComp=function(){var t=$.Deferred(),i="",r;return i=this.isUpdate?"/components?library=UserLib&componentId="+n.ClientTestInputData.getComponentDefault().ComponentId:"/components?library=UserLib",r=n.Settings.APIURI()+i,$.ajax({type:this.isUpdate?"PUT":"POST",url:r,data:JSON.stringify(n.ClientTestInputData.getComponentDefault()),contentType:"application/json"}).done(function(){t.resolve()}).fail(function(i){var r="Unit test component could not be saved: <br />"+i.responseText+" <br />You may need to click the Save new model button so your component can be recreated.";n.MessageManager.showErrorMessage(r);t.resolve()}),t.promise()},t.prototype.parseComp=function(t,i){var r=$.Deferred();return $.ajax({type:"POST",url:n.Settings.APIURI()+"/componentparser",data:JSON.stringify({Model:t}),contentType:"application/json"}).done(function(n){i.setReturnVal(n.Name);r.resolve()}).fail(function(){r.resolve()}),r.promise()},t.prototype.deleteComp=function(t){var i="?library=UserLib&componentId="+t;$.ajax({type:"DELETE",url:n.Settings.APIURI()+"/components/"+i,contentType:"application/json"}).done(function(){console.log("Unit test component deleted")}).fail(function(){console.log("Delete unit test component failed")})},t}();n.TestModelEditor=t}(Project||(Project={})),function(n){var t=function(){function t(t,i){this.testId="testSE";this.clientTestManager=t;this.symEditPaper=Raphael("testPaper",400,400);var r=n.CeUtility.getSVGElements(n.ClientTestInputData.getSvg(),this.symEditPaper);this.ceSymImage=new n.CeSymImage(i,this.symEditPaper)}return t.prototype.runTests=function(){var u=this,t=$.Deferred(),i=-1,r=-1;return n.MessageManager.removeAllMessages(),this.clientTestManager.testAssertion.testIdNotes("ImageImport: Test Proper Image Type"),this.ceSymImage.addImg2Svg(n.ClientTestInputData.getImage(n.IMAGE_TEST_DATA.GOOD_IMAGE)),i=n.MessageManager.getMessageList().length,this.clientTestManager.testAssertion.assertEqualString("0",i.toString()),n.MessageManager.removeAllMessages(),this.clientTestManager.testAssertion.testIdNotes("ImageImport: Test Improper Image Type (text)"),this.ceSymImage.addImg2Svg(n.ClientTestInputData.getImage(n.IMAGE_TEST_DATA.GOOD_TEXT)),r=n.MessageManager.getMessageList().length,this.clientTestManager.testAssertion.assertEqualString("1",r.toString()),this.removePaper(),setTimeout(function(){t.resolve()},this.clientTestManager.bogusTestDelay),t.promise()},t.prototype.removePaper=function(){this.symEditPaper.remove()},t}();n.TestSymbolEditor=t}(Project||(Project={})),function(n){var t=function(){function t(t){this.testId="testPropertyEditor";this.clientTestManager=t;this.prop=new n.CompProperty}return t.prototype.runTests=function(){var t=$.Deferred();return this.prop.Minimum="",this.prop.Typical="1000",this.prop.Maximum="",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Typ (no SI) prop only"),this.clientTestManager.testAssertion.assertEqualString(this.prop.Typical,n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="",this.prop.Typical="1k",this.prop.Maximum="",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Typ (SI) prop only"),this.clientTestManager.testAssertion.assertEqualString(this.prop.Typical,n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="1m",this.prop.Typical="",this.prop.Maximum="",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Min prop only"),this.clientTestManager.testAssertion.assertEqualString(this.prop.Minimum,n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="",this.prop.Typical="",this.prop.Maximum="10u",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Max prop only"),this.clientTestManager.testAssertion.assertEqualString(this.prop.Maximum,n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="1k",this.prop.Typical="",this.prop.Maximum="2k",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Min and Max props only"),this.clientTestManager.testAssertion.assertEqualString("1500",n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="1k",this.prop.Typical="2k",this.prop.Maximum="",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Min and Typ props only"),this.clientTestManager.testAssertion.assertEqualString(this.prop.Typical,n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="",this.prop.Typical="2k",this.prop.Maximum="5k",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Typ and Max props only"),this.clientTestManager.testAssertion.assertEqualString(this.prop.Typical,n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="1k",this.prop.Typical="2k",this.prop.Maximum="3k",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test Min, Typ, and Max props"),this.clientTestManager.testAssertion.assertEqualString(this.prop.Typical,n.Utility.getPropTypFromMinTypMax(this.prop)),this.prop.Minimum="",this.prop.Typical="",this.prop.Maximum="",this.clientTestManager.testAssertion.testIdNotes("PropEd: Test no props supplied"),this.clientTestManager.testAssertion.assertEqualString("",n.Utility.getPropTypFromMinTypMax(this.prop)),setTimeout(function(){t.resolve()},this.clientTestManager.bogusTestDelay),t.promise()},t}();n.TestPropertyEditor=t}(Project||(Project={})),function(n){var t=function(){function n(n){this.testId="testDMB";this.clientTestManager=n;this.props=new Dmb.FormValidation;this.propFormatter=new Dmb.PropertyFormatter}return n.prototype.runTests=function(){var n=$.Deferred();return this.initDmbPropsTests(),this.initDmbSI2NumberTests(),this.initDmbCellValidation(),setTimeout(function(){n.resolve()},this.clientTestManager.bogusTestDelay),n.promise()},n.prototype.initDmbPropsTests=function(){var n=[];n.length=0;n.push("Unused");n.push("1");n.push("2");n.push("3");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Pos, Min, Typ, & Max No Suffix, [min1, typ2, max3]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("1m");n.push("2m");n.push("3m");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Pos, Min, Typ, & Max SI Suffix, [min1m, typ2m, max3m]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("-1");n.push("-2");n.push("-3");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Neg, Min, Typ, & Max No Suffix, [min-1, typ-2, max-3]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("-1m");n.push("-2m");n.push("-3m");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Neg, Min, Typ, & Max SI Suffix, [min-1m, typ-2m, max-3m]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("-2");n.push("0");n.push("1");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Mixed-Sign Min, Typ, & Max No Suffix, [min-2, typ0, max1]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("-2k");n.push("0k");n.push("1k");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Mixed-Sign Min, Typ, & Max SI Suffix, [min-2k, typ0k, max1k]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("5k");n.push("");n.push("");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Minimum Only, [min5k]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("");n.push("5k");n.push("");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Typical Only, [typ5k]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("");n.push("");n.push("5k");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Maximum Only, [max5k]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("3k");n.push("5k");n.push("");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Min and Typ Only, [min3k, typ5k]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("");n.push("5k");n.push("10k");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Typ and Max Only, [typ5k, max10k]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("1k");n.push("");n.push("2k");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Valid Min and Max Only, [min1k, max2k]");this.clientTestManager.testAssertion.assertIsFalse(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("1");n.push("3");n.push("2");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Pos Min, Typ, & Max No Suffix, [min1, typ3, max2]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("1m");n.push("3m");n.push("2m");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Pos Min, Typ, & Max SI Suffix, [min1m, typ3m, max2m]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("-3");n.push("-2");n.push("-1");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Neg Min, Typ, & Max No Suffix, [min-3, typ-2, max-1]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("-1m");n.push("-3m");n.push("-2m");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Neg Min, Typ, & Max SI Suffix, [min-1m, typ-3m, max-2m]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("2");n.push("0");n.push("-1");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Mixed-Sign Min, Typ, & Max No Suffix, [min2, typ0, max-1]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("2k");n.push("0k");n.push("-1k");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Mixed-Sign Min, Typ, & Max SI Suffix, [min2k, typ0k, max-1k]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("5k");n.push("3k");n.push("");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Min and Typ Only, [min5k, typ3k]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("");n.push("15k");n.push("10k");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Typ and Max Only, [typ15k, max10k]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n));n.length=0;n.push("Unused");n.push("3k");n.push("");n.push("2k");this.clientTestManager.testAssertion.testIdNotes("DMB Props: Invalid Min and Max Only, [min3k, max2k]");this.clientTestManager.testAssertion.assertIsTrue(this.props.ValidateRow(n))},n.prototype.initDmbSI2NumberTests=function(){var n="DMB SI2Double in DmbPropertyFormatter ";this.clientTestManager.testAssertion.testIdNotes(n+"10k");this.clientTestManager.testAssertion.assertEqualValue("10.0e3",this.propFormatter.SIUnitPrefixes2Double("10k"));this.clientTestManager.testAssertion.testIdNotes(n+"10Meg");this.clientTestManager.testAssertion.assertEqualValue("10.0e6",this.propFormatter.SIUnitPrefixes2Double("10Meg"));this.clientTestManager.testAssertion.testIdNotes(n+"10G");this.clientTestManager.testAssertion.assertEqualValue("10.0e9",this.propFormatter.SIUnitPrefixes2Double("10G"));this.clientTestManager.testAssertion.testIdNotes(n+"10T");this.clientTestManager.testAssertion.assertEqualValue("10.0e12",this.propFormatter.SIUnitPrefixes2Double("10T"));this.clientTestManager.testAssertion.testIdNotes(n+"10m");this.clientTestManager.testAssertion.assertEqualValue("10.0e-3",this.propFormatter.SIUnitPrefixes2Double("10m"));this.clientTestManager.testAssertion.testIdNotes(n+"10u");this.clientTestManager.testAssertion.assertEqualValue("10.0e-6",this.propFormatter.SIUnitPrefixes2Double("10u"));this.clientTestManager.testAssertion.testIdNotes(n+"10n");this.clientTestManager.testAssertion.assertEqualValue("10.0e-9",this.propFormatter.SIUnitPrefixes2Double("10n"));this.clientTestManager.testAssertion.testIdNotes(n+"10p");this.clientTestManager.testAssertion.assertEqualValue("10.0e-12",this.propFormatter.SIUnitPrefixes2Double("10p"));this.clientTestManager.testAssertion.testIdNotes(n+"10f");this.clientTestManager.testAssertion.assertEqualValue("10.0e-15",this.propFormatter.SIUnitPrefixes2Double("10f"));this.clientTestManager.testAssertion.testIdNotes(n+"10b");this.clientTestManager.testAssertion.assertEqualValue("-1",this.propFormatter.SIUnitPrefixes2Double("10b"))},n.prototype.initDmbCellValidation=function(){var n="DMB cell validation in DmbPropertyFormatter ";this.clientTestManager.testAssertion.testIdNotes(n+"(real) 10.1k");this.clientTestManager.testAssertion.assertEqualString("10.1k",this.propFormatter.ValidateInputValue("real","10.1k"));this.clientTestManager.testAssertion.testIdNotes(n+"(real) 10e3");this.clientTestManager.testAssertion.assertEqualString("10e3",this.propFormatter.ValidateInputValue("real","10e3"));this.clientTestManager.testAssertion.testIdNotes(n+"(real) 10e3 ms");this.clientTestManager.testAssertion.assertEqualString(this.propFormatter.errorWarningMessages.ErrorDoubleFormat(),this.propFormatter.ValidateInputValue("real","10e3 ms"));this.clientTestManager.testAssertion.testIdNotes(n+"(time) 10m");this.clientTestManager.testAssertion.assertEqualString("10m",this.propFormatter.ValidateInputValue("time","10m"));this.clientTestManager.testAssertion.testIdNotes(n+"(time) 10e-3");this.clientTestManager.testAssertion.assertEqualString("10e-3",this.propFormatter.ValidateInputValue("time","10e-3"));this.clientTestManager.testAssertion.testIdNotes(n+"(time) 10e-3 ms");this.clientTestManager.testAssertion.assertEqualString(this.propFormatter.errorWarningMessages.ErrorTimeFormat(),this.propFormatter.ValidateInputValue("time","10e-3 ms"));this.clientTestManager.testAssertion.testIdNotes(n+"(integer) 10.0k");this.clientTestManager.testAssertion.assertEqualString("10.0k",this.propFormatter.ValidateInputValue("integer","10.0k"));this.clientTestManager.testAssertion.testIdNotes(n+"(integer) 10e3");this.clientTestManager.testAssertion.assertEqualString("10e3",this.propFormatter.ValidateInputValue("integer","10e3"));this.clientTestManager.testAssertion.testIdNotes(n+"(integer) 10e-3");this.clientTestManager.testAssertion.assertEqualString(this.propFormatter.errorWarningMessages.ErrorIntegerFormat(),this.propFormatter.ValidateInputValue("integer","10e-3"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) 1");this.clientTestManager.testAssertion.assertEqualString("1",this.propFormatter.ValidateInputValue("std_logic","1"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) 0");this.clientTestManager.testAssertion.assertEqualString("0",this.propFormatter.ValidateInputValue("std_logic","0"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) X");this.clientTestManager.testAssertion.assertEqualString("X",this.propFormatter.ValidateInputValue("std_logic","X"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) Z");this.clientTestManager.testAssertion.assertEqualString("Z",this.propFormatter.ValidateInputValue("std_logic","Z"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) W");this.clientTestManager.testAssertion.assertEqualString("W",this.propFormatter.ValidateInputValue("std_logic","W"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) L");this.clientTestManager.testAssertion.assertEqualString("L",this.propFormatter.ValidateInputValue("std_logic","L"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) H");this.clientTestManager.testAssertion.assertEqualString("H",this.propFormatter.ValidateInputValue("std_logic","H"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) -");this.clientTestManager.testAssertion.assertEqualString("-",this.propFormatter.ValidateInputValue("std_logic","-"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) U");this.clientTestManager.testAssertion.assertEqualString("U",this.propFormatter.ValidateInputValue("std_logic","U"));this.clientTestManager.testAssertion.testIdNotes(n+"(std_logic) 3");this.clientTestManager.testAssertion.assertEqualString(this.propFormatter.errorWarningMessages.ErrorStdLogicFormat(),this.propFormatter.ValidateInputValue("std_logic","3"));this.clientTestManager.testAssertion.testIdNotes(n+"(bit) 0");this.clientTestManager.testAssertion.assertEqualString("0",this.propFormatter.ValidateInputValue("bit","0"));this.clientTestManager.testAssertion.testIdNotes(n+"(bit) 1");this.clientTestManager.testAssertion.assertEqualString("1",this.propFormatter.ValidateInputValue("bit","1"));this.clientTestManager.testAssertion.testIdNotes(n+"(bit) 3");this.clientTestManager.testAssertion.assertEqualString(this.propFormatter.errorWarningMessages.ErrorBitFormat(),this.propFormatter.ValidateInputValue("bit","3"));this.clientTestManager.testAssertion.testIdNotes(n+"(boolean) true");this.clientTestManager.testAssertion.assertEqualString("true",this.propFormatter.ValidateInputValue("boolean","true"));this.clientTestManager.testAssertion.testIdNotes(n+"(boolean) false");this.clientTestManager.testAssertion.assertEqualString("false",this.propFormatter.ValidateInputValue("boolean","false"));this.clientTestManager.testAssertion.testIdNotes(n+"(boolean) 0");this.clientTestManager.testAssertion.assertEqualString(this.propFormatter.errorWarningMessages.ErrorBooleanFormat(),this.propFormatter.ValidateInputValue("boolean","0"));this.clientTestManager.testAssertion.testIdNotes(n+"(MyType) 10k");this.clientTestManager.testAssertion.assertEqualString("10k",this.propFormatter.ValidateInputValue("MyType","10k"))},n}();n.TestDMB=t}(Project||(Project={})),function(n){var t=function(){function t(t){this.testId="testCssClassManager";this.clientTestManager=t;this.cssClassManager=new n.CssClassManager(null)}return t.prototype.runTests=function(){var t=$.Deferred(),n="svw_sym_pin_whisker_";return this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker electrical"),this.clientTestManager.testAssertion.assertEqualString(n+"elec",this.cssClassManager.getWhiskerClass("electrical")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker rotational"),this.clientTestManager.testAssertion.assertEqualString(n+"r",this.cssClassManager.getWhiskerClass("rotational")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker rotational_velocity"),this.clientTestManager.testAssertion.assertEqualString(n+"rv",this.cssClassManager.getWhiskerClass("rotational_velocity")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker translational"),this.clientTestManager.testAssertion.assertEqualString(n+"t",this.cssClassManager.getWhiskerClass("translational")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker translational_velocity"),this.clientTestManager.testAssertion.assertEqualString(n+"tv",this.cssClassManager.getWhiskerClass("translational_velocity")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker thermal"),this.clientTestManager.testAssertion.assertEqualString(n+"th",this.cssClassManager.getWhiskerClass("thermal")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker magnetic"),this.clientTestManager.testAssertion.assertEqualString(n+"mag",this.cssClassManager.getWhiskerClass("magnetic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker fluidic"),this.clientTestManager.testAssertion.assertEqualString(n+"flu",this.cssClassManager.getWhiskerClass("fluidic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker compressible_fluidic"),this.clientTestManager.testAssertion.assertEqualString(n+"cflu",this.cssClassManager.getWhiskerClass("compressible_fluidic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker radiant"),this.clientTestManager.testAssertion.assertEqualString(n+"rad",this.cssClassManager.getWhiskerClass("radiant")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker quantity"),this.clientTestManager.testAssertion.assertEqualString(n+"qty",this.cssClassManager.getWhiskerClass(1)),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker std_logic"),this.clientTestManager.testAssertion.assertEqualString(n+"dig_sig",this.cssClassManager.getWhiskerClass("std_logic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker real sig"),this.clientTestManager.testAssertion.assertEqualString(n+"real_sig",this.cssClassManager.getWhiskerClass("real")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker integer sig"),this.clientTestManager.testAssertion.assertEqualString(n+"int_sig",this.cssClassManager.getWhiskerClass("integer")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker bool sig"),this.clientTestManager.testAssertion.assertEqualString(n+"bool_sig",this.cssClassManager.getWhiskerClass("boolean")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker bit sig"),this.clientTestManager.testAssertion.assertEqualString(n+"bit_sig",this.cssClassManager.getWhiskerClass("bit")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker custom subtype"),this.clientTestManager.testAssertion.assertEqualString(n+"other_term",this.cssClassManager.getWhiskerClass("MySubType")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker electrical_vector"),this.clientTestManager.testAssertion.assertEqualString(n+"elec",this.cssClassManager.getWhiskerClass("electrical_vector")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test whisker MySubType_vector"),this.clientTestManager.testAssertion.assertEqualString(n+"other_term",this.cssClassManager.getWhiskerClass("MySubType_vector")),n="svw_sym_pin_indicator_",this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator electrical"),this.clientTestManager.testAssertion.assertEqualString(n+"elec",this.cssClassManager.getIndicatorClass("electrical")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator rotational"),this.clientTestManager.testAssertion.assertEqualString(n+"r",this.cssClassManager.getIndicatorClass("rotational")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator rotational_velocity"),this.clientTestManager.testAssertion.assertEqualString(n+"rv",this.cssClassManager.getIndicatorClass("rotational_velocity")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator translational"),this.clientTestManager.testAssertion.assertEqualString(n+"t",this.cssClassManager.getIndicatorClass("translational")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator translational_velocity"),this.clientTestManager.testAssertion.assertEqualString(n+"tv",this.cssClassManager.getIndicatorClass("translational_velocity")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator thermal"),this.clientTestManager.testAssertion.assertEqualString(n+"th",this.cssClassManager.getIndicatorClass("thermal")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator magnetic"),this.clientTestManager.testAssertion.assertEqualString(n+"mag",this.cssClassManager.getIndicatorClass("magnetic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator fluidic"),this.clientTestManager.testAssertion.assertEqualString(n+"flu",this.cssClassManager.getIndicatorClass("fluidic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator compressible_fluidic"),this.clientTestManager.testAssertion.assertEqualString(n+"cflu",this.cssClassManager.getIndicatorClass("compressible_fluidic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator radiant"),this.clientTestManager.testAssertion.assertEqualString(n+"rad",this.cssClassManager.getIndicatorClass("radiant")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator quantity"),this.clientTestManager.testAssertion.assertEqualString(n+"qty",this.cssClassManager.getIndicatorClass(1)),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator std_logic"),this.clientTestManager.testAssertion.assertEqualString(n+"dig_sig",this.cssClassManager.getIndicatorClass("std_logic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator real sig"),this.clientTestManager.testAssertion.assertEqualString(n+"real_sig",this.cssClassManager.getIndicatorClass("real")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator integer sig"),this.clientTestManager.testAssertion.assertEqualString(n+"int_sig",this.cssClassManager.getIndicatorClass("integer")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator bool sig"),this.clientTestManager.testAssertion.assertEqualString(n+"bool_sig",this.cssClassManager.getIndicatorClass("boolean")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator bit sig"),this.clientTestManager.testAssertion.assertEqualString(n+"bit_sig",this.cssClassManager.getIndicatorClass("bit")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator custom subtype"),this.clientTestManager.testAssertion.assertEqualString(n+"other_term",this.cssClassManager.getIndicatorClass("MySubType")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator electrical_vector"),this.clientTestManager.testAssertion.assertEqualString(n+"elec",this.cssClassManager.getIndicatorClass("electrical_vector")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test indicator MySubType_vector"),this.clientTestManager.testAssertion.assertEqualString(n+"other_term",this.cssClassManager.getIndicatorClass("MySubType_vector")),n="svw_sym_arrow_",this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow quantity"),this.clientTestManager.testAssertion.assertEqualString(n+"qty",this.cssClassManager.getArrowClass(1)),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow std_logic"),this.clientTestManager.testAssertion.assertEqualString(n+"dig_sig",this.cssClassManager.getArrowClass("std_logic")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow real sig"),this.clientTestManager.testAssertion.assertEqualString(n+"real_sig",this.cssClassManager.getArrowClass("real")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow integer sig"),this.clientTestManager.testAssertion.assertEqualString(n+"int_sig",this.cssClassManager.getArrowClass("integer")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow bool sig"),this.clientTestManager.testAssertion.assertEqualString(n+"bool_sig",this.cssClassManager.getArrowClass("boolean")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow bit sig"),this.clientTestManager.testAssertion.assertEqualString(n+"bit_sig",this.cssClassManager.getArrowClass("bit")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow custom subtype"),this.clientTestManager.testAssertion.assertEqualString(n+"other_sig",this.cssClassManager.getArrowClass("MySubType")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow real_vector"),this.clientTestManager.testAssertion.assertEqualString(n+"real_sig",this.cssClassManager.getArrowClass("real_vector")),this.clientTestManager.testAssertion.testIdNotes("CssClassManager: Test arrow MySubType_vector"),this.clientTestManager.testAssertion.assertEqualString(n+"other_sig",this.cssClassManager.getArrowClass("MySubType_vector")),setTimeout(function(){t.resolve()},this.clientTestManager.bogusTestDelay),t.promise()},t}();n.TestCssClassManager=t}(Project||(Project={})),function(n){var t=function(){function t(t){this.testId="testCeUtilities";this.clientTestManager=t;this.prop=new n.CompProperty}return t.prototype.runTests=function(){var a=$.Deferred(),v,l,t,r,y,i,u,p,f,e,o,s,h,c;return this.clientTestManager.testAssertion.testIdNotes("CeUtility: Test endsWith"),this.clientTestManager.testAssertion.assertIsTrue(n.CeUtility.endsWith("mySuffixEnd","End")),v="beginMyPrefix",this.clientTestManager.testAssertion.testIdNotes("CeUtility: Test startsWith"),this.clientTestManager.testAssertion.assertIsTrue(n.CeUtility.startsWith(v,"begin")),l=n.CeUtility.getSvgWidthHeight(n.ClientTestInputData.getSvg()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: Get SVG string Width"),this.clientTestManager.testAssertion.assertEqualValue("120",l[0].toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: Get SVG string Height"),this.clientTestManager.testAssertion.assertEqualValue("80",l[1].toString()),t=[],y=n.ClientTestInputData.getSvg(),r=n.ClientTestInputData.getTestPaper(),t=n.CeUtility.getSVGElements(y,r),this.clientTestManager.testAssertion.testIdNotes("CeUtility: elements from svg length"),this.clientTestManager.testAssertion.assertEqualValue("8",t.length.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG rect element"),this.clientTestManager.testAssertion.assertEqualString("rect",t[0].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG path element"),this.clientTestManager.testAssertion.assertEqualString("path",t[1].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG path element"),this.clientTestManager.testAssertion.assertEqualString("path",t[2].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG path element"),this.clientTestManager.testAssertion.assertEqualString("path",t[3].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG text element"),this.clientTestManager.testAssertion.assertEqualString("text",t[4].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG text element"),this.clientTestManager.testAssertion.assertEqualString("text",t[5].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG text element"),this.clientTestManager.testAssertion.assertEqualString("text",t[6].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: SVG text element"),this.clientTestManager.testAssertion.assertEqualString("text",t[7].type),i=[],i=n.CeUtility.getPaperElements(r),this.clientTestManager.testAssertion.testIdNotes("CeUtility: elements from paper length"),this.clientTestManager.testAssertion.assertEqualValue("8",t.length.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper rect element"),this.clientTestManager.testAssertion.assertEqualString("rect",i[0].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper path element"),this.clientTestManager.testAssertion.assertEqualString("path",i[1].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper path element"),this.clientTestManager.testAssertion.assertEqualString("path",i[2].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper path element"),this.clientTestManager.testAssertion.assertEqualString("path",i[3].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper text element"),this.clientTestManager.testAssertion.assertEqualString("text",i[4].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper text element"),this.clientTestManager.testAssertion.assertEqualString("text",i[5].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper text element"),this.clientTestManager.testAssertion.assertEqualString("text",i[6].type),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper text element"),this.clientTestManager.testAssertion.assertEqualString("text",i[7].type),u=n.CeUtility.getPaperBBox(r),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper bb width"),this.clientTestManager.testAssertion.assertEqualValue("120",u.width.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper bb height"),this.clientTestManager.testAssertion.assertEqualValue("98",u.height.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper bb x"),this.clientTestManager.testAssertion.assertEqualValue("0",u.x.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper bb y"),this.clientTestManager.testAssertion.assertEqualValue("-18",u.y.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper bb x2"),this.clientTestManager.testAssertion.assertEqualValue("120",u.x2.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: paper bb y2"),this.clientTestManager.testAssertion.assertEqualValue("80",u.y2.toString()),p={width:-10.5,height:10.01,x:5.4,y:5.4,x2:5.5,y2:5.5},f=n.CeUtility.getRoundedBBVals(p),this.clientTestManager.testAssertion.testIdNotes("CeUtility: rounded bb width"),this.clientTestManager.testAssertion.assertEqualValue("-10",f.width.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: rounded bb height"),this.clientTestManager.testAssertion.assertEqualValue("10",f.height.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: rounded bb x"),this.clientTestManager.testAssertion.assertEqualValue("5",f.x.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: rounded bb y"),this.clientTestManager.testAssertion.assertEqualValue("5",f.y.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: rounded bb x2"),this.clientTestManager.testAssertion.assertEqualValue("6",f.x2.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: rounded bb y2"),this.clientTestManager.testAssertion.assertEqualValue("6",f.y2.toString()),e=n.CeUtility.getBBoxWithoutText(t),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoText width"),this.clientTestManager.testAssertion.assertEqualValue("120",e.width.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoText height"),this.clientTestManager.testAssertion.assertEqualValue("80",e.height.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoText x"),this.clientTestManager.testAssertion.assertEqualValue("0",e.x.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoText y"),this.clientTestManager.testAssertion.assertEqualValue("0",e.y.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoText x2"),this.clientTestManager.testAssertion.assertEqualValue("120",e.x2.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoText y2"),this.clientTestManager.testAssertion.assertEqualValue("80",e.y2.toString()),o=n.CeUtility.getPaperBBoxWithoutText(r),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoText width"),this.clientTestManager.testAssertion.assertEqualValue("120",o.width.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoText height"),this.clientTestManager.testAssertion.assertEqualValue("80",o.height.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoText x"),this.clientTestManager.testAssertion.assertEqualValue("0",o.x.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoText y"),this.clientTestManager.testAssertion.assertEqualValue("0",o.y.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoText x2"),this.clientTestManager.testAssertion.assertEqualValue("120",o.x2.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoText y2"),this.clientTestManager.testAssertion.assertEqualValue("80",o.y2.toString()),s=n.CeUtility.getPaperBBoxWithoutPinsText(r),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoTextPins width"),this.clientTestManager.testAssertion.assertEqualValue("80",s.width.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoTextPins height"),this.clientTestManager.testAssertion.assertEqualValue("80",s.height.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoTextPins x"),this.clientTestManager.testAssertion.assertEqualValue("20",s.x.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoTextPins y"),this.clientTestManager.testAssertion.assertEqualValue("0",s.y.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoTextPins x2"),this.clientTestManager.testAssertion.assertEqualValue("100",s.x2.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbPaperNoTextPins y2"),this.clientTestManager.testAssertion.assertEqualValue("80",s.y2.toString()),h=n.CeUtility.getBBoxWithoutPinsText(t),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoTextPins width"),this.clientTestManager.testAssertion.assertEqualValue("80",h.width.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoTextPins height"),this.clientTestManager.testAssertion.assertEqualValue("80",h.height.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoTextPins x"),this.clientTestManager.testAssertion.assertEqualValue("20",h.x.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoTextPins y"),this.clientTestManager.testAssertion.assertEqualValue("0",h.y.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoTextPins x2"),this.clientTestManager.testAssertion.assertEqualValue("100",h.x2.toString()),this.clientTestManager.testAssertion.testIdNotes("CeUtility: bbElemsNoTextPins y2"),this.clientTestManager.testAssertion.assertEqualValue("80",h.y2.toString()),c=n.CeUtility.convertFontStringToFontElements("normal normal normal 8px/normal Arial"),this.clientTestManager.testAssertion.testIdNotes("CeUtility: fontString2Object fontFamily"),this.clientTestManager.testAssertion.assertEqualString("Arial",c.fontFamily),this.clientTestManager.testAssertion.testIdNotes("CeUtility: fontString2Object fontSize"),this.clientTestManager.testAssertion.assertEqualString("8px",c.fontSize),this.clientTestManager.testAssertion.testIdNotes("CeUtility: fontString2Object fontStyle"),this.clientTestManager.testAssertion.assertEqualString("normal",c.fontStyle),this.clientTestManager.testAssertion.testIdNotes("CeUtility: fontString2Object fontVariant"),this.clientTestManager.testAssertion.assertEqualString("normal",c.fontVariant),this.clientTestManager.testAssertion.testIdNotes("CeUtility: fontString2Object fontWeight"),this.clientTestManager.testAssertion.assertEqualString("normal",c.fontWeight),n.ClientTestInputData.removeTestPaper(r),setTimeout(function(){a.resolve()},this.clientTestManager.bogusTestDelay),a.promise()},t}();n.TestCeUtilities=t}(Project||(Project={})),function(n){var t=function(){function t(t,i){this.testId="testSchToVhdlGeneration";this.designID="0ed5b5bc-b47f-4ebe-9c9e-d6eb491ac511";this.revisionID="c9215000-320d-47c4-8d5b-bb3433c0a447";this.fromUserID="e5ce2305-99f6-4836-94b5-efa085b563fe";this.localRevisionID="";this.localDesignID="";this.clientTestManager=t;this.surface=i;this.clientTestResults=new n.ClientTestResults;$.ajaxSetup({headers:{TOKEN_HEADER:n.Settings.APIKEY,token:"5",userID:n.Settings.UUID}})}return t.prototype.runTests=function(){var t=this,r=this,i=$.Deferred();return $.when(this.loadDesign(this.designID,this.revisionID,null)).done(function(r){r?(t.ceStructuralVhdl=new n.CeStructuralVhdl(t.surface,n.ClientTestInputData.getComponentDefault(),!1,!0),$.when(t.ceStructuralVhdl.generateVhdlFromSchematic()).done(function(){$.when(t.compileModel(n.CeStructuralVhdl.structuralVhdlString)).done(function(){t.clientTestManager.testAssertion.testIdNotes("SchToVhdl: Test generated model compiles");t.clientTestManager.testAssertion.assertEqualString("Compile Passed",t.clientTestResults.getReturnVal());t.cleanup();i.resolve(!0)})})):(t.cleanup(),i.resolve(!1))}),i.promise()},t.prototype.copyDesign=function(){var i=this,t=jQuery.Deferred();return $.ajax(n.Settings.APIURI()+"/designs?fromUser="+this.fromUserID+"&fromRevision="+this.revisionID+"&toUser="+n.Settings.UUID,{dataType:"json",contentType:"application/json;charset=utf-8",type:"POST",data:null,success:function(n){n?(i.localDesignID=n.DesignID,i.localRevisionID=n.RevisionID,t.resolve(!0)):(console.log("Error copying test design"),t.resolve(!1))},error:function(){console.log("Error copying test design");t.resolve(!1)}}),t.promise()},t.prototype.deleteCopiedDesign=function(){var t=jQuery.Deferred();return!this.localRevisionID||!this.localDesignID?(t.resolve(),t.promise()):($.ajax(n.Settings.APIURI()+"/designs?designID="+this.localDesignID+"&revisionID="+this.localRevisionID,{dataType:"json",contentType:"application/json;charset=utf-8",type:"DELETE",data:null,success:function(){t.resolve(!0)},error:function(){t.resolve(!1)}}),t.promise())},t.prototype.loadDesign=function(t,i,r){var f=this,u=jQuery.Deferred();return $.ajax(n.Settings.APIURI()+"/designs?designID="+t+"&revisionID="+i,{dataType:"json",contentType:"application/json;charset=utf-8",type:"GET",data:null,success:function(n){n?$.when(f.surface.loadDesign(n,r,!0)).done(function(n){n==Schematic.DesignLoadStatus.LOAD_OK||n==Schematic.DesignLoadStatus.LOAD_FAILED_NO_SIMULATION_DATA||n==Schematic.DesignLoadStatus.LOAD_FAILED_PLOTTING_RESULTS?u.resolve(!0):(console.log("Error opening test design"),u.resolve(!1))}):(console.log("Error opening test design"),u.resolve(!1))},error:function(){console.log("Error opening test design");u.resolve(!1)}}),u.promise()},t.prototype.compileModel=function(t){var i=this,r=jQuery.Deferred();return $.ajax({type:"POST",url:n.Settings.APIURI()+"/componentcompiler",data:JSON.stringify({Model:t}),contentType:"application/json"}).done(function(n){n=="OK"?i.clientTestResults.setReturnVal("Compile Passed"):i.clientTestResults.setReturnVal("Compile Failed");r.resolve(!0)}).always(function(){}),r.promise()},t.prototype.cleanup=function(){var n=this;setTimeout(function(){n.surface.clearDesign();n.deleteCopiedDesign()},3e3)},t}();n.TestSchToVhdl=t}(Project||(Project={})),function(n){var t=function(){function t(t,i){this.isUpdate=!1;this.delay=1e4;this.testId="testPromotionTool";this.clientTestManager=t;this.surface=i;this.clientTestResults=new n.ClientTestResults}return t.prototype.runTests=function(){var t=this,a=this,i,f,e,o,s,h,c,l=$.Deferred(),u=n.ClientTestInputData.getComponentDefault(),r;return u.Src=n.ClientTestInputData.getTestComponentModelSource(),u.ComponentId="TestCompID1",r=n.ClientTestInputData.getComponentDefault(),r.Src=n.ClientTestInputData.getTestComponentModelSource(),r.ComponentId="TestCompID2",f=this.postPutDbTestComp(u),$.when(f).done(function(){n.ClientTestManager.showFlow&&console.log("Promotion: Initial comp saved to UserLib");i=new n.CompMetadataPlusPromotion(u.Lib,u.ComponentId);setTimeout(function(){$("#revDescriptionId").val("Initial comp promotion");$("#categoriesDiv :checkbox[value=0]").prop("checked",!0);var u=i.getUpdatedComponent();i.isUpdate=!1;o=i.postPutComponent("staging",u);$.when(o).done(function(){n.ClientTestManager.showFlow&&console.log("Promotion: Initial comp promoted to SVWebLib");h=t.getDbTestComps(u.Lib,u.Name);$.when(h).done(function(){t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Initial promotion from UserLib");t.clientTestManager.testAssertion.assertEqualString("Initial comp promotion",t.activeComps[0].Revisions[0].Description);t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check length of GET comps array (1 comp)");t.clientTestManager.testAssertion.assertEqualValue("1",t.activeComps.length.toString());i.close();e=t.postPutDbTestComp(r);$.when(e).done(function(){n.ClientTestManager.showFlow&&console.log("Promotion: Revised comp saved to UserLib");i=new n.CompMetadataPlusPromotion(r.Lib,r.ComponentId);setTimeout(function(){$("#revDescriptionId").val("First revision to initial comp promotion");$("#categoriesDiv :checkbox[value=0]").prop("checked",!0);var r=i.getUpdatedComponent();i.isUpdate=!1;s=i.postPutComponent("staging",r);$.when(s).done(function(){n.ClientTestManager.showFlow&&console.log("Promotion: Revised comp promoted to SVWebLib");setTimeout(function(){c=t.getDbTestComps(r.Lib,r.Name);$.when(c).done(function(){t.activeComps.length==2?t.activeComps[0].Revisions.length==2&&t.activeComps[1].Revisions.length==2&&(t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check length of GET comps array (2 comps)"),t.clientTestManager.testAssertion.assertEqualValue("2",t.activeComps.length.toString()),t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check Revision[0].Description of intiial comp"),t.clientTestManager.testAssertion.assertEqualString("Test_Component_v1: Initial comp promotion",t.activeComps[0].Revisions[0].Description),t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check Revision[1].Description of intiial comp"),t.clientTestManager.testAssertion.assertEqualString("First revision to initial comp promotion",t.activeComps[0].Revisions[1].Description),t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check Revision[0].Description of revised comp"),t.clientTestManager.testAssertion.assertEqualString("Test_Component_v1: Initial comp promotion",t.activeComps[1].Revisions[0].Description),t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check Revision[1].Description of revised comp"),t.clientTestManager.testAssertion.assertEqualString("First revision to initial comp promotion",t.activeComps[1].Revisions[1].Description),t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check suffix added to entity of old comp"),t.clientTestManager.testAssertion.assertIsTrue(t.activeComps[0].Src.indexOf("Test_Component_v1")>-1),t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Check suffix not added to new comp"),t.clientTestManager.testAssertion.assertIsFalse(t.activeComps[1].Src.indexOf("Test_Component_v1")>-1)):t.clientTestManager.testAssertion.testIdNotes("Comp Promotion: Skipped Promotion/Revision tests");t.cleanup();l.resolve()})},t.delay)})},t.delay)})})})},t.delay)}),l.promise()},t.prototype.cleanup=function(){this.deleteComp("UserLib","TestCompID1");this.deleteComp("UserLib","TestCompID2");this.deleteComp("SVWebLib","TestCompID1");this.deleteComp("SVWebLib","TestCompID2")},t.prototype.getDbTestComps=function(t,i){var u=this,r=$.Deferred(),f="?library="+t+"&Name="+i;return $.ajax({type:"GET",url:n.Settings.APIURI()+"/components/"+f,contentType:"application/json"}).done(function(n){u.activeComps=n;r.resolve()}).fail(function(){u.isUpdate=!1;r.resolve()}),r.promise()},t.prototype.postPutDbTestComp=function(t){var i=$.Deferred(),r="",u;return r=this.isUpdate?"/components?library=UserLib&componentId="+t.ComponentId:"/components?library=UserLib",u=n.Settings.APIURI()+r,$.ajax({type:this.isUpdate?"PUT":"POST",url:u,data:JSON.stringify(t),contentType:"application/json"}).done(function(){i.resolve()}).fail(function(){n.MessageManager.showErrorMessage("Unit test component could not be saved. Does it already exist? in DB");i.resolve()}),i.promise()},t.prototype.deleteComp=function(t,i){var r="?library="+t+"&componentId="+i;$.ajax({type:"DELETE",url:n.Settings.APIURI()+"/components/"+r,contentType:"application/json"}).done(function(){console.log("Test components deleted")}).fail(function(){console.log("Delete test components failed")})},t}();n.TestCompPromotion=t}(Project||(Project={})),function(n){var t=function(){function t(n,t,i){this.surface=t;this.simulationSidebar=i;this.initFlag=!1;this.container=$('<div id="save_dialog"><\/div>');var r=$("<div><\/div>");r.append('<div style="float: left">Save design<\/div>');r.append('<i id="save_dialog_exit" class="icon-remove" style="float: right"><\/i>');r.append('<p style="line-height: 10px;">&nbsp<\/p>');this.container.append(r);this.container.append('<hr class="hr_sidebar"/>');this.container.append('<div class="sidebar_text_label">Design Name<\/div>');this.input=$('<div class="input-group input input-group-sm" style="width: 100%"><\/div>');this.input.append('<input id="save_name_input" type="text" class="form-control" placeholder = "design" value="">');this.container.append(this.input);this.container.append("<p><\/p>");this.button=$('<button type="button" id="save_design" class="btn sidebar_button icon-cloud-upload" style="width: 100%">&nbspSave<\/button>');this.container.append(this.button);this.container.append("<p><\/p>");$(document.body).append(this.container);this.container.draggable()}return t.prototype.init=function(){var n=this;this.initFlag||(this.initFlag=!0,$("#save_dialog_exit").click(function(){n.container.css("display","none")}),$("#save_design").click(function(){n.doSaveAs()}),$("#save_name_input").keydown(function(t){t.keyCode==13&&n.doSaveAs()}))},t.prototype.show=function(){$("#save_name_input").val(this.surface.getDesign().getName());this.container.css("top",$(window).height()/2-this.container.height()/2-150);this.container.css("left",$(window).width()/2-this.container.width()/2);this.container.css("display","block")},t.prototype.doSave=function(){var t=this.surface.getDesign(),i=t.save();i.done(function(i){var r=t.getName();switch(i){case Schematic.DesignSavedState.NOT_NEEDED:n.MessageManager.showInfoMessage("The design was not saved since there were no changes");break;case Schematic.DesignSavedState.NEW_REVISION:n.MessageManager.showInfoMessage("Design "+r+" was saved");break;case Schematic.DesignSavedState.UPDATED_REVISION:n.MessageManager.showInfoMessage("Design "+r+" was updated");break;case Schematic.DesignSavedState.UPDATED_SIMULATION:n.MessageManager.showInfoMessage("Design "+r+" was updated with new simulation data")}})},t.prototype.doSaveAs=function(){var t=surface.getDesign(),r=t.getName(),i=$("#save_name_input").val();i!=r&&(t.setName(i),t.setDesignID(""),t.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS));this.doSave();this.container.css("display","none")},t}();n.SaveDesign=t}(Project||(Project={})),function(n){var t=function(){function t(n,t){this.title=n;this.queryParams=t}return t.prototype.show=function(){var t=this;$.ajaxSetup({headers:{TOKEN_HEADER:n.Settings.APIKEY,token:"5",userID:n.Settings.UUID}});$.ajax({url:n.Settings.APIURI()+"/sharedDesigns?"+this.queryParams,type:"POST",success:function(i){i?t.showDialog(i):n.MessageManager.showErrorMessage("Unable to get the URL. Please try again later.")},error:function(){n.MessageManager.showErrorMessage("Unable to get the URL. Please try again later.")}})},t.prototype.showDialog=function(i){var e=$(t.DIV).data("kendoWindow"),r,u,f;e&&e.destroy();r={title:this.title,width:300};r=$.extend({},n.KendoHelper.CommonKendoWindowOptions,r);u='<div><textarea readonly class="share_url" id="'+t.TEXT_AREA_ID+'" style="width: 100%; ';i.indexOf(t.SHORT_URL_BASE)!=-1&&(u+="font-size: 24px; height: 33px; ");u+='">'+i+"<\/textarea><\/div>";$('<div class="share_url" id="'+t.DIV_ID+'"><\/div>').appendTo(document.body).kendoWindow(r).data("kendoWindow").center().content(u).open();f=$(t.TEXT_AREA);f.height(f[0].scrollHeight);$(t.DIV).parent().css("z-index",6e4);$(t.DIV).focus();f.select();this.addContextMenu()},t.prototype.addContextMenu=function(){var n,i;try{document.queryCommandEnabled("copy");n=new SVWebContextMenu.MenuContent(this);n.addMenuElement("Copy URL",this.copyUrl);i=SVWebContextMenu.MenuHelper.createMenu(n);i.bindMenuTo(t.DIV)}catch(r){$(t.DIV).append('<div style="font-size: small">Copy the URL with Ctrl-C/Cmd-C)<\/div>')}},t.prototype.copyUrl=function(){$(t.DIV).focus();$(t.TEXT_AREA).select();document.execCommand("copy")},t.SHORT_URL_BASE="http://sysvis.io",t.DIV_ID="share_url_div",t.DIV="#"+t.DIV_ID,t.TEXT_AREA_ID="share_url_text_area",t.TEXT_AREA="#"+t.TEXT_AREA_ID,t}();n.ShareUrlDialog=t}(Project||(Project={})),function(n){var t,r,i;(function(n){n[n.RUNNING=0]="RUNNING";n[n.NOT_RUNNING=1]="NOT_RUNNING";n[n.RESULTS_AVAILABLE=2]="RESULTS_AVAILABLE"})(n.SimulationResultsState||(n.SimulationResultsState={}));t=n.SimulationResultsState;r=function(){function r(t){this.stateChangeCallback=null;this.stateChangeCallbackContext=null;this.stateChangeCallbackArgs=null;this.surface=t;this.preparingCounter=0;this.simulationLaunchError=!1;this.simInformation=new i;this.resetSimInformation();$.ajaxSetup({headers:{TOKEN_HEADER:n.Settings.APIKEY,TOKEN:"5",userID:n.Settings.UUID}})}return r.prototype.getState=function(){return this.simInformation.getState()},r.prototype.setState=function(n){n!=this.getState()&&(this.simInformation.setState(n),this.stateChangeCallback&&this.stateChangeCallback(this.stateChangeCallbackContext,this.stateChangeCallbackArgs,n))},r.prototype.getSimulationId=function(){return this.simInformation.getSimulationId()},r.prototype.setSimulationId=function(n){this.simInformation.setSimulationId(n)},r.prototype.getErrorMessage=function(){return this.simInformation.errorMessage},r.prototype.setErrorMessage=function(n){this.simInformation.errorMessage=n},r.prototype.getUserMessage=function(){return this.simInformation.userMessage},r.prototype.setUserMessage=function(n){this.simInformation.userMessage=n},r.prototype.getPercentage=function(){return this.simInformation.percentage},r.prototype.setPercentage=function(n){this.simInformation.percentage=n},r.prototype.hasError=function(){return this.simInformation.error},r.prototype.setError=function(n){this.simInformation.error=n},r.prototype.getInfo=function(){return this.simInformation.info},r.prototype.setInfo=function(n){this.simInformation.info=n},r.prototype.hasWaveformData=function(){return this.simInformation.hasWaveformData},r.prototype.setWaveformData=function(n){this.simInformation.hasWaveformData=n},r.prototype.hasLog=function(){return this.simInformation.hasSimulationLog},r.prototype.setSimulationLog=function(n){this.simInformation.hasSimulationLog=n},r.prototype.resetSimInformation=function(){this.simInformation.reset()},r.prototype.wasInterrupted=function(){return this.simInformation.interrupt},r.prototype.setInterrupt=function(){this.simInformation.interrupt=!0},r.prototype.setStateChangeCallback=function(n,t,i){this.stateChangeCallback=n;this.stateChangeCallbackContext=t;this.stateChangeCallbackArgs=i},r.prototype.clearStateChangeCallback=function(){this.stateChangeCallback=null;this.stateChangeCallbackContext=null;this.stateChangeCallbackArgs=null},r.prototype.start=function(r){var u=this;appInsights.trackEvent("Starting Simulation");this.simInformation||(this.simInformation=new i);this.resetSimInformation();this.setState(t.RUNNING);r.updateUI();var f=this.surface.getDesign(),e=f.getDesignID(),o=f.getRevisionID();$.ajax({url:n.Settings.APIURI()+"/simulations/?&designId="+e+"&revisionId="+o,dataType:"json",type:"POST",data:null,contentType:"application/json;charset=utf-8",success:function(n){u.setSimulationId(n);f.getLatestSimulationResultInfo().setSimulationId(u.getSimulationId());u.preparingCounter=0},error:function(t,i){this.simulationLaunchError=i;n.Settings.notify("simstart error",{simid:this.getSimulationId(),error:i})}})},r.prototype.stop=function(t){var i=$.Deferred(),u=this.getSimulationId(),r;if(u!=null)return r=u,r+=t?"&force=true":"&force=false",this.setInfo("Interrupting Simulation"),this.setPercentage(0),this.setInterrupt(),$.ajax({url:n.Settings.APIURI()+"/simulations/?simulationId="+r,dataType:"json",type:"DELETE",data:null,contentType:"application/json;charset=utf-8",success:function(){i.resolve(!0)},error:function(){i.resolve(!1)}}),i.promise()},r.prototype.updateSimulationInformation=function(){var i=this,r=$.Deferred(),f=this.getSimulationId(),u;return this.getState()==t.NOT_RUNNING||f==null?(r.resolve(),r.promise()):(u=this.surface.getDesign(),$.ajax({url:n.Settings.APIURI()+"/simulations/?simulationId="+f,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){var f,e;if(i.setPercentage(n.Progress),n.State=="COMPLETED_NORMALLY"||n.State=="COMPLETED_ABNORMALLY")i.setInfo(""),i.setState(t.RESULTS_AVAILABLE),n.Error&&(i.setError(!0),i.setErrorMessage("Simulation error"),i.setUserMessage("Simulation error")),n.ErrorMessage&&i.setErrorMessage(n.ErrorMessage),n.UserMessage&&(i.setUserMessage(n.UserMessage),i.setInfo(n.UserMessage)),n.WaveformDatabaseURI!=null&&n.WaveformDatabaseURI!=""&&(i.setWaveformData(!0),u.getDesignID()==n.DesignID&&u.getRevisionID()==n.RevisionID&&u.getLatestSimulationResultInfo().setResultStatus(!0)),n.SimulationLogURI!=null&&n.SimulationLogURI!=""&&i.setSimulationLog(!0),i.notifySimulationComplete();else if(n.ProgressMessage&&(i.wasInterrupted()||i.simBeyondTime0(n.ProgressMessage)))i.setInfo(n.ProgressMessage);else{for(f=" ",e=0;e<i.preparingCounter%4;e++)f+=". ";n.ProgressMessage?i.setInfo("Searching for DC solution"+f):n.Progress<=0&&i.setInfo("Waiting to simulate"+f);i.preparingCounter++;i.preparingCounter<0&&(i.preparingCounter=0)}r.resolve()},error:function(){r.resolve()}}),r.promise())},r.prototype.updateSimulationState=function(i){var r=this,u=$.Deferred();return $.ajax({url:n.Settings.APIURI()+"/simulations/?simulationId="+this.getSimulationId(),dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){n.State=="QUEUED"||n.State=="RUNNING"?(r.setState(t.RUNNING),r.setPercentage(n.Progress),r.setInfo(n.ProgressMessage),i.showStopIcon(),n.Interrupt&&i.startInterruptTimer(Sidebar.INTERRUPT_MODE.PROCESSING_RESULTS,Sidebar.SimulationMenu.PROCESSING_RESULTS_TIMEOUT_1)):(r.setError(n.Error),r.setUserMessage(n.UserMessage));u.resolve(!0)},error:function(){u.resolve(!1)}}),u.promise()},r.prototype.resultsProcessingComplete=function(){this.setState(t.NOT_RUNNING)},r.prototype.simBeyondTime0=function(n){return n&&n.substr(0,2)=="<0"?!1:!0},r.prototype.notifySimulationComplete=function(){this.hasError()?(n.Settings.notify("sim error",{simid:this.getSimulationId(),errormsg:this.getErrorMessage(),usermsg:this.getUserMessage()}),n.Settings.notifyEventSim("failed")):this.wasInterrupted()?(n.Settings.notify("sim interrupt",{simid:this.getSimulationId(),progress:this.getPercentage(),waveforms:this.hasWaveformData()?"true":"false",log:this.hasLog()?"true":"false"}),n.Settings.notifyEventSim("interrupted")):(n.Settings.notify("sim passed",{simid:this.getSimulationId(),waveforms:this.hasWaveformData()?"true":"false",log:this.hasLog()?"true":"false"}),n.Settings.notifyEventSim("succeeded"))},r}();n.SimulateDesign=r;i=function(){function n(){}return n.prototype.reset=function(){this.setState(t.NOT_RUNNING);this.setSimulationId(null);this.percentage=0;this.info="";this.error=!1;this.hasWaveformData=!1;this.hasSimulationLog=!1;this.interrupt=!1;this.errorMessage="";this.userMessage=""},n.prototype.getState=function(){return this.state},n.prototype.setState=function(n){this.state=n},n.prototype.getSimulationId=function(){return this.simulationId},n.prototype.setSimulationId=function(n){this.simulationId=n},n}();n.SimulationInformation=i}(Project||(Project={})),function(n){var t;(function(n){var t=function(){function n(n,t){this.clickListeners=[];this.IsDebugMode=!0;this.name=n;this.surface=t;this._createWidget(n)}return n.prototype._createWidget=function(n){$(document.body).append("<div id="+n+"><\/div>");this.simulationElement=document.getElementById(n);this.simulationWidget=$(this.simulationElement).kendoWindow({draggable:!0,resizable:!0,visible:!1,title:"Simulation",scrollable:!1,modal:!1,actions:["Custom","Refresh","Maximize","Minimize","Close"],width:400,height:500}).data("kendoWindow");this.simulationWidget.center();this.simulationWidget.wrapper.find(".k-i-custom").click({self:this},function(n){n.data.self._customButtonAction()});this.simulationWidget.wrapper.find(".k-i-refresh").click({self:this},function(n){n.data.self._refreshButtonAction()})},n.prototype.ShowNetlist=function(){var t=this,n;this.IsDebugMode&&console.log("Start ShowNetlist(): "+this.displayTime());n=surface.getDesign().save();n.done(function(){t.SaveShowNetlist()})},n.prototype.SaveShowNetlist=function(){this.showDialog("Design Netlist");var t=this.surface.getDesign(),r=t.getDesignID(),u=t.getRevisionID();$.ajaxSetup({headers:{TOKEN_HEADER:Project.Settings.APIKEY,token:"5",userID:Project.Settings.UUID}});var i="",n=$("#netlistLogWindow").data("kendoWindow"),f=$.ajax({url:Project.Settings.APIURI()+"/Netlist/?designID="+r+"&revisionID="+u,type:"GET",data:null,contentType:"application/json;charset=utf-8"}).done(function(t){t?(i='<textarea style="width:100%;height:100%">'+t+"<\/textarea>",n.content(i)):n.content("No netlist returned")}).fail(function(t,i){n.content("GET netlist server request error: "+i)})},n.prototype.showDialog=function(n){var i=$("#netlistLogWindow"),t;i.kendoWindow({actions:["Close"],draggable:!0,height:"430px",modal:!1,pinned:!1,position:{top:100,left:100},resizable:!0,width:"750px"});t=i.data("kendoWindow");t.center();t.title(n);t.open();i.scrollTop(0);$("#netlistLogWindow").css("overflow","hidden")},n.prototype.ClickHandlersRemove=function(){if(this.clickListeners.length!=0){for(var n=0;n<this.clickListeners.length;n++)$(this.clickListeners[n]).off("click");this.clickListeners=[]}},n.prototype._customButtonAction=function(){},n.prototype._refreshButtonAction=function(){},n.prototype.CheckSchematic=function(n){var i=!0,c=n.surface.getDesign().getDesignID(),t="",r,u,f;if(c?c&&n.surface.getDesign().getCompArray().length==0&&(t="Design has no symbols.<br>Please add/connect symbols before simulating...",i=!1):(t="Design could not be found.<br>Please create or load a design before simulating...",i=!1),!i)return Project.MessageManager.showErrorMessage(t),t="",i;var e=n.surface.getDesign().getCompArray(),o=[],s=[],h=!1;for(r=0;r<e.length;r++)for(o=e[r].getCompProps(),s=e[r].getInstProps(),u=0;u<o.length;u++){for(h=!1,f=0;f<s.length;f++)if(h=!1,s[f].name==o[u].Name){h=!0;s[f].value||(t=t.concat(e[r].getInstName()+": <span><strong>"+s[f].name+"<\/strong><\/span> value not specified. Please supply a value.<br>"),i=!1);break}h||o[u].Typical||(t=t.concat(e[r].getInstName()+": <span><strong>"+o[u].Name+"<\/strong><\/span> value not specified. Please supply a value.<br>"),i=!1)}return i||(Project.MessageManager.showErrorMessage(t),t=""),i},n.prototype.displayTime=function(){var r="",n=new Date,u=n.getHours(),t=n.getMinutes(),i=n.getSeconds(),f="",e="";return t<10&&(f="0"+t),i<10&&(e="0"+i),r+=u+":"+t+":"+i+" ",r+(u>11?"PM":"AM")},n}();n.Control=t})(t=n.Simulation||(n.Simulation={}))}(svw||(svw={})),function(n){function u(t){if(!t)return n.TIME_DOMAIN_NAME;var i=+t;switch(i){case 0:return n.NONE_NAME;case 1:return n.TIME_DOMAIN_NAME;case 2:return n.FREQUENCY_DOMAIN_NAME;default:return n.TIME_DOMAIN_NAME}}function f(i){switch(i){case n.NONE_NAME:return t.NONE;case n.TIME_DOMAIN_NAME:return t.TIME_DOMAIN;case n.FREQUENCY_DOMAIN_NAME:return t.FREQUENCY_DOMAIN;default:return t.NONE}}var t,r,i;(function(n){n[n.NONE=0]="NONE";n[n.TIME_DOMAIN=1]="TIME_DOMAIN";n[n.FREQUENCY_DOMAIN=2]="FREQUENCY_DOMAIN"})(n.SIMULATION_TYPE||(n.SIMULATION_TYPE={}));t=n.SIMULATION_TYPE;n.SIMULATION_TYPE_LIST=[t.TIME_DOMAIN,t.FREQUENCY_DOMAIN];n.NONE_NAME="None";n.TIME_DOMAIN_NAME="Time-Domain";n.FREQUENCY_DOMAIN_NAME="Frequency-Domain";n.getSimulationTypeName=u;n.getSimulationTypeByName=f;r=function(){function t(n,t,i){if(this.design=n,this.simulationType=t,i==null)this.signalList=[],this.initialConditions={},this.name="";else{this.initialConditions=i.InitialConditions;this.name=i.Name;this.signalList=[];for(var r=0;r<i.SignalList.length;++r)this.signalList.push(i.SignalList[r])}}return t.prototype.setName=function(t){this.name!=t&&(this.name=t,this.design.setDirty(n.DIRTY_FLAG.DIRTY_SIM_SETTINGS))},t.prototype.getDesign=function(){return this.design},t.prototype.getSaveData=function(){var n=new i,t,r;for(n.SignalList=[],n.InitialConditions=this.initialConditions,n.SimulationType=this.simulationType,n.Name=this.name,t=0;t<this.signalList.length;t++)r=this.signalList[t],n.SignalList.push(r);return n},t.prototype.dump=function(){},t}();n.BaseSimulation=r;i=function(){function t(){}return t.prototype.compareTo=function(t,i,r){var u=i+PATH_SEPARATOR+"BaseSimulation";return n.Utility.comparePrimitives(this.Name,t.Name,"Name",u,!0)?n.Utility.compareMaps(this.InitialConditions,t.InitialConditions,u+"/InitialConditions",r)?n.Utility.comparePrimitives(this.SimulationType,t.SimulationType,"SimulationType",u,!0)?!0:!1:!1:!1},t}();n.BaseSimulationState=i}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(t){function i(n,r){r?(t.call(this,n,i.SIMULATION_TYPE_STR,r),this.endTime=r.EndTime,this.updateEndTimeField()):t.call(this,n,i.SIMULATION_TYPE_STR)}return __extends(i,t),i.prototype.setEndTime=function(t){this.endTime!=t&&(this.endTime=t,this.getDesign().setDirty(n.DIRTY_FLAG.DIRTY_SIM_SETTINGS),this.updateEndTimeField())},i.prototype.getEndTime=function(){return this.endTime},i.prototype.getSaveData=function(){var n=t.prototype.getSaveData.call(this);return n.EndTime=this.endTime,n},i.prototype.dump=function(n,i){t.prototype.dump.call(this,n,i)},i.prototype.updateEndTimeField=function(){this.getDesign().getSurface().getSimulationSidebar().updateEndTimeField(this.endTime)},i.SIMULATION_TYPE_STR="TransientSimulation",i}(n.BaseSimulation),t;n.TransientSimulation=i;t=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(n.BaseSimulationState);n.TransientSimulationState=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t,i,r;(function(n){n[n.POINTS_LINEAR_SPACING=0]="POINTS_LINEAR_SPACING";n[n.POINTS_PER_OCTAVE=1]="POINTS_PER_OCTAVE";n[n.POINTS_PER_DECADE=2]="POINTS_PER_DECADE"})(n.POINT_SPECIFICATION||(n.POINT_SPECIFICATION={}));t=n.POINT_SPECIFICATION;i=function(i){function r(n,u){u?(i.call(this,n,r.SIMULATION_TYPE_STR,u),this.startFreq=u.StartingFrequency,this.endFreq=u.EndingFrequency,this.nPoints=u.NumberOfPoints,this.pointSpacing=u.PointSpacing,this.updateStartFreqField(),this.updateEndFreqField()):(i.call(this,n,r.SIMULATION_TYPE_STR),this.nPoints=100,this.pointSpacing=t.POINTS_PER_DECADE)}return __extends(r,i),r.prototype.setStartFreq=function(t){this.startFreq!=t&&(this.startFreq=t,this.getDesign().setDirty(n.DIRTY_FLAG.DIRTY_SIM_SETTINGS),this.updateStartFreqField())},r.prototype.setEndFreq=function(t){this.endFreq!=t&&(this.endFreq=t,this.getDesign().setDirty(n.DIRTY_FLAG.DIRTY_SIM_SETTINGS),this.updateEndFreqField())},r.prototype.getStartFreq=function(){return this.startFreq},r.prototype.getEndFreq=function(){return this.endFreq},r.prototype.getSaveData=function(){var n=i.prototype.getSaveData.call(this);return n.StartingFrequency=this.startFreq,n.EndingFrequency=this.endFreq,n.NumberOfPoints=this.nPoints,n.PointSpacing=this.pointSpacing,n},r.prototype.dump=function(n,t){i.prototype.dump.call(this,n,t)},r.prototype.updateStartFreqField=function(){this.getDesign().getSurface().getSimulationSidebar().updateStartFreqField(this.startFreq)},r.prototype.updateEndFreqField=function(){this.getDesign().getSurface().getSimulationSidebar().updateEndFreqField(this.endFreq)},r.SIMULATION_TYPE_STR="FrequencySimulation",r}(n.BaseSimulation);n.FrequencySimulation=i;r=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(n.BaseSimulationState);n.FrequencySimulationState=r}(Project||(Project={})),function(n){var i=function(){function i(){n.Settings.isSVWeb()?(this.Eps=i.SVWEB_DEFAULT_EPS,this.Hmin=i.SVWEB_DEFAULT_HMIN,this.Itl1=i.SVWEB_DEFAULT_ITL1,this.Itl4=i.SVWEB_DEFAULT_ITL4,this.ManualOptions=""):(this.Eps=i.TRIAD_DEFAULT_EPS,this.Hmin=i.TRIAD_DEFAULT_HMIN,this.Itl1=i.TRIAD_DEFAULT_ITL1,this.Itl4=i.TRIAD_DEFAULT_ITL4,this.ManualOptions="")}return i.prototype.setState=function(n){n!=null&&(this.Eps=n.Eps,this.Hmin=n.Hmin,this.Itl1=n.Itl1,this.Itl4=n.Itl4,this.ManualOptions=n.ManualOptions)},i.prototype.getSaveData=function(){var n=new t;return n.Eps=this.Eps,n.Hmin=this.Hmin,n.Itl1=this.Itl1,n.Itl4=this.Itl4,n.ManualOptions=this.ManualOptions,n},i.getDefaultTimeResolution=function(n){return n?i.TIME_RESOLUTION_SELECTED:i.TIME_RESOLUTION},i.getDefaultConvergence=function(n){return n?{itl4:i.CONVERGENCE_ITL4,itl1:i.CONVERGENCE_ITL1}:{itl4:i.CONVERGENCE_ITL4_SELECTED,itl1:i.CONVERGENCE_ITL1_SELECTED}},i.getDefaultManualOptions=function(){return""},i.ADVANCED_OPTIONS_TOOLTIP="Standard (default) settings are good for most simulations. Adavnced Options can be useful for some designs.",i.MANUAL_OPTIONS_TOOLTIP="Hand-typed simulation options. Only recommended for expert users.",i.BALANCE_GROUP_NAME="BalanceGroup",i.BALANCE_GROUP_VALUE_NAME="Eps",i.SPEED_NAME="More Speed",i.SPEED="1.0e-5",i.SPEED_TOOLTIP="Decreases the simulation time by reducing the accuracy of the results, but often only minimally noticeable",i.BALANCE_NAME="Balanced",i.BALANCE="1.0e-7",i.BALANCE_TOOLTIP="Generally good compromise between speed and accuracy",i.ACCURACY_NAME="More Accuracy",i.ACCURACY="1.0e-9",i.ACCURACY_TOOLTIP="Increases the accuracy of the results but usually with a corresponding increase in simulation time",i.TIME_RESOLUTION_VALUE_NAME="Hmin",i.TIME_RESOLUTION_NAME="Time Resolution<br>Enhancement",i.TIME_RESOLUTION="0.9e-9",i.TIME_RESOLUTION_SELECTED="1.0e-12",i.TIME_RESOLUTION_TOOLTIP="Allows smaller time-steps to better track fast transients and higher frequencies",i.CONVERGENCE_NAME="Convergence Assist",i.CONVERGENCE_ITL1_VALUE_NAME="itl1",i.CONVERGENCE_ITL1="100",i.CONVERGENCE_ITL1_SELECTED="300",i.CONVERGENCE_ITL4_VALUE_NAME="itl4",i.CONVERGENCE_ITL4="13",i.CONVERGENCE_ITL4_SELECTED="100",i.CONVERGENCE_TOOLTIP="Modifies the simulation algorithm to help it converge on a solution for some systems",i.SVWEB_DEFAULT_EPS=i.BALANCE,i.SVWEB_DEFAULT_HMIN=i.TIME_RESOLUTION,i.SVWEB_DEFAULT_ITL1=i.CONVERGENCE_ITL1,i.SVWEB_DEFAULT_ITL4=i.CONVERGENCE_ITL4,i.TRIAD_DEFAULT_EPS=i.BALANCE,i.TRIAD_DEFAULT_HMIN=i.TIME_RESOLUTION_SELECTED,i.TRIAD_DEFAULT_ITL1=i.CONVERGENCE_ITL1,i.TRIAD_DEFAULT_ITL4=i.CONVERGENCE_ITL4,i}(),t;n.AdvancedOptions=i;t=function(){function t(){}return t.prototype.compareTo=function(t,i,r){var u=i+PATH_SEPARATOR+"AdvancedOptions";return n.Utility.comparePrimitives(this.Eps,t.Eps,"Eps",i,r)?n.Utility.comparePrimitives(this.Hmin,t.Hmin,"Hmin",i,r)?n.Utility.comparePrimitives(this.Itl1,t.Itl1,"Itl1",i,r)?n.Utility.comparePrimitives(this.Itl4,t.Eps,"Itl4",i,r)?n.Utility.comparePrimitives(this.ManualOptions,t.Eps,"ManualOptions",i,r)?!0:!1:!1:!1:!1:!1},t}();n.AdvancedOptionsState=t}(Project||(Project={})),function(n){var t=function(){function t(n,t){this.surface=n;this.simSidebar=t;this.createHandlers();this.sendInitMessage()}return t.prototype.createHandlers=function(){var n=this;window.addEventListener("message",function(i){var r=i.data;!r||!r.action;switch(r.action){case t.COMP_REPLACE:n.handleReplace(r);break;case t.GET_PROPS:n.handleGetProps(r);break;case t.SET_PROPS:n.handleSetProps(r);break;case t.SET_NAME:n.handleSetName(i);break;case t.CLOSE_WINDOW:n.handleCloseWindow(r);break;case t.OPEN_DESIGN:n.handleOpenDesign(i);break;case t.OPEN_SHARED_DESIGN:n.handleOpenSharedDesign(i);break;case t.SAVE_DESIGN:n.handleSaveDesign(i);break;case t.CROSS_HIGHLIGHT:n.handleCrossHighlight(r,!0);break;case t.CROSS_UNHIGHLIGHT:n.handleCrossHighlight(r,!1)}},!1)},t.prototype.sendInitMessage=function(){t.sendMessage(t.APP_INIT)},t.sendSetFocusMessage=function(){t.sendMessage(t.SET_FOCUS)},t.sendDesignDirtyMessage=function(){t.sendMessage(t.DESIGN_DIRTY)},t.sendDesignCleanMessage=function(){t.sendMessage(t.DESIGN_CLEAN)},t.sendDesignSavedMessage=function(){window.parent&&window.parent.postMessage({action:n.Handler.DESIGN_SAVED,containerID:surface.getContainerID()},"*")},t.sendMessage=function(n){window.parent&&window.parent.postMessage({action:n},"*")},t.prototype.handleReplace=function(n){var t=n.instName,i=n.compSource,u=n.compName,f=n.compLib,r=n.componentId;this.surface.getDesign().replaceComponent(t,i,r)},t.prototype.handleGetProps=function(n){var r=this.surface.getDesign(),i,u,f;!r;i=r.findCompByInstName(n.id);!i;u=i.getInstProps();f={action:t.GET_PROPS,properties:u};event.source.postMessage(f,"*")},t.prototype.handleSetProps=function(n){var i=n.properties,r,t;!i;r=this.surface.getDesign();t=r.findCompByInstName(n.id);t&&t.setInstProps(i)},t.prototype.handleSetName=function(n){var t=n.data,r,i;t&&(r=this.surface.getDesign().getName(),i=t.containerID,surface.updateDesignInfo(t.name,n.origin,t.url),t.name&&i&&r!=t.name&&$.ajax(Project.Settings.APIURI()+"/designcontainer?containerID="+i+"&name="+t.name,{dataType:"json",contentType:"application/json;charset=utf-8",type:"PUT",headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID},success:function(){},error:function(){}}))},t.prototype.handleCloseWindow=function(){$(PROP_URL_WINDOW).data("kendoWindow").close()},t.prototype.handleOpenDesign=function(n){var u=this,f=n.data,r,i;this.surface.setContainerID(f.containerID);r=f.containerID;this.surface.disableControls(!1);i=jQuery.Deferred();addLoadingAppDeferred(i);$.ajax(Project.Settings.APIURI()+"/designcontainer?containerID="+r+"&getDesignRevision=true",{dataType:"json",contentType:"application/json;charset=utf-8",type:"GET",headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID},success:function(f){if(!f){u.surface.enableControls(!1);i&&i.resolve();n.source.postMessage({action:t.ERROR_OPENING_DESIGN,containerID:r},"*");return}$.when(u.surface.loadDesign(f,i)).done(function(){n.source.postMessage({action:t.DESIGN_OPENED,containerID:r},"*")})},error:function(){i&&i.resolve();n.source.postMessage({action:t.ERROR_OPENING_DESIGN,containerID:r},"*")},complete:function(){u.surface.enableControls(!1)}})},t.prototype.handleOpenSharedDesign=function(n){var r=this,f=n.data,u=f.containerID,i;this.surface.disableControls(!1);i=jQuery.Deferred();addLoadingAppDeferred(i);$.ajax(Project.Settings.APIURI()+"/designcontainer?containerID="+u+"&getDesignRevision=true",{dataType:"json",contentType:"application/json;charset=utf-8",type:"GET",headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:Project.Settings.UUID},success:function(e){if(!e){r.surface.enableControls(!1);i&&i.resolve();n.source.postMessage({action:t.ERROR_OPENING_DESIGN,containerID:u},"*");return}r.surface.initSharedDesign();$.when(r.surface.loadDesign(f,i,!0)).done(function(){r.surface.showLandingPageButton();n.source.postMessage({action:t.SHARED_DESIGN_OPENED,containerID:u},"*")})},error:function(){i&&i.resolve();n.source.postMessage({action:t.ERROR_OPENING_DESIGN,containerID:u},"*")},complete:function(){r.surface.enableControls(!1)}})},t.prototype.handleSaveDesign=function(n){var u=this,i=n.data,t=this.surface.getDesign(),r=t.getName();this.surface.updateDesignInfo(i.name,n.origin,i.url);i.name!=r&&(t.setDesignID(""),t.setDirty(Project.DIRTY_FLAG.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS));t.save()},t.prototype.handleCrossHighlight=function(n,t){var i=this.surface.getDesign();t?i.crossHighlight(n.nodeName,n.isFolder):i.crossUnhighlight(n.nodeName,n.isFolder)},t.COMP_REPLACE="replaceComponent",t.GET_PROPS="getProperties",t.SET_PROPS="setProperties",t.SET_NAME="setName",t.CLOSE_WINDOW="propWindowClose",t.OPEN_DESIGN="openDesign",t.OPEN_SHARED_DESIGN="openSharedDesign",t.SAVE_DESIGN="saveDesign",t.DESIGN_SAVED="designSaved",t.DESIGN_OPENED="designOpened",t.ERROR_OPENING_DESIGN="errorOpeningDesign",t.SHARED_DESIGN_OPENED="sharedDesignOpened",t.APP_INIT="appInit",t.CROSS_HIGHLIGHT="crossHighlight",t.CROSS_UNHIGHLIGHT="crossUnhighlight",t.SET_FOCUS="setFocus",t.DESIGN_DIRTY="designDirty",t.DESIGN_CLEAN="designClean",t.COMP_ADDED="componentAdded",t.COMP_REMOVED="componentRemoved",t.COMP_SELECTED="componentSelected",t}();n.Handler=t}(Messaging||(Messaging={})),function(n){var u=function(){function i(n){this.waveBoxes=[];this.simulations=[];this.design=n}return i.prototype.probeExists=function(n){var t=n.getWavebox(),i;return t.existsInDesign()?(i=t.probes.indexOf(n),i>=0):!1},i.prototype.addWaveBox=function(n){this.waveBoxes.push(n)},i.prototype.removeWavebox=function(n){var t=this.waveBoxes.indexOf(n);t>=0&&this.waveBoxes.splice(t,1)},i.prototype.waveBoxExists=function(n){var t=this.waveBoxes.indexOf(n);return t>=0},i.prototype.hasResultData=function(){for(var i=this.simulations.length,t=!1,n=0;n<i;++n)this.simulations[n].getSaveData().simulationResultInfo!=null&&(t=!0);return t},i.prototype.cleanSimulations=function(){for(var n,i=[],r=this.getUniqueSimulationList(),t=0;t<r.length;t++)n=r[t],n&&(n.clearResults(this.design.getRevisionID()),i.push(n));this.simulations=i},i.prototype.getSaveData=function(){for(var f,u,e,r=new t,i=0;i<this.waveBoxes.length;++i)f=this.waveBoxes[i].getSaveData(!1),f&&r.waveboxStates.push(f);for(u=this.simulations.length,i=0;i<u;++i)this.simulations[i].getStaleState()==n.StaleState.CURRENT&&r.simulations.push(this.simulations[i].getSaveData());return u>0&&r.simulations.length==0&&(e=new n.Simulation(this.design,this.simulations[u-1].getSaveData()),e.getSimulationResultInfo().clear(),r.simulations.push(e.getSaveData())),r},i.prototype.load=function(n){var t=this,i=jQuery.Deferred();return $.when(this.restoreSimulations(n.simulations)).done(function(r){n=t.convertState(n);t.restoreWaveBoxes(n.waveboxStates);ProbeModule.getWaveBoxManager().setInitialWaveboxPosition(t.design);i.resolve(r)}),i.promise()},i.prototype.convertState=function(t){var r=this.design.getVersion()<n.VersionTracer.WAVEBOX_DESIGN_VERSION,i;return r?(this.design.setMigrated(),i=t.probes&&t.probes.length>0?!0:!1,i?this.migrateOldState(t):(t.waveboxStates=[],t)):this.deserializeState(t)},i.prototype.deserializeState=function(n){for(var r,i=[],t=0;t<n.waveboxStates.length;t++)r=ServerStructures.WaveBoxMigration.deserializeWaveboxState(n.waveboxStates[t]),i.push(r);return n.waveboxStates=i,n},i.prototype.migrateOldState=function(n){var t,i;for(n.waveboxStates=[],t=0;t<n.probes.length;t++)i=ServerStructures.WaveBoxMigration.convertOldProbeStateToWaveboxState(n.probes[t]),i&&n.waveboxStates.push(i);return n.probes=null,n},i.prototype.suspendProbeVisibility=function(){for(var n=0;n<this.waveBoxes.length;++n)this.waveBoxes[n].suspendProbeVisibility()},i.prototype.restoreProbeVisibility=function(){for(var n=0;n<this.waveBoxes.length;++n)this.waveBoxes[n].restoreProbeVisibility()},i.prototype.getWaveboxArray=function(){return this.waveBoxes},i.prototype.hasWaveboxes=function(){return this.waveBoxes&&this.waveBoxes.length>0},i.prototype.getNumWaveBoxes=function(){return this.waveBoxes.length},i.prototype.dump=function(n){for(var r,t,i=0;i<this.waveBoxes.length;i++)for(r=this.waveBoxes[i],t=0;t<r.probes.length;t++)r.probes[t].dump(n+1,"Probe"+t)},i.prototype.restoreWaveBoxes=function(n){var t,r,i;if(n)for(t=0;t<n.length;t++)r=n[t],i=new ProbeModule.WaveBox(this.design,!1,null),i.showSpinner(),i.restore(r,!1)},i.prototype.getLatestSimulation=function(){var t=this.simulations.length,n;return t<=0?null:(n=this.simulations[t-1],!n)?null:n},i.prototype.getUniqueSimulationList=function(){for(var t,r,u=[],f=[],o=this.simulations.length-1,e=0,i=o;i>=0;--i)if(t=this.simulations[i],t&&(r=t.getSimulationParameters().getActiveSimulation(),f[r]||(u.push(t),f[r]=!0,e++)),e==n.SIMULATION_TYPE_LIST.length)break;return u.reverse()},i.prototype.getUniqueSimulations=function(){return new r(this)},i.prototype.addSimulation=function(n){this.simulations.push(n)},i.prototype.restoreSimulations=function(t){var i=jQuery.Deferred(),f,r,e,o,u,s;if(!t)return i.resolve(!0),i.promise();for(f=!1,this.simulations=[],r=0;r<t.length;++r)this.simulations.push(new n.Simulation(this.design,t[r]));return this.simulations.length>0&&!this.design.getSurface().isSharedDesign()&&(e=this.simulations[this.simulations.length-1].getSimulationResultInfo(),e&&(o=e.getSimulationId(),o&&(u=this.design.getSurface().getSimulationSidebar(),s=u.getSimulator(),s.setSimulationId(o),f=!0,$.when(s.updateSimulationState(u)).done(function(n){u.updateUI();i.resolve(n)})))),f||i.resolve(!0),i.promise()},i.prototype.isOneStale=function(){for(var t=0;t<this.simulations.length;++t)if(this.simulations[t].getStaleState()==n.StaleState.STALE)return!0;return!1},i.prototype.updateStaleState=function(n){for(var i,t=0;t<this.simulations.length;++t)i=this.simulations[t],i.hasResults()&&i.updateStaleState(n)},i.prototype.setRevisionID=function(n){for(var i,t=0;t<this.simulations.length;++t)i=this.simulations[t],i.getRevisionID().length==0&&i.setRevisionID(n)},i}(),t,i,r;n.DesignSimulationData=u;t=function(){function n(){this.waveboxStates=[];this.simulations=[]}return n.prototype.compareTo=function(n,t,i,r){var f=t+PATH_SEPARATOR+"simulationData",u;if(r>=5&&this.simulations&&this.simulations.length>0)for(u=0;u<this.simulations.length;++u)if(!this.simulations[u].compareTo(n.simulations[u],f+"/simulations",i,r))return!1;return!0},n}();n.DesignSimulationDataState=t;i=function(){function t(){this.simulationId=null;this.simulationType=n.SIMULATION_TYPE.NONE;this.isLatest=!1}return t}();n.SimulationDescription=i;r=function(){function t(t){this.simulationMap=[];this.simulationDescriptions=[];this.allTypes=!1;this.anyResults=!1;this.allResults=!1;var i=t.getUniqueSimulationList();this.init(i);this.allTypes=i.length==n.SIMULATION_TYPE_LIST.length}return t.prototype.init=function(n){var o=n.length-1,t,u;for(this.allResults=n&&n.length>0,this.anyResults=!1,t=0;t<n.length;t++)if(u=n[t],u){var r=new i,f=u.getSimulationParameters().getActiveSimulation(),e=u.getSimulationResultInfo();r.simulationId=e.getSimulationId();r.isLatest=t==o;r.simulationType=f;e.hasResultsToPlot()?this.anyResults=!0:this.allResults=!1;this.simulationMap[f]=r;this.simulationDescriptions.push(r)}},t.prototype.getSimulation=function(n){return this.simulationMap[n]},t.prototype.hasAllResults=function(){return this.allTypes&&this.allResults},t.prototype.hasAnyResults=function(){return this.anyResults},t.prototype.getSimulationDescriptions=function(){return this.simulationDescriptions},t.prototype.getLatestDesignSimulation=function(){var n=this.simulationDescriptions.length;return n>0?this.simulationDescriptions[n-1]:null},t}();n.UniqueSimulations=r}(Project||(Project={})),function(n){var t=function(){function n(n,t){this.func=n;this.arg=t}return n}(),i,r,u,f;n.UndoManagerCallback=t;i=function(){function i(){this.undoCommands=[];this.index=-1;this.isExecuting=!1;this.callbacks=[];this.enabled=!0;this.count=0}return i.prototype.execute=function(n,t){return n?(this.isExecuting=!0,n[t](),this.isExecuting=!1,this):this},i.prototype.startUndoableCommand=function(t,i,r,u,f){if(this.enabled)if(this.getActiveCommand()&&!n.Settings.isProductionMode()){var e=f?f:"";console.log("UndoManager.startUndoableCommand() could not start setting up the requested command "+e+"because there is already an active command. Current active command = "+this.getActiveCommand().getCommandClassName())}else this.activeCommand=new t(i,r,u,f)},i.prototype.addToStartState=function(t){this.enabled&&(this.getActiveCommand()?this.getActiveCommand().addToStartState(t):n.Settings.isProductionMode()||console.log("UndoManager.addToStartState() could not add an object to the start state because there is not an active command.\n"))},i.prototype.clearActiveCommand=function(){this.enabled&&this.getActiveCommand()&&(this.activeCommand=null)},i.prototype.finishUndoableCommand=function(t,i){(i===void 0&&(i="unknown command"),this.enabled)&&(this.getActiveCommand()?(this.getActiveCommand().calcEndState(t),this.addToUndoManager()):n.Settings.isProductionMode()||console.log("UndoManager.finishUndoableCommand() for "+i+" could not finish setting up the requested command because there is not an active command.\n"))},i.prototype.cancelCommand=function(t){this.enabled&&(this.getActiveCommand()&&this.getActiveCommand().getCommandName()==t?(this.getActiveCommand().undoCommand(),this.clearActiveCommand()):n.Settings.isProductionMode()||console.log("UndoManager.cancelCommand() for "+t+" could not finish setting up the requested command because there is not an active command.\n"))},i.prototype.getActiveCommand=function(){return this.activeCommand},i.prototype.getCurrentId=function(){return this.index<0?-1:this.undoCommands[this.index].id},i.prototype.addToUndoManager=function(){var t=++this.count,i=new n.CommandInfo(t,this.getActiveCommand());this.add(i);this.clearActiveCommand()},i.prototype.add=function(n){!this.isExecuting&&this.enabled&&(this.undoCommands.splice(this.index+1,this.undoCommands.length-this.index),this.undoCommands.push(n),this.index=this.undoCommands.length-1,this.executeCallbacks())},i.prototype.addCallback=function(n,i){this.callbacks.push(new t(n,i))},i.prototype.removeCallback=function(n){for(var t=0;t<this.callbacks.length;++t)if(n==this.callbacks[t].func){this.callbacks.splice(t,1);return}},i.prototype.executeCallbacks=function(){for(var n=0;n<this.callbacks.length;++n)this.callbacks[n].func(this.callbacks[n].arg)},i.prototype.undo=function(){do{var t=this.undoCommands[this.index];if(!t)return this;this.execute(t,"undo");this.index-=1;this.executeCallbacks()}while(t.step==n.COMMAND_STEP.MIDDLE||t.step==n.COMMAND_STEP.LAST);return this},i.prototype.redo=function(){do{var t=this.undoCommands[this.index+1];if(!t)return this;this.execute(t,"redo");this.index+=1;this.executeCallbacks()}while(t.step==n.COMMAND_STEP.FIRST||t.step==n.COMMAND_STEP.MIDDLE);return this},i.prototype.clear=function(){var t=this.undoCommands.length;this.undoCommands=[];this.index=-1;this.callbacks.length>0&&t>0&&this.executeCallbacks();n.Command.resetCommandIndex()},i.prototype.hasUndo=function(){return this.index!==-1},i.prototype.hasRedo=function(){return this.index<this.undoCommands.length-1},i.prototype.getCommands=function(){return this.undoCommands},i.prototype.getCommandIndex=function(){if(this.index===-1||this.undoCommands[this.index].step==n.COMMAND_STEP.SINGLE)return this.index;for(var t=this.index;t>-1&&this.undoCommands[t].step!=n.COMMAND_STEP.FIRST;)t--;return t},i.prototype.enable=function(){this.enabled=!0},i.prototype.disable=function(){this.enabled=!1},i.prototype.getState=function(){for(var u,f,i=[],r=this.getCommands(),t=r.length-1;t>=0;t--)u=r[t],f=new n.CommandDescription(u),i.push(f);return new n.UndoStackState(i,this.index)},i.prototype.restoreState=function(n,t,i){for(var u,r=t.length-1;r>=0;r--)u=t[r],u?(this.activeCommand=u,this.addToUndoManager()):console.log("Command is not implemented!!!");this.index=i;this.activeCommand=null},i.prototype.setCurrentIndex=function(n){this.index=n},i.prototype.restoreCommand=function(t,i){var u=i.className,r;return!u||!i?null:(r=Object.create(window[n.Command.MODULE_NAME][u].prototype),r.constructor(t,i.state),r)},i.prototype.performStackOperations=function(n){var i=$.Deferred(),t=this.getCommandIndex();if(t>n)while(t>=0&&t>n)this.undo(),t=this.getCommandIndex();else if(t<n)while(t<n)this.redo(),t=this.getCommandIndex();return i.resolve(),i.promise()},i.prototype.performStackOperationsAmount=function(n,t){for(var i=$.Deferred(),u=this,r=0;r<n;r++)t?this.undo():this.redo();return i.resolve(),i.promise()},i.prototype.dumpUndoManagerState=function(t,i,r){var v,s,h,c,o,f,e,l,a,u;if(n.VersionTracer.CURRENT_DESIGN_VERSION<=5){if(t){for(v=r?r:t.getName(),s=this.getState(),h=0;h<s.commandList.length;h++)if(c=s.commandList[h],c.state instanceof n.ComponentCommandState){for(o=c.state,f=0;f<o.compStartStates.length;f++)e=o.compStartStates[f],e.dbComp.Src="",e.dbComp.Img="";for(f=0;f<o.compEndStates.length;f++)e=o.compEndStates[f],e.dbComp.Src="",e.dbComp.Img=""}console.log("------------- UndoManager for"+v+"-----------------");l=i?"public startUndoStackState: any = ":"public endUndoStackState: any = ";l+=JSON.stringify(s)+";\n";a="_QQQQQQQQQQQQQQQQQQQQQ_";u=WaveViewer.WaveUtils.replaceAll("{","{\n",l);u=WaveViewer.WaveUtils.replaceAll("[]",a,u);u=WaveViewer.WaveUtils.replaceAll("[","\n[\n",u);u=WaveViewer.WaveUtils.replaceAll("]","\n]\n",u);u=WaveViewer.WaveUtils.replaceAll(a,"[]",u);console.log(u);console.log("======================================================");Sidebar.DumpEditor.addToTestData(u,!1)}else n.MessageManager.showErrorMessage("dumpUndoManagerState() function is not defined for design version "+n.VersionTracer.CURRENT_DESIGN_VERSION);return u}},i}();n.UndoManager=i;r=function(){function n(n,t){this.id=n;this.undo=function(){t.undoCommand()};this.redo=function(){t.redoCommand()};this.commandName=t.getCommandName();this.step=t.getStep();this.getCommandState=function(){return t.getCommandState()};this.getCommandClass=function(){return t.getCommandClassName()}}return n}();n.CommandInfo=r;u=function(){function n(n){this.state=n.getCommandState();this.step=n.step;this.className=n.getCommandClass()}return n}();n.CommandDescription=u;f=function(){function n(n,t){this.commandList=[];this.commandList=n;this.index=t}return n}();n.UndoStackState=f}(Project||(Project={})),function(n){var t=function(){function t(n){this.surface=n;this.container=$('<div id="'+UNDO_STACK_DIALOG_ID+'" class="'+UNDO_STACK_DIALOG_CLASS+'" ><\/div>');$(document.body).append(this.container)}return t.prototype.init=function(){var i=this,n;this.container.empty();n=$("<div><\/div>");n.append('<div style="float: left">Undo Stack<\/div>');n.append('<i id="'+t.UNDO_STACK_EXIT+'" class="icon-remove" style="float: right"><\/i>');n.append('<p style="line-height: 10px;">&nbsp<\/p>');this.container.append(n);this.container.append('<hr class="hr_sidebar"/>');this.container.draggable();$("#"+t.UNDO_STACK_EXIT).click(function(){i.close()});this.surface.getDesign().getUndoManager().addCallback(this.update,this);this.update()},t.prototype.close=function(){this.container.css("display","none");this.surface.getDesign().getUndoManager().removeCallback(this.update)},t.prototype.show=function(){this.init();this.container.css("top",$(window).height()/2-this.container.height()/2);this.container.css("left",$(window).width()/2-this.container.width()/2);this.container.css("display","block")},t.prototype.update=function(i){var u,r,s,f;i==null?(i=this,u=$('<div id="'+t.UNDO_COMMAND_LIST+'" style="overflow: auto; height: '+(i.container.height()-40)+'px"><\/div>')):(u=$("#"+t.UNDO_COMMAND_LIST),u.empty());var o=i.surface.getDesign().getUndoManager(),e=o.getCommands(),h=o.getCommandIndex(),c=0;for(r=e.length-1;r>=-1;r--)r>=0&&e[r].step!=n.COMMAND_STEP.FIRST&&e[r].step!=n.COMMAND_STEP.SINGLE||(s=r==-1?"Beginning":e[r].commandName,f=$('<div id="'+(t.UNDO_COMMAND_ROW+r)+'" style="cursor: pointer">'+s+"<\/div>"),r==h&&f.addClass("current_undo_index"),c++%2==0&&f.addClass("sidebar_alternate_row"),f.click(function(n){var i=parseInt(n.currentTarget.id.substring(t.UNDO_COMMAND_ROW.length));o.performStackOperations(i)}),u.append(f));i.container.append(u)},t.UNDO_COMMAND_LIST="undo_command_list",t.UNDO_COMMAND_ROW="undo_command_list_",t.UNDO_STACK_EXIT="undo_stack_browser_exit",t}();n.UndoStackBrowser=t}(Project||(Project={})),function(n){var t=function(){function n(){}return n.WAVEBOX_DESIGN_VERSION=7,n.CURRENT_DESIGN_VERSION=n.WAVEBOX_DESIGN_VERSION,n}();n.VersionTracer=t}(Project||(Project={})),function(n){var i=function(){function n(){this.simulationId=null;this.hasWaveformData=!1}return n.prototype.getSimulationId=function(){return this.simulationId},n.prototype.setSimulationId=function(n){this.simulationId=n},n.prototype.setResultStatus=function(n){this.hasWaveformData=n},n.prototype.clear=function(){this.simulationId=null;this.hasWaveformData=!1},n.prototype.getSaveData=function(){var n=new t;return n.simulationId=this.simulationId,n.hasWaveformData=this.hasWaveformData,n},n.prototype.load=function(n){n&&(this.simulationId=n.simulationId,this.hasWaveformData=n.hasWaveformData)},n.prototype.hasResults=function(){return this.simulationId!=null},n.prototype.hasResultsToPlot=function(){return this.simulationId!=null&&this.hasWaveformData},n}(),t;n.SimulationResultInfo=i;t=function(){function t(){this.simulationId=null;this.hasWaveformData=!1}return t.prototype.compareTo=function(t,i,r){return n.Utility.comparePrimitives(this.simulationId,t.simulationId,"simulationId",i,r)?n.Utility.comparePrimitives(this.hasWaveformData,t.hasWaveformData,"hasWaveformData",i,r)?!0:!1:!1},t}();n.SimulationResultState=t}(Project||(Project={})),function(n){var t=function(){function n(){}return n.prototype.crossHighlightByWaveform=function(n,t){n.highlightWaveformAndLegend(t);this.highlightFirstVisibleNodeOrParent(n.wdbId,n.getWaveformHandle(),t);WaveViewer.getManager().highlightSchematicElement(n.getSchematicElementName(),!1,t);n.parentRow&&n.parentRow.hightlightYAxis(n.getYAxisNameWithUnits(),n.getColor(),t)},n.prototype.crossHighlightBySchematicElement=function(n,t,i){var o=WaveViewer.getManager().getViewerWindow(),r,u,f,e;if(o&&(r=o.getLatestWdbId(),u=this.getWaveformHandlesByNodeName(r,n,t),u)){for(f=0;f<u.length;f++)e=u[f],this.highlightWaveformByHandle(r,e,i),this.highlightNodeByHandle(r,e,i);this.highlightFirstVisibleNodeOrParentForFolder(r,n,i)}},n.prototype.crossHighlightFromTree=function(n,t){var i=$(n.currentTarget).find(".viewerSimulationFolder, .viewerSimulationFile"),f,s;if(i.length){var r=i.attr("value"),u=i.attr("wdbid"),e=i.attr("wfid"),h="true"==i.attr("isFolder"),o="true"==i.attr("isComplex"),c="true"==i.attr("isBus");h?o?(f=i.attr("parentName"),f!="undefined"&&(r=f+PATH_SEPARATOR+r),this.crossHighlightByFolderNode(u,r,t,!0)):c?(s=WaveViewer.WaveUtils.getNameWithoutSuffix(r),this.crossHighlightByWaveformNode(u,s,e,t)):this.crossHighlightByFolderNode(u,r,t,!1):o?this.crossHighlightByFolderNode(u,this.getComplexFolderName(r),t,!0):this.crossHighlightByWaveformNode(u,r,e,t)}this.highlighTreeNode(n.currentTarget,t)},n.prototype.getComplexFolderName=function(n){var t=n.split("/");return t?t[0]:n},n.prototype.crossHighlightByFolderNode=function(n,t,i,r){var o=t,f=this.getWaveformHandlesByNodeName(n,t,!0),u,e;if(f)for(u=0;u<f.length;u++)e=f[u],this.highlightWaveformByHandle(n,e,i);WaveViewer.getManager().highlightSchematicElement(t,!r,i)},n.prototype.crossHighlightByWaveformNode=function(n,t,i,r){this.highlightWaveformByHandle(n,i,r);WaveViewer.getManager().highlightSchematicElement(t,!1,r)},n.prototype.highlightWaveformByHandle=function(n,t,i){var f=WaveViewer.getManager().getViewerWindow(),r,u,e;if(f&&(r=f.getWaveContainer().getPlottedWaveformsByHandle(t,n),r&&r.length>0))for(u=0;u<r.length;u++)e=r[u],e.highlightWaveformAndLegend(i)},n.prototype.highlighTreeNode=function(n,t){n!=null&&(t?$(n).addClass("svw-highlighted"):$(n).removeClass("svw-highlighted"))},n.prototype.highlightNodeByHandle=function(n,t,i){var o=WaveViewer.getManager().getTreeView(),u,f,r,e,s,h;if(o&&(u=this.getWdbDataItem(n),u))for(f=u.items,r=0;r<f.length;r++)e=f[r],e.id==t&&(s=o.findByUid(e.uid),h=$(s).find(".k-in:first"),this.highlighTreeNode(h,i))},n.prototype.getWdbDataItem=function(n){var u=WaveViewer.getManager().getTreeView(),f,i,t,r;if(u)for(f=u.dataSource.view()[0],i=f.items,t=0;t<i.length;t++)if(r=i[t],r.wdbId==n)return r;return null},n.prototype.getParentFolderName=function(n,t){var i=WaveViewer.getManager().getTreeView(),u;if(i){var f=i.dataSource.view()[0],e=f.items,r=this.getWdbDataItem(n);r&&(u=this.getFolderDataItem(t,r),u)}return null},n.prototype.getWaveformHandlesByNodeName=function(n,t,i){var c=WaveViewer.getManager().getTreeView(),o,s,u,f,h;if(c){var r=[],l=c.dataSource.view()[0],a=l.items,e=this.getWdbDataItem(n);if(e){if(!i&&(o=this.getWaveformDataItemByNodeName(t,e),o))return r.push(o.id),r;if(s=this.getFolderDataItem(t,e),s&&(u=s.items,u))for(f=0;f<u.length;f++)h=u[f],h.isFolder||r.push(h.id)}}return r},n.prototype.getFolderDataItem=function(n,t){var i,f,r,u;if(t&&(i=t.items,f=[],i))for(r=0;r<i.length;r++)if(u=i[r],u.isFolder&&u.name==n)return u;return null},n.prototype.getWaveformDataItemByNodeName=function(n,t){var r,s,u,i,f,o,e;if(t&&(r=t.items,s=[],r))for(u=0;u<r.length;u++)if(i=r[u],i.isBus){if(f=i.name,o=f.indexOf(n+"["),f==n||o==0)return i}else if(i.isFolder){if(e=this.getWaveformDataItemByNodeName(n,i),e!=null)return e}else if(i.name==n)return i;return null},n.prototype.getWaveformDataItemByHandle=function(n,t){var u,e,f,i,r;if(t&&(u=t.items,e=[],u))for(f=0;f<u.length;f++)if(i=u[f],i.isFolder){if(i.isBus){if(this.isEqualByHandle(n,i.id))return i;if(r=this.getWaveformDataItemByHandle(n,i),r!=null)return r}else if(r=this.getWaveformDataItemByHandle(n,i),r!=null)return r}else if(this.isEqualByHandle(n,i.id))return i;return null},n.prototype.isEqualByHandle=function(n,t){if(!n||!t)return!1;if(n==t)return!0;var i=n.split(":")[1],r=t.split(":")[1];return i==r},n.prototype.isEqualByName=function(n,t){return!n||!t?!1:n==t?!0:!1},n.prototype.getDataItemByName=function(n,t){var i,f,r,u;if(t&&(i=t.items,f=[],i))for(r=0;r<i.length;r++)if(u=i[r],u.isFolder&&this.isEqualByName(n,u.name))return u;return null},n.prototype.isNodeVisible=function(n){var i=WaveViewer.getManager().getTreeJQ(),r=i.offset().top,f=r+i.height(),t=$(n).offset().top,u=t+$(n).height();return t==u?!1:u<=f&&t>=r},n.prototype.isNodeVisibleInTree=function(n){var t=n.find(".k-in:first");return this.isNodeVisible(t)},n.prototype.highlightFirstVisibleNodeOrParent=function(n,t,i){var u=WaveViewer.getManager().getTreeView(),f,e,o,r,h,c,s;if(u&&(f=this.getWdbDataItem(n),f)){if(e=this.getWaveformDataItemByHandle(t,f),e==null){if(o=u.findByUid(f.uid),this.isNodeVisibleInTree(o)){this.highlighTreeNode(o.find(".k-in:first"),i);return}return}if(r=u.findByUid(e.uid),this.isNodeVisibleInTree(r)){this.highlighTreeNode(r.find(".k-in:first"),i);return}do if(h=r,r=u.parent(r),r.length){if(c=u.dataItem(r),this.isNodeVisibleInTree(r)){this.highlighTreeNode(r.find(".k-in:first"),i);return}}else{s=u.findByUid(f.uid);this.highlighTreeNode(s.find(".k-in:first"),i);return}while(1)}},n.prototype.highlightFirstVisibleNodeOrParentForFolder=function(n,t,i){var u=WaveViewer.getManager().getTreeView(),f,e,r,s,h,o;if(u&&(f=this.getWdbDataItem(n),f)){if(e=this.getDataItemByName(t,f),e==null)return;if(r=u.findByUid(e.uid),this.isNodeVisibleInTree(r)){this.highlighTreeNode(r.find(".k-in:first"),i);return}do if(s=r,r=u.parent(r),r.length){if(h=u.dataItem(r),this.isNodeVisibleInTree(r)){this.highlighTreeNode(r.find(".k-in:first"),i);return}}else{o=u.findByUid(f.uid);this.highlighTreeNode(o.find(".k-in:first"),i);return}while(1)}},n}();n.CrossHighlightManager=t}(Project||(Project={})),function(n){n.color={};n.color.make=function(t,i,r,u){var f={};return f.r=t||0,f.g=i||0,f.b=r||0,f.a=u!=null?u:1,f.add=function(n,t){for(var i=0;i<n.length;++i)f[n.charAt(i)]+=t;return f.normalize()},f.scale=function(n,t){for(var i=0;i<n.length;++i)f[n.charAt(i)]*=t;return f.normalize()},f.toString=function(){return f.a>=1?"rgb("+[f.r,f.g,f.b].join(",")+")":"rgba("+[f.r,f.g,f.b,f.a].join(",")+")"},f.normalize=function(){function n(n,t,i){return t<n?n:t>i?i:t}return f.r=n(0,parseInt(f.r),255),f.g=n(0,parseInt(f.g),255),f.b=n(0,parseInt(f.b),255),f.a=n(0,f.a,1),f},f.clone=function(){return n.color.make(f.r,f.b,f.g,f.a)},f.normalize()};n.color.extract=function(t,i){var r;do{if(r=t.css(i).toLowerCase(),r!=""&&r!="transparent")break;t=t.parent()}while(t.length&&!n.nodeName(t.get(0),"body"));return r=="rgba(0, 0, 0, 0)"&&(r="transparent"),n.color.parse(r)};n.color.parse=function(i){var r,u=n.color.make,f;return(r=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(i))?u(parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)):(r=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(i))?u(parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4])):(r=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(i))?u(parseFloat(r[1])*2.55,parseFloat(r[2])*2.55,parseFloat(r[3])*2.55):(r=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(i))?u(parseFloat(r[1])*2.55,parseFloat(r[2])*2.55,parseFloat(r[3])*2.55,parseFloat(r[4])):(r=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(i))?u(parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)):(r=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(i))?u(parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)):(f=n.trim(i).toLowerCase(),f=="transparent"?u(255,255,255,0):(r=t[f]||[0,0,0],u(r[0],r[1],r[2])))};var t={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}}(jQuery),function(n){function t(t,i){var r=i.children("."+t)[0];if(r==null&&(r=document.createElement("canvas"),r.className=t,n(r).css({direction:"ltr",position:"absolute",left:0,top:0}).appendTo(i),!r.getContext))if(window.G_vmlCanvasManager)r=window.G_vmlCanvasManager.initElement(r);else throw new Error("Canvas is not available. If you're using IE with a fall-back such as Excanvas, then there's either a mistake in your conditional include, or the page has no DOCTYPE and is rendering in Quirks Mode.");this.element=r;var u=this.context=r.getContext("2d"),f=window.devicePixelRatio||1,e=u.webkitBackingStorePixelRatio||u.mozBackingStorePixelRatio||u.msBackingStorePixelRatio||u.oBackingStorePixelRatio||u.backingStorePixelRatio||1;this.pixelRatio=f/e;this.resize(i.width(),i.height());this.textContainer=null;this.text={};this._textCache={}}function r(i,r,f,e){function nt(n,t){t=[c].concat(t);for(var i=0;i<n.length;++i)n[i].apply(this,t)}function ci(){for(var i,u={Canvas:t},r=0;r<e.length;++r)i=e[r],i.init(c,u),i.options&&n.extend(!0,o,i.options)}function li(t){var f;n.extend(!0,o,t);t&&t.colors&&(o.colors=t.colors);o.xaxis.color==null&&(o.xaxis.color=n.color.parse(o.grid.color).scale("a",.22).toString());o.yaxis.color==null&&(o.yaxis.color=n.color.parse(o.grid.color).scale("a",.22).toString());o.xaxis.tickColor==null&&(o.xaxis.tickColor=o.grid.tickColor||o.xaxis.color);o.yaxis.tickColor==null&&(o.yaxis.tickColor=o.grid.tickColor||o.yaxis.color);o.grid.borderColor==null&&(o.grid.borderColor=o.grid.color);o.grid.tickColor==null&&(o.grid.tickColor=n.color.parse(o.grid.color).scale("a",.22).toString());for(var r,s=i.css("font-size"),c=s?+s.replace("px",""):13,h={style:i.css("font-style"),size:Math.round(.8*c),variant:i.css("font-variant"),weight:i.css("font-weight"),family:i.css("font-family")},e=o.xaxes.length||1,u=0;u<e;++u)r=o.xaxes[u],r&&!r.tickColor&&(r.tickColor=r.color),r=n.extend(!0,{},o.xaxis,r),o.xaxes[u]=r,r.font&&(r.font=n.extend({},h,r.font),r.font.color||(r.font.color=r.color),r.font.lineHeight||(r.font.lineHeight=Math.round(r.font.size*1.15)));for(e=o.yaxes.length||1,u=0;u<e;++u)r=o.yaxes[u],r&&!r.tickColor&&(r.tickColor=r.color),r=n.extend(!0,{},o.yaxis,r),o.yaxes[u]=r,r.font&&(r.font=n.extend({},h,r.font),r.font.color||(r.font.color=r.color),r.font.lineHeight||(r.font.lineHeight=Math.round(r.font.size*1.15)));for(o.xaxis.noTicks&&o.xaxis.ticks==null&&(o.xaxis.ticks=o.xaxis.noTicks),o.yaxis.noTicks&&o.yaxis.ticks==null&&(o.yaxis.ticks=o.yaxis.noTicks),o.x2axis&&(o.xaxes[1]=n.extend(!0,{},o.xaxis,o.x2axis),o.xaxes[1].position="top",o.x2axis.min==null&&(o.xaxes[1].min=null),o.x2axis.max==null&&(o.xaxes[1].max=null)),o.y2axis&&(o.yaxes[1]=n.extend(!0,{},o.yaxis,o.y2axis),o.yaxes[1].position="right",o.y2axis.min==null&&(o.yaxes[1].min=null),o.y2axis.max==null&&(o.yaxes[1].max=null)),o.grid.coloredAreas&&(o.grid.markings=o.grid.coloredAreas),o.grid.coloredAreasColor&&(o.grid.markingsColor=o.grid.coloredAreasColor),o.lines&&n.extend(!0,o.series.lines,o.lines),o.points&&n.extend(!0,o.series.points,o.points),o.bars&&n.extend(!0,o.series.bars,o.bars),o.shadowSize!=null&&(o.series.shadowSize=o.shadowSize),o.highlightColor!=null&&(o.series.highlightColor=o.highlightColor),u=0;u<o.xaxes.length;++u)st(y,u+1).options=o.xaxes[u];for(u=0;u<o.yaxes.length;++u)st(b,u+1).options=o.yaxes[u];for(f in w)o.hooks[f]&&o.hooks[f].length&&(w[f]=w[f].concat(o.hooks[f]));nt(w.processOptions,[o])}function at(n){l=ai(n);yi();pi()}function ai(t){for(var r,u=[],i=0;i<t.length;++i)r=n.extend(!0,{},o.series),t[i].data!=null?(r.data=t[i].data,delete t[i].data,n.extend(!0,r,t[i]),t[i].data=r.data):r.data=t[i],u.push(r);return u}function ot(n,t){var i=n[t+"axis"];return typeof i=="object"&&(i=i.n),typeof i!="number"&&(i=1),i}function it(){return n.grep(y.concat(b),function(n){return n})}function vt(n){for(var i={},t,r=0;r<y.length;++r)t=y[r],t&&t.used&&(i["x"+t.n]=t.c2p(n.left));for(r=0;r<b.length;++r)t=b[r],t&&t.used&&(i["y"+t.n]=t.c2p(n.top));return i.x1!==undefined&&(i.x=i.x1),i.y1!==undefined&&(i.y=i.y1),i}function vi(n){for(var u={},t,i,r=0;r<y.length;++r)if(t=y[r],t&&t.used&&(i="x"+t.n,n[i]==null&&t.n==1&&(i="x"),n[i]!=null)){u.left=t.p2c(n[i]);break}for(r=0;r<b.length;++r)if(t=b[r],t&&t.used&&(i="y"+t.n,n[i]==null&&t.n==1&&(i="y"),n[i]!=null)){u.top=t.p2c(n[i]);break}return u}function st(t,i){return t[i-1]||(t[i-1]={n:i,direction:t==y?"x":"y",options:n.extend(!0,{},t==y?o.xaxis:o.yaxis)}),t[i-1]}function yi(){for(var f=l.length,e=-1,u,h,t,c,a,i=0;i<l.length;++i)u=l[i].color,u!=null&&(f--,typeof u=="number"&&u>e&&(e=u));f<=e&&(f=e+1);var v,s=[],p=o.colors,w=p.length,r=0;for(i=0;i<f;i++)v=n.color.parse(p[i%w]||"#666"),i%w==0&&i&&(r=r>=0?r<.5?-r-.2:0:-r),s[i]=v.scale("rgb",1+r);for(h=0,i=0;i<l.length;++i){if(t=l[i],t.color==null?(t.color=s[h].toString(),++h):typeof t.color=="number"&&(t.color=s[t.color].toString()),t.lines.show==null){a=!0;for(c in t)if(t[c]&&t[c].show){a=!1;break}a&&(t.lines.show=!0)}t.lines.zero==null&&(t.lines.zero=!!t.lines.fill);t.xaxis=st(y,ot(t,"x"));t.yaxis=st(b,ot(t,"y"))}}function pi(){function b(n,t,i){t<n.datamin&&t!=-v&&(n.datamin=t);i>n.datamax&&i!=v&&(n.datamax=i)}var y=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,v=Number.MAX_VALUE,f,c,e,r,t,u,h,i,s,ut,ft,o,et,ot,k,a;for(n.each(it(),function(n,t){t.datamin=y;t.datamax=p;t.used=!1}),f=0;f<l.length;++f)t=l[f],t.datapoints={points:[]},nt(w.processRawData,[t,t.data,t.datapoints]);for(f=0;f<l.length;++f)if(t=l[f],ft=t.data,o=t.datapoints.format,o||(o=[],o.push({x:!0,number:!0,required:!0}),o.push({y:!0,number:!0,required:!0}),(t.bars.show||t.lines.show&&t.lines.fill)&&(et=!!(t.bars.show&&t.bars.zero||t.lines.show&&t.lines.zero),o.push({y:!0,number:!0,required:!1,defaultValue:0,autoscale:et}),t.bars.horizontal&&(delete o[o.length-1].y,o[o.length-1].x=!0)),t.datapoints.format=o),t.datapoints.pointsize==null)for(t.datapoints.pointsize=o.length,h=t.datapoints.pointsize,u=t.datapoints.points,ot=t.lines.show&&t.lines.steps,t.xaxis.used=t.yaxis.used=!0,c=e=0;c<ft.length;++c,e+=h){if(ut=ft[c],k=ut==null,!k)for(r=0;r<h;++r)i=ut[r],s=o[r],s&&(s.number&&i!=null&&(i=+i,isNaN(i)?i=null:i==Infinity?i=v:i==-Infinity&&(i=-v)),i==null&&(s.required&&(k=!0),s.defaultValue!=null&&(i=s.defaultValue))),u[e+r]=i;if(k)for(r=0;r<h;++r)i=u[e+r],i!=null&&(s=o[r],s.autoscale!==!1&&(s.x&&b(t.xaxis,i,i),s.y&&b(t.yaxis,i,i))),u[e+r]=null;else if(ot&&e>0&&u[e-h]!=null&&u[e-h]!=u[e]&&u[e-h+1]!=u[e+1]){for(r=0;r<h;++r)u[e+h+r]=u[e+r];u[e+1]=u[e-h+1];e+=h}}for(f=0;f<l.length;++f)t=l[f],nt(w.processDatapoints,[t,t.datapoints]);for(f=0;f<l.length;++f){t=l[f];u=t.datapoints.points;h=t.datapoints.pointsize;o=t.datapoints.format;var d=y,g=y,tt=p,rt=p;for(c=0;c<u.length;c+=h)if(u[c]!=null)for(r=0;r<h;++r)(i=u[c+r],s=o[r],s&&s.autoscale!==!1&&i!=v&&i!=-v)&&(s.x&&(i<d&&(d=i),i>tt&&(tt=i)),s.y&&(i<g&&(g=i),i>rt&&(rt=i)));if(t.bars.show){switch(t.bars.align){case"left":a=0;break;case"right":a=-t.bars.barWidth;break;default:a=-t.bars.barWidth/2}t.bars.horizontal?(g+=a,rt+=a+t.bars.barWidth):(d+=a,tt+=a+t.bars.barWidth)}b(t.xaxis,d,tt);b(t.yaxis,g,rt)}n.each(it(),function(n,t){t.datamin==y&&(t.datamin=null);t.datamax==p&&(t.datamax=null)})}function wi(){i.css("padding",0).children(":not(.flot-base,.flot-overlay), .raphael-waverow").remove();i.css("position")=="static"&&i.css("position","relative");a=new t("flot-base",i);tt=new t("flot-overlay",i);bi(c,i);s=a.context;v=tt.context;d=n(ft).off();var r=i.data("plot");r&&(r.shutdown(),tt.clear());i.data("plot",c)}function bi(n,t){ft=ki(n,t);ut=new Raphael(ft,t.width(),t.height());ut.renderfix();ut.clear()}function ki(t,i){var r=document.createElement("div");return r.className="raphael-waverow",r.width=i.width(),r.height=i.height(),r.id="raphael-waverow"+t.getOptions().raphaelSupport.rowId,n(r).css({position:"absolute",left:0,top:0}),n(r).appendTo(i),r}function di(){o.grid.hoverable&&(d.mousemove(ti),d.bind("mouseleave",ii));o.grid.clickable&&d.click(ri);nt(w.bindEvents,[d])}function yt(){rt&&clearTimeout(rt);d.off("mousemove",ti);d.off("mouseleave",ii);d.off("click",ri);nt(w.shutdown,[d])}function pt(n){function u(n){return n}var i,r,t=n.options.transform||u,f=n.options.inverseTransform;n.direction=="x"?(i=n.scale=k/Math.abs(t(n.max)-t(n.min)),r=Math.min(t(n.max),t(n.min))):(i=n.scale=p/Math.abs(t(n.max)-t(n.min)),i=-i,r=Math.max(t(n.max),t(n.min)));n.p2c=t==u?function(n){return(n-r)*i}:function(n){return(t(n)-r)*i};n.c2p=f?function(n){return f(r+n/i)}:function(n){return r+n/i}}function gi(n){for(var e,o,t=n.options,r=n.ticks||[],i=t.labelWidth||0,u=t.labelHeight||0,s=i||(n.direction=="x"?Math.floor(a.width/(r.length||1)):null),h=n.direction+"Axis "+n.direction+n.n+"Axis",c="flot-"+n.direction+"-axis flot-"+n.direction+n.n+"-axis "+h,l=t.font||"flot-tick-label tickLabel",f=0;f<r.length;++f)(e=r[f],e.label)&&(o=a.getTextInfo(c,e.label,l,null,s),i=Math.max(i,o.width),u=Math.max(u,o.height));n.labelWidth=t.labelWidth||i;n.labelHeight=t.labelHeight||u}function nr(t){var r=t.labelWidth,u=t.labelHeight,e=t.options.position,l=t.direction==="x",f=t.options.tickLength,i=o.grid.axisMargin,s=o.grid.labelMargin,v=!0,p=!0,w=!0,c=!1;n.each(l?y:b,function(n,i){i&&(i.show||i.reserveSpace)&&(i===t?c=!0:i.options.position===e&&(c?p=!1:v=!1),c||(w=!1))});p&&(i=0);f==null&&(f=w?"full":5);isNaN(+f)||(s+=+f);l?(u+=s,e=="bottom"?(h.bottom+=u+i,t.box={top:a.height-h.bottom,height:u}):(t.box={top:h.top+i,height:u},h.top+=u+i)):(r+=s,e=="left"?(t.box={left:h.left+i,width:r},h.left+=r+i):(h.right+=r+i,t.box={left:a.width-h.right,width:r}));t.position=e;t.tickLength=f;t.box.padding=s;t.innermost=v}function tr(n){n.direction=="x"?(n.box.left=h.left-n.labelWidth/2,n.box.width=a.width-h.left-h.right+n.labelWidth):(n.box.top=h.top-n.labelHeight/2,n.box.height=a.height-h.bottom-h.top+n.labelHeight)}function ir(){var i=o.grid.minBorderMargin,r,t;if(i==null)for(i=0,r=0;r<l.length;++r)i=Math.max(i,2*(l[r].points.radius+l[r].points.lineWidth/2));t={left:i,right:i,top:i,bottom:i};n.each(it(),function(n,i){i.reserveSpace&&i.ticks&&i.ticks.length&&(i.direction==="x"?(t.left=Math.max(t.left,i.labelWidth/2),t.right=Math.max(t.right,i.labelWidth/2)):(t.bottom=Math.max(t.bottom,i.labelHeight/2),t.top=Math.max(t.top,i.labelHeight/2)))});h.left=Math.ceil(Math.max(t.left,h.left));h.right=Math.ceil(Math.max(t.right,h.right));h.top=Math.ceil(Math.max(t.top,h.top));h.bottom=Math.ceil(Math.max(t.bottom,h.bottom))}function wt(){var r,u=it(),f=o.grid.show,e,t,i;for(t in h)e=o.grid.margin||0,h[t]=typeof e=="number"?e:e[t]||0;nt(w.processOffset,[h]);for(t in h)h[t]+=typeof o.grid.borderWidth=="object"?f?o.grid.borderWidth[t]:0:f?o.grid.borderWidth:0;if(n.each(u,function(n,t){var i=t.options;t.show=i.show==null?t.used:i.show;t.reserveSpace=i.reserveSpace==null?t.show:i.reserveSpace;rr(t)}),f){for(ht&&(k=a.width-h.left-h.right,p=a.height-h.bottom-h.top,n.each(u,function(n,t){pt(t)}),ht=!1),i=n.grep(u,function(n){return n.show||n.reserveSpace}),n.each(i,function(n,t){ur(t);fr(t);er(t,t.ticks);gi(t)}),r=i.length-1;r>=0;--r)nr(i[r]);ir();n.each(i,function(n,t){tr(t)})}k=a.width-h.left-h.right;p=a.height-h.bottom-h.top;n.each(u,function(n,t){pt(t)});f&&sr();vr()}function rr(n){var t=n.options,r=+(t.min!=null?t.min:n.datamin),i=+(t.max!=null?t.max:n.datamax),f=i-r,e,u;f==0?(e=i==0?1:.01,t.min==null&&(r-=e),(t.max==null||t.min!=null)&&(i+=e)):(u=t.autoscaleMargin,u!=null&&(t.min==null&&(r-=f*u,r<0&&n.datamin!=null&&n.datamin>=0&&(r=0)),t.max==null&&(i+=f*u,i>0&&n.datamax!=null&&n.datamax<=0&&(i=0))));n.min=r;n.max=i}function ur(t){var i=t.options,w,v,h,f,r,s,p,c;w=typeof i.ticks=="number"&&i.ticks>0?i.ticks:.3*Math.sqrt(t.direction=="x"?a.width:a.height);var l=(t.max-t.min)/w,o=-Math.floor(Math.log(l)/Math.LN10),e=i.tickDecimals;if(e!=null&&o>e&&(o=e),v=Math.pow(10,-o),h=l/v,h<1.5?f=1:h<3?(f=2,h>2.25&&(e==null||o+1<=e)&&(f=2.5,++o)):f=h<7.5?5:10,f*=v,i.minTickSize!=null&&f<i.minTickSize&&(f=i.minTickSize),t.delta=l,t.tickDecimals=Math.max(0,e!=null?e:o),t.tickSize=i.tickSize||f,i.mode=="time"&&!t.tickGenerator)throw new Error("Time mode requires the flot.time plugin.");t.tickGenerator||(t.tickGenerator=function(n){var i=[],e=u(n.min,n.tickSize),r=0,t=Number.NaN,f;do f=t,t=e+r*n.tickSize,i.push(t),++r;while(t<n.max&&t!=f);return i},t.tickFormatter=function(n,t){var u=t.tickDecimals?Math.pow(10,t.tickDecimals):1,i=""+Math.round(n*u)/u,f,r;return t.tickDecimals!=null&&(f=i.indexOf("."),r=f==-1?0:i.length-f-1,r<t.tickDecimals)?(r?i:i+".")+(""+u).substr(1,t.tickDecimals-r):i});n.isFunction(i.tickFormatter)&&(t.tickFormatter=function(n,t){return""+i.tickFormatter(n,t)});i.alignTicksWithAxis!=null&&(r=(t.direction=="x"?y:b)[i.alignTicksWithAxis-1],r&&r.used&&r!=t&&(s=t.tickGenerator(t),s.length>0&&(i.min==null&&(t.min=Math.min(t.min,s[0])),i.max==null&&s.length>1&&(t.max=Math.max(t.max,s[s.length-1]))),t.tickGenerator=function(n){for(var u=[],t,i=0;i<r.ticks.length;++i)t=(r.ticks[i].v-r.min)/(r.max-r.min),t=n.min+t*(n.max-n.min),u.push(t);return u},t.mode||i.tickDecimals!=null||(p=Math.max(0,-Math.floor(Math.log(t.delta)/Math.LN10)+1),c=t.tickGenerator(t),c.length>1&&/\..*0$/.test((c[1]-c[0]).toFixed(p))||(t.tickDecimals=p))))}function fr(t){var r=t.options.ticks,e=[],o,u,f,s,i;for(r==null||typeof r=="number"&&r>0?e=t.tickGenerator(t):r&&(e=n.isFunction(r)?r(t):r),t.ticks=[],o=0;o<e.length;++o)f=null,s=!1,t.direction=="y"&&t.options.isResize&&(s=!0),i=e[o],typeof i=="object"?(u=+i[0],i.length>1&&(f=i[1]),i.length>2&&(s=i[2])):u=+i,f==null&&(f=t.tickFormatter(u,t)),isNaN(u)||t.ticks.push({v:u,label:f,major:s})}function er(n,t){n.options.autoscaleMargin&&t.length>0&&(n.options.min==null&&(n.min=Math.min(n.min,t[0].v)),n.options.max==null&&t.length>1&&(n.max=Math.max(n.max,t[t.length-1].v)))}function bt(){var n,t;for(a.clear(),nt(w.drawBackground,[s]),n=o.grid,n.show&&n.backgroundColor&&or(),n.show&&!n.aboveData&&dt(),t=0;t<l.length;++t)nt(w.drawSeries,[s,l[t]]),hr(l[t]);nt(w.draw,[s]);n.show&&n.aboveData&&dt();a.render();et()}function kt(n,t){for(var s,f,i,r,u,o=it(),e=0;e<o.length;++e)if(f=o[e],f.direction==t&&(u=t+f.n+"axis",n[u]||f.n!=1||(u=t+"axis"),n[u])){i=n[u].from;r=n[u].to;break}return n[u]||(f=t=="x"?y[0]:b[0],i=n[t+"1"],r=n[t+"2"]),i!=null&&r!=null&&i>r&&(s=i,i=r,r=s),{from:i,to:r,axis:f}}function or(){s.save();s.translate(h.left,h.top);s.fillStyle=si(o.grid.backgroundColor,p,0,"rgba(255, 255, 255, 0)");s.fillRect(0,0,k,p);s.restore()}function dt(){var v,f,t,e,d,rt,et,ot,tt,ut,b;if(s.save(),s.translate(h.left,h.top),d=o.grid.markings,d)for(n.isFunction(d)&&(f=c.getAxes(),f.xmin=f.xaxis.min,f.xmax=f.xaxis.max,f.ymin=f.yaxis.min,f.ymax=f.yaxis.max,d=d(f)),v=0;v<d.length;++v){var nt=d[v],i=kt(nt,"x"),r=kt(nt,"y");(i.from==null&&(i.from=i.axis.min),i.to==null&&(i.to=i.axis.max),r.from==null&&(r.from=r.axis.min),r.to==null&&(r.to=r.axis.max),i.to<i.axis.min||i.from>i.axis.max||r.to<r.axis.min||r.from>r.axis.max)||(i.from=Math.max(i.from,i.axis.min),i.to=Math.min(i.to,i.axis.max),r.from=Math.max(r.from,r.axis.min),r.to=Math.min(r.to,r.axis.max),rt=i.from===i.to,et=r.from===r.to,rt&&et)||(i.from=Math.floor(i.axis.p2c(i.from)),i.to=Math.floor(i.axis.p2c(i.to)),r.from=Math.floor(r.axis.p2c(r.from)),r.to=Math.floor(r.axis.p2c(r.to)),rt||et?(ot=nt.lineWidth||o.grid.markingsLineWidth,tt=ot%2?.5:0,s.beginPath(),s.strokeStyle=nt.color||o.grid.markingsColor,s.lineWidth=ot,rt?(s.moveTo(i.to+tt,r.from),s.lineTo(i.to+tt,r.to)):(s.moveTo(i.from,r.to+tt),s.lineTo(i.to,r.to+tt)),s.stroke()):(s.fillStyle=nt.color||o.grid.markingsColor,s.fillRect(i.from,r.to,i.to-i.from,r.from-r.to)))}for(f=it(),t=o.grid.borderWidth,ut=0;ut<f.length;++ut){var u=f[ut],ft=u.box,g=u.tickLength,l,a,y,w;if(u.show&&u.ticks.length!=0){for(s.lineWidth=1,u.direction=="x"?(l=0,a=g=="full"?u.position=="top"?0:p:ft.top-h.top+(u.position=="top"?ft.height:0)):(a=0,l=g=="full"?u.position=="left"?0:k:ft.left-h.left+(u.position=="left"?ft.width:0)),u.innermost||(s.strokeStyle=u.options.color,s.beginPath(),y=w=0,u.direction=="x"?y=k+1:w=p+1,s.lineWidth==1&&(u.direction=="x"?a=Math.floor(a)+.5:l=Math.floor(l)+.5),s.moveTo(l,a),s.lineTo(l+y,a+w),s.stroke()),s.strokeStyle=u.options.tickColor,s.beginPath(),v=0;v<u.ticks.length;++v)(b=u.ticks[v].v,y=w=0,isNaN(b)||b<u.min||b>u.max||g=="full"&&(typeof t=="object"&&t[u.position]>0||t>0)&&(b==u.min||b==u.max))||(u.direction=="x"?(l=u.p2c(b),w=g=="full"?-p:g,u.position=="top"&&(w=-w)):(a=u.p2c(b),y=g=="full"?-k:g,u.position=="left"&&(y=-y)),s.lineWidth==1&&(u.direction=="x"?l=Math.floor(l)+.5:a=Math.floor(a)+.5),s.moveTo(l,a),s.lineTo(l+y,a+w));s.stroke()}}t&&(e=o.grid.borderColor,typeof t=="object"||typeof e=="object"?(typeof t!="object"&&(t={top:t,right:t,bottom:t,left:t}),typeof e!="object"&&(e={top:e,right:e,bottom:e,left:e}),t.top>0&&(s.strokeStyle=e.top,s.lineWidth=t.top,s.beginPath(),s.moveTo(0-t.left,0-t.top/2),s.lineTo(k,0-t.top/2),s.stroke()),t.right>0&&(s.strokeStyle=e.right,s.lineWidth=t.right,s.beginPath(),s.moveTo(k+t.right/2,0-t.top),s.lineTo(k+t.right/2,p),s.stroke()),t.bottom>0&&(s.strokeStyle=e.bottom,s.lineWidth=t.bottom,s.beginPath(),s.moveTo(k+t.right,p+t.bottom/2),s.lineTo(0,p+t.bottom/2),s.stroke()),t.left>0&&(s.strokeStyle=e.left,s.lineWidth=t.left,s.beginPath(),s.moveTo(0-t.left/2,p+t.bottom),s.lineTo(0-t.left/2,0),s.stroke())):(s.lineWidth=t,s.strokeStyle=o.grid.borderColor,s.strokeRect(-t/2,-t/2,k+t,p+t)));s.restore()}function sr(){n.each(it(),function(n,t){var i=t.box,l=t.direction+"Axis "+t.direction+t.n+"Axis",c="flot-"+t.direction+"-axis flot-"+t.direction+t.n+"-axis "+l,v=t.options.font||"flot-tick-label tickLabel",r,u,f,o,s,e;if(a.removeText(c),t.show&&t.ticks.length!=0)for(e=0;e<t.ticks.length;++e)(r=t.ticks[e],!r.label||r.v<t.min||r.v>t.max)||(t.direction=="x"?(o="center",u=h.left+t.p2c(r.v),t.position=="bottom"?f=i.top+i.padding:(f=i.top+i.height-i.padding,s="bottom")):(s="middle",f=h.top+t.p2c(r.v),t.position=="left"?(u=i.left+i.width-i.padding,o="right"):u=i.left+i.padding),a.addText(c,u,f,r.label,v,null,null,o,s))})}function hr(n){n.lines.show&&cr(n);n.bars.show&&ar(n);n.points.show&&lr(n)}function cr(n){function u(n,t,i,r,u){var l=n.points,a=n.pointsize,v=null,y=null,c;for(s.beginPath(),c=a;c<l.length;c+=a){var f=l[c-a],e=l[c-a+1],o=l[c],h=l[c+1];if(f!=null&&o!=null){if(e<=h&&e<u.min){if(h<u.min)continue;f=(u.min-e)/(h-e)*(o-f)+f;e=u.min}else if(h<=e&&h<u.min){if(e<u.min)continue;o=(u.min-e)/(h-e)*(o-f)+f;h=u.min}if(e>=h&&e>u.max){if(h>u.max)continue;f=(u.max-e)/(h-e)*(o-f)+f;e=u.max}else if(h>=e&&h>u.max){if(e>u.max)continue;o=(u.max-e)/(h-e)*(o-f)+f;h=u.max}if(f<=o&&f<r.min){if(o<r.min)continue;e=(r.min-f)/(o-f)*(h-e)+e;f=r.min}else if(o<=f&&o<r.min){if(f<r.min)continue;h=(r.min-f)/(o-f)*(h-e)+e;o=r.min}if(f>=o&&f>r.max){if(o>r.max)continue;e=(r.max-f)/(o-f)*(h-e)+e;f=r.max}else if(o>=f&&o>r.max){if(f>r.max)continue;h=(r.max-f)/(o-f)*(h-e)+e;o=r.max}(f!=v||e!=y)&&s.moveTo(r.p2c(f)+t,u.p2c(e)+i);v=o;y=h;s.lineTo(r.p2c(o)+t,u.p2c(h)+i)}}s.stroke()}function e(n,t,i){for(var c=n.points,o=n.pointsize,b=Math.min(Math.max(0,i.min),i.max),h=0,l=!1,a=1,p=0,w=0,v,y;;){if(o>0&&h>c.length+o)break;h+=o;var r=c[h-o],u=c[h-o+a],f=c[h],e=c[h+a];if(l){if(o>0&&r!=null&&f==null){w=h;o=-o;a=2;continue}if(o<0&&h==p+o){s.fill();l=!1;o=-o;a=1;h=p=w+o;continue}}if(r!=null&&f!=null){if(r<=f&&r<t.min){if(f<t.min)continue;u=(t.min-r)/(f-r)*(e-u)+u;r=t.min}else if(f<=r&&f<t.min){if(r<t.min)continue;e=(t.min-r)/(f-r)*(e-u)+u;f=t.min}if(r>=f&&r>t.max){if(f>t.max)continue;u=(t.max-r)/(f-r)*(e-u)+u;r=t.max}else if(f>=r&&f>t.max){if(r>t.max)continue;e=(t.max-r)/(f-r)*(e-u)+u;f=t.max}if(l||(s.beginPath(),s.moveTo(t.p2c(r),i.p2c(b)),l=!0),u>=i.max&&e>=i.max){s.lineTo(t.p2c(r),i.p2c(i.max));s.lineTo(t.p2c(f),i.p2c(i.max));continue}else if(u<=i.min&&e<=i.min){s.lineTo(t.p2c(r),i.p2c(i.min));s.lineTo(t.p2c(f),i.p2c(i.min));continue}v=r;y=f;u<=e&&u<i.min&&e>=i.min?(r=(i.min-u)/(e-u)*(f-r)+r,u=i.min):e<=u&&e<i.min&&u>=i.min&&(f=(i.min-u)/(e-u)*(f-r)+r,e=i.min);u>=e&&u>i.max&&e<=i.max?(r=(i.max-u)/(e-u)*(f-r)+r,u=i.max):e>=u&&e>i.max&&u<=i.max&&(f=(i.max-u)/(e-u)*(f-r)+r,e=i.max);r!=v&&s.lineTo(t.p2c(v),i.p2c(u));s.lineTo(t.p2c(r),i.p2c(u));s.lineTo(t.p2c(f),i.p2c(e));f!=y&&(s.lineTo(t.p2c(f),i.p2c(e)),s.lineTo(t.p2c(y),i.p2c(e)))}}}var t,i,r,f;s.save();s.translate(h.left,h.top);s.lineJoin="round";t=n.lines.lineWidth;i=n.shadowSize;t>0&&i>0&&(s.lineWidth=i,s.strokeStyle="rgba(0,0,0,0.1)",r=Math.PI/18,u(n.datapoints,Math.sin(r)*(t/2+i/2),Math.cos(r)*(t/2+i/2),n.xaxis,n.yaxis),s.lineWidth=i/2,u(n.datapoints,Math.sin(r)*(t/2+i/4),Math.cos(r)*(t/2+i/4),n.xaxis,n.yaxis));s.lineWidth=t;s.strokeStyle=n.color;f=ct(n.lines,n.color,0,p);f&&(s.fillStyle=f,e(n.datapoints,n.xaxis,n.yaxis));t>0&&u(n.datapoints,0,0,n.xaxis,n.yaxis);s.restore()}function lr(n){function r(n,t,i,r,u,f,e,o){for(var h,c,a=n.points,v=n.pointsize,l=0;l<a.length;l+=v)(h=a[l],c=a[l+1],h==null||h<f.min||h>f.max||c<e.min||c>e.max)||(s.beginPath(),h=f.p2c(h),c=e.p2c(c)+r,o=="circle"?s.arc(h,c,t,0,u?Math.PI:Math.PI*2,!1):o(s,h,c,t,u),s.closePath(),i&&(s.fillStyle=i,s.fill()),s.stroke())}var t;s.save();s.translate(h.left,h.top);var i=n.points.lineWidth,e=n.shadowSize,u=n.points.radius,f=n.points.symbol;i==0&&(i=.0001);i>0&&e>0&&(t=e/2,s.lineWidth=t,s.strokeStyle="rgba(0,0,0,0.1)",r(n.datapoints,u,null,t+t/2,!0,n.xaxis,n.yaxis,f),s.strokeStyle="rgba(0,0,0,0.2)",r(n.datapoints,u,null,t/2,!0,n.xaxis,n.yaxis,f));s.lineWidth=i;s.strokeStyle=n.color;r(n.datapoints,u,ct(n.points,n.color),0,!1,n.xaxis,n.yaxis,f);s.restore()}function gt(n,t,i,r,u,f,e,o,s,h,c){var l,y,a,v,p,w,b,k,d;(h?(k=w=b=!0,p=!1,l=i,y=n,v=t+r,a=t+u,y<l&&(d=y,y=l,l=d,p=!0,w=!1)):(p=w=b=!0,k=!1,l=n+r,y=n+u,a=i,v=t,v<a&&(d=v,v=a,a=d,k=!0,b=!1)),y<e.min||l>e.max||v<o.min||a>o.max)||(l<e.min&&(l=e.min,p=!1),y>e.max&&(y=e.max,w=!1),a<o.min&&(a=o.min,k=!1),v>o.max&&(v=o.max,b=!1),l=e.p2c(l),a=o.p2c(a),y=e.p2c(y),v=o.p2c(v),f&&(s.fillStyle=f(a,v),s.fillRect(l,v,y-l,a-v)),c>0&&(p||w||b||k)&&(s.beginPath(),s.moveTo(l,a),p?s.lineTo(l,v):s.moveTo(l,v),b?s.lineTo(y,v):s.moveTo(y,v),w?s.lineTo(y,a):s.moveTo(y,a),k?s.lineTo(l,a):s.moveTo(l,a),s.stroke()))}function ar(n){function r(t,i,r,u,f,e){for(var h=t.points,c=t.pointsize,o=0;o<h.length;o+=c)h[o]!=null&&gt(h[o],h[o+1],h[o+2],i,r,u,f,e,s,n.bars.horizontal,n.bars.lineWidth)}var t,i;s.save();s.translate(h.left,h.top);s.lineWidth=n.bars.lineWidth;s.strokeStyle=n.color;switch(n.bars.align){case"left":t=0;break;case"right":t=-n.bars.barWidth;break;default:t=-n.bars.barWidth/2}i=n.bars.fill?function(t,i){return ct(n.bars,n.color,t,i)}:null;r(n.datapoints,t,t+n.bars.barWidth,i,n.xaxis,n.yaxis);s.restore()}function ct(t,i,r,u){var e=t.fill,f;return e?t.fillColor?si(t.fillColor,r,u,i):(f=n.color.parse(i),f.a=typeof e=="number"?e:.4,f.normalize(),f.toString()):null}function vr(){var g,r,w,b,v,t,k;if(o.legend.container!=null?n(o.legend.container).html(""):i.find(".legend").remove(),o.legend.show){var f=[],e=[],y=!1,d=o.legend.labelFormatter,s,p;for(r=0;r<l.length;++r)s=l[r],s.label&&(p=d?d(s.label,s):s.label,p&&e.push({label:p,color:s.color}));for(o.legend.sorted&&(n.isFunction(o.legend.sorted)?e.sort(o.legend.sorted):o.legend.sorted=="reverse"?e.reverse():(g=o.legend.sorted!="descending",e.sort(function(n,t){return n.label==t.label?0:n.label<t.label!=g?1:-1}))),r=0;r<e.length;++r)w=e[r],r%o.legend.noColumns==0&&(y&&f.push("<\/tr>"),f.push("<tr>"),y=!0),f.push('<td class="legendColorBox"><div style="border:1px solid '+o.legend.labelBoxBorderColor+';padding:1px"><div style="width:4px;height:0;border:5px solid '+w.color+';overflow:hidden"><\/div><\/div><\/td><td class="legendLabel">'+w.label+"<\/td>");if(y&&f.push("<\/tr>"),f.length!=0)if(b='<table style="font-size:smaller;color:'+o.grid.color+'">'+f.join("")+"<\/table>",o.legend.container!=null)n(o.legend.container).html(b);else{var c="",a=o.legend.position,u=o.legend.margin;u[0]==null&&(u=[u,u]);a.charAt(0)=="n"?c+="top:"+(u[1]+h.top)+"px;":a.charAt(0)=="s"&&(c+="bottom:"+(u[1]+h.bottom)+"px;");a.charAt(1)=="e"?c+="right:"+(u[0]+h.right)+"px;":a.charAt(1)=="w"&&(c+="left:"+(u[0]+h.left)+"px;");v=n('<div class="legend">'+b.replace('style="','style="position:absolute;'+c+";")+"<\/div>").appendTo(i);o.legend.backgroundOpacity!=0&&(t=o.legend.backgroundColor,t==null&&(t=o.grid.backgroundColor,t=t&&typeof t=="string"?n.color.parse(t):n.color.extract(v,"background-color"),t.a=1,t=t.toString()),k=v.children(),n('<div style="position:absolute;width:'+k.width()+"px;height:"+k.height()+"px;"+c+"background-color:"+t+';"> <\/div>').prependTo(v).css("opacity",o.legend.backgroundOpacity))}}}function ni(n,t,i){for(var w=o.grid.mouseActiveRadius,it=w*w+1,a=null,r,s,e,h,p,tt,u=l.length-1;u>=0;--u)if(i(l[u])){var f=l[u],b=f.xaxis,k=f.yaxis,c=f.datapoints.points,v=b.c2p(n),y=k.c2p(t),g=w/b.scale,nt=w/k.scale;if(s=f.datapoints.pointsize,b.options.inverseTransform&&(g=Number.MAX_VALUE),k.options.inverseTransform&&(nt=Number.MAX_VALUE),hi||f.lines.show||f.points.show)for(r=0;r<c.length;r+=s)if((e=c[r],h=c[r+1],e!=null)&&!(e-v>g)&&!(e-v<-g)&&!(h-y>nt)&&!(h-y<-nt)){var rt=Math.abs(b.p2c(e)-n),ut=Math.abs(k.p2c(h)-t),ft=rt*rt+ut*ut;ft<it&&(it=ft,a=[u,r/s])}if(f.bars.show&&!a){switch(f.bars.align){case"left":p=0;break;case"right":p=-f.bars.barWidth;break;default:p=-f.bars.barWidth/2}for(tt=p+f.bars.barWidth,r=0;r<c.length;r+=s){var e=c[r],h=c[r+1],d=c[r+2];e!=null&&(l[u].bars.horizontal?v<=Math.max(d,e)&&v>=Math.min(d,e)&&y>=h+p&&y<=h+tt:v>=e+p&&v<=e+tt&&y>=Math.min(d,h)&&y<=Math.max(d,h))&&(a=[u,r/s])}}}return a?(u=a[0],r=a[1],s=l[u].datapoints.pointsize,{datapoint:l[u].datapoints.points.slice(r*s,(r+1)*s),dataIndex:r,series:l[u],seriesIndex:u}):null}function ti(n){o.grid.hoverable&&lt("plothover",n,function(n){return n.hoverable!=!1})}function ii(n){o.grid.hoverable&&lt("plothover",n,function(){return!1})}function ri(n){lt("plotclick",n,function(n){return n.clickable!=!1})}function lt(n,t,r){var e=d.offset(),l=t.pageX-e.left-h.left,a=t.pageY-e.top-h.top,c=vt({left:l,top:a}),u,s,f;if(c.pageX=t.pageX,c.pageY=t.pageY,u=ni(l,a,r),u&&(u.pageX=parseInt(u.series.xaxis.p2c(u.datapoint[0])+e.left+h.left,10),u.pageY=parseInt(u.series.yaxis.p2c(u.datapoint[1])+e.top+h.top,10)),o.grid.autoHighlight){for(s=0;s<g.length;++s)f=g[s],f.auto!=n||u&&f.series==u.series&&f.point[0]==u.datapoint[0]&&f.point[1]==u.datapoint[1]||ei(f.series,f.point);u&&fi(u.series,u.datapoint,n)}i.trigger(n,[c,u])}function et(){var n=o.interaction.redrawOverlayInterval;if(n==-1){ui();return}rt||(rt=setTimeout(ui,n))}function ui(){rt=null;v.save();tt.clear();v.translate(h.left,h.top);for(var n,t=0;t<g.length;++t)n=g[t],n.series.bars.show?pr(n.series,n.point):yr(n.series,n.point);v.restore();nt(w.drawOverlay,[v])}function fi(n,t,i){var r,u;typeof n=="number"&&(n=l[n]);typeof t=="number"&&(r=n.datapoints.pointsize,t=n.datapoints.points.slice(r*t,r*(t+1)));u=oi(n,t);u==-1?(g.push({series:n,point:t,auto:i}),et()):i||(g[u].auto=!1)}function ei(n,t){var i,r;if(n==null&&t==null){g=[];et();return}typeof n=="number"&&(n=l[n]);typeof t=="number"&&(i=n.datapoints.pointsize,t=n.datapoints.points.slice(i*t,i*(t+1)));r=oi(n,t);r!=-1&&(g.splice(r,1),et())}function oi(n,t){for(var r,i=0;i<g.length;++i)if(r=g[i],r.series==n&&r.point[0]==t[0]&&r.point[1]==t[1])return i;return-1}function yr(t,i){var r=i[0],u=i[1],f=t.xaxis,e=t.yaxis,h=typeof t.highlightColor=="string"?t.highlightColor:n.color.parse(t.color).scale("a",.5).toString(),o,s;r<f.min||r>f.max||u<e.min||u>e.max||(o=t.points.radius+t.points.lineWidth/2,v.lineWidth=o,v.strokeStyle=h,s=1.5*o,r=f.p2c(r),u=e.p2c(u),v.beginPath(),t.points.symbol=="circle"?v.arc(r,u,s,0,2*Math.PI,!1):t.points.symbol(v,r,u,s,!1),v.closePath(),v.stroke())}function pr(t,i){var u=typeof t.highlightColor=="string"?t.highlightColor:n.color.parse(t.color).scale("a",.5).toString(),f=u,r;switch(t.bars.align){case"left":r=0;break;case"right":r=-t.bars.barWidth;break;default:r=-t.bars.barWidth/2}v.lineWidth=t.bars.lineWidth;v.strokeStyle=u;gt(i[0],i[1],i[2]||0,r,r+t.bars.barWidth,function(){return f},t.xaxis,t.yaxis,v,t.bars.horizontal,t.bars.lineWidth)}function si(t,i,r,u){var h,e,c,f,o;if(typeof t=="string")return t;for(h=s.createLinearGradient(0,r,0,i),e=0,c=t.colors.length;e<c;++e)f=t.colors[e],typeof f!="string"&&(o=n.color.parse(u),f.brightness!=null&&(o=o.scale("rgb",f.brightness)),f.opacity!=null&&(o.a*=f.opacity),f=o.toString()),h.addColorStop(e/(c-1),f);return h}var l=[],o={colors:["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"],legend:{show:!0,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:.85,sorted:null},xaxis:{show:null,position:"bottom",mode:null,font:null,color:null,tickColor:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,reserveSpace:null,tickLength:null,alignTicksWithAxis:null,tickDecimals:null,tickSize:null,minTickSize:null},yaxis:{autoscaleMargin:.02,position:"left"},xaxes:[],yaxes:[],series:{points:{show:!1,radius:3,lineWidth:2,fill:!0,fillColor:"#ffffff",symbol:"circle"},lines:{lineWidth:2,fill:!1,fillColor:null,steps:!1},bars:{show:!1,lineWidth:2,barWidth:1,fill:!0,fillColor:null,align:"left",horizontal:!1,zero:!0},shadowSize:3,highlightColor:null},grid:{show:!0,aboveData:!1,color:"#545454",backgroundColor:null,borderColor:null,tickColor:null,margin:0,labelMargin:5,axisMargin:8,borderWidth:2,minBorderMargin:null,markings:null,markingsColor:"#f4f4f4",markingsLineWidth:2,clickable:!1,hoverable:!1,autoHighlight:!0,mouseActiveRadius:10},interaction:{redrawOverlayInterval:1e3/60},hooks:{}},a=null,tt=null,ut=null,ft=null,ht=!1,hi=!0,d=null,s=null,v=null,y=[],b=[],h={left:0,right:0,top:0,bottom:0},k=0,p=0,w={processOptions:[],processRawData:[],processDatapoints:[],processOffset:[],drawBackground:[],drawSeries:[],draw:[],bindEvents:[],drawOverlay:[],shutdown:[]},c=this,g,rt;c.setData=at;c.setupGrid=wt;c.draw=bt;c.getPlaceholder=function(){return i};c.getOverlay=function(){return tt};c.getCanvas=function(){return a.element};c.getPlotOffset=function(){return h};c.width=function(){return k};c.height=function(){return p};c.offset=function(){var n=d.offset();return n.left+=h.left,n.top+=h.top,n};c.getData=function(){return l};c.getAxes=function(){var t={};return n.each(y.concat(b),function(n,i){i&&(t[i.direction+(i.n!=1?i.n:"")+"axis"]=i)}),t};c.getXAxes=function(){return y};c.getYAxes=function(){return b};c.c2p=vt;c.p2c=vi;c.getOptions=function(){return o};c.highlight=fi;c.unhighlight=ei;c.triggerRedrawOverlay=et;c.pointOffset=function(n){return{left:parseInt(y[ot(n,"x")-1].p2c(+n.x)+h.left,10),top:parseInt(b[ot(n,"y")-1].p2c(+n.y)+h.top,10)}};c.shutdown=yt;c.destroy=function(){yt();i.removeData("plot").empty();l=[];o=null;a=null;tt=null;d=null;s=null;v=null;y=[];b=[];w=null;g=[];c=null};c.resize=function(){var t=i.width(),r=i.height();a.resize(t,r);tt.resize(t,r);n(ft).width(t);n(ft).height(r);ut.setSize(t,r);ht=!0};c.getPaper=function(){return ut};c.getSurface=function(){return a};c.findNearbyItem=ni;c.hooks=w;ci(c);li(f);wi();at(r);wt();bt();di();g=[];rt=null}function u(n,t){return t*Math.floor(n/t)}var i=Object.prototype.hasOwnProperty;n.fn.detach||(n.fn.detach=function(){return this.each(function(){this.parentNode&&this.parentNode.removeChild(this)})});t.prototype.resize=function(n,t){if(n<=0||t<=0)throw new Error("Invalid dimensions for plot, width = "+n+", height = "+t);var i=this.element,u=this.context,r=this.pixelRatio;this.width!=n&&(i.width=n*r,i.style.width=n+"px",this.width=n);this.height!=t&&(i.height=t*r,i.style.height=t+"px",this.height=t);u.restore();u.save();u.scale(r,r)};t.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)};t.prototype.render=function(){var h=this._textCache,r,u,f,c,t,e,o,s,n;for(r in h)if(i.call(h,r)){u=this.getTextLayer(r);f=h[r];u.hide();for(c in f)if(i.call(f,c)){t=f[c];for(e in t)if(i.call(t,e)){for(o=t[e].positions,s=0;n=o[s];s++)n.active?n.rendered||(u.append(n.element),n.rendered=!0):(o.splice(s--,1),n.rendered&&n.element.remove());o.length==0&&delete t[e]}}u.show()}};t.prototype.getTextLayer=function(t){var i=this.text[t];return i==null&&(this.textContainer==null&&(this.textContainer=n("<div class='flot-text'><\/div>").css({position:"absolute",top:0,left:0,bottom:0,right:0,"font-size":"smaller",color:"#545454"}).insertAfter(this.element)),i=this.text[t]=n("<div><\/div>").addClass(t).css({position:"absolute",top:0,left:0,bottom:0,right:0}).appendTo(this.textContainer)),i};t.prototype.getTextInfo=function(t,i,r,u,f){var h,o,s,c,e;return i=""+i,h=typeof r=="object"?r.style+" "+r.variant+" "+r.weight+" "+r.size+"px/"+r.lineHeight+"px "+r.family:r,o=this._textCache[t],o==null&&(o=this._textCache[t]={}),s=o[h],s==null&&(s=o[h]={}),c=s[i],c==null&&(e=n("<div><\/div>").html(i).css({position:"absolute","max-width":f,top:-9999}).appendTo(this.getTextLayer(t)),typeof r=="object"?e.css({font:h,color:r.color}):typeof r=="string"&&e.addClass(r),c=s[i]={width:e.outerWidth(!0),height:e.outerHeight(!0),element:e,positions:[]},e.remove()),c};t.prototype.addText=function(n,t,i,r,u,f,e,o,s){var h=this.getTextInfo(n,r,u,f,e),l=h.positions,a,c;for(o=="center"?t-=h.width/2:o=="right"&&(t-=h.width),s=="middle"?i-=h.height/2:s=="bottom"&&(i-=h.height),a=0;c=l[a];a++)if(c.x==t&&c.y==i){c.active=!0;return}c={active:!0,rendered:!1,element:l.length?h.element.clone():h.element,x:t,y:i};l.push(c);c.element.css({top:Math.round(i),left:Math.round(t),"text-align":o})};t.prototype.removeText=function(n,t,r,u,f,e){var h,a,c,v,l,o,s;if(u==null){if(h=this._textCache[n],h!=null)for(a in h)if(i.call(h,a)){c=h[a];for(v in c)if(i.call(c,v))for(l=c[v].positions,o=0;s=l[o];o++)s.active=!1}}else for(l=this.getTextInfo(n,u,f,e).positions,o=0;s=l[o];o++)s.x==t&&s.y==r&&(s.active=!1)};n.plot=function(t,i,u){return new r(n(t),i,u,n.plot.plugins)};n.plot.version="0.8.3";n.plot.plugins=[];n.fn.plot=function(t,i){return this.each(function(){n.plot(this,t,i)})}}(jQuery),function(n){function t(n){n.drawVerticalGrid=function(t,i){n.svw_ticks=t;drawAxisLine=i};var t=function(n,t,i){i.waveformRenderer&&(n.getOptions().raphaelSupport.isResizingMode?i.waveformRenderer.drawSeriesLinesOnCanvas(n,t,i):i.waveformRenderer.drawSeriesLinesWithRaphael(n,i))};n.hooks.drawSeries.push(t)}n.plot.plugins.push({init:t,options:{raphaelSupport:{useRaphael:!1,rowId:null,show:!1,isResizingMode:!1}},name:"raphaelSupport",version:"0.1"})}(jQuery),function(n){function o(){return!!document.createElement("canvas").getContext}function s(){if(!o())return!1;var n=document.createElement("canvas"),t=n.getContext("2d");return typeof t.fillText=="function"}function e(){var n=document.createElement("div");return typeof n.style.MozTransition!="undefined"||typeof n.style.OTransition!="undefined"||typeof n.style.webkitTransition!="undefined"||typeof n.style.transition!="undefined"}function f(n,t,i,r,u){this.axisName=n;this.position=t;this.padding=i;this.plot=r;this.opts=u;this.width=0;this.height=0}function r(n,t,i,r,u){f.prototype.constructor.call(this,n,t,i,r,u)}function i(n,t,i,r,u){f.prototype.constructor.call(this,n,t,i,r,u)}function t(n,t,r,u,f){i.prototype.constructor.call(this,n,t,r,u,f)}function u(n,i,r,u,f){t.prototype.constructor.call(this,n,i,r,u,f);this.requiresResize=!1}function h(f){var h=!1,o={},c=2;f.hooks.draw.push(function(f){h?n.each(f.getAxes(),function(n,t){var i=t.options||f.getOptions()[n];i&&i.axisLabel&&o[n].draw(t.box)}):(n.each(f.getAxes(),function(n,h){var l=h.options||f.getOptions()[n],a,v,y,p,w;l&&l.axisLabel&&(a=null,h.readyToPlot=!1,l.axisLabelUseHtml||navigator.appName!="Microsoft Internet Explorer"?a=!l.axisLabelUseHtml&&(e()||s()||l.axisLabelUseCanvas)?l.axisLabelUseCanvas||!e()?r:t:i:(v=navigator.userAgent,y=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"),y.exec(v)!=null&&(rv=parseFloat(RegExp.$1)),a=rv>=9&&!l.axisLabelUseCanvas&&!l.axisLabelUseHtml?t:l.axisLabelUseCanvas||l.axisLabelUseHtml?l.axisLabelUseCanvas?r:i:u),p=l.axisLabelPadding===undefined?c:l.axisLabelPadding,o[n]=new a(n,h.position,p,f,l),o[n].calculateSize(),h.labelHeight+=o[n].height,w=h.direction=="x"?0:10,h.labelWidth+=o[n].width+w,l.labelHeight=h.labelHeight,l.labelWidth=h.labelWidth,h.readyToPlot=!0)}),h=!0,f.setupGrid(),f.draw())})}r.prototype=new f;r.prototype.constructor=r;r.prototype.calculateSize=function(){this.opts.axisLabelFontSizePixels||(this.opts.axisLabelFontSizePixels=14);this.opts.axisLabelFontFamily||(this.opts.axisLabelFontFamily="sans-serif");var n=this.opts.axisLabelFontSizePixels+this.padding,t=this.opts.axisLabelFontSizePixels+this.padding;this.position=="left"||this.position=="right"?(this.width=this.opts.axisLabelFontSizePixels+this.padding,this.height=0):(this.width=0,this.height=this.opts.axisLabelFontSizePixels+this.padding)};r.prototype.draw=function(n){var t=this.plot.getCanvas().getContext("2d");t.save();t.font=this.opts.axisLabelFontSizePixels+"px "+this.opts.axisLabelFontFamily;t.fillStyle=this.opts.axisLabelColour;var u=t.measureText(this.opts.axisLabel).width,f=this.opts.axisLabelFontSizePixels,i,r,e=0;this.position=="top"?(i=n.left+n.width/2-u/2,r=n.top+f*.72):this.position=="bottom"?(i=n.left+n.width/2-u/2,r=n.top+n.height-f*.72):this.position=="left"?(i=n.left+f*.72,r=n.height/2+n.top+u/2,e=-Math.PI/2):this.position=="right"&&(i=n.left+n.width-f*.72,r=n.height/2+n.top-u/2,e=Math.PI/2);t.translate(i,r);t.rotate(e);t.fillText(this.opts.axisLabel,0,0);t.restore()};i.prototype=new f;i.prototype.constructor=i;i.prototype.calculateSize=function(){var t=n('<div class="axisLabels" style="position:absolute;">'+this.opts.axisLabel+"<\/div>");this.plot.getPlaceholder().append(t);this.labelWidth=t.outerWidth(!0);this.labelHeight=t.outerHeight(!0);t.remove();this.width=this.height=0;this.position=="left"||this.position=="right"?this.width=this.labelWidth+this.padding:this.height=this.labelHeight+this.padding};i.prototype.draw=function(t){this.plot.getPlaceholder().find("#"+this.axisName+"Label").remove();var i=n('<div id="'+this.axisName+'Label" " class="axisLabels" style="position:absolute;">'+this.opts.axisLabel+"<\/div>");this.plot.getPlaceholder().append(i);this.position=="top"?(i.css("left",t.left+t.width/2-this.labelWidth/2+"px"),i.css("top",t.top+"px")):this.position=="bottom"?(i.css("left",t.left+t.width/2-this.labelWidth/2+"px"),i.css("top",t.top+t.height-this.labelHeight+"px")):this.position=="left"?(i.css("top",t.top+t.height/2-this.labelHeight/2+"px"),i.css("left",t.left+"px")):this.position=="right"&&(i.css("top",t.top+t.height/2-this.labelHeight/2+"px"),i.css("left",t.left+t.width-this.labelWidth+"px"))};t.prototype=new i;t.prototype.constructor=t;t.prototype.calculateSize=function(){i.prototype.calculateSize.call(this);this.width=this.height=0;this.position=="left"||this.position=="right"?this.width=this.labelHeight+this.padding:this.height=this.labelHeight+this.padding};t.prototype.transforms=function(n,t,i){var r={"-moz-transform":"","-webkit-transform":"","-o-transform":"","-ms-transform":""},u,s,f,o,e;(t!=0||i!=0)&&(u=" translate("+t+"px, "+i+"px)",r["-moz-transform"]+=u,r["-webkit-transform"]+=u,r["-o-transform"]+=u,r["-ms-transform"]+=u);n!=0&&(s=n/90,f=" rotate("+n+"deg)",r["-moz-transform"]+=f,r["-webkit-transform"]+=f,r["-o-transform"]+=f,r["-ms-transform"]+=f);o="top: 0; left: 0; ";for(e in r)r[e]&&(o+=e+":"+r[e]+";");return o+";"};t.prototype.calculateOffsets=function(n){var t={x:0,y:0,degrees:0};return this.position=="bottom"?(t.x=n.left+n.width/2-this.labelWidth/2,t.y=n.top+n.height-this.labelHeight):this.position=="top"?(t.x=n.left+n.width/2-this.labelWidth/2,t.y=n.top):this.position=="left"?(t.degrees=-90,t.x=n.left-this.labelWidth/2+this.labelHeight/2,t.y=n.height/2+n.top):this.position=="right"&&(t.degrees=90,t.x=n.left+n.width-this.labelWidth/2-this.labelHeight/2,t.y=n.height/2+n.top),t};t.prototype.draw=function(t){this.plot.getPlaceholder().find("."+this.axisName+"Label").remove();var i=this.calculateOffsets(t),r=n('<div class="axisLabels '+this.axisName+'Label" style="position:absolute; '+this.transforms(i.degrees,i.x,i.y)+'">'+this.opts.axisLabel+"<\/div>");this.plot.getPlaceholder().append(r)};u.prototype=new t;u.prototype.constructor=u;u.prototype.transforms=function(n,t,i){var r="",u;if(n!=0){for(u=n/90;u<0;)u+=4;r+=" filter: progid:DXImageTransform.Microsoft.BasicImage(rotation="+u+"); ";this.requiresResize=this.position=="right"}return t!=0&&(r+="left: "+t+"px; "),i!=0&&(r+="top: "+i+"px; "),r};u.prototype.calculateOffsets=function(n){var i=t.prototype.calculateOffsets.call(this,n);return this.position=="top"?i.y=n.top+1:this.position=="left"?(i.x=n.left,i.y=n.height/2+n.top-this.labelWidth/2):this.position=="right"&&(i.x=n.left+n.width-this.labelHeight,i.y=n.height/2+n.top-this.labelWidth/2),i};u.prototype.draw=function(n){if(t.prototype.draw.call(this,n),this.requiresResize){var i=this.plot.getPlaceholder().find("."+this.axisName+"Label");i.css("width",this.labelWidth);i.css("height",this.labelHeight)}};n.plot.plugins.push({init:h,options:{},name:"axisLabels",version:"2.0b0"})}(jQuery),function(n){function t(t){function s(n){i.active&&(v(n),t.getPlaceholder().trigger("plotselecting",[e()]))}function h(t){if(t.which==1&&!b(t)){document.body.focus();document.onselectstart!==undefined&&r.onselectstart==null&&(r.onselectstart=document.onselectstart,document.onselectstart=function(){return!1});document.ondrag!==undefined&&r.ondrag==null&&(r.ondrag=document.ondrag,document.ondrag=function(){return!1});a(i.first,t);i.active=!0;u=function(n){p(n)};n(document).one("mouseup",u)}}function p(n){return u=null,document.onselectstart!==undefined&&(document.onselectstart=r.onselectstart),document.ondrag!==undefined&&(document.ondrag=r.ondrag),i.active=!1,v(n),f()?c():(t.getPlaceholder().trigger("plotunselected",[]),t.getPlaceholder().trigger("plotselecting",[null])),!1}function e(){if(!f()||!i.show)return null;var r={},u=i.first,e=i.second;return n.each(t.getAxes(),function(n,t){if(t.used){var i=t.c2p(u[t.direction]),f=t.c2p(e[t.direction]);r[n]={from:Math.min(i,f),to:Math.max(i,f)}}}),r}function c(){var n=e();t.getPlaceholder().trigger("plotselected",[n]);n.xaxis&&n.yaxis&&t.getPlaceholder().trigger("selected",[{x1:n.xaxis.from,y1:n.yaxis.from,x2:n.xaxis.to,y2:n.yaxis.to}])}function l(n,t,i){return t<n?n:t>i?i:t}function a(n,r){var u=t.getOptions(),f=t.getPlaceholder().offset(),e=t.getPlotOffset();n.x=l(0,r.pageX-f.left-e.left,t.width());n.y=l(0,r.pageY-f.top-e.top,t.height());u.selection.mode=="y"&&(n.x=n==i.first?0:t.width());u.selection.mode=="x"&&(n.y=n==i.first?0:t.height())}function v(n){n.pageX!=null&&(a(i.second,n),f()?(i.show=!0,t.triggerRedrawOverlay()):y(!0))}function y(n){i.show&&(i.show=!1,t.triggerRedrawOverlay(),n||t.getPlaceholder().trigger("plotunselected",[]))}function o(n,i){var e,r,u,f,o=t.getAxes(),s,h;for(s in o)if(e=o[s],e.direction==i&&(f=i+e.n+"axis",n[f]||e.n!=1||(f=i+"axis"),n[f])){r=n[f].from;u=n[f].to;break}return n[f]||(e=i=="x"?t.getXAxes()[0]:t.getYAxes()[0],r=n[i+"1"],u=n[i+"2"]),r!=null&&u!=null&&r>u&&(h=r,r=u,u=h),{from:r,to:u,axis:e}}function w(n,r){var u,e=t.getOptions();e.selection.mode=="y"?(i.first.x=0,i.second.x=t.width()):(u=o(n,"x"),i.first.x=u.axis.p2c(u.from),i.second.x=u.axis.p2c(u.to));e.selection.mode=="x"?(i.first.y=0,i.second.y=t.height()):(u=o(n,"y"),i.first.y=u.axis.p2c(u.from),i.second.y=u.axis.p2c(u.to));i.show=!0;t.triggerRedrawOverlay();!r&&f()&&c()}function f(){var n=t.getOptions().selection.minSize;return Math.abs(i.second.x-i.first.x)>=n&&Math.abs(i.second.y-i.first.y)>=n}function b(n){return n.target.nodeName!="svg"?!0:!1}var i={first:{x:-1,y:-1},second:{x:-1,y:-1},show:!1,active:!1},r={},u=null;t.clearSelection=y;t.setSelection=w;t.getSelection=e;t.extractRange=o;t.hooks.bindEvents.push(function(n,t){var i=n.getOptions();i.selection.mode!=null&&(t.mousemove(s),t.mousedown(h))});t.hooks.drawOverlay.push(function(t,r){var u,e,o;if(i.show&&f()){u=t.getPlotOffset();e=t.getOptions();r.save();r.translate(u.left,u.top);o=n.color.parse(e.selection.color);r.strokeStyle=o.scale("a",.8).toString();r.lineWidth=1;r.lineJoin=e.selection.shape;r.fillStyle=o.scale("a",.4).toString();var s=Math.min(i.first.x,i.second.x)+.5,h=Math.min(i.first.y,i.second.y)+.5,c=Math.abs(i.second.x-i.first.x)-1,l=Math.abs(i.second.y-i.first.y)-1;r.fillRect(s,h,c,l);r.strokeRect(s,h,c,l);r.restore()}});t.hooks.shutdown.push(function(t,i){i.unbind("mousemove",s);i.unbind("mousedown",h);u&&n(document).unbind("mouseup",u)})}n.plot.plugins.push({init:t,options:{selection:{mode:null,color:"#e8cfac",shape:"round",minSize:5}},name:"selection",version:"1.1"})}(jQuery),function(n){function t(t){function i(n,t){var r=0,i,e;if(t=="undefined"||t==null||t<0)return 0;var u=n.getOptions(),o=u.grid.axisMargin+u.grid.borderWidth,f=n.getYAxes();for(i=0;i<f.length;i++)if(e=f[i],i<t)r+=e.box.width+o;else return r;return r}function r(n){if(n){var t=n.direction;return n.n==1?t+"axis":t+n.n+"axis"}return null}function u(n,t){var i={x:0,y:0,w:0,h:0},e,u,f;if(t){var l=n.xaxis.from,a=n.xaxis.to,o=t.p2c(l),s=t.p2c(a),h=0,c=0;t.direction=="y"?(e=r(t),h=n[e].from,c=n[e].to,u=t.p2c(h),f=t.p2c(c)):(u=0,f=20);i.x=Math.min(o,s);i.y=Math.min(u,f);i.w=Math.abs(s-o);i.h=Math.abs(f-u)}return i}function f(n){for(var r,o=t.getAxes().xaxis,u=t.getYAxes(),f=0,i=0;i<u.length;i++){if(r=u[i],e(n,t,r,f))return i;r.box&&(f+=r.box.width)}return-1}function e(n,t,i,r){var u=t.getAxes().xaxis,f=t.offset(),e=n.pageX-f.left,o=n.pageY-f.top,s=u.p2c(u.min),c=i.p2c(i.min),l=i.p2c(i.max),h=i.box;return h?e<s-h.width-r||e>s?!1:o<l||o>c?!1:!0:!1}function o(t,r){var v=t.getSelection(),s,l,g,e,h,d,o;if(v){var c=t.getSelectedAxis(),y=t.getPlotOffset(),f=t.getOptions(),p=0,w=!0;if(f.yaxes[0].ticks!=null&&f.yaxes[0].ticks!="undefined"&&f.yaxes[0].ticks==!1&&(w=!1),p=f.selection.mode!="x"?i(t,t.getYAxes().length-1):f.selection.mode!="y"?i(t,c):i(t,c),s=f.selection.mode!="x"?10:0,r.save(),r.translate(y.left-s-p,y.top),l=n.color.parse(f.selection.color),r.strokeStyle=l.scale("a",.8).toString(),r.lineWidth=1,r.lineJoin="round",g=r.fillStyle,r.fillStyle=l.scale("a",.4).toString(),f.selection.mode!="x"){var b=t.getYAxes(),a=f.grid.borderWidth,nt=f.grid.axisMargin,k=!0;if(w)for(e=b.length-1;e>=0;e--)h=b[e],k||(a+=h.box.width+nt),k=!1,d=f.selection.mode=="xy"?!0:e==c,h&&d&&(o=u(v,h,f.selection.mode),r.fillRect(a,o.y,s,o.h),r.strokeRect(a,o.y,s,o.h))}r.restore()}}t.setSelectionMode=function(n){this.getOptions().selection.mode=n};t.getSelectedAxis=function(){return t.selectedYAxis};t.hooks.bindEvents.push(function(n,t){var r=this,i=n.getOptions();i.selection.mode!=null&&t.mousedown(function(t){(n.selectedYAxis=-1,t.which==1)&&t.target.nodeName=="svg"&&(n.selectedYAxis=f(t))})});t.hooks.drawOverlay.push(o)}n.plot.plugins.push({init:t,options:{},name:"svw_selection",version:"1.0"})}(jQuery),function(n){var t=function(){function t(n){this.ps=2;this.wf=n}return t.prototype.setPlottedInfo=function(t,i,r,u,f,e){var s,h,o;i&&i!=null&&(u&&(s=this.paper.path(i),s.transform(this.trans+" T 1,1"),s.attr({stroke:n.SVW_Colors.DROP_SHADOW_COLOR}),s.attr({"stroke-width":n.WaveManager.DROP_SHADOW_WIDTH})),h=this.paper.path(i),o=this.paper.path(i),h.transform(this.trans),h.attr({stroke:r}),h.attr({"stroke-width":n.WaveManager.WAVEFORM_WIDTH}),o.transform(this.trans),o.attr({"stroke-width":n.WaveManager.WAVEFORM_OUTLINED_WIDTH}),o.attr({stroke:r}),o.attr({"stroke-opacity":0}),t&&(this.wf.element&&this.wf.element.remove(),this.wf.elementOutline&&this.wf.elementOutline.remove(),this.wf.dropshadow&&this.wf.dropshadow.remove(),this.wf.pathArray&&this.wf.pathArray.remove(),this.wf.textValue&&this.wf.textValue.remove(),o.node.id=t,this.wf.element=h,this.wf.elementOutline=o,u&&(this.wf.dropshadow=s),f&&(this.wf.pathArray=f),e&&(this.wf.textValue=e),this.wf.setPlotted()))},t.prototype.updateWaveformColorIndex=function(n){this.wf.setColorIndex(n);this.wf.updateWaveformLegendColor()},t.prototype.needToPlot=function(n){if(!this.wf||!this.wf.getWaveContainer().readyToAdjust)return!1;var t=n.getAxes().yaxis;return t&&(!t.show||t.readyToPlot)?!0:!1},t}();n.WaveformRenderer=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n){t.call(this,n)}return __extends(i,t),i.prototype.init=function(t,i){var r;if(!this.needToPlot(t)||(this.plot=t,r=this.wf,r.datapoints=i.datapoints,r.xaxis=i.xaxis,r.yaxis=i.yaxis,this.paper=this.plot.getPaper(),this.plotOffset=this.plot.getPlotOffset(),this.trans=n.WaveUtils.getTransformString(this.plotOffset.left,this.plotOffset.top),!t.getOptions().raphaelSupport)||!t.getOptions().raphaelSupport.show||!t.getPaper()||!r)return!1;var u=r.xaxis,f=r.yaxis,e=r.getColor(),o=r.getFlotWaveformId();return(this.points=r.datapoints.points,this.ps=r.datapoints.pointsize,this.points.length==0)?!1:!0},i.prototype.drawSeriesLinesWithRaphael=function(n,t){var s,u;if(this.init(n,t)){var e=null,o=null,l=this.ps,c=this.points,p=this.wf.xaxis,w=this.wf.yaxis,r,i,a="";for(s=l;s<c.length;s+=l){var h=c[s-l],f=c[s-l+1],v=c[s],y=c[s+1];if(this.wf.isStep()?(r=v,i=f):(r=v,i=y),u=this.checkSegment(h,f,r,i),u!=null)h=u.x1,f=u.y1,r=u.x2,i=u.y2,a+=this.drawSegment(h,f,r,i,e,o),e=r,o=i;else{e=r;o=i;continue}if(this.wf.isStep()){if(h=r,f=i,r=v,i=y,u=this.checkSegment(h,f,r,i),u==null){e=r;o=i;continue}h=u.x1;f=u.y1;r=u.x2;i=u.y2;a+=this.drawSegment(h,f,r,i,e,o);e=r;o=i}}this.wf.isStep()&&(a+=this.drawSegment(r,i,p.max,i,e,o));this.setPlottedInfo(this.wf.getFlotWaveformId(),a,this.wf.getColor(),!1)}},i.prototype.checkSegment=function(n,t,i,r){var u=this.wf.xaxis,f=this.wf.yaxis;if(n==null||i==null)return null;if(t<=r&&t<f.min){if(r<f.min)return null;n=(f.min-t)/(r-t)*(i-n)+n;t=f.min}else if(r<=t&&r<f.min){if(t<f.min)return null;i=(f.min-t)/(r-t)*(i-n)+n;r=f.min}if(t>=r&&t>f.max){if(r>f.max)return null;n=(f.max-t)/(r-t)*(i-n)+n;t=f.max}else if(r>=t&&r>f.max){if(t>f.max)return null;i=(f.max-t)/(r-t)*(i-n)+n;r=f.max}if(n<=i&&n<u.min){if(i<u.min)return null;t=(u.min-n)/(i-n)*(r-t)+t;n=u.min}else if(i<=n&&i<u.min){if(n<u.min)return null;r=(u.min-n)/(i-n)*(r-t)+t;i=u.min}if(n>=i&&n>u.max){if(i>u.max)return null;t=(u.max-n)/(i-n)*(r-t)+t;n=u.max}else if(i>=n&&i>u.max){if(n>u.max)return null;r=(u.max-n)/(i-n)*(r-t)+t;i=u.max}return{x1:n,x2:i,y1:t,y2:r}},i.prototype.drawSegment=function(n,t,i,r,u,f){var e=this.wf.xaxis,o=this.wf.yaxis,s="";return(n!=u||t!=f)&&(s+="M "+e.p2c(n)+" "+o.p2c(t)+" "),s+("L "+e.p2c(i)+" "+o.p2c(r)+" ")},i.prototype.drawSeriesLinesOnCanvas=function(n,t,i){var l,f;if(this.init(n,i)){var w=this.ps,p=this.points,s=this.wf.xaxis,a=this.wf.yaxis,v=this.plotOffset.left,y=this.plotOffset.top,h=null,c=null,u=null,r=null;for(t.strokeStyle=this.wf.getColor(),t.beginPath(),l=w;l<p.length;l+=w){var o=p[l-w],e=p[l-w+1],b=p[l],k=p[l+1];if(this.wf.isStep()?(u=b,r=e):(u=b,r=k),f=this.checkSegment(o,e,u,r),f!=null)o=f.x1,e=f.y1,u=f.x2,r=f.y2,(o!=h||e!=c)&&t.moveTo(s.p2c(o)+v,a.p2c(e)+y),t.lineTo(s.p2c(u)+v,a.p2c(r)+y),h=u,c=r;else{h=u;c=r;continue}if(this.wf.isStep()){if(o=u,e=r,u=b,r=k,f=this.checkSegment(o,e,u,r),f==null){h=u;c=r;continue}o=f.x1;e=f.y1;u=f.x2;r=f.y2;(o!=h||e!=c)&&t.moveTo(s.p2c(o)+v,a.p2c(e)+y);t.lineTo(s.p2c(u)+v,a.p2c(r)+y);h=u;c=r}}this.wf.isStep()&&((u!=h||r!=c)&&t.moveTo(s.p2c(s.max)+v,a.p2c(r)+y),t.lineTo(s.p2c(s.max)+v,a.p2c(r)+y));t.stroke();this.wf.setPlotted()}},i}(n.WaveformRenderer);n.AnalogRenderer=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n){t.call(this,n);this.currentMap=[]}return __extends(i,t),i.prototype.fillStdLogicMap=function(t){i.stdLogicMap[n.DigitalWaveform.SLOGIC_U]={drawStyle:i.DRAW_STYLE_UNKNOWN,lineStyle:i.LINE_STYLE_SOLID,color:t};i.stdLogicMap[n.DigitalWaveform.SLOGIC_X]={drawStyle:i.DRAW_STYLE_UNKNOWN,lineStyle:i.LINE_STYLE_SOLID,color:t};i.stdLogicMap[n.DigitalWaveform.SLOGIC_0]={drawStyle:i.DRAW_STYLE_LOW,lineStyle:i.LINE_STYLE_SOLID,color:t};i.stdLogicMap[n.DigitalWaveform.SLOGIC_1]={drawStyle:i.DRAW_STYLE_HIGH,lineStyle:i.LINE_STYLE_SOLID,color:t};i.stdLogicMap[n.DigitalWaveform.SLOGIC_Z]={drawStyle:i.DRAW_STYLE_UNKNOWN,lineStyle:i.LINE_STYLE_SHORT_DASH,color:i.DigitalZColor};i.stdLogicMap[n.DigitalWaveform.SLOGIC_W]={drawStyle:i.DRAW_STYLE_UNKNOWN,lineStyle:i.LINE_STYLE_MEDIUM_DASH,color:i.DigitalWColor};i.stdLogicMap[n.DigitalWaveform.SLOGIC_L]={drawStyle:i.DRAW_STYLE_LOW,lineStyle:i.LINE_STYLE_MEDIUM_DASH,color:t};i.stdLogicMap[n.DigitalWaveform.SLOGIC_H]={drawStyle:i.DRAW_STYLE_HIGH,lineStyle:i.LINE_STYLE_MEDIUM_DASH,color:t};i.stdLogicMap[n.DigitalWaveform.SLOGIC_M]={drawStyle:i.DRAW_STYLE_UNKNOWN,lineStyle:i.LINE_STYLE_SOLID,color:t}},i.prototype.fillBooleanMap=function(t){i.booleanMap[n.BooleanWaveform.BOOL_FALSE]={drawStyle:i.DRAW_STYLE_LOW,lineStyle:i.LINE_STYLE_SOLID,color:t};i.booleanMap[n.BooleanWaveform.BOOL_TRUE]={drawStyle:i.DRAW_STYLE_HIGH,lineStyle:i.LINE_STYLE_SOLID,color:t}},i.prototype.fillBitMap=function(t){i.bitMap[n.BitWaveform.BIT_0]={drawStyle:i.DRAW_STYLE_LOW,lineStyle:i.LINE_STYLE_SOLID,color:t};i.bitMap[n.BitWaveform.BIT_1]={drawStyle:i.DRAW_STYLE_HIGH,lineStyle:i.LINE_STYLE_SOLID,color:t}},i.prototype.updateColorMap=function(){this.waveformColor=this.wf.getColor();var t=this.wf.getWaveformType();switch(t){case n.WaveManager.STD_LOGIC_WF:this.fillStdLogicMap(this.waveformColor);this.currentMap=i.stdLogicMap;break;case n.WaveManager.BOOLEAN_WF:this.fillBooleanMap(this.waveformColor);this.currentMap=i.booleanMap;break;case n.WaveManager.BIT_WF:this.fillBitMap(this.waveformColor);this.currentMap=i.bitMap;break;case n.WaveManager.BUS_WF:this.fillStdLogicMap(this.waveformColor);this.currentMap=i.stdLogicMap;break;case n.WaveManager.BUS:this.fillStdLogicMap(this.waveformColor);this.currentMap=i.stdLogicMap;break;default:this.fillStdLogicMap(this.waveformColor);this.currentMap=i.stdLogicMap}},i.getValueForStyle=function(t){switch(t){case i.DRAW_STYLE_LOW:return n.DigitalWaveform.LO;case i.DRAW_STYLE_HIGH:return n.DigitalWaveform.HI;case i.DRAW_STYLE_UNKNOWN:case i.DRAW_STYLE_RAILROAD:return n.DigitalWaveform.MID}return n.DigitalWaveform.MID},i.prototype.setStyleAttributes=function(n,t){n.attr({stroke:this.currentMap[t].color});switch(this.currentMap[t].lineStyle){case i.LINE_STYLE_SHORT_DASH:n.attr({"stroke-dasharray":"-"});return;case i.LINE_STYLE_MEDIUM_DASH:n.attr({"stroke-dasharray":"--"});return;case i.LINE_STYLE_DOT_DASH:n.attr({"stroke-dasharray":"-."});return;case i.LINE_STYLE_DOTTED:n.attr({"stroke-dasharray":". "});return}},i.prototype.init=function(t,i){if(!this.needToPlot(t))return!1;this.plot=t;var r=this.wf;return(r.datapoints=i.datapoints,r.xaxis=i.xaxis,r.yaxis=i.yaxis,this.paper=this.plot.getPaper(),this.plotOffset=this.plot.getPlotOffset(),this.trans=n.WaveUtils.getTransformString(this.plotOffset.left,this.plotOffset.top),!t.getOptions().raphaelSupport)?!1:t.getOptions().raphaelSupport.show?t.getPaper()?r?(this.updateColorMap(),this.points=r.datapoints.points,this.ps=r.datapoints.pointsize,this.points.length==0)?!1:!0:!1:!1:!1},i.prototype.drawSeriesLinesWithRaphael=function(t,r){var f,o,v,g,it,rt,p,s,h,nt;if(this.init(t,r)){var c=this.points,w=this.ps,l=this.wf.xaxis,b=this.wf.yaxis,a="",k,d,tt=!0,ut=this.paper.set();for(f=w;f<c.length-1;f+=this.ps){o=c[f-w];v=c[f-w+1];g=c[f];it=c[f+1];var u=g,y=v,e=this.checkSegment(o,u);e!=null&&(o=e.x1,u=e.x2,rt=i.getValueForStyle(this.currentMap[v].drawStyle),p=i.getValueForStyle(this.currentMap[y].drawStyle),tt&&(tt=!1,a+="M "+l.p2c(o)+" "+b.p2c(rt)+" "),s=l.p2c(u),h=b.p2c(p),a+="L "+s+" "+h+" ",k=s,d=h);o=u;v=y;u=g;e=this.checkSegment(o,u);e!=null&&(e.previous||(y=it),u=e.x2,p=i.getValueForStyle(this.currentMap[y].drawStyle),s=l.p2c(u),h=b.p2c(p),a+="L "+s+" "+h+" ",k=s,d=h)}nt=l.p2c(l.max);n.WaveUtils.almostEqual(nt,k)||(a+="L "+nt+" "+d+" ");this.setPlottedInfo(this.wf.getFlotWaveformId(),a,this.wf.getColor(),!1)}},i.prototype.checkSegment=function(n,t){var i=this.wf.xaxis,r=!1;if(n==null||t==null)return null;if(n<=t&&n<i.min){if(t<i.min)return null;n=i.min}else if(t<=n&&t<i.min){if(n<i.min)return null;t=i.min}if(n>=t&&n>i.max){if(t>i.max)return null;n=i.max;r=!0}else if(t>=n&&t>i.max){if(n>i.max)return null;t=i.max;r=!0}return{x1:n,x2:t,previous:r}},i.prototype.drawSegment=function(n,t,i,r,u,f,e){var o=n;return o=o+f.p2c(t),o=o+" ",o=o+e.p2c(i),o=o+" ",o=o+"L ",o=o+f.p2c(r),o=o+" ",o=o+e.p2c(u),o+" "},i.prototype.drawSeriesLinesOnCanvas=function(t,r,u){var o,h,w,g,it,rt,c,nt;if(this.init(t,u)){var l=this.points,v=this.ps,e=this.wf.xaxis,a=this.wf.yaxis,k=null,d=null,tt=!0,y=this.plotOffset.left,p=this.plotOffset.top;for(r.strokeStyle=this.wf.getColor(),r.beginPath(),o=v;o<l.length-1;o+=v){h=l[o-v];w=l[o-v+1];g=l[o];it=l[o+1];var f=g,b=w,s=this.checkSegment(h,f);s!=null&&(h=s.x1,f=s.x2,rt=i.getValueForStyle(this.currentMap[w].drawStyle),c=i.getValueForStyle(this.currentMap[b].drawStyle),tt&&(tt=!1,r.moveTo(e.p2c(h)+y,a.p2c(rt)+p)),r.lineTo(e.p2c(f)+y,a.p2c(c)+p),k=e.p2c(f),d=a.p2c(c));h=f;w=b;f=g;s=this.checkSegment(h,f);s!=null&&(s.previous||(b=it),f=s.x2,c=i.getValueForStyle(this.currentMap[b].drawStyle),r.lineTo(e.p2c(f)+y,a.p2c(c)+p),k=e.p2c(f),d=a.p2c(c))}nt=e.p2c(e.max);n.WaveUtils.almostEqual(nt,k)||r.lineTo(nt+y,d+p);r.stroke();this.wf.setPlotted()}},i.DigitalZColor="green",i.DigitalWColor="blue",i.stdLogicMap=[],i.booleanMap=[],i.bitMap=[],i.DRAW_STYLE_HIGH=0,i.DRAW_STYLE_LOW=1,i.DRAW_STYLE_UNKNOWN=2,i.DRAW_STYLE_RAILROAD=3,i.LINE_STYLE_SOLID=0,i.LINE_STYLE_SHORT_DASH=1,i.LINE_STYLE_MEDIUM_DASH=2,i.LINE_STYLE_DOT_DASH=3,i.LINE_STYLE_DOTTED=4,i}(n.WaveformRenderer);n.DigitalRenderer=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n){t.call(this,n);this.minimalLabelWidth=10;this.fontSize=10;this.shift=10;this.yText=0}return __extends(i,t),i.prototype.initBus=function(t,i){if(!this.needToPlot(t))return!1;Project.Utility.startTrace("bus rendering starts");this.plot=t;var r=this.wf;return(r.datapoints=i.datapoints,r.xaxis=i.xaxis,r.yaxis=i.yaxis,this.paper=this.plot.getPaper(),this.plotOffset=this.plot.getPlotOffset(),this.trans=n.WaveUtils.getTransformString(this.plotOffset.left,this.plotOffset.top),!t.getOptions().raphaelSupport)?!1:t.getOptions().raphaelSupport.show?t.getPaper()?r?(this.updateColorMap(),this.points=r.datapoints.points,this.ps=r.datapoints.pointsize,this.points.length==0)?!1:(this.minimalLabelWidth=n.WaveUtils.getTextParameters("...",this.paper,this.fontSize).width+this.shift,this.yText=this.wf.yaxis.p2c(n.DigitalWaveform.MID)+this.fontSize/2,!0):!1:!1:!1},i.prototype.drawSeriesLinesWithRaphael=function(n,t){var o,s,h;if(this.initBus(n,t)){var r=this.ps,u=this.points,f=this.wf.xaxis,e=this.wf.yaxis,i=this.paper.set();Project.Utility.trace("Start first line",!0);o=this.drawLine(r,u,f,e,!0,this.wf,i);Project.Utility.trace("Start second line",!0);s=this.drawLine(r,u,f,e,!1,this.wf,i);h=o+" "+s;this.setPlottedInfo(this.wf.getFlotWaveformId(),h,"transparent",!1,i);Project.Utility.trace("Bus rendering ends",!0)}},i.prototype.drawLine=function(t,i,r,u,f,e,o){for(var y,s,p,h="",c=t,v=0;c<i.length;c+=t,v++){var l=i[c-t],a=i[c],w=this.checkSegment(l,a);w!=null&&(f?(y=e.yValues[v],h+=this.drawBusSegment(l,a,r,u,n.DigitalWaveform.HI,y)):h+=this.drawBusSegment(l,a,r,u,n.DigitalWaveform.LO))}return s=this.paper.path(h),s.transform(this.trans),s.attr({stroke:this.waveformColor}),p=n.SVW_Colors.getDigitalFillColor(this.wf.getWaveContainer()),s.attr("fill",p),o.push(s),h},i.prototype.drawBusSegment=function(t,i,r,u,f,e){var o="M ",g=4,nt,c,l,tt,d,it,a;if((t>i&&(nt=t,t=i,i=nt),t<r.min&&i<r.min)||t>r.max&&i>r.max)return"";var p=r.p2c(r.min),w=r.p2c(r.max),s=r.p2c(t),h=r.p2c(i),v=s+g,y=h-g,b=!0,k=!0;return t<r.min&&(s=p,b=!1),i>r.max&&(h=w,k=!1),v>w&&(v=w),y<p&&(y=p),c=u.p2c(n.DigitalWaveform.MID),l=u.p2c(f),b&&k&&v>=y?(tt=(s+h)/2,o+=s+" "+c+" ",o+="L "+tt+" "+l+" ",o+="L "+h+" "+c+" "):(o+=o+s+" ",b&&(o+=c+" ",o+="L "+v+" "),o+=l+" ",k?(o+="L "+y+" "+l+" ",o+="L "+h+" "+c+" "):o+="L "+h+" "+l+" "),d=Math.abs(h-s),e!=null&&d>this.minimalLabelWidth&&(it=n.SVW_Colors.getCursorTextColor(this.wf.getWaveContainer()),a=this.paper.text(s+this.shift,this.yText,e).attr({"text-anchor":"start"}),a.attr({"stroke-width":1,"font-size":this.fontSize}),a.attr({fill:it}),n.WaveUtils.truncateText(d,e,a)&&$(a.node).qtip({content:{text:e},style:{classes:"svw-tooltip"}})),o},i.prototype.drawSeriesLinesOnCanvas=function(t,i,r){var s;if(this.initBus(t,r)){var f=this.ps,e=this.points,o=this.wf.xaxis,u=this.wf.yaxis;i.strokeStyle=this.wf.getColor();this.minimalLabelWidth=n.WaveUtils.getTextParameters("...",this.paper,this.fontSize).width+this.shift;this.yText=u.p2c(n.DigitalWaveform.MID)+this.fontSize/2;s=this.paper.set();Project.Utility.trace("Start first line",!0);this.drawSimpleLine(i,f,e,o,u,!0);Project.Utility.trace("Start second line",!0);this.drawSimpleLine(i,f,e,o,u,!1);this.wf.setPlotted();Project.Utility.trace("Bus rendering ends",!0)}},i.prototype.drawSimpleLine=function(t,i,r,u,f,e){var o,s,l;for(t.beginPath(),o=i,s=0;o<r.length;o+=i,s++){var h=r[o-i],c=r[o],a=this.checkSegment(h,c);a!=null&&(e?(l=this.wf.yValues[s],this.drawBusSegmentSimple(t,h,c,u,f,n.DigitalWaveform.HI,l)):this.drawBusSegmentSimple(t,h,c,u,f,n.DigitalWaveform.LO))}t.stroke()},i.prototype.drawBusSegmentSimple=function(t,i,r,u,f,e,o){var tt=4,it,v,a,ut,nt,ft,w;if((i>r&&(it=i,i=r,r=it),!(i<u.min)||!(r<u.min))&&(!(i>u.max)||!(r>u.max))){var rt=this.plot.getPlotOffset(),s=rt.left,h=rt.top,b=u.p2c(u.min),k=u.p2c(u.max),c=u.p2c(i),l=u.p2c(r),y=c+tt,p=l-tt,d=!0,g=!0;i<u.min&&(c=b,d=!1);r>u.max&&(l=k,g=!1);y>k&&(y=k);p<b&&(p=b);v=f.p2c(n.DigitalWaveform.MID);a=f.p2c(e);d&&g&&y>=p?(ut=(c+l)/2,t.moveTo(c+s,v+h),t.lineTo(ut+s,a+h),t.lineTo(l+s,v+h)):(d?(t.moveTo(c+s,v+h),t.lineTo(y+s,a+h)):t.moveTo(c+s,a+h),g?(t.lineTo(p+s,a+h),t.lineTo(l+s,v+h)):t.lineTo(l+s,a+h));nt=Math.abs(l-c);o!=null&&nt>this.minimalLabelWidth&&(ft=n.SVW_Colors.getCursorTextColor(this.wf.getWaveContainer()),w=this.paper.text(c+this.shift,this.yText,o).attr({"text-anchor":"start"}),w.attr({"stroke-width":1,"font-size":this.fontSize}),w.attr({fill:ft}),n.WaveUtils.truncateText(nt,o,w))}},i.DigitalFillColor="white",i}(n.DigitalRenderer);n.BusRenderer=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(){function n(){n.initThemes()}return n.initThemes=function(){n.colorThemes[n.BASE_THEME]=new u(n.BASE_THEME);n.colorThemes[n.BLACK_THEME]=new r(n.BLACK_THEME)},n.getNextColorIndex=function(){var t=n.colorIndex%n.NUM_WAVEFORM_COLORS;return n.colorIndex++,t},n.initGlobalColorIndex=function(t){n.colorIndex=t+1},n.adjustColorByRow=function(t,i,r){var e=0,u,f;for(t<0&&(t=n.getNextColorIndex(),e=1),u=t,f=e;f<n.NUM_WAVEFORM_COLORS;){if(!i.checkForColorIndex(u,r))return u;u=n.getNextColorIndex();f++}return t},n.getNextColor=function(t,i){var r=n.getCurrentTheme(i),u=n.getIndexByColorInTheme(r,t);return u<0?r.getWaveformColor(this.getNextColorIndex()):(n.colorIndex=(u+1)%n.NUM_WAVEFORM_COLORS,r.getWaveformColor(n.colorIndex))},n.findColorAbsentInContainer=function(t){for(var u=t.getFirstRow().getFirstWaveform().getColor(),i=n.getNextColor(u,t),r=0;r<n.NUM_WAVEFORM_COLORS;r++){if(!n.isColorInContainer(i,t))return i;i=n.getNextColor(i,t);r++}return i},n.isColorInContainer=function(n,t){for(var r,i=0;i<t.getPlottedWaveforms().length;i++)if(r=t.getPlottedWaveforms()[i],r.getColor()&&r.getColor()==n)return!0;return!1},n.getCurrentTheme=function(t){if(!t)return n.colorThemes[n.BASE_THEME];var i=t.getId();return n.currentTheme.hasOwnProperty(i)||(n.currentTheme[i]=n.colorThemes[n.BASE_THEME]),n.currentTheme[i]},n.getNewColor=function(t){return!t||t.isEmpty()?this.getColorByIndex(this.getNextColorIndex(),t):n.findColorAbsentInContainer(t)},n.getDifferentColor=function(t,i){var u,f,e,r;if(!t||t.isEmpty()||!i||i.length==0)return this.getColorByIndex(this.getNextColorIndex(),t);if(r=this.getColorByIndex(this.getNextColorIndex(),t),!n.usedColor(r,i))return r;for(u=this.getGlobalIndexByColor(i[i.length-1]),f=0;f<n.NUM_WAVEFORM_COLORS;f++){if(e=u%n.NUM_WAVEFORM_COLORS,r=n.getColorByIndex(e,t),!n.usedColor(r,i))return r;u++}return r},n.usedColor=function(n,t){for(var i=0;i<t.length;i++)if(n&&n==t[i])return!0;return!1},n.getColorByIndex=function(t,i){var r=n.getCurrentTheme(i);return r.getWaveformColor(t)},n.getGlobalIndexByColor=function(t){var r=n.colorThemes[n.BASE_THEME],i;return t?(i=n.getIndexByColorInTheme(r,t),i>=0)?i:(r=n.colorThemes[n.BLACK_THEME],i=n.getIndexByColorInTheme(r,t),i>=0)?i:-1:-1},n.getIndexByColorInTheme=function(t,i){if(!i)return n.getNextColorIndex();for(var r=0;r<n.NUM_WAVEFORM_COLORS;r++)if(i==t.getWaveformColor(r))return r;return-1},n.isWhiteBackground=function(t){var i=n.getCurrentTheme(t);return n.BASE_THEME==i.themeId},n.init=function(){n.inUse||(n.inUse=!0,n.initThemes())},n.setTheme=function(t,i){n.init();n.currentTheme[t.getId()]=n.colorThemes[i]},n.getColor=function(t,i){return n.init(),n.getCurrentTheme(t).getColor(i)},n.getThemeName=function(t){return n.init(),n.getCurrentTheme(t).getThemeName()},n.getRowBackgroundColor=function(t){n.init();var i=n.getCurrentTheme(t);return i.getColor(n.ROW_BACKGROUND_COLOR)},n.getGridLineColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.GRID_LINE_COLOR)},n.getCursorLineColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.CURSOR_LINE_COLOR)},n.getCursorLockedLineColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.CURSOR_LOCKED_LINE_COLOR)},n.getCursorHighliteLineColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.CURSOR_HIGHLIGHT_LINE_COLOR)},n.getFillBackgroundColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.CURSOR_FLAG_BACKGROUND_COLOR)},n.getCursorTextColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.CURSOR_TEXT_COLOR)},n.getAnnotationLineColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.ANNOTATION_LINE_COLOR)},n.getIncorrectValueColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.INCORRECT_CURSOR_VALUE_COLOR)},n.getDigitalFillColor=function(t){return n.init(),n.getCurrentTheme(t).getColor(n.DIGITAL_FILL_COLOR)},n.initBaseTheme=function(){n.WF_COLOR_DEFAULT_BASE=[];n.WF_COLOR_DEFAULT_BASE[n.ROW_BACKGROUND_COLOR]="";n.WF_COLOR_DEFAULT_BASE[n.CURSOR_LINE_COLOR]="black";n.WF_COLOR_DEFAULT_BASE[n.GRID_LINE_COLOR]="#f4f4f4";n.WF_COLOR_DEFAULT_BASE[n.CURSOR_TEXT_COLOR]="#000080";n.WF_COLOR_DEFAULT_BASE[n.CURSOR_LOCKED_LINE_COLOR]="grey";n.WF_COLOR_DEFAULT_BASE[n.CURSOR_HIGHLIGHT_LINE_COLOR]="blue";n.WF_COLOR_DEFAULT_BASE[n.CURSOR_FLAG_BACKGROUND_COLOR]="#FFF";n.WF_COLOR_DEFAULT_BASE[n.ANNOTATION_LINE_COLOR]="#ccc";n.WF_COLOR_DEFAULT_BASE[n.INCORRECT_CURSOR_VALUE_COLOR]="red";n.WF_COLOR_DEFAULT_BASE[n.DIGITAL_FILL_COLOR]="#FFF"},n.initBlackTheme=function(){n.WF_COLOR_DEFAULT_BLACK=[];n.WF_COLOR_DEFAULT_BLACK[n.ROW_BACKGROUND_COLOR]="black";n.WF_COLOR_DEFAULT_BLACK[n.CURSOR_LINE_COLOR]="grey";n.WF_COLOR_DEFAULT_BLACK[n.GRID_LINE_COLOR]="#2F4F4F";n.WF_COLOR_DEFAULT_BLACK[n.CURSOR_TEXT_COLOR]="#7B68EE";n.WF_COLOR_DEFAULT_BLACK[n.CURSOR_LOCKED_LINE_COLOR]="grey";n.WF_COLOR_DEFAULT_BLACK[n.CURSOR_HIGHLIGHT_LINE_COLOR]="blue";n.WF_COLOR_DEFAULT_BLACK[n.CURSOR_FLAG_BACKGROUND_COLOR]="#FFF";n.WF_COLOR_DEFAULT_BLACK[n.ANNOTATION_LINE_COLOR]="#2F4F4F";n.WF_COLOR_DEFAULT_BLACK[n.INCORRECT_CURSOR_VALUE_COLOR]="red";n.WF_COLOR_DEFAULT_BLACK[n.DIGITAL_FILL_COLOR]="black"},n.initWhiteTheme=function(){n.WF_COLOR_DEFAULT_WHITE=[];n.WF_COLOR_DEFAULT_WHITE[n.ROW_BACKGROUND_COLOR]="white";n.WF_COLOR_DEFAULT_WHITE[n.CURSOR_LINE_COLOR]="grey";n.WF_COLOR_DEFAULT_WHITE[n.GRID_LINE_COLOR]="#f4f4f4";n.WF_COLOR_DEFAULT_WHITE[n.CURSOR_TEXT_COLOR]="#ff0000";n.WF_COLOR_DEFAULT_WHITE[n.CURSOR_LOCKED_LINE_COLOR]="grey";n.WF_COLOR_DEFAULT_WHITE[n.CURSOR_HIGHLIGHT_LINE_COLOR]="blue";n.WF_COLOR_DEFAULT_WHITE[n.CURSOR_FLAG_BACKGROUND_COLOR]="#FFF";n.WF_COLOR_DEFAULT_WHITE[n.ANNOTATION_LINE_COLOR]="#f4f4f4";n.WF_COLOR_DEFAULT_WHITE[n.INCORRECT_CURSOR_VALUE_COLOR]="red"},n.DROP_SHADOW_COLOR="rgb(170, 170, 170)",n.ZERO_LEVEL_COLOR="#949494",n.SIGN_COLOR="black",n.inUse=!1,n.currentTheme=[],n.BASE_THEME=0,n.BLACK_THEME=1,n.WHITE_THEME=2,n.PALETTE_NUMBER=2,n.ROW_BACKGROUND_COLOR=0,n.CURSOR_LINE_COLOR=1,n.GRID_LINE_COLOR=2,n.CURSOR_TEXT_COLOR=3,n.CURSOR_LOCKED_LINE_COLOR=4,n.CURSOR_HIGHLIGHT_LINE_COLOR=5,n.CURSOR_FLAG_BACKGROUND_COLOR=6,n.ANNOTATION_LINE_COLOR=7,n.INCORRECT_CURSOR_VALUE_COLOR=8,n.DIGITAL_FILL_COLOR=9,n.colorThemes=[],n.NUM_WAVEFORM_COLORS=9,n.colorIndex=0,n}(),i,r,u;n.SVW_Colors=t;i=function(){function n(){this.themeId=t.BASE_THEME;this.colorMap=[];this.themName="Base"}return n.prototype.getColor=function(n){return this.colorMap[n]},n.prototype.getThemeName=function(){return this.themName},n.prototype.getWaveformColor=function(n){return this.waveformColors?this.waveformColors[n]:"black"},n}();n.ColorTheme=i;r=function(n){function i(r){n.call(this);this.themeId=r;this.colorMap=i.WF_COLOR_DEFAULT_BLACK;this.themName="Black";this.waveformColors=i.COLOR_TABLE_BLACK;i.WF_COLOR_DEFAULT_BLACK[t.ROW_BACKGROUND_COLOR]="black";i.WF_COLOR_DEFAULT_BLACK[t.CURSOR_LINE_COLOR]="grey";i.WF_COLOR_DEFAULT_BLACK[t.GRID_LINE_COLOR]="#2F4F4F";i.WF_COLOR_DEFAULT_BLACK[t.CURSOR_TEXT_COLOR]="#7B68EE";i.WF_COLOR_DEFAULT_BLACK[t.CURSOR_LOCKED_LINE_COLOR]="grey";i.WF_COLOR_DEFAULT_BLACK[t.CURSOR_HIGHLIGHT_LINE_COLOR]="blue";i.WF_COLOR_DEFAULT_BLACK[t.CURSOR_FLAG_BACKGROUND_COLOR]="#FFF";i.WF_COLOR_DEFAULT_BLACK[t.ANNOTATION_LINE_COLOR]="#2F4F4F";i.WF_COLOR_DEFAULT_BLACK[t.INCORRECT_CURSOR_VALUE_COLOR]="red"}return __extends(i,n),i.WF_COLOR_DEFAULT_BLACK=[],i.COLOR_TABLE_BLACK=["rgb(30, 144, 255)","rgb(124, 252, 0)","rgb(255, 255, 0)","rgb(138, 43, 226)","#AAFFFF","rgb(255, 127, 0)","rgb(128, 0, 128)","#FF1493","#43E8D2"],i}(i);n.BlackTheme=r;u=function(n){function i(r){n.call(this);this.themeId=r;this.colorMap=i.WF_COLOR_DEFAULT_WHITE;this.themName="White";this.waveformColors=i.COLOR_TABLE_WHITE;i.WF_COLOR_DEFAULT_WHITE[t.ROW_BACKGROUND_COLOR]="";i.WF_COLOR_DEFAULT_WHITE[t.CURSOR_LINE_COLOR]="black";i.WF_COLOR_DEFAULT_WHITE[t.GRID_LINE_COLOR]="#ccc";i.WF_COLOR_DEFAULT_WHITE[t.CURSOR_TEXT_COLOR]="#000080";i.WF_COLOR_DEFAULT_WHITE[t.CURSOR_LOCKED_LINE_COLOR]="grey";i.WF_COLOR_DEFAULT_WHITE[t.CURSOR_HIGHLIGHT_LINE_COLOR]="blue";i.WF_COLOR_DEFAULT_WHITE[t.CURSOR_FLAG_BACKGROUND_COLOR]="#FFF";i.WF_COLOR_DEFAULT_WHITE[t.ANNOTATION_LINE_COLOR]="#ccc";i.WF_COLOR_DEFAULT_WHITE[t.INCORRECT_CURSOR_VALUE_COLOR]="red"}return __extends(i,n),i.WF_COLOR_DEFAULT_WHITE=[],i.COLOR_TABLE_WHITE=["#00009c","#009600","#7f00ff","#ff0000","#319ace","#660000","#bd20c6","#003300","#ffa500"],i}(i);n.WhiteTheme=u}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(t,i,r,u,f){this.treeJQ=null;this.viewerWindow=null;this.treeData=[];this.putToCache=!0;this.treeJQ=t;this.treeData=i;u instanceof n.ViewerWindow?this.viewerWindow=u:(this.probe=u,this.objectName=f);var e;f?(this.putToCache=!1,e=this.prepareDataForWaveformTree(this.treeData)):e=this.prepareDataForTree(this.treeData);Project.Utility.trace("create tree as tree",!1);this.createTree([e],r)}return t.prototype.getTreeJQ=function(){return this.treeJQ},t.prototype.prepareDataForTree=function(t){var i=new n.TreeNodeDescription(n.WaveManager.WDB),r;if(i.expanded=!0,i.id="SimulationRoot",i.classInfo="isSimulationRoot",i.name=n.ViewerWindow.TREE_TITLE,i.text=i.name,!t)return i;for(r=0;r<t.length;r++){var u=t[r],e=n.getManager().getWdbMetadataFromCache(u.simulationId),f=this.createWdbNode(u,e,i);f&&i.items.push(f)}return this.resortTreeNode(i),i},t.prototype.prepareDataForWaveformTree=function(t){var u,r,f;if(!t)return i;var e=t[0],s=this.objectName.toLowerCase(),i=this.createWaveformNode(s,e.wdbId,e.simulationId),o=n.getManager().getWaveformNodes(e.simulationId,s);if(o)for(u=0;u<o.length;u++)r=o[u],this.isHierarchy(r.Name)?this.addToHierarchyFolder(r,i,r.Name,!0):(f=this.createTreeNode(r,i),f.isFolder?i.folderList.push(f):i.items.push(f));return this.addFolderList(i),this.resortTreeNode(i),i},t.prototype.createWaveformNode=function(t,i,r){var f=n.WaveManager.HIERARCHY,u=new n.TreeNodeDescription(f);return u.id="",u.name=t,u.text=t,u.wdbId=i,u.simulationId=r,u.expanded=!0,u},t.prototype.createTree=function(t){var i=this,o,h,f,r,e,c,v;Project.Utility.trace("start create dataSource",!0);o=new kendo.data.HierarchicalDataSource({data:t,schema:{model:{children:"items",hasChildren:function(n){return n.items&&n.items.length>0}}}});Project.Utility.trace("end create dataSource",!0);var l=function(n){var t=i.isWdbNode(n.node);i.addToExpandedFolders(n.node,t);i.viewerWindow||ProbeModule.getWaveBoxManager().adjustDialogHeight(i.getTreeJQ());i.setupPerfectScrollbar()},a=function(n){var t=i.isWdbNode(n.node);i.removeFromExpandedFolders(n.node,t);i.viewerWindow||ProbeModule.getWaveBoxManager().adjustDialogHeight(i.getTreeJQ());i.setupPerfectScrollbar()},y=function(){i.viewerWindow||ProbeModule.getWaveBoxManager().adjustDialogHeight(i.getTreeJQ())},s=this.getTreeJQ(),u;if(i.viewerWindow?(Project.Utility.trace("start create options",!0),u={loadOnDemand:!0,dragAndDrop:!0,dataImageUrlField:"image",dataSource:o,template:kendo.template(i.getTemplate()),drop:function(n){n.preventDefault();i.viewerWindow.dropWaveform(n);setBodyCursor("auto");i.removeEscListener()},dragstart:function(n){var t=i.isBusNode(n.sourceNode),r=$(n.sourceNode).children("ul.k-group");!t&&r[0]&&n.preventDefault();i.addEscListener()},drag:function(n){i.viewerWindow.checkDropStatus(n);i.viewerWindow.drag_pageX=n.pageX;i.viewerWindow.drag_pageY=n.pageY},expand:l,collapse:a},Project.Utility.trace("end create options",!0)):u={loadOnDemand:!0,dragAndDrop:!1,dataImageUrlField:"image",dataSource:o,template:kendo.template(i.getTemplate()),expand:l,collapse:a,dataBound:y},i.viewerWindow){Project.Utility.trace("start kendoTreeView",!0);s.kendoTreeView(u).on("dblclick",".k-in",function(n){i.viewerWindow.dropWaveformByDblClick(n)}).on("click",".k-in",function(){}).on("mouseenter",".k-in",function(t){n.getManager().getCrossHighlightManager().crossHighlightFromTree(t,!0)}).on("mouseenter",".viewerSimulationFolder.isSimulationRoot",function(n){var t=$(this).attr("simtype"),i=Project.getSimulationTypeName(t);$(this).qtip({overwrite:!1,content:i,position:{my:"left top",at:"bottom right"},show:{event:n.type,ready:!0},style:{classes:"svw-tooltip"}})}).on("mouseleave",".k-in",function(t){n.getManager().getCrossHighlightManager().crossHighlightFromTree(t,!1)});Project.Utility.trace("end kendoTreeView",!0)}else s.kendoTreeView(u).on("click",".k-in",function(n){var t,r;(n.preventDefault(),n.stopPropagation(),t=$(n.currentTarget).find(".viewerSimulationFile")[0],t)&&i.probe&&(r=i.getWaveformHandle(t),i.probe.probeObject.finishWaveformSelection(r,null))});for(h=i.getTreeJQ().data("kendoTreeView"),f=0;f<this.treeData.length;f++)if(r=this.treeData[f],r.isExpanded)for(e=0;e<r.expandedFolders.length;e++)c=r.expandedFolders[e],c&&$(s.find(".k-item")).each(function(){var t=$(this).attr("data-uid"),n=i.getNodePath(this);$(this).find(".viewerSimulationFolder").each(function(){var u=$(this).attr("wdbid"),i;n&&n==c&&r.wdbId==u&&(i=h.findByUid(t),h.expand(i))})});i.viewerWindow?i.setupPerfectScrollbar():($(SCHEMATIC).bind("mouseup.compDialog",function(n){i.probe&&i.probe.probeObject.finishWaveformSelection(null,n)}),v=i.probe.getWavebox().getWaveBoxWindow().wrapper.find(".k-i-close"),v.bind("click.compDialog",function(n){i.probe&&i.probe.probeObject.finishWaveformSelection(null,n)}),$(document).bind("keydown.compDialog",function(n){n.which==Project.Design.EscKey&&i.probe&&i.probe.probeObject.finishWaveformSelection(null,n)}))},t.prototype.setupPerfectScrollbar=function(){var n=this;setTimeout(function(){var t=Project.Utility.updatePerfectScrollBar(n.getTreeJQ(),n.scrollbar!=null);n.scrollbar=t},t.SCROLLBAR_TIMEOUT)},t.prototype.addEscListener=function(){$(document).bind("keydown.treeDrag",function(t){t.which==Project.Design.EscKey&&(n.getManager().cancelWaveformDragging(),$("body").trigger("mouseup"))})},t.prototype.removeEscListener=function(){$(document).unbind("keydown.treeDrag")},t.prototype.getWdbIdForNode=function(n){var t=null;return $(n).find(".viewerSimulationFolder:first").each(function(){var n=$(this).attr("wdbId");n&&(t=n)}),t},t.prototype.isWdbNode=function(n){var t=!1;return $(n).find("img").siblings("span").each(function(){$(this).attr("class")=="viewerSimulationFolder isSimulationRoot"&&(t=!0)}),t},t.prototype.isBusNode=function(n){var t=$(n).find(".viewerSimulationFile:first")[0];return t?$(t).attr("isBus")=="true":!1},t.prototype.addToExpandedFolders=function(n,t){var u=this.getNodePath(n),f=this.getWdbIdForNode(n),r,i;if(this.treeData)for(r=0;r<this.treeData.length;r++)i=this.treeData[r],i.wdbId==f&&(t?i.isExpanded=!0:$.inArray(u,i.expandedFolders)<0&&i.expandedFolders.push(u))},t.prototype.removeFromExpandedFolders=function(n,t){var u,f,r,i;if(this.treeData)for(u=this.getNodePath(n),f=this.getWdbIdForNode(n),r=0;r<this.treeData.length;r++)i=this.treeData[r],i.wdbId==f&&(t?i.isExpanded=!1:(i.expandedFolders.splice($.inArray(u,i.expandedFolders),1),this.collapseChildNodes(n,i)))},t.prototype.getTemplate=function(){return"# if (item.isFolder && !item.isBus) {# <span class='#= item.classInfo#' value = '#= item.name#' parentName = '#= item.parentName#' simulationId = '#= item.simulationId#' wdbId = '#= item.wdbId#' isFolder ='#= item.isFolder#' isBus ='#= item.isBus#' isComplex ='#= item.isComplex#' Id ='#= item.id #' simType ='#= item.simType#'>#=item.text#<\/span>#} else if (item.isFolder && item.isBus) {# <span class='#= item.classInfo#' value = '#= item.name#' parentName = '#= item.parentName#' simulationId = '#= item.simulationId#' wdbId = '#= item.wdbId#' isFolder ='#= item.isFolder#' isBus ='#= item.isBus#' isComplex ='#= item.isComplex#' Id ='#= item.id #' simType ='#= item.simType#' wfId ='#= item.id #'>#=item.text#<\/span>#} else {# <span class='#= item.classInfo #' value = '#= item.name #' simulationId = '#= item.simulationId#' wdbId = '#= item.wdbId#' isComplex ='#= item.isComplex#' wfId ='#= item.id #'>#=item.text#<\/span>#} #"},t.prototype.createWdbNode=function(t,i){if(i){var r=new n.TreeNodeDescription(n.WaveManager.WDB,i.Type);return r.expanded=t.isExpanded,r.id=t.wdbId,r.name=t.wdbName,r.text=r.name,r.simulationId=t.simulationId,r.wdbId=t.wdbId,r.simType=i.Type,this.handleChildren(i,r),r}},t.prototype.createTreeNode=function(t,i){if(t){var r=new n.TreeNodeDescription(t.Type);return t.isBusBit?(r.name=t.Name,r.text=n.WaveUtils.extractBusBitName(r.name)):(r.name=t.Name,r.text=r.name),r.id=t.Id,r.wdbId=i.wdbId,r.simulationId=i.simulationId,this.handleChildren(t,r),r}},t.prototype.addFolderList=function(n){for(var t=0;t<n.folderList.length;t++)this.addFolderList(n.folderList[t]),n.items.push(n.folderList[t]);n.folderList=[]},t.prototype.handleChildren=function(n,t){var u,i,r;if(n.Children){for(u=0;u<n.Children.length;u++)i=n.Children[u],t.isBus&&this.isBusBit(i.Name)?(i.isBusBit=!0,r=this.createTreeNode(i,t),t.folderList.push(r)):this.isHierarchy(i.Name)?this.addToHierarchyFolder(i,t,i.Name,!1):(r=this.createTreeNode(i,t),r.isFolder?t.folderList.push(r):t.items.push(r));this.addFolderList(t)}},t.prototype.isContainer=function(t){return t==n.WaveManager.FOLDER||t==n.WaveManager.HIERARCHY||t==n.WaveManager.BUS||t==n.WaveManager.COMPOUND_BUS||t==n.WaveManager.COMPOUND_WAVEFORM?!0:!1},t.prototype.isHierarchy=function(n){return n?n.indexOf("/")>0?!0:!1:!1},t.prototype.isBusBit=function(n){return n?n.indexOf("[")>0?!0:!1:!1},t.prototype.getNestedFolder=function(n,t,i){var r,f,u;if(i&&t.name==n)return t;r=t.folderList;for(f in r)if(u=r[f],u.name==n)return u;return null},t.prototype.addToHierarchyFolder=function(t,i,r,u){var a=t.Name,h,c,o,l;if(r){var e=r.split("/"),s=e[0],f=this.getNestedFolder(s,i,u);f&&e.length==2&&n.WaveUtils.isScalarForComplexWaveform(e[1])&&(f.nodeType=n.WaveManager.COMPLEX_HIERARCHY);f||(h=n.WaveManager.HIERARCHY,e.length>1&&n.WaveUtils.isScalarForComplexWaveform(e[1])&&(h=n.WaveManager.COMPLEX_HIERARCHY),f=new n.TreeNodeDescription(h),f.id="",f.name=s,h==n.WaveManager.COMPLEX_HIERARCHY&&i.nodeType!=n.WaveManager.WDB&&(f.parentName=i.name),f.text=s,f.wdbId=i.wdbId,f.simulationId=i.simulationId,i.folderList.push(f));e.length==2?(c=e[1],o=this.createTreeNode(t,f),o.name=a,f.nodeType==n.WaveManager.COMPLEX_HIERARCHY&&(o.isComplex=!0),o.text=c,f.items.push(o)):e.length>2&&(l=r.substring(s.length+1),this.addToHierarchyFolder(t,f,l,!1))}},t.prototype.resortTreeNode=function(n){var i,t;if(n&&n.items)for(i in n.items)t=n.items[i],t.isFolder&&(t.isComplex?this.resortInComplexFolder(t):this.resortTreeNode(t))},t.prototype.resortInComplexFolder=function(t){var i;if(t.isComplex&&(i=t.items,i)){var r=this.getItemByText(n.WaveManager.SCALAR_DBMAG,i),u=this.getItemByText(n.WaveManager.SCALAR_MAGNITUDE,i),f=this.getItemByText(n.WaveManager.SCALAR_PHASE,i),e=this.getItemByText(n.WaveManager.SCALAR_REAL_PART,i),o=this.getItemByText(n.WaveManager.SCALAR_IMAG_PART,i);t.items=[];r&&t.items.push(r);u&&t.items.push(u);f&&t.items.push(f);e&&t.items.push(e);o&&t.items.push(o)}},t.prototype.getItemByText=function(n,t){if(!t)return null;for(var i in t)if(t[i].text==n)return t[i];return null},t.prototype.collapseChildNodes=function(n,t){var r=n.childNodes,i,f,u;if(r)for(i=0;i<r.length;i++)f=r[i],u=this.getNodePath(n),t.expandedFolders.splice($.inArray(u,t.expandedFolders),1)},t.prototype.getNodeName=function(n){var t=this.getTreeJQ().data("kendoTreeView");return t.text(n).trim()},t.prototype.getNodePath=function(n){for(var r=this.getTreeJQ().data("kendoTreeView"),i=this.getNodeName(n),t=r.parent(n);t&&t.length!=0;)i=this.getNodeName(t)+PATH_SEPARATOR+i,t=r.parent(t);return i},t.prototype.getWaveformHandle=function(n){return $(n).attr("wfId")},t.SCROLLBAR_TIMEOUT=300,t}();n.ViewerTree=t}(WaveViewer||(WaveViewer={}));PATH_SEPARATOR="/",function(n){var u=function(){function i(t,r,u){var o=this,f,e;this.openWdbCounter=0;this.latestWdbId=null;this.isResizing=!1;this.blockObject=null;n.getManager().setWindowMode(r);this.currentIndex=i.GLOBAL_WINDOW_INDEX++;this.treeId=i.TREE_ID+"_"+this.currentIndex;this.windowId=t;this.plotContainerId=i.WINDOW_CONTAINER_ID+"_"+this.currentIndex;u&&(this.$surface=u.getSurfaceAsJQuery(),this.surface=u);f=this.getWindowJQ();f.addClass(n.WaveManager.VIEWER_WINDOW_CLASS);f.mouseup(function(){n.getManager().triggerZoom()});e=this.plotContainerId+"_ButtonPanel";this.addButtonPanel(e,r);this.createPlotContainer(f);n.getManager().setViewerWindow(this);f.bind("SVW-ResizeEvent",function(){o.resize()})}return i.prototype.createPlotContainer=function(t){t.append('<div id="'+this.plotContainerId+'"><\/div>');var i=this.getPlotContainerJQ();i.addClass(n.WaveManager.WINDOW_CONTAINER_CLASS)},i.prototype.createWaveContainer=function(){var t=n.WaveboxDecorationOptions.getDefaultOptionsForWindow();this.waveContainer=new n.WaveContainer(this.getPlotContainerJQ(),t);this.waveContainer.setViewerWindow(this)},i.prototype.getWaveContainer=function(){return this.waveContainer},i.prototype.getViewerState=function(){return new n.ViewerState(this)},i.prototype.getTreeJQ=function(){return $("#"+this.treeId)},i.prototype.getWindowJQ=function(){return $("#"+this.windowId)},i.prototype.setWindowWidth=function(n){this.getWindowJQ().width(n)},i.prototype.getWindowHeight=function(){return this.getWindowJQ().height()},i.prototype.createIFrameViewer=function(){this.dlIFrameViewer=$("<iframe>",{id:"idown",src:""}).hide().appendTo("body")},i.prototype.getIFrameViewer=function(){return this.dlIFrameViewer},i.prototype.getPlotContainerJQ=function(){return $("#"+this.plotContainerId)},i.prototype.addButtonPanel=function(n,t){var r=document.createElement("div"),i=$(r);i.addClass("viewer_button_panel");i.width(38);i.appendTo(this.getWindowJQ());this.buttonPanel=i;this.toolbar=new Project.FadingElement(i);this.toolbar.defineEvents();t?this.addPopOutButton():window.opener==null||window.opener.closed||this.addPopInButton();(t||window.opener!=null&&!window.opener.closed)&&this.addShareButton();this.addToolButton()},i.prototype.addButtonToButtonPanel=function(n,t,i,r){i===void 0&&(i=null);r===void 0&&(r=null);var f=document.createElement("button"),u=$(f);i&&u.append('<img src="/Content/images/'+i+'" onmousedown= "return false" >');n&&u.addClass("btn viewer_button "+n);r&&u.addClass(r);u.appendTo(this.buttonPanel);u.on("mouseenter mouseleave",function(n){$(this).qtip({overwrite:!1,content:t,position:{my:"right top",at:"bottom left"},show:{event:n.type,ready:!0},style:{classes:"svw-tooltip"}})});return u},i.prototype.addShareButton=function(){var t=this,i=this.addButtonToButtonPanel(null,"Share Viewer","share_viewer.png","viewer_button");i.click(function(){$.when(n.ViewerRequests.sendViewerStateToServer(t)).done(function(n){var t=new Project.ShareUrlDialog("Share Viewer","viewerStateID="+n);t.show()})})},i.prototype.addPopInButton=function(){var n=this.addButtonToButtonPanel(null,"Pin Viewer to schematic","dock_viewer.png","viewer_button");n.click(function(){window.opener==null||window.opener.closed||window.close()})},i.prototype.addPopOutButton=function(){var t=this,n,i;Project.Utility.isIE()||(n=this.addButtonToButtonPanel(null,"Show Viewer in new window","undock_viewer.png","viewer_button"),i=this,n.click(function(n){n.preventDefault();t.openViewerPage()}))},i.prototype.addToolButton=function(){var n=this,t=this.addButtonToButtonPanel(null,"Waveform Analyzer","func_viewer.png","viewer_button"),i=this;t.click(function(){var t=null;n.waveContainer.isEmpty()||(t=n.waveContainer.getPlottedWaveforms()[0]);n.waveContainer.getToolWindow().open(t)})},i.prototype.openViewerPage=function(){var u=window.location.protocol+"//"+window.location.host+"/Viewer",f=this.getViewerWindowWidth(),i=this.getViewerWindowHeight();i<Operations.ToolWindow.DIALOG_HEIGHT+50&&(i=Operations.ToolWindow.DIALOG_HEIGHT+50);var r=this,t=null,e="Please press the 'pop-ups blocked' icon in your browser address line.\nCheck 'Always allow pop-ups...' item and try again.",s=window.attachEvent||window.addEventListener,o=window.attachEvent?"onbeforeunload":"beforeunload";s(o,function(n){n.preventDefault?n.preventDefault():n.returnValue=!1;t&&t.close();$(window).unbind(o)});this.waveContainer.closeToolWindow();$.when(n.ViewerRequests.sendViewerStateToServer(this)).done(function(o){var h="popup,scrollbars=no,toolbar=no,location=no,titlebar=no,directories=no,status=no,menubar=no,resizable=yes,",c,s;t=o?window.open(u+"?stateid="+o,"Viewer",h+"width="+f+",height="+i,!1):window.open(u,"Viewer",h+"width="+f+",height="+i,!1);t?(r.disableAndClose(),n.getManager().setChildBrowserWindow(t),c=t.attachEvent||t.addEventListener,s=t.attachEvent?"onbeforeunload":"beforeunload",c(s,function(i){var u,f,e;i.preventDefault?i.preventDefault():(u="Please, press 'Leave this page' button",i.returnValue=u);r.enableAndOpen();f=t.getViewerWin();e=new n.ViewerState(f.getViewerState());r.restoreViewerState(e);n.getManager().setChildBrowserWindow(null);$(t).unbind(s)})):Project.MessageManager.showWarningMessage(e)}).fail(function(){Project.MessageManager.showWarningMessage(e)})},i.prototype.setSimulationSidebar=function(n){this.simulationSidebar=n},i.prototype.getSurface=function(){return this.surface},i.prototype.disableAndClose=function(){var n=this.getSurface().getSidebarManager();n&&n.disableAndCloseViewerWindow()},i.prototype.enableAndOpen=function(){var n=this.getSurface().getSidebarManager();n&&n.enableAndOpenViewerWindow()},i.prototype.setChildBrowserWindow=function(t){n.getManager().setChildBrowserWindow(t)},i.prototype.restoreViewerState=function(n){var i,t;Project.Utility.trace("restoreViewerState",!1);this.showWindow();this.createTreeContainer();i=this;n&&(this.showSpinner("restoreState"),t=n.getTreeData(),t&&t.length>0?$.when(this.restoreTreeForState(t)).done(function(){i.restoreViewerWaveContainer(n.getWaveContainerState())}):this.hideSpinner("restoreState"))},i.prototype.getSimulationIdsForWaveforms=function(n){var f=n.getRowStates(),e=[],t,o,s,i,r,u;if(f)for(t=0;t<f.length;t++)if(o=f[t],o&&(s=[],i=o.getWaveformStates(),i))for(r=0;r<i.length;r++)u=i[r],u&&$.inArray(u.simulationId,e)<0&&e.push(u.simulationId);return e},i.prototype.restoreViewerWaveContainer=function(n){var t=this,i,r,u;Project.Utility.trace("restoreWaveContainer",!1);this.getWaveContainer().clear();this.showSpinner("restoreWaveContainer");i=n.getXVisibleState();r=this.getWaveContainer();r.setXVisibleState(i.range.xmin,i.range.xmax,i.isViewAll);u=n.getRowStates();u?$.when(this.restoreWaveformsForRows(u)).done(function(i){var f,e;if(i&&i.length>0){for(f=0;f<u.length;f++)e=i[f].yRanges,r.addWaveformsToNewRows(i[f].waveforms,e,!0);$.when(r.plotRows()).done(function(){t.restoreCursors(n.getCursorStates());t.restoreMeasurements(n);t.hideSpinner("restoreState")})}else t.hideSpinner("restoreState")}):(this.getWaveContainer().plotEmptyWaveform(),this.restoreCursors(n.getCursorStates()),this.hideSpinner("restoreState"))},i.prototype.restoreMeasurements=function(n){var t=[],i,r,u;for(this.waveContainer.containerMeasManager.clear(),i=0;i<n.measurementStates.length;i++)r=n.measurementStates[i],r&&(u=this.createMeasurementByState(r),u&&t.push(u));t&&t.length!=0&&this.waveContainer.containerMeasManager.restoreWaveformMeasurements(t)},i.prototype.parseMeasurementMarkerStates=function(n){var r=[],t,i;if(n&&n.length!=0)for(t=0;t<n.length;t++)i=JSON.parse(n[t]),i&&r.push(i);return r},i.prototype.getArgsFromState=function(n){var t,i,r;return n&&(i=this.waveContainer.getPlottedWaveformByOrderNum(n.waveformIndex),r=this.waveContainer.getPlottedWaveformByOrderNum(n.waveformIndex2),i&&(t=new Operations.ToolArguments,t.arg1=new Operations.ToolArg,t.arg1.wf=i,t.arg2=new Operations.ToolArg,t.arg2.wf=r?r:i)),t},i.prototype.createMeasurementByState=function(n){var u,r;if(!n||!n.measurementRequest)return null;var f=Operations.ToolUtils.createMeasurementById(n.measurementRequest.MeasurementId),i=this.parseMeasurementMarkerStates(n.markerStatesJson),e=this.getArgsFromState(n);if(f&&e){if(u=f.cloneMeasurement(e,n.measurementRequest),i&&i.length!=0)for(r=0;r<i.length;r++){var t=i[r],o=this.waveContainer.getPlottedWaveformByOrderNum(t.waveformOrderNum),s=this.waveContainer.getPlottedWaveformByOrderNum(t.waveformOrderNum2);o&&(t.flotWaveformId=o.getFlotWaveformId());s&&(t.flotWaveformId2=s.getFlotWaveformId());u.addRestoredMarkerState(t)}return u}return null},i.prototype.restoreWaveformsForRows=function(t){var u=$.Deferred(),f,o,s,e,i,a,h;if(t){Project.Utility.trace("restore waveform for one row start",!1);var c=n.WaveUtils.getRequestRange(this.waveContainer.getXAxisState(),this.waveContainer.getXAxisState().isViewAll),v=c.range.xmin,y=c.range.xmax,l=new ServerStructures.ContainerDataRequest(0);for(f=0;f<t.length;f++){for(o=t[f].getWaveformStates(),s=new ServerStructures.RowDataRequest(f),e=0;e<o.length;e++)i=o[e],a=n.WaveUtils.createWaveformDataRequestElem(i.simulationId,i.wfId,v,y,!0,i.wdbId,i.waveformColor,n.PAN_DIRECTION.NONE,n.WaveUtils.isBus(i.waveformType),e,i.getSourceInfo()),s.putWaveformElement(a);l.putRowRequest(s)}h=new ServerStructures.DesignDataRequest;h.putContainerRequest(l);$.when(n.ViewerRequests.createAndInitWaveforms(h)).done(function(n){var i,f,e,s,a;if(n&&n.containers){var h=[],c=n.containers[0];for(i=0;i<c.getAmount();i++){var v=c.getRowWaveforms(i),o=new r(i),l=t[i].getWaveformStates(),y=l.length;for(f=0;f<y;f++)e=l[f],s=v[f],s.points.show=e.showPoints,Project.Utility.trace("create waveform",!1),o.waveforms.push(s),a=ServerStructures.YAxisState.createYAxisState(e.yVisibleRange,e.isViewAllForY,!1),o.yRanges.push(a);h[i]=o}u.resolve(h)}else u.resolve(null)}).fail(function(){u.resolve(null)})}else u.resolve();return u.promise()},i.prototype.restoreCursors=function(n){var t,i;if(n)for(t=0;t<n.length;t++)i=n[t],this.getWaveContainer().addCursorGroup(i)},i.prototype.getViewerWindowHeight=function(){return this.getWindowJQ().height()},i.prototype.getViewerWindowWidth=function(){return this.getWindowJQ().width()},i.prototype.showWindow=function(){this.getWaveContainer()||this.createWaveContainer()},i.prototype.loadSimulationResults=function(n){var t=$.Deferred();return this.showWindow(),Project.Utility.trace("loadSimulationResults",!0),this.createTreeContainer(),this.showSpinner(null),this.initWdb(n,t),t.promise()},i.prototype.restoreTreeForState=function(t){var i=this,e=[],o=$.Deferred(),r,u,f;for(Project.Utility.trace("restoreTreeForState",!1),r="",this.treeData=[],u=0;u<t.length;u++)f=t[u],Project.Utility.trace("before get wdb",!1),e.push(n.ViewerRequests.getWdb(f.simulationId)),r=f.wdbId;return $.when.apply(null,e).done(function(){i.treeData=t;Project.Utility.trace("start create tree",!1);i.latestWdbId=r;i.viewerTree=new n.ViewerTree(i.getTreeJQ(),i.treeData,r,i);Project.Utility.trace("create tree menu",!1);i.createTreeMenu();i.hideSpinner(null);o.resolve()}),o.promise()},i.prototype.getLatestWdbId=function(){return this.latestWdbId},i.prototype.getWdbIdBySimulationId=function(n){for(var i,t=0;t<this.treeData.length;t++)if(i=this.treeData[t],i.simulationId==n)return i.wdbId;return null},i.prototype.initWdb=function(i,r){var u=this;$.when(n.ViewerRequests.getWdb(i)).done(function(f){var e,o,s,h,c;if(Project.Utility.trace("after getWdb from server",!0),u.currentSimulation=i,e=null,f){if(o=f.Name,o&&o!=""||(o=u.surface.getDesign()?u.surface.getDesign().getName():"SimulationResults"+u.openWdbCounter++),e=t.getNewWdbId(),s=new t(i,o,e),u.treeData)for(h=0;h<u.treeData.length;h++)c=u.treeData[h],c.isExpanded=!1;else u.treeData=[];s.isExpanded=!0;u.treeData.push(s)}u.treeData&&u.treeData.length>0&&(u.latestWdbId=e,u.viewerTree=new n.ViewerTree(u.getTreeJQ(),u.treeData,e,u),u.createTreeMenu());u.hideSpinner(null);r.resolve(s)}).fail(function(){u.hideSpinner(null);r.resolve(null)})},i.prototype.createTreeContainer=function(){var t,n;Project.Utility.trace("start createTreeContainer",!0);t=this.getTreeJQ();t&&t.remove();n=document.createElement("div");n.id=this.treeId;$(n).addClass(i.TREE_CLASS);$(n).insertBefore(this.getPlotContainerJQ())},i.prototype.showSpinner=function(n){n===void 0&&(n=null);this.showHideSpinner(!0,n)},i.prototype.hideSpinner=function(n){n===void 0&&(n=null);this.showHideSpinner(!1,n)},i.prototype.showHideSpinner=function(n,t){var i=this,r=this.getWindowJQ();n?(kendo.ui.progress(this.getWindowJQ(),!0),this.blockObject||(this.blockObject=t)):this.blockObject?t&&this.blockObject==t&&(kendo.ui.progress(this.getWindowJQ(),!1),this.blockObject=null):(kendo.ui.progress(this.getWindowJQ(),!1),this.blockObject=null)},i.prototype.removeWdbFromTree=function(n,t){var i,r;if(t&&n)for(i=n.length-1;i>=0;i--)if(r=n[i],r.wdbId&&r.wdbId==t){n.splice(i,1);this.removeDataFromCache(r);r=null;break}},i.prototype.removeDataFromCache=function(t){n.getManager().removeWdbMetadataFromCache(t.simulationId);n.getManager().removeWaveformsFromCache(t.simulationId)},i.prototype.removePlottedWaveforms=function(n){this.getWaveContainer().deleteWdbWaveforms(n);this.getWaveContainer().redraw()},i.prototype.clear=function(){this.treeData&&(this.treeData=[],this.getWaveContainer().clear())},i.prototype.hideWindow=function(){this.getWindowJQ().hide()},i.prototype.resize=function(t){var i,r;t===void 0&&(t=!1);this.showWindow();i=this.getWaveContainer();n.getManager().isWindowMode()?(r=$(VIEWER_PANE).data("pane"),r&&!r.collapsed&&i.resize(t)):i.resize(t);this.viewerTree&&this.viewerTree.setupPerfectScrollbar()},i.prototype.onResize=function(){this.isResizing=!0;this.resize()},i.prototype.getWdbId=function(n){return $(n).attr("wdbId")},i.prototype.getBus=function(n){var t=$(n).attr("isBus");return t?!0:!1},i.prototype.getWaveformHandle=function(n){return $(n).attr("wfId")},i.prototype.getSimulationId=function(n){return $(n).attr("simulationId")},i.prototype.dropWaveform=function(t){var o,h;if(!n.getManager().canDragWaveform()){n.getManager().resetWaveformDragging();return}var r=$(t.sourceNode).find(".viewerSimulationFolder, .viewerSimulationFile")[0],u=this.getWaveformHandle(r),f=this.getSimulationId(r),e=this.getWdbId(r);if(f&&u&&e){o=this.getBus(r);this.showSpinner(null);var i=this,s=this.getWaveContainer(),c=this.getWaveformType(t),l=this.isWaveformOrBus(t),a=s.allowToDrop(i.drag_pageX,i.drag_pageY,c,l);if(a==n.ALLOW_DROP.NOT_ALLOWED){i.hideSpinner(null);return}h=n.WaveUtils.createDesignRequestForWaveform(f,u,null,null,!0,e,null,o,0,n.SourceInfo.createSourceInfoForViewer());$.when(n.ViewerRequests.createAndInitWaveforms(h)).done(function(n){var u,t,r,f;if(n&&n.containers)for(u=n.containers[0],t=0;t<u.getAmount();t++)r=u.getRowWaveforms(t),r&&r[0]?(f=r[0],$.when(s.performDropState(!0,f,i.drag_pageX,i.drag_pageY)).done(function(){i.hideSpinner(null)}).fail(function(){i.hideSpinner(null)})):i.hideSpinner(null);else i.hideSpinner(null)}).fail(function(){i.hideSpinner(null)})}},i.prototype.dropWaveformByDblClick=function(n){var t=$(n.currentTarget).find(".viewerSimulationFile")[0];if(t){var i=this.getWaveformHandle(t),r=this.getSimulationId(t),u=this.getWdbId(t),f=this.getBus(t);this.showSpinner();this.plotWaveformByHandle(r,i,u,null,f)}},i.prototype.plotWaveformByHandle=function(t,i,r,u,f){var h=this,e=$.Deferred(),o=this,s;return t&&i&&r?(s=n.WaveUtils.createDesignRequestForWaveform(t,i,null,null,!0,r,u,f,0,n.SourceInfo.createSourceInfoForViewer()),$.when(n.ViewerRequests.createAndInitWaveforms(s)).done(function(n){var r,t,i,u;if(n&&n.containers)for(r=n.containers[0],t=0;t<r.getAmount();t++)i=r.getRowWaveforms(t),i&&i[0]?(u=i[0],u.isEmptyWaveform()?(o.hideSpinner(),e.resolve(!0)):$.when(h.getWaveContainer().addAndPlotWaveforms(u,!0)).done(function(){o.hideSpinner();e.resolve(!0)})):(o.hideSpinner(),e.resolve(!1));else e.resolve(!1),o.hideSpinner()}).fail(function(){e.resolve(!1);o.hideSpinner()})):(this.hideSpinner(),e.resolve(!1)),e.promise()},i.prototype.plotWaveformsFromWavebox=function(t){var h=t.getWaveContainer(),c=h.getPlottedWaveforms(),e,o,s,a;if(c){var u=0,f=0,r=h.getRequestXAxisState(),y=t.getPlotMode(),v=t.getUniqName(),l=t.getPlotInfo(0,n.SourceInfo.VIEWER_CONTAINER_NAME),i=this.getWaveContainer();i.showSpinner();e=!1;(i.isEmpty()||i.isViewAllForX())&&(e=!0);e&&r.range&&r.range.xmin&&r.range.xmax?(u=r.range.xmin,f=r.range.xmax,i.setXVisibleState(u,f,r.isViewAll),r.isViewAll||n.getManager().copyWaveformRangeDataInCache(c,v)):(o=i.getRequestXAxisState().range,u=o.xmin,f=o.xmax);s=new ServerStructures.DesignDataRequest;a=l.containerRequest;s.putContainerRequest(a);$.when(n.ViewerRequests.createAndInitWaveforms(s)).done(function(n){var u,t,r,f;if(n&&n.containers){for(u=n.containers[0],t=0;t<u.getAmount();t++)r=u.getRowWaveforms(t),r&&r.length>0&&(f=l.getYAxisStates(t),i.addWaveformsToNewRows(r,f,!0));$.when(i.plotRows()).done(function(){i.hideSpinner()}).fail(function(){i.hideSpinner()})}else i.hideSpinner()}).fail(function(){i.hideSpinner()})}},i.prototype.createTreeMenu=function(){this.removeMenu();this.createFolderMenu();this.createTreeRootMenu()},i.prototype.createFolderMenu=function(){var n=new SVWebContextMenu.MenuContent(this);n.addMenuElement("Close",this.closeWdbFunc);n.addMenuElement("Collapse Folders",this.collapseFoldersFunc);this.folderMenu=SVWebContextMenu.MenuHelper.createMenu(n);this.folderMenu.bindMenuTo(".viewerSimulationFolder.isSimulationRoot")},i.prototype.createTreeRootMenu=function(){var n=new SVWebContextMenu.MenuContent(this);n.addMenuElement("Close",this.closeWdbFunc);n.addMenuElement("Collapse All",this.collapseFoldersFunc);this.rootMenu=SVWebContextMenu.MenuHelper.createMenu(n);this.rootMenu.bindMenuTo("#SimulationRoot")},i.prototype.removeMenu=function(){this.folderMenu&&(this.folderMenu.unbindMenuFrom(".viewerSimulationFolder.isSimulationRoot",!0),this.folderMenu.removeMenu());this.rootMenu&&(this.rootMenu.unbindMenuFrom("#SimulationRoot",!0),this.rootMenu.removeMenu());var n=this;$(".viewerSimulationFile").each(function(){var t=$(this).attr("wfid"),i="[wfid='"+t+"']";n.fileMenu&&n.fileMenu.unbindMenuFrom(i,!0)});n.fileMenu&&(n.fileMenu.removeMenu(),n.fileMenu=null)},i.prototype.getWaveformType=function(t){var i=$(t.sourceNode).find(".viewerSimulationFolder, .viewerSimulationFile")[0],u=this.getWaveformHandle(i),f=this.getSimulationId(i),r=n.getManager().getWaveformInfoFromCache(f,u,null,!0);return r?r.getWaveformType():n.WaveManager.ANALOG_WF},i.prototype.isDigitalWaveform=function(t){var i=$(t.sourceNode).find(".viewerSimulationFolder, .viewerSimulationFile")[0],u=this.getWaveformHandle(i),f=this.getSimulationId(i),r=n.getManager().getWaveformInfoFromCache(f,u,null,!0);return r?n.WaveUtils.isDigitalWaveform(r.getWaveformType()):!0},i.prototype.isWaveformOrBus=function(t){var i=$(t.sourceNode).find(".viewerSimulationFolder, .viewerSimulationFile")[0],r=this.getWaveformHandle(i),u,f;return r?(u=this.getSimulationId(i),f=n.getManager().getWaveformInfoFromCache(u,r,null,!0),f)?!0:this.getBus(i):!1},i.prototype.checkDropStatus=function(t){var i=this.getWaveformType(t),r=this.isWaveformOrBus(t),u=this.getWaveContainer().allowToDrop(t.pageX,t.pageY,i,r);u==n.ALLOW_DROP.NOT_ALLOWED?(t.setStatusClass("k-denied"),setBodyCursor("not-allowed")):(t.setStatusClass("k-add"),setBodyCursor("move"))},i.prototype.collapseFoldersFunc=function(n,t){for(var f,c,l,o,r=n,s=r.getWdbId(t.sender.target),a=$(t.sender.target),v=a.text().trim(),y=r.getTreeJQ(),u=y.data("kendoTreeView"),p=u.dataSource.view()[0],h=p.items,e=0;e<h.length;e++)f=h[e],f.wdbId==s&&r.collapseChildrenFolders(f,u),v==i.TREE_TITLE&&(c=f.uid,l=u.findByUid(c),u.collapse(l));o=r.getWdbInfo(s);o&&(o.expandedFolders=[])},i.prototype.traverseChildren=function(n){for(var t,r=n.items,i=0;i<r.length;i++)t=r[i],console.log("item id = "+t.id),console.log("item uid = "+t.uid),console.log("item name = "+t.name),console.log("---------------"),this.traverseChildren(t)},i.prototype.collapseChildrenFolders=function(n,t){var u=n.items,i,r,f,e;if(u)for(i=0;i<u.length;i++)r=u[i],r.isFolder&&(this.collapseChildrenFolders(r,t),f=r.uid,e=t.findByUid(f),t.collapse(e))},i.prototype.getWdbInfo=function(n){for(var i,t=0;t<this.treeData.length;t++)if(i=this.treeData[t],i.wdbId==n)return i;return null},i.prototype.closeWdbFunc=function(t,r){var u=t;u.createTreeContainer();var e=$(r.sender.target),o=e.text().trim(),f=u.getWdbId(r.sender.target);o==i.TREE_TITLE?u.clear():(u.removeWdbFromTree(u.treeData,f),u.removePlottedWaveforms(f));u.latestWdbId=f;u.viewerTree=new n.ViewerTree(u.getTreeJQ(),u.treeData,f,u);u.createTreeMenu()},i.prototype.getTreeData=function(){return this.treeData},i.TREE_CLASS="svw-windowList",i.TREE_ID="windowList",i.TREE_TITLE="Simulation Results",i.WINDOW_CONTAINER_ID="windowContainer",i.GLOBAL_WINDOW_INDEX=0,i.GLOBAL_BUTTON_ID=0,i}(),i,t,r;n.ViewerWindow=u;i=function(){function t(n,t){this.expanded=!1;this.items=[];this.folderList=[];this.isComplex=!1;this.nodeType=n;t&&(this.simType=t);this.initNode()}return t.prototype.initNode=function(){var t=this.nodeType;switch(t){case n.WaveManager.WDB:this.isFolder=!0;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFolder isSimulationRoot";this.image=this.simType&&this.simType==Project.SIMULATION_TYPE.FREQUENCY_DOMAIN?"/Content/kendo/ex_treeviewicons/folderColorAC.png":"/Content/kendo/ex_treeviewicons/folderColor.png";break;case n.WaveManager.FOLDER:this.isFolder=!0;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFolder";this.image="/Content/kendo/ex_treeviewicons/folderColor.png";break;case n.WaveManager.HIERARCHY:this.isFolder=!0;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFolder";this.image="/Content/kendo/ex_treeviewicons/folderHier.gif";break;case n.WaveManager.COMPLEX_HIERARCHY:this.isFolder=!0;this.isBus=!1;this.isComplex=!0;this.classInfo="viewerSimulationFolder";this.image="/Content/kendo/ex_treeviewicons/folderComplex.png";break;case n.WaveManager.ANALOG_WF:this.isFolder=!1;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFile";this.image="/Content/kendo/ex_treeviewicons/fileAnalog.gif";break;case n.WaveManager.STEP_WF:this.isFolder=!1;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFile";this.image="/Content/kendo/ex_treeviewicons/fileStep.gif";break;case n.WaveManager.ENUMERATED_WF:this.isFolder=!1;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFile";this.image="/Content/kendo/ex_treeviewicons/fileEnum.gif";break;case n.WaveManager.STD_LOGIC_WF:case n.WaveManager.BOOLEAN_WF:case n.WaveManager.VHDL_CHAR_WF:case n.WaveManager.BIT_WF:case n.WaveManager.STRING_WF:this.isFolder=!1;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFile";this.image="/Content/kendo/ex_treeviewicons/fileDigital.gif";break;case n.WaveManager.BUS:this.isFolder=!0;this.isBus=!0;this.isComplex=!1;this.classInfo="viewerSimulationFile";this.image="/Content/kendo/ex_treeviewicons/fileBus.gif";break;case n.WaveManager.UNDEFINED:case n.WaveManager.COMPOUND_BUS:case n.WaveManager.COMPOUND_WAVEFORM:case n.WaveManager.SPECTRAL_WF:case n.WaveManager.SCATTER_WF:case n.WaveManager.QSIM_12STATE_WF:case n.WaveManager.QSIM_STATE_WF:case n.WaveManager.BUS_WF:this.isFolder=!1;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFile";this.image="/Content/kendo/ex_treeviewicons/fileAnalog.gif";break;default:this.isFolder=!1;this.isBus=!1;this.isComplex=!1;this.classInfo="viewerSimulationFile";this.image="/Content/kendo/ex_treeviewicons/fileAnalog.gif"}},t}();n.TreeNodeDescription=i;t=function(){function n(n,t,i){this.expandedFolders=[];this.isExpanded=!1;this.simulationId=n;this.wdbName=t;this.wdbId=i}return n.getNewWdbId=function(){return n.WDB_STRING+n.GLOBAL_WDB_INDEX++},n.getExpressionWdbId=function(){return n.expressionWdbId||(n.expressionWdbId=n.WDB_STRING+n.GLOBAL_WDB_INDEX++),n.expressionWdbId},n.GLOBAL_WDB_INDEX=0,n.WDB_STRING="__SVWeb_wbd__",n}();n.WdbInfo=t;r=function(){function n(n){this.waveforms=[];this.rowIndex=0;this.rowIndex=n;this.waveforms=[];this.yRanges=[]}return n}()}(WaveViewer||(WaveViewer={})),function(n){var u=function(){function t(n,t,i){this.found=!1;this.cursor=n;this.flagId=t;this.forXAxis=i}return t.prototype.onTop=function(){this.flagBox&&this.flagBox.toFront();this.flagText&&this.flagText.toFront();this.flagLine&&this.flagLine.toFront()},t.prototype.remove=function(){this.flagBox&&this.flagBox.remove();this.flagText&&(this.unbindMenu(),this.flagText.remove());this.flagLine&&this.flagLine.remove()},t.prototype.getCursorShape=function(){return this.forXAxis?"default":"default"},t.prototype.setMenu=function(){var n=this.cursor.cursorGroup.getMenu();n&&n.bindMenuTo("#"+this.flagId)},t.prototype.unbindMenu=function(){var n=this.cursor.cursorGroup.getMenu();n&&n.unbindMenuFrom("#"+this.flagId,!1)},t.prototype.getBox=function(){return this.flagBox},t.prototype.setBox=function(n){this.flagBox&&this.flagBox.remove();this.flagBox=n;this.flagBox.attr({cursor:this.getCursorShape()})},t.prototype.getText=function(){return this.flagText},t.prototype.setText=function(t){var r=this,i;this.flagText&&this.flagText.remove();this.flagText=t;this.flagText.node.id=this.flagId;this.flagText.attr({cursor:this.getCursorShape()});this.setMenu();this.cursor.parentRow instanceof n.DomainAxis&&this.flagText.dblclick(function(){r.cursor.cursorGroup.moveToXValueInternal()});i=this;this.flagText&&this.flagText.hover(function(){n.SVWEventHandler.getIsMoving()||i.cursor&&i.cursor.cursorGroup&&i.cursor.cursorGroup.onTop()},function(){})},t.prototype.getLine=function(){return this.flagLine},t.prototype.setLine=function(n){this.flagLine&&this.flagLine.remove();this.flagLine=n},t.prototype.hide=function(){this.flagLine&&this.flagLine.hide();this.flagBox&&this.flagBox.hide();this.flagText&&this.flagText.hide()},t.prototype.show=function(){this.flagLine&&this.flagLine.show();this.flagBox&&this.flagBox.show();this.flagText&&this.flagText.show()},t}(),i,r,t;n.CursorFlagContent=u;i=function(){function i(n,t,i,r){this.waveformName="No Name";this.yValue=0;this.yPos=0;this.textInFlag=" No Text";this.xUnits="";this.yUnits="";this.xAxsisName="";this.box={x:0,y:0,height:0,width:0,onRight:!0};this.waveform=t;this.cursor=n;this.flagContent=new u(n,i,r)}return i.prototype.setColors=function(){var t=this.cursor.waveContainer,e=n.SVW_Colors.getCursorLineColor(t),h=n.SVW_Colors.getCursorLockedLineColor(t),s=n.SVW_Colors.getFillBackgroundColor(t),u=this.flagContent.getBox(),f,o,i,r;u&&(u.attr({stroke:e}),u.attr({fill:s}));f=this.flagContent.getLine();f&&f.attr({stroke:e});o=n.SVW_Colors.getCursorTextColor(t);i=this.flagContent.getText();i&&(r=this.waveform,r?r.isResolved||r.isResolvedOnRange||this.cursor.cursorGroup.isYValueResolved(this.waveform)?i.attr({fill:r.getColor()}):i.attr({fill:n.SVW_Colors.getIncorrectValueColor(t)}):i.attr({fill:o}))},i.prototype.updateDataBySignal=function(i){var s=this.cursor.cursorGroup.getXValue(),r=i.getIntersectionPoint(s,this.cursor.cursorGroup),f,u;this.yValue=r.y;this.yPos=i.yaxis.p2c(this.yValue);isNaN(this.yPos)?this.yPos=0:isFinite(this.yPos)?this.yPos<0?this.yPos=0:this.yPos>this.cursor.parentRow.getRowHeight()&&(this.yPos=this.cursor.parentRow.getRowHeight()):this.yPos=r.value==n.WaveUtils.SHOW_NEG_INFINITY?this.cursor.parentRow.getRowHeight():0;this.waveformName=i.getOriginalWaveformName();f=i.getXUnits();this.xUnits=f==null||f=="-"?"":" "+f;u=i.getYUnits();this.yUnits=u==null||u=="-"||u==""?"":" "+u;this.textInFlag=i.getCursorFlagText(r.x,r.y,r.value);this.xAxsisName=i.getXName();var e=this.cursor.getTextParameters(this.textInFlag),h=e.width,c=e.height,l=Math.round(h+2*t.TEXT_MARGIN),o=Math.round(c);return this.box.y=Math.round(this.yPos-o-t.TEXT_MARGIN)+.5,this.box.width=l,this.box.height=o,this.setBoxXPosition(),!0},i.prototype.setBoxXPosition=function(){var u=this.cursor.cursorGroup.isShownFlagOnRight(),n=Math.round(this.cursor.cursorXPosition+15)+.5,t=Math.round(this.cursor.cursorXPosition-15-this.box.width)+.5,i,r;u?(i=n+this.box.width<this.cursor.parentRow.getRowWidth(),i?(this.box.onRight=!0,this.box.x=n):(this.box.onRight=!1,this.box.x=t)):(r=t>0,r?(this.box.onRight=!1,this.box.x=t):(this.box.onRight=!0,this.box.x=n))},i.prototype.updateFlag=function(){var n=this.box,r=Math.round(n.x+n.width/2)-.5,u=Math.round(n.y+n.height/2)+.5,i=this.flagContent.getText(),t;i.attr({text:this.textInFlag});i.attr({x:r});i.attr({y:u});t=this.flagContent.getBox();t.attr({x:n.x});t.attr({y:n.y});t.attr({width:n.width});this.createFlagLine()},i.prototype.drawFlag=function(){var n=this.box;this.drawTextInBox(n.x,n.y,n.width,n.height,this.textInFlag);this.createFlagLine()},i.prototype.hide=function(){this.flagContent&&this.flagContent.hide()},i.prototype.show=function(){this.flagContent&&this.flagContent.show()},i.prototype.createFlagLine=function(){var t=this.box,i=this.yPos,r;i<0?i=0:i>this.cursor.parentRow.getRowHeight()&&(i=this.cursor.parentRow.getRowHeight());r="M "+this.cursor.cursorXPosition+" "+i+(this.box.onRight?" L "+(t.x+1)+" "+(t.y+t.height-1):" L "+(t.x+t.width-1)+" "+(t.y+t.height-1));var u=this.cursor.parentRow.getPlotOffset(),e=this.cursor.parentRow.getPaper(),o=n.WaveUtils.getTransformString(u.left,u.top),f=e.path(r);f.transform(o);this.flagContent.setLine(f)},i.prototype.drawTextInBox=function(i,r,u,f,e){var a=t.RECTAGLE_RADIUS,o=this.cursor.parentRow.getPaper();if(o){var h=this.cursor.parentRow.getPlotOffset(),c=o.rect(i,r,u,f,a).attr({"stroke-width":t.CURSOR_STYLE.rectLineWidth}),l=n.WaveUtils.getTransformString(h.left,h.top);c.transform(l);this.flagContent.setBox(c);var v=Math.round(i+u/2)+.5,y=Math.round(r+f/2)-.5,s=o.text(v,y,e);s.attr({"font-size":t.CURSOR_STYLE.flagFontSize});s.transform(l);this.flagContent.setText(s)}},i.prototype.remove=function(){this.flagContent&&this.flagContent.remove()},i}();n.CursorFlagDescription=i;r=function(){function n(n){this.cursor=n;this.cursorBaseDescription=new i(n,null,n.getNewFlagId(),!0)}return n.prototype.remove=function(){var n,i,t;this.cursorLineLine.remove();this.cursorLineRect.remove();n=this.cursorBaseDescription;n&&n.flagContent&&this.cursorBaseDescription.flagContent.remove();for(i in this.cursor.dataArray)t=this.cursor.dataArray[i].flagContent,t&&t.remove()},n.prototype.addCursorLine=function(n,t){this.cursorLineLine=n;this.cursorLineRect=t;t.attr({cursor:"w-resize"});t.node.id=this.cursor.cursorId},n.prototype.getCursorOuterRect=function(){return this.cursorLineRect},n.prototype.getCursorLineLine=function(){return this.cursorLineLine},n.prototype.getCursorBaseDescription=function(){return this.cursorBaseDescription},n.prototype.hide=function(){var n,i,t;this.cursorLineLine&&this.cursorLineLine.hide();n=this.cursorBaseDescription;n&&n.flagContent&&this.cursorBaseDescription.flagContent.hide();for(i in this.cursor.dataArray)t=this.cursor.dataArray[i].flagContent,t&&t.hide()},n.prototype.show=function(){var n,i,t;this.cursorLineLine&&this.cursorLineLine.show();n=this.cursorBaseDescription;n&&n.flagContent&&this.cursorBaseDescription.flagContent.show();for(i in this.cursor.dataArray)t=this.cursor.dataArray[i].flagContent,t&&t.show()},n}();n.WaveCursorElement=r;t=function(){function t(n,i,r,u){var f,e;this.cursorXPosition=0;this.dataArray=[];this.showBase=!1;this.cursorFlagIndex=0;this.parentRow=n;this.waveContainer=this.parentRow.waveContainer;this.cursorGroup=i;f=r;r==null&&(f=this.waveContainer.getDefaultCursorXValue());this.cursorFlagIndex=0;this.cursorId="waveRowCursor_"+t.GLOBAL_CURSOR_ID++;this.cursorBaseFlagId=this.cursorId+"_flag_";e=this.parentRow.getNumberOfCursors();u&&(this.showBase=u);this.updateByXValue(f,!1);this.setMenu()}return t.prototype.getNewFlagId=function(){return this.cursorBaseFlagId+this.cursorFlagIndex++},t.prototype.getPositionOnScreen=function(){var n=this.waveContainer.getWaveContainerJQ().offset(),t=n.left+this.waveContainer.defineXAxisWidth()+this.cursorXPosition,i=n.top+this.waveContainer.getWaveContainerJQ().height();return new BaseWire.Point(t,i)},t.prototype.getTextParameters=function(n){var u=this.parentRow.getPaper(),i=u.text(0,0,n);i.attr({"font-size":t.CURSOR_STYLE.flagFontSize});var r=i.getBBox(),f=r.width,e=r.height;return i.remove(),{width:f,height:e}},t.prototype.remove=function(){this.unbindMenu();this.cursorElement&&this.cursorElement.remove()},t.prototype.hide=function(){this.cursorElement&&this.cursorElement.hide()},t.prototype.show=function(){this.cursorElement&&this.cursorElement.show()},t.prototype.getCursorElement=function(){return this.cursorElement||(this.cursorElement=new r(this)),this.cursorElement},t.prototype.updateData=function(){var t=this.parentRow.getPlottedWaveforms(),e,f,n,o,r,u;for(e in this.dataArray)f=this.dataArray[e],f.remove(),f=null;if(this.dataArray=[],t)for(n=0;n<t.length;n++)o=t[n],r=o,r&&r.checkCursorPosition(this.cursorGroup.getXValue())&&(u=new i(this,t[n],this.getNewFlagId(),!1),u.yAxis=t[n].yaxis,this.cursorGroup.getXValue()!=null&&(u.updateDataBySignal(r),this.dataArray.push(u)))},t.prototype.updateState=function(n){var i,t;if(this.updateData(),this.shuffle(0,this.parentRow.getRowHeight()),this.dataArray)for(i in this.dataArray)t=this.dataArray[i],t.flagContent.found?t.updateFlag():t.drawFlag();this.drawBase();n?this.drawCursorLine(this.parentRow.getPaper()):this.getCursorElement().getCursorOuterRect()?this.updateCursorLine(this.parentRow.getPaper()):(this.drawCursorLine(this.parentRow.getPaper()),this.addEventHandlers());this.setColors()},t.prototype.updateByPosition=function(n){this.cursorXPosition=n;var t=this.parentRow.calcXValueByPosition(n);this.cursorGroup.setXValueForRowCursors(t,!0);this.updateState(!1)},t.prototype.updateByXValue=function(n,t){this.cursorXPosition=this.parentRow.calcPositionByXValue(n);this.updateState(t)},t.prototype.snapToPoint=function(n){var t=this.parentRow.getPlottedWaveforms(),i=n,r,u;t&&t[0]&&(r=t[0].findRealClosestPointByX(n),r!=null&&(i=r));this.cursorXPosition=i;u=this.parentRow.calcXValueByPosition(i);this.cursorGroup.setXValueForRowCursors(u,!1);this.updateState(!1)},t.prototype.highlightCursor=function(t){var i=this.getCursorElement().getCursorLineLine(),r,u;t?i.attr({stroke:n.SVW_Colors.getCursorHighliteLineColor(this.waveContainer)}):(r=n.SVW_Colors.getCursorLineColor(this.waveContainer),u=r,i.attr({stroke:u}))},t.prototype.onTop=function(){var r=this.getCursorElement().getCursorLineLine(),i,n,t;if(r.toFront(),this.dataArray)for(i in this.dataArray)n=this.dataArray[i],n&&n.flagContent&&n.flagContent.onTop();this.showBase&&(t=this.cursorElement.getCursorBaseDescription(),t&&t.flagContent&&t.flagContent.onTop())},t.prototype.updateBaseName=function(n){this.drawBase(n);this.setColors()},t.prototype.updateAsLocked=function(){this.setColors()},t.prototype.setColors=function(){var i=this.getCursorElement(),f=i.getCursorLineLine(),e=n.SVW_Colors.getCursorLineColor(this.waveContainer),r,u,t;if(f.attr({stroke:e}),r=i.getCursorBaseDescription(),r.setColors(),this.dataArray)for(u in this.dataArray)t=this.dataArray[u],t&&t.setColors()},t.prototype.getXValueWithoutUnits=function(){return this.waveContainer.getFormattedCursorXValue(this.cursorGroup.getXValue())},t.prototype.drawBase=function(n){var v,y,s;if(this.showBase){var w=this.getCursorElement(),i=w.getCursorBaseDescription(),h=i&&i.flagContent&&i.flagContent.getText()!=null;n&&n==!0&&(h=!1);var b=this.cursorGroup.isBaseGroup()?"Base :":"",f=b+this.waveContainer.getFormattedCursorXValue(this.cursorGroup.getXValue()),r=this.cursorXPosition,c=Math.round(this.parentRow.getRowHeight()+this.waveContainer.getXAxisLabelHeight()+5)+.5,l=this.getTextParameters(f),k=l.width,d=l.height,u=Math.round(k+2*t.TEXT_MARGIN),a=Math.round(d),e=Math.round(this.cursorXPosition)+.5,o=Math.round(this.cursorXPosition-u)+.5,g=this.cursorGroup.isShownFlagOnRight();if(g?(v=e+u<this.parentRow.getRowWidth(),r=v?e:o):(y=o+this.waveContainer.getMinimalYAxisWidth()>15,r=y?o:e),h){var nt=Math.round(r+u/2)+.5,tt=Math.round(c+a/2)+.5,p=i.flagContent.getText();p.attr({text:f});p.attr({x:nt});s=i.flagContent.getBox();s.attr({x:r});s.attr({width:Math.round(u)})}else i.drawTextInBox(r,c,Math.round(u),Math.round(a),f)}},t.prototype.sortByYPos=function(n,t){var i=n.yPos,r=t.yPos;return i<r?-1:i>r?1:0},t.prototype.shuffle=function(n,t){var e=this.dataArray.length,s=[],r,c,u;if(!(e<=0)){if(e==1){r=this.dataArray[0];r.box.y<n?r.box.y=n+1:r.box.y+r.box.height>t&&(r.box.y=t-r.box.height+1);return}for(u=0;u<e;u++)s[u]=this.dataArray[u];e>1&&s.sort(this.sortByYPos);var i=null,f=0,o,h=-1;for(u=0;u<e;u++)r=s[u],i={y:r.box.y,height:r.box.height},f=i.y,o=f+i.height,u==0?f<n&&(f+=n-f+1,o=f+i.height,i.y=f,r.box.y=i.y):f<h&&(f+=h-f+1,o=f+i.height,i.y=f,r.box.y=i.y),h=o;if(h>t)for(i.y-=h-t,s[e-1].box.y=i.y,c=i.y,u=e-2;u>=0;u--){if(r=s[u],i={y:r.box.y,height:r.box.height},o=i.y+i.height,o<c||o<=n)break;i.y=c-i.height-1;r.box.y=i.y;c=i.y}}},t.prototype.drawCursorLine=function(i){var o,u,r;if(i){o=this.parentRow.getPlotOffset();u=i.canvas.clientHeight?i.canvas.clientHeight:i.height;this.showBase&&(u-=10);var f=Math.round(this.cursorXPosition)+.5,h="M "+f+" 0 L "+f+" "+u+" z",s=n.WaveUtils.getTransformString(o.left,0),e=i.path(h),c=n.SVW_Colors.getCursorLineColor(this.waveContainer);e.attr({"stroke-width":t.CURSOR_STYLE.lineWidth});e.transform(s);r=i.rect(f-t.DELTA_FOR_SELECTION,0,2*t.DELTA_FOR_SELECTION,u);r.attr({fill:c});r.attr({opacity:0});r.transform(s);this.getCursorElement().addCursorLine(e,r)}},t.prototype.updateCursorLine=function(n){var f,i,u;if(n){f=this.parentRow.getPlotOffset();i=n.canvas.clientHeight?n.canvas.clientHeight:n.height;this.showBase&&(i-=10);var r=Math.round(this.cursorXPosition)+.5,e="M "+r+" 0 L "+r+" "+i+" z",o=this.getCursorElement().getCursorLineLine();o.attr({path:e});u=this.getCursorElement().getCursorOuterRect();u.attr({x:r-t.DELTA_FOR_SELECTION})}},t.prototype.getBoundingRect=function(){for(var n=null,f=new Project.BoundingRect(this.getCursorElement().getCursorLineLine().getBBox()),i,r,u,n=Project.Utility.accumulateBoundingRect(n,f),t=0;t<this.dataArray.length;t++)i=this.dataArray[t],r=new Project.BoundingRect(i.flagContent.getBox().getBBox()),n=Project.Utility.accumulateBoundingRect(n,r),u=new Project.BoundingRect(i.flagContent.getLine().getBBox()),n=Project.Utility.accumulateBoundingRect(n,u);return n},t.prototype.adjustFlagPositions=function(){this.waveContainer.adjustFlagPositions()},t.prototype.addEventHandlers=function(){var i=this.getCursorElement().getCursorOuterRect(),t=this,r=function(){n.SVWEventHandler.getIsMoving()||t.cursorGroup&&(t.cursorGroup.highlightAllCursors(!0),t.cursorGroup.onTop())},u=function(){t.cursorGroup&&t.cursorGroup.highlightAllCursors(!1)};i.hover(r,u);var f=function(r,u,f){if(f.which==1)return n.SVWEventHandler.getIsMoving()?void 0:(n.SVWEventHandler.setIsMoving(i),t.cursorGroup&&t.cursorGroup.highlightAllCursors(!0),{})},e=function(r,u,f,e,o){var h,c,s;if(o.which==1)return n.SVWEventHandler.getIsMoving()!=i?void 0:(h=t.parentRow.getOffset(),c=Math.max(0,Math.min(o.pageX-h.left,t.parentRow.getRowWidth())),t.updateByPosition(c),t.cursorGroup&&t.cursorGroup.highlightAllCursors(!0),t.adjustFlagPositions(),t.parentRow&&(s=t.parentRow.getFirstWaveform(),s&&(n.getManager().getCrossHighlightManager().crossHighlightByWaveform(s,!0),n.getManager().getCrossHighlightManager().crossHighlightByWaveform(s,!1))),{})},o=function(r){if(r.which==1&&n.SVWEventHandler.getIsMoving()==i){n.SVWEventHandler.setIsMoving(null);var u=t.parentRow.getOffset(),f=Math.max(0,Math.min(r.pageX-u.left,t.parentRow.getRowWidth()));return t.cursorGroup&&t.cursorGroup.highlightAllCursors(!1),t.cursorGroup.checkAndUpdateCursorsYValue(!0),t.adjustFlagPositions(),t.parentRow.waveContainer.notifyAboutCursors(),{}}};i.drag(e,f,o)},t.prototype.setMenu=function(){var n=this.cursorGroup.getMenu();n&&n.bindMenuTo("#"+this.cursorId)},t.prototype.unbindMenu=function(){var n=this.cursorGroup.getMenu();n&&n.unbindMenuFrom("#"+this.cursorId,!1)},t.GLOBAL_CURSOR_ID=0,t.DELTA_FOR_SELECTION=5,t.PRECISION=4,t.TEXT_MARGIN=5,t.MAX_NAME_LENGTH=10,t.RECTAGLE_RADIUS=5,t.CURSOR_STYLE={flagFontSize:10,lineWidth:1,rectLineWidth:1},t}();n.WaveRowCursor=t}(WaveViewer||(WaveViewer={})),function(n){var u=function(){function t(i,r,u){this.isPlottedInFlot=!1;this.colorIndex=-1;this.customColor=null;this.currentXUnits=n.WaveManager.NO_UNITS;this.currentYUnits=n.WaveManager.NO_UNITS;this.currentYName=n.WaveManager.NO_UNITS;this.currentXName=n.WaveManager.NO_UNITS;this.isRealEmptyWaveform=!1;this.isHighlighted=!1;this.useLogXAxis=!1;this.xWaveformMin=0;this.xWaveformMax=1;this.YWaveformMin=0;this.YWaveformMax=1;this.useAsConstant=!0;this.data=[];this.yValues=[];this.isResolved=!1;this.isResolvedOnRange=!1;this.yAxisNameWithUnits=n.WaveManager.NO_UNITS;this.points={show:!1};this.plotGetYVisibleRange=function(n){var i=this.plot.getYAxes(),r,t;for(r in i)if(t=i[r],t.options.axisLabel==n)return{from:t.min,to:t.max,axis:t};return null};this.waveformId="waveform"+t.GLOBAL_WAVEFORM_ID++;r&&(this.sourceInfo=r);u&&(this.isRealEmptyWaveform=!0);i||(i=new n.WaveformInfo(null,null));this.simulationId=i.getSimulationId();this.wfHandle=i.getWaveformHandle();this.wdbId=i.wdbId;this.waveformType=i.getWaveformType();this.signalName=i.getSignalName();this.label=n.WaveUtils.limitName(this.signalName);this.workOptions=n.WorkOptions.getWorkOptionsByType(this.waveformType);this.waveformRenderer=this.workOptions.getRenderer(this);this.initWaveform(i)}return t.createWaveform=function(t,i,r,u){if(u||!t)return new n.AnalogWaveform(t,r,!0);var f=t.getWaveformType();switch(f){case n.WaveManager.ANALOG_WF:return new n.AnalogWaveform(t,r);case n.WaveManager.STEP_WF:return new n.StepWaveform(t,r);case n.WaveManager.BUS_WF:case n.WaveManager.BUS:return new n.BusWaveform(t,r);case n.WaveManager.STD_LOGIC_WF:return new n.StdLogicWaveform(t,r);case n.WaveManager.BOOLEAN_WF:return new n.BooleanWaveform(t,r);case n.WaveManager.BIT_WF:return new n.BitWaveform(t,r);case n.WaveManager.ENUMERATED_WF:return new n.EnumWaveform(t,r);default:return new n.AnalogWaveform(t,r)}},t.prototype.hasMeasurementWithMarkers=function(){return this.waveContainer.hasWaveformMeasurementWithMarkers(this)},t.prototype.isProbeWaveformForProbe=function(n){return this.sourceInfo?this.sourceInfo.isForTheProbe(n):!1},t.prototype.isCalculatorWaveformForProbe=function(n){if(!this.sourceInfo)return!1;var t=ProbeModule.PlotMode.SEPARATE_ROWS;return this.waveContainer.isInWaveBox()&&(t=this.waveContainer.getWavebox().getPlotMode()),this.sourceInfo.isCalculatorWaveformForProbe(n,t)},t.prototype.isBasedOnProbe=function(n){return this.isProbeWaveformForProbe(n)||this.isCalculatorWaveformForProbe(n)},t.prototype.checkCursorPosition=function(n){if(n==null||n==undefined||n<this.getXWaveformMin()||n>this.getXWaveformMax())return!1;var t=this.getCurrentXRange();return t&&(n<t.xmin||n>t.xmax)?!1:!0},t.prototype.findClosestPoint=function(n,t,i){var ft,a,et,u,ot,ut;ft=i<0?this.xaxis.min:this.xaxis.p2c(n-i);var s=this.xaxis.p2c(n),w=this.yaxis.p2c(t),k=s,d=w,r=s-i,h=w-i,f,e,c,g,nt,tt,it,v=2*i*i,l,y=v,o=this.getWaveformDataForFlot();if(c=o[0][0],g=o[0][1],r=this.xaxis.p2c(c),h=this.yaxis.p2c(g),a=0,i<0)y=Math.abs(s-r);else{for(et=o[0][0],u=1;u<o.length;u++)c=o[u][0],r=this.xaxis.p2c(c),r>=ft?et=r:a=u-1;a=a<0?0:a}for(u=a;u<o.length;u++){if(nt=o[u][0],tt=o[u][1],f=this.xaxis.p2c(nt),e=this.yaxis.p2c(tt),it=(r-f)*(r-f)+(h-e)*(h-e),ot=(s-f)*(s-f),l=ot+(w-e)*(w-e),l<y&&(k=f,d=e,y=l),it>=Math.abs(v-l)){var p=Math.sqrt(it),st=Math.sqrt(v),ht=Math.sqrt(l),b=(p+st+ht)/2,lt=Math.sqrt(b*(b-p)*(b-st)*(b-ht)),ct=2*lt/p,rt=ct*ct;rt<y&&(y=rt,ut=Math.sqrt(v-rt),k=r+(f-r)*ut/p,d=h+(e-h)*ut/p)}if(c>s)break;r=f;h=e;v=l;c=nt;g=tt}return{x:this.xaxis.c2p(k),y:this.yaxis.c2p(d)}},t.prototype.findRealClosestPointByX=function(n){var h=this.xaxis.c2p(n),i=n,t,f,e,s,o,u=this.getWaveformDataForFlot(),r;for(f=u[0][0],i=this.xaxis.p2c(f),t=i,r=1;r<u.length;r++)if(e=u[r][0],o=u[r][1],t=this.xaxis.p2c(e),n-t>0)f=e,s=o,i=t;else break;return Math.abs(n-i)<Math.abs(n-t)?i:t},t.prototype.getWaveformState=function(){var n=new i;return n.saveState(this),n},t.prototype.initWaveformByState=function(n){this.simulationId=n.simulationId;this.waveformId=n.getFlotWaveformId();this.waveformType=n.waveformType;this.currentXUnits=n.currentXUnits;this.currentYUnits=n.currentYUnits;this.currentYName=n.currentYName;this.currentXName=n.currentXName;this.colorIndex=n.colorIndex;this.customColor=n.waveformColor;this.points.show=n.showPoints;this.useLogXAxis=n.useLogXAxis},t.prototype.setWaveformData=function(n){n?(n.isWholeRange&&n.isResolvedOnRange?(this.isResolved=!0,this.isResolvedOnRange=!0):!n.isWholeRange&&n.isResolvedOnRange?(this.isResolved=!1,this.isResolvedOnRange=!0):(this.isResolved=!1,this.isResolvedOnRange=!1),this.data=n.getData(),this.initYValues(n),this.currentXRange=n.getCurrentXRange()):this.data=[{}]},t.prototype.initYValues=function(t){var r,i;if(this.yValues=t.getYValues(),this.workOptions.workType==n.WORK_TYPE.RAILROAD&&(!this.yValues||this.yValues.length==0))for(this.yValues=[],r=this.data,i=0;i<r.length;i++)this.yValues.push(""+r[i][1])},t.prototype.isPlotted=function(){return this.isPlottedInFlot?!0:this.isEmptyXRange()?(this.isPlottedInFlot=!0,!0):this.isCurrentEmptyArea()?(this.isPlottedInFlot=!0,!0):this.isPlottedInFlot},t.prototype.setPlotted=function(){this.isPlottedInFlot=!0},t.prototype.setUnplotted=function(){this.isPlottedInFlot=!1},t.prototype.isCurrentEmptyArea=function(){return!this.xaxis||!this.yaxis?!1:this.isEmptyArea(this.xaxis.xMin,this.xaxis.xMax,this.yaxis.yMin,this.yaxis.yMax)},t.prototype.isEmptyArea=function(t,i,r,u){var f=this.getWaveformDataForFlot(),e,o,s;if(this.isEmptyWaveform()||!f||f.length==0||!f||f.length==0)return!0;for(e=0;e<f.length;e++)if(o=f[e][0],n.WaveUtils.isCorrectValue(o)&&o>=t&&o<=i&&(s=f[e][1],n.WaveUtils.isCorrectValue(s)&&(!this.workOptions.canZoomYAxis()||s>=r&&s<=u)))return!1;return!0},t.prototype.hasIntersectionWithArea=function(t,i,r,u){var f=this.getWaveformDataForFlot(),s,o,e;if(this.isEmptyWaveform()||!f||f.length==0)return!1;var v=new n.Line(t,r,t,u),y=new n.Line(t,u,i,u),p=new n.Line(i,u,i,r),w=new n.Line(t,r,i,r);if(!f||f.length==0)return!0;var l=null,a=null,h=f[0][0],c=f[0][1];for(s=1;s<f.length;s++)if(l=h,a=c,h=f[s][0],c=f[s][1],n.WaveUtils.isCorrectValue(h)&&n.WaveUtils.isCorrectValue(c)&&(o=new n.Line(l,a,h,c),n.WaveUtils.hasPossibleIntersection(o,new n.Line(t,r,i,u))&&l!=null&&a!=null&&((e=n.WaveUtils.getLineIntersection(o,v),e)||(e=n.WaveUtils.getLineIntersection(o,y),e)||(e=n.WaveUtils.getLineIntersection(o,p),e)||(e=n.WaveUtils.getLineIntersection(o,w),e))))return!0;return!1},t.prototype.isEmptyXRange=function(){var n=this.getWaveformDataForFlot();return this.isEmptyWaveform()||!n||n.length==0?!0:!n||n.length==0?!0:this.xaxis?this.xaxis.min>this.xWaveformMax||this.xaxis.max<this.xWaveformMin?!0:!1:!1},t.prototype.getWaveformHandle=function(){return this.wfHandle},t.prototype.getFlotWaveformId=function(){return this.waveformId},t.prototype.getWaveformDataForFlot=function(){return this.data},t.prototype.getXWaveformMin=function(){return this.xWaveformMin},t.prototype.getXWaveformMax=function(){return this.xWaveformMax},t.prototype.getWholeYRange=function(){if(this.isEmptyWaveform())return n.YWaveRange.getEmptyRange();var t=this.workOptions.getYRange(!1);return t?t:this.createYRange()},t.prototype.createYRange=function(){return new n.YWaveRange(this.YWaveformMin,this.YWaveformMax,this.yAxisNameWithUnits,this.useAsConstant)},t.prototype.setWholeYRange=function(n){this.YWaveformMin=n.ymin;this.YWaveformMax=n.ymax;this.useAsConstant=n.useAsConstant;this.yAxisNameWithUnits=this.workOptions.getYAxisNameWithUnits(n.axisName)},t.prototype.setWholeXRange=function(n){this.xWaveformMin=n.xmin;this.xWaveformMax=n.xmax},t.prototype.getCurrentXRange=function(){return this.currentXRange},t.prototype.isViewAll=function(){var t=this.getCurrentXRange();return n.WaveUtils.almostEqual(t.xmin,this.xWaveformMin)&&n.WaveUtils.almostEqual(t.xmax,this.xWaveformMax)},t.prototype.getDataType=function(){return this.dataType},t.prototype.isLogXAxis=function(){return this.useLogXAxis},t.prototype.getYValueForX=function(n,t){return""+t},t.prototype.getFullWaveformName=function(){return this.waveformName},t.prototype.setWaveContainer=function(t){this.waveContainer=t;this.isRealEmptyWaveform||this.getColor()!=null||this.setColorIndex(n.SVW_Colors.getNextColorIndex())},t.prototype.getWaveContainer=function(){return this.waveContainer},t.prototype.setYAxis=function(n){this.yaxis=n},t.prototype.changeYUnits=function(t){n.WaveUtils.isStringEmpty(t)||(this.currentYUnits=t)},t.prototype.isEmptyWaveform=function(){return this.isRealEmptyWaveform},t.prototype.isConstantWaveform=function(){return this.getWholeYRange().useAsConstant},t.prototype.setAsEmptyWaveform=function(){this.isRealEmptyWaveform=!0},t.prototype.convertY=function(t){var i=this;return i instanceof n.DigitalWaveform?i.getStdLogicValue(t):t},t.prototype.isBus=function(){return n.WaveUtils.isBus(this.getWaveformType())},t.prototype.isStep=function(){return this.getWaveformType()==n.WaveManager.STEP_WF},t.prototype.isAnalogOrStep=function(){var t=this.getWaveformType();return t==n.WaveManager.ANALOG_WF||t==n.WaveManager.STEP_WF},t.prototype.isDigital=function(){var t=this.getWaveformType();return t==n.WaveManager.BIT_WF||t==n.WaveManager.BOOLEAN_WF||t==n.WaveManager.STD_LOGIC_WF},t.prototype.isDigitalToAnalogConvertible=function(){var t=this.getWaveformType();return t==n.WaveManager.BIT_WF||t==n.WaveManager.BOOLEAN_WF||t==n.WaveManager.STD_LOGIC_WF},t.prototype.isAnalogToDigitalConvertible=function(){var t=this.getWaveformType();return t==n.WaveManager.ANALOG_WF},t.prototype.isForInputControl=function(){return this.isAnalogOrStep()},t.prototype.initWaveform=function(t){this.waveformType=t.getWaveformType();this.signalName=t.getSignalName();this.label=n.WaveUtils.limitName(this.signalName);this.wfHandle=t.getWaveformHandle();t.isMetadataSet()&&(this.waveformName=this.getOriginalWaveformName(),this.dataType=t.getDataType(),this.currentXUnits=t.getXUnits(),this.currentYUnits=t.getYUnits(),this.currentYName=t.getYName(),this.currentXName=t.getXName(),this.setWholeXRange(t.getWholeXRange()),this.setWholeYRange(t.getWholeYRange()),this.useLogXAxis=t.isLogXAxis())},t.prototype.getYAxisNameWithUnits=function(){return this.yAxisNameWithUnits},t.prototype.getXMinMax=function(t){var u,i,f,e,r;if(this.isEmptyWaveform()||!i||i.length==0)return new n.XWaveRange(0,1);if(u=t.getWholeXRange(),u.xmin!=null&&u.xmax!=null)return u;if(i=this.getWaveformDataForFlot(),!i||i.length==0)return new n.XWaveRange(null,null);for(f=i[0][0],e=i[0][0],r=1;r<i.length;r++)i[r][0]<f&&(f=i[r][0]),e<i[r][0]&&(e=i[r][0]);return new n.XWaveRange(f,e)},t.prototype.getSchematicElementName=function(){var t,r,i;if(n.WaveUtils.isScalarForComplexWaveform(this.getSimpleWaveformName())){if(t=this.signalName.split("/"),t&&t.length>1){for(r=t[0],i=1;i<t.length-1;i++)r+=PATH_SEPARATOR+t[i];return r}return this.signalName}return this.isBus?n.WaveUtils.getNameWithoutSuffix(this.signalName):this.signalName},t.prototype.getSimpleWaveformName=function(){var n=this.signalName.split("/");return n&&n.length>1?n[n.length-1]:this.signalName},t.prototype.getOriginalWaveformName=function(){return this.signalName},t.prototype.getXUnits=function(){return this.currentXUnits},t.prototype.getYUnits=function(){return this.currentYUnits},t.prototype.getXName=function(){return this.currentXName},t.prototype.getYName=function(){return this.currentYName},t.prototype.setElement=function(n,t,i,r,u){this.element=r.element;this.elementOutline=r.elementOutline;this.pathArray=r.pathArray;this.parentRow=t;var f=this;this.plot=i;this.paper=i.getPaper();this.waveContainer=n;this.yaxis=r.yaxis;this.xaxis=r.xaxis;u&&(this.addEventHandlers(),this.setMenu())},t.prototype.updateListeners=function(){this.addEventHandlers()},t.prototype.getEventHolder=function(){return this.elementOutline},t.prototype.getPaper=function(){return this.paper},t.prototype.getVisibleYRange=function(){var i=this.getYAxisNameWithUnits(),t;return this.plot?(t=this.plotGetYVisibleRange(i),t?new n.YWaveRange(t.from,t.to,i,this.getWholeYRange().useAsConstant):this.parentRow.getYVisibleRange(this)):this.parentRow.getYVisibleRange(this)},t.prototype.setPlot=function(n){this.plot=n},t.prototype.highlightWaveform=function(t){var i=this.element,r;i&&(r=this,t?i.attr({"stroke-width":3}):i.attr({"stroke-width":n.WaveManager.WAVEFORM_WIDTH}),this.pathArray&&this.pathArray.forEach(function(i){t?i.attr({"stroke-width":3}):i.attr({"stroke-width":n.WaveManager.WAVEFORM_WIDTH})}))},t.prototype.highlightWaveformAndLegend=function(n){var r=this.parentRow.getPlotArea().getOptions().legend.labelBoxBorderColor,t=this.getLegendLabelForWaveform(),i=this.getColorBoxForLegendLabel(t);this.highlightWaveform(n);n?(this.parentRow.highlightLegendLabel(t,this.getColor(),!0),this.parentRow.highlightLegendBox(i,this.getColor())):(this.parentRow.highlightLegendLabel(t,"transparent",!1),this.parentRow.highlightLegendBox(i,r))},t.prototype.getLegendLabelForWaveform=function(){var t="#legend"+this.parentRow.getRowId(),i=this,n=null;return $(t).find("div.legendLabel").each(function(t,r){var u=r.id;if(u&&u=="legendLabel"+i.waveformId){n=this;return}}),n},t.prototype.getColorBoxForLegendLabel=function(n){return $(n).closest("td").prev("td.legendColorBox")},t.prototype.updateWaveformLegendColor=function(){var n=this.getLegendLabelForWaveform(),t=this.getColorBoxForLegendLabel(n);$(t).children(":first").children(":first").css("border-color",this.getColor())},t.prototype.getNumberOfVisiblePoints=function(){for(var t,u,f=0,e=this.parentRow.getPlotArea().getData()[0].data,i=null,n=this.waveContainer.getDomainAxis().getPlotArea().getAxes().xaxis,o=n.min,s=n.max,r=0;r<e.length;r++)t=e[r],u=t[0],t[0]>o&&t[0]<s&&(i==null||Math.abs(n.p2c(u)-n.p2c(i))>=1)&&(i=u,f++);return f},t.prototype.addEventHandlers=function(){var r=this,i=this.getEventHolder();if(i){var t=this,u=function(){n.SVWEventHandler.getIsMoving()||(n.getManager().getCrossHighlightManager().crossHighlightByWaveform(t,!0),t.showZoomInMessage())},f=function(){n.getManager().getCrossHighlightManager().crossHighlightByWaveform(t,!1)};i.hover(u,f);this.waveContainer.isInWaveBox()||i.click(function(){t.parentRow.clickHandle(t)});var e=function(r,u,f){if(n.SVWEventHandler.isLeftMouseButtonEvent(f)&&!n.SVWEventHandler.getIsMoving()){n.SVWEventHandler.setIsMoving(i);var e=t.waveContainer.createTail(t.waveformName,t.getColor(),f);return setBodyCursor("move"),t.addEscListener(),{}}},o=function(r,u,f,e,o){if(n.SVWEventHandler.getIsMoving()==i){var s=t.getWaveContainer().allowToDrop(o.pageX,o.pageY,t,!0);return s!=n.ALLOW_DROP.IN_ROW?setBodyCursor("not-allowed"):setBodyCursor("move"),{}}},s=function(r){if(n.SVWEventHandler.getIsMoving()==i)return n.SVWEventHandler.setIsMoving(null),setBodyCursor("auto"),n.getManager().canDragWaveform()?t.waveContainer.performDropState(!1,t,r.pageX,r.pageY):t.removeEscListener(),{}};this.waveContainer.isInWaveBox()?(i.mousedown(function(n){r.triggerSelectionOnRow(n)}),i.mousemove(function(n){r.triggerSelectionOnRow(n)}),i.mouseup(function(n){r.triggerSelectionOnRow(n)})):i.drag(o,e,s)}},t.prototype.showZoomInMessage=function(){if(!this.workOptions.canZoomYAxis()&&n.getManager().isWindowMode()&&this.parentRow.getRowWidth()<this.getNumberOfVisiblePoints()*3)t.NotificationContainer=this.waveContainer,Project.MessageManager.showInfoMessage("Select an area to zoom",!0,1e3,this.positionZoomInMessage)},t.prototype.positionZoomInMessage=function(n){var i,f;if(!$("."+n.sender._guid)[1]){var e=n.element.parent(),r=t.NotificationContainer.getWaveContainerJQ().offset(),u=r.top;t.NotificationContainer.isInWaveBox()&&(u-=30);n.element.parent().css({top:u,left:r.left});i=5e4;f=Project.KendoHelper.getKendoWindowMaxZIndex();i=f+1e3;n.element.parent().css({zIndex:i})}},t.prototype.triggerSelectionOnRow=function(n){var i,r,t;n.preventDefault();n.stopPropagation();i=document.createEvent("MouseEvent");i.initMouseEvent(n.type,!0,!0,n.view,n.detail,n.screenX,n.screenY,n.clientX,n.clientY,n.ctrlKey,n.altKey,n.shiftKey,n.metaKey,n.button,document.body.parentNode);r=this.parentRow.getRowJQ()[0];r&&(t=r.getElementsByTagName("svg"),t&&t.length>0&&t[0].dispatchEvent(i))},t.prototype.addEscListener=function(){$(document).bind("keydown.waveformDrag",function(t){t.which==Project.Design.EscKey&&(n.getManager().cancelWaveformDragging(),$("body").trigger("mouseup"))})},t.prototype.removeEscListener=function(){$(document).unbind("keydown.waveformDrag")},t.getEmptyWaveform=function(){var i=new n.WaveformInfo(null,null);return t.createWaveform(i,null,null,!0)},t.prototype.setColorIndex=function(n){n>=0&&(this.colorIndex=n)},t.prototype.setCustomColor=function(n){n&&(this.customColor=n)},t.prototype.getColor=function(){return this.customColor?this.customColor:(this.colorIndex<0&&(this.colorIndex=n.SVW_Colors.getNextColorIndex()),n.SVW_Colors.getColorByIndex(this.colorIndex,this.getWaveContainer()))},t.prototype.getColorIndex=function(){return this.colorIndex},t.prototype.remove=function(n){n&&this.removeMenu(n);this.element&&this.element.remove();this.elementOutline&&this.elementOutline.remove();this.pathArray&&this.pathArray.remove()},t.prototype.shade=function(){this.element&&this.element.attr("stroke-opacity",ProbeModule.WaveBoxManager.WAVEFORM_OPACITY)},t.prototype.plotBusBits=function(n){n.plotBits()},t.prototype.clearBusBits=function(n){n.clearBits()},t.prototype.setWaveformColor=function(n){this.setCustomColor(n);this.waveContainer.isInWaveBox()&&this.waveContainer.changeColorInWaveBox(n,this.sourceInfo);this.getWaveContainer().redraw()},t.prototype.setTransformedWaveform=function(n,t){var r=t,i=n.waveContainer.getWavebox();i&&i.setTransformedWaveform(r,n.sourceInfo.objectIndex)},t.prototype.createMenu=function(){var t,i;this.waveformMenu||(t=new n.MenuDriver(this),this.waveformMenu=t.createMenu());this.waveContainer.isInWaveBox()||this.legendMenu||(i=new n.MenuDriver(this,!0),this.legendMenu=i.createMenu())},t.prototype.setMenu=function(){this.createMenu();this.bindMenu()},t.prototype.bindMenu=function(){if(this.waveformMenu&&this.waveformMenu.bindMenuTo($("#"+this.waveformId)),this.legendMenu&&!this.waveContainer.isInWaveBox()){this.legendMenu.bindMenuTo("#legendLabel"+this.waveformId);var t=this.getLegendLabelForWaveform(),n=this.getColorBoxForLegendLabel(t);n&&this.legendMenu.bindMenuTo(n)}},t.prototype.updateMenu=function(){this.removeMenu(!0);this.setMenu()},t.prototype.removeMenu=function(n){(this.waveformMenu||this.legendMenu)&&this.unbindMenu(n);this.waveformMenu&&(this.waveformMenu.removeMenu(),this.waveformMenu=null);this.legendMenu&&(this.legendMenu.removeMenu(),this.legendMenu=null)},t.prototype.unbindMenu=function(n){if(this.waveformMenu&&this.waveformMenu.unbindMenuFrom($("#"+this.waveformId),n),this.legendMenu&&!this.waveContainer.isInWaveBox()){this.legendMenu.unbindMenuFrom("#legendLabel"+this.waveformId,n);var t=this.getLegendLabelForWaveform(),i=this.getColorBoxForLegendLabel(t);this.legendMenu.unbindMenuFrom(i,n)}},t.prototype.getMiddleLevel=function(){return(this.YWaveformMin+this.YWaveformMax)/2},t.prototype.getMiddlePoint=function(){var n=this.waveContainer.getXAxisState(),t=n.range.xmin,i=n.range.xmax,r=.01*(i-t);return(t+i)/2},t.GLOBAL_WAVEFORM_ID=0,t.isDataEmpty=function(n){return n?n.isEmptyWaveform()?!0:!1:!0},t}(),r,i,t;n.Waveform=u;r=function(){function n(n,t,i){this.x=n;this.y=t;this.value=i}return n}();n.WaveformPoint=r;i=function(){function i(){this.showPoints=!1;this.isViewAllForY=!0;this.currentXUnits=n.WaveManager.NO_UNITS;this.currentYUnits=n.WaveManager.NO_UNITS;this.currentYName=n.WaveManager.NO_UNITS;this.currentXName=n.WaveManager.NO_UNITS;this.useLogXAxis=!1}return i.prototype.saveState=function(n){this.simulationId=n.simulationId;this.waveformId=n.getFlotWaveformId();this.yVisibleRange=n.parentRow.getYVisibleRange(n);this.isViewAllForY=n.parentRow.isViewAllForY(this.yVisibleRange.axisName);this.waveformType=n.getWaveformType();this.currentXUnits=n.getXUnits();this.currentYUnits=n.getYUnits();this.currentYName=n.getYName();this.currentXName=n.getXName();this.wfId=n.getWaveformHandle();this.wdbId=n.wdbId;this.useLogXAxis=n.isLogXAxis();this.colorIndex=n.getColorIndex();this.waveformColor=n.getColor();this.showPoints=n.points.show;this.sourceInfo=n.sourceInfo},i.prototype.setState=function(i){this.simulationId=i.simulationId;this.waveformId=i.waveformId;this.yVisibleRange=i.yVisibleRange?new n.YWaveRange(i.yVisibleRange):new n.YWaveRange(null,null,n.WaveManager.NO_UNITS,!0);this.isViewAllForY=i.isViewAllForY;this.waveformType=i.waveformType;this.currentXUnits=i.currentXUnits;this.currentYUnits=i.currentYUnits;this.currentYName=i.currentYName;this.currentXName=i.currentXName;this.wfId=i.wfId;this.wdbId=i.wdbId;this.useLogXAxis=i.useLogXAxis;this.colorIndex=i.colorIndex;this.waveformColor=i.waveformColor;this.showPoints=i.showPoints;this.sourceInfo=i.sourceInfo?i.sourceInfo:t.createSourceInfoForViewer()},i.prototype.getSourceInfo=function(){return this.sourceInfo||(this.sourceInfo=t.createSourceInfoForViewer()),this.sourceInfo},i.prototype.getFlotWaveformId=function(){return this.waveformId},i}();n.WaveformState=i;t=function(){function n(t,i,r){var u,f;this.objectIndex=n.WAVEBOX_INDEX;this.forProbe=!0;this.waveformState=t;this.forProbe=r;t&&t.typeId==ServerStructures.WaveformStateType.PROBE?(u=t,this.objectIndex=u.probeIndex):t&&t.typeId==ServerStructures.WaveformStateType.CALCULATOR&&(f=new ServerStructures.CalculatorWaveformState,this.objectIndex=n.CALCULATOR_INDEX);this.containerUniqName=i}return n.prototype.isForTheProbe=function(n){return this.forProbe&&this.objectIndex==n},n.createSourceInfoForProbe=function(t,i){var r=new ServerStructures.ProbeWaveformState;return r.probeIndex=t,new n(r,i,!0)},n.createSourceInfoForCalcWf=function(t,i,r){var u=new ServerStructures.CalculatorWaveformState;return u.probeIndices=r,new n(u,i,!1)},n.createSourceInfoForViewer=function(){var t=new ServerStructures.ProbeWaveformState;return t.probeIndex=n.VIEWER_CONTAINER_INDEX,new n(t,n.VIEWER_CONTAINER_NAME,!1)},n.prototype.isCalculatorWaveformForProbe=function(n,t){return this.waveformState?t==ProbeModule.PlotMode.CALCULATOR?!0:this.objectIndex==n:!1},n.isProbeIndex=function(n){return n>=0},n.VIEWER_CONTAINER_NAME="Viewer",n.VIEWER_CONTAINER_INDEX=-1e3,n.CALCULATOR_INDEX=-2e3,n.WAVEBOX_INDEX=-1,n}();n.SourceInfo=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r){t.call(this,n,i,r)}return __extends(i,t),i.prototype.getWaveformType=function(){return n.WaveManager.ANALOG_WF},i.prototype.getCursorFlagText=function(n,t,i){return i},i.prototype.findNearestPoint=function(n){for(var s,h,u,r,e,f=this.getWaveformDataForFlot(),o=f.length,c=Math.ceil(o/1e3),i=-1,t=1;t<c;t++)if(n<=f[t*1e3][0]){i=t-1;break}for(s=!1,i<0&&(i=c-1,s=!0),h=s?Math.ceil((o-i*1e3)/100):10,u=-1,t=1;t<h;t++)if(n<=f[i*1e3+t*100][0]){u=t-1;break}for(u<0&&(u=h-1),r=0,e=0;e<101;e++)if(r=i*1e3+u*100+e,r<o){if(f[r][0]>n)break}else{r-=1;break}return r},i.prototype.getIntersectionPoint=function(t,i){var u,h,f,a,o,l,s;if(t<this.getXWaveformMin()||t>this.getXWaveformMax())return null;if(u=this.getWaveformDataForFlot(),i&&i.isYValueResolved(this))return h=i.getYValueForCursorGroup(this),s=n.getManager().getFormattedCursorYValue(h.YValue,this),new n.WaveformPoint(t,h.YValue,s);for(f=-1,a=this.findNearestPoint(t),o=a;o<u.length;o++)if(u[o][0]>t){f=o;break}f<0&&(f=u.length-1);var v=this.yaxis,c,r=u[f-1],e=u[f],y=r==null||!n.WaveUtils.isCorrectValue(r[1]),p=e==null||!n.WaveUtils.isCorrectValue(e[1]);return y&&p?(l=n.WaveUtils.getInfiniteRepresentation(r[1],v.min,v.max),new n.WaveformPoint(t,l.val,l.name)):(c=y?e[1]:p?r[1]:e[0]==r[0]?r[1]:r[1]+(e[1]-r[1])*(t-r[0])/(e[0]-r[0]),s=n.getManager().getFormattedCursorYValue(c,this),new n.WaveformPoint(t,c,s))},i}(n.Waveform);n.AnalogWaveform=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.prototype.getCursorFlagText=function(n,t,i){return"'"+i+"'"},i.prototype.getIntersectionPoint=function(t,i){var o,s,r,u,e,f,h;if(t<this.getXWaveformMin()||t>this.getXWaveformMax())return null;if(i&&i.isYValueResolved(this))return o=i.getYValueForCursorGroup(this),s=this.getStdLogicValue(o.YValue),new n.WaveformPoint(t,s,this.getStringByValue(o.YValue));if(r=this.getWaveformDataForFlot(),e=!1,t<this.getXWaveformMin()?(u=r[0][1],e=!0):t>this.getXWaveformMax()&&(u=r[r.length-1][1],e=!0),!e){for(f=0;f<r.length;++f)if(r[f][0]>t)break;u=r[f-1][1]}return h=this.getStdLogicValue(u),new n.WaveformPoint(t,h,this.getStringByValue(u))},i.LO=0,i.HI=1,i.MID=.5,i.SLOGIC_U=0,i.SLOGIC_X=1,i.SLOGIC_0=2,i.SLOGIC_1=3,i.SLOGIC_Z=4,i.SLOGIC_W=5,i.SLOGIC_L=6,i.SLOGIC_H=7,i.SLOGIC_M=8,i.SLOGIC_MAX_INDEX=8,i.DIGITAL_MIN=0,i.DIGITAL_MAX=1,i.BUS_MIN=-.5,i.BUS_MAX=1.5,i}(n.Waveform);n.DigitalWaveform=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.prototype.getWaveformType=function(){return n.WaveManager.STEP_WF},i.prototype.getCursorFlagText=function(n,t,i){return i},i.prototype.getIntersectionPoint=function(t,i){var r=this.getWaveformDataForFlot(),o=!1,u,s,f,e;if(i&&i.isYValueResolved(this))return s=i.getYValueForCursorGroup(this),e=n.getManager().getFormattedCursorYValue(s.YValue,this),new n.WaveformPoint(t,s.YValue,e);if(t<this.getXWaveformMin()?(u=r[0][1],o=!0):t>this.getXWaveformMax()&&(u=r[r.length-1][1],o=!0),!o){for(f=0;f<r.length;++f)if(r[f][0]>t)break;u=r[f-1][1]}return e=n.getManager().getFormattedCursorYValue(u,this),new n.WaveformPoint(t,u,e)},i}(n.Waveform);n.StepWaveform=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.prototype.getWaveformType=function(){return n.WaveManager.STD_LOGIC_WF},i.prototype.getStdLogicValue=function(t){switch(t){case n.DigitalWaveform.SLOGIC_U:return n.DigitalWaveform.MID;case n.DigitalWaveform.SLOGIC_X:return n.DigitalWaveform.MID;case n.DigitalWaveform.SLOGIC_0:return n.DigitalWaveform.LO;case n.DigitalWaveform.SLOGIC_1:return n.DigitalWaveform.HI;case n.DigitalWaveform.SLOGIC_Z:return n.DigitalWaveform.MID;case n.DigitalWaveform.SLOGIC_W:return n.DigitalWaveform.MID;case n.DigitalWaveform.SLOGIC_L:return n.DigitalWaveform.LO;case n.DigitalWaveform.SLOGIC_H:return n.DigitalWaveform.HI;case n.DigitalWaveform.SLOGIC_M:return n.DigitalWaveform.MID;default:return n.DigitalWaveform.MID}},i.prototype.getStringByValue=function(t){switch(t){case n.DigitalWaveform.SLOGIC_U:return"U";case n.DigitalWaveform.SLOGIC_X:return"X";case n.DigitalWaveform.SLOGIC_0:return"0";case n.DigitalWaveform.SLOGIC_1:return"1";case n.DigitalWaveform.SLOGIC_Z:return"Z";case n.DigitalWaveform.SLOGIC_W:return"W";case n.DigitalWaveform.SLOGIC_L:return"L";case n.DigitalWaveform.SLOGIC_H:return"H";case n.DigitalWaveform.SLOGIC_M:return"-"}return"undefined"},i}(n.DigitalWaveform);n.StdLogicWaveform=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.prototype.getWaveformType=function(){return n.WaveManager.BOOLEAN_WF},i.prototype.getStdLogicValue=function(n){switch(n){case i.BOOL_FALSE:return i.LO;case i.BOOL_TRUE:return i.HI;default:return i.LO}},i.prototype.getStringByValue=function(n){switch(n){case i.BOOL_FALSE:return"0";case i.BOOL_TRUE:return"1"}return"undefined"},i.LO=0,i.HI=1,i.BOOL_FALSE=0,i.BOOL_TRUE=1,i.BOOL_MAX_INDEX=1,i}(n.DigitalWaveform);n.BooleanWaveform=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.prototype.getWaveformType=function(){return n.WaveManager.BIT_WF},i.prototype.getStdLogicValue=function(n){switch(n){case i.BIT_0:return i.LO;case i.BIT_1:return i.HI;default:return i.LO}},i.prototype.getStringByValue=function(n){switch(n){case i.BIT_0:return"0";case i.BIT_1:return"1"}return"undefined"},i.LO=0,i.HI=1,i.BIT_0=0,i.BIT_1=1,i}(n.DigitalWaveform);n.BitWaveform=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.prototype.getWaveformType=function(){return n.WaveManager.BUS},i.prototype.getIntersectionPoint=function(t,i){var o,u,h;if(t<this.getXWaveformMin()||t>this.getXWaveformMax())return null;if(i&&i.isYValueResolved(this))return o=i.getYValueForCursorGroup(this),new n.WaveformPoint(t,n.DigitalWaveform.MID,o.YValue);var r=this.getWaveformDataForFlot(),s,e=!1,f=0;if(t<this.getXWaveformMin()?(s=r[0][1],f=0,e=!0):t>this.getXWaveformMax()&&(s=r[r.length-1][1],f=r.length-1,e=!0),!e)for(u=0;u<r.length;u++)if(r[u][0]>t){f=u==0?0:u-1;break}return h=this.yValues[f],new n.WaveformPoint(t,n.DigitalWaveform.MID,h)},i.prototype.getStdLogicValue=function(){return n.DigitalWaveform.MID},i.prototype.getStringByValue=function(){return"undefined"},i.prototype.plotBits=function(){var t=this,r=n.getManager().getBusBitNodes(this.simulationId,this.getWaveformHandle()),i;if(r){this.getWaveContainer().showSpinner();var s=this.getWaveContainer().getXAxisState().isViewAll,u=n.WaveUtils.getRequestRange(this.getWaveContainer().getXAxisState(),s),h=u.range.xmin,c=u.range.xmax,f=new ServerStructures.DesignDataRequest,e=new ServerStructures.ContainerDataRequest(0);for(i=0;i<r.length;i++){var o=new ServerStructures.RowDataRequest(i),l=r[i],a=n.WaveUtils.createWaveformDataRequestElem(this.simulationId,l.Id,h,c,!0,this.wdbId,this.getColor(),n.PAN_DIRECTION.NONE,!1,0,this.sourceInfo);o.putWaveformElement(a);e.putRowRequest(o)}f.putContainerRequest(e);$.when(n.ViewerRequests.createAndInitWaveforms(f)).done(function(n){var r,i,u;if(n&&n.containers)for(r=n.containers[0],i=0;i<r.getAmount();i++)u=r.getRowWaveforms(i),u&&$.when(t.getWaveContainer().addAndPlotWaveforms(u,!1)).done(function(){t.getWaveContainer().hideSpinner()}).fail(function(){t.getWaveContainer().hideSpinner()});else t.getWaveContainer().hideSpinner()}).fail(function(){t.getWaveContainer().hideSpinner()})}},i.prototype.getPlottedBits=function(){var e=[],u=n.getManager().getBusBitNodes(this.simulationId,this.getWaveformHandle()),f,t,i,r;if(u)for(f=this.getWaveContainer().getPlottedWaveforms(),t=0;t<u.length;t++)for(i=0;i<f.length;i++)r=f[i],r.wdbId==this.wdbId&&r.getWaveformHandle()==u[t].Id&&e.push(r);return e},i.prototype.setWaveformColor=function(n){this.setCustomColor(n);this.getWaveContainer().isInWaveBox()?this.getWaveContainer().changeColorInWaveBox(n,this.sourceInfo):this.changeBitsColor();this.getWaveContainer().redraw()},i.prototype.changeBitsColor=function(){var t,n;for(this.getWaveContainer().showSpinner(),t=this.getPlottedBits(),n=0;n<t.length;n++)t[n].setCustomColor(this.getColor());this.getWaveContainer().redraw();this.getWaveContainer().hideSpinner()},i.prototype.clearBits=function(){for(var t=this.getPlottedBits(),n=0;n<t.length;n++)this.getWaveContainer().deleteWaveformFromParentRow(t[n],!1);this.getWaveContainer().redraw();this.getWaveContainer().hideSpinner()},i}(n.DigitalWaveform);n.BusWaveform=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this,n,i)}return __extends(i,t),i.prototype.getWaveformType=function(){return n.WaveManager.ENUMERATED_WF},i.prototype.getIntersectionPoint=function(t,i){var o,u,h;if(t<this.getXWaveformMin()||t>this.getXWaveformMax())return null;if(i&&i.isYValueResolved(this))return o=i.getYValueForCursorGroup(this),new n.WaveformPoint(t,n.BusWaveform.MID,o.YValue);var r=this.getWaveformDataForFlot(),s,e=!1,f=0;if(t<this.getXWaveformMin()?(s=r[0][1],f=0,e=!0):t>this.getXWaveformMax()&&(s=r[r.length-1][1],f=r.length-1,e=!0),!e)for(u=0;u<r.length;u++)if(r[u][0]>t){f=u==0?0:u-1;break}return h=this.yValues[f],new n.WaveformPoint(t,n.BusWaveform.MID,h)},i.prototype.getStdLogicValue=function(){return n.DigitalWaveform.MID},i.prototype.getStringByValue=function(){return"undefined"},i}(n.DigitalWaveform);n.EnumWaveform=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function n(){}return n.setIsMoving=function(t){n.isMoving=t},n.getIsMoving=function(){return n.isMoving},n.isLeftMouseButtonEvent=function(n){return n.which==1},n.isRightMouseButtonEvent=function(n){return n.which==3},n.isMoving=null,n}();n.SVWEventHandler=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){function w(){return s||(s=new t),s}var y,p,t,s,h,c,f,l,a,b,k,v,i,u,r,e,o;(function(n){n[n.PREVIOUS=0]="PREVIOUS";n[n.NEXT=1]="NEXT";n[n.ALL=2]="ALL"})(n.SIMULATION_FOR_SEARCH||(n.SIMULATION_FOR_SEARCH={}));y=n.SIMULATION_FOR_SEARCH,function(n){n[n.BY_STATE=0]="BY_STATE";n[n.BY_SIMULATION=1]="BY_SIMULATION"}(n.UPDATING_MODE||(n.UPDATING_MODE={}));p=n.UPDATING_MODE;t=function(){function t(){this.waveContainers=[];this.cancelWaveformDrag=!1;this.windowMode=!1;this.wdbMetadataCache=[];this.waveformDataCacheForAll=[];this.waveformDataCacheForRange=[];this.waveformInfoCache=[]}return t.getUUID=function(){return Project.Settings.UUID?Project.Settings.UUID:"anonymous"},t.prototype.getSurface=function(){return $("#schematic").length?surface:null},t.prototype.getDlIFrame=function(){return this.getSurface()!=null?this.getSurface().getDlIFrameSchematic():this.getViewerWindow().getIFrameViewer()},t.prototype.setChildBrowserWindow=function(n){this.childBrowserWindow=n?n:null},t.prototype.getChildBrowserWindow=function(){return this.childBrowserWindow},t.prototype.setViewerWindow=function(n){this.viewerWindow=n},t.prototype.getViewerWindow=function(){return this.childBrowserWindow?this.childBrowserWindow.getViewerWin():this.viewerWindow},t.prototype.getDesign=function(){return this.childBrowserWindow?surface.getDesign():null},t.prototype.getParentViewerWindow=function(){return this.viewerWindow},t.prototype.getCrossHighlightManager=function(){return new Project.CrossHighlightManager},t.prototype.cancelWaveformDragging=function(){this.cancelWaveformDrag=!0;setBodyCursor("auto")},t.prototype.resetWaveformDragging=function(){this.cancelWaveformDrag=!1;setBodyCursor("auto");$(document).unbind("keydown.waveformDrag")},t.prototype.canDragWaveform=function(){return!this.cancelWaveformDrag},t.prototype.getTreeJQ=function(){var n=this.getViewerWindow();return n.getTreeJQ()},t.prototype.getTreeView=function(){var n=this.getTreeJQ();return n.data("kendoTreeView")},t.prototype.isWindowMode=function(){return this.windowMode},t.prototype.setWindowMode=function(n){this.windowMode=n},t.prototype.showViewer=function(){$(MAIN_EDITOR).data("kendoSplitter").expand(VIEWER_PANE)},t.prototype.hideViewer=function(){$(MAIN_EDITOR).data("kendoSplitter").collapse(VIEWER_PANE)},t.prototype.addWaveContainer=function(n){this.waveContainers.push(n)},t.prototype.getFormattedCursorYValue=function(t,i){var u=i.yaxis,f=null,e=null,r,o,s;return t>=n.WaveUtils.AS_NAN_LEVEL?n.WaveUtils.SHOW_NAN:t>=n.WaveUtils.AS_INFINITY_LEVEL?n.WaveUtils.SHOW_POS_INFINITY:t<=-n.WaveUtils.AS_INFINITY_LEVEL?n.WaveUtils.SHOW_NEG_INFINITY:(r=i.getYUnits(),o=r==null||r=="-"||r==""?"":r.trim(),u&&(f=u.min,e=u.max),f!=null&&e!=null)?(s=new n.AxisUnits(f,e,!0),s.formatCursorValue(t,!1)):t.toString()+" "+o},t.prototype.highlightSchematicElement=function(n,t,i){if(this.isWindowMode())i?this.getParentViewerWindow().getSurface().getDesign().crossHighlight(n,t):this.getParentViewerWindow().getSurface().getDesign().crossUnhighlight(n,t);else if(window.opener){var r=i?"crossHighlight":"crossUnhighlight";window.opener.postMessage({action:r,nodeName:n,isFolder:t},"*")}},t.prototype.plotWaveformInViewer=function(n){if(n)if(this.getChildBrowserWindow()){var t=this.getChildBrowserWindow().getViewerWin();t.plotWaveformByHandle(n.simulationId,n.getWaveformHandle(),n.wdbId,n.getColor(),n.isBus())}else this.viewerWindow.enableAndOpen(),this.getViewerWindow().plotWaveformByHandle(n.simulationId,n.getWaveformHandle(),n.wdbId,n.getColor(),n.isBus())},t.prototype.plotInViewerFromWavebox=function(n){if(this.getChildBrowserWindow()){var t=this.getChildBrowserWindow().getViewerWin();t.plotWaveformsFromWavebox(n)}else this.viewerWindow.enableAndOpen(),this.getViewerWindow().plotWaveformsFromWavebox(n)},t.prototype.copyWaveformRangeDataInCache=function(t,i){for(var r,u=0;u<t.length;u++)r=t[u],r&&!r.isEmptyWaveform()&&this.copyRangeDataInCache(r.simulationId,r.getWaveformHandle(),i,n.SourceInfo.VIEWER_CONTAINER_NAME)},t.prototype.getWdbMetadataFromCache=function(n){return this.wdbMetadataCache[n]},t.prototype.getWaveformNodes=function(n,t){var u=this.wdbMetadataCache[n],e,f,r,i;if(u&&t)for(e=t.toLowerCase(),f=[],r=0;r<u.Children.length;r++)i=u.Children[r],i&&i.Name&&i.Name.indexOf(e+PATH_SEPARATOR)==0&&f.push(i);return f},t.prototype.getBusBitNodes=function(n,t){var f=this.wdbMetadataCache[n],u,e,i,r;if(f&&t){for(u=null,e=[],i=0;i<f.Children.length;i++)if(r=f.Children[i],r&&r.Name&&r.Id==t){u=r;break}if(u)for(i=0;i<u.Children.length;i++)r=u.Children[i],e.push(r)}return e},t.prototype.putWdbMetadataToCache=function(n,t){return this.wdbMetadataCache[n]=t,t},t.prototype.removeWdbMetadataFromCache=function(n){var t=this.wdbMetadataCache[n];t&&this.wdbMetadataCache.splice($.inArray(t,this.wdbMetadataCache),1);t=null},t.prototype.createWaveformInfosForWdb=function(t){var i=n.getManager().getWdbMetadataFromCache(t.simulationId);i&&this.createWaveformInfo(i,t.simulationId,t.wdbId)},t.prototype.createWaveformInfo=function(t,i,r){var f,u,e;if(n.WaveUtils.isWaveform(t.Type))f=new n.WaveformInfo(i,r,t),this.putWaveformInfoToCache(f);else if(t.Children)for(u=0;u<t.Children.length;u++)e=t.Children[u],this.createWaveformInfo(e,i,r)},t.prototype.extractHandle=function(n){if(!n)return null;if(this.isWfHandle(n)){var t=n.split(":"),i=t[0],r=new RegExp(i+":","g");return n.replace(r,"<")}return n},t.prototype.isWfHandle=function(n){if(n.indexOf("[")>=0)return!1;var t=n.split(":");return t.length>1},t.prototype.putWaveformInfoToCache=function(n){var r,i,u,t;n&&(r=n.getWaveformHandle(),r)&&(i=this.extractHandle(r),i&&(u=n.getSimulationId(),t=this.waveformInfoCache[u],t?t[i]=n:(t=[],t[i]=n,this.waveformInfoCache[u]=t)))},t.prototype.getComponentInfoList=function(n,t){var u=[],r,f,i;if(n&&(r=this.waveformInfoCache[n],r))for(f in r)i=r[f],i&&i.getSignalName()&&i.getSignalName().indexOf(t+PATH_SEPARATOR)==0&&u.push(i);return u},t.prototype.getWaveformDataFromCache=function(n,t,i,r){var u=this.getWaveformDataFromCacheForAll(n,t);return i?u:u&&u.isResolvedOnRange?u:this.getWaveformDataFromCacheForRange(n,t,r)},t.prototype.getWaveformDataFromCacheForAll=function(n,t){var i,r;return!n||!t?null:(i=this.waveformDataCacheForAll[n],i&&(r=this.extractHandle(t),r))?i[r]:null},t.prototype.getWaveformDataFromCacheForRange=function(n,t,i){var r,u;return!n||!t||!i?null:(r=this.waveformDataCacheForRange[n],r&&(u=this.extractHandle(t),u&&r[u]))?r[u][i]:null},t.prototype.copyRangeDataInCache=function(t,i,r,u){var f=n.getManager().getWaveformDataFromCache(t,i,!1,r);f&&!f.isWholeRange&&this.putWaveformDataToCache(t,i,f,u)},t.prototype.putWaveformDataToCache=function(n,t,i,r){return i.isWholeRange?this.putWaveformDataForAll(n,t,i):this.putWaveformDataForRange(n,t,i,r)},t.prototype.putWaveformDataForAll=function(n,t,i){if(!n||!t)return null;var r=this.waveformDataCacheForAll[n],u=this.extractHandle(t);return u?(r?r[u]=i:(r=[],r[u]=i,this.waveformDataCacheForAll[n]=r),i):null},t.prototype.putWaveformDataForRange=function(n,t,i,r){if(!n||!t||!r)return null;var u=this.waveformDataCacheForRange[n],f=this.extractHandle(t);return f?(u||(u=[]),u[f]||(u[f]=[]),u[f][r]=i,this.waveformDataCacheForRange[n]=u,i):null},t.prototype.clearWaveformDataForRange=function(n,t,i){var e,r,o,s,u,f;if(n&&i)for(e=t.getPlottedWaveforms(),r=0;r<e.length;r++)o=e[r],o.isEmptyWaveform()||(s=o.getWaveformHandle(),u=this.waveformDataCacheForRange[n],u&&s&&(f=this.extractHandle(s),f&&u[f]&&(u[f][i]=null)))},t.prototype.removeWaveformsFromCache=function(n){var r=this.waveformDataCacheForAll[n],u,i,t,f;if(r)for(t=r.length-1;t>=0;t--)if(u=r[t],u){r.splice(t,1);u=null;break}if(i=this.waveformDataCacheForAll[n],i=this.waveformDataCacheForRange[n],i)for(t=i.length-1;t>=0;t--)if(f=i[t],f){i.splice(t,1);f=null;break}},t.prototype.triggerZoom=function(){var t=n.SVWEventHandler.getIsMoving(),i,r;t instanceof n.DomainAxis&&(i=t,i.getRowJQ().trigger("mouseup"));t instanceof n.WaveRow&&(r=t,r.getRowJQ().trigger("mouseup"))},t.prototype.isWaveformInWdb=function(t,i){var r=n.getManager().getWaveformInfoFromCache(t,null,i,!1);return r!=null},t.prototype.getWaveformInfoFromCache=function(n,t,i,r){if(t){var u=this.getWaveformInfoByHandle(n,t,r);if(u)return u}return i?this.getWaveformInfoByName(n,i,r):null},t.prototype.getWaveformInfoByHandle=function(n,t,i){var r,u,f;return!n||!t?null:(r=this.extractHandle(t),!r)?null:(u=this.waveformInfoCache[n],u&&(f=u[r],f!=null))?f:i?this.createWaveformInfoByHandle(n,t):null},t.prototype.getWaveformInfoByName=function(n,t,i){var u,f,r;if(n){if(this.waveformInfoCache||(this.waveformInfoCache=[]),u=this.waveformInfoCache[n],u)for(f in u)if(r=u[f],r&&r.getSignalName()&&r.getSignalName()==t)return r;if(i)return this.createWaveformInfoByName(n,t)}return null},t.prototype.createWaveformInfoByName=function(t,i){var f=this.getViewerWindow(),e,r,o,u;return f&&(e=this.wdbMetadataCache[t],e&&(r=this.getTreeNode(t,null,i),r))?(o=f.getWdbIdBySimulationId(t),u=new n.WaveformInfo(t,o,r),this.putWaveformInfoToCache(u),u):null},t.prototype.createWaveformInfoByHandle=function(t,i){var f=this.getViewerWindow(),e,r,o,u;return f&&(e=this.wdbMetadataCache[t],e&&(r=this.getTreeNode(t,i,null),r))?(o=f.getWdbIdBySimulationId(t),u=new n.WaveformInfo(t,o,r),this.putWaveformInfoToCache(u),u):null},t.prototype.getTreeNode=function(n,t,i){var u=this.wdbMetadataCache[n],r;return u&&(r=this.getTreeChildNode(u,t,i),r!=null)?r:null},t.prototype.getTreeChildNode=function(n,t,i){var r,u,f;if(i&&n.Name==i||t&&n.Id==t)return n;if(r=n.Children,r)for(u=0;u<r.length;u++)if(f=this.getTreeChildNode(r[u],t,i),f!=null)return f;return null},t.UNDEFINED=-1,t.WDB=0,t.FOLDER=1,t.HIERARCHY=2,t.BUS=3,t.COMPOUND_BUS=4,t.COMPOUND_WAVEFORM=5,t.COMPLEX_HIERARCHY=20,t.ANALOG_WF=6,t.STEP_WF=7,t.HISTOGRAM_WF=8,t.SCATTER_WF=9,t.SPECTRAL_WF=10,t.STD_LOGIC_WF=11,t.QSIM_12STATE_WF=12,t.QSIM_STATE_WF=13,t.BOOLEAN_WF=14,t.VHDL_CHAR_WF=15,t.BIT_WF=16,t.ENUMERATED_WF=17,t.STRING_WF=18,t.BUS_WF=19,t.UNDEFINED_DATA=-1,t.NUMERIC_INTEGER_DATA=0,t.NUMERIC_REAL_DATA=1,t.NUMERIC_COMPLEX_DATA=2,t.STRING_DATA=3,t.ENUMERATED_DATA=4,t.WINDOW_CONTAINER_CLASS="svw-windowContainer",t.VIEWER_WINDOW_CLASS="svw-viewer-window",t.SCALAR_DBMAG="dbMag",t.SCALAR_MAGNITUDE="magnitude",t.SCALAR_PHASE="phase",t.SCALAR_REAL_PART="real_part",t.SCALAR_IMAG_PART="imag_part",t.SCALARS=[t.SCALAR_DBMAG,t.SCALAR_MAGNITUDE,t.SCALAR_PHASE,t.SCALAR_REAL_PART,t.SCALAR_IMAG_PART],t.LEGEND_WIDTH=100,t.LEGEND_FONT_SIZE=14,t.MAX_LEGEND_LENGTH=10,t.X_AXIS_HEIGHT=38,t.X_AXIS_HEIGHT_WITHOUT_NAME=32,t.AXIS_LABEL_COLOR="#545454",t.TICK_LABEL_COLOR="#545454",t.AXIS_MAJOR_TICK_LINES_COLOR="black",t.AXIS_MINOR_TICK_LINES_COLOR="#949494",t.X_TICK_LENGTH_FOR_WINDOW=10,t.X_TICK_LENGTH_FOR_BOX=5,t.X_TICK_FONT_SIZE=11,t.X_LABEL_HEIGHT=20,t.AXIS_PADDING=12.5,t.X_LABEL_WIDTH=100,t.GRID_BORDER_WIDTH=1,t.WAVEFORM_WIDTH=1.5,t.DROP_SHADOW_WIDTH=1,t.WAVEFORM_OUTLINED_WIDTH=5,t.INITIAL_WIDTH=700,t.INITIAL_HEIGHT=400,t.ROW_NUMBER=3,t.DIGITAL_ROW_HEIGHT=50,t.MINIMAL_ANALOG_ROW_HEIGHT=80,t.NO_UNITS="No Units",t.DIGITAL_Y_AXIS="Digital",t.RAILROAD_Y_AXIS="Railroad",t.GLOBAL_WAVECONTAINER_INDEX=0,t.MINIMAL_Y_AXIS_WIDTH=20,t.ADD_WDB="addWDB",t.RESTORE_STATE="restoreState",t.ZOOMING_LIMIT_MESSAGE="Cannot zoom in any further",t.ZOOMING_EMPTY_MESSAGE="There are no datapoints in selected area",t.ZOOMING_DIGITAL_MESSAGE="Cannot do any Y zooming for a digital waveform",t}();n.WaveManager=t;n.getManager=w;h=function(){function n(){this.showLegend=!1;this.showXAxis=!0;this.showXAxisLabel=!0;this.showYAxis=!0;this.showYAxisLabel=!0;this.showToolbar=!1;this.showPoints=!1;this.showBorder=!1}return n.getDefaultOptionsForWindow=function(){var t=new n;return t.showLegend=!0,t.showXAxisLabel=!0,t},n.prototype.isLegendShown=function(){return this.showLegend},n.prototype.isXAxisShown=function(){return this.showXAxis},n.prototype.isXAxisLabelShown=function(){return this.showXAxisLabel},n.prototype.isYAxisShown=function(){return this.showYAxis},n.prototype.isYAxisLabelShown=function(){return this.showYAxisLabel},n.prototype.isToolbarShown=function(){return this.showToolbar},n.prototype.arePointsShown=function(){return this.showPoints},n.prototype.setShowPoints=function(n){this.showPoints=n},n.prototype.restoreDefaultDecoration=function(n){this.showLegend=!1;this.showXAxis=!0;this.showXAxisLabel=!0;this.showToolbar=!1;this.showPoints=!1;this.showBorder=!0;this.showYAxis=n?!1:!0;this.showYAxisLabel=n?!1:!0},n.prototype.hideDecoration=function(){this.showLegend=!1;this.showXAxis=!1;this.showXAxisLabel=!1;this.showYAxis=!1;this.showYAxisLabel=!1;this.showToolbar=!1;this.showPoints=!1;this.showBorder=!1},n}();n.WaveboxDecorationOptions=h;c=function(){function n(n,t){this.xmin=n;this.xmax=t}return n}();n.XWaveRange=c;f=function(){function t(n,t,i,r){if(this.isForSelectedAxis=!1,this.useAsConstant=!1,$.isNumeric(n))this.ymin=n,this.ymax=t,this.axisName=i,this.useAsConstant=r;else{var u=n;this.ymin=u.ymin;this.ymax=u.ymax;this.axisName=u.axisName;this.useAsConstant=u.useAsConstant}}return t.getEmptyRange=function(){return new t(0,1,n.WaveManager.NO_UNITS,!0)},t.prototype.compareTo=function(n,t,i){var r=t+PATH_SEPARATOR+"y range";return Project.Utility.comparePrimitives(this.ymin,n.ymin,"ymin",t,i)?Project.Utility.comparePrimitives(this.ymax,n.ymax,"ymax",r,i)?Project.Utility.comparePrimitives(this.axisName,n.axisName,"axisName",r,i)?!0:!1:!1:!1},t}();n.YWaveRange=f;l=function(){function n(n,t,i,r){this.xmin=n;this.xmax=t;this.ymin=i;this.ymax=r}return n}();n.WaveRange=l;a=function(){function t(t,i,r){this.panDirection=n.PAN_DIRECTION.NONE;this.mode=t;this.row=i;this.panDirection=r}return t}();n.ZoomState=a,function(n){n[n.IN_ROW=0]="IN_ROW";n[n.BEFORE_ROW=1]="BEFORE_ROW";n[n.AFTER_ROW=2]="AFTER_ROW";n[n.UNDEFINED_ROW=3]="UNDEFINED_ROW"}(n.DROP_STATE||(n.DROP_STATE={}));b=n.DROP_STATE,function(n){n[n.IN_ROW=0]="IN_ROW";n[n.AFTER_ROW=1]="AFTER_ROW";n[n.NOT_ALLOWED=2]="NOT_ALLOWED"}(n.ALLOW_DROP||(n.ALLOW_DROP={}));k=n.ALLOW_DROP;v=function(){function n(n,t){this.currentRow=n;this.state=t}return n}();n.WaveDropState=v,function(n){n[n.ANALOG=0]="ANALOG";n[n.DIGITAL=1]="DIGITAL";n[n.RAILROAD=2]="RAILROAD"}(n.WORK_TYPE||(n.WORK_TYPE={}));i=n.WORK_TYPE;u=function(){function n(){}return n.prototype.canPlotWithType=function(n){return n==i.ANALOG?this.canPlotWithAnalog():n==i.DIGITAL?this.canPlotWithDigital():n==i.RAILROAD?this.canPlotWithRailroad():!1},n.getWorkOptionsByAxis=function(n){return n?n==t.DIGITAL_Y_AXIS?new e:n==t.RAILROAD_Y_AXIS?new o:new r:new r},n.getWorkOptionsByType=function(n){return n==t.ANALOG_WF||n==t.STEP_WF?new r:n==t.STD_LOGIC_WF||n==t.BOOLEAN_WF||n==t.BIT_WF?new e:n==t.BUS_WF||n==t.ENUMERATED_WF||n==t.BUS?new o:(n==t.HISTOGRAM_WF||n==t.SCATTER_WF||n==t.SPECTRAL_WF||n==t.QSIM_12STATE_WF||n==t.VHDL_CHAR_WF||n==t.STRING_WF,new r)},n}();n.WorkOptions=u;r=function(t){function r(){t.call(this);this.workType=i.ANALOG}return __extends(r,t),r.prototype.getRenderer=function(t){return new n.AnalogRenderer(t)},r.prototype.canShowYAxis=function(){return!0},r.prototype.useDigitalHeight=function(){return!1},r.prototype.canShowPoints=function(){return!0},r.prototype.getTickGenerator=function(){return n.YAxisTicks.tickGeneratorForYAxis},r.prototype.getYRange=function(){return null},r.prototype.getYAxisNameWithUnits=function(n){return n},r.prototype.canZoomYAxis=function(){return!0},r.prototype.canShowZeroLevel=function(){return!0},r.prototype.canPlotWithAnalog=function(){return!0},r.prototype.canPlotWithRailroad=function(){return!1},r.prototype.canPlotWithDigital=function(){return!0},r.prototype.canApplyMathOperations=function(n){var t=n.workType;return t==i.ANALOG?!0:t==i.DIGITAL?!1:t==i.RAILROAD?!1:void 0},r}(u);n.WorkOptions_Analog=r;e=function(r){function u(){r.call(this);this.workType=i.DIGITAL}return __extends(u,r),u.prototype.getRenderer=function(t){return new n.DigitalRenderer(t)},u.prototype.canShowYAxis=function(){return!0},u.prototype.useDigitalHeight=function(){return!0},u.prototype.canShowPoints=function(){return!1},u.prototype.getTickGenerator=function(){return n.YAxisTicks.tickGeneratorForYAxisDigital},u.prototype.getYRange=function(i){var u=n.DigitalWaveform.DIGITAL_MIN,e=n.DigitalWaveform.DIGITAL_MAX,r;return i&&(r=.1,u-=r,e+=r),new f(u,e,t.DIGITAL_Y_AXIS,!1)},u.prototype.getYAxisNameWithUnits=function(){return t.DIGITAL_Y_AXIS},u.prototype.canZoomYAxis=function(){return!1},u.prototype.canShowZeroLevel=function(){return!1},u.prototype.canPlotWithAnalog=function(){return!0},u.prototype.canPlotWithRailroad=function(){return!1},u.prototype.canPlotWithDigital=function(){return!0},u.prototype.canApplyMathOperations=function(){return!1},u}(u);n.WorkOptions_Digital=e;o=function(r){function u(){r.call(this);this.workType=i.RAILROAD}return __extends(u,r),u.prototype.getRenderer=function(t){return new n.BusRenderer(t)},u.prototype.canShowYAxis=function(){return!1},u.prototype.useDigitalHeight=function(){return!0},u.prototype.canShowPoints=function(){return!1},u.prototype.getTickGenerator=function(){return n.YAxisTicks.tickGeneratorForYAxisDigital},u.prototype.getYRange=function(i){var u=n.DigitalWaveform.DIGITAL_MIN,e=n.DigitalWaveform.DIGITAL_MAX,r;return i&&(r=.1,u-=r,e+=r),new f(u,e,t.DIGITAL_Y_AXIS,!1)},u.prototype.getYAxisNameWithUnits=function(){return t.RAILROAD_Y_AXIS},u.prototype.canZoomYAxis=function(){return!1},u.prototype.canShowZeroLevel=function(){return!1},u.prototype.canPlotWithAnalog=function(){return!1},u.prototype.canPlotWithRailroad=function(){return!1},u.prototype.canPlotWithDigital=function(){return!1},u.prototype.canApplyMathOperations=function(){return!1},u}(u);n.WorkOptions_Railroad=o}(WaveViewer||(WaveViewer={})),function(n){var t,u,i,r;(function(n){n[n.ROW=0]="ROW";n[n.WAVEFORM=1]="WAVEFORM";n[n.CONTAINER=2]="CONTAINER"})(n.MENU_TYPE||(n.MENU_TYPE={}));t=n.MENU_TYPE;u=function(){function r(i,r){r===void 0&&(r=!1);this.menuType=t.CONTAINER;this.forLegend=!1;i instanceof n.WaveRowBase?(this.row=i,this.menuType=t.ROW,this.waveContainer=this.row.waveContainer):i instanceof n.Waveform&&(this.waveform=i,this.menuType=t.WAVEFORM,this.waveContainer=this.waveform.waveContainer,this.forLegend=r)}return r.prototype.getRow=function(){var n;return this.menuType==t.ROW?n=this.row:this.menuType==t.WAVEFORM&&(n=this.waveform.parentRow),n},r.prototype.updateMenus=function(){var t=[],i,n;for(this.waveContainer.isInWaveBox()?t=this.waveContainer.getRows():(n=this.getRow(),t.push(n)),i=0;i<t.length;i++)n=t[i],n&&!n.isEmpty()&&n.updateMenu(!1)},r.prototype.createMenuContent=function(){var n;return this.menuType==t.ROW?new SVWebContextMenu.MenuContent(this.row):this.menuType==t.WAVEFORM?new SVWebContextMenu.MenuContent(this.waveform):void 0},r.prototype.createMenu=function(){var n=this.createMenuContent(),i=this.waveContainer.isInWaveBox(),u,f;return i?(n.addMenuElement(r.PLOT_IN_VIEWER,this.plotInViewerFunc),this.createDisplayMenu(n),this.createSimulationTypeMenu(n)):this.forLegend||n.addMenuElement(r.ZOOM_UNDO,this.zoomUndoFunc),this.waveContainer.isViewAllForX()&&this.waveContainer.isViewAllForY()||n.addMenuElement(r.VIEW_ALL,this.viewAllFunc),i&&this.forLegend||n.addSeparatorToMenu(),this.forLegend&&(n.addMenuElement(r.WfOP_TOOL,this.wfOpToolFunc),n.addSeparatorToMenu()),u=r.CHOOSE_COLORS,f=r.DOWNLOAD_WAVEFORMS,i||this.menuType!=t.WAVEFORM||(u=r.CHOOSE_SINGLE_COLOR,f=r.DOWNLOAD_SINGLE_WAVEFORM),n.addMenuElement(u,this.chooseWaveformColorFunc),i?this.waveContainer.isDecorationShown()&&n.addMenuElement(r.ADD_CURSOR,this.addCursorFunc):this.forLegend||n.addMenuElement(r.ADD_CURSOR,this.addCursorFunc),this.forLegend||n.addMenuElement(f,this.downloadWaveformFunc),i||this.forLegend||n.addMenuElement(r.CLEAR_WINDOW,this.clearWindowFunc),this.forLegend||n.addSeparatorToMenu(),this.menuType==t.WAVEFORM&&this.forLegend&&this.waveform.workOptions.canShowPoints()&&n.addMenuElementAsCheckbox(r.SHOW_POINTS,this.showPointsFunc,this.waveform.points.show),this.forLegend&&(n.addMenuElement(r.DOWNLOAD_SINGLE_WAVEFORM,this.downloadWaveformFunc),this.waveform.hasMeasurementWithMarkers()&&n.addMenuElement(r.DELETE_MEASUREMENTS,this.deleteMeasurementsFunc),n.addMenuElement(r.DELETE_WAVEFORM,this.deleteWaveformFunc),n.addSeparatorToMenu()),SVWebContextMenu.MenuHelper.createMenu(n,this)},r.prototype.plotInViewerFunc=function(n,t,i,r){r.plotInViewerFuncInternal()},r.prototype.plotInViewerFuncInternal=function(){if(this.waveContainer.isInWaveBox()){var t=this.waveContainer.getPlottedWaveforms(),i=this.waveContainer.getWavebox().getUniqName();n.getManager().plotInViewerFromWavebox(this.waveContainer.getWavebox())}},r.prototype.createDisplayMenu=function(n){if(this.canShowDisplayMenu()){var t=this.waveContainer.getWavebox(),u=n.addMenuElement(r.DISPLAY_MENU),e=t.getPlotMode(),f=t.isSingleMode();n.addMenuElementAsRadioButton(u,r.SEPARATE_ROW_MODE,this.updatePlotModeFunc,!f);n.addMenuElementAsRadioButton(u,r.SINGLE_ROW_MODE,this.updatePlotModeFunc,f);t&&!t.hasDetachedProbe()&&this.canApplyMathOperations()&&(this.calcMenu=new i(this,n,this.waveContainer,u));n.addSeparatorToMenu()}},r.prototype.canShowDisplayMenu=function(){var n=this.waveContainer.getWavebox();return n?n.getNumberOfAttachedProbes()<=1?!1:this.waveContainer.canPlotInOverlay()?!0:!1:!1},r.prototype.canApplyMathOperations=function(){var n=this.waveContainer.getWavebox();return n?n.getNumberOfAttachedProbes()<=1?!1:this.waveContainer.canApplyMathOperations()?!0:!1:!1},r.prototype.updatePlotModeFunc=function(n,t,i,r){var u=t;r.updatePlotModeFuncInternal(u)},r.prototype.updatePlotModeFuncInternal=function(n){var t=this.waveContainer.getWavebox();t&&(n==r.SEPARATE_ROW_MODE?t.setSeparateRowMode():n==r.SINGLE_ROW_MODE&&t.setSingleRowMode())},r.prototype.viewAllFunc=function(n,t,i,r){r.viewAllFuncInternal()},r.prototype.viewAllFuncInternal=function(){this.waveContainer.viewAll()},r.prototype.createSimulationTypeMenu=function(n){var t=this.waveContainer.getWavebox();if(t&&t.canSwitchSimulationType()){var i=n.addMenuElement(r.SIMULATION_TYPE),f=t.getSimulationType(!0),u=f==Project.SIMULATION_TYPE.TIME_DOMAIN;n.addMenuElementAsRadioButton(i,Project.TIME_DOMAIN_NAME,this.updateSimulationTypeFunc,u);n.addMenuElementAsRadioButton(i,Project.FREQUENCY_DOMAIN_NAME,this.updateSimulationTypeFunc,!u);n.addSeparatorToMenu()}},r.prototype.updateSimulationTypeFunc=function(n,t,i,r){var u=t;r.updateSimulationTypeFuncInternal(u)},r.prototype.updateSimulationTypeFuncInternal=function(n){var i=Project.getSimulationTypeByName(n),t=this.waveContainer.getWavebox();t&&(t.setSimulationTypeFromMenu(i),this.updateMenus())},r.prototype.chooseWaveformColorFunc=function(n,t,i,r){var u=t.sender.pageCoordinates;r.chooseWaveformColorFuncInternal(u)},r.prototype.chooseWaveformColorFuncInternal=function(i){var r=[],u=this.waveContainer.isInWaveBox();u||this.menuType!=t.WAVEFORM?r=this.waveContainer.getPlottedWaveforms():r.push(this.waveform);new n.WaveformColorPicker(r,i,u)},r.prototype.clearWindowFunc=function(n,t,i,r){r.clearWindowFuncInternal()},r.prototype.clearWindowFuncInternal=function(){this.waveContainer.clear()},r.prototype.addCursorFunc=function(n,t,i,r){r.addCursorFuncInternal(i)},r.prototype.addCursorFuncInternal=function(n){var t=this.getRow(),i;if(t.menuPositionEvent){var e=t.menuPositionEvent,r=t.getOffset(),u=Math.max(0,Math.min(e.pageX-r.left,t.getRowWidth())),f=t.calcXValueByPosition(u);this.waveContainer.addCursorGroup(f);return}if(!n||!n.getPageCoordinates()){this.waveContainer.addCursorGroup(null);return}if(i=n.getPageCoordinates(),!i){this.waveContainer.addCursorGroup(null);return}var o=i.pageX,r=t.getOffset(),u=Math.max(0,Math.min(o-r.left,t.getRowWidth())),f=t.calcXValueByPosition(u);this.waveContainer.addCursorGroup(f)},r.prototype.showPointsFunc=function(n,t,i,r){r.showPointsFuncInternal(t)},r.prototype.showPointsFuncInternal=function(n){this.forLegend&&(this.waveform.points.show=n);this.waveContainer.redraw()},r.prototype.showZeroLevelFunc=function(n,t,i,r){r.showZeroLevelFuncInternal(t)},r.prototype.showZeroLevelFuncInternal=function(t){var r=[],f,u,i;for(this.waveContainer.isInWaveBox()?r=this.waveContainer.getRows():(f=this.getRow(),f instanceof n.WaveRow&&r.push(f)),u=0;u<r.length;u++)i=r[u],i&&!i.isEmpty()&&(i.zeroLevelFlag=t,i.plotArtefacts(!0));this.updateMenus()},r.prototype.zoomUndoFunc=function(n,t,i,r){r.zoomUndoFuncInternal()},r.prototype.zoomUndoFuncInternal=function(){this.waveContainer.undoZoom()},r.prototype.deleteWaveformFunc=function(n,t,i,r){r.deleteWaveformFuncInternal()},r.prototype.deleteWaveformFuncInternal=function(){this.waveContainer.removeWaveformMeasurements(this.waveform,!1);this.waveContainer.deleteWaveformFromParentRow(this.waveform,!0)},r.prototype.deleteMeasurementsFunc=function(n,t,i,r){r.deleteMeasurementsFuncInternal()},r.prototype.deleteMeasurementsFuncInternal=function(){this.waveform&&this.waveContainer.removeWaveformMeasurements(this.waveform,!0)},r.prototype.wfOpToolFunc=function(n,t,i,r){r.wfOpToolFuncInternal()},r.prototype.wfOpToolFuncInternal=function(){this.waveform?this.waveContainer.getToolWindow().open(this.waveform):this.waveContainer.getToolWindow().open(null)},r.prototype.downloadWaveformFunc=function(n,t,i,r){r.downloadWaveformFuncInternal()},r.prototype.downloadWaveformFuncInternal=function(){var i=[];!this.waveContainer.isInWaveBox()&&this.menuType==t.WAVEFORM||this.forLegend?i.push(this.waveform):i=this.waveContainer.getPlottedWaveforms();n.ViewerRequests.downloadWaveformData(n.getManager().getDlIFrame(),i,"csv")},r.DISPLAY_MENU="Display",r.SEPARATE_ROW_MODE="Dual Trace",r.SINGLE_ROW_MODE="Overlaid",r.PLOT_IN_VIEWER="Plot in Viewer",r.SIMULATION_TYPE="Simulation Type",r.ZOOM_UNDO="Zoom Undo",r.VIEW_ALL="View All",r.CHOOSE_COLORS="Choose Colors",r.CHOOSE_SINGLE_COLOR="Choose Color",r.ADD_CURSOR="Add Cursor",r.CLEAR_WINDOW="Clear Window",r.SHOW_POINTS="Show Points",r.SHOW_ZERO_LEVEL="Show Zero Level",r.DELETE_WAVEFORM="Delete Waveform",r.DOWNLOAD_WAVEFORMS="Download Waveforms",r.DOWNLOAD_SINGLE_WAVEFORM="Download Waveform",r.MEASUREMENTS="Measurements...",r.WfOP_TOOL="Waveform Analyzer...",r.DELETE_MEASUREMENTS="Delete Measurements",r}();n.MenuDriver=u;i=function(){function t(n,t,i,r){this.calcMenuMapIndex=[];this.menuManager=n;this.menuContent=t;this.radioSubMenu=r;this.waveContainer=i;this.createMenu()}return t.prototype.createMenu=function(){var o=this.waveContainer.getWavebox(),l,t,i,f,e,u,h;if(o){this.menuContent.addSeparatorToSubMenu(this.radioSubMenu);this.calcMenuMapIndex=[];var a=o.getPlotMode(),s=o.getPlotState(),c=r.getOperationMap();for(l in c)if(t=c[l],t){if(i=s.getCalculatorMenuItemBlock(t.function),f="",i)for(e=0;e<i.items.length;e++)f+=i.items[e].text;else f=s.getCalculatorMenuItemName(t.function);u=this.menuContent.addMenuElementAsRadioButton(this.radioSubMenu,f,this.updateCaclulatorFunc,this.isFunctionForOperation(t.function,a));h=s.getOperationApplicability(t);h!=n.CalculatorOperation.ALLOW&&(u.tooltip=h,u.disable());i&&(u.coloredBlock=i);this.calcMenuMapIndex[u.id]=t.function}}},t.prototype.updateCaclulatorFunc=function(n,t,i,r,u){r.calcMenu.updateCaclulatorFuncInternal(u)},t.prototype.updateCaclulatorFuncInternal=function(n){var i=this.waveContainer.getWavebox(),t;i&&n&&(t=this.calcMenuMapIndex[n],t&&i.setFunction(t))},t.prototype.isFunctionForOperation=function(n,t){var i=this.waveContainer.getWavebox(),r;if(i)return r=i.getFunction(),t==ProbeModule.PlotMode.CALCULATOR?r==n:!1},t}();n.CalculatorMenu=i;r=function(){function n(){this.isUnary=!1;this.isCommutative=!1;this.directOrder=!0}return n.initCalculatorOperations=function(){var t=new n;t.function=ServerStructures.CalculatorFunction.ADD;t.sign="+";t.isUnary=!1;t.name="Add";t.isCommutative=!0;t.directOrder=!0;n.calculatorOperations[t.function]=t;t=new n;t.function=ServerStructures.CalculatorFunction.SUBTRACT;t.sign="-";t.isUnary=!1;t.name="Subtract";t.isCommutative=!1;t.directOrder=!0;n.calculatorOperations[t.function]=t;t=new n;t.function=ServerStructures.CalculatorFunction.MULTIPLY;t.sign="*";t.isUnary=!1;t.name="Multiply";t.isCommutative=!0;t.directOrder=!0;n.calculatorOperations[t.function]=t;t=new n;t.function=ServerStructures.CalculatorFunction.DIVIDE;t.sign="/";t.isUnary=!1;t.name="Divide";t.isCommutative=!1;t.directOrder=!0;n.calculatorOperations[t.function]=t;t=new n;t.function=ServerStructures.CalculatorFunction.SUBTRACT_OPPOSITE;t.sign="-";t.isUnary=!1;t.name="Opposite Subtract";t.isCommutative=!1;t.directOrder=!1;n.calculatorOperations[t.function]=t;t=new n;t.function=ServerStructures.CalculatorFunction.DIVIDE_OPPOSITE;t.sign="/";t.isUnary=!1;t.name="Opposite Divide";t.isCommutative=!1;t.directOrder=!1;n.calculatorOperations[t.function]=t},n.getOperationMap=function(){return n.calculatorOperations.length==0&&n.initCalculatorOperations(),n.calculatorOperations},n.getOperation=function(t){n.calculatorOperations.length==0&&n.initCalculatorOperations();var i=n.calculatorOperations[t];return i?i:n.calculatorOperations[ServerStructures.CalculatorFunction.ADD]},n.getFuncByName=function(n){return ServerStructures.CalculatorFunction[n]},n.getNameByFunc=function(n){return ServerStructures.CalculatorFunction[n]},n.ALLOW="Operation is allowed",n.NOT_ALLOW="Operation is not allowed",n.calculatorOperations=[],n}();n.CalculatorOperation=r}(WaveViewer||(WaveViewer={})),function(n){var t,r,u,h,f,e,i,o,s;(function(n){n[n.NONE=0]="NONE";n[n.VERTICAL=1]="VERTICAL";n[n.HORIZONTAL=2]="HORIZONTAL";n[n.BOTH=3]="BOTH"})(n.RESIZE_MODE||(n.RESIZE_MODE={}));t=n.RESIZE_MODE;r=function(){function r(t,i,u){var f,e;this.isViewAllForXFlag=!0;this.rows=[];this.zoomMode="xy";this.zoomState=null;this.localColorIndex=1;this.useLogXAxis=!1;this.readyToAdjust=!1;this.pointOptionMap=[];f=n.WaveManager.GLOBAL_WAVECONTAINER_INDEX++;this.waveBox=u;this.cursorGroupManager=new n.CursorGroupManager(this);this.parentContainerJQ=t;n.getManager().addWaveContainer(this);this.decorationOptions=i?i:new n.WaveboxDecorationOptions;e=r.WAVE_TOOLBAR_CLASS+f;this.spinnerId=r.CONTAINER_SPINNER_ID+"_"+f;this.spinnerIdStr="#"+this.spinnerId;this.parentContainerJQ.addClass(r.WAVE_CONTAINER_CLASS);this.createWaveRowContainer(e);this.parentContainerJQ.mouseup(function(){n.getManager().triggerZoom()});this.containerMeasManager=new Operations.ContainerMeasManager(this)}return r.prototype.getWaveContainerWrapper=function(){return this.parentContainerJQ},r.prototype.getToolWindow=function(){return this.toolWindow||(this.toolWindow=new Operations.ToolWindow(this)),this.toolWindow},r.prototype.closeToolWindow=function(){this.toolWindow&&this.toolWindow.close()},r.prototype.createContent=function(n,t,i){n.append('<div id="'+i+'" class="'+r.WAVE_CONTAINER_CLASS+'"><\/div>')},r.prototype.hideDecoration=function(){this.decorationOptions&&this.isInWaveBox()&&(this.decorationOptions.hideDecoration(),this.disableSelectionMode())},r.prototype.restoreDefaultDecoration=function(){this.decorationOptions&&this.isInWaveBox()&&(this.decorationOptions.restoreDefaultDecoration(!1),this.enableSelectionMode())},r.prototype.isLogXAxis=function(){return this.useLogXAxis},r.prototype.setParentWidth=function(n){this.parentContainerJQ.width(n)},r.prototype.getParentContainerJQ=function(){return this.parentContainerJQ},r.prototype.getId=function(){return this.id},r.prototype.getWaveContainerJQ=function(){return $("#"+this.id)},r.prototype.setHeight=function(n){var t=this.getWaveContainerJQ().height();this.getWaveContainerJQ().height(n)},r.prototype.getToolbarHeight=function(){return this.decorationOptions.isToolbarShown()?$(this.toolDiv).height():0},r.prototype.getProbeWaveform=function(n){for(var r,i,t=0;t<this.rows.length;t++)if(r=this.rows[t],r&&(i=r.getProbeWaveform(n),i&&!i.isEmptyWaveform()))return i;return null},r.prototype.getCalculatorWaveformForProbe=function(n){for(var r,i,t=0;t<this.rows.length;t++)if(r=this.rows[t],r&&(i=r.getCalculatorWaveformForProbe(n),i&&!i.isEmptyWaveform()))return i;return null},r.prototype.notifyAboutZoomState=function(){this.isInWaveBox()&&(this.waveBox.notify(ProbeModule.ChangeEvents.ZOOM,n.SourceInfo.WAVEBOX_INDEX),this.waveBox.markAsDirty())},r.prototype.notifyAboutCursors=function(){this.isInWaveBox()&&(this.waveBox.notify(ProbeModule.ChangeEvents.CURSORS,n.SourceInfo.WAVEBOX_INDEX,this.getCursorStates()),this.waveBox.markAsDirty())},r.prototype.changeColorInWaveBox=function(n,t){this.isInWaveBox()&&this.waveBox.updateColors(t,n)},r.prototype.isInWaveBox=function(){return this.waveBox!=null},r.prototype.setViewerWindow=function(n){this.viewerWindow=n},r.prototype.getViewerWindow=function(){return this.viewerWindow},r.prototype.isViewAllForX=function(){return this.isViewAllForXFlag},r.prototype.isViewAllForY=function(){for(var t,n=0;n<this.rows.length;n++)if(t=this.rows[n],t&&!t.isViewAllForAllYAxis())return!1;return!0},r.prototype.setViewAllForX=function(){this.isViewAllForXFlag=!0;this.xAxisState=this.getOriginalXState()},r.prototype.getState=function(){var n=new o;return n.saveState(this),n},r.prototype.isXAxisShown=function(){return this.decorationOptions&&this.decorationOptions.isXAxisShown()?!0:!1},r.prototype.createWaveRowContainer=function(t){var i,f,u,o;this.id=r.WAVE_ROW_CONTAINER_CLASS+r.GLOBAL_WAVECONTAINER_ID++;i=this.getWaveContainerWrapper();this.decorationOptions.isToolbarShown()&&(i.append("<DIV ID="+t+"><\/DIV>"),f=$("#"+t),f.addClass(r.WAVE_TOOLBAR_CLASS),this.toolDiv=$(f),new e(this,this.toolDiv));i.css({minHeight:r.MINIMAL_CONTAINER_HEIGHT});i.height()<r.MINIMAL_CONTAINER_HEIGHT&&i.height(r.MINIMAL_CONTAINER_HEIGHT);i.append("<DIV ID="+this.getId()+"><\/DIV>");u=this.getWaveContainerJQ();u.addClass(r.WAVE_ROW_CONTAINER_CLASS);this.isInWaveBox()||u.css("overflowY","auto");o=this.definePlaceholderDimensions();u.width(o.placeholderWidth);this.setHeight(i.height()-this.getXAxisHeight());this.decorationOptions.isXAxisShown()&&(this.domainAxis=new n.DomainAxis(this,o.placeholderWidth,i));this.panButtons=new n.PanButtons(this);this.addPanButtonHover();this.plotEmptyWaveform()},r.prototype.setShowHidePoints=function(){var n=this.decorationOptions.arePointsShown();this.decorationOptions.setShowPoints(!n);this.plotRows()},r.prototype.setShowDecorations=function(){this.showHideDecorations(!0)},r.prototype.setHideDecorations=function(){this.showHideDecorations(!1)},r.prototype.showHideDecorations=function(n){var r=this.getWaveContainerJQ(),u,t,f,i;n?(this.toolDiv&&this.toolDiv.show(),r.css("overflow-y","auto")):(this.toolDiv&&this.toolDiv.hide(),r.css("overflow-y","hidden"));u=this.getDomainAxis();t=$("#"+u.getRowId());t&&(n?t.show():t.hide());for(f in this.rows)i=this.rows[f],i&&i.showHideDecorations(n)},r.prototype.getCurrentZoomMode=function(){return this.zoomMode},r.prototype.setCurrentZoomMode=function(n){this.zoomMode=n},r.prototype.createTail=function(n,t,i){return new f(this.getWaveContainerWrapper(),n,t,i)},r.prototype.getDomainAxis=function(){return this.domainAxis},r.prototype.getRows=function(){return this.rows},r.prototype.getOriginalXState=function(){var t,i,u,r;if(!this.rows||this.rows.length==0)return ServerStructures.XAxisState.createXAxisState(null,!0,!0);t=null;i=null;for(u in this.rows)r=this.rows[u],r&&(t=n.WaveUtils.getMin(t,r.getXOriginalRange().xmin),i=n.WaveUtils.getMax(i,r.getXOriginalRange().xmax));return ServerStructures.XAxisState.createXAxisState(new n.XWaveRange(t,i),!0)},r.prototype.getRealXVisibleState=function(){var n=this.getPlottedWaveforms();return n==null||n.length==0?ServerStructures.XAxisState.createXAxisState(null,!0,!0):n.length==1&&n[0].isEmptyWaveform()?ServerStructures.XAxisState.createXAxisState(null,!0,!1):this.getXAxisState()},r.prototype.getRequestXAxisState=function(){return n.WaveUtils.getRequestRange(this.getXAxisState(),this.isViewAllForX())},r.prototype.getXAxisState=function(){return(this.isViewAllForX()||!this.xAxisState)&&(this.xAxisState=this.getOriginalXState()),this.xAxisState},r.prototype.setXVisibleState=function(t,i,r){r?this.setViewAllForX():(this.xAxisState=ServerStructures.XAxisState.createXAxisState(new n.XWaveRange(t,i),!1),this.isViewAllForXFlag=!1)},r.prototype.showMeasurementRange=function(n,t){for(var i=0;i<this.rows.length;i++)this.rows[i].showMeasurementRange(n,t);this.getDomainAxis().showMeasurementRange(n,t)},r.prototype.hideMeasurementRange=function(){for(var n=0;n<this.rows.length;n++)this.rows[n].hideMeasurementRange();this.getDomainAxis().hideMeasurementRange()},r.prototype.getYVisibleRangeForWaveform=function(n,t){var i=this.findRowById(n);return i?i.getYVisibleRange(t):null},r.prototype.getFirstRow=function(){if(this.rows)for(var n in this.rows)return this.rows[n];return null},r.prototype.moveToBottom=function(){if(this.rows){var t=this.rows.length*n.WaveManager.MINIMAL_ANALOG_ROW_HEIGHT;this.getWaveContainerJQ().scrollTop(t)}else this.getWaveContainerJQ().scrollTop()},r.prototype.findRowById=function(n){var t,i;if(!this.rows)for(t in this.rows)if(i=this.rows[t],i.getRowId()==n)return this.rows[t];return null},r.prototype.getZoomStack=function(){return this.zoomStack||(this.zoomStack=new u),this.zoomStack},r.prototype.addToZoomStack=function(n){var t=this.getZoomStack();t.addToStack(n);this.notifyAboutZoomState()},r.prototype.getAndRemoveFromZoomStack=function(){var n=this.getZoomStack();return this.notifyAboutZoomState(),n.getAndRemoveFromStack()},r.prototype.clearZoomStack=function(){var n=this.getZoomStack();n.clearStack();this.notifyAboutZoomState()},r.prototype.viewAll=function(){var n,t;this.setViewAllForX();for(n in this.rows)this.rows[n].viewAll();t=this;this.showSpinner();$.when(this.plotRows()).done(function(){t.hideSpinner()});this.clearZoomStack()},r.prototype.undoZoom=function(){var n=this.getAndRemoveFromZoomStack();this.applyLastZoomRange(n);this.notifyAboutZoomState()},r.prototype.applyLastZoomRange=function(n){var i=this,t;if(this.showSpinner(),!n){this.viewAll();return}n.rowId&&n.YRange&&(t=this.findRowById(n.rowId),t&&t.setYVisibleRange(n.YRange,!1));n.xRange&&this.setXVisibleState(n.xRange.xmin,n.xRange.xmax,!1);$.when(this.plotRows()).done(function(){i.hideSpinner()})},r.prototype.setSelectionForOthers=function(n,t){var r,i;if(t){for(r in this.rows)i=this.rows[r],i!=n&&i.setSelection("x",t);n&&this.decorationOptions.isXAxisShown()&&this.getDomainAxis().setSelection("x",t)}},r.prototype.getPlotAreaLeftOffset=function(){for(var i,n=0,t=0;t<this.rows.length;t++)i=this.rows[t].getPlotArea().getPlotOffset().left,n<i&&(n=i);return n},r.prototype.getPlotAreaWidth=function(){for(var i,n=0,t=0;t<this.rows.length;t++)i=this.rows[t].getPlotArea().getSurface().width,n<i&&(n=i);return n},r.prototype.showAnyYAxis=function(){for(var n=0;n<this.rows.length;n++)if(this.rows[n].hasAnyYAxis(null))return!0;return!1},r.prototype.hasDigitalRow=function(){return this.getRows()?this.getDigitalRowAmount()!=0:!1},r.prototype.canPlotInOverlay=function(){var n,i,t,r;if(!this.getRows())return!0;for(n=0;n<this.rows.length;n++)for(i=this.rows[n],t=0;t<this.rows.length;t++)if(r=this.rows[t],n!=t&&(!i.canPlotRowInOverlay(r)||!r.canPlotRowInOverlay(i)))return!1;return!0},r.prototype.canApplyMathOperations=function(){var t,n,i,r;if(!this.getRows())return!1;if(this.rows.length==1)return n=this.rows[0],n.canApplyMathOperationsInRow();for(t=0;t<this.rows.length;t++)for(n=this.rows[t],i=0;i<this.rows.length;i++)if(r=this.rows[i],t!=i&&(!n.canApplyMathOperations(r)||!r.canApplyMathOperations(n)))return!1;return!0},r.prototype.definePlaceholderDimensions=function(){var t=new s,i=this.getWaveContainerWrapper(),o,f,e,u;return i?(t.placeholderWidth=i.width(),t.placeholderWidth<=0&&(t.placeholderWidth=1),this.isInWaveBox()||(this.getNumberOfRows()==1?i.find("."+r.WAVE_ROW_CONTAINER_CLASS).css("overflow-y","hidden"):i.find("."+r.WAVE_ROW_CONTAINER_CLASS).css("overflow-y","auto")),o=this.decorationOptions.isToolbarShown()?this.getToolbarHeight():0,t.placeholderHeight=i.height()-o,f=this.getDomainAxis(),e=0,f&&(e=f.getCurrentXAxisPadding(this.getNumberOfRows())),t.placeholderHeight+=e):(t.placeholderWidth=n.WaveManager.INITIAL_WIDTH,t.placeholderHeight=n.WaveManager.INITIAL_HEIGHT),u=n.WaveUtils.defineScrollBarWidth(),this.scrollbarWidth=!u||u<0?n.WaveUtils.DEFAULT_LINE_HEIGHT:u,this.isInWaveBox()&&(this.scrollbarWidth=0),t},r.prototype.getDigitalRowAmount=function(){var t=0,i,n;for(i in this.rows)n=this.rows[i],n&&!n.hasAnyAnalogHeightWaveform()&&t++;return t},r.prototype.getAnalogRowAmount=function(){var t=0,i,n;for(i in this.rows)n=this.rows[i],n&&n.hasAnyAnalogHeightWaveform()&&t++;return t},r.prototype.getOptimalRowNumber=function(t){var i=n.WaveManager.ROW_NUMBER,f=this.getWaveContainerJQ(),r,u;if(t<=n.WaveManager.ROW_NUMBER)return n.WaveManager.ROW_NUMBER;for(r=n.WaveManager.MINIMAL_ANALOG_ROW_HEIGHT;i<=t;)if(u=f.height()-1*i-2,r=u/i,r>n.WaveManager.MINIMAL_ANALOG_ROW_HEIGHT)i++;else break;return i},r.prototype.defineCurrentHeight=function(t){var e=this.getDigitalRowAmount(),s=t-e,l=this.definePlaceholderDimensions(),a=this.getXAxisHeight(),v=this.getWaveContainerJQ(),c,u;this.setHeight(l.placeholderHeight-a);var h=!1,f=this.getOptimalRowNumber(t),r=v.height()-2*f,o=r/f;return s==0&&e!=0?(u=r/e,!this.isInWaveBox()&&u<n.WaveManager.DIGITAL_ROW_HEIGHT?(h=!0,new i(o,n.WaveManager.DIGITAL_ROW_HEIGHT)):new i(o,u)):t==0||t==1?new i(r,n.WaveManager.DIGITAL_ROW_HEIGHT):(r=r-e*n.WaveManager.DIGITAL_ROW_HEIGHT,!this.isInWaveBox()&&t>=f&&(h=!0),c=s<=f?s:f,u=r/c,!this.isInWaveBox()&&u<o?(h=!0,new i(o,n.WaveManager.DIGITAL_ROW_HEIGHT)):new i(u,n.WaveManager.DIGITAL_ROW_HEIGHT))},r.prototype.getMinimalYAxisWidth=function(){var i=n.WaveManager.MINIMAL_Y_AXIS_WIDTH,r,t;if(!this.rows||(t=this.rows[n.RowState.length],!t))return i;for(r=0;r<this.rows.length;r++)t=this.rows[r],t instanceof n.WaveRow&&(i=Math.max(t.getFirstAxisWidth(),i));return i},r.prototype.defineXAxisWidth=function(){var t,i,r;if(!this.isDecorationShown())return 10;if(t=n.WaveManager.MINIMAL_Y_AXIS_WIDTH,!this.rows)return t;for(i=0;i<this.rows.length;i++)r=this.rows[i],t=Math.max(r.getAxisWidth(),t);return t},r.prototype.resize=function(n,i){var f=this,r,u;n===void 0&&(n=!1);i===void 0&&(i=!1);this.showSpinner();r=!1;this.isInWaveBox()&&(r=this.waveBox.needToHideDecoration(),i&&this.startResizingMode());r?this.hideDecoration():this.restoreDefaultDecoration();u=n?t.VERTICAL:t.BOTH;$.when(this.plotRows(u)).done(function(){f.hideSpinner()})},r.prototype.stopResizingMode=function(){var t,n;if(!this.isInWaveBox()||this.getWavebox().isPinnedToSchematic()){for(t in this.rows)n=this.rows[t],n.canShowPoints()&&n.restorePointOption(this.pointOptionMap),n.stopResizingMode();this.pointOptionMap=[]}},r.prototype.startResizingMode=function(){var t,n;if((!this.isInWaveBox()||this.getWavebox().isPinnedToSchematic())&&ProbeModule.getWaveBoxManager().isAllowedResizingMode())for(t in this.rows)n=this.rows[t],n.canShowPoints()&&n.storePointOption(this.pointOptionMap),n.startResizingMode()},r.prototype.stopResize=function(n){var i=this;n?this.hideDecoration():this.restoreDefaultDecoration();this.isInWaveBox()&&this.stopResizingMode();$.when(this.plotRows(t.BOTH)).done(function(){i.updateMenu();i.hideSpinner()})},r.prototype.getPlottedWaveforms=function(){var t=[],i,r,n,u,f;for(i in this.rows){r=this.rows[i];n=r.getPlottedWaveforms();for(u in n)f=n[u],t.push(f)}return t},r.prototype.getPlottedWaveformByFlotId=function(n){for(var i=this.getPlottedWaveforms(),t=0;t<i.length;t++)if(i[t].getFlotWaveformId()==n)return i[t];return null},r.prototype.getPlottedWaveformIndex=function(n){for(var i=this.getPlottedWaveforms(),t=0;t<i.length;t++)if(i[t].getFlotWaveformId()==n)return t;return-1},r.prototype.getPlottedWaveformByOrderNum=function(n){var t=this.getPlottedWaveforms();return n<0||n>t.length-1?null:t[n]},r.prototype.getPlottedWaveformsByHandle=function(n,t){var u=this.getPlottedWaveforms(),r=[],f,i;for(f in u)i=u[f],i.wdbId==t&&i.getWaveformHandle()==n&&r.push(i);return r.length==0?null:r},r.prototype.loadingElement=function(){return $("<div id="+this.spinnerId+" class='k-loading-mask'><span class='k-loading-text'>Loading...<\/span><div class='k-loading-image'/><div class='k-loading-color'/><\/div>")},r.prototype.showSpinner=function(){kendo.ui.progress(this.getWaveContainerWrapper().parent(),!0)},r.prototype.hideSpinner=function(){kendo.ui.progress(this.getWaveContainerWrapper().parent(),!1)},r.prototype.redraw=function(){this.plotRows()},r.prototype.getWavebox=function(){return this.isInWaveBox()?this.waveBox:null},r.prototype.setupPanButtons=function(n){this.panButtons&&this.panButtons.setup(n)},r.prototype.plotEmptyContainer=function(){var r=new n.XWaveRange(0,1),e=this.defineCurrentHeight(1),i=this.rows[0],u,f;i||(i=this.getNextEmptyRow());i.setRowHeight(e.analogHeight);u=this.getCurrentWidth();i.disableSelectionMode();this.domainAxis.disableSelectionMode();i.setupDataForPlot(0,u,r,!1);f=this.defineXAxisWidth();this.domainAxis.drawAxis(i.getPlotArea().width(),f,r,this.getXAxisName());this.updateAllCursorGroups(t.BOTH);this.toolWindow&&this.toolWindow.updateToolCombo();this.decorationOptions.isXAxisShown()&&(this.getDomainAxis().setupCurrentXAxisPadding(1),this.drawTickAndGridForAxis(!0));this.setupPanButtons(n.PAN_STATE.HIDE)},r.prototype.testSelectionMode=function(){var t=this.getXAxisState();Math.abs(t.range.xmax-t.range.xmin)<=n.WaveUtils.ERROR_DELTA?this.disableSelectionMode():this.enableSelectionMode()},r.prototype.disableSelectionMode=function(){for(var t,n=0;n<this.getRows().length;n++)t=this.getRows()[n],t.disableSelectionMode();this.domainAxis.disableSelectionMode()},r.prototype.enableSelectionMode=function(){for(var t,n=0;n<this.getRows().length;n++)t=this.getRows()[n],t.enableSelectionMode();this.domainAxis.enableSelectionMode()},r.prototype.plotRows=function(i,r,u){var c=this,l,o,h,f;i===void 0&&(i=t.NONE);r===void 0&&(r=null);u===void 0&&(u=!1);Project.Utility.trace("Starting plot rows");var e=$.Deferred(),a=this,s=i!=t.NONE;return(s&&(l=this.getWaveContainerJQ(),o=this.definePlaceholderDimensions(),l.width(o.placeholderWidth),this.setHeight(o.placeholderHeight),this.decorationOptions.isToolbarShown()&&$(this.toolDiv).width(o.placeholderWidth)),this.isEmpty())?(this.plotEmptyContainer(),e.resolve(),Project.Utility.trace("Empty plot returning in ",!0),e.promise()):(this.testSelectionMode(),h=n.PAN_DIRECTION.NONE,r?(this.zoomState=r,h=r.panDirection):this.zoomState=null,f=ServerStructures.XAxisState.createXAxisState(null,!0),(this.zoomState||s||!this.isViewAllForX())&&(f=this.getXAxisState()),s?(this.plotRealData(e,f.range,i),e.resolve()):(Project.Utility.trace("Before update data",!1),$.when(n.ViewerRequests.getWaveformsData(this.getPlottedWaveforms(),f.range.xmin,f.range.xmax,this.isViewAllForX(),h)).done(function(){(f.range.xmin==null||f.range.xmax==null)&&(f=c.getRealXVisibleState());Project.Utility.trace("Getting data took: ",!0);c.plotRealData(e,f.range,t.NONE,u);Project.Utility.trace("Real plot took : ",!0);e.resolve()}),Project.Utility.trace("Continuing after waiting for data")),Project.Utility.trace("Plot rows took: ",!0),e.promise())},r.prototype.plotRealData=function(n,i,r,u){var a,s,o,e,h,p,f,c;u===void 0&&(u=!1);var l=this.defineCurrentHeight(this.rows.length),v=l.analogHeight,y=l.digitalHeight;for(o in this.rows)e=this.rows[o],a=e.hasAnyAnalogHeightWaveform()?v:y,e.setRowHeight(a);if(s=this.getCurrentWidth(),Project.Utility.trace("Before adjustYAxis with false",!1),r==t.VERTICAL)for(o in this.rows)e=this.rows[o],f=e.getPlotArea(),f.resize(),f.setupGrid(),f.draw();else this.readyToAdjust=!1,this.adjustYAxis(0,s,i,!1),s=this.getCurrentWidth(),h=this.defineXAxisWidth(),Project.Utility.trace("Before adjustYAxis with true",!1),this.readyToAdjust=!0,this.adjustYAxis(h,s,i,!0);h=this.defineXAxisWidth();p=r!=t.NONE;this.getDomainAxis()&&this.getFirstRow()?(f=this.getFirstRow().getPlotArea(),c=100,f&&(c=f.width()),this.getDomainAxis().drawAxis(c,h,i,this.getXAxisName()),this.finishPlotting(n,r,u)):this.finishPlotting(n,r)},r.prototype.updateMenu=function(){var n,t;for(n in this.rows)t=this.rows[n],t.updateMenu(!1);this.getDomainAxis().updateMenu(!1)},r.prototype.finishPlotting=function(n,i,r){var u,f,e;r===void 0&&(r=!1);this.toolWindow&&i==t.NONE&&this.toolWindow.updateToolCombo();for(u in this.rows)f=this.rows[u],f.updateListenersAndMenu(i);e=i!=t.NONE;this.domainAxis.updateMenu(e);r||this.updateAllCursorGroups(i);this.updateMarkers();this.decorationOptions.isXAxisShown()&&(this.getDomainAxis().setupCurrentXAxisPadding(this.getNumberOfRows()),this.drawTickAndGridForAxis(this.needToPlotXAxis()));n.resolve();Project.Utility.trace("End of rows plotting",!1)},r.prototype.addPanButtonHover=function(){var t=this;this.getWaveContainerWrapper().hover(function(){t.setupPanButtons(n.PAN_STATE.SHOW)},function(){t.setupPanButtons(n.PAN_STATE.HIDE)})},r.prototype.needToPlotXAxis=function(){return this.isInWaveBox()?this.getFirstRow().getFirstWaveform().isConstantWaveform()?!0:!1:!0},r.prototype.getNumberOfRows=function(){var n=this.rows;return n?n.length:0},r.prototype.getPaper=function(){var n=this.getFirstRow();return n.getPaper()},r.prototype.getCurrentWidth=function(){var i=!1,r=this.getWaveContainerJQ(),n=r[0],t;return n&&(n.clientHeight<n.scrollHeight||n.clientWidth<n.scrollWidth)&&(i=!0),t=r.width()-this.getLegendWidth(),i&&(t-=this.scrollbarWidth),t<=0&&(t=1),t},r.prototype.findRangeByAxisName=function(n,t){var r,i;for(r in t)if(i=t[r],i.axisName==n)return i;return null},r.prototype.adjustYAxis=function(n,t,i,r){var e,o,u,f;for(Project.Utility.trace("Adjusting y Axis",!0),e=$.Deferred(),o=[],u=0;u<this.rows.length;u++)f=this.rows[u],f&&f.setupDataForPlot(n,t,i,r);Project.Utility.trace("Adjusting y axis took : ",!0)},r.prototype.getXAxisName=function(){var u,i,t,r;return this.decorationOptions.isXAxisLabelShown()?(u=this.getFirstRow(),!u)?n.WaveManager.NO_UNITS:(i=u.getFirstWaveform(),!i)?n.WaveManager.NO_UNITS:(t=i.getXName(),!t||t.length==0||t==n.WaveManager.NO_UNITS)?n.WaveManager.NO_UNITS:(r=i.getXUnits(),!r||r.length==0)?t:t+" ("+r+")":""},r.prototype.getXUnits=function(){var u=this.getFirstRow(),t,r,i;return u?(t=u.getFirstWaveform(),!t)?n.WaveManager.NO_UNITS:(r=t.getXName(),!r||r.length==0)?n.WaveManager.NO_UNITS:(i=t.getXUnits(),!i||i.length==0)?n.WaveManager.NO_UNITS:i:n.WaveManager.NO_UNITS},r.prototype.checkRowPosition=function(t,i,r){var f=t.getPlotArea().offset(),e=i-f.left+30,u=r-f.top;return u<-20?n.DROP_STATE.UNDEFINED_ROW:u<0?n.DROP_STATE.BEFORE_ROW:u>t.getPlotArea().height()?n.DROP_STATE.AFTER_ROW:e<0?n.DROP_STATE.UNDEFINED_ROW:n.DROP_STATE.IN_ROW},r.prototype.getDropState=function(t,i){var u=this.rows[0],e=this.checkRowPosition(u,t,i),o,r,s,f;if(e==n.DROP_STATE.UNDEFINED_ROW)return null;if(e==n.DROP_STATE.IN_ROW)return new n.WaveDropState(u,n.DROP_STATE.IN_ROW);if(e==n.DROP_STATE.BEFORE_ROW)return new n.WaveDropState(u,n.DROP_STATE.BEFORE_ROW);if(o=this.rows.length,o==1)return new n.WaveDropState(u,n.DROP_STATE.AFTER_ROW);if(r=this.rows[o-1],f=this.checkRowPosition(r,t,i),f==n.DROP_STATE.IN_ROW)return new n.WaveDropState(r,n.DROP_STATE.IN_ROW);if(f==n.DROP_STATE.AFTER_ROW)return new n.WaveDropState(r,n.DROP_STATE.AFTER_ROW);if(o==2)return new n.WaveDropState(u,n.DROP_STATE.AFTER_ROW);for(s=1;s<this.rows.length;s++){if(r=this.rows[s],f=this.checkRowPosition(r,t,i),f==n.DROP_STATE.IN_ROW)return new n.WaveDropState(r,n.DROP_STATE.IN_ROW);if(f!=e)return new n.WaveDropState(u,n.DROP_STATE.AFTER_ROW);u=r}return new n.WaveDropState(r,n.DROP_STATE.AFTER_ROW)},r.prototype.allowToDrop=function(t,i,r,u){var o,h,f,s,e;if(!u||(e=this.getDropState(t,i),!e)||(o=e.currentRow,!o))return n.ALLOW_DROP.NOT_ALLOWED;if(this.isEmpty())return n.ALLOW_DROP.IN_ROW;if(s=null,r instanceof n.Waveform){if(f=r,s=f.parentRow,h=f.workOptions,f&&!this.checkAxisForMatch(f.isLogXAxis()))return this.clear(),this.useLogXAxis=f.isLogXAxis(),n.ALLOW_DROP.IN_ROW}else e=this.getDropState(t,i),h=n.WorkOptions.getWorkOptionsByType(r);return e.state==n.DROP_STATE.IN_ROW?s&&o.isTheSameRow(s)?n.ALLOW_DROP.NOT_ALLOWED:o.getDropStatus(h):n.ALLOW_DROP.IN_ROW},r.prototype.performDropState=function(t,i,r,u){var f=$.Deferred(),s=this.allowToDrop(r,u,i,!0);if(s==n.ALLOW_DROP.NOT_ALLOWED)return f.resolve(),f.promise();if(s==n.ALLOW_DROP.AFTER_ROW)return t?(this.tryToPlotBelow(f,r,u,i),f.promise()):(f.resolve(),f.promise());if(this.isEmpty())return $.when(this.addAndPlotWaveforms(i,!0)).done(function(){f.resolve()}),f.promise();var e=this.getDropState(r,u),o=e.currentRow,h=i.parentRow;return e&&e.currentRow?(e.state==n.DROP_STATE.IN_ROW?o.addWaveformToRow(i):e.state==n.DROP_STATE.AFTER_ROW?this.addRowAfter(o,i):e.state==n.DROP_STATE.BEFORE_ROW&&this.addRowBefore(o,i),h&&this.deleteWaveformFromRow(i,!1,h),$.when(this.plotRows()).done(function(){f.resolve()})):(this.deleteWaveformFromParentRow(i,!1),$.when(this.addAndPlotWaveforms(i,!0)).done(function(){f.resolve()})),f.promise()},r.prototype.tryToPlotBelow=function(t,i,r,u){var f=this.getDropState(i,r),o=f.currentRow,e=u.parentRow;if(e&&o.isTheSameRow(e)){t.resolve(!0);return}f&&f.currentRow&&f.state==n.DROP_STATE.IN_ROW?(this.addRowAfter(o,u),e&&this.deleteWaveformFromRow(u,!1,e),$.when(this.plotRows()).done(function(){t.resolve(!0)})):t.resolve(!1)},r.prototype.isYAxisAlwaysVisible=function(){return this.decorationOptions.isYAxisShown()},r.prototype.isYAxisLabelAlwaysVisible=function(){return this.decorationOptions.isYAxisLabelShown()},r.prototype.isDecorationShown=function(){return this.isInWaveBox()&&this.getWavebox().isDecorationHidden()?!1:!0},r.prototype.insertRowToRowList=function(n,t){if(t>=this.rows.length)this.rows[this.rows.length]=n;else{t<0&&(t=0);for(var i=this.rows.length;i>t;i--)this.rows[i]=this.rows[i-1];this.rows[t]=n}},r.prototype.tryToSetInitialState=function(){return!this.rows||this.rows.length==0?(this.setViewAllForX(),this.useLogXAxis=!1,this.plotEmptyWaveform(),!0):!1},r.prototype.clear=function(){this.removeAllCursorGroups(!1);this.isEmpty()?this.plotEmptyContainer():(this.destroyAllRows(),this.tryToSetInitialState())},r.prototype.destroy=function(){this.removeAllCursorGroups(!1);this.destroyAllRows()},r.prototype.destroyAllRows=function(){for(var t,n=this.rows.length;n>=0;n--)t=this.rows[n],this.destroyAndRemoveFromRows(t)},r.prototype.isEmpty=function(){if(this.rows.length==0)return!0;if(this.rows.length==1){var n=this.rows[0];if(!n||n.isEmpty())return!0}return!1},r.prototype.checkAxisForMatch=function(n){var i=this.getFirstRow(),t;return i?(t=i.getFirstWaveform(),!t||t.isEmptyWaveform())?n==this.useLogXAxis:n==t.isLogXAxis():!0},r.prototype.restoreContainerDimensions=function(){var t=this.getWaveContainerJQ(),n=this.definePlaceholderDimensions();t.width(n.placeholderWidth);this.setHeight(n.placeholderHeight);this.decorationOptions.isToolbarShown()&&$(this.toolDiv).width(n.placeholderWidth)},r.prototype.plotEmptyWaveform=function(){this.addAndPlotWaveforms(n.Waveform.getEmptyWaveform(),!0)},r.prototype.addAndPlotWaveforms=function(n,t,i){var u=this,r=$.Deferred();if(!n)return r.resolve(),r.promise();var f=this.definePlaceholderDimensions(),e=f.placeholderWidth,o=f.placeholderHeight;return this.addWaveformsToNewRows(n,i,t),$.when(this.plotRows()).done(function(){u.checkDimensions(e,o)?r.resolve():$.when(u.plotRows()).done(function(){r.resolve()})}),r.promise()},r.prototype.checkDimensions=function(n,t){var i=this.definePlaceholderDimensions(),r=i.placeholderWidth,u=i.placeholderHeight;return u!=t||r!=n?!1:!0},r.prototype.addWaveformsToNewRows=function(n,t,i){var f=[],u=[],h=!1,c,o,e,r,s;if($.isArray(n)?f=n:(f.push(n),h=!0),c=f[0],c&&!this.checkAxisForMatch(c.isLogXAxis())&&(this.clear(),this.useLogXAxis=f[0].isLogXAxis()),t&&($.isArray(t)?u=t:(u.push(t),h=!0)),h||i){e=this.getNextEmptyRow();for(o in f){for(r=0;r<u.length;r++)u[r]&&e.setYVisibleRange(u[r].range,u[r].isViewAll);s=f[o];e.addWaveformToRow(s)}}else for(o in f){for(e=this.getNextEmptyRow(),r=0;r<u.length;r++)u[r]&&e.setYVisibleRange(u[r].range,u[r].isViewAll);s=f[o];e.addWaveformToRow(s)}},r.prototype.getNextEmptyRow=function(){var t=null,i;return this.rows.length==0?(t=new n.WaveRow(this,this.decorationOptions),this.insertRowToRowList(t,0),t):this.rows.length==1&&(i=this.rows[0],i.isEmpty())?i:(t=new n.WaveRow(this,this.decorationOptions),this.insertRowToRowList(t,this.rows.length),t)},r.prototype.addRowAfter=function(t,i){var u=this.getRowIndex(t),r=new n.WaveRow(this,this.decorationOptions);r.addWaveformToRow(i);this.addRowAfterRow(t,r)},r.prototype.addRowAfterRow=function(n,t){var i=t.getRowJQ(),r;i.insertAfter(n.getRowLegendJQ());t.getRowLegendJQ().insertAfter(i);r=this.getRowIndex(n);this.insertRowToRowList(t,r+1)},r.prototype.addRowBefore=function(t,i){var f=this.getRowIndex(t),r=new n.WaveRow(this,this.decorationOptions),u;r.addWaveformToRow(i);u=r.getRowJQ();u.insertBefore(t.getRowJQ());r.getRowLegendJQ().insertAfter(u);this.insertRowToRowList(r,f-1)},r.prototype.destroyAndRemoveFromRows=function(n){var i,r,t;n&&(i=n.getRowJQ(),r=n.getRowLegendJQ(),n.destroy(),t=this.getRowIndex(n),t>=0&&(this.rows[t]=null,this.rows.splice(t,1),i.remove(),r.remove(),i=null,r=null))},r.prototype.getRowIndex=function(n){for(var t=0;t<this.rows.length;t++)if(this.rows[t].isTheSameRow(n))return t;return-1},r.prototype.zoomIn=function(){var n=this.getFirstRow();n&&n.doZoom(!0)},r.prototype.zoomOut=function(){var n=this.getFirstRow();n&&n.doZoom(!1)},r.prototype.changeBackgroundColor=function(){var t=this.localColorIndex++,i,r;t=t%n.SVW_Colors.PALETTE_NUMBER;n.SVW_Colors.setTheme(this,t);i=n.SVW_Colors.getRowBackgroundColor(this);r=n.SVW_Colors.getThemeName(this);this.redraw()},r.prototype.getLegendWidth=function(){return this.decorationOptions.isLegendShown()?n.WaveManager.LEGEND_WIDTH:this.isDecorationShown()?10:0},r.prototype.getXAxisHeight=function(){return this.decorationOptions.isXAxisShown()&&this.decorationOptions.isXAxisLabelShown()?n.WaveManager.X_AXIS_HEIGHT:this.decorationOptions.isXAxisShown()?n.WaveManager.X_AXIS_HEIGHT_WITHOUT_NAME:10},r.prototype.getXAxisLabelHeight=function(){return this.decorationOptions.isXAxisShown()&&this.decorationOptions.isXAxisLabelShown()?n.WaveManager.X_LABEL_HEIGHT:this.decorationOptions.isXAxisShown()?n.WaveManager.X_TICK_FONT_SIZE:0},r.prototype.getXAxisTickHeight=function(){return this.decorationOptions.isXAxisShown()?n.WaveManager.X_TICK_LENGTH_FOR_WINDOW:0},r.prototype.getXAxisTicks=function(){return this.getDomainAxis()&&this.getDomainAxis().getPlotArea()?this.getDomainAxis().getPlotArea().getAxes().xaxis.ticks:[]},r.prototype.drawTickAndGridForAxis=function(t){var i=this.getXAxisTicks(),r=this.getRows(),u,f;for(u in r)f=r[u],f.drawTickAndGridForAxis(i,t);n.WaveUtils.drawTickAndGridForAxis(this.getDomainAxis().getPlotArea(),i,t,this.isLogXAxis())},r.prototype.deleteWdbWaveforms=function(n){for(var t,r=this.getRows(),i=r.length-1;i>=0;i--)t=r[i],t.deleteWdbWaveformsFromRow(n),t.isEmpty()&&this.destroyAndRemoveFromRows(t)},r.prototype.deleteWaveformFromParentRow=function(n,t){n&&this.deleteWaveformFromRow(n,t,n.parentRow)},r.prototype.deleteWaveformFromRow=function(n,t,i){n&&i&&(i.deleteWaveformFromRow(n),i.isEmpty()&&this.destroyAndRemoveFromRows(i),t&&(this.isEmpty()?this.plotEmptyWaveform():this.plotRows()))},r.prototype.getCurrentRowIndex=function(n){for(var t=0;t<this.rows.length;t++)if(this.rows[t]==n)return t;return-1},r.prototype.updateMarkers=function(){this.containerMeasManager.updateMarkers()},r.prototype.updateWaveformMarkers=function(n){this.containerMeasManager.updateWaveformMarkers(n)},r.prototype.removeMeasurement=function(n){this.containerMeasManager.removeMeasurement(n)},r.prototype.hasWaveformMeasurementWithMarkers=function(n){return this.containerMeasManager.hasWaveformMeasurementWithMarkers(n)},r.prototype.removeWaveformMeasurements=function(n,t){this.containerMeasManager.removeWaveformMeasurements(n,t)},r.prototype.getWaveformMeasurements=function(n){return this.containerMeasManager?this.containerMeasManager.getWaveformMeasurements(n):[]},r.prototype.getFormattedCursorXValue=function(t){var r=this.getXAxisState(),u=new n.AxisUnits(r.range.xmin,r.range.xmax,!0),i=u.formatCursorValue(t,this.isLogXAxis());if($.isNumeric(i))return i;var f=i.substr(0,i.length-1),e=i.substr(i.length-1);return f+e},r.prototype.updateBaseFlagForAllCursorGroup=function(){this.cursorGroupManager.updateAllCursorGroups()},r.prototype.removeCursorGroup=function(n,t){this.cursorGroupManager.removeCursorGroup(n,t)},r.prototype.addCursorGroup=function(n){return this.cursorGroupManager.addCursorGroup(n)},r.prototype.updateAllCursorGroups=function(n){n===void 0&&(n=t.NONE);this.cursorGroupManager.updateAllCursorGroups()},r.prototype.hideAllCursorGroups=function(){this.cursorGroupManager.hideAllCursorGroups()},r.prototype.removeAllCursorGroups=function(n){this.cursorGroupManager.removeAllCursorGroups(n)},r.prototype.getCursorStates=function(){return this.cursorGroupManager.getCursorStates()},r.prototype.getDefaultCursorXValue=function(){return this.cursorGroupManager.getDefaultCursorXValue()},r.prototype.adjustFlagPositions=function(){this.cursorGroupManager.adjustFlagPositions()},r.WAVE_CONTAINER_CLASS="svw-waveContainer",r.WAVE_ROW_CONTAINER_CLASS="svw-waveRowContainer",r.WAVE_TOOLBAR_CLASS="svw-toolbar",r.GLOBAL_WAVECONTAINER_ID=0,r.MINIMAL_ROW_HEIGHT=10,r.MINIMAL_CONTAINER_HEIGHT=2*r.MINIMAL_ROW_HEIGHT,r.CONTAINER_SPINNER_ID="svw-containerSpinner",r}();n.WaveContainer=r;u=function(){function n(){this.zoomStackList=[];this.lastRange=null}return n.prototype.addToStack=function(n){this.lastRange!=null&&this.zoomStackList.push(this.lastRange);this.lastRange=n},n.prototype.getAndRemoveFromStack=function(){var n,t;return(this.lastRange=null,n=this.zoomStackList.length,n==0)?null:(t=this.zoomStackList[n-1],this.zoomStackList.splice(n-1,1),this.lastRange=this.zoomStackList[n-2],t)},n.prototype.isStackEmpty=function(){return!this.zoomStackList||this.zoomStackList.length==0},n.prototype.clearStack=function(){this.zoomStackList=[];this.lastRange=null},n.prototype.getLastRange=function(){return this.lastRange},n.prototype.setLastRange=function(n){this.lastRange=n},n.prototype.setZoomList=function(n){n&&(this.zoomStackList=n)},n}();n.CommonZoomStack=u;h=function(){function n(n,t,i){this.xRange=null;this.rowId=null;this.YRange=null;n&&(this.xRange=n);t&&(this.rowId=t);i&&(this.YRange=i)}return n}();n.CommonZoomRange=h;f=function(){function n(t,i,r,u){this.backgroundColor="grey";this.tailId="tail"+n.GLOBAL_TAIL_INDEX++;this.$plotDiv=$(t);this.createTail(i,r,u)}return n.prototype.initTail=function(n,t,i){$(this.$plotDiv).append("<div id="+this.tailId+' style="position:absolute;z-index:56000"><\/div>');var r=$("#"+this.tailId),p=r[0],f=13,e=15,o=15,s=4,h=e,c=o,l=Raphael(p,100,100),u=l.text(h,c,n).attr({"text-anchor":"start"});u.attr({"stroke-width":.5,"font-size":f,stroke:t,"font-family":"'Open Sans', sans-serif"});var w=u.getBBox().width,a=u.getBBox().height,v=w+2*s,y=a,b=h-s,k=c-a/2+1,d=f/2,g=l.rect(b,k,v,y,d);return g.attr({fill:this.backgroundColor,opacity:.2,"stroke-width":1.5}),r.width(e+v),r.height(o+y),r.position({my:"right top",at:"center",of:i}),r.hide(),r},n.prototype.createTail=function(n,t,i){var u=this,r=this.initTail(n,t,i);$(window).bind("mousemove.tail",function(n){r.show();document.body.focus();r.position({my:"left top",at:"center",of:n})});$(window).bind("mouseup.tail",function(){$("#"+u.tailId).each(function(){document.body.focus();this.parentNode.removeChild(this)});$(window).unbind(".tail")})},n.GLOBAL_TAIL_INDEX=0,n}();n.TailDiv=f;e=function(){function t(n,t){this.buttons=[];this.toolDiv=t;this.waveContainer=n;this.toolbarId="toolbar_"+n.getId();this.addToolbar();var i=this.calcMinimalToolbarWidth(),r=t.width();r<i&&this.waveContainer.setParentWidth(i)}return t.prototype.addToolbar=function(){var f=document.createElement("div"),i,o,e;f.id=this.toolbarId;i=$(f);i.addClass("roundBorder gradient "+r.WAVE_TOOLBAR_CLASS);f.style.border="1px solid #B4B4B4";f.style.marginBottom="10px";i.appendTo(this.toolDiv);var u=this,t=this.addButton(i,"Add Cursor","glyphicon-flag");t.click(function(){u.waveContainer.addCursorGroup(null)});t=this.addButton(i,"Remove All Cursors","glyphicon-play-circle");t.click(function(){u.waveContainer.removeAllCursorGroups(!0)});t=this.addButton(i,"View All","glyphicon-eye-open");t.click(function(){u.waveContainer.viewAll()});t=this.addButton(i,"Clear Window","glyphicon-remove-sign");t.click(function(){u.waveContainer.clear()});t=this.addButton(i,"Zoom In","glyphicon-zoom-in");t.click(function(){u.waveContainer.zoomIn()});t=this.addButton(i,"Zoom Out","glyphicon-zoom-out");t.click(function(){u.waveContainer.zoomOut()});t=this.addButton(i,"Zoom Undo","glyphicon-share-alt");t.click(function(){u.waveContainer.undoZoom()});o="Not set";t=this.addButton(i,"Change Background Color","glyphicon-adjust");t.click(function(){u.waveContainer.changeBackgroundColor()});t=this.addButton(i,"Show Points","glyphicon-screenshot");t.click(function(){u.waveContainer.setShowHidePoints()});t=this.addButton(i,"Show Context Menu Examples","glyphicon-info-sign",!0);t.click(function(){new n.ExampleBox("Examples")});t.css("margin-right","5px");e=3;$(f).height(3*e+t.height());this.toolDiv.height($(f).height()+10)},t.prototype.calcMinimalToolbarWidth=function(){if(!this.buttons||this.buttons.length==0)return 0;return this.buttons.length*(this.buttons[0].scrollWidth+6)+10},t.prototype.addSeparator=function(n){var t=document.createElement("span");t.style.margin="0 .2em";$(t).appendTo(n)},t.prototype.addButton=function(n,i,r,u){var h=i+this.toolbarId+t.GLOBAL_BUTTON_ID++,f=document.createElement("button"),e,l;f.id=h;$(f).addClass("btn btn-info btn-xs svw-button");e=document.createElement("i");$(e).addClass("glyphicon-white glyphicon "+r);$(e).appendTo($(f));this.buttons.push(f);var o=this.calcMinimalToolbarWidth(),c=this.toolDiv.width(),s=!1;c<o&&(this.waveContainer.setParentWidth(o),s=!0);l=this;$(f).appendTo(n);u&&!s&&$(f).css("float","right");$(f).on("mouseenter mouseleave",function(n){var t=i;$(this).qtip({overwrite:!1,content:i,position:{at:"bottom right"},style:{classes:"svw-tooltip"},show:{event:n.type,ready:!0}})});return $(f)},t.GLOBAL_BUTTON_ID=0,t}();n.Toolbar=e;i=function(){function n(n,t){this.analogHeight=n;this.digitalHeight=t}return n}();n.RowHeights=i;o=function(){function t(){this.rowStates=[];this.cursorStates=[];this.isViewAllForX=!0;this.measurementStates=[]}return t.prototype.saveState=function(n){var e,c,f,s,h,u,t,l;for(this.rowStates=[],this.cursorStates=n.getCursorStates(),e=n.getRows(),t=0;t<e.length;t++)c=e[t].getRowState(),this.rowStates.push(c);for(this.rowStates.length!=0&&(this.xVisibleRange=n.getRealXVisibleState().range,this.isViewAllForX=n.isViewAllForX()),f=0;f<n.containerMeasManager.measurements.length;f++){var i=n.containerMeasManager.measurements[f],o=i.getRequest(),r=new ServerStructures.BaseMeasurementState;if(r.measurementRequest=o,r.waveformIndex=n.getPlottedWaveformIndex(i.wf.getFlotWaveformId()),r.waveformIndex2=n.getPlottedWaveformIndex(i.wf2.getFlotWaveformId()),i.markerManager&&(s=i.markerManager.getMarkerStates(),s))for(h=0;h<s.length;h++)if(o&&o.ReturnType==ServerStructures.ReturnType.LIST&&(u=i.markerManager.getShownMarkerStates(),u&&u.length!=0)){for(t=0;t<u.length;t++)l=JSON.stringify(u[t]),r.markerStatesJson.push(l);this.measurementStates.push(r)}}},t.prototype.getRowStates=function(){return this.rowStates},t.prototype.getCursorStates=function(){return this.cursorStates},t.prototype.getXVisibleState=function(){return ServerStructures.XAxisState.createXAxisState(this.xVisibleRange,this.isViewAllForX)},t.prototype.isViewAllForXRange=function(){return this.isViewAllForX},t.prototype.setWaveContainerState=function(t){var i,r;if(this.rowStates=[],t.rowStates)for(i=0;i<t.rowStates.length;i++)r=new n.RowState,r.setState(t.rowStates[i]),this.rowStates.push(r);this.cursorStates=t.cursorStates?t.cursorStates:[];this.xVisibleRange=t.xVisibleRange;this.isViewAllForX=t.isViewAllForX;this.measurementStates=t.measurementStates?t.measurementStates:[]},t}();n.WaveContainerState=o;s=function(){function n(){this.placeholderWidth=0;this.placeholderHeight=0}return n}();n.PlaceholderDimensions=s}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(n){this.cursorsList=[];this.waveContainer=n;this.initOriginalOptions()}return t.prototype.initCursorList=function(){this.cursorsList=[]},t.prototype.showMeasurementRange=function(n,t){var r=this.getPlotArea(),u=r.getAxes().xaxis,i=r.getOverlay().context,f=r.getPlotOffset(),p=r.getOptions();i.save();var e=u.p2c(n),o=u.p2c(t),s=0,h=r.height(),c=Math.min(e,o),l=Math.min(s,h),a=Math.abs(o-e),v=Math.abs(h-s),y=p.selection.color;i.strokeStyle=y;i.lineWidth=1;i.lineJoin="round";i.fillStyle=y;i.globalAlpha=.2;i.translate(f.left,f.top);i.fillRect(c,l,a,v);i.strokeRect(c,l,a,v);i.restore()},t.prototype.hideMeasurementRange=function(){var n=this.getPlotArea();n.triggerRedrawOverlay()},t.prototype.addZoomEscListener=function(){var n=this;$(document).bind("keydown.zoomEvent",function(t){t.which==Project.Design.EscKey&&n.cancelZoom()})},t.prototype.singleWaveformTest=function(n,t,i){var r=n.getVisibleYRange(),u;return r.ymin>t.ymax||r.ymax<t.ymin?!1:(u=n.isEmptyArea(i.xmin,i.xmax,t.ymin,t.ymax),!u)?!0:n.hasIntersectionWithArea(i.xmin,i.xmax,t.ymin,t.ymax)},t.prototype.cancelZoom=function(){n.SVWEventHandler.setIsMoving(null);this.waveContainer.hideSpinner();this.getPlotArea().clearSelection(!1);this.waveContainer.redraw();var t=this.getRowJQ();t.unbind("mousemove");t.unbind("mouseup");$(document).unbind(".zoomEvent")},t.prototype.findCursorByGroupId=function(n){var i,t;if(!this.cursorsList)return null;for(i in this.cursorsList)if(t=this.cursorsList[i],t.cursorGroup.getId()==n)return t;return null},t.prototype.removeAllCursorsInRow=function(){var t,n;if(this.cursorsList)for(t in this.cursorsList)n=this.cursorsList[t],n&&this.removeCursor(n.cursorGroup.getId())},t.prototype.getNumberOfCursors=function(){return this.cursorsList?this.cursorsList.length:0},t.prototype.updateCursorByXValue=function(n,t,i,r){var u=this.findCursorByGroupId(n.getId());u?u.updateByXValue(t,r):this.addCursor(n,t,i)},t.prototype.addCursor=function(t,i,r){var u=this.findCursorByGroupId(t.getId());u||(u=new n.WaveRowCursor(this,t,i,r),this.cursorsList.push(u))},t.prototype.updateBaseName=function(n,t){var r,i;for(r in this.cursorsList)i=this.cursorsList[r],i.cursorGroup.getId()==n?i.updateBaseName(t):i.updateBaseName(!t)},t.prototype.updateAsLocked=function(){var t,n;for(t in this.cursorsList)n=this.cursorsList[t],n&&n.updateAsLocked()},t.prototype.setCursorMenu=function(){var t,n;for(t in this.cursorsList)n=this.cursorsList[t],n&&n.setMenu()},t.prototype.removeCursorMenu=function(){var t,n;for(t in this.cursorsList)n=this.cursorsList[t],n&&n.unbindMenu()},t.prototype.removeCursor=function(n){var t=this.findCursorByGroupId(n);t&&(t.remove(),this.cursorsList.splice($.inArray(t,this.cursorsList),1),t=null)},t.prototype.hideCursor=function(n){var t=this.findCursorByGroupId(n);t&&t.hide()},t.prototype.showCursor=function(n){var t=this.findCursorByGroupId(n);t&&t.show()},t.prototype.highlightCursor=function(n,t){var i=this.findCursorByGroupId(n);i&&i.highlightCursor(t)},t.prototype.cursorOnTop=function(n){var t=this.findCursorByGroupId(n);t&&t.onTop()},t.prototype.getCursorYValue=function(n,t){var u=this.findCursorByGroupId(n),r,i;if(u)for(r=u.dataArray,i=0;i<r.length;i++)t.push(r[i].yValue)},t.prototype.getRowHeight=function(){return this.getPlotArea().height()},t.prototype.getRowWidth=function(){return this.getPlotArea().width()},t.prototype.calcXValueByPosition=function(n){var t=this.getPlotArea().getAxes();return t.xaxis.c2p(n)},t.prototype.calcPositionByXValue=function(n){var t=this.getPlotArea().getAxes();return t.xaxis.p2c(n)},t.prototype.getPlotOffset=function(){return this.getPlotArea().getPlotOffset()},t.prototype.getOffset=function(){return this.getPlotArea().offset()},t.prototype.getStringWidth=function(n){return this.getPlotArea().measureText(n)},t.prototype.doZoom=function(t){var f=this.waveContainer.getXAxisState().range,e=f.xmax,o=f.xmin,s=(o+e)/2,h=e-o,c=t?h/4:h,i=s-c,r=s+c,u=this.waveContainer.getOriginalXState().range,l;i<u.xmin&&(i=u.xmin);r>u.xmax&&(r=u.xmax);this.waveContainer.showSpinner();this.waveContainer.setXVisibleState(i,r,!1);this.waveContainer.addToZoomStack(new n.CommonZoomRange(new n.XWaveRange(i,r),null,null));l=this;$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState("x",null,n.PAN_DIRECTION.NONE))).done(function(){l.waveContainer.hideSpinner()})},t.DEFAULT_MINIMAL_DYNAMIC_RANGE=1e-18,t.GLOBAL_ROW_ID=0,t}();n.WaveRowBase=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t="waveboxAxis",i=function(i){function r(n,r,u){var f,e;i.call(this,n);this.axisId=null;this.axisId=t+n.getId();f=document.createElement("div");f.id=this.axisId;e=$(f);e.addClass(t);u.append(f);e.height(this.waveContainer.getXAxisHeight());this.initAxisOptions();this.setMenu()}return __extends(r,i),r.prototype.getRowId=function(){return this.axisId},r.prototype.getRowJQ=function(){return $("#"+this.axisId)},r.prototype.isEmpty=function(){return this.waveContainer.getFirstRow().isEmpty()},r.prototype.setupCurrentXAxisPadding=function(n){var t=this.getCurrentXAxisPadding(n),i="-"+t+"px",r=this.getRowJQ();r.css("margin-top",i)},r.prototype.getCurrentXAxisPadding=function(t){var i=this.waveContainer.getOptimalRowNumber(t);return t<=i,n.WaveManager.AXIS_PADDING},r.prototype.initOriginalOptions=function(){this.axisOption={series:{lines:{show:!1,lineWidth:0},shadowSize:0},grid:{aboveData:!0,labelMargin:0,borderWidth:0},selection:{mode:"x",color:"blue",minSize:3},yaxis:{show:!1,tickFormatter:n.AxisUtils.emptyFormatter},xaxis:{show:!0,position:"bottom",color:"black",tickColor:"black",tickLength:this.waveContainer.getXAxisTickHeight(),axisLabelUseCanvas:!0,axisLabelFontSizePixels:n.WaveManager.X_TICK_FONT_SIZE,axisLabelColour:n.WaveManager.AXIS_LABEL_COLOR,labelHeight:n.WaveManager.X_LABEL_HEIGHT,axisLabelPadding:0,labelWidth:n.WaveManager.X_LABEL_WIDTH},raphaelSupport:{useRaphael:!0,show:!0,rowId:null},isXAxisRow:!0}},r.prototype.initAxisOptions=function(){var r=this,t,i;return this.axisOption&&(t=n.SVW_Colors.getRowBackgroundColor(this.waveContainer),i=this.axisOption,this.axisOption=$.extend(!0,{},i,{grid:{backgroundColor:t},raphaelSupport:{rowId:r.axisId}})),this.axisOption},r.prototype.setRowPlot=function(n,t){var i,r;this.axisArea=n;i=n.getAxes();n&&t&&(r=this,this.initCursorList(),this.addXAxisListeners())},r.prototype.getPlotArea=function(){return this.axisArea},r.prototype.getPaper=function(){return this.axisArea.getPaper()},r.prototype.getPlottedWaveforms=function(){return[]},r.prototype.inResize=function(){return this.waveContainer.getFirstRow().inResize()},r.prototype.cancelSelection=function(){this.waveContainer.hideSpinner();this.getPlotArea().clearSelection(!1);this.waveContainer.redraw();this.waveContainer.disableSelectionMode();Project.MessageManager.showWarningMessage(n.WaveManager.ZOOMING_LIMIT_MESSAGE)},r.prototype.drawAxis=function(t,i,r,u){var f=this.getRowJQ(),s,h,e,o,c;f&&(s=Math.round(n.WaveManager.X_LABEL_WIDTH/2),f.width(t+n.WaveManager.X_LABEL_WIDTH),f.width()<=0&&f.width(1),h=this.waveContainer.isXAxisShown(),f.css("marginLeft",i-s),e=this.axisOption,o=$.extend(!0,{},e,{xaxis:{min:r.xmin,max:r.xmax,axisLabel:u,axisLabelUseCanvas:!0,ticks:n.XAxisTicks.tickGeneratorForLinearXAxis,isResize:this.inResize()},grid:{show:h}}),e=o,this.waveContainer.isLogXAxis()&&(o=$.extend(!0,{},e,{xaxis:{transform:n.WaveUtils.logAxis,inverseTransform:n.WaveUtils.expAxis,ticks:n.XAxisTicks.tickGeneratorForLogXAxis,isResize:this.inResize()}})),c=$.plot(f,[{}],o),this.setRowPlot(c,!0))},r.prototype.checkForSanity=function(n){if(!n||!n.xaxis)return!1;var t=this.axisArea.getAxes().xaxis,i=n.xaxis.from,r=n.xaxis.to;return Math.abs(t.p2c(i)-t.p2c(r))>3?!0:!1},r.prototype.axisMouseUpFunction=function(){var t=this.axisArea.getSelection();if(t){if(t.xaxis.to-t.xaxis.from<n.WaveUtils.ERROR_DELTA){this.cancelSelection();return}if(t.yaxis.to-t.yaxis.from<n.WaveUtils.ERROR_DELTA){this.cancelSelection();return}var u=this.axisArea.getOptions(),r=u.selection.mode,i=this.waveContainer;r=="x"&&this.checkForSanity(t)&&(i.setXVisibleState(t.xaxis.from,t.xaxis.to,!1),i.addToZoomStack(new n.CommonZoomRange(new n.XWaveRange(t.xaxis.from,t.xaxis.to),null,null)),i.showSpinner(),$.when(i.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState(r,this,n.PAN_DIRECTION.NONE))).done(function(){i.hideSpinner()}))}},r.prototype.axisMouseMoveFunction=function(){var t=this.axisArea.getSelection();if(t){if(t.xaxis.to-t.xaxis.from<n.WaveUtils.ERROR_DELTA){this.cancelSelection();return}if(t.yaxis.to-t.yaxis.from<n.WaveUtils.ERROR_DELTA){this.cancelSelection();return}this.waveContainer.setSelectionForOthers(null,t)}},r.prototype.addXAxisListeners=function(){var t=this,i=this.getRowJQ();i.mousedown(function(r){if(n.SVWEventHandler.isRightMouseButtonEvent(r)){this.menuPositionEvent=r;return}n.SVWEventHandler.getIsMoving()||(n.SVWEventHandler.setIsMoving(t),i.css("cursor","default"),t.addZoomEscListener(),$(document).bind("mouseup.zoomEvent",function(){n.getManager().triggerZoom()}),i.mousemove(function(i){n.SVWEventHandler.getIsMoving()==t&&t.axisMouseMoveFunction(i)}),i.mouseup(function(r){n.SVWEventHandler.getIsMoving()==t&&(n.SVWEventHandler.setIsMoving(null),i.unbind("mousemove"),i.unbind("mouseup"),$(document).unbind(".zoomEvent"),t.axisMouseUpFunction(r))}))})},r.prototype.disableSelectionMode=function(){var n=this.axisOption;this.axisOption=$.extend(!0,{},n,{selection:{mode:null}})},r.prototype.enableSelectionMode=function(){var n=this.axisOption;this.axisOption=$.extend(!0,{},n,{selection:{mode:"x",color:"blue",minSize:3}})},r.prototype.setSelection=function(n,t){var i=this.getPlotArea(),r=i.getAxes(),u={xaxis:{from:t.xaxis.from,to:t.xaxis.to},yaxis:{from:r.yaxis.min,to:r.yaxis.max}};i.setSelectionMode("x");i.setSelection(u,!0)},r.prototype.getFirstWaveform=function(){return this.waveContainer.getFirstRow().getFirstWaveform()},r.prototype.createMenu=function(){if(!this.rowMenu){var t=new n.MenuDriver(this);this.rowMenu=t.createMenu()}},r.prototype.setMenu=function(){this.createMenu();this.rowMenu.bindMenuTo("#"+this.getRowId())},r.prototype.updateMenu=function(n){n||(this.removeMenu(),this.setMenu())},r.prototype.removeMenu=function(){this.rowMenu&&(this.rowMenu.unbindMenuFrom("#"+this.getRowId(),!0),this.rowMenu.removeMenu(),this.rowMenu=null)},r}(n.WaveRowBase);n.DomainAxis=i}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var r=function(i){function r(t,r){var u,f;i.call(this,t);this.isViewAllForXFlag=!0;this.isViewAllForYFlag=[];this.currentYRanges=[];this.showYAxisLabel=!0;this.zeroLevelFlag=!1;this.isResizingMode=!1;this.waveforms=[];this.rowId="waveboxRow"+n.WaveRowBase.GLOBAL_ROW_ID++;this.rowLegendId="legend"+this.rowId;this.decorOptions=r;u=t.getWaveContainerJQ();u.append("<DIV ID="+this.rowId+"><\/DIV>");f=this.getRowJQ();f.addClass("waveboxRow").width(u.width()-this.waveContainer.getLegendWidth()).addClass("floatoneline");r.isLegendShown()&&(u.append("<DIV ID="+this.rowLegendId+"><\/DIV>"),this.getRowLegendJQ().addClass("waveboxRowLegend").css({"border-top":"6px solid transparent"}).addClass("floatoneline"));this.initRowOptions();this.adjustWaveformColors();this.rowPanButtons=new n.RowPanButtons(this)}return __extends(r,i),r.prototype.getRowLegendJQ=function(){return $("#"+this.rowLegendId)},r.prototype.getRowJQ=function(){return $("#"+this.rowId)},r.prototype.getRowId=function(){return this.rowId},r.prototype.isTheSameRow=function(n){return this.getRowId()==n.getRowId()},r.prototype.setRowHeight=function(n){this.getRowJQ().height(n)},r.prototype.getRowState=function(){var n=new t;return n.saveState(this),n},r.prototype.getWaveforms=function(){return this.waveforms},r.prototype.getWaveform=function(n){if(n<0||n>=this.waveforms.length)return null;var t=this.waveforms[n];return t&&!t.isEmptyWaveform()?t:null},r.prototype.getProbeWaveform=function(n){for(var t,i=0;i<this.waveforms.length;i++)if(t=this.waveforms[i],t&&!t.isEmptyWaveform()&&t.isProbeWaveformForProbe(n))return t;return null},r.prototype.getCalculatorWaveformForProbe=function(n){for(var t,i=0;i<this.waveforms.length;i++)if(t=this.waveforms[i],t&&!t.isEmptyWaveform()&&t.isCalculatorWaveformForProbe(n))return t;return null},r.prototype.removeEmptyWavform=function(){if(this.waveforms==null)this.waveforms=[];else if(this.waveforms.length==1){var n=this.waveforms[0];n.isEmptyWaveform()&&(n.remove(!0),n=null,this.waveforms=[])}},r.prototype.addWaveformToList=function(t){if(this.removeEmptyWavform(),t instanceof n.Waveform)this.waveforms.push(t);else for(var i=0;i<t.length;i++)this.waveforms.push(t[i])},r.prototype.hasMultipleYAxis=function(){var n=this.getPlotArea(),t;return n&&n.getYAxes()?(t=n.getYAxes(),t&&t.length>1):!1},r.prototype.canShowZeroLevel=function(){var n,t;if(this.isEmpty()||this.hasMultipleYAxis())return!1;for(n=0;n<this.waveforms.length;n++)if(t=this.waveforms[n],!t.isEmptyWaveform()&&!t.workOptions.canShowZeroLevel())return!1;return!0},r.prototype.canApplyMathOperationsInRow=function(){var n,t;if(this.isEmpty())return!0;for(n=0;n<this.waveforms.length;n++)if(t=this.waveforms[n],!t.isEmptyWaveform()&&!this.canApplyMathToWaveform(t.workOptions))return!1;return!0},r.prototype.canApplyMathOperations=function(n){var t,i;if(this.isEmpty()||n.isEmpty())return!0;for(t=0;t<n.waveforms.length;t++)if(i=n.waveforms[t],!i.isEmptyWaveform()&&!this.canApplyMathToWaveform(i.workOptions))return!1;return!0},r.prototype.canApplyMathToWaveform=function(n){for(var i,t=0;t<this.waveforms.length;t++)if(i=this.waveforms[t],!i.isEmptyWaveform()&&!i.workOptions.canApplyMathOperations(n))return!1;return!0},r.prototype.canPlotRowInOverlay=function(n){var t,i;if(this.isEmpty()||n.isEmpty())return!0;for(t=0;t<n.waveforms.length;t++)if(i=n.waveforms[t],!i.isEmptyWaveform()&&!this.canPlotWaveformInRow(i.workOptions))return!1;return!0},r.prototype.canPlotWaveformInRow=function(t){return this.getDropStatus(t)==n.ALLOW_DROP.IN_ROW?!0:!1},r.prototype.getDropStatus=function(t){var u,r,i;if(this.isEmpty())return n.ALLOW_DROP.IN_ROW;var f=!1,e=!1,o=!1;for(u=0;u<this.waveforms.length;u++)r=this.waveforms[u],r.isEmptyWaveform()||(r.workOptions.workType==n.WORK_TYPE.ANALOG?f=!0:r.workOptions.workType==n.WORK_TYPE.DIGITAL?e=!0:r.workOptions.workType==n.WORK_TYPE.RAILROAD&&(o=!0));return(i=!0,f&&i&&(i=t.canPlotWithAnalog()),e&&i&&(i=t.canPlotWithDigital()),o&&i&&(i=t.canPlotWithRailroad()),i)?n.ALLOW_DROP.IN_ROW:n.ALLOW_DROP.AFTER_ROW},r.prototype.isConstantRow=function(){for(var t,n=0;n<this.waveforms.length;n++)if(t=this.waveforms[n],!t.isConstantWaveform())return!1;return!0},r.prototype.hasAnyAnalogHeightWaveform=function(){var n,t;if(this.isEmpty())return!0;for(n=0;n<this.waveforms.length;n++)if(t=this.waveforms[n],!t.workOptions.useDigitalHeight())return!0;return!1},r.prototype.hasAnyDigitalHeightWaveform=function(){var n,t;if(this.isEmpty())return!1;for(n=0;n<this.waveforms.length;n++)if(t=this.waveforms[n],t.workOptions.useDigitalHeight())return!0;return!1},r.prototype.hasAnyYAxis=function(t){var i,u,r;if(!t){for(i=0;i<this.waveforms.length;i++)if(u=this.waveforms[i],u.workOptions.canShowYAxis())return!0;return!1}return(r=n.WorkOptions.getWorkOptionsByAxis(t),r)?r.canShowYAxis():!0},r.prototype.canZoomYAxis=function(t){var i=n.WorkOptions.getWorkOptionsByAxis(t);return i?i.canZoomYAxis():!0},r.prototype.canShowPoints=function(){var n,t;if(this.isEmpty())return!0;for(n=0;n<this.waveforms.length;n++)if(t=this.waveforms[n],!t.workOptions.canShowPoints())return!1;return!0},r.prototype.initOriginalOptions=function(){var t=this;this.originalRowOptions={grid:{clickable:!1,autoHighlight:!1,borderWidth:n.WaveManager.GRID_BORDER_WIDTH,markingsColor:"#f4f4f4"},legend:{labelBoxBorderColor:"#ccc",labelFormatter:function(n,t){return'<div class ="legendLabel" id=legendLabel'+t.waveformId+">"+n+"<\/div>"}},lines:{show:!1},shadowSize:0,points:{show:!0},bars:{show:!1},xaxis:{show:!1},selection:{mode:"xy",color:"blue",minSize:3},raphaelSupport:{useRaphael:!0,show:!0,isResizingMode:!1},yaxis:{tickColor:"#ccc",autoscaleMargin:.01,color:"black",axisLabelColour:n.WaveManager.AXIS_LABEL_COLOR,tickLength:this.waveContainer.getXAxisTickHeight()},isXAxisRow:!1}},r.prototype.drawTickAndGridForAxis=function(t,i){n.WaveUtils.drawTickAndGridForAxis(this.getPlotArea(),t,i,this.waveContainer.isLogXAxis(),this.canShowZeroLevel())},r.prototype.setBackgroundColor=function(t){var i=this.rowOptions,u=n.SVW_Colors.getRowBackgroundColor(this.waveContainer),r=this;this.rowOptions=$.extend(!0,{},i,{grid:{backgroundColor:t},raphaelSupport:{rowId:r.getRowId()}})},r.prototype.getAxisWidth=function(){var n=this.getPlotArea().getPlotOffset();return n.left},r.prototype.getFirstAxisWidth=function(){var t=this.getPlotArea().getYAxes(),r,u,i,f;if(!t||t.length==0)return n.WaveManager.MINIMAL_Y_AXIS_WIDTH;for(r=n.WaveManager.MINIMAL_Y_AXIS_WIDTH,u=0,i=0;i<t.length;i++)t[i]&&t[i].box&&(f=t[i].box.left,f>u&&(u=f,r=t[i].box.width));return r},r.prototype.initRowOptions=function(){var r=this,t,i;return this.rowOptions||(t=n.SVW_Colors.getRowBackgroundColor(this.waveContainer),i=this.originalRowOptions,this.rowOptions=$.extend(!0,{},i,{grid:{backgroundColor:t},raphaelSupport:{rowId:r.getRowId()}})),this.originalRowOptions.xaxis.show=this.decorOptions.isXAxisShown(),this.rowOptions},r.prototype.showHideDecorations=function(n){var t=this.rowOptions;n?this.getRowLegendJQ().show():this.getRowLegendJQ().hide()},r.prototype.getYVisibleRange=function(t){var r=t.getYAxisNameWithUnits(),i=this.getCurrentVisibleRangeForAxis(r);return i||(i=n.YWaveRange.getEmptyRange()),i},r.prototype.getPlotArea=function(){return this.plotArea},r.prototype.getXOriginalRange=function(){return this.getXMinMaxForRow()},r.prototype.getYOriginalRange=function(n){return this.getYOriginalRanges()[n]},r.prototype.getYOriginalRanges=function(){return this.getYMinMaxForRow()},r.prototype.isViewAllForX=function(){return this.isViewAllForXFlag},r.prototype.isViewAllForY=function(n){return this.isViewAllForYFlag.hasOwnProperty(n)?this.isViewAllForYFlag[n]:(this.isViewAllForYFlag[n]=!0,this.isViewAllForYFlag[n])},r.prototype.isViewAllForAllYAxis=function(){for(var n=0;n<this.waveforms.length;n++){var t=this.waveforms[n],i=t.getYAxisNameWithUnits(),r=this.isViewAllForY(i);if(!r)return!1}return!0},r.prototype.viewAll=function(){this.isViewAllForXFlag=!0;this.isViewAllForYFlag=[];this.waveContainer.clearZoomStack();this.yZoomNotify(null,!0)},r.prototype.getCurrentVisibleRangeForAxis=function(n){return this.isViewAllForY(n)?this.currentYRanges=this.getYOriginalRanges():this.currentYRanges||(this.currentYRanges=this.getYOriginalRanges()),this.currentYRanges[n]},r.prototype.getPlotYRangeForAxis=function(t){var i,r,u;return this.getPlotArea()?(i=n.WorkOptions.getWorkOptionsByAxis(t),i&&(r=i.getYRange(!1),r))?r:(u=this.getPlotArea().getAxes().yaxis,new n.YWaveRange(u.min,u.max,t,!1)):this.currentYRanges[t]},r.prototype.setYVisibleRange=function(t,i){this.currentYRanges[t.axisName]=new n.YWaveRange(t.ymin,t.ymax,t.axisName,t.useAsConstant);this.isViewAllForYFlag[t.axisName]=i;this.yZoomNotify(t,i)},r.prototype.yZoomNotify=function(n,t){var r,i,u;if(this.getWavebox())for(r=this.getPlottedWaveforms(),i=0;i<r.length;i++)u=r[i],this.getWavebox().notify(ProbeModule.ChangeEvents.Y_ZOOM,u.sourceInfo.objectIndex,n,t)},r.prototype.getSelectedYAxis=function(){return this.getPlotArea().getSelection()?this.getPlotArea().getSelectedAxis():null},r.prototype.getZoomYRanges=function(t,i){var r=[],e=this,u=e.getPlotArea().getYAxes(),f=this.getSelectedYAxis();return $.each(u,function(e,o){var s="y"+o.n+"axis",h,c;t[s]||o.n!=1||(s="yaxis");t[s]&&(h=o.options.axisLabel?o.options.axisLabel:n.WaveManager.NO_UNITS,i!="y"?r.push(new n.YWaveRange(t[s].from,t[s].to,h,!1)):f!=null&&o.n==u[f].n?(c=new n.YWaveRange(t[s].from,t[s].to,h,!1),c.isForSelectedAxis=!0,r.push(c)):r.push(new n.YWaveRange(o.min,o.max,h,!1)))}),r},r.prototype.cancelSelection=function(n){this.waveContainer.hideSpinner();this.getPlotArea().clearSelection(!1);this.waveContainer.redraw();this.waveContainer.disableSelectionMode();n&&Project.MessageManager.showWarningMessage(n)},r.prototype.axisMouseDown=function(n){var i=this.getRowJQ(),t;i.css("cursor","default");t=this.getZoomMode(n);this.waveContainer.setCurrentZoomMode(t);this.getPlotArea().setSelectionMode(t)},r.prototype.axisMouseMove=function(){var n=this.getPlotArea(),i=n.getSelection(),r,t;if(i){var s=this.getRowJQ(),h=n.getPlotOffset(),c=n.height(),u=this.waveContainer.getCurrentZoomMode();if(u!="y")this.waveContainer.setSelectionForOthers(this,i);else{var f=n.getSelectedAxis(),e=n.getYAxes(),o=e[f];for(r in this.waveforms)t=this.waveforms[r],t&&t.getYAxisNameWithUnits()==o.options.axisLabel?t.highlightWaveformAndLegend(!0):t.highlightWaveformAndLegend(!1)}}},r.prototype.ySelectionSanityCheck=function(t){for(var i,r=0;r<t.length;r++){if(i=t[r],i.isForSelectedAxis&&!this.canZoomYAxis(i.axisName))return n.WaveManager.ZOOMING_DIGITAL_MESSAGE;if(n.WaveUtils.almostEqual(i.ymin,i.ymax))return n.WaveManager.ZOOMING_LIMIT_MESSAGE}return null},r.prototype.fixYRangeArray=function(t){for(var r,u,i=0;i<t.length;i++)r=t[i],this.canZoomYAxis(r.axisName)||(u=n.WorkOptions.getWorkOptionsByAxis(r.axisName),t[i]=u.getYRange(!0))},r.prototype.axisMouseUp=function(){var a=this,h=this.getPlotArea(),i=h.getSelection(),r,o,e,v,l,t,s;if(i){this.waveContainer.showSpinner();var u=this.waveContainer.getCurrentZoomMode(),f=null,c=null;if(n.WaveUtils.almostEqual(i.xaxis.to,i.xaxis.from)){this.cancelSelection(n.WaveManager.ZOOMING_LIMIT_MESSAGE);return}if(f=new n.XWaveRange(i.xaxis.from,i.xaxis.to),r=this.getZoomYRanges(i,u),o=this.ySelectionSanityCheck(r),o){this.cancelSelection(o);return}if(this.fixYRangeArray(r),e=!0,u!="x"?e=this.rangeSanityCheck(r,f):this.waveContainer.getRows().length==1&&(e=this.rangeSanityCheck(r,f)),!e){this.cancelSelection(n.WaveManager.ZOOMING_EMPTY_MESSAGE);return}u!="y"&&this.waveContainer.setXVisibleState(i.xaxis.from,i.xaxis.to,!1);v=h.getAxes();for(l in r)t=r[l],Math.abs(t.ymin-t.ymax)<n.WaveUtils.ERROR_DELTA&&(t.ymax=t.ymin+n.WaveUtils.ERROR_DELTA),this.setYVisibleRange(t,!1),t.isForSelectedAxis&&(c=new n.YWaveRange(t.ymin,t.ymax,t.axisName,t.useAsConstant));s=null;u=="y"&&(s=this.getRowId());this.waveContainer.addToZoomStack(new n.CommonZoomRange(f,s,c));$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState(u,this,n.PAN_DIRECTION.NONE))).done(function(){a.waveContainer.hideSpinner()})}},r.prototype.rangeSanityCheck=function(t,i){for(var u,r=0;r<t.length;r++){if(u=t[r],Math.abs(u.ymin-u.ymax)<n.WaveUtils.ERROR_DELTA)return!1;if(this.singleRangeTest(u,i))return!0}return!1},r.prototype.singleRangeTest=function(n,t){for(var r=this.getPlottedWaveformsForYAxis(n.axisName),i=0;i<r.length;i++)if(this.singleWaveformTest(r[i],n,t))return!0;return!1},r.prototype.addSelectionListeners=function(){var t=this,i=this.getRowJQ();i.mousedown(function(r){if(n.SVWEventHandler.isRightMouseButtonEvent(r)){t.menuPositionEvent=r;return}n.SVWEventHandler.getIsMoving()||(n.SVWEventHandler.setIsMoving(t),t.addZoomEscListener(),t.axisMouseDown(r),$(document).bind("mouseup.zoomEvent",function(){n.getManager().triggerZoom()}),i.mousemove(function(i){n.SVWEventHandler.getIsMoving()==t&&t.axisMouseMove(i)}),i.mouseup(function(r){n.SVWEventHandler.getIsMoving()==t&&(n.SVWEventHandler.setIsMoving(null),t.axisMouseUp(r),i.unbind("mousemove"),i.unbind("mouseup"),$(document).unbind(".zoomEvent"))}))})},r.prototype.highlightLegendLabel=function(n,t,i){i?(t||(t=this.getPlotArea().getOptions().legend.backgroundColor,t="transparent"),$(n).css("font-weight","bold"),$(n).css("background-color",t)):($(n).css("font-weight","normal"),$(n).css("background-color","transparent"))},r.prototype.highlightLegendBox=function(n,t){t||(t=this.getPlotArea().getOptions().legend.labelBoxBorderColor);$(n).children(":first").css("border-color",t)},r.prototype.setSelection=function(n,t){var i=this.getPlotArea(),r=i.getAxes(),u={xaxis:{from:t.xaxis.from,to:t.xaxis.to},yaxis:{from:r.yaxis.min,to:r.yaxis.max}};i.setSelectionMode("x");i.setSelection(u,!0)},r.prototype.clickHandle=function(n){if(n){var t=this.waveContainer.getToolWindow();t.isOpened()&&t.selectNewWaveform(n)}},r.prototype.addEventHandlers=function(){var t=this,r=this.getRowLegendJQ(),f=this.getPlotArea().getOptions().legend.labelBoxBorderColor,i=r.find("div.legendLabel"),u=r.find("td.legendColorBox");this.addDraggable(i);this.addTooltipToLegend(i);u.click(function(){var n=t.findLegendLabelForColorBox($(this)),i=t.getWaveformForLegendLabel(n[0].id);t.clickHandle(i)});i.mouseover(function(){var i=t.getWaveformForLegendLabel(this.id);i&&n.getManager().getCrossHighlightManager().crossHighlightByWaveform(i,!0)}).mouseout(function(){var i=t.getWaveformForLegendLabel(this.id);i&&n.getManager().getCrossHighlightManager().crossHighlightByWaveform(i,!1)});u.mouseover(function(){var r=t.findLegendLabelForColorBox($(this)),i=t.getWaveformForLegendLabel(r[0].id);i&&n.getManager().getCrossHighlightManager().crossHighlightByWaveform(i,!0)}).mouseout(function(){var r=t.findLegendLabelForColorBox($(this)),i=t.getWaveformForLegendLabel(r[0].id);i&&n.getManager().getCrossHighlightManager().crossHighlightByWaveform(i,!1)});this.setMenu()},r.prototype.addTooltipToLegend=function(n){var t=this;n.on("mouseenter mouseleave",function(n){var i=t.getWaveformForLegendLabel(this.id),u=t.waveContainer.getCurrentWidth();if(i&&i.label!=i.getFullWaveformName()){var f=i.getWaveformDataForFlot().length,r=i.getFullWaveformName();$(this).qtip({overwrite:!1,content:r,position:{my:"top middle",at:"bottom left"},style:{classes:"svw-tooltip"},show:{event:n.type,ready:!0,delay:1e3}})}})},r.prototype.addDraggable=function(t){var i=this,u=function(r,u){if(u)return n.SVWEventHandler.setIsMoving(t),r.preventDefault(),i.waveContainer.createTail(u.getFullWaveformName(),u.getColor(),r),setBodyCursor("move"),{}},f=function(n,t){return setBodyCursor("auto"),t&&i.waveContainer.performDropState(!1,t,n.pageX,n.pageY),{}},r=!1;t.mousedown(function(e){var h,o,s;if(!n.SVWEventHandler.getIsMoving()&&n.SVWEventHandler.isLeftMouseButtonEvent(e)){e.preventDefault();i.addEscListener();h=$(e.target).attr("id");o=i.getWaveformForLegendLabel(h);n.SVWEventHandler.setIsMoving(t);r=!1;s={x:e.clientX,y:e.clientY};$("body").on("mousemove.legendLabel",function(f){if(n.SVWEventHandler.getIsMoving()==t){r||(u(e,o),r=!0);var s=i.waveContainer.allowToDrop(f.pageX,f.pageY,o,!0);s!=n.ALLOW_DROP.IN_ROW?setBodyCursor("not-allowed"):setBodyCursor("move")}});$("body").mouseup(function(r){if(n.SVWEventHandler.getIsMoving()==t){r.preventDefault();var u=!1;(r.clientX!==s.x||r.clientY!==s.y)&&(u=!0);n.SVWEventHandler.setIsMoving(null);u?(n.getManager().canDragWaveform()&&f(r,o),n.getManager().resetWaveformDragging()):(i.clickHandle(o),n.getManager().resetWaveformDragging());$(t).off("mousemove");$("body").off("mousemove.legendLabel");$("body").off("mouseup");i.removeEscListener()}})}})},r.prototype.addEscListener=function(){$(document).bind("keydown.waveformDrag",function(t){t.which==Project.Design.EscKey&&(n.getManager().cancelWaveformDragging(),$("body").trigger("mouseup"))})},r.prototype.removeEscListener=function(){$(document).unbind("keydown.waveformDrag")},r.prototype.findColorBoxForLegendLabel=function(n){return n.closest("td").prev("td.legendColorBox")},r.prototype.findLegendLabelForColorBox=function(n){return n.next("td.legendLabel").children(":first")},r.prototype.addWaveformToRow=function(n){var t,i;n&&(n.parentRow&&(t=n.parentRow),n.parentRow=this,this.addWaveformToList(n),i=n.getYAxisNameWithUnits())},r.prototype.deleteWaveformFromRow=function(n){n&&(n.remove(!0),this.waveforms.splice($.inArray(n,this.waveforms),1),n=null)},r.prototype.deleteWdbWaveformsFromRow=function(n){for(var i,t=this.waveforms.length-1;t>=0;t--)i=this.waveforms[t],i&&i.wdbId==n&&this.deleteWaveformFromRow(i)},r.prototype.isEmpty=function(){var n=this.getWaveforms(),t;return!n||n.length==0?!0:n.length==1?(t=n[0],t.isEmptyWaveform())?!0:t.getWaveformHandle()==null?!0:!1:!1},r.prototype.clearRow=function(){var t,n;for(t in this.waveforms)n=this.waveforms[t],n&&n.remove(!1)},r.prototype.destroy=function(){var t,n;this.removeMenu();this.removeAllCursorsInRow();for(t in this.waveforms)n=this.waveforms[t],n&&n.remove(!0);this.rowPanButtons.remove();this.rowPanButtons=null},r.prototype.disableSelectionMode=function(){var n=this.rowOptions;this.rowOptions=$.extend(!0,{},n,{selection:{mode:null}})},r.prototype.enableSelectionMode=function(){var n=this.rowOptions;this.rowOptions=$.extend(!0,{},n,{selection:{mode:"xy",color:"blue",minSize:3}})},r.prototype.getBorderColor=function(){return this.waveContainer.isDecorationShown()?null:"transparent"},r.prototype.inResize=function(){return this.isResizingMode},r.prototype.startResizingMode=function(){this.isResizingMode=!0},r.prototype.stopResizingMode=function(){this.isResizingMode=!1},r.prototype.prepareYAxisOptions=function(t){var s=[],o,f,i,e,r,u,h;for(f in t){if(i=void 0,e=n.WorkOptions.getWorkOptionsByAxis(f),!e.canShowYAxis()){i=e.getYRange(!0);o={show:!1,min:i.ymin,max:i.ymax};s.push(o);continue}if(i=this.getCurrentVisibleRangeForAxis(f),r=i.ymin,u=i.ymax,!i.useAsConstant&&this.isViewAllForY(f)&&(h=.1*n.AxisUtils.getAxisRange(r,u),r-=h,u+=h),this.isViewAllForY(f))o=this.decorOptions.isYAxisShown()?this.decorOptions.isYAxisLabelShown()&&this.showYAxisLabel?i.useAsConstant?{axisLabel:f,axisLabelUseCanvas:!0,axisLabelFontSizePixels:n.WaveManager.X_TICK_FONT_SIZE,ticks:e.getTickGenerator(),isResize:this.inResize(),min:r,max:u}:{axisLabel:f,axisLabelUseCanvas:!0,axisLabelFontSizePixels:n.WaveManager.X_TICK_FONT_SIZE,ticks:e.getTickGenerator(),isResize:this.inResize(),min:r,max:u}:"":{ticks:!1,min:r,max:u};else{if(!i){console.log("Error: range is null");return}o=this.decorOptions.isYAxisShown()?this.decorOptions.isYAxisLabelShown()&&this.showYAxisLabel?{axisLabel:f,axisLabelUseCanvas:!0,axisLabelFontSizePixels:n.WaveManager.X_TICK_FONT_SIZE,min:r,max:u,ticks:e.getTickGenerator(),isResize:this.inResize()}:{min:r,max:u,ticks:e.getTickGenerator(),isResize:this.inResize()}:{ticks:!1,min:r,max:u}}s.push(o)}return s},r.prototype.setupDataForPlot=function(t,i,r,u){var o=this.rowOptions,f=this.getRowJQ(),c=this.getRowLegendJQ(),l,s,y,p;f.width(i);l=f.height();s=n.WaveUtils.DEFAULT_LINE_HEIGHT*this.waveforms.length+n.WaveManager.GRID_BORDER_WIDTH;l<s&&this.setRowHeight(s);c.width(this.waveContainer.getLegendWidth()).css("overflow","hidden");var a=[],v=[],e=0;u&&(e=t-this.getPlotArea().getPlotOffset().left,f.width(i-e),f.css("marginLeft",e));this.mapSignals(a,v,r);y=this.prepareYAxisOptions(a);this.clearRow();var w=n.SVW_Colors.getRowBackgroundColor(this.waveContainer),b=n.SVW_Colors.getGridLineColor(this.waveContainer),h=$.extend(!0,{},o,{yaxes:y,yaxis:{show:this.decorOptions.isYAxisShown(),tickColor:"black"},grid:{show:!0,offsetShift:e,backgroundColor:w,markingsColor:b,borderColor:this.getBorderColor()},legend:{show:!0,container:c},xaxis:{min:r.xmin,max:r.xmax},raphaelSupport:{useRaphael:u,rowId:this.getRowId(),show:u,isResizingMode:this.inResize()}});o=h;this.waveContainer.isLogXAxis()&&(h=$.extend(!0,{},o,{xaxis:{transform:n.WaveUtils.logAxis,inverseTransform:n.WaveUtils.expAxis}}));p=$.plot(f,v,h);this.setRowPlot(p,u)},r.prototype.waitForPlot=function(n,t){n.isPlotted()?t.resolve():setTimeout(function(){n.waitForPlot(n,t)},10)},r.prototype.resetBeforePlot=function(){for(var t,n=0;n<this.waveforms.length;n++)t=this.waveforms[n],t.isEmptyWaveform()?t.setPlotted():t.setUnplotted()},r.prototype.isPlotted=function(){for(var t,n=0;n<this.waveforms.length;n++)if((t=this.waveforms[n],!t.isEmptyWaveform())&&!t.isPlotted())return!1;return!0},r.prototype.setPlotAreaForWaveforms=function(n){var i,t;for(i in this.waveforms)t=this.waveforms[i],t.isEmptyWaveform()||t.setPlot(n)},r.prototype.updateListenersAndMenu=function(t){var r,i,u;for(r in this.waveforms)i=this.waveforms[r],i.isEmptyWaveform()||i.updateListeners();t==n.RESIZE_MODE.VERTICAL&&this.addEventHandlers();u=t!=n.RESIZE_MODE.NONE;this.updateMenu(u)},r.prototype.getWaveformForElement=function(n,t){var r,i;if(!this.waveforms||!n)return null;t||(t="");for(r in this.waveforms)if(i=this.waveforms[r],t+i.getFlotWaveformId()==n)return i;return null},r.prototype.getWaveformForLegendLabel=function(n){return this.getWaveformForElement(n,"legendLabel")},r.prototype.getWaveformForLegendBox=function(n){return this.getWaveformForElement(n,"legendColorBox")},r.prototype.getWaveformById=function(n){var i,t;for(i in this.waveforms)if(t=this.waveforms[i],t.getFlotWaveformId()==n)return t;return null},r.prototype.getZoomMode=function(n){return this.checkForAllYAxes(n,this.getPlotArea())!=null?"y":"xy"},r.prototype.checkForAllYAxes=function(n,t){var e=t.getAxes().xaxis,u=t.getYAxes(),f=0,r,i;for(r in u){if(i=u[r],this.checkForYAxis(n,t,i,f))return r;i.box&&(f+=i.box.width)}return null},r.prototype.checkForYAxis=function(n,t,i,r){var u=t.getAxes().xaxis,f=t.offset(),e=n.pageX-f.left,o=n.pageY-f.top,s=u.p2c(u.min),c=i.p2c(i.min),l=i.p2c(i.max),h=i.box;return h?e<s-h.width-r||e>s?!1:o<l||o>c?!1:!0:!1},r.prototype.setRowPlot=function(n,t){this.plotArea=n;var i=this.getRowJQ().height(),r=this.plotArea.height();n&&t&&(this.initCursorList(),this.addEventHandlers());this.addSelectionListeners();this.plotArtefacts(!1);this.setPlotAreaForWaveforms(this.plotArea)},r.prototype.getZeroLevelFlag=function(){return this.zeroLevelFlag},r.prototype.setZeroLevelFlag=function(n){this.zeroLevelFlag=n},r.prototype.plotArtefacts=function(n){this.plotZeroLevel(n)},r.prototype.plotZeroLevel=function(n){if(!n&&this.hasMultipleYAxis()){this.zeroLevelFlag=!1;this.updateMenu(!1);return}this.zeroLevelFlag?this.addZeroLine(n):this.removeZeroLine(n)},r.prototype.setPreviousYRange=function(n){this.previousYRange=n},r.prototype.getPreviousYRange=function(){return this.previousYRange},r.prototype.addZeroLine=function(t){var r=this,e=null,u=this.getFirstWaveform(),o=u.getYAxisNameWithUnits(),f=!1,i=this.getCurrentVisibleRangeForAxis(o);u&&u.workOptions.canShowZeroLevel()&&(t&&(this.setPreviousYRange(new n.YWaveRange(i)),i.ymin>0?(i.ymin=-.01*Math.abs(i.ymax-i.ymin),f=!0):i.ymax<0&&(i.ymax=0,f=!0),e=i),t&&f?(this.setYVisibleRange(e,!1),$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState("y",this,n.PAN_DIRECTION.NONE))).done(function(){r.drawZeroLine(r.getPlotArea());r.waveContainer.hideSpinner()})):this.drawZeroLine(this.getPlotArea()))},r.prototype.removeZeroLine=function(t){var e=this,u,i;if(this.zeroLine&&(u=this.getFirstWaveform(),u))if(i=u.getYAxisNameWithUnits(),this.isViewAllForY(i))this.erazeZeroLine(),this.viewAll();else{var r=this.getPreviousYRange(),o=this.getCurrentVisibleRangeForAxis(i),f=!1;r?f=r.ymin==o.ymin&&r.ymax==o.ymax:(r=this.getCurrentVisibleRangeForAxis(i),f=!0);t&&!f?(this.setYVisibleRange(r,this.isViewAllForY(i)),$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState("y",this,n.PAN_DIRECTION.NONE))).done(function(){e.erazeZeroLine();e.waveContainer.hideSpinner()})):this.erazeZeroLine()}},r.prototype.erazeZeroLine=function(){this.zeroLine&&(this.zeroLine.remove(),this.zeroOutline.remove(),this.zeroLine=null,this.zeroOutline=null)},r.prototype.drawZeroLine=function(t){var s;if(this.zeroLevelFlag){var u=t.getPaper(),h=t.getAxes().yaxis,i=t.getAxes().xaxis,c=i.p2c(i.min),l=i.p2c(i.max),f=h.p2c(0),e=this.getPlotOffset(),o=n.WaveUtils.getTransformString(e.left,e.top),r="M "+c+" "+f;r+=" L "+l+" "+f;this.zeroLine=u.path(r);s=n.SVW_Colors.ZERO_LEVEL_COLOR;this.zeroLine.attr({stroke:s});this.zeroLine.transform(o);this.zeroOutline=u.path(r);this.zeroOutline.attr({opacity:0});this.zeroOutline.transform(o);this.zeroOutline.attr("stroke-width","5");$(this.zeroOutline.node).qtip({content:{text:"Zero Level"},position:{target:"mouse",adjust:{mouse:!0}},style:{classes:"svw-tooltip"}})}},r.prototype.getPaper=function(){return this.getPlotArea()?this.getPlotArea().getPaper():null},r.prototype.getPlottedWaveforms=function(){var t=[],i,n;for(i in this.waveforms)n=this.waveforms[i],n.isEmptyWaveform()||t.push(n);return t},r.prototype.getPlottedWaveformsForYAxis=function(n){var i=[],u,t,r;if(!n)return i;for(u in this.waveforms)t=this.waveforms[u],t.isEmptyWaveform()||(r=t.getYAxisNameWithUnits(),r&&r==n&&i.push(t));return i},r.prototype.checkForColor=function(n,t){var i,r;if(!n)return!1;for(i=0;i<this.waveforms.length;i++)if(i!=t&&(r=this.waveforms[i],r.getColor()&&r.getColor()==n))return!0;return!1},r.prototype.checkForColorIndex=function(n,t){var i,r;if(n<0)return!1;for(i=0;i<this.waveforms.length;i++)if(i!=t&&(r=this.waveforms[i],r.getColorIndex()&&r.getColorIndex()==n))return!0;return!1},r.prototype.getFirstWaveform=function(){return this.waveforms?this.waveforms[0]:null},r.prototype.getAxes=function(){return this.getPlotArea()?this.getPlotArea().getAxes():null},r.prototype.adjustWaveformColors=function(){var t,i;if(this.waveforms.length!=0&&this.waveforms.length!=1)for(t=1;t<this.waveforms.length;t++)i=this.waveforms[t],i.setColorIndex(n.SVW_Colors.adjustColorByRow(i.getColorIndex(),this,t))},r.prototype.mapSignals=function(n,t){var s=this.getRowJQ().width(),e=1,r=1,h=!this.decorOptions.isYAxisShown()||!this.decorOptions.isYAxisLabelShown(),o,i,u,f;for(o in this.waveforms)i=this.waveforms[o],i.parentRow=this,i.setWaveContainer(this.waveContainer),i.color=i.getColor(),u=i.getYAxisNameWithUnits(),n.hasOwnProperty(u)?r=n[u]:(r=e++,n[u]=r),i.setYAxis(r),i.hasOwnProperty("data")?t.push(i):(f=jQuery.extend(!0,{},i),f.data=i.getWaveformDataForFlot(),t.push(f),i=f);return e-1},r.prototype.getXMinMaxForRow=function(){var t,i,r,u;if(!this.waveforms||this.waveforms.length==0)return new n.XWaveRange(0,1);if(this.waveforms.length==1)return new n.XWaveRange(this.waveforms[0].getXWaveformMin(),this.waveforms[0].getXWaveformMax());for(t=null,i=null,r=0;r<this.waveforms.length;r++)u=this.waveforms[r],u.isEmptyWaveform()||(t=n.WaveUtils.getMin(t,u.getXWaveformMin()),i=n.WaveUtils.getMax(i,u.getXWaveformMax()));return t==null||i==null?new n.XWaveRange(0,1):new n.XWaveRange(t,i)},r.prototype.getYMinMaxForRow=function(){var t=[],f,u,i;this.waveforms&&this.waveforms.length!=0||(t[n.WaveManager.NO_UNITS]=n.YWaveRange.getEmptyRange());for(f in this.waveforms){var r=this.waveforms[f],e=r.getYAxisNameWithUnits(),o=!1;for(u in t)if(i=t[u],u==e){i.ymin=Math.min(i.ymin,r.getWholeYRange().ymin);i.ymax=Math.max(i.ymax,r.getWholeYRange().ymax);o=!0;break}o||(t[e]=r.getWholeYRange())}return t},r.prototype.storePointOption=function(n){var t,i;if(!this.isResizingMode)for(t=0;t<this.waveforms.length;t++)i=this.waveforms[t],n[i.getWaveformHandle()]=i.points.show,i.points.show=!1},r.prototype.restorePointOption=function(n){for(var t,r,i=0;i<this.waveforms.length;i++)t=this.waveforms[i],r=!1,n[t.getWaveformHandle()]&&(r=n[t.getWaveformHandle()],n[t.getWaveformHandle()]=!1),t.points.show=r},r.prototype.getWavebox=function(){return this.waveContainer.getWavebox()},r.prototype.createMenu=function(){if(!this.rowMenu){var t=new n.MenuDriver(this);this.rowMenu=t.createMenu()}},r.prototype.setMenu=function(){this.createMenu();this.rowMenu.bindMenuTo("#"+this.getRowId())},r.prototype.updateWaveformMenu=function(){var t,n;for(t in this.waveforms)n=this.waveforms[t],n&&!n.isEmptyWaveform()&&n.updateMenu()},r.prototype.updateMenu=function(n){n||(this.removeMenu(),this.setMenu());this.updateWaveformMenu()},r.prototype.removeMenu=function(){this.rowMenu&&(this.rowMenu.unbindMenuFrom("#"+this.getRowId(),!0),this.rowMenu.removeMenu(),this.rowMenu=null)},r.prototype.hightlightYAxis=function(t,i,r){var f=this.getPlotArea().getYAxes(),u;if((!t||!(f.length<2))&&(u=this.findAxisByName(t),u)){var e=".flot-"+u.direction+u.n+"-axis",o=r?i:n.WaveManager.TICK_LABEL_COLOR,s=r?"bold":"normal",h=this.getRowJQ().find(e).find(".tickLabel");h.each(function(){$(this).css("color",o);$(this).css("font-weight",s)})}},r.prototype.findAxisByName=function(n){for(var i,r=this.getPlotArea().getYAxes(),t=0;t<r.length;t++)if(i=r[t],i.options.axisLabel==n)return i;return null},r}(n.WaveRowBase),i,t;n.WaveRow=r;i=function(){function n(n,t,i,r,u){this.redundantPoints=[];this.element=n;this.elementOutline=t;this.xaxis=i;this.yaxis=r;u&&(this.pathArray=u)}return n}();n.FlotInfo=i;t=function(){function t(){this.waveformStates=[]}return t.prototype.saveState=function(n){var i=n.getWaveforms(),r,t;if(i)for(r in i)t=i[r],t&&!t.isEmptyWaveform()&&this.waveformStates.push(t.getWaveformState())},t.prototype.setState=function(t){var i,r;if(this.waveformStates=[],t.waveformStates)for(i=0;i<t.waveformStates.length;i++)r=new n.WaveformState,r.setState(t.waveformStates[i]),this.waveformStates.push(r)},t.prototype.getWaveformStates=function(){return this.waveformStates},t}();n.RowState=t}(WaveViewer||(WaveViewer={})),function(n){var i=function(){function t(){this.intersectionByX=function(n,t,i,r,u){var f=r-t,e=u-i,o=i*r-u*t;return(e*n+o)/f};this.intersectionByY=function(n,t,i,r,u){var f=r-t,e=u-i,o=i*r-u*t;return(f*n-o)/e}}return t.getTextParameters=function(n,t,i){var r=t.text(0,0,n);r.attr({"font-size":i});var u=r.getBBox(),f=u.width,e=u.height;return r.remove(),{width:f,height:e}},t.getPositionIndex=function(n,t,i,r,u,f){return n<=i?t>=f?0:t<=f&&t>=u?3:6:n>=i&&n<=r?t>=f?1:t<=f&&t>=u?4:7:t>=f?2:t<=f&&t>=u?5:8},t.defineSegmentPosition=function(n,t){if(!n||!t)return-1;switch(n){case 0:switch(t){default:case 0:case 1:case 2:case 3:case 6:return-1;case 4:return 1;case 5:case 7:case 8:return 0}case 1:switch(t){default:case 0:case 1:case 2:case 3:case 6:return-1;case 4:case 7:return 1;case 5:case 8:return 0}default:case 2:case 5:case 8:return-1;case 3:switch(t){default:case 0:case 1:case 2:case 3:case 6:return-1;case 4:case 5:return 1;case 7:case 8:return 0}case 4:return 1;case 6:switch(t){default:case 0:case 3:case 6:case 7:case 8:return-1;case 4:return 1;case 1:case 2:case 5:return 0}case 7:switch(t){default:case 0:case 3:case 6:case 7:case 8:return-1;case 1:case 4:return 1;case 2:case 5:return 0}}},t.isStringEmpty=function(n){return n?n.length==0?!0:!1:!0},t.tmpSpan=function(n,t){var r="<span id = 'string_span' style = 'font-weight: bold; font-size: "+t+";'>"+n+"<\/span>",i;return $("body").append(r),i=$("#string_span").width(),$("#string_span").remove(),i},t.defineScrollBarWidth=function(){$("body").append('<div id="wide_scroll_div_one" style="width:50px;height:50px;overflow-y:scroll;position:absolute;top:-200px;left:-200px;"><div id="wide_scroll_div_two" style="height:100px;width:100%"><\/div><\/div>');var n=$("#wide_scroll_div_one").width(),t=$("#wide_scroll_div_two").innerWidth(),i=n-t;return $("#wide_scroll_div_one").remove(),i},t.calcLabelWidth=function(n,i){return t.tmpSpan(n,i)},t.truncateText=function(n,t,i){var r=!1,f=i.getBBox().width,u;return f>=n&&(u=Math.round(n/(f/t.length)),u>3?(t=t.substr(0,u-3),i.attr("text",t+"..."),r=!0):u==3?(i.attr("text","..."),r=!0):(i.attr("text"," "),r=!0)),r},t.limitNameForMenu=function(n){if(!n)return"";if(n.length<=5)return n;var t=n.split("/"),i=t[t.length-1];return t.length>1&&(i=".../"+i),i},t.limitName=function(i){var e,o;if(!i)return"";var r=i,u=n.WaveManager.MAX_LEGEND_LENGTH,f=r.length;if(f>u){if(e=t.tmpSpan(i,""+n.WaveManager.LEGEND_FONT_SIZE),o=t.defineScrollBarWidth(),u=Math.floor(f*(n.WaveManager.LEGEND_WIDTH-o)/e),f<u)return i;var s=Math.floor((u-2)/2),h="",c="",l=t.getSubname(r,u-1);return l?"..."+l:(h=r.substring(0,s),c=r.substring(f-s),h+"..."+c)}return r},t.getSubname=function(n,t){var r=n.indexOf(PATH_SEPARATOR),i=n,u;return r>0?(i=n.substring(r+1),u=i.length,u<t?i:this.getSubname(i,t)):null},t.lessOrAlmostEqual=function(n,i){return n<=i?!0:t.almostEqual(n,i)},t.greaterOrAlmostEqual=function(n,i){return n>=i?!0:t.almostEqual(n,i)},t.inRange=function(n,i){return t.greaterOrAlmostEqual(n,i.min)&&t.lessOrAlmostEqual(n,i.max)},t.getBrowserWindowWidth=function(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0},t.isWaveform=function(t){return t==n.WaveManager.ANALOG_WF||t==n.WaveManager.STEP_WF||t==n.WaveManager.HISTOGRAM_WF||t==n.WaveManager.SCATTER_WF||t==n.WaveManager.SPECTRAL_WF||t==n.WaveManager.STD_LOGIC_WF||t==n.WaveManager.QSIM_12STATE_WF||t==n.WaveManager.BOOLEAN_WF||t==n.WaveManager.VHDL_CHAR_WF||t==n.WaveManager.BIT_WF||t==n.WaveManager.ENUMERATED_WF||t==n.WaveManager.STRING_WF||t==n.WaveManager.BUS_WF||t==n.WaveManager.BUS?!0:!1},t.isDigitalWaveform=function(t){return t==n.WaveManager.STD_LOGIC_WF||t==n.WaveManager.BOOLEAN_WF||t==n.WaveManager.BIT_WF?!0:!1},t.isBus=function(t){return t==n.WaveManager.BUS?!0:!1},t.isEqualWithNull=function(n,t){return n==null&&t==null?!0:n==null||t==null?!1:n==t},t.getMin=function(n,t){return n==null?t:t==null?n:Math.min(n,t)},t.getMax=function(n,t){return n==null?t:t==null?n:Math.max(n,t)},t.replaceAll=function(n,i,r){return r.replace(new RegExp(t.escapeRegExp(n),"g"),i)},t.escapeRegExp=function(n){return n.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")},t.logAxis=function(t){return t<=0&&(t=n.WaveRowBase.DEFAULT_MINIMAL_DYNAMIC_RANGE),Math.log(t)},t.expAxis=function(n){return Math.exp(n)},t.createScalarAspectId=function(n,t){return n+"_"+t},t.getHandleByHandle=function(n){var t=n.indexOf("_");return t>0?n.substring(0,t):n},t.getTransByHandle=function(n){var t=n.indexOf("_");return t>0?n.substring(t+1):null},t.getSinglePointMinMax=function(i,r){var u=[],f;return t.almostEqual(i,r)||r-i<n.WaveRowBase.DEFAULT_MINIMAL_DYNAMIC_RANGE?(Math.max(Math.abs(i),Math.abs(r))<n.WaveRowBase.DEFAULT_MINIMAL_DYNAMIC_RANGE?(u[0]=-1,u[1]=1):(f=Math.abs(i*.01),u[0]=i-f,u[1]=i+f),{isAlmostConstant:!0,min:u[0],max:u[1]}):{isAlmostConstant:!1,min:-1,max:1}},t.isScalarForComplexWaveform=function(t){return t?t==n.WaveManager.SCALAR_DBMAG?!0:t==n.WaveManager.SCALAR_IMAG_PART?!0:t==n.WaveManager.SCALAR_MAGNITUDE?!0:t==n.WaveManager.SCALAR_PHASE?!0:t==n.WaveManager.SCALAR_REAL_PART?!0:!1:!1},t.compareStrings=function(n,t){var i,r;return n==t?!0:!n||!t?!1:(i=n.replace(/&nbsp;/g,""),i=n.replace(/ /g,""),r=t.replace(/&nbsp;/g,""),r=t.replace(/ /g,""),i==r)},t.isCorrectValue=function(n){return n==null?!1:isNaN(n)||!isFinite(n)?!1:!0},t.fixInfinite=function(n){return isNaN(n)||n==t.SHOW_NAN?t.AS_NAN:n==t.SHOW_INFINITY||n==t.SHOW_POS_INFINITY?t.AS_POS_INFINITY:n==t.SHOW_NEG_INFINITY?t.AS_NEG_INFINITY:isFinite(n)?n:t.AS_POS_INFINITY},t.getInfiniteRepresentation=function(n,i,r){return n==null||isNaN(n)?{val:i,name:t.SHOW_NAN}:n==Number.POSITIVE_INFINITY?{val:r,name:t.SHOW_POS_INFINITY}:{val:i,name:t.SHOW_NEG_INFINITY}},t.createDesignRequestForWaveform=function(i,r,u,f,e,o,s,h,c,l){var a=new ServerStructures.DesignDataRequest,v=new ServerStructures.ContainerDataRequest(0),y=new ServerStructures.RowDataRequest(0),p=t.createWaveformDataRequestElem(i,r,u,f,e,o,s,n.PAN_DIRECTION.NONE,h,c,l);return p&&(y.putWaveformElement(p),v.putRowRequest(y),a.putContainerRequest(v)),a},t.createWaveformDataRequestElem=function(t,i,r,u,f,e,o,s,h,c,l){var v=n.ViewerRequests.getNumDivsForRequest(h),a=new ServerStructures.WaveformDataRequestElemClient(c,l);return a.divisions=v,a.includeMetadata=f,a.resultId=t,a.waveformId=i,a.xmax=u,a.xmin=r,a.wdbId=e,a.waveformColor=o,a.panDirection=s,a},t.extractCompInstName=function(n){if(!n)return null;var t=n,i=n.split(PATH_SEPARATOR);return i.length>0&&(t=i[0]),t},t.extractTransformedName=function(n){if(!n)return null;var i=null,r=n.split(PATH_SEPARATOR);return r.length<2?null:(i=r[r.length-1],!t.isScalarForComplexWaveform(i))?null:i},t.extractCompWfName=function(n,i){var u,r,f,e;return n?(u=null,r=n.split(PATH_SEPARATOR),r.length<2)?null:(i?(f=r[r.length-1],e=!t.isScalarForComplexWaveform(f),u=t.combineName(r,e)):u=t.combineName(r,!0),u):null},t.extractBusBitName=function(n){var i,t;return n?(i=null,t=n.split(PATH_SEPARATOR),t.length<2)?n:t[t.length-1]:null},t.combineName=function(n,t){for(var r=n[1],i=2;i<n.length;i++)i!=n.length-1?r+=PATH_SEPARATOR+n[i]:t&&(r+=PATH_SEPARATOR+n[i]);return r},t.getNameWithoutSuffix=function(n){var t=n.indexOf("[");return t<0?n:n.substr(0,t)},t.getDigitalDigits=function(n){var t=(""+n).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0},t.drawTickAndGridForAxis=function(i,r,u,f,e){var o,h,c,s,l;e===void 0&&(e=!1);o=i.getSurface().context;i.svw_ticks=r;h=i.getOptions();i.svw_ticks&&i.svw_ticks.length>0&&(h.isXAxisRow?f?(c=new n.PlotTicksLog(i),c.plotXLogAxisTicks(o,u)):t.drawXAxisLine(i,u):(s=new n.PlotYTicks(i),l=i.getYAxes(),s.drawHorizontalGridLines(o,l[0],e),s.drawVerticalGridLines(f)))},t.drawXAxisLine=function(n,t){var r;if(t){var i=n.getSurface().context,e=n.getOptions(),u=n.getPlotOffset(),f=n.getAxes().xaxis;i.save();i.strokeStyle=f.options.color;i.translate(u.left,u.top);r=12;i.beginPath();i.moveTo(0,-r+4.5);i.lineTo(n.width(),-r+4.5);i.stroke();i.strokeStyle=f.options.color;i.restore()}},t.hasPossibleIntersection=function(n,t){return n.x1<t.x1&&n.x2<t.x2?!1:n.x1>t.x2&&n.x2>t.x2?!1:n.y1<t.y1&&n.y2<t.y1?!1:n.y1>t.y2&&n.y2>t.y2?!1:!0},t.getLineIntersection=function(n,t){var i=n.x2-n.x1,r=n.y2-n.y1,u=t.x2-t.x1,f=t.y2-t.y1,e=n.x1-t.x1,o=n.y1-t.y1,s=(-r*e+i*o)/(-u*r+i*f),h=(u*o-f*e)/(-u*r+i*f);return s>=0&&s<=1&&h>=0&&h<=1?!1:!0},t.isDigitalYAxis=function(t){return t?t==n.WaveManager.NO_UNITS?!0:t==n.WaveManager.DIGITAL_Y_AXIS?!0:!1:!1},t.joinWithoutDuplication=function(n,i,r,u,f){var e=n.length-1,o=t.almostEqual(n[e][0],r[0][0]),s=f?i[e]==u[0]:!0;return o&&s&&(n.splice(e),i.splice(e),r.splice(0,1),u.splice(0,1)),n.push.apply(n,r),i.push.apply(i,u),{points:n,yValues:i}},t.getRequestRange=function(t,i){var r=i?null:t?t.range.xmin:null,u=i?null:t?t.range.xmax:null;return ServerStructures.XAxisState.createXAxisState(new n.XWaveRange(r,u),i)},t.copyToClipboard=function(n){var t=$("<input>"),i;$("body").append(t);t.val(n).select();try{i=document.execCommand("copy")}catch(r){i=!1}return t.remove(),i},t.DEFAULT_LINE_HEIGHT=20,t.ERROR_DELTA=1e-12,t.MAX_PRECISION=10,t.EQUAL_DELTA=1e-18,t.DBL_DIG=15,t.DOUBLE_RESOLUTION=Math.pow(10,-(t.DBL_DIG-1)),t.calcDistance=function(n,t,i,r,u,f){var e=f-r,o=u-i,s=r*u-f*i,h=Math.sqrt(e*e+o*o);return Math.abs((e*n+o*t+s)/h)},t.getTransformString=function(n,t){return" T "+n+","+t},t.adjustValPrecision=function(n){return n==null?"null":n.toFixed(t.MAX_PRECISION)},t.almostEqual=function(n,i){if(n==null||i==null)return!1;if(n==i)return!0;var r=n<0?-n:n,u=i<0?-i:i,f=r>=u?r:u,e=f*t.DOUBLE_RESOLUTION;return n-=i,r=n<0?-n:n,r<e},t.traceTime=0,t.allTime=0,t.AS_NAN=11e156,t.AS_POS_INFINITY=11e106,t.AS_NEG_INFINITY=-11e106,t.AS_NAN_LEVEL=11e149,t.AS_INFINITY_LEVEL=11e84,t.SHOW_NAN="NaN",t.SHOW_POS_INFINITY="+Infinity",t.SHOW_NEG_INFINITY="-Infinity",t.SHOW_INFINITY="Infinity",t}(),t;n.WaveUtils=i;t=function(){function n(n,t,i,r){n<=i?(this.x1=n,this.y1=t,this.x2=i,this.y2=r):(this.x1=i,this.y1=r,this.x2=n,this.y2=t)}return n}();n.Line=t}(WaveViewer||(WaveViewer={})),function(n){var i="waveCursorGroup",r=function(){function r(n,t){this.isBaseCursor=!1;this.showFlagOnRight=!0;this.waveformMap=[];this.isBlocked=!1;var u=r.GLOBAL_CURSOR_ID++;this.cursorGroupName=r.CURSOR_GROUP_NAME+u;this.id=i+u;this.waveContainer=n;this.xUnits=n.getXUnits();t?this.setState(t):this.updateMenu();this.setXValueForRowCursors(t.xValue,!1)}return r.prototype.isShownFlagOnRight=function(){return this.showFlagOnRight},r.prototype.isShownFlagOnLeft=function(){return!this.showFlagOnRight},r.prototype.setLeftFlagPosition=function(){this.showFlagOnRight=!1},r.prototype.setRightFlagPosition=function(){this.showFlagOnRight=!0},r.prototype.getId=function(){return this.id},r.prototype.getName=function(){return this.cursorGroupName},r.prototype.getXValue=function(){return this.xValue},r.prototype.getXUnits=function(){return this.xUnits},r.prototype.getState=function(){var n=new t;return n.xValue=this.getXValue(),n},r.prototype.setState=function(n){this.xValue=n.xValue;this.showFlagOnRight=!0;this.updateMenu()},r.prototype.setXValueForRowCursors=function(n,t){var i=this.waveContainer.getOriginalXState().range;n<i.xmin?n=i.xmin:n>i.xmax&&(n=i.xmax);this.xValue=n;this.xUnits=this.waveContainer.getXUnits();this.waveformMap=[];this.updateByXValue(!1);t||this.checkAndUpdateCursorsYValue(!0)},r.prototype.setXUnits=function(n){return this.xUnits=n},r.prototype.setGroupAsBase=function(n,t){this.isBaseCursor=n;this.updateBaseName();t&&this.waveContainer.updateBaseFlagForAllCursorGroup(this.getId(),n)},r.prototype.updateBaseName=function(){var n,i,t,r;if(this.waveContainer.isXAxisShown()){n=this.isBaseGroup();for(i in this.waveContainer.getRows())t=this.waveContainer.getRows()[i],t&&t.updateBaseName(this.getId(),n);this.waveContainer.getDomainAxis().updateBaseName(this.getId(),n);r=n?"<b>Base cursor : <b>"+this.cursorGroupName:"<b>Cursor : <b>"+this.cursorGroupName;this.cursorGroupMenu.setTitle(r);this.cursorGroupMenu.selectCheckBox(this.baseCursorMenuElement,n)}},r.prototype.getMenu=function(){return this.cursorGroupMenu},r.prototype.isBaseGroup=function(){return this.isBaseCursor},r.prototype.isYValueResolved=function(n){return this.waveformMap[n.getWaveformHandle()]!=null},r.prototype.removeMenu=function(){var n,t,i;if(this.cursorGroupMenu){for(n=0;n<this.waveContainer.getRows().length;n++)t=this.waveContainer.getRows()[n],t&&t.removeCursorMenu();i=this.waveContainer.getDomainAxis();i&&i.removeCursorMenu();this.cursorGroupMenu.removeMenu();this.cursorGroupMenu=null}},r.prototype.updateMenu=function(){var n,t,i;for(this.removeMenu(),this.createMenu(),n=0;n<this.waveContainer.getRows().length;n++)t=this.waveContainer.getRows()[n],t&&t.setCursorMenu();i=this.waveContainer.getDomainAxis();i&&i.setCursorMenu()},r.prototype.createMenu=function(){var n=new SVWebContextMenu.MenuContent(this);n.addMenuElement("Set X Value...",this.moveToXValue);n.addMenuElement("Delete",function(n){n.waveContainer.removeCursorGroup(n,!0)});this.cursorGroupMenu=SVWebContextMenu.MenuHelper.createMenu(n)},r.prototype.moveToXValue=function(n){n.moveToXValueInternal()},r.prototype.validator=function(n,t,i){var r=Project.CompProperty.validator.ValidateInputValue(i,t);return r.match("^Invalid")?(n.qtip("destroy"),n.qtip({content:r,position:{my:"right bottom",at:"left middle",target:$(n)},style:{classes:"svw-tooltip"}}),n.qtip("show"),!1):(n.qtip("destroy"),!0)},r.prototype.moveToXValueInternal=function(){var t=this,u=this.waveContainer.getDomainAxis(),f,i;if(u&&(f=this.waveContainer.getXAxisName().indexOf("Time")>-1,i=u.findCursorByGroupId(this.id),i)){var e=i.getXValueWithoutUnits(),o=function(n){n=t.removeUnits(n);var r=new Project.PropertyFormatter,i=r.SIUnitPrefixes2Double(n);isNaN(i)||(t.setXValueForRowCursors(i,!1),t.updateByXValue(!1),t.waveContainer.notifyAboutCursors())},s=-50,c=n.getManager().getDesign(),h=new Project.InputField(c),r=i.getPositionOnScreen();f?h.queryNumber(e,o,r.x,r.y+s,0,this.validator,"time"):h.queryNumber(e,o,r.x,r.y+s,0,this.validator,"real")}},r.prototype.removeUnits=function(t){var i=this.getXUnits(),r;return i&&i!=""&&i!=n.WaveManager.NO_UNITS&&(r=t.lastIndexOf(i),r>-1)?t.substr(0,r):t},r.prototype.setAsBase=function(n,t){n.setGroupAsBase(t,!0)},r.prototype.remove=function(){for(var t,i,n=0;n<this.waveContainer.getRows().length;n++)t=this.waveContainer.getRows()[n],t&&t.removeCursor(this.getId());i=this.waveContainer.getDomainAxis();i&&i.removeCursor(this.getId());this.cursorGroupMenu&&(this.cursorGroupMenu.removeMenu(),this.cursorGroupMenu=null)},r.prototype.isCursorInVisibleRange=function(){var n=this.waveContainer.getRealXVisibleState().range;return!n||n.xmin==null||n.xmax==null?!1:this.xValue<n.xmin||this.xValue>n.xmax?!1:!0},r.prototype.hide=function(){for(var t,i,n=0;n<this.waveContainer.getRows().length;n++)t=this.waveContainer.getRows()[n],t&&t.hideCursor(this.getId());i=this.waveContainer.getDomainAxis();i&&i.hideCursor(this.getId())},r.prototype.show=function(){for(var t,i,n=0;n<this.waveContainer.getRows().length;n++)t=this.waveContainer.getRows()[n],t&&t.showCursor(this.getId());i=this.waveContainer.getDomainAxis();i&&i.showCursor(this.getId())},r.prototype.updateByXValue=function(n){for(var i,r,t=0;t<this.waveContainer.getRows().length;t++)i=this.waveContainer.getRows()[t],i&&i.updateCursorByXValue(this,this.getXValue(),!1,n);r=this.waveContainer.getDomainAxis();r&&r.updateCursorByXValue(this,this.getXValue(),!0,n);this.isCursorInVisibleRange()?this.show():this.hide()},r.prototype.highlightAllCursors=function(n){for(var r,i,t=0;t<this.waveContainer.getRows().length;t++)r=this.waveContainer.getRows()[t],r.highlightCursor(this.getId(),n);i=this.waveContainer.getDomainAxis();i&&i.highlightCursor(this.getId(),n)},r.prototype.onTop=function(){for(var i,t,n=0;n<this.waveContainer.getRows().length;n++)i=this.waveContainer.getRows()[n],i.cursorOnTop(this.getId());t=this.waveContainer.getDomainAxis();t&&t.cursorOnTop(this.getId())},r.prototype.updateAllCursors=function(n){this.updateByXValue(n);this.checkAndUpdateCursorsYValue(!1)},r.prototype.updateCursorsByYValue=function(){for(var t,i,n=0;n<this.waveContainer.getRows().length;n++)t=this.waveContainer.getRows()[n],t&&(i=t.findCursorByGroupId(this.getId()),i&&i.updateState(!1))},r.prototype.checkAndUpdateCursorsYValue=function(t){var r=[],f,u,e,o,c,i,s,l,h;if(t&&(this.waveformMap=[]),f=this.getXValue(),this.isCursorInVisibleRange()){for(u=0;u<this.waveContainer.getRows().length;u++)if(e=this.waveContainer.getRows()[u],e){o=e.getPlottedWaveforms();for(c in o)i=o[c],i.isResolved||i.isResolvedOnRange||(s=i.checkCursorPosition(f),t?s&&r.push(i):(l=this.getYValueForCursorGroup(i),!l&&s&&r.push(i)))}r.length!=0&&(h=this,$.when(n.ViewerRequests.getYValues(f,r)).done(function(n){var t,i;if(n){for(t=0;t<n.length;t++)i=r[t],h.putYValueForCursorGroup(i,n[t]);h.updateCursorsByYValue()}}).fail(function(){}))}},r.prototype.getYValueForCursorGroup=function(n){return this.waveformMap[n.getWaveformHandle()]},r.prototype.putYValueForCursorGroup=function(n,t){n&&(this.waveformMap[n.getWaveformHandle()]=t)},r.prototype.redrawFlags=function(){this.updateByXValue(!1)},r.prototype.getBoundingRect=function(){for(var i,f,n,r,t=null,u=0;u<this.waveContainer.getRows().length;u++)i=this.waveContainer.getRows()[u],i&&(n=i.findCursorByGroupId(this.getId()),n&&(r=n.getBoundingRect(),t=Project.Utility.accumulateBoundingRect(t,r)));return f=this.waveContainer.getDomainAxis(),f&&(n=i.findCursorByGroupId(this.getId()),n&&(r=n.getBoundingRect(),t=Project.Utility.accumulateBoundingRect(t,r))),t},r.prototype.getAllCursorValues=function(){for(var t,i=[],n=0;n<this.waveContainer.getRows().length;n++)t=this.waveContainer.getRows()[n],t&&t.getCursorYValue(this.getId(),i);return i},r.GLOBAL_CURSOR_ID=0,r.CURSOR_GROUP_NAME="C",r.FLAG_ON_RIGHT="On Right",r.FLAG_ON_LEFT="On Left",r}(),t;n.WaveCursorGroup=r;t=function(){function n(){}return n.prototype.compareTo=function(n,t,i){var r=t+PATH_SEPARATOR+"cursor group";return Project.Utility.comparePrimitives(this.xValue,n.xValue,"xValue",t,i)?!0:!1},n.prototype.initByState=function(n){this.xValue=n.xValue},n}();n.WaveCursorGroupState=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(n){this.cursorGroups=[];this.waveContainer=n}return t.prototype.getCursorGroups=function(){return this.cursorGroups},t.prototype.getCursorGroupNumber=function(){return this.cursorGroups?this.cursorGroups.length:0},t.prototype.hideAllCursorGroups=function(t){var i,r;if(t===void 0&&(t=n.RESIZE_MODE.NONE),this.cursorGroups)for(i=0;i<this.cursorGroups.length;i++)r=this.cursorGroups[i],r&&r.remove()},t.prototype.updateAllCursorGroups=function(t){var e,f,r,o,u,i;if(t===void 0&&(t=n.RESIZE_MODE.NONE),this.cursorGroups)if(t==n.RESIZE_MODE.VERTICAL)for(e=this.waveContainer.getState(),f=e.getCursorStates(),this.removeAllCursorGroups(!1),r=0;r<f.length;r++)o=f[r],i=this.addCursorGroup(o);else for(u=0;u<this.cursorGroups.length;u++)i=this.cursorGroups[u],i&&(this.waveContainer.isDecorationShown()?(i.setXUnits(this.waveContainer.getXUnits()),i.updateAllCursors(!1)):i.remove())},t.prototype.getDefaultCursorXValue=function(){var n=this.waveContainer.getXAxisState(),t=n.range.xmin,i=n.range.xmax,r=.01*(i-t),u=this.getCursorGroupNumber();return(t+i)/2+r*u},t.prototype.addCursorGroup=function(t){var u=!1,i=new n.WaveCursorGroupState,r,e,f;return t==null?(r=this.getDefaultCursorXValue(),i.xValue=r):typeof t=="number"?(r=t,i.xValue=r):t instanceof n.WaveCursorGroupState?(i=t,u=!0):(e=t,i.initByState(e),u=!0),f=new n.WaveCursorGroup(this.waveContainer,i),this.cursorGroups.push(f),this.adjustFlagPositions(),u||this.waveContainer.notifyAboutCursors(),f},t.prototype.removeAllCursorGroups=function(n){var t,i;if(this.cursorGroups){for(t in this.cursorGroups)i=this.cursorGroups[t],this.removeCursorGroup(i,!1);this.cursorGroups=[];n&&this.waveContainer.notifyAboutCursors()}},t.prototype.removeCursorGroup=function(n,t){n&&(n.remove(),t&&(this.cursorGroups.splice($.inArray(n,this.cursorGroups),1),this.adjustFlagPositions(),this.waveContainer.notifyAboutCursors()))},t.prototype.updateBaseFlagForAllCursorGroup=function(n,t){var r,i;if(t)for(r in this.cursorGroups)i=this.cursorGroups[r],i&&i.getId()!=n&&i.setGroupAsBase(!1,!1)},t.prototype.getCursorStates=function(){var r=[],t=this.getCursorGroups(),n,i;if(t)for(n=0;n<t.length;n++)i=t[n],i&&r.push(i.getState());return r},t.prototype.adjustFlagPositions=function(){var t=this.cursorGroups,u,n,r,i;if(t&&!(t.length<2)){for(n=0;n<t.length;n++)t[n].isBlocked=!1,u=this.waveContainer.getDomainAxis().findCursorByGroupId(t[n].getId()),t[n].cursorXPosition=u?u.cursorXPosition:0;for(t.sort(this.sortByXPos),n=0;n<t.length-1;n++)if(r=t[n],i=t[n+1],this.areOvelapped(r,i)){if(r.isShownFlagOnLeft()&&i.isShownFlagOnRight())continue;r.isBlocked?this.putFlagsOnRight(i):(this.tryPutOnLeft(t,n),this.areOvelapped(r,i)&&this.putFlagsOnRight(i))}}},t.prototype.putFlagsOnRight=function(n){n.isShownFlagOnLeft()&&(n.setRightFlagPosition(),n.redrawFlags());n.isBlocked=!0},t.prototype.tryPutOnLeft=function(n,t){var i=n[t],r;return(i.setLeftFlagPosition(),i.redrawFlags(),t==0)?!0:(r=n[t-1],this.areOvelapped(r,i))?(i.setRightFlagPosition(),i.redrawFlags(),i.isBlocked=!0,!1):!0},t.prototype.areOvelapped=function(n,t){var i=n.getBoundingRect(),r=t.getBoundingRect();return!(r.x1>i.x2||r.x2<i.x1||r.y1>i.y2||r.y2<i.y1)},t.prototype.sortByXPos=function(n,t){var i=n.cursorXPosition,r=t.cursorXPosition;return i<r?-1:i>r?1:0},t}();n.CursorGroupManager=t}(WaveViewer||(WaveViewer={})),function(n){var i=function(){function t(){}return t.tickGeneratorForYAxis=function(i){var r=new n.AxisUnits(i.min,i.max),f,u;if(i.options.isResize&&(f=getSchematic(),f&&f.wheelZoomNow))return u=[],t.addTempTick(i.min,r,u),t.addTempTick((i.min+i.max)/2,r,u),t.addTempTick(i.max,r,u),u;var e=r.getMajorTickSpacing(),o=n.PlotTicks.generateLinearTicks(i,e,r,!1),s=o.ticks;return s=t.generateNiceLinearTicksForY(i,e,r,o),n.PlotTicks.convertTickForFlot(s)},t.addTempTick=function(t,i,r){var u=t,f=n.PlotTicks.tickFormatterForLinear(i,u),e=[t,f,!0,n.TICK_PLOT.LONG_TICK];r.push(e)},t.tickGeneratorForYAxisDigital=function(){var t=[0,"0",!0,n.TICK_PLOT.LONG_TICK],i=[1,"1",!0,n.TICK_PLOT.LONG_TICK];return[t,i]},t.generateNiceLinearTicksForY=function(i,r,u,f){var o=f.ticks;if(n.PlotTicks.isAxisReady(i)){var s=i.options.font||"flot-tick-label tickLabel",h=f.firstTick?f.firstTick.label:""+i.max,c=n.PlotTicks.calcLabelHeight(h,s),e=i.box;if(!e||e.height<c)return o}return n.PlotTicks.generateNiceLinearTicks(i,u,f,t.testDistanceBetweenTwo,!1)},t.testDistanceBetweenTwo=function(t,i,r){if(!t||!i)return!0;var u=r.options.font||"flot-tick-label tickLabel",f=n.PlotTicks.calcLabelHeight(t.label,u)-6,e=r.p2c(t.v),o=r.p2c(i.v),s=Math.abs(o-e);return n.WaveUtils.greaterOrAlmostEqual(s,f)},t}(),t;n.YAxisTicks=i;t=function(){function t(n){this.plot=n}return t.prototype.drawHorizontalGridLines=function(n,t,i){var f=this.plot,v=f.getOptions(),o=f.getPlotOffset(),y=f.height(),l=f.width(),s,e,r,u,c;if(t.ticks){s=f.getSurface();s.render();n.save();n.translate(o.left,o.top);n.fillStyle="#FFFFFF";var h=t.box,a=Math.round(h.left-o.left+(t.position=="left"?h.width:0)),p=a-7;for(e=0;e<t.ticks.length;e++)r=t.ticks[e],r&&t.min<=r.v&&r.v<=t.max&&r.major&&(u=t.p2c(r.v),u=Math.floor(u)+.5,e==0&&this.shiftFirstTick(r,t,u),n.beginPath(),c=this.getHorizontalLineColor(r,i),n.strokeStyle=c,n.moveTo(0,u),n.lineTo(l,u),n.stroke());n.restore()}},t.prototype.shiftFirstTick=function(t,i,r){var u=!1,f;if(n.WaveUtils.almostEqual(t.v,i.min)?u=!0:(f=Math.abs(i.p2c(i.min)-i.p2c(t.v)),f<=n.PlotTicks.StartTickShift&&(u=!0)),u){var s=this.plot.getSurface(),h=n.PlotTicks.getLayer(i),c=i.options.font||"flot-tick-label tickLabel",e=r-n.PlotTicks.StartTickShift,o=s.getTextInfo(h,t.label,c,null,"100px");o.positions[0].y=e;o.positions[0].element.css({top:Math.round(e)})}},t.prototype.getVerticalLineColor=function(t,i){var u=this.plot,f=u.getOptions(),r=f.grid.markingsColor;return i?(t.major||n.PlotTicks.isTenTick(t)?r=n.WaveManager.AXIS_MAJOR_TICK_LINES_COLOR:n.PlotTicks.isFiveTick(t)&&(r=n.WaveManager.AXIS_MINOR_TICK_LINES_COLOR),r):r},t.prototype.getHorizontalLineColor=function(t,i){var u=this.plot,f=u.getOptions(),r=f.grid.markingsColor;return i&&t.v==0&&(r=n.SVW_Colors.ZERO_LEVEL_COLOR),r},t.prototype.drawVerticalGridLines=function(n){var i=this.plot,t=i.getSurface().context,c=i.getOptions(),s=i.getPlotOffset(),f=i.getAxes().xaxis,l=i.height(),e,u,r,o,h;for(t.save(),t.translate(s.left,s.top),t.lineWidth=1,t.strokeStyle=c.grid.markingsColor,e=i.svw_ticks,u=0;u<e.length;u++)r=e[u],r&&(o=r.v,f.min<o&&o<f.max&&(h=this.getVerticalLineColor(r,n),t.strokeStyle=h,this.plotGridLine(t,f,r.v,l)));t.restore()},t.prototype.plotGridLine=function(n,t,i,r){n.beginPath();var u=t.p2c(i);u=Math.floor(u)+.5;n.moveTo(u,0);n.lineTo(u,r);n.stroke()},t}();n.PlotYTicks=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(){}return t.tickGeneratorForLinearXAxis=function(i){var r;if(i.options.isResize&&(r=getSchematic(),r&&r.wheelZoomNow))return[i.min,(i.min+i.max)/2,i.max];var u=new n.AxisUnits(i.min,i.max),o=u.getMajorTickSpacing(),f=n.PlotTicks.generateLinearTicks(i,o,u,!1),e=f.ticks;return e=n.PlotTicks.generateNiceLinearTicks(i,u,f,t.testDistanceBetweenTwoLinear,!1),n.PlotTicks.convertTickForFlot(e)},t.testDistanceBetweenTwoLinear=function(t,i,r){if(!t||!i)return!0;var e=r.p2c(t.v),o=r.p2c(i.v),u=r.options.font||"flot-tick-label tickLabel",s=n.PlotTicks.calcTextWidth("0",u),f=n.PlotTicks.calcLabelWidth(t,u)+s,h=Math.abs(o-e);return n.WaveUtils.greaterOrAlmostEqual(h,f>80?80:f)},t.testDistanceBetweenTwoLog=function(t,i,r){if(!t||!i)return!0;var f=r.p2c(t.v),e=r.p2c(i.v),o=r.options.font||"flot-tick-label tickLabel",u=n.PlotTicks.calcLabelWidth(i,o),s=Math.abs(e-f);return n.WaveUtils.greaterOrAlmostEqual(s,u>35?35:u)},t.testDistanceBetweenAll=function(n,i){var r,u,f;if(!n)return!0;for(r=0;r<n.ticks.length-1;r++)if(u=n.ticks[r],f=n.ticks[r+1],!t.testDistanceBetweenTwoLog(u,f,i))return!1;return!0},t.tickGeneratorForLogXAxis=function(i){var u=new n.AxisUnits(i.min,i.max),h=u.getMajorTickSpacing(),f=n.PlotTicks.generateLogMajorTicks(i,u,1),r=f.ticks,s=r.length,o,e;return r=n.PlotTicks.generateNiceLogMajorTicks(i,u,f,t.testDistanceBetweenTwoLog),o=r.length>=s,e=r,n.PlotTicks.isAxisReady(i)&&o&&(e=t.addPseudo(r,i,u,f.powerShift)),n.PlotTicks.convertTickForFlot(e)},t.addArray=function(n,t){for(var i=0;i<t.length;i++)n.push(t[i]);return n},t.addPseudo=function(n,i,r,u){return n.length<1?t.logAxisAsLinear(i):n.length==1?t.ticksForTwoTenRanges(n,i,r):t.logAxisAsLog(n,i,r,u)},t.ticksForTwoTenRanges=function(n,i,r){var u=[],f=n[0].v,e=t.logAxisAsLog(n,i,r,1),o=t.logAxisAsLinear(i);return u=t.addSeparatePseudoTicks(f,u,e,o,!0),u.push(n[0]),t.addSeparatePseudoTicks(f,u,e,o,!1)},t.addSeparatePseudoTicks=function(n,t,i,r,u){for(var e,o=[],s=[],f=0;f<i.length;f++)e=u?i[f].v<n:i[f].v>n,e&&o.push(i[f]);for(f=0;f<r.length;f++)e=u?r[f].v<n:r[f].v>n,e&&s.push(r[f]);return s.length>o.length?this.addArray(t,s):this.addArray(t,o),t},t.logAxisAsLinear=function(i){for(var e,h=t.tickFormatterForLog,r=new n.AxisUnits(i.min,i.max),o=r.getMajorTickSpacing(),s=n.PlotTicks.generateLinearTicks(i,o,r,!0),u=n.PlotTicks.generateNiceLinearTicks(i,r,s,t.testDistanceBetweenTwoLinear,!0),f=0;f<u.length;f++)e=u[f],e.power=n.AxisUtils.findPower(e.v);return u},t.logAxisAsLog=function(i,r,u,f){var s=[],c=Math.pow(10,i[0].power),l,h,o,a,e,v,y;if(c>r.min)for(l=Math.pow(10,i[0].power-f),h=2;h<10;h++)o=h*l,n.WaveUtils.greaterOrAlmostEqual(o,r.min)&&o<c&&(a=this.tickFormatterForLog(u,o),s.push(new n.TickInfo(o,a,!1,i[0].power)));for(e=0;e<i.length;e++)v=e==i.length-1?i[e].power+f:i[e+1].power,s.push(i[e]),y=t.pseudoTicksForRange(r,u,i[e].power,v),this.addArray(s,y);return s},t.pseudoTicksForRange=function(i,r,u,f){for(var a,s,h,e,c,l=[],y=f-u,v=t.tickFormatterForLog,p=Math.pow(10,f),o=u;o<f;o++){for(a=Math.pow(10,o),s=Math.pow(10,o+1),h=1;h<10;h++)e=h*a,e>a&&e<s&&n.WaveUtils.inRange(e,i)&&(c=v(r,e),l.push(new n.TickInfo(e,c,!1,o)));y>1&&s<p&&n.WaveUtils.inRange(e,i)&&(c=v(r,s),l.push(new n.TickInfo(s,c,!0,o+1)))}return l},t.tickFormatterForLog=function(t,i){return t.format=n.AxisUnits.AXIS_FORMAT_F,t.formatLogValue(i)},t}();n.XAxisTicks=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(n,i,r){this.rangeSuffix=t.RANGE_SFX_IEEE;r?(this.digitColumns=1,this.decimalColumns=4):this.majorTickSpacing=this.computeMajorTickSpacing(n,i)}return t.prototype.formatCursorValue=function(t,i){return this.formatDataValue(t,!0,n.WaveRowCursor.PRECISION,i)},t.prototype.formatLogValue=function(n){return this.formatDataValue(n,!1,0,!0)},t.prototype.formatLinearValue=function(n){return this.formatDataValue(n,!1,0,!1)},t.prototype.formatDataValue=function(n,i,r,u,f,e){var o,s,h;return u&&(this.logBase=t.LOG_10),f==null&&(f=this.unitScale),e==null&&(e=this.unitSuffix),(u||i)&&(n!=0?(f=this.computeUnitScale(Math.abs(n),!0),e=this.computeUnitNotation(f)):e=""),e||(e=""),f||(f=this.computeUnitScale(Math.abs(n),!0)),n*=f,o=this.decimalColumns,i&&(o=r==0?Math.max(t.NUM_DECIMAL_DIGITS,this.decimalColumns):r),s=0,this.format!=t.AXIS_FORMAT_G&&(s=this.digitColumns+o,s++),h=this.formatDouble(this.format,n,s,o),e!=null?h+e:h},t.log10=function(n){return Math.log(n)/t.LOG_OF_10},t.prototype.computeUnitScale=function(n,i){if(this.rangeSuffix==t.RANGE_SFX_NONE)return 1;var u=Math.abs(n),r=Math.round(Math.floor(t.log10(u+u*.001)));switch(r){case-18:case-17:case-16:if(this.rangeSuffix==t.RANGE_SFX_IEEE)return 1e18;break;case-15:case-14:case-13:return 1e15;case-12:case-11:case-10:return 1e12;case-9:case-8:case-7:return 1e9;case-6:case-5:case-4:return 1e6;case-3:case-2:case-1:return 1e3;case 0:case 1:case 2:return 1;case 3:case 4:case 5:return.001;case 6:case 7:case 8:return 1e-6;case 9:case 10:case 11:return 1e-9;case 12:case 13:case 14:return 1e-12;case 15:case 16:case 17:if(this.rangeSuffix==t.RANGE_SFX_IEEE)return 1e-15;break;case 18:case 19:case 20:if(this.rangeSuffix==t.RANGE_SFX_IEEE)return 1e-18}if(this.rangeSuffix==t.RANGE_SFX_IEEE){if(r<-18)return i?1e18:0;if(r>20)return i?1e-18:0}else{if(r<=-16)return i?1e15:0;if(r>=15)return i?1e-12:0}return 1},t.prototype.formatDouble=function(n,i,r,u){return t.calcValue(i,u,n)},t.prototype.computeUnitNotation=function(n){if(this.rangeSuffix==t.RANGE_SFX_NONE)return null;var r=Math.abs(n),i=Math.round(Math.floor(t.log10(r+r*.001)));switch(i){case-17:case-16:case-15:return t.SUFFIXES[1][this.rangeSuffix];case-14:case-13:case-12:return t.SUFFIXES[2][this.rangeSuffix];case-11:case-10:case-9:return t.SUFFIXES[3][this.rangeSuffix];case-8:case-7:case-6:return t.SUFFIXES[4][this.rangeSuffix];case-5:case-4:case-3:return t.SUFFIXES[5][this.rangeSuffix];case-2:case-1:case 0:return t.SUFFIXES[6][this.rangeSuffix];case 1:case 2:case 3:return t.SUFFIXES[7][this.rangeSuffix];case 4:case 5:case 6:return t.SUFFIXES[8][this.rangeSuffix];case 7:case 8:case 9:return t.SUFFIXES[9][this.rangeSuffix];case 10:case 11:case 12:return t.SUFFIXES[10][this.rangeSuffix];case 13:case 14:case 15:return t.SUFFIXES[11][this.rangeSuffix];default:return i<=-18?t.SUFFIXES[0][this.rangeSuffix]:i>=16?t.SUFFIXES[12][this.rangeSuffix]:null}},t.prototype.getMajorTickSpacing=function(){return this.majorTickSpacing},t.prototype.computeMajorTickSpacing=function(i,r){var f,o,h,s,c;i==r&&(i=i-1,r=r+1);f=n.AxisUtils.getAxisRange(i,r);o=1;f<=0&&(h=i,i=r,r=h,f=-f);for(var u=f*.1,e=0;u<1;)u*=10,e--;while(u>10)u*=.1,e++;return s=t.LOOKUP[Math.round(u)],u=e!=0?s*Math.pow(10,e):s,c=Math.ceil(f/u),this.spacingBase=s,this.spacingPower=e,o=u,this.calcDigits(i,r,o),o},t.prototype.calcDigits=function(n,i,r){var e=Math.abs(i),h=Math.abs(n),o,u,s,f;h>e&&(e=h);o=Math.abs(r);this.unitScale=this.computeUnitScale(e,!0);this.unitScale!=1&&(o*=this.unitScale,e*=this.unitScale);this.unitSuffix=this.computeUnitNotation(this.unitScale);u=t.log10(o);s=!1;u<0?(s=!0,u=-u,f=Math.floor(u),f!=u&&f++,this.decimalColumns=f):this.decimalColumns=1;e>=1?(this.digitColumns=Math.floor(t.log10(e))+1,this.digitColumns>5&&!s?(this.format=t.AXIS_FORMAT_E,this.digitColumns=1,this.unitScale=1,this.unitSuffix=null):this.format=this.digitColumns>0&&this.decimalColumns>0?t.AXIS_FORMAT_F:t.AXIS_FORMAT_G):(this.digitColumns=0,this.decimalColumns>5?(this.unitScale=1,this.unitSuffix=null,this.format=t.AXIS_FORMAT_E,u=-t.log10(e),f=Math.floor(u),f!=u&&f++,this.decimalColumns-=f,this.decimalColumns<=0&&(this.decimalColumns=1)):this.format=t.AXIS_FORMAT_F)},t.calcValue=function(n,i,r){var u,f;return i<0&&(i=6),u=1,n<0&&(n=-n,u=-1),f=t.fixedFormat(n,i,r),u<0?"-"+f:f},t.fixedFormat=function(n,i,r){return r==t.AXIS_FORMAT_E?""+n.toExponential(3):""+t.toFixed(n,i)},t.toFixed=function(n,t){var i=Math.pow(10,t+1),r=Math.floor(n*i),u=Math.round(r/10)*10/i;return n.toFixed(t)},t.exponentFormat=function(n,t){return n.toExponential(t)},t.formatDataValueForCursor=function(n,i){var e,o;if(n==0)return"0.0";var u=new t(null,null,!0),f=u.computeUnitScale(n,!0),r=u.computeUnitNotation(f);return n*=f,e=Math.max(t.NUM_DECIMAL_DIGITS,i),o=t.calcValue(n,e,t.AXIS_FORMAT_F),r||(r=""),o+r},t.formatDataWithPercent=function(n){var i=6,r=6,u,f;return r=n<10?i-2:n<100?i-3:i-4,u=Math.max(t.NUM_DECIMAL_DIGITS,r),f=t.calcValue(n,u,t.AXIS_FORMAT_F),f},t.formatDataValueForMeasurement=function(n,i,r){var s,u;if(n==0)return"0.0 "+(r?r:"");var e=new t(null,null,!0),o=e.computeUnitScale(n,!0),f=e.computeUnitNotation(o);return n*=o,s=Math.max(t.NUM_DECIMAL_DIGITS,i),u=t.calcValue(n,s,t.AXIS_FORMAT_F),f?u+=r&&r!=""?" "+f+r:f:r&&r!=""&&(u+=" "+r),u},t.RANGE_SFX_IEEE=0,t.RANGE_SFX_SPICE=1,t.RANGE_SFX_ENGR=2,t.RANGE_SFX_NONE=3,t.LOG_OF_10=Math.log(10),t.LOG_NONE=0,t.LOG_2=2,t.LOG_10=10,t.AXIS_FORMAT_E=0,t.AXIS_FORMAT_F=1,t.AXIS_FORMAT_G=2,t.NUM_DECIMAL_DIGITS=5,t.SUFFIXES=[["E","T","e+18"],["P","T","e+15"],["T","T","e+12"],["G","G","e+9"],["M","MEG","e+6"],["k","K","e+3"],[null,null,null],["m","M","e-3"],["u","U","e-6"],["n","N","e-9"],["p","P","e-12"],["f","F","e-15"],["a","F","e-18"]],t.LOOKUP=[1,1,2,2,5,5,5,5,10,10,10],t}();n.AxisUnits=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(){}return t.emptyFormatter=function(){return""},t.findPower=function(t){return Math.round(Math.floor(n.AxisUnits.log10(t+t*.001)))},t.getAxisRange=function(t,i){var u=i-t,f=n.WaveUtils.getDigitalDigits(t),e=n.WaveUtils.getDigitalDigits(i),r=Math.max(f,e);return r>21&&(r=21),r>0&&(u=+u.toPrecision(r)),u},t.WAVEBOX_LIMIT=300,t}();n.AxisUtils=t}(WaveViewer||(WaveViewer={})),function(n){var i,t,f,r,e,u;(function(n){n[n.LONG_TICK=0]="LONG_TICK";n[n.SHORT_TICK=1]="SHORT_TICK";n[n.NO_TICK=2]="NO_TICK"})(n.TICK_PLOT||(n.TICK_PLOT={}));i=n.TICK_PLOT;t=function(){function t(){}return t.generateNiceLinearTicks=function(n,i,r,u,f){var e=r.ticks,o;if(t.isAxisReady(n)){for(var h=t.testDistance(r,n,u),s,c=i.spacingBase,l=i.spacingPower,a=e;!h;)o=t.getNextTickSize(c,l),c=o.base,l=o.power,s=o.tickSize,i.calcDigits(n.min,n.max,s),r=t.generateLinearTicks(n,s,i,f),a=e,e=r.ticks,h=t.testDistance(r,n,u);if(e.length<=1)return t.applySpecialRule(a,e,n,u)}return e},t.applySpecialRule=function(n,t,i,r){for(var e=[],f=0,o=n[0],u=1;u<n.length;u++)if(u!=0&&r(o,n[u],i)){f=u;break}if(f==0)return t;for(u=0;u<n.length;u+=f)e.push(n[u]);return e},t.testDistance=function(t,i,r){if(!t)return!0;var u=t.firstTick,f=t.secondTick;return!u||!f?!0:t.isLog?n.XAxisTicks.testDistanceBetweenAll(t,i):r(u,f,i)},t.getNextTickSizeInfo=function(n){n=Math.round(n);switch(n){case 1:return{base:2,power:0};case 2:return{base:5,power:0};case 5:return{base:1,power:1};case 10:return{base:2,power:1};default:return{base:2,power:0}}},t.getNextTickSize=function(n,i){var r=t.getNextTickSizeInfo(n),u=i+r.power,f=""+r.base+"e"+u,e=+f;return{tickSize:e,base:r.base,power:u}},t.isAxisReady=function(n){return n.p2c!=null},t.generateLinearTicks=function(i,f,e,o){var b=o?n.XAxisTicks.tickFormatterForLog:t.tickFormatterForLinear,p,c;i.tickSize=f;for(var l=i.tickSize*Math.floor(i.min/i.tickSize),w=[],h=0,s=l,a,v=null,y=null;s<i.min;)h++,a=s,s=l+h*i.tickSize;while(n.WaveUtils.lessOrAlmostEqual(s,i.max)&&s!=a)p=b(e,s),c=new r(s,p,t.isMajor(p,o),1),w.push(c),v?y||(y=c):v=c,h++,a=s,s=l+h*i.tickSize;return new u(w,v,y,1,!1)},t.isMajor=function(n,i){return i?t.TENS.indexOf(n)>-1:!0},t.getLayer=function(n){var t=n.direction+"Axis "+n.direction+n.n+"Axis";return"flot-"+n.direction+"-axis flot-"+n.direction+n.n+"-axis "+t},t.getFirstTick=function(n){for(var i,t=0;t<n.ticks.length;++t)if(i=n.ticks[t],!i.label||i.v<n.min||i.v>n.max)continue;else return t;return 0},t.getLastTick=function(n){for(var i,t=n.ticks.length-1;t>=0;t--)if(i=n.ticks[t],!i.label||i.v<n.min||i.v>n.max)continue;else return t;return n.ticks.length-1},t.calcLabelWidth=function(n,t){var i=n.label;return this.calcTextWidth(i,t)},t.calcTextWidth=function(n,i){return t.fakeEl||(t.fakeEl=$("<span>").hide().appendTo(document.body)),t.fakeEl.html(n).css("font",i),Math.ceil(t.fakeEl.outerWidth(!1))},t.calcLabelHeight=function(n,i){return t.fakeEl||(t.fakeEl=$("<span>").hide().appendTo(document.body)),t.fakeEl.html(n).css("font",i),t.fakeEl.outerHeight(!1)},t.convertTickForFlot=function(n){var i,t;if(!n||n.length==0)return[];for(i=[],t=0;t<n.length;t++)i.push(n[t].getFlotTick());return i},t.generateLogMajorTicks=function(t,i,f){var p=n.XAxisTicks.tickFormatterForLog,y,s;t.tickSize=Math.pow(10,f);for(var a=n.AxisUtils.findPower(t.min),b=n.AxisUtils.findPower(t.max),v=[],o=a,e=Math.pow(10,a),h,c=null,l=null,w=-1;e<t.min;)o+=f,h=e,e=Math.pow(10,o);while(n.WaveUtils.inRange(e,t)&&e!=h)y=p(i,e),s=new r(e,y,!0,o),v.push(s),c?l||(l=s):(c=s,w=o-f),o+=f,h=e,e=Math.pow(10,o);return new u(v,c,l,f,!0)},t.generateNiceLogMajorTicks=function(n,i,r,u){var f=r,e=f.ticks;if(t.isAxisReady(n)){for(var s=t.testDistance(f,n,u),c=i.spacingBase,l=i.spacingPower,h=e,o=f.powerShift;!s;)o+=1,f=t.generateLogMajorTicks(n,i,o),h=e,e=f.ticks,s=t.testDistance(f,n,u);r.powerShift=o}return e},t.isFiveTick=function(n){return t.FIVES.indexOf(n.label)>-1},t.isTenTick=function(n){return t.TENS.indexOf(n.label)>-1},t.difTick=2,t.StartTickShift=3,t.PSEUDO_FONT={size:8,lineHeight:12,style:"normal",weight:"normal",family:"sans-serif",variant:"normal",color:n.WaveManager.TICK_LABEL_COLOR},t.PSEUDO_FONT_SIZE=8,t.BASE_FONT_SIZE=10,t.NO_TICK_COLOR="#c1c4c7",t.TENS=["1.0E","10.0E","100.0E","1.0P","10.0P","100.0P","1.0T","10.0T","100.0T","1.0G","10.0G","100.0G","1.0M","10.0M","100.0M","1.0k","10.0k","100.0k","1.0","10.0","100.0","1.0m","10.0m","100.0m","1.0u","10.0u","100.0u","1.0n","10.0n","100.0n","1.0p","10.0p","100.0p","1.0f","10.0f","100.0f","1.0a","10.0a","100.0a"],t.FIVES=["5.0E","50.0E","500.0E","5.0P","50.0P","500.0P","5.0T","50.0T","500.0T","5.0G","50.0G","500.0G","5.0M","50.0M","500.0M","5.0k","50.0k","500.0k","5.0","50.0","500.0","5.0m","50.0m","500.0m","5.0u","50.0u","500.0u","5.0n","50.0n","500.0n","5.0p","50.0p","500.0p","5.0f","50.0f","500.0f","5.0a","50.0a","500.0a"],t.tickFormatterForLinear=function(n,t){return n.formatLinearValue(t)},t}();n.PlotTicks=t;f=function(){function r(n){this.logMajors=[];this.logTens=[];this.logFives=[];this.pseudoSeriesMap=[];this.plot=n;this.axis=n.getAxes().xaxis}return r.prototype.plotXLogAxisTicks=function(n,r){var a=this.plot,e=this.axis,v=this.plot.getPlotOffset(),h=a.svw_ticks,p=t.getLayer(e),y=this.plot.getSurface(),c,l,f,u,s,o;if(y.removeText(p),h){for(this.logMajors=[],this.logTens=[],this.logFives=[],this.pseudoSeriesMap=[],f=0;f<h.length;f++)u=h[f],u&&this.putToSeries(u);for(this.prepareMajorTicks(),this.prepareTicksByPriority(),y.render(),c=e.options.color,o=e.options.tickLength,n.save(),n.strokeStyle=c,n.translate(v.left,v.top),n.fillStyle="#FFFFFF",l=12,n.fillRect(0,-l+3.5,a.width()+5,o-2),r&&(n.beginPath(),n.moveTo(0,-l+3.5),n.lineTo(a.width(),-l+3.5),n.stroke(),n.strokeStyle=c),f=0;f<h.length;f++)u=h[f],u&&e.min<=u.v&&u.v<=e.max&&(s=e.p2c(u.v),s=Math.floor(s)+.5,n.beginPath(),o=o!=5?1:-1,n.moveTo(s,-l),n.strokeStyle=c,u.show==i.LONG_TICK?n.lineTo(s,o):u.show==i.SHORT_TICK&&n.lineTo(s,o-t.difTick),n.stroke(),n.strokeStyle=c);n.restore()}},r.prototype.putToSeries=function(n){n.major?this.logMajors.push(n):t.isTenTick(n)?this.logTens.push(n):t.isFiveTick(n)?this.logFives.push(n):this.putToPseudoMap(n)},r.prototype.prepareTicksByPriority=function(){var r=this.logTens.length>0,i=this.logFives.length>0,t,n;r?(t=this.canShowTens(),t&&(this.setVisibilityForTens(t),i?(n=this.canShowFives(),n&&(this.setVisibilityForFives(n),this.setVisibilityForOthers())):this.setVisibilityForOthers())):i?(n=this.canShowFives(),n?(this.setVisibilityForFives(n),this.setVisibilityForOthers()):this.setVisibilityForOthers()):this.setVisibilityForOthers();this.plotFirstAndLastTicks()},r.prototype.plotFirstAndLastTicks=function(){var t=this.plot.getAxes().xaxis,n=t.ticks;n&&n.length>0&&(this.plotEdge(n[0],this.getFirstVisibleTick()),this.plotEdge(n[n.length-1],this.getLastVisibleTick()))},r.prototype.getLastVisibleTick=function(){var i=this.plot.getAxes().xaxis,n=i.ticks,t;if(n&&n.length>0)for(t=n.length-1;t>=0;t--)if(this.isTickVisible(n[t]))return n[t];return null},r.prototype.getFirstVisibleTick=function(){var i=this.plot.getAxes().xaxis,n=i.ticks,t;if(n&&n.length>0)for(t=0;t<n.length-1;t++)if(this.isTickVisible(n[t]))return n[t];return null},r.prototype.isTickVisible=function(n){return n.show!=i.NO_TICK},r.prototype.plotEdge=function(n,t){var u,f,e,r;n.show==i.NO_TICK&&(u=this.checkWithMajor(n),u&&(this.setVisibilityForPseudoTick(!0,n),t&&(f=this.testDistanceBetweenLogTicks(n,t),f||(e=this.getTickInfo(t,!1),r=e.positions,r&&r[0]&&(r[0].active=!1)))))},r.prototype.testDistanceBetweenLogTicks=function(t,i){if(!t||!i||t.label==i.label)return!0;var f=t.major,e=i.major,r=f?this.getBaseWidth(t):this.getPseudoWidth(t),u=e?this.getBaseWidth(i):this.getPseudoWidth(i),o=this.getLeftTickPosition(t)+r/2,s=this.getLeftTickPosition(i)+u/2,h=Math.abs(s-o),c=Math.round((r+u)/2)+4;return n.WaveUtils.greaterOrAlmostEqual(h,c)},r.prototype.getLeftTickPosition=function(n){var r=n.label,i=0,t=this.plot.getPlaceholder().find(".flot-tick-label:contains("+r+")");return t&&t.position()&&(i=t.position().left),i},r.prototype.checkWithMajor=function(n){return this.checkWithArray(n,this.logMajors)},r.prototype.checkWithTens=function(n){return!this.logTens||this.logTens.length==0?!0:this.checkWithArray(n,this.logTens)},r.prototype.checkWithFives=function(n){return!this.logFives||this.logFives.length==0?!0:this.checkWithArray(n,this.logFives)},r.prototype.checkWithArray=function(n,t){var r,f,i,o,s;if(!t||t.length==0)return!0;if(n.v<t[0].v&&(r=this.testDistanceBetweenLogTicks(t[0],n),!r)||n.v>t[t.length-1].v&&(f=this.testDistanceBetweenLogTicks(t[t.length-1],n),!f))return!1;for(i=0;i<t.length;i++){var e=t[i],u=i!=t.length-1?t[i+1]:null,r=e.v<n.v,h=u?u.v>n.v:!0;if(r&&h&&((o=this.testDistanceBetweenLogTicks(e,n),!o)||(s=this.testDistanceBetweenLogTicks(u,n),!s)))return!1}return!0},r.prototype.prepareMajorTicks=function(){for(var u,o,s,f,h,n=this.plot,v=n.getPlotOffset(),e=n.getAxes().xaxis,c=t.getLayer(e),l=n.getSurface(),a=e.options.font||"flot-tick-label tickLabel",r=0;r<this.logMajors.length;r++)for(u=this.logMajors[r],u.show=i.LONG_TICK,o=l.getTextInfo(c,u.label,a,null,null),s=o.positions,f=0;h=s[f];f++)h.active=!0},r.prototype.canShowTens=function(){var n,t;if(!this.logTens||this.logTens.length==0)return!0;for(n=0;n<this.logTens.length;n++)if(t=this.logTens[n],!this.checkWithMajor(t))return!1;return!0},r.prototype.canShowFives=function(){for(var t,n=0;n<this.logFives.length;n++)if((t=this.logFives[n],!this.checkWithMajor(t))||!this.checkWithTens(t)||n!=0&&!this.testDistanceBetweenLogTicks(this.logFives[n-1],t))return!1;return!0},r.prototype.canShowPseudoSeries=function(n,t){for(var r,i=0;i<n.length;i++)if((r=n[i],!this.canShowPseudoTick(r,t))||i!=0&&!this.testDistanceBetweenLogTicks(n[i-1],r))return!1;return!0},r.prototype.canShowPseudoTick=function(n,t){return this.checkWithMajor(n)?this.checkWithTens(n)?this.checkWithFives(n)?this.checkWithArray(n,t)?!0:!1:!1:!1:!1},r.prototype.setVisibilityForSeries=function(n,t){for(var r,i=0;i<t.length;i++)r=t[i],this.setVisibilityForPseudoTick(n,r)},r.prototype.setVisibilityForTens=function(n){this.setVisibilityForSeries(n,this.logTens)},r.prototype.setVisibilityForFives=function(n){this.setVisibilityForSeries(n,this.logFives)},r.prototype.setVisibilityForOthers=function(){var i=[],r=this.logMajors.length<=1,n,t;if(r)this.handleAsSeparateTicks();else for(n=1;n<10;n++)t=this.pseudoSeriesMap[""+n],t&&(i=this.handleAsSeries(t,i))},r.prototype.handleAsSeries=function(n,t){var r=this.canShowPseudoSeries(n,t),i;if(this.setVisibilityForSeries(r,n),r)for(i=0;i<n.length;i++)t.push(n[i]);return t},r.prototype.handleAsSeparateTicks=function(){for(var n,i,f=this.plot,e=f.getAxes().xaxis,r=e.ticks,u=[],t=0;t<r.length;t++)n=r[t],n.major||(i=this.canShowPseudoTick(n,u),this.setVisibilityForPseudoTick(i,n),i&&u.push(n))},r.prototype.setVisibilityForPseudoTick=function(n,t){for(var o=this.getTickInfo(t,!0),s=o.positions,u=0,f=0,e=0,r;r=s[e];e++)r.active=!1,u=r.x,f=r.y;n?this.positionPseudoTick(t,u,f):t.show=i.NO_TICK},r.prototype.positionPseudoTick=function(n,r,u){var s;n.show=i.SHORT_TICK;var f=this.getTickInfo(n,!1),e=f.positions,o={active:!0,rendered:!1,element:e.length?f.element.clone():f.element,x:r,y:u};e.push(o);s=t.calcLabelWidth(n,t.PSEUDO_FONT);o.element.css({top:Math.round(u),left:Math.round(r+3),"text-align":"center","max-width":s})},r.prototype.getTickInfo=function(n,i){var r=this.plot,e=r.getSurface(),u=r.getAxes().xaxis,o=t.getLayer(u),f=t.PSEUDO_FONT;return i&&(f=u.options.font||"flot-tick-label tickLabel"),e.getTextInfo(o,n.label,f,null,null)},r.prototype.getFirstDigit=function(n){var i=0,t=n.label;return t?(t.charAt(0)=="-"&&(i=1),t.charAt(i)):null},r.prototype.putToPseudoMap=function(n){var i=this.getFirstDigit(n);!i||t.isTenTick(n)||t.isFiveTick(n)||(this.pseudoSeriesMap[i]||(this.pseudoSeriesMap[i]=[]),this.pseudoSeriesMap[i].push(n))},r.prototype.getBaseWidth=function(i){var r=i.label,u=n.WaveUtils.getTextParameters(r,this.plot.getPaper(),t.BASE_FONT_SIZE);return u.width},r.prototype.getPseudoWidth=function(i){var r=i.label,u=n.WaveUtils.getTextParameters(r,this.plot.getPaper(),t.PSEUDO_FONT_SIZE);return u.width},r}();n.PlotTicksLog=f;r=function(){function n(n,t,r,u){this.show=i.NO_TICK;this.power=1;this.v=n;this.label=t;this.major=r;this.power=u}return n.prototype.getFlotTick=function(){return[this.v,this.label,this.major,this.show]},n}();n.TickInfo=r;e=function(){function n(n,t,r,u){this.show=i.NO_TICK;this.power=1;this.v=n;this.label=t;this.major=r;this.power=u}return n}();n.TickFlot=e;u=function(){function n(n,t,i,r,u){this.powerShift=1;this.isLog=!1;this.ticks=n;this.firstTick=t;this.secondTick=i;this.powerShift=r;this.isLog=u}return n}();n.TicksData=u}(WaveViewer||(WaveViewer={})),function(n){var i=function(){function i(t,r,u,f){f===void 0&&(f=null);this.resetMode=!1;this.uniqName=null;this.withoutDecor=!1;this.decorOptions=null;this.isResizing=!1;this.probes=[];this.pinned=!0;this.probeVisArray=[];this.waveboxVis=n.VisibilityState.WAVEBOX;this.design=t;this.surface=t.getSurface();this.waveboxPlotState=new n.WaveBoxPlotState(t,this);this.decorOptions=f?f:new WaveViewer.WaveboxDecorationOptions;var e=n.getWaveBoxManager().getNextWaveboxIndex();this.probeButtonId=i.PROBE_BUTTON_ID+e;this.plotContainerId=i.PLOT_CONTAINER_ID+e;this.createWindow();this.uniqName=u?u:this.design.createUniqName("_wavebox_");n.getWaveBoxManager().addWaveboxToList(this);this.initProbes();this.initSimulationDescription();this.addToDesign();this.addProbeButton();this.resetWavebox()}return i.prototype.initProbes=function(){var t,r;for(this.probes=[],t=0;t<i.MAX_NUM_PROBES;t++)r=new n.Probe(this.design,t,this,null,!1),this.probes.push(r)},i.prototype.detachProbe=function(t,i){t.detach();this.hasAttachedProbe()?n.getWaveBoxManager().updateSingleWavebox(this):this.plotAsEmpty();this.updateTitle(!0);i&&this.design.getUndoManager().finishUndoableCommand(this,"MoveProbeCommand")},i.prototype.getProbeIndexForDetached=function(){for(var n=0;n<this.probes.length;n++)if(!this.probes[n].isAttached())return n;return-1},i.prototype.isSingleMode=function(){return this.waveboxPlotState.getPlotMode()==n.PlotMode.SINGLE_ROW},i.prototype.initSimulationDescription=function(){var n=this.design.getLatestSimulation();this.setSimulationDescription(n,!0)},i.prototype.addToDesign=function(){this.design.addWaveBox(this)},i.prototype.removeFromDesign=function(){this.design.removeWaveBox(this);this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},i.prototype.renameInDesign=function(){},i.prototype.existsInDesign=function(){return!0},i.prototype.highlight=function(){},i.prototype.unhighlight=function(){},i.prototype.hasDetachedProbes=function(){for(var n=0;n<i.MAX_NUM_PROBES;n++)if(!this.probes[n].isAttached())return!0;return!1},i.prototype.initProbeByState=function(t,i,r){var u=this.probes[r],f,e;u||(u=new n.Probe(this.design,r,this,null,!1),this.probes[r]=u);f=t.probeStates[r];e=ServerStructures.WaveBoxMigration.getProbeColor(r,t);f&&u.initByState(f,i,e)},i.prototype.initProbeByObjectOrLocation=function(n,t,i,r){var u=this.probes[r];return u&&(u.isAttached()||u.removeGraphic(),n?u.initByProbeObject(n,t,i):u.initByLocation(t,i)),this.updateProbeButton(),u},i.prototype.updateProbeButton=function(){if(this.hasDetachedProbe()){var n=this.getProbeIndexForDetached();this.showProbeButton(n)}else this.hideProbeButton(-1);setBodyCursor("auto")},i.prototype.getInitialPosition=function(){var u=$(window).width()-sidebar_manager.getVisibleWidth(Sidebar.Orientation.RIGHT)-i.WAVEBOX_WIDTH,t=n.getWaveBoxManager().getPlottedWaveboxAmount(),r=Math.floor(t/i.VERTICALLY_SHOWN_WAVEBOXES),f=t%i.VERTICALLY_SHOWN_WAVEBOXES*(i.WAVEBOX_HEIGHT+i.WAVEBOX_TITLE_HEIGHT)+r*i.WAVEBOX_TITLE_HEIGHT;return new BaseWire.Point(u-(r+1)*i.WAVEBOX_X_SHIFT,f+i.WAVEBOX_Y_SHIFT)},i.prototype.getTitleAsString=function(){return this.title?this.title.getTitleAsString():i.NO_DATA_FOR_0},i.prototype.setTitleEventHandlers=function(){if(this.title)return this.title.setEventHandlers()},i.prototype.setEmptyTitle=function(){if(this.title)return this.title.setEmptyTitle()},i.prototype.adjustTitle=function(){this.title&&this.title.adjustTitle()},i.prototype.createWindow=function(){function p(){e||(t.updateProbeEndPosition(),e=!0,t.getUndoManager().startUndoableCommand(Project.MoveWaveboxCommand,t.design,t))}function w(){e=!1;t.getUndoManager().finishUndoableCommand(t,"MoveWaveboxCommand");t.markAsDirty()}var a=this,t=this,f,o,h,e,c,l,u;this.title=new r(this);this.visible=!0;this.pinned=!0;var v=this.pinned?"Pinned":"Unpinned",s=t.getInitialPosition(),y={visible:!0,title:t.getTitleAsString(),modal:!1,resizable:!0,width:i.WAVEBOX_WIDTH,height:i.WAVEBOX_HEIGHT,position:{top:s.y,left:s.x},actions:[v,"Close"],resize:$.proxy(function(){a.onResize()},this),dragstart:p,dragend:w};this.waveboxWindow=$("<div><\/div>").appendTo(document.body).kendoWindow(y).data("kendoWindow");this.waveboxWindow.content('<div id="'+this.plotContainerId+'"><\/div>');this.waveboxWrapper=this.waveboxWindow.wrapper;f=$("#"+this.plotContainerId);f.css("overflow","hidden");this.setTitleEventHandlers();this.waveContainer=new WaveViewer.WaveContainer(f,this.decorOptions,this);o=this.waveboxWindow.wrapper.closest("div.k-window");Project.Utility.fixViewerAndSidebarZIndex();h=o.find("div.k-window-content");h.css("overflow","hidden");o.on("mouseup",function(){if(t.isResizing){t.isResizing=!1;n.getWaveBoxManager().disableResizingMode();var i=t.needToHideDecoration();t.getWaveContainer().stopResize(i);t.getUndoManager().finishUndoableCommand(t,"MoveWaveboxCommand")}t.probesToFront()});Project.KendoHelper.maximizeKendoWindowSpace(f.parent().parent());t=this;e=!1;c=this.waveboxWindow;c.dragging._draggable.bind("drag",function(){t.updateProbeEndPosition()});this.waveboxWindow.bind("close",function(n){n.preventDefault()});l=this.waveboxWindow.wrapper.find(".k-i-close");l.click(function(){t.onClose()});this.waveboxWindow.wrapper.find(".k-window-actions").css({right:0});u=null;this.pinned?(u=this.waveboxWindow.wrapper.find(".k-i-pinned"),u.click(function(){t.unpinFromSchematic()})):(u=this.waveboxWindow.wrapper.find(".k-i-unpinned"),u.click(function(){t.pinToSchematic()}));this.addPinButtonTooltip(u)},i.prototype.getWaveBoxWindow=function(){return this.waveboxWindow},i.prototype.isPinnedToSchematic=function(){return this.pinned},i.prototype.addPinButtonTooltip=function(n){var t=this.pinned?"Press to keep wavebox size and position fixed":"Press to allow wavebox size and position to change with the schematic";n.qtip({content:t,style:{classes:"svw-tooltip"}})},i.prototype.pinToSchematic=function(){var t=this,n=this.waveboxWindow.wrapper.find(".k-i-unpinned");n.length>0&&(this.pinned=!0,n.unbind("click"),n.removeClass("k-i-unpinned"),n.addClass("k-i-pinned"),this.addPinButtonTooltip(n),n.click(function(){t.unpinFromSchematic()}))},i.prototype.unpinFromSchematic=function(){var t=this,n=this.waveboxWindow.wrapper.find(".k-i-pinned");n.length>0&&(this.pinned=!1,n.unbind("click"),n.removeClass("k-i-pinned"),n.addClass("k-i-unpinned"),this.addPinButtonTooltip(n),n.click(function(){t.pinToSchematic()}))},i.prototype.onClose=function(){this.getUndoManager().startUndoableCommand(Project.RemoveWaveboxCommand,this.design,this);this.remove(!0);this.getUndoManager().finishUndoableCommand(null,"RemoveWaveboxCommand")},i.prototype.getSurface=function(){return this.surface},i.prototype.getUndoManager=function(){return this.design.getUndoManager()},i.prototype.getWaveboxWindowJQ=function(){return this.waveboxWrapper},i.prototype.getWaveContainer=function(){return this.waveContainer},i.prototype.getWaveContainerState=function(){return this.getWaveContainer().getState()},i.prototype.getFirstRow=function(){return this.getWaveContainer().getFirstRow()},i.prototype.canSwitchSimulationType=function(){return this.design.canSwitchSimulationType()},i.prototype.getSaveData=function(n){var t=new ServerStructures.WaveboxState,i,r,f,o,u,e,s;for(t.isVisible=this.isVisible(),this.isVisible()||this.show(),i=this.getPlotState(),t.uniqName=this.uniqName,r=this.getWaveboxPosition(),f=r.getCenterInSchematicCoor(this.design),t.xCenter=Math.round(f.x),t.yCenter=Math.round(f.y),t.width=Math.round(r.width*this.design.getSurface().getScale()),t.height=Math.round(r.height*this.design.getSurface().getScale()),t.isPinned=this.isPinnedToSchematic(),t.simulationType=i.getSimulationType(!0),t.cursorStates=i.getCursorStates(),this.resetMode?t.xAxis=ServerStructures.XAxisState.createXAxisState(null,!0,!0):(o=i.getVisibleXRange(),t.xAxis=ServerStructures.XAxisState.createXAxisState(o,i.getViewAllForX(),!0)),this.isVisible()||this.hide(),t.rowStates=i.getServerRows(!n),t.probeStates=[],u=0;u<this.getProbes().length;u++)e=this.getProbe(u),e&&(s=e.getProbeState(),t.probeStates.push(s));return t},i.prototype.setInitialPositionAndSize=function(n,t){var r=n.getCenterInSchematicCoor(this.design),i;this.setProbeEndPositions(r);this.waveboxWindow.wrapper.width(n.width);this.waveboxWindow.wrapper.height(n.height);i=n.getCenterInScreenCoor(this.design);this.moveCenterToAbsolutePosition(i,t);this.waveContainer.restoreContainerDimensions()},i.prototype.applyVisibility=function(){this.isVisible()||this.hide()},i.prototype.hide=function(){this.waveboxWindow.wrapper.closest("div.k-window").hide();this.hideProbes();this.visible=!1},i.prototype.show=function(){this.waveboxWindow.wrapper.closest("div.k-window").show();this.waveContainer.redraw();this.showProbes();this.visible=!0},i.prototype.getVisibility=function(){return this.visible?n.VisibilityState.WAVEBOX:n.VisibilityState.HIDDEN},i.prototype.setVisibility=function(t){t==n.VisibilityState.WAVEBOX?this.show():this.hide()},i.prototype.showOnTop=function(){this.waveboxWindow.toFront()},i.prototype.isVisible=function(){return this.visible},i.prototype.plotAsEmpty=function(){this.clear(!0)},i.prototype.prepareToUpdate=function(){this.showSpinner();this.clear(!1)},i.prototype.clear=function(n){this.getWaveContainer().clear();this.updateTitle(n)},i.prototype.resetWavebox=function(){this.getWaveContainer().clear();this.setEmptyTitle()},i.prototype.shadeWaveformsForProbe=function(n){for(var i,r=this.getPlottedWaveformsForProbe(n),t=0;t<r.length;t++)i=r[t],i&&i.shade();this.updateTitle(!1,n)},i.prototype.getPlottedWaveformsForProbe=function(n){for(var t,r=[],u=this.waveContainer.getPlottedWaveforms(),i=0;i<u.length;i++)t=u[i],t&&!t.isEmptyWaveform()&&t.isBasedOnProbe(n)&&r.push(t);return r},i.prototype.getCalculatorWaveformForProbe=function(n){return this.waveContainer.getCalculatorWaveformForProbe(n)},i.prototype.moveCenterToAbsolutePosition=function(n,t){var i=this.waveboxWindow.wrapper.width(),r=this.waveboxWindow.wrapper.height();this.waveboxWindow.wrapper.css({left:n.x-i/2,top:n.y-r/2});t||this.updateProbeEndPosition()},i.prototype.updateWaveboxeByPan=function(n,t){if(this.isPinnedToSchematic()&&(n!=0||t!=0)){var i=this.waveboxWindow.wrapper.position(),r=i.left+n,u=i.top+t;this.waveboxWindow.wrapper.css({left:r,top:u})}this.updateProbeEndPosition()},i.prototype.repaintAfterZoom=function(){var n=this,t;this.waveContainer.stopResizingMode();t=this.needToHideDecoration();t?this.waveContainer.hideDecoration():this.waveContainer.restoreDefaultDecoration();$.when(this.waveContainer.plotRows(WaveViewer.RESIZE_MODE.BOTH)).done(function(){n.waveContainer.updateMenu();n.hideSpinner()})},i.prototype.updateWaveboxByZoom=function(n,t){var i,r;if(this.isPinnedToSchematic()){var u=this.waveboxWindow.wrapper.width(),f=this.waveboxWindow.wrapper.height(),e=u*n/t,o=f*n/t;this.waveboxWindow.wrapper.width(e);this.waveboxWindow.wrapper.height(o);i=this.getWaveboxCenterByProbe();r=this.surface.schToScreen(i.x,i.y);this.moveCenterToAbsolutePosition(r,!1);this.getWaveContainer().resize(!1,!0);this.adjustTitle()}else this.updateProbeEndPosition()},i.prototype.remove=function(t){n.getWaveBoxManager().removeWaveboxFromList(this);this.design.removeWaveBox(this);this.getWaveContainer().destroy();this.waveboxWindow.destroy();t&&this.removeProbes()},i.prototype.onResize=function(){this.isResizing||this.getUndoManager().startUndoableCommand(Project.ResizeWaveboxCommand,this.design,this);n.getWaveBoxManager().enableResizingMode();this.isResizing=!0;this.getWaveContainer().resize(!1,!0);this.adjustTitle();this.updateProbeEndPosition();this.markAsDirty()},i.prototype.needToHideDecoration=function(){var n=this.getWaveboxWindowJQ(),t=n.width(),r=n.height(),u=i.WAVEBOX_HIDE_HEIGHT*(this.waveContainer.getRows().length+1);return this.withoutDecor=t<i.WAVEBOX_HIDE_WIDTH||r<u?!0:!1,this.withoutDecor},i.prototype.isDecorationHidden=function(){return this.withoutDecor},i.prototype.cleanByError=function(){this.clear(!0);this.hideSpinner();this.applyVisibility()},i.prototype.restoreCursors=function(n){var t,i;if(n){for(t=0;t<n.length;t++)i=n[t],this.getWaveContainer().addCursorGroup(i);this.waveContainer.isDecorationShown()||this.waveContainer.hideAllCursorGroups()}},i.prototype.prepareToNewSimulation=function(t){this.notify(n.ChangeEvents.BEFORE_NEW_SIMULATION,WaveViewer.SourceInfo.WAVEBOX_INDEX,t)},i.prototype.resetWaveboxState=function(){this.getPlotState().resetState();this.markAsDirty()},i.prototype.updatePlotState=function(){for(var t=0;t<this.probes.length;t++)this.notify(n.ChangeEvents.WAVEBOX_STATE,t)},i.prototype.setSimulationTypeFromMenu=function(t){this.notify(n.ChangeEvents.SIMULATION_TYPE,WaveViewer.SourceInfo.WAVEBOX_INDEX,t);n.getWaveBoxManager().updateSingleWavebox(this);this.markAsDirty()},i.prototype.showSpinner=function(){this.waveContainer.showSpinner()},i.prototype.hideSpinner=function(){this.waveContainer.hideSpinner()},i.prototype.updateColors=function(t,i){if(t.forProbe){var r=this.getProbe(t.objectIndex);r&&r.updateColors(i)}else this.notify(n.ChangeEvents.COLOR,t.objectIndex,i);this.updateTitle(!0)},i.prototype.updateTitle=function(n,t){t===void 0&&(t=-1);this.title&&this.title.update(n,t)},i.prototype.setTransformedWaveform=function(t,i){this.notify(n.ChangeEvents.TRANSFORMATION,i,t)&&n.getWaveBoxManager().updateSingleWavebox(this)},i.prototype.getProbe=function(n){return!this.probes||this.probes.length<=n?null:this.probes[n]},i.prototype.getProbes=function(){return this.probes},i.prototype.getBoundingRect=function(){var i,r;if(!this.isVisible())return null;var u=null,t=this.getWaveboxWindowJQ(),n=t.position();return n&&(i=this.surface.screenToSch(n.left,n.top),r=this.surface.screenToSch(n.left+t.width(),n.top+t.height()),u=new Project.BoundingRect(i.x,i.y,r.x,r.y)),u},i.prototype.markAsDirty=function(){this.design.setDirty(Project.DIRTY_FLAG.DIRTY_WAVEBOX)},i.prototype.getWaveboxCenterOnSchematic=function(){var n=this.getWaveboxWindowJQ(),t=n.position(),r=n.width(),u=n.height(),f=t.left+r/2,e=t.top+u/2,i=surface.screenToSch(f,e);return new BaseWire.Point(i.x,i.y)},i.prototype.getWaveboxCenterByProbe=function(){return this.probes[0].getProbeEndPosition()},i.prototype.probesToFront=function(){for(var n=0;n<this.probes.length;n++)this.probes[n].toFront()},i.prototype.removeProbes=function(){for(var n=0;n<this.probes.length;n++)this.probes[n].remove(!1)},i.prototype.hideProbes=function(){for(var n=0;n<this.probes.length;n++)this.probes[n].hideGraphics()},i.prototype.showProbes=function(){for(var n=0;n<this.probes.length;n++)this.probes[n].showGraphics()},i.prototype.updateProbeEndPosition=function(){for(var n=0;n<this.probes.length;n++)this.probes[n].updateProbeEndPosition()},i.prototype.setProbeEndPositions=function(n){for(var t=0;t<this.probes.length;t++)this.probes[t].setProbeEndPositions(n)},i.prototype.getSimulationType=function(n){return this.waveboxPlotState.getSimulationType(n)},i.prototype.getFunction=function(){return this.waveboxPlotState.getFunction()},i.prototype.setFunction=function(t){this.notify(n.ChangeEvents.CALCULATOR,WaveViewer.SourceInfo.WAVEBOX_INDEX,t);n.getWaveBoxManager().updateSingleWavebox(this);this.markAsDirty()},i.prototype.setSimulationDescription=function(t,i){return this.notify(n.ChangeEvents.SIMULATION_DESCRIPTION,WaveViewer.SourceInfo.WAVEBOX_INDEX,t,i)},i.prototype.notify=function(n,t,i,r){return this.waveboxPlotState.notify(n,t,i,r)},i.prototype.setWaveboxState=function(n){var i=new t(n.xCenter,n.yCenter,!1);i.height=n.height/this.design.getSurface().getScale();i.width=n.width/this.design.getSurface().getScale();this.setInitialPositionAndSize(i,!0);n.simulationType=n.simulationType?n.simulationType:Project.SIMULATION_TYPE.NONE;this.waveboxPlotState.setState(n)},i.prototype.getComponentWaveformName=function(n){return this.waveboxPlotState.getCompWfName(n)},i.prototype.getProbePlotState=function(n){return this.waveboxPlotState.getProbePlotState(n)},i.prototype.getPlotState=function(){return this.waveboxPlotState},i.prototype.getUniqName=function(){return this.uniqName},i.prototype.getWaveboxPosition=function(){var n=this.getWaveboxWindowJQ(),r=n.position(),u=n.width(),f=n.height(),e=r.left+u/2,o=r.top+f/2,i=new t(e,o,!0);return i.width=u,i.height=f,i},i.prototype.setSeparateRowMode=function(){this.notify(n.ChangeEvents.PLOT_MODE,WaveViewer.SourceInfo.WAVEBOX_INDEX,n.PlotMode.SEPARATE_ROWS);n.getWaveBoxManager().updateSingleWavebox(this);this.markAsDirty()},i.prototype.setSingleRowMode=function(){this.notify(n.ChangeEvents.PLOT_MODE,WaveViewer.SourceInfo.WAVEBOX_INDEX,n.PlotMode.SINGLE_ROW);n.getWaveBoxManager().updateSingleWavebox(this);this.markAsDirty()},i.prototype.hasDetachedProbe=function(){for(var t,n=0;n<this.probes.length;n++)if(t=this.probes[n],!t.isAttached())return!0;return!1},i.prototype.hasAttachedProbe=function(){for(var t,n=0;n<this.probes.length;n++)if(t=this.probes[n],t.isAttached())return!0;return!1},i.prototype.getNumberOfAttachedProbes=function(){for(var i,t=0,n=0;n<this.probes.length;n++)i=this.probes[n],i.isAttached()&&t++;return t},i.prototype.hideProbeButton=function(n){this.probeButton.currentProbeIndex=n;var t=this.getProbeButtonJQ();t.hide()},i.prototype.showProbeButton=function(n){this.probeButton.currentProbeIndex=n;var i=this.probes[n].getColor(),t=this.getProbeButtonJQ();t.children("span").css("color",i);t.css({position:"absolute",left:0,bottom:"5px",width:"14px",height:"14px",top:""});t.show()},i.prototype.getProbeButtonJQ=function(){return $("#"+this.probeButtonId)},i.prototype.addProbeButton=function(){var r=this.waveContainer.getWaveContainerWrapper(),u=WaveViewer.WaveManager.AXIS_LABEL_COLOR,f='<span class="glyphicon glyphicon-pencil"  aria-label="true" style="color:'+u+'"> <\/span>',t=$("<div type=button id="+this.probeButtonId+">"+f+" <\/div>");t.appendTo(r);t.addClass(i.PROBE_BUTTON_CLASS);this.probeButton=new n.ProbeButton(surface,"#"+this.probeButtonId,this);this.updateProbeButton()},i.prototype.suspendProbeVisibility=function(){var t,i,r;for(this.probeVisArray=[],t=0;t<this.getProbes().length;t++)i=this.getProbe(t),i&&(r=i.getVisibility(),this.probeVisArray.push(r),i.setVisibility(n.VisibilityState.HIDDEN));this.waveboxVis=this.getVisibility();this.setVisibility(n.VisibilityState.HIDDEN)},i.prototype.restoreProbeVisibility=function(){var t,i,r;for(this.setVisibility(this.waveboxVis),t=0;t<this.getProbes().length;t++)i=this.getProbe(t),i&&(r=this.probeVisArray[t],i.setVisibility(r));this.probeVisArray=[];this.waveboxVis=n.VisibilityState.WAVEBOX},i.prototype.restore=function(t,i){this.removeProbes();this.setWaveboxState(t,i);for(var r=0;r<t.probeStates.length;r++)this.initProbeByState(t,i,r);this.updateProbeButton();i&&n.getWaveBoxManager().updateSingleWavebox(this)},i.prototype.getPlotInfo=function(n,t){return t===void 0&&(t=null),this.getPlotState().getPlotInfo(n,t)},i.prototype.getPlotMode=function(){return this.getPlotState().getPlotMode()},i.prototype.getProbeColor=function(n){return this.getProbePlotState(n)?this.getProbePlotState(n).getColor():null},i.prototype.getSimulationId=function(){return this.getPlotState().getSimulationId()},i.prototype.forTest_getPosition=function(){return this.waveboxWindow.wrapper.offset()},i.prototype.forTests_getRowAmount=function(){return this.getWaveContainer().getRows().length},i.WAVEBOX_WIDTH=250,i.WAVEBOX_HEIGHT=160,i.WAVEBOX_HIDE_WIDTH=100,i.WAVEBOX_HIDE_HEIGHT=40,i.WAVEBOX_MIN_WIDTH=80,i.WAVEBOX_MIN_HEIGHT=60,i.WAVEBOX_TITLE_HEIGHT=16,i.WAVEBOX_Y_VALUE_HEIGHT=13,i.VERTICALLY_SHOWN_WAVEBOXES=3,i.WAVEBOX_X_SHIFT=20,i.WAVEBOX_Y_SHIFT=20,i.NO_DATA=" (no data)",i.NO_DATA_FOR_0="No data",i.MAX_NUM_PROBES=2,i.PROBE_BUTTON_CLASS="probe_button",i.PROBE_BUTTON_ID="probe_button_",i.PLOT_CONTAINER_ID="waveContainer",i}(),t,r;n.WaveBox=i;t=function(){function n(n,t,i){this.inScreenCoor=!1;this.centerX=n;this.centerY=t;this.inScreenCoor=i}return n.prototype.getCenterInScreenCoor=function(n){var t;return this.inScreenCoor?new BaseWire.Point(this.centerX,this.centerY):n.getSurface().schToScreen(this.centerX,this.centerY)},n.prototype.getCenterInSchematicCoor=function(n){var t;return this.inScreenCoor?n.getSurface().screenToSch(this.centerX,this.centerY):new BaseWire.Point(this.centerX,this.centerY)},n}();n.WaveBoxPosition=t;r=function(){function t(n){this.title=i.NO_DATA_FOR_0;this.waveBox=n}return t.prototype.getTitleAsString=function(){return this.title},t.prototype.update=function(n,t){var o,h,f,r,e,u,l,a;if(t===void 0&&(t=-1),o=this.getTitleWidget(),this.setEmptyTitle(),h=this.getWaveBoxWindow(),f=this.waveBox.getPlotState().getTitles(n,t),f.length==0)o.css("color",this.waveBox.getProbePlotState(0).getColor()),h.title(i.NO_DATA_FOR_0);else{for(r=0;r<f.length;r++){var c=f[r],v=this.getTitleBlockId(r),s='<span id = "'+v+'">';for(e=0;e<c.titles.length;e++)u=c.titles[e],u&&(l=this.getProbeNameClass(u.probeIndex),a='<span class = "'+l+'" style="color: '+u.color+'">'+u.wfTitle+" <\/span>",s+=a);s+=" <\/span>";o.append(s);this.addTitleBlockTooltip(r)}this.shadeProbeName(t)}},t.prototype.setEmptyTitle=function(){var n=this.getWaveBoxWindow();n.title("")},t.prototype.setEventHandlers=function(){var i=this,n=this.getTitleWidget(),t;n.on("dblclick",function(n){n.stopPropagation()});t=this.getWaveBoxWindow();t.wrapper.find(".k-block>.k-header, .k-window-titlebar").on("dblclick",function(n){n.stopPropagation()});n.on("mousedown",function(){i.waveBox.probesToFront()})},t.prototype.adjustTitle=function(){var t=this.getWaveBoxWindow(),i=t.wrapper.width(),r=t.wrapper.find(".k-window-actions").width(),n=this.getTitleWidget();n&&(n.width(i-r),n.css("text-overflow","ellipsis"))},t.prototype.getTitleWidgetForBlock=function(n){return $("#"+this.getTitleBlockId(n))},t.prototype.getWaveBoxWindow=function(){return this.waveBox.getWaveBoxWindow()},t.prototype.addTitleBlockTooltip=function(n){var t=this,i=this.getTitleWidgetForBlock(n);i.qtip({content:function(){var i=t.getTitleBlockTooltip(n);return i?i:""},position:{my:"bottom left",at:"top left"},style:{classes:"svw-tooltip"},events:{show:function(){return!0}}})},t.prototype.getTitleBlockId=function(n){return this.waveBox.getUniqName()+"_title_"+n},t.prototype.getTitleBlockTooltip=function(n){var r=this.waveBox.getPlotState().getTitles(!1),u="",t,i;if(r.length==0||(t=r[n],!t))return null;for(i=0;i<t.titles.length;i++)u+=t.titles[i].wfTitle;return u},t.prototype.needToShowTitleTooltip=function(n){var t="";if(t=this.getTitleBlockTooltip(n),!t)return!1;var i=this.getWaveBoxWindow(),r=i.wrapper.find(".k-window-actions").css("font-size"),u=WaveViewer.WaveUtils.calcLabelWidth(t,r),f=i.wrapper.find(".k-window-actions").width();return u>i.wrapper.width()-f?!0:!1},t.prototype.getTitleWidget=function(){var n=this.getWaveBoxWindow();return n.wrapper.find(".k-window-title")},t.prototype.getProbeNameClass=function(n){return"ProbeWaveformTitle"+n},t.prototype.shadeProbeName=function(t){var i=this.getProbeNameClass(t);this.getTitleWidget().find("."+i).each(function(){$(this).css("opacity",n.WaveBoxManager.WAVEFORM_OPACITY)})},t}();n.WaveBoxTitle=r}(ProbeModule||(ProbeModule={})),function(n){function r(){return t||(t=new i),t}var i=function(){function t(){this.waveBoxes=[];this.useResizingMode=!1;this.newSimulationType=Project.SIMULATION_TYPE.TIME_DOMAIN;this.blockFlag=!1;this.plottedWaveboxes=0;this.initialColorIndex=-1;this.isNewProbe=!1;this.probePosition=null;this.previousWaveformHandler=null}return t.prototype.getNextWaveboxIndex=function(){return t.GLOBAL_WAVEBOX_INDEX++},t.prototype.resetWaveboxIndex=function(){t.GLOBAL_WAVEBOX_INDEX=1},t.prototype.addWaveboxToList=function(n){this.waveBoxes.push(n);this.plottedWaveboxes++},t.prototype.removeWaveboxFromList=function(n){this.waveBoxes.splice($.inArray(n,this.waveBoxes),1)},t.prototype.removeAllWaveboxes=function(n){for(var i,t=this.waveBoxes.length-1;t>=0;--t)i=this.waveBoxes[t],i&&i.remove(n);this.resetWaveboxIndex()},t.prototype.setResetMode=function(){for(var t,n=0;n<this.waveBoxes.length;n++)t=this.waveBoxes[n],t&&(t.resetMode=!0)},t.prototype.clearResetMode=function(){for(var t,n=0;n<this.waveBoxes.length;n++)t=this.waveBoxes[n],t&&(t.resetMode=!1)},t.prototype.updateWaveboxesByZoom=function(n,t){var r,i;for(r in this.waveBoxes)i=this.waveBoxes[r],i&&i.updateWaveboxByZoom(n,t)},t.prototype.updateWaveboxesAfterZoom=function(){var t,n;for(t in this.waveBoxes)n=this.waveBoxes[t],n&&n.repaintAfterZoom()},t.prototype.disableResizingMode=function(){this.useResizingMode=!1},t.prototype.enableResizingMode=function(){this.useResizingMode=!0},t.prototype.isAllowedResizingMode=function(){return this.useResizingMode},t.prototype.updateWaveboxesByPan=function(n,t){var i,r;if(n!=0||t!=0)for(i in this.waveBoxes)r=this.waveBoxes[i],r.updateWaveboxeByPan(n,t)},t.prototype.pinWaveboxesToSchematic=function(){var t,n;for(t in this.waveBoxes)n=this.waveBoxes[t],n&&n.pinToSchematic()},t.prototype.unpinWaveboxesFromSchematic=function(){var t,n;for(t in this.waveBoxes)n=this.waveBoxes[t],n&&n.unpinFromSchematic()},t.prototype.storePinState=function(){var t=[],i,n;for(i in this.waveBoxes)n=this.waveBoxes[i],n&&(t[n.uniqName]=n.isPinnedToSchematic());return t},t.prototype.restorePinState=function(n){var i,t;if(n)for(i in this.waveBoxes)t=this.waveBoxes[i],t&&(n[t.uniqName]?t.pinToSchematic():t.unpinFromSchematic())},t.prototype.prepareToNewSimulation=function(n){var i,t;for(i in this.waveBoxes)t=this.waveBoxes[i],t&&t.prepareToNewSimulation(n)},t.prototype.waitFunction=function(t,i){var r=this;n.getWaveBoxManager().isBlock()?setTimeout(function(){r.waitFunction(t,i)},10):(t(),i.resolve())},t.prototype.prepareToLoadSimulationResults=function(n){var t=$.Deferred();return this.newSimulationType=n,this.waitFunction(this.prepareToLoadSimulationResultsInternal,t),t.promise()},t.prototype.prepareToLoadSimulationResultsInternal=function(){var i=n.getWaveBoxManager(),r=surface.getDesign().getLatestSimulationByType(i.newSimulationType),u,t;for(u in i.waveBoxes)t=i.waveBoxes[u],t&&(r&&WaveViewer.getManager().clearWaveformDataForRange(r.simulationId,t.getWaveContainer(),t.getUniqName()),t.prepareToUpdate());i.newSimulationType=Project.SIMULATION_TYPE.TIME_DOMAIN},t.prototype.setSimulationDescriptionForWavebox=function(n,t){var i,u,r,f;if(n){i=this.waveBoxes;for(u in i)r=i[u],f=t==WaveViewer.UPDATING_MODE.BY_STATE?!1:!0,r&&r.setSimulationDescription(n,f)}},t.prototype.updateWaveboxes=function(){var i=this,n=$.Deferred(),t=this.waveBoxes;return!t||this.waveBoxes.length==0?n.resolve(!0):($.when(this.updateWaveboxesInternal(t)).done(function(t,r){if(r.length==0)n.resolve(t);else{for(var u=0;u<r.length;u++)r[u].resetWaveboxState(),r[u].showSpinner();$.when(i.updateWaveboxesInternal(r)).done(function(t){n.resolve(t)})}}).fail(function(){n.resolve(!1)}),n.promise())},t.prototype.updateWaveboxesWithoutData=function(){for(var t=this.waveBoxes,n=0;n<t.length;n++)t[n].updateTitle(!0),t[n].hideSpinner()},t.prototype.ifNoData=function(n,t){for(var r,i=0;i<t.getAmount();i++)if(r=t.getRowWaveforms(i),this.allEmpty(r))return!0;return!1},t.prototype.plotWavebox=function(n,t,i,r){var e=$.Deferred(),h=t.xAxisState,u,o,f,s,c,l;if(this.ifNoData(n,i))h.isViewAll||r.push(n),n.cleanByError(),e.resolve();else{for(n.isResizing&&e.resolve(),u=n.getWaveContainer(),o=h.range,o?u.setXVisibleState(o.xmin,o.xmax,h.isViewAll):u.setXVisibleState(null,null,!0),f=0;f<i.getAmount();f++)s=i.getRowWaveforms(f),s&&s.length>0&&(c=t.getYAxisStates(f),u.addWaveformsToNewRows(s,c,!0));l=n.needToHideDecoration();l?n.getWaveContainer().hideDecoration():n.getWaveContainer().restoreDefaultDecoration();$.when(u.plotRows(WaveViewer.RESIZE_MODE.NONE,null,!0)).done(function(){n.updateTitle(!1);var t=n.getPlotState().getCursorStates();t&&n.restoreCursors(t);n.hideSpinner();e.resolve()})}return e.promise()},t.prototype.initCalcWaveforms=function(n){for(var f,i,t=$.Deferred(),e=[],o=0,r=new ServerStructures.ExpressionRequestClient,u=0;u<n.length;u++)f=n[u],f&&(i=f.getPlotState(),i.hasCalcWaveform()&&(i.addExpressionRequestElement(r),e[o++]=i));return r.ExprRequests.length!=0?$.when(WaveViewer.ViewerRequests.createAndInitExpressions(r)).done(function(n){for(var i=0;i<n.length;i++)e[i].setCalcWfCredentials(n[i]);t.resolve()}).fail(function(){t.resolve()}):t.resolve(),t.promise()},t.prototype.completeWaveboxRestoring=function(){var i=this,t=jQuery.Deferred();return $.when(n.getWaveBoxManager().updateWaveboxes()).done(function(n){var u,r,f;for(Project.Utility.trace("completeWaveboxRestoring done",!0),u=i.waveBoxes,r=0;r<u.length;r++)f=u[r],f&&f.updatePlotState();t.resolve(n)}),t.promise()},t.prototype.updateWaveboxesInternal=function(n){var r=this,t=$.Deferred(),u=new ServerStructures.DesignDataRequest,f=[],e=[],i=[];return $.when(this.initCalcWaveforms(n)).done(function(){for(var o,l,s,h=0,c=0;c<n.length;c++)o=n[c],o&&(o.hasAttachedProbe()?(o.showSpinner(),l=o.getPlotState().getPlotInfo(h,o.getUniqName()),s=l.containerRequest,s&&s.notEmpty()?u.putContainerRequest(s)?(e[h]=l,f[h++]=o):o.cleanByError():o.cleanByError()):o.cleanByError());if(WaveViewer.SVW_Colors.initGlobalColorIndex(r.initialColorIndex),u.isEmpty())return t.resolve(!1,i),t.promise();$.when(WaveViewer.ViewerRequests.createAndInitWaveforms(u)).done(function(o){var h,s;if(o&&o.containers){for(h=[],s=0;s<o.containers.length;s++){var c=o.containers[s],v=u.getContainerRequest[s],l=f[s],a=e[s];h.push(r.plotWavebox(l,a,c,i))}$.when.apply(null,h).done(function(){t.resolve(!0,i)})}else r.cleanByError(n),t.resolve(!1,i)}).fail(function(){r.cleanByError(n);t.resolve(!1,i)})}),t.promise()},t.prototype.cleanByError=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.cleanByError()},t.prototype.setBlock=function(){this.blockFlag?console.log("ERROR in BLOCK mode"):this.blockFlag=!0},t.prototype.clearBlock=function(){this.blockFlag=!1},t.prototype.isBlock=function(){return this.blockFlag},t.prototype.updateSingleWavebox=function(n){var t=this;this.setBlock();$.when(this.updateSingleWaveboxInternal(n)).done(function(){t.clearBlock()})},t.prototype.updateSingleWaveboxInternal=function(n){var r=this,t=$.Deferred(),i;return n.showSpinner(),n.getPlotInfo(0)?(i=[],i.push(n),$.when(this.initCalcWaveforms(i)).done(function(){var u=n.getPlotInfo(0),i,f;n.prepareToUpdate();i=new ServerStructures.DesignDataRequest;f=u.containerRequest;i.putContainerRequest(f)?$.when(WaveViewer.ViewerRequests.createAndInitWaveforms(i)).done(function(i){if(i&&i.containers){var f=i.containers[0];i?$.when(r.plotWavebox(n,u,f,[])).done(function(){t.resolve(!0)}):(n.cleanByError(),t.resolve(!1))}else n.cleanByError(),t.resolve(!1)}):(n.cleanByError(),t.resolve(!1))})):(n.cleanByError(),t.resolve(!1)),t.promise()},t.prototype.allEmpty=function(n){if(!n)return!0;for(var t=0;t<n.length;t++)if(n[t]&&!n[t].isEmptyWaveform())return!1;return!0},t.prototype.clearAllWaveboxesByError=function(){var n=this.waveBoxes,t,i;for(t in n)i=n[t],i.cleanByError()},t.prototype.getPlottedWaveboxAmount=function(){return this.waveBoxes&&this.waveBoxes.length!=0||(this.plottedWaveboxes=0),this.plottedWaveboxes<0&&(this.plottedWaveboxes=0),this.plottedWaveboxes},t.prototype.ignoreMockProbe=function(){this.plottedWaveboxes--},t.prototype.setInitialWaveboxPosition=function(t){var r,i;for(this.plottedWaveboxes=0,r=0,i=0;i<n.WaveBox.VERTICALLY_SHOWN_WAVEBOXES;i++)this.checkForFirstPosition(t,i)&&(r=i+1);this.plottedWaveboxes=r},t.prototype.checkForFirstPosition=function(t,i){var o=sidebar_manager.getVisibleWidth(Sidebar.Orientation.LEFT),s=sidebar_manager.getVisibleWidth(Sidebar.Orientation.RIGHT),h=$(window).width()-s-o,c=n.WaveBox.WAVEBOX_HEIGHT+n.WaveBox.WAVEBOX_TITLE_HEIGHT,l=n.WaveBox.WAVEBOX_X_SHIFT+50,a=n.WaveBox.WAVEBOX_Y_SHIFT+50,r=t.getSurface().screenToSch(new BaseWire.Point(h-l,a+i*c)),v=new Project.BoundingRect(r.x,r.y,r.x+n.WaveBox.WAVEBOX_WIDTH,r.y+n.WaveBox.WAVEBOX_HEIGHT),u,f,e;for(u in this.waveBoxes)if(f=this.waveBoxes[u],e=Project.Utility.intersectRect(f.getBoundingRect(),v),e)return!0;return!1},t.prototype.countColorIndex=function(n){var t=WaveViewer.SVW_Colors.getGlobalIndexByColor(n);t>this.initialColorIndex&&(this.initialColorIndex=t)},t.prototype.getWaveformTreeJQ=function(){return $("#"+t.OBJECT_TREE_ID)},t.prototype.adjustDialogHeight=function(n){var r=this.probePosition,t,i;r&&(t=20,i=Math.abs($(SCHEMATIC_PANE).height()-r.y)-t,setTimeout(function(){var r=n.height()+t,u=n.closest(".k-window"),f=r<i?r:i;u.height(f)},300))},t.prototype.openWaveformDialog=function(i,r,u,f,e){var c,l,o,s,h,a;return this.closeWaveformDialog(!1,null),this.probeForDialog=r,this.isNewProbe=u,this.previousWaveformHandler=f,this.probePosition=i,c={visible:!0,title:!1,modal:!1,resizable:!0,width:n.WaveBox.WAVEBOX_WIDTH,height:n.WaveBox.WAVEBOX_HEIGHT,position:{top:i.y,left:i.x}},l=Math.abs($(SCHEMATIC_PANE).width()-i.y),this.waveformTreeDialog=$("<div><\/div>").appendTo(document.body).kendoWindow(c).data("kendoWindow"),this.waveformTreeDialog.content('<div id="'+t.OBJECT_TREE_ID+'"><\/div>'),o=WaveViewer.WdbInfo.getNewWdbId(),s=new WaveViewer.WdbInfo(r.getWavebox().getSimulationId(),e,o),s.isExpanded=!0,h=[],h.push(s),a=new WaveViewer.ViewerTree(n.getWaveBoxManager().getWaveformTreeJQ(),h,o,this.probeForDialog,e),u||this.setColor(this.probeForDialog.getColor()),this.waveformTreeDialog},t.prototype.setColor=function(t){var i=n.getWaveBoxManager().getWaveformTreeJQ().data("kendoTreeView"),r=i.dataSource.view()[0],u=i.findByUid(r.uid);u.find(".viewerSimulationFolder:first").css("color",t).css("font-weight","Bold")},t.prototype.closeWaveformDialog=function(n,t){this.probeForDialog=null;this.isNewProbe=!1;this.previousWaveformHandler=null;this.getWaveformTreeJQ().length&&(this.waveformTreeDialog&&this.waveformTreeDialog.destroy(),this.getWaveformTreeJQ().remove());(n||t)&&($(SCHEMATIC).unbind(".compDialog"),$(document).unbind(".compDialog"))},t.GLOBAL_WAVEBOX_INDEX=1,t.WAVEFORM_OPACITY=.3,t.OBJECT_TREE_ID="ObjectProbeTreeId",t}(),t;n.WaveBoxManager=i;n.getWaveBoxManager=r}(ProbeModule||(ProbeModule={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var ri=function(){function i(){}return i.convertOldProbeStateToWaveboxState=function(n){var i=new h,t,u,r;return i.cursorStates=n.cursorStates,i.simulationType=n.simulationType,i.uniqName=null,i.width=n.waveboxWidth,i.height=n.waveboxHeight,i.xCenter=n.waveboxLeft,i.yCenter=n.waveboxTop,i.isVisible=n.waveboxIsVisible,i.isPinned=!0,i.xAxis=nt.createXAxisState(new WaveViewer.XWaveRange(n.xmin,n.xmax),n.isViewAllForX),i.probeStates=[],n.compInstName?(t=new a,t.compInstName=n.compInstName,t.compWfName=n.compWfName,t.uniqName=n.uniqName,t.x=n.x,t.y=n.y,i.probeStates.push(t)):n.wireSegName?(t=new l,t.wireSegName=n.wireSegName,t.uniqName=n.uniqName,t.x=n.x,t.y=n.y,i.probeStates.push(t)):(t=new v,t.uniqName=n.uniqName,t.x=n.x,t.y=n.y,i.probeStates.push(t)),i.rowStates=[],u=new c,u.waveformStates=[],r=new f,r.color=n.waveformColor,r.probeIndex=0,r.showPoints=!1,r.yAxis=tt.createYAxisState(n.yRange,!0,!1),r.transformName=n.transformName,u.waveformStates.push(r),i.rowStates.push(u),i},i.deserializeWaveboxState=function(i){var e=new h,p,nt,k,rt,tt,y,d,w,g,o,b,s,u;for(e.cursorStates=i.cursorStates,e.simulationType=i.simulationType,e.uniqName=null,e.width=i.width,e.height=i.height,e.xCenter=i.xCenter,e.yCenter=i.yCenter,e.isVisible=i.isVisible,e.isPinned=i.isPinned,e.xAxis=i.xAxis,e.probeStates=[],y=0;y<i.probeStates.length;y++)p=i.probeStates[y],s=void 0,p.typeId==t.COMPONENT?(nt=p,k=new a,k.compInstName=nt.compInstName,k.compWfName=nt.compWfName,s=k):p.typeId==t.WIRE?(rt=p,tt=new l,tt.wireSegName=rt.wireSegName,s=tt):s=new v,s&&(s.uniqName=p.uniqName,s.x=p.x,s.y=p.y,e.probeStates.push(s));for(e.rowStates=[],y=0;y<i.rowStates.length;y++)if(d=i.rowStates[y],w=new c,w.waveformStates=[],d.waveformStates){for(g=0;g<d.waveformStates.length;g++)o=d.waveformStates[g],o.typeId==r.CALCULATOR?(b=o,u=new it,u.color=o.color,u.function=b.function,u.probeIndices=b.probeIndices,u.showPoints=o.showPoints,u.yAxis=n.YAxisState.createYAxisState(o.yAxis.range,o.yAxis.isViewAll,!1),u.transformName=o.transformName,u.resultId=b.resultId,u.handle=b.handle,w.waveformStates.push(u)):(s=o,u=new f,u.color=o.color,u.probeIndex=s.probeIndex,u.showPoints=o.showPoints,u.yAxis=n.YAxisState.createYAxisState(o.yAxis.range,o.yAxis.isViewAll,!1),u.transformName=o.transformName,w.waveformStates.push(u));e.rowStates.push(w)}return e},i.getProbeColor=function(n,t){for(var e,u,i,r=0;r<t.rowStates.length;r++)for(e=t.rowStates[r],u=0;u<e.waveformStates.length;u++)if(i=e.waveformStates[u],i&&i instanceof f&&i.probeIndex==n)return i.color;return null},i}(),b,ut,ft,et,e,ot,st,ht,k,ct,lt,at,o,s,d,g,vt,yt,pt,wt,i,bt,kt,dt,gt,ni,ui,t,r,h,c,u,l,a,v,y,nt,tt,p,f,it,rt,w,ti,ii;n.WaveBoxMigration=ri;b=function(){function n(){this.DataRequests=[]}return n}();n.WaveformDataRequest=b;ut=function(){function n(){this.containerDataRequestList=[]}return n.prototype.getContainerAmount=function(){return this.containerDataRequestList.length},n.prototype.getServerRequest=function(){for(var t,i=new b,n=0;n<this.containerDataRequestList.length;n++)t=this.containerDataRequestList[n],t&&t.getServerRequest(i);return i},n.prototype.getElement=function(n){if(this.isEmpty())return null;var t=this.containerDataRequestList[n.contIndex];return t?t.getElement(n):null},n.prototype.isEmpty=function(){return this.containerDataRequestList.length==0},n.prototype.putContainerRequest=function(n){return n.notEmpty()?(this.containerDataRequestList[n.contIndex]=n,!0):!1},n.prototype.getContainerRequest=function(n){return this.isEmpty()?null:this.containerDataRequestList[n]},n}();n.DesignDataRequest=ut;ft=function(){function n(n){this.contIndex=0;this.rowDataRequestList=[];this.contIndex=n}return n.prototype.getRowAmount=function(){return this.rowDataRequestList.length},n.prototype.getElement=function(n){if(!this.notEmpty())return null;var t=this.rowDataRequestList[n.rowIndex];return t?t.getElement(n):null},n.prototype.notEmpty=function(){return this.rowDataRequestList.length!=0},n.prototype.putRowRequest=function(n){n&&n.notEmpty()&&(this.rowDataRequestList[n.rowIndex]=n)},n.prototype.getRowRequest=function(n){return this.notEmpty()?this.rowDataRequestList[n]:null},n.prototype.getServerRequest=function(n){for(var i,t=0;t<this.rowDataRequestList.length;t++)i=this.rowDataRequestList[t],i&&i.getServerRequest(n)},n}();n.ContainerDataRequest=ft;et=function(){function n(n){this.waveforms=[];this.rowIndex=0;this.rowIndex=n}return n.prototype.getWaveformAmount=function(){return this.waveforms.length},n.prototype.putWaveformElement=function(n){n&&(this.waveforms[n.wfIndex]=n)},n.prototype.getWaveformElement=function(n){return this.notEmpty()?this.waveforms[n]:null},n.prototype.notEmpty=function(){return this.waveforms.length!=0},n.prototype.getServerRequest=function(n){for(var t,i,r=0;r<this.waveforms.length;r++)t=this.waveforms[r],t&&(i=new e,i.divisions=t.divisions,i.includeMetadata=t.includeMetadata,i.resultId=t.resultId,i.waveformId=t.waveformId,i.xmax=t.xmax,i.xmin=t.xmin,n.DataRequests.push(i))},n.prototype.getElement=function(n){if(!this.notEmpty())return null;return this.waveforms[n.waveformIndex]},n}();n.RowDataRequest=et;e=function(){function n(){}return n}();n.WaveformDataRequestElem=e;ot=function(n){function t(t,i){n.call(this);this.wfIndex=0;this.panDirection=WaveViewer.PAN_DIRECTION.NONE;this.wfIndex=t;this.sourceInfo=i}return __extends(t,n),t}(e);n.WaveformDataRequestElemClient=ot;st=function(){function n(){this.TransferData=[]}return n}();n.WaveformDataTransfer=st;ht=function(){function n(){}return n}();n.WaveformDataTransferElem=ht;k=function(){function n(){}return n}();n.StatusMessage=k;ct=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(k);n.DetailStatusMessage=ct;lt=function(){function n(n){this.useLogXAxis=!1;this.DataType=n.DataType;this.Label=n.Label;this.XName=n.XName;this.YName=n.YName;this.XUnits=n.XUnits;this.YUnits=n.YUnits;this.xWaveformMin=n.xWaveformMin;this.xWaveformMax=n.xWaveformMax;this.yWaveformMin=n.yWaveformMin;this.yWaveformMax=n.yWaveformMax;this.useLogXAxis=n.useLogXAxis;this.Handle=n.Handle;this.Type=n.Type}return n}();n.WaveformMetadata=lt;at=function(){function n(n,t,i){this.XMin=n.XMin;this.XMax=n.XMax;this.IsResolved=n.IsResolved;n.Data=this.convertToData(n.Data,t,i);this.Data=n.Data}return n.prototype.convertToData=function(n,t,i){switch(i){case WaveViewer.WaveManager.NUMERIC_INTEGER_DATA:case WaveViewer.WaveManager.NUMERIC_REAL_DATA:case WaveViewer.WaveManager.ENUMERATED_DATA:return new s(n);case WaveViewer.WaveManager.NUMERIC_COMPLEX_DATA:return new g(n);case WaveViewer.WaveManager.STRING_DATA:return new d(n);default:return null}},n}();n.WaveformData=at;o=function(){function n(n){this.XData=n.XData}return n}();n.DataSeries=o;s=function(n){function t(t){n.call(this,t);this.YData=this.fixData(t.YData)}return __extends(t,n),t.prototype.fixData=function(n){for(var r,i=[],t=0;t<n.length;t++)r=WaveViewer.WaveUtils.fixInfinite(n[t]),i.push(r);return i},t}(o);n.DataSeriesNumeric=s;d=function(n){function t(t){var r,u,i;for(n.call(this,t),this.YValueData=[],r=[],u=WaveViewer.StdLogicWaveform.SLOGIC_X,i=0;i<t.YData.length;i++)this.YValueData.push(t.YData[i]),r.push(u);this.YData=r}return __extends(t,n),t}(s);n.DataSeriesString=d;g=function(n){function t(t){n.call(this,t);this.YDataReal=t.YDataReal;this.YDataImag=t.YDataImag}return __extends(t,n),t}(o);n.DataSeriesComplex=g;vt=function(){function n(n){this.isBusBit=!1;this.Name=n.Name;this.Id=n.Id;this.Type=n.Type;this.Children=n.Children}return n.prototype.parseList=function(t){var u=[],i,r,f;if(!t)return null;for(i=0;i<t.length;i++)r=t[i],r&&(f=new n(r),u.push(f));return u},n}();n.ViewerNodeMetadata=vt;yt=function(){function n(){this.resultIdWaveformIdPairs=[]}return n}();n.ResultsDownloadRequest=yt;pt=function(){function n(){this.ResultIdWaveformIdPairs=[]}return n}();n.YValuesRequest=pt;wt=function(){function n(){}return n}();n.ResultIdWaveformId=wt;i=function(){function n(){}return n}();n.YValueData=i;bt=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.YValueDataDouble=bt;kt=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.YValueDataComplex=kt;dt=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.YValueDataString=dt;gt=function(){function n(){}return n}();n.ServerDesignSimulationDataState=gt;ni=function(){function n(){}return n}();n.ServerDesignState=ni,function(n){n[n.ADD=1]="ADD";n[n.SUBTRACT=2]="SUBTRACT";n[n.MULTIPLY=3]="MULTIPLY";n[n.DIVIDE=4]="DIVIDE";n[n.SUBTRACT_OPPOSITE=5]="SUBTRACT_OPPOSITE";n[n.DIVIDE_OPPOSITE=6]="DIVIDE_OPPOSITE"}(n.CalculatorFunction||(n.CalculatorFunction={}));ui=n.CalculatorFunction,function(n){n[n.EMPTY=0]="EMPTY";n[n.WIRE=1]="WIRE";n[n.COMPONENT=2]="COMPONENT"}(n.ProbeStateType||(n.ProbeStateType={}));t=n.ProbeStateType,function(n){n[n.NONE=0]="NONE";n[n.PROBE=1]="PROBE";n[n.CALCULATOR=2]="CALCULATOR"}(n.WaveformStateType||(n.WaveformStateType={}));r=n.WaveformStateType;h=function(){function n(){this.cursorStates=[];this.probeStates=[];this.rowStates=[]}return n}();n.WaveboxState=h;c=function(){function n(){this.waveformStates=[]}return n}();n.WaveboxRowState=c;u=function(){function n(){this.typeId=t.EMPTY;this.probeIndex=0}return n}();n.ProbeState=u;l=function(n){function i(){n.call(this);this.typeId=t.WIRE}return __extends(i,n),i}(u);n.WireProbeState=l;a=function(n){function i(){n.call(this);this.typeId=t.COMPONENT}return __extends(i,n),i}(u);n.ComponentProbeState=a;v=function(n){function i(){n.call(this);this.typeId=t.EMPTY}return __extends(i,n),i}(u);n.EmptyProbeState=v;y=function(){function n(){this.isViewAll=!0}return n}();n.AxisState=y;nt=function(n){function t(){n.apply(this,arguments);this.range=null}return __extends(t,n),t.createXAxisState=function(n,i,r){r===void 0&&(r=!1);var u=new t;return n?(u.range=new WaveViewer.XWaveRange(n.xmin,n.xmax),u.isViewAll=i):r?(u.range=new WaveViewer.XWaveRange(0,1),u.isViewAll=!0):(u.range=new WaveViewer.XWaveRange(null,null),u.isViewAll=!0),u},t}(y);n.XAxisState=nt;tt=function(n){function t(){n.apply(this,arguments);this.range=null}return __extends(t,n),t.createYAxisState=function(n,i,r){var u=new t;return n?(u.range=new WaveViewer.YWaveRange(n.ymin,n.ymax,n.axisName,n.useAsConstant),u.isViewAll=i):r?(u.range=WaveViewer.YWaveRange.getEmptyRange(),u.isViewAll=!0):(u.range=new WaveViewer.YWaveRange(null,null,WaveViewer.WaveManager.NO_UNITS,!0),u.isViewAll=!0),u},t}(y);n.YAxisState=tt;p=function(){function n(){this.typeId=r.NONE;this.showPoints=!1}return n}();n.WaveformBaseState=p;f=function(n){function t(){n.call(this);this.typeId=r.PROBE}return __extends(t,n),t}(p);n.ProbeWaveformState=f;it=function(n){function t(){n.call(this);this.probeIndices=[];this.typeId=r.CALCULATOR}return __extends(t,n),t}(p);n.CalculatorWaveformState=it;rt=function(){function n(){this.ExprRequests=[]}return n}();n.ExpressionRequest=rt;w=function(){function n(){}return n}();n.ExpressionRequestElem=w;ti=function(){function n(){this.ExprRequests=[]}return n.prototype.getServerRequest=function(){for(var t,i=new rt,n=0;n<this.ExprRequests.length;n++)t=this.ExprRequests[n],t&&t.getServerRequest(i);return i},n}();n.ExpressionRequestClient=ti;ii=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t.prototype.getServerRequest=function(n){var t=new w;t.divisions=this.divisions;t.expression=this.expression;t.xmax=this.xmax;t.xmin=this.xmin;t.name=this.name;n.ExprRequests.push(t)},t}(w);n.ExpressionRequestElemClient=ii}(ServerStructures||(ServerStructures={})),function(n){var e=function(){function i(){}return i.getWdbFromServer=function(n){return $.ajax({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},url:Project.Settings.APIURI()+"/waveforms?resultId="+n,type:"GET",data:null,contentType:"application/json;charset=utf-8"})},i.getWdb=function(t){var u=$.Deferred(),r;return Project.Utility.trace("getWdb for "+t,!0),r=n.getManager().getWdbMetadataFromCache(t),Project.Utility.trace("getWdbMetadataFromCache",!0),r?(i.setWdbName(r),u.resolve(r)):$.when(i.getWdbFromServer(t)).done(function(f){i.isCorrectResponse(f)?(r=new ServerStructures.ViewerNodeMetadata(f),i.setWdbName(r),n.getManager().putWdbMetadataToCache(t,r),u.resolve(r)):u.resolve(null)}).fail(function(t){n.getManager().isWindowMode()&&!surface.isSharedDesign()&&i.showExceptionMessage(t.responseJSON);u.resolve(null)}),u.promise()},i.setWdbName=function(t){var r=null,u=t.Name;n.getManager().isWindowMode()&&surface&&surface.getDesign()&&(r=surface.getDesign().getName());(r==null||r=="")&&(r=u==null||u==""?i.DEFAULT_RESULT_NAME:u);t.Name=r},i.getWaveformStuffFromServer=function(n){var t=n.getServerRequest();return $.ajax({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},url:Project.Settings.APIURI()+"/waveforms",type:"POST",data:JSON.stringify(t),contentType:"application/json;charset=utf-8"})},i.showExpressionError=function(n,t){t||(t="This ");var r=t+" waveform has no results for current operation.",i="";i=n?t+": "+n:r;i&&Project.MessageManager.showErrorMessage(i)},i.isExpressionResultCorrect=function(n,t){if(n||this.showExpressionError(null,t),!n.WaveformStatus)return!0;var i=n.WaveformStatus.DetailMessage;return i?(this.showExpressionError(i,t),!1):(i=n.WaveformStatus.Message,i)?(this.showExpressionError(i,t),!1):!0},i.createAndInitExpressions=function(n){var t=this,r=$.Deferred(),u=n.getServerRequest();return $.when(i.getExpressionStuffFromServer(u)).done(function(f){var s,e,h,o,c;if(Project.Utility.trace("Calc waveform info from server received",!0),s=[],i.isCorrectResponse(f)){for(e=0;e<f.TransferData.length;e++)Project.Utility.trace("Init a calc waveform",!1),h=f.TransferData[e],o=n.ExprRequests[e],t.isExpressionResultCorrect(h,o.name)?(c=t.handleResponseAsWaveform(h,o.xmin,o.xmax,o.wdbId,o.containerUniqName),s[e]=c?c:null):s[e]=null;r.resolve(s)}else t.showExpressionError(null,u.ExprRequests[0].name),r.resolve(null)}).fail(function(){t.showExpressionError(null,u.ExprRequests[0].name);r.resolve(null)}),r.promise()},i.getExpressionStuffFromServer=function(n){return $.ajax({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},url:Project.Settings.APIURI()+"/expressions",type:"POST",data:JSON.stringify(n),contentType:"application/json;charset=utf-8"})},i.getNumDivsForRequest=function(n){return n?300:1500},i.createWaveformDataRequest=function(t,i,r,u,f,e){var l=!1,v,o,s,h;u?(i=null,r=null,l=!0):(i==null||r==null)&&(l=!0);var b=new ServerStructures.DesignDataRequest,k=new ServerStructures.ContainerDataRequest(0),a=new ServerStructures.RowDataRequest(0),w=0;for(v=0;v<t.length;v++)if(o=t[v],o.simulationId&&!o.isEmptyWaveform()){var y=Math.max(i,o.getXWaveformMin()),p=Math.min(r,o.getXWaveformMax()),d=o.sourceInfo.containerUniqName,c=n.getManager().getWaveformDataFromCache(o.simulationId,o.getWaveformHandle(),l,d);c&&c.match(y,p,l,f)?(Project.Utility.trace("Found WaveformData in cache",!1),o.setWaveformData(c)):c?(s=new n.PanInfo(f,y,p,this.getNumDivsForRequest(o.isBus())),s=c.checkShift(s),s.panDirection!=n.PAN_DIRECTION.NONE?(h=n.WaveUtils.createWaveformDataRequestElem(o.simulationId,o.getWaveformHandle(),s.min,s.max,!1,o.wdbId,o.getColor(),s.panDirection,o.isBus(),w++,o.sourceInfo),h.divisions=s.numPoints,a.putWaveformElement(h),e.push(o)):(h=n.WaveUtils.createWaveformDataRequestElem(o.simulationId,o.getWaveformHandle(),y,p,!1,o.wdbId,o.getColor(),n.PAN_DIRECTION.NONE,o.isBus(),w++,o.sourceInfo),a.putWaveformElement(h),e.push(o))):(h=n.WaveUtils.createWaveformDataRequestElem(o.simulationId,o.getWaveformHandle(),y,p,!1,o.wdbId,o.getColor(),n.PAN_DIRECTION.NONE,o.isBus(),w++,o.sourceInfo),a.putWaveformElement(h),e.push(o))}return k.putRowRequest(a),b.putContainerRequest(k),b},i.getWaveformsData=function(t,r,u,f,e){var o=$.Deferred(),h=!1;f?(r=null,u=null,h=!0):(r==null||u==null)&&(h=!0);var c=[],s=this.createWaveformDataRequest(t,r,u,f,e,c);return s.isEmpty()?o.resolve():$.when(i.getWaveformStuffFromServer(s)).done(function(t){var u,a,f;if(Project.Utility.trace("WaveformData from server received",!0),i.isCorrectResponse(t))for(u=0;u<t.TransferData.length;u++){var r=c[u],l=t.TransferData[u],p=r.getFlotWaveformId(),y=new n.ResponseInfo(0,0,u),e=s.getElement(y),v=e.sourceInfo.containerUniqName;l.Data&&l.Data.Data?e.panDirection!=n.PAN_DIRECTION.NONE?(f=n.getManager().getWaveformDataFromCache(r.simulationId,r.getWaveformHandle(),!1,v),a=new ServerStructures.WaveformData(l.Data,r.getWaveformType(),r.getDataType()),f.combineData(a,e.xmin,e.xmax,e.panDirection,e.isBus,r.getDataType()),n.getManager().putWaveformDataToCache(r.simulationId,r.getWaveformHandle(),f,v),r.setWaveformData(f)):(a=new ServerStructures.WaveformData(l.Data,r.getWaveformType(),r.getDataType()),f=new n.WaveformData(a,h,r.getDataType()),n.getManager().putWaveformDataToCache(r.simulationId,r.getWaveformHandle(),f,v),r.setWaveformData(f)):c[u]=n.Waveform.getEmptyWaveform()}Project.Utility.trace("Set WaveformData into waveforms",!1);o.resolve()}).fail(function(n){i.showExceptionMessage(n.responseJSON);i.reportMinMaxError(n.responseJSON,s);o.resolve()}),o.promise()},i.cleanUpRequest=function(i,r){var y,d,p,f,e,h,c,o,u,l,s,k,a,v;if(Project.Utility.trace("Get WaveformData from server starts",!0),y=new ServerStructures.DesignDataRequest,d=[],!i||i.isEmpty())return null;for(p=0,f=0;f<i.getContainerAmount();f++){var nt=new t(f),w=i.getContainerRequest(f),g=0,b=new ServerStructures.ContainerDataRequest(f);for(e=0;e<w.getRowAmount();e++)if(h=w.getRowRequest(e),h){for(c=new ServerStructures.RowDataRequest(g++),o=0;o<h.getWaveformAmount();o++)u=h.getWaveformElement(o),u.resultId?(l=!1,(u.xmin==null||u.xmax==null)&&(l=!0),s=n.getManager().getWaveformInfoFromCache(u.resultId,u.waveformId,null,!0),s&&s.isMetadataSet()?(k=u.sourceInfo.containerUniqName,a=n.getManager().getWaveformDataFromCache(u.resultId,u.waveformId,l,k),a&&a.match(u.xmin,u.xmax,l,n.PAN_DIRECTION.NONE)?(Project.Utility.trace("Found WaveformData in cache",!1),v=n.Waveform.createWaveform(s,s.wdbId,u.sourceInfo,!1),v.setWaveformData(a),v.setCustomColor(u.waveformColor),r.putWaveformToResults(v,f,e,o)):(r.putPlaceholderToResults(p++,f,e,o),c.putWaveformElement(u))):(r.putPlaceholderToResults(p++,f,e,o),c.putWaveformElement(u))):r.putWaveformToResults(null,f,e,o);b.putRowRequest(c)}y.putContainerRequest(b)}return y},i.createViewerNodeMetadata=function(n){var t=new ServerStructures.ViewerNodeMetadata(n);return t.Name=n.Metadata.Label,t.Id=n.Metadata.Handle,t.Type=n.Metadata.Type,t},i.createAndInitWaveforms=function(t){var r=$.Deferred();if(Project.Utility.trace("Get WaveformData from server starts",!0),!t||t.isEmpty())return r.resolve(null),r.promise();var f=new u,e=this.cleanUpRequest(t,f);return e.isEmpty()?(r.resolve(f),r.promise()):($.when(i.getWaveformStuffFromServer(e)).done(function(t){var c,u,a,p,v,y;if(Project.Utility.trace("WaveformData from server received",!0),i.isCorrectResponse(t))for(c=0;c<t.TransferData.length;c++){Project.Utility.trace("Init a waveform",!1);var h=t.TransferData[c],l=f.getResponseInfo(c),o=e.getElement(l),k=o.sourceInfo.containerUniqName,s=void 0;if(h.Data&&h.Data.Data){u=n.getManager().getWaveformInfoFromCache(o.resultId,o.waveformId,null,!0);u?o.includeMetadata&&(a=new ServerStructures.WaveformMetadata(h.Metadata),u.setWaveformMetadata(a),n.getManager().putWaveformInfoToCache(u)):(p=i.createViewerNodeMetadata(h),u=new n.WaveformInfo(o.resultId,o.wdbId,p),a=new ServerStructures.WaveformMetadata(h.Metadata),u.setWaveformMetadata(a),n.getManager().putWaveformInfoToCache(u));s=n.Waveform.createWaveform(u,u.wdbId,o.sourceInfo,!1);s.setCustomColor(o.waveformColor);var d=new ServerStructures.WaveformData(h.Data,u.getWaveformType(),u.getDataType()),w=!1,b=!1;o.xmin==null||o.xmax==null?w=!0:(v=u.getWholeXRange(),(o.xmin>v.xmax||o.xmax<v.xmin)&&(s=n.Waveform.getEmptyWaveform(),b=!0));b||(y=new n.WaveformData(d,w,s.getDataType()),n.getManager().putWaveformDataToCache(u.getSimulationId(),u.getWaveformHandle(),y,k),s.setWaveformData(y))}else s=n.Waveform.getEmptyWaveform();f.putWaveformToResults(s,l.contIndex,l.rowIndex,l.waveformIndex)}Project.Utility.trace("Create waveforms based on info from server",!1);r.resolve(f)}).fail(function(n){i.showExceptionMessage(n.responseJSON);i.reportMinMaxError(n.responseJSON,e);r.resolve(null)}),r.promise())},i.getYValues=function(n,t){var r=$.Deferred();return $.when(i.getYValuesFromServer(n,t)).done(function(n){if(i.isCorrectResponse(n)){var t=n;r.resolve(t)}else r.resolve(null)}).fail(function(n){i.showExceptionMessage(n.responseJSON);r.resolve(null)}),r.promise()},i.getYValuesFromServer=function(n,t){var u=new ServerStructures.YValuesRequest,i,f,r;for(u.XValue=n,i=0;i<t.length;i++)f=t[i],r=new ServerStructures.ResultIdWaveformId,r.ResultId=f.simulationId,r.WaveformId=f.getWaveformHandle(),u.ResultIdWaveformIdPairs.push(r);return $.ajax({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},url:Project.Settings.APIURI()+"/yvalues",type:"POST",data:JSON.stringify(u),contentType:"application/json;charset=utf-8"})},i.getSimulationInformation=function(n){var t=$.Deferred();return $.when(i.getSimulationInformationFromServer(n)).done(function(n){var i=null;n&&$.isArray(n)&&n[0]!=null&&(i=n[0]);t.resolve(i)}).fail(function(n){i.showExceptionMessage(n.responseJSON);t.resolve(null)}),t.promise()},i.getSimulationInformationFromServer=function(t){return $.ajax({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5",userID:n.WaveManager.getUUID()},url:Project.Settings.APIURI()+"/results/?designId="+t,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8"})},i.showExceptionMessage=function(n){if(!n){i.isCorrectResponse(null);return}var t=n.Message,r=t.indexOf("ExceptionMessage");r>=0&&(t=t.substring(r-1));t.length>0&&(console.log("Error = "+t),Project.MessageManager.showErrorMessage(t))},i.isCorrectResponse=function(n){var t=null,r;return(n?n.hasOwnProperty("ErrorMessage")?(r=i.getFirstLine(n.ErrorMessage),console.log("Error = "+n.ErrorMessage),t=r):n.hasOwnProperty("Message")&&(r=i.getFirstLine(n.Message),console.log("Error = "+n.Message),t=r):t="Incorrect data received",!t)?!0:(Project.MessageManager.showErrorMessage(t),!1)},i.isCorrectWaveformData=function(n){var t;if(n){if(n.hasOwnProperty("ErrorMessage"))return t=i.getFirstLine(n.ErrorMessage),console.log("Error = "+n.ErrorMessage),Project.MessageManager.showErrorMessage(t),!1;if(n.hasOwnProperty("Message"))return t=i.getFirstLine(n.Message),console.log("Error = "+n.Message),Project.MessageManager.showErrorMessage(t),!1}else return Project.MessageManager.showErrorMessage("Incorrect data received"),!1;return!0},i.getFirstLine=function(n){if(!n)return n;var t=n.indexOf("\n");return t>0?n.substr(0,t):n},i.sendViewerStateToServer=function(n){var t=$.Deferred(),i=n.getViewerState();return $.ajax(Project.Settings.APIURI()+"/viewerstate",{dataType:"json",contentType:"application/json;charset=utf-8",type:"POST",data:JSON.stringify(i),headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},success:function(n){t.resolve(n)},error:function(n,i){t.resolve(null);Project.MessageManager.showErrorMessage("Error saving state: "+i)}}),t.promise()},i.getViewerStateFromServer=function(n){var t=$.Deferred();return $.ajax(Project.Settings.APIURI()+"/viewerstate?stateId="+n,{dataType:"json",contentType:"application/json;charset=utf-8",type:"GET",headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},success:function(n){t.resolve(n)},error:function(n,i){t.resolve();Project.MessageManager.showErrorMessage("Error getting state: "+i)}}),t.promise()},i.reportMinMaxError=function(n,t){if(n.Message.indexOf("Internal error getting simulation data")>=0){var i=t.getServerRequest(),r=JSON.stringify(i);Project.Settings.notify("xminmax error",{url:Project.Settings.APIURI(),data:r})}},i.downloadWaveformData=function(n,t,i){var f=new ServerStructures.ResultsDownloadRequest,r,e,u,o;for(f.fileType=i,r=0;r<t.length;r++)e=t[r],u=new ServerStructures.ResultIdWaveformId,u.ResultId=e.simulationId,u.WaveformId=e.getWaveformHandle(),f.resultIdWaveformIdPairs.push(u);o=JSON.stringify(f);$.ajax(Project.Settings.APIURI()+"/results",{dataType:"json",contentType:"application/json;charset=utf-8",type:"POST",data:o,headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},success:function(t){if(t!=null){var i=Project.Settings.APIURI()+"/results?tempID="+t+"&notUsed=true";n.attr("src",i)}},error:function(n,t){Project.MessageManager.showErrorMessage("Error downloading waveform data: "+t)}})},i.getMeasurementStuffFromServer=function(n){return $.ajax({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},url:Project.Settings.APIURI()+"/measurements",type:"POST",data:JSON.stringify(n),contentType:"application/json;charset=utf-8"})},i.isForWaveform=function(n){return n.ReturnType==ServerStructures.ReturnType.WAVEFORM?!0:n.ReturnType=="1"?!0:!1},i.createAndInitMeasurements=function(t){var r=this,u=$.Deferred();return $.when(i.getMeasurementStuffFromServer(t)).done(function(f){var o,e;if(Project.Utility.trace("Calc waveform info from server received",!0),o=[],i.isCorrectResponse(f)){for(e=0;e<f.TransferData.length;e++){Project.Utility.trace("Init a meas waveform",!1);var h=f.TransferData[e],s=t.MeasRequests[e],c=r.isForWaveform(s);if(r.isMeasurementResultCorrect(h,s.waveformName,s.MeasurementId,c))if(c){var l=n.WdbInfo.getExpressionWdbId(),a=h.MeasurementWaveform,v=n.SourceInfo.VIEWER_CONTAINER_NAME,y=r.handleResponseAsWaveform(a,s.XBegin,s.XEnd,l,v);o[e]=y?h:null}else o[e]=h;else o[e]=null}u.resolve(o)}else r.showMeasurementError(t.MeasRequests[0].MeasurementId,null,t.MeasRequests[0].waveformName),u.resolve(null)}).fail(function(){r.showMeasurementError(t.MeasRequests[0].MeasurementId,null,t.MeasRequests[0].waveformName);u.resolve(null)}),u.promise()},i.handleResponseAsWaveform=function(t,r,u,e,o){var c,y;if(!t.Metadata||!t.Data||!t.Data.Data)return null;var l,p=i.createViewerNodeMetadata(t),s=new n.WaveformInfo(t.Metadata.ResultId,e,p),h=new f;h.resultId=t.Metadata.ResultId;h.handle=t.Metadata.Handle;l=new ServerStructures.WaveformMetadata(t.Metadata);s.setWaveformMetadata(l);n.getManager().putWaveformInfoToCache(s);var w=new ServerStructures.WaveformData(t.Data,s.getWaveformType(),s.getDataType()),a=!1,v=!1;return r==null||u==null?a=!0:(c=s.getWholeXRange(),(r<c.xmin||u>c.xmax)&&(v=!0)),v||(y=new n.WaveformData(w,a,t.Metadata.DataType),n.getManager().putWaveformDataToCache(s.getSimulationId(),s.getWaveformHandle(),y,o)),h},i.isMeasurementResultCorrect=function(n,t,i){if(!n)return this.showMeasurementError(i,null,t),!1;if(!n.MeasurementStatus)return!0;var r=n.MeasurementStatus.DetailMessage;return r?(this.showMeasurementError(i,r,t),!1):(r=n.MeasurementStatus.Message,r)?(this.showMeasurementError(i,r,t),!1):!0},i.showMeasurementError=function(n,t,i){var e=Operations.ToolUtils.getMeasurementNameById(n),r="",f,u;i?r=e+"("+i+")":(i="This ",r=i);f=r+" waveform has no results";u="";u=n?e?t?r+": "+t:f:"Measurement with "+n+" has not been implemented yet":f;u&&Project.MessageManager.showErrorMessage(u)},i.getMeasurementResults=function(n){var t=$.Deferred();return $.when(i.getMeasurementResultsFromServer(n)).done(function(n){t.resolve(n)}).fail(function(n){i.showExceptionMessage(n.responseJSON);t.resolve(null)}),t.promise()},i.getMeasurementResultsFromServer=function(n){return $.ajax({headers:{TOKEN_HEADER:Project.Settings.APIKEY,TOKEN:"5"},url:Project.Settings.APIURI()+"/Measurements",type:"POST",data:JSON.stringify(n),contentType:"application/json;charset=utf-8"})},i.TempOverUnderUnitFix=function(n,t){n instanceof ServerStructures.OverUnderMeasurementRequest&&n.AbsoluteOrRelative==ServerStructures.AbsoluteRelative.RELATIVE&&(t.MeasurementValues.Units="%")},i.DEFAULT_RESULT_NAME="Results",i}(),r,u,t,i,f;n.ViewerRequests=e;r=function(){function n(n,t,i){this.contIndex=0;this.rowIndex=0;this.waveformIndex=0;this.contIndex=n;this.rowIndex=t;this.waveformIndex=i}return n}();n.ResponseInfo=r;u=function(){function n(){this.containers=[]}return n.prototype.putWaveformToResults=function(n,i,r,u){this.containers[i]||(this.containers[i]=new t(i));this.containers[i].putWaveformToResults(n,r,u)},n.prototype.putPlaceholderToResults=function(n,i,r,u){this.containers[i]||(this.containers[i]=new t(i));this.containers[i].putPlaceholderToResults(n,r,u)},n.prototype.getResponseInfo=function(n){for(var t=new r(-1,-1,-1),i=0;i<this.containers.length;i++)if(t=this.containers[i].getResponseInfo(n,t),t.rowIndex!=-1)return t.contIndex=i,t;return null},n.prototype.getContainerAmount=function(){return this.containers.length},n}();n.DesignDataResponse=u;t=function(){function n(n){this.rows=[];this.contIndex=0;this.contIndex=n}return n.prototype.getResults=function(){return this.rows},n.prototype.getAmount=function(){return this.rows.length},n.prototype.getRow=function(n){return this.rows[n]},n.prototype.getResponseInfo=function(n,t){for(var r,i=0;i<this.rows.length;i++)if(r=this.rows[i].getWaveformIndex(n),r>=0)return t.waveformIndex=r,t.rowIndex=i,t;return t},n.prototype.putWaveformToResults=function(n,t,r){this.rows[t]||(this.rows[t]=new i(t));this.rows[t].putWaveformToResults(n,r)},n.prototype.getWaveformIndex=function(n,t){return this.rows[t]?this.rows[t].getWaveformIndex(n):-1},n.prototype.putPlaceholderToResults=function(n,t,r){this.rows[t]||(this.rows[t]=new i(t));this.rows[t].putPlaceholderToResults(n,r)},n.prototype.getRowWaveforms=function(n){return this.rows[n]?this.rows[n].getWaveforms():[]},n.prototype.getRowAmount=function(){return this.rows.length},n}();n.ContainerDataResponse=t;i=function(){function t(n){this.waveforms=[];this.rowMap=[];this.rowIndex=n}return t.prototype.putWaveformToResults=function(t,i){i<0||(t||(this.waveforms[i]=n.Waveform.getEmptyWaveform()),this.waveforms[i]=t)},t.prototype.getWaveformIndex=function(n){for(var t=0;t<this.rowMap.length;t++)if(this.rowMap[t]==n)return t;return-1},t.prototype.putPlaceholderToResults=function(n,t){this.rowMap[t]=n},t.prototype.getWaveforms=function(){return this.waveforms},t}();n.RowDataResponse=i;f=function(){function n(){}return n}();n.ResultIdWaveformHandle=f}(WaveViewer||(WaveViewer={})),function(n){var u=function(){function r(t,i,r){var u,f;this.yValues=[];this.isResolvedOnRange=!1;this.isWholeRange=!1;u=this.convertWaveformDataResponse(t,r);this.data=u.flotPoints;t.Data instanceof ServerStructures.DataSeriesString&&(f=t.Data,this.yValues=f.YValueData);this.isResolvedOnRange=t.IsResolved;this.isWholeRange=i;t.XMin!=null&&t.XMax!=null&&(this.currentXRange=new n.XWaveRange(t.XMin,t.XMax))}return r.prototype.match=function(t,i,r,u){return r?this.isWholeRange:t!=null&&this.currentXRange.xmin==t&&i!=null&&this.currentXRange.xmax==i?!0:(this.isResolvedOnRange||u!=n.PAN_DIRECTION.NONE)&&t!=null&&n.WaveUtils.lessOrAlmostEqual(this.currentXRange.xmin,t)&&i!=null&&n.WaveUtils.greaterOrAlmostEqual(this.currentXRange.xmax,i)?!0:!1},r.prototype.combineData=function(t,i,r,u,f,e){var s=this.convertWaveformDataResponse(t,e),h=this.data,o;this.isWholeRange&&this.isResolvedOnRange||(u==n.PAN_DIRECTION.LEFT?(o=n.WaveUtils.joinWithoutDuplication(s.flotPoints,s.yValues,this.data,this.yValues,f),this.data=o.points,this.yValues=o.yValues,this.currentXRange.xmin=i,this.isResolvedOnRange=this.isResolvedOnRange&&t.IsResolved):u==n.PAN_DIRECTION.RIGHT&&(o=n.WaveUtils.joinWithoutDuplication(this.data,this.yValues,s.flotPoints,s.yValues,f),this.data=o.points,this.yValues=o.yValues,this.currentXRange.xmax=r,this.isResolvedOnRange=this.isResolvedOnRange&&t.IsResolved),this.isWholeRange=!1)},r.prototype.checkShift=function(t){var r,u;return t.min==null||t.max==null?t:this.leftIntersection(t.min,t.max)?(r=this.currentXRange.xmin-t.max,u=Math.ceil(t.numPoints*r/Math.abs(t.max-t.min)),new i(n.PAN_DIRECTION.LEFT,t.min,this.currentXRange.xmin,u)):this.rightIntersection(t.min,t.max)?(r=t.max-this.currentXRange.xmax,u=Math.ceil(t.numPoints*r/Math.abs(t.max-t.min)),new i(n.PAN_DIRECTION.RIGHT,this.currentXRange.xmax,t.max,u)):t},r.prototype.isInside=function(t){return n.WaveUtils.greaterOrAlmostEqual(t,this.currentXRange.xmin)&&n.WaveUtils.lessOrAlmostEqual(t,this.currentXRange.xmax)},r.prototype.leftIntersection=function(n,t){return n==null||t==null?!1:n<this.currentXRange.xmin&&this.isInside(t)?!0:!1},r.prototype.rightIntersection=function(n,t){return n==null||t==null?!1:t>this.currentXRange.xmax&&this.isInside(n)?!0:!1},r.prototype.getData=function(){return this.data},r.prototype.getYValues=function(){return this.yValues},r.prototype.getCurrentXRange=function(){return this.currentXRange},r.prototype.convertWaveformDataResponse=function(i,r){var h,o,s,f,e,u;if(!i.Data)return new t([],[],0,[]);if(h=i.Data.XData,!h)return new t([],[],0,[]);o=i.Data;switch(r){case n.WaveManager.NUMERIC_INTEGER_DATA:case n.WaveManager.NUMERIC_REAL_DATA:case n.WaveManager.ENUMERATED_DATA:return s=o,u=new t(s.XData,s.YData,s.XData.length,[]),u;case n.WaveManager.STRING_DATA:return f=o,u=new t(f.XData,f.YData,f.XData.length,f.YValueData),u;case n.WaveManager.NUMERIC_COMPLEX_DATA:return e=o,u=new t(e.XData,e.YData,e.XData.length,e.YValueData),u;default:return new t([],[],0,[])}},r}(),i,r,t;n.WaveformData=u;i=function(){function n(n,t,i,r){this.panDirection=n;this.min=t;this.max=i;this.numPoints=r}return n}();n.PanInfo=i;r=function(){function t(t,i,r){this.name="";this.xName="";this.yName="";this.xUnits=n.WaveManager.NO_UNITS;this.yUnits=n.WaveManager.NO_UNITS;this.xWaveformMin=0;this.xWaveformMax=1;this.yWaveformMin=0;this.yWaveformMax=1;this.waveformType=n.WaveManager.ANALOG_WF;this.dataType=n.WaveManager.NUMERIC_REAL_DATA;this.useLogXAxis=!1;this.isInit=!1;this.Color="black";this.isToplineSet=!1;this.isBaselineSet=!1;this.topLine=0;this.baseLine=0;this.wdbId=i;r&&(this.name=r.Name,this.wfHandle=r.Id,this.waveformType=r.Type,this.simulationId=t)}return t.prototype.setExpressionPreMetadata=function(n,t,i,r){this.name=n;this.wfHandle=t;this.waveformType=i;this.simulationId=r},t.prototype.setTopline=function(n){this.topLine=n;this.isToplineSet=!0},t.prototype.setBaseline=function(n){this.baseLine=n;this.isBaselineSet=!0},t.prototype.getTopline=function(){return this.topLine},t.prototype.getBaseline=function(){return this.baseLine},t.prototype.setWaveformMetadata=function(t){if(t!=null){this.xName=t.XName;this.yName=t.YName;this.xUnits=t.XUnits;this.yUnits=t.YUnits;this.xWaveformMin=t.xWaveformMin;this.xWaveformMax=t.xWaveformMax;this.yWaveformMin=t.yWaveformMin;this.yWaveformMax=t.yWaveformMax;this.dataType=t.DataType;this.isInit=!0;this.useLogXAxis=t.useLogXAxis;this.waveformType=t.Type;var i=n.WorkOptions.getWorkOptionsByType(this.waveformType);this.useLogXAxis&&this.xWaveformMin<=0&&(this.xWaveformMin=n.WaveRowBase.DEFAULT_MINIMAL_DYNAMIC_RANGE);this.xWaveformMin>this.xWaveformMax&&(this.xWaveformMax=this.xWaveformMin)}},t.prototype.isMetadataSet=function(){return this.isInit},t.prototype.getWholeXRange=function(){return new n.XWaveRange(this.xWaveformMin,this.xWaveformMax)},t.prototype.getYAxisName=function(t,i){var u=n.WorkOptions.getWorkOptionsByType(this.waveformType),r=u.getYAxisNameWithUnits(t);return r?r:(t||(t=this.getYName()),i||(i=this.getYUnits()),!t||t.length==0||t==n.WaveManager.NO_UNITS)?n.WaveManager.NO_UNITS:!i||i.length==0?t:t+" ("+i+")"},t.prototype.getWholeYRange=function(){var i=this.yWaveformMin,r=this.yWaveformMax,t=n.WaveUtils.getSinglePointMinMax(i,r);return t.isAlmostConstant&&(i=t.min,r=t.max),new n.YWaveRange(i,r,this.getYAxisName(),t.isAlmostConstant)},t.prototype.canDivide=function(){return this.yWaveformMin==0&&this.yWaveformMax==0?!1:!0},t.prototype.getSignalName=function(){return this.name},t.prototype.getWaveformHandle=function(){return this.wfHandle},t.prototype.getSimulationId=function(){return this.simulationId},t.prototype.getWaveformType=function(){return this.waveformType},t.prototype.getDataType=function(){return this.dataType},t.prototype.getXUnits=function(){return this.xUnits},t.prototype.getYUnits=function(){return this.yUnits},t.prototype.getXName=function(){return this.xName},t.prototype.getYName=function(){return this.yName},t.prototype.isLogXAxis=function(){return this.useLogXAxis},t}();n.WaveformInfo=r;t=function(){function n(n,t,i,r){this.flotPoints=[{}];for(var u=0;u<i;++u)this.flotPoints[u]=new Array(2),this.flotPoints[u][0]=n[u],this.flotPoints[u][1]=t[u];this.yValues=r}return n}();n.FlotPoints=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(i){var u=n.ViewerPage.getBrowserWindowHeight(),r;$("#"+t.VIEWER_PAGE_ID).height(u);this.viewerWindow=new n.ViewerWindow(t.VIEWER_PAGE_ID,!1);r=this;i?$.when(n.ViewerRequests.getViewerStateFromServer(i)).done(function(t){var i=new n.ViewerState(t);r.viewerWindow.restoreViewerState(i)}):this.viewerWindow.showWindow();$(window).resize(function(){var i=n.ViewerPage.getBrowserWindowHeight();$("#"+t.VIEWER_PAGE_ID).height(i);r.viewerWindow.resize()});this.addEventListeners();this.viewerWindow.createIFrameViewer()}return t.getBrowserWindowHeight=function(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0},t.prototype.loadResults=function(n){this.viewerWindow.loadSimulationResults(n)},t.prototype.addEventListeners=function(){var t=this;window.addEventListener("message",function(i){var r=i.data;if(r&&r.action)switch(r.action){case n.WaveManager.ADD_WDB:r.wdbId&&t.loadResults(r.wdbId)}},!1)},t.VIEWER_PAGE_ID="ViewerPage",t}();n.ViewerPage=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(t){this.treeData=[];t&&(t instanceof n.ViewerWindow?this.saveViewerState(t):this.setViewerState(t))}return t.prototype.saveViewerState=function(n){this.treeData=[];n.getTreeData()&&this.makeDeepCopy(n.getTreeData());this.waveContainerState=n.getWaveContainer().getState()},t.prototype.setViewerState=function(t){t&&t.treeData?(this.treeData=[],t.treeData&&this.makeDeepCopy(t.treeData)):this.treeData=[];var i=new n.WaveContainerState;i.setWaveContainerState(t.waveContainerState);this.waveContainerState=i},t.prototype.makeDeepCopy=function(t){for(var i,r,f,u=0;u<t.length;u++){for(i=t[u],r=new n.WdbInfo(i.simulationId,i.wdbName,i.wdbId),r.expandedFolders=[],r.isExpanded=i.isExpanded,f=0;f<i.expandedFolders.length;f++)r.expandedFolders.push(i.expandedFolders[f]);this.treeData.push(r)}},t.prototype.getWaveContainerState=function(){return this.waveContainerState},t.prototype.getTreeData=function(){return this.treeData},t}();n.ViewerState=t}(WaveViewer||(WaveViewer={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var a,i,t,r,u,f,e,o,s,h,l,c;(function(n){n[n.NONE=0]="NONE";n[n.LEFT=1]="LEFT";n[n.RIGHT=2]="RIGHT";n[n.UP=3]="UP";n[n.DOWN=4]="DOWN"})(n.PAN_DIRECTION||(n.PAN_DIRECTION={}));a=n.PAN_DIRECTION,function(n){n[n.HIDE=0]="HIDE";n[n.SHOW=1]="SHOW"}(n.PAN_STATE||(n.PAN_STATE={}));i=n.PAN_STATE;t=function(){function n(n){this.fromWavebox=!1;this.buttonContainerJQ=n.getWaveContainerWrapper();this.waveContainer=n;this.fromWavebox=n.isInWaveBox()}return n.prototype.getNextIndex=function(){return n.GLOBAL_INDEX++},n.prototype.getButtonContainer=function(){return this.buttonContainerJQ},n.prototype.getButtonContainerOffset=function(){return this.buttonContainerJQ.position().left},n.prototype.getWaveContainer=function(){return this.waveContainer},n.prototype.setup=function(n){var t,i;this.leftPanButton||(t=this.getWaveContainer().getDomainAxis(),i=this.getWaveContainer().getXAxisName(),this.leftPanButton=new e(this,"chevron-left","Move left",i,t));this.leftPanButton.updateVisibility(n);this.rightPanButton||(t=this.getWaveContainer().getDomainAxis(),i=this.getWaveContainer().getXAxisName(),this.rightPanButton=new o(this,"chevron-right","Move right",i,t));this.rightPanButton.updateVisibility(n);this.fromWavebox&&this.setupYPanButtons(n)},n.prototype.setupYPanButtons=function(){},n.prototype.getDigitalShift=function(){return this.waveContainer.showAnyYAxis()?0:15},n.GLOBAL_INDEX=1,n.PAN_NUM=4,n}();n.PanButtons=t;r=function(){function t(n,t,i,r,u){this.panButtonSize=15;this.iconName=t;this.iconTooltip=i;this.axisName=r;this.row=u;this.base=n;this.waveContainer=n.getWaveContainer();this.addButton()}return t.prototype.addButton=function(){var n=this;this.button=this.create();this.button.hide();this.button.click(function(){n.buttonOperation()})},t.prototype.create=function(){var i="_panButton_"+this.iconName+"_"+this.base.getNextIndex(),r='<span class="glyphicon glyphicon-'+this.iconName+'" aria-label="true" style="color:'+n.WaveManager.AXIS_LABEL_COLOR+'"> <\/span>',t=$("<div type=button id="+i+">"+r+" <\/div>");return t.appendTo(this.base.getButtonContainer()),t.css({position:"absolute",width:this.panButtonSize+"px",height:this.panButtonSize+"px",color:n.WaveManager.AXIS_LABEL_COLOR}),t},t.prototype.updateVisibility=function(n){if(this.button){if(n==i.HIDE){this.button.hide();return}if(this.needToHide()){this.button.hide();return}this.setPosition();this.button.show();this.needToStop()?this.disable():this.enable()}},t.prototype.disable=function(){this.button.addClass("disabled")},t.prototype.enable=function(){this.button.removeClass("disabled")},t}();n.BasePanButton=r;u=function(n){function t(t,i,r,u,f){n.call(this,t,i,r,u,f);this.waveRow=f}return __extends(t,n),t.prototype.hideYAxis=function(){return!1},t.prototype.isConstantRow=function(){return!1},t.prototype.isViewAll=function(){return this.waveContainer.isViewAllForX()},t.prototype.needToHide=function(){return!this.waveContainer||this.waveContainer.isEmpty()?!0:this.waveContainer.isDecorationShown()?this.isViewAll()?!0:!1:!0},t}(r);n.XPanButton=u;f=function(t){function i(n,i,r,u,f){t.call(this,n,i,r,u,f);this.waveRow=f}return __extends(i,t),i.prototype.hideYAxis=function(){return this.waveRow&&!this.waveRow.canZoomYAxis(this.axisName)},i.prototype.isConstantRow=function(){return this.waveRow&&this.waveRow.isConstantRow()},i.prototype.isViewAll=function(){var r=this.waveRow.isViewAllForY(this.axisName);if(r)return!0;var i=this.waveRow.getYOriginalRange(this.axisName),t=this.waveRow.getCurrentVisibleRangeForAxis(this.axisName),u=i.ymin-this.getYPanDelta(t),f=i.ymax+this.getYPanDelta(t),e=n.WaveUtils.lessOrAlmostEqual(t.ymin,u),o=n.WaveUtils.lessOrAlmostEqual(f,t.ymax);return e&&o},i.prototype.needToHide=function(){return!this.waveContainer||this.waveContainer.isEmpty()?!0:this.waveContainer.isDecorationShown()?this.hideYAxis()?!0:this.isConstantRow()?!0:this.isViewAll()?!0:!1:!0},i.prototype.getYPanDelta=function(n){return Math.abs(n.ymax-n.ymin)*.05},i}(r);n.YPanButton=f;e=function(r){function u(){r.apply(this,arguments)}return __extends(u,r),u.prototype.buttonOperation=function(){var t=this,r=this.waveContainer.getXAxisState(),o=this.waveContainer.getOriginalXState(),s=r.range.xmax,h=r.range.xmin,c=o.range.xmin;if(this.needToStop()){this.disable();return}var u=this.getRangeForLeftPan(),f=u.min,e=u.max;this.waveContainer.showSpinner();this.waveContainer.setXVisibleState(f,e,!1);this.waveContainer.addToZoomStack(new n.CommonZoomRange(new n.XWaveRange(f,e),null,null));$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState("x",this.waveRow,n.PAN_DIRECTION.LEFT))).done(function(){t.waveContainer.hideSpinner();t.base.setup(i.SHOW)})},u.prototype.needToStop=function(){var t=this.waveContainer.getXAxisState(),i=this.waveContainer.getOriginalXState();return n.WaveUtils.lessOrAlmostEqual(t.range.xmin,i.range.xmin)},u.prototype.setPosition=function(){var n=this.base.getButtonContainerOffset(),t=this.waveContainer.getPlotAreaLeftOffset();this.button.css({left:n+t+this.base.getDigitalShift()-2,bottom:5})},u.prototype.getRangeForLeftPan=function(){var n=this.waveContainer.isLogXAxis();return n?this.getLogRangeToLeft():this.getLinearRangeToLeft()},u.prototype.getLogRangeToLeft=function(){var f=this.waveContainer.getDomainAxis().getPlotArea(),r=this.waveContainer.getOriginalXState().range.xmin,u=f.width()/t.PAN_NUM,n=f.getAxes().xaxis,o=n.min,s=n.max,i=n.c2p(n.p2c(n.min)-u),e;return i<r&&(u=n.p2c(r)-n.p2c(i),i=r),e=n.c2p(n.p2c(n.max)-u),{min:i,max:e}},u.prototype.getLinearRangeToLeft=function(){var f=this.waveContainer.getXAxisState(),s=this.waveContainer.getOriginalXState(),e=f.range.xmax,n=f.range.xmin,i=s.range.xmin,h=Math.abs(e-n),r=h/t.PAN_NUM,u=n-r,o;return u<i&&(u=i,r=n-i),o=e-r,{min:u,max:o}},u}(u);n.LeftPanButton=e;o=function(r){function u(){r.apply(this,arguments)}return __extends(u,r),u.prototype.buttonOperation=function(){var o=this,t=this.waveContainer.getXAxisState(),s=this.waveContainer.getOriginalXState(),h=t.range.xmax,c=t.range.xmin,l=s.range.xmax,e;if(this.needToStop()){this.disable();return}var r=this.getRangeForRightPan(),u=r.min,f=r.max;this.waveContainer.showSpinner();this.waveContainer.setXVisibleState(u,f,!1);this.waveContainer.addToZoomStack(new n.CommonZoomRange(new n.XWaveRange(u,f),null,null));e=this;$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState("x",null,n.PAN_DIRECTION.RIGHT))).done(function(){e.waveContainer.hideSpinner();o.base.setup(i.SHOW)})},u.prototype.needToStop=function(){var t=this.waveContainer.getXAxisState(),i=this.waveContainer.getOriginalXState();return n.WaveUtils.greaterOrAlmostEqual(t.range.xmax,i.range.xmax)},u.prototype.setPosition=function(){var n=this.waveContainer.getPlotAreaWidth(),t=this.base.getButtonContainerOffset();this.button.css({left:t+n-this.panButtonSize+this.base.getDigitalShift()-2,bottom:5})},u.prototype.getRangeForRightPan=function(){var n=this.waveContainer.isLogXAxis();return n?this.getLogRangeToRight():this.getLinearRangeToRight()},u.prototype.getLogRangeToRight=function(){var f=this.waveContainer.getDomainAxis().getPlotArea(),r=this.waveContainer.getOriginalXState().range.xmax,u=f.width()/t.PAN_NUM,n=f.getAxes().xaxis,o=n.min,s=n.max,i=n.c2p(n.p2c(n.max)+u),e;return i>r&&(u=n.p2c(r)-n.p2c(i),i=r),e=n.c2p(n.p2c(n.min)+u),{min:e,max:i}},u.prototype.getLinearRangeToRight=function(){var f=this.waveContainer.getXAxisState(),s=this.waveContainer.getOriginalXState(),n=f.range.xmax,e=f.range.xmin,i=s.range.xmax,h=Math.abs(n-e),r=h/t.PAN_NUM,u=n+r,o;return u>i&&(u=i,r=i-n),o=e+r,{min:o,max:u}},u}(u);n.RightPanButton=o;s=function(r){function u(){r.apply(this,arguments)}return __extends(u,r),u.prototype.buttonOperation=function(){var a=this,v=this.waveRow.getYOriginalRange(this.axisName),r=this.waveRow.getCurrentVisibleRangeForAxis(this.axisName),u=r.ymax,h=r.ymin,f=v.ymax+this.getYPanDelta(r),c,s,l;if(this.needToStop()){this.disable();return}var y=Math.abs(u-h),e=y/t.PAN_NUM,o=u+e;o>f&&(o=f,e=f-u);c=h+e;this.waveContainer.showSpinner();s=new n.YWaveRange(c,o,this.axisName,!1);this.waveRow.setYVisibleRange(s,!1);this.waveContainer.addToZoomStack(new n.CommonZoomRange(null,null,s));l=this;$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState("y",this.waveRow,n.PAN_DIRECTION.UP))).done(function(){l.waveContainer.hideSpinner();a.base.setup(i.SHOW)})},u.prototype.needToStop=function(){var t=this.waveRow.getCurrentVisibleRangeForAxis(this.axisName),i=this.waveRow.getYOriginalRange(this.axisName),r=i.ymax+this.getYPanDelta(t);return n.WaveUtils.greaterOrAlmostEqual(t.ymax,r)},u.prototype.setPosition=function(){var n=this.waveContainer.getFirstRow().getPlotArea().getPlotOffset().top,t=this.base.getButtonContainerOffset();this.button.css({left:5+t,top:n})},u}(f);n.UpPanButton=s;h=function(r){function u(){r.apply(this,arguments)}return __extends(u,r),u.prototype.buttonOperation=function(){var a=this,v=this.waveRow.getYOriginalRange(this.axisName),r=this.waveRow.getCurrentVisibleRangeForAxis(this.axisName),h=r.ymax,u=r.ymin,f=v.ymin-this.getYPanDelta(r),c,s,l;if(this.needToStop()){this.disable();return}var y=Math.abs(h-u),e=y/t.PAN_NUM,o=u-e;o<f&&(o=f,e=u-f);c=h-e;this.waveContainer.showSpinner();s=new n.YWaveRange(o,c,this.axisName,!1);this.waveRow.setYVisibleRange(s,!1);this.waveContainer.addToZoomStack(new n.CommonZoomRange(null,null,s));l=this;$.when(this.waveContainer.plotRows(n.RESIZE_MODE.NONE,new n.ZoomState("y",this.waveRow,n.PAN_DIRECTION.DOWN))).done(function(){l.waveContainer.hideSpinner();a.base.setup(i.SHOW)})},u.prototype.needToStop=function(){var t=this.waveRow,i=t.getCurrentVisibleRangeForAxis(this.axisName),r=t.getYOriginalRange(this.axisName),u=r.ymin-this.getYPanDelta(i);return n.WaveUtils.lessOrAlmostEqual(i.ymin,u)},u.prototype.setPosition=function(){var n=this.waveContainer.getFirstRow().getPlotArea().getSurface().height,t=this.base.getButtonContainerOffset();this.button.css({left:5+t,top:n-this.panButtonSize})},u}(f);n.DownPanButton=h;l=function(){function n(n){this.axisButtons={};this.axisButtons={};this.waveRow=n;this.setup(i.HIDE)}return n.prototype.setup=function(n){var i=this.getYAxesNames(),r,t,u;if(i&&i.length==1)for(r=0;r<i.length;r++)t=i[r],this.axisButtons[t]||(u=new c(this.waveRow,t),this.axisButtons[t]=u),this.axisButtons[t].updateVisibility(n)},n.prototype.remove=function(){for(var n in this.axisButtons)this.axisButtons[n].remove(),this.axisButtons[n]=null},n.prototype.getYAxesNames=function(){var u=[],f=[],i=this.waveRow.getWaveforms(),n,r,t;if(i)for(n=0;n<i.length;n++)r=i[n],r.isEmptyWaveform()||(t=r.getYAxisNameWithUnits(),u[t]||(u[t]=!0,f.push(t)));return f},n}();n.RowPanButtons=l;c=function(){function n(n,t){var i=n.waveContainer.panButtons;this.upPanButton=new s(i,"chevron-up","Move up",t,n);this.downPanButton=new h(i,"chevron-down","Move left",t,n)}return n.prototype.remove=function(){this.upPanButton.button.remove();this.upPanButton=null;this.downPanButton.button.remove();this.downPanButton=null},n.prototype.updateVisibility=function(n){this.upPanButton.updateVisibility(n);this.downPanButton.updateVisibility(n)},n}();n.AxisPanButtons=c}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function t(n,t,i){(this.colorPickerWrapper=null,this.contents=null,this.inWavebox=!0,this.originalColors=[],this.curWidth=20,n)&&(this.waveforms=n,this.pageCoordinates=t,this.inWavebox=i,this.createContent(),this.createAndOpen())}return t.prototype.createContent=function(){var i,u,r;for(this.originalColors=[],$('<div id="'+t.COLOR_PICKER_ID+'"><\/div>').appendTo(document.body),this.contents="<div>",this.curWidth=20,i=0;i<this.waveforms.length;i++){u=this.waveforms[i];r=u.getColor();this.originalColors[i]=r;var f=t.PALETTE_PICKER_ID+i,e=u.getFullWaveformName()+":&nbsp;&nbsp;&nbsp;",o=n.WaveUtils.calcLabelWidth(e,t.FONT_SIZE);o>this.curWidth&&(this.curWidth=o);this.contents+='<div style="font-size: '+t.FONT_SIZE+'">';this.contents+='<label for="'+f+'" style="color: '+r+'">'+e+"<\/label>";this.contents+='<input type="color" id= "'+f+'" value="'+r+'"/>';this.contents+="<\/div>"}this.contents+="<\/div>"},t.prototype.createAndOpen=function(){var f=this,u;this.colorPickerWrapper&&this.colorPickerWrapper.length>0&&this.closeColorPicker();var r="Choose Colors",e=n.WaveUtils.calcLabelWidth(r,t.FONT_SIZE)+12,o=this,i={resizable:!1,minWidth:e,minHeight:24,width:this.curWidth+70,title:r};i=$.extend({},Project.KendoHelper.CommonKendoWindowOptions,i);this.colorPickerWindow=$(t.COLOR_PICKER).kendoWindow(i).data("kendoWindow");this.colorPickerWrapper=$(t.COLOR_PICKER).parent();this.colorPickerWrapper.addClass(t.COLOR_PICKER_WINDOW_CLASS);this.colorPickerWindow.content(this.contents);this.colorPickerWindow.wrapper.find(".k-block>.k-header, .k-window-titlebar, .k-window-title").on("dblclick",function(n){n.stopPropagation()});this.setChangeEventHandler();this.setStyle();this.addClosePickerListener();u=this.colorPickerWindow.wrapper.find(".k-i-close");u.click(function(){f.closeColorPicker()});this.colorPickerWindow.open()},t.prototype.addClosePickerListener=function(){var n=this;$(document).bind("mouseup.colorPicker",function(i){var r=$("."+t.COLOR_PICKER_WINDOW_CLASS);r&&(r&&n.isInside(r,i)||r&&n.closeColorPicker())})},t.prototype.isInside=function(n,t){if(!n)return!0;if(!n.is(t.target)&&n.has(t.target).length===0){if($(t.target).hasClass("k-overlay"))return!0;var i=$(t.target).closest("div");return i&&i.hasClass("k-colorpalette")?!0:!1}return!0},t.prototype.setStyle=function(){Project.KendoHelper.maximizeKendoWindowSpace(this.colorPickerWindow.wrapper,!1);this.colorPickerWrapper.find(".k-widget.k-colorpicker").css("float","right");this.colorPickerWrapper.find(".k-colorpicker .k-selected-color").css("line-height","none").css("height",t.FONT_SIZE).css("border-radius","0px");this.colorPickerWrapper.find(".k-picker-wrap").css("line-height","none").css("height",t.FONT_SIZE).css("border-radius","0px");this.colorPickerWrapper.find(".k-select").css("line-height","none").css("min-height",t.FONT_SIZE);this.colorPickerWrapper.find(".k-icon").css("vertical-align","top");this.inWavebox||this.colorPickerWrapper.css("z-index","56000");this.setInitialWindowPosition(new BaseWire.Point(this.pageCoordinates.pageX,this.pageCoordinates.pageY),this.colorPickerWrapper)},t.prototype.setInitialWindowPosition=function(n,t){var u=this.inWavebox?$(SCHEMATIC_TOOLBAR).outerHeight():0,f=this.inWavebox?sidebar_manager.getVisibleWidth(Sidebar.Orientation.RIGHT):0,r=$(window).width()-f,e=this.inWavebox?surface.getVisibleHeight():$(window).height(),o=t.outerWidth(),i=t.outerHeight();n.x+o<r&&n.y+i<e?t.css({left:n.x,top:n.y}):n.x+o<r&&n.y+i>=e?n.y-i>u?t.css({left:n.x,top:n.y-i}):t.css({left:n.x,top:u}):n.x+o>=r&&n.y+i<e?t.css({right:r+f-n.x,top:n.y}):n.y-i>u?t.css({right:r+f-n.x,top:n.y-i}):t.css({right:r+f-n.x,top:u})},t.prototype.closeColorPicker=function(){$(document).unbind("mouseup.colorPicker");this.colorPickerWindow.destroy()},t.prototype.setChangeEventHandler=function(){function e(n){var i=n.data.selectedWfIndex,t=r.waveforms[i];t&&t.setWaveformColor(this.value);$(this).parent().closest("div").find("label:first").css("color",this.value)}function o(){var i=$(this).data("selectedWfIndex"),t=r.waveforms[i];t&&n.getManager().getCrossHighlightManager().crossHighlightByWaveform(t,!0)}function s(){var i=$(this).data("selectedWfIndex"),t=r.waveforms[i];t&&n.getManager().getCrossHighlightManager().crossHighlightByWaveform(t,!1)}for(var u,r=this,i=0;i<this.waveforms.length;i++){var l=this.waveforms[i],f=t.PALETTE_PICKER_ID+i,h="#"+f,c=$(h).kendoColorPicker({palette:n.WhiteTheme.COLOR_TABLE_WHITE,tileSize:20,columns:3});c.bind("change",{selectedWfIndex:i},e);u=$('label[for="'+f+'"]');u.data("selectedWfIndex",i);u.hover(o,s)}},t.COLOR_PICKER_ID="row_color_picker",t.COLOR_PICKER="#row_color_picker",t.COLOR_PICKER_WINDOW_CLASS="wf_color_picker_window",t.PALETTE_PICKER_ID="palette-picker",t.FONT_SIZE="12px",t}();n.WaveformColorPicker=t}(WaveViewer||(WaveViewer={})),function(n){var t=function(){function n(){}return n}();n.ToolOperation=t}(Operations||(Operations={})),function(n){var i=function(){function t(){}return t.getMessage=function(i,r,u){u===void 0&&(u=null);var f=n.ToolUtils.replace(i,t.SUBS1,r);return u?n.ToolUtils.replace(f,t.SUBS2,u):f},t.SUBS1="%svw_subs1%",t.SUBS2="%svw_subs2%",t.CHOOSE_OPERATION="Choose an operation",t.EMPTY_INPUT="Error: Set argument. It should not be empty",t.EMPTY_FIRST_INPUT="Error: Set first argument. It should not be empty",t.EMPTY_SECOND_INPUT="Error: Set second argument. It should not be empty",t.CHOOSE_WAVEFORM="Error: Argument is wrong. Choose a waveform.",t.CHOOSE_FIRST_WAVEFORM="Error: First argument is wrong. Choose a waveform.",t.CHOOSE_SECOND_WAVEFORM="Error: Second argument is wrong. Choose a waveform.",t.CHOOSE_AT_LEAST_ONE_WAVEFORM="Error: choose at least one argument as a waveform",t.APPLY_OPERATION="Press to apply the operation",t.UNSUPPORTED_OPERATION="Unsupported waveform type for selected operation",t.INCONSISTENT_WAVEFORM_TYPES="Invalid operation - waveform Y types do not match",t.DIVIDE_ZERO_DENOMINATOR_WAVEFORM="Invalid operation - denominator waveform contains only zero values",t.DIVIDE_ZERO_DENOMINATOR="Invalid operation - denominator value is zero",t.IS_EMPTY=" is empty",t.NOT_NUMBER=" not a number",t.INVALID_OPERATION="Invalid operation - "+t.SUBS1+" value ",t.INVALID_LESS="Invalid operation - "+t.SUBS1+" value is less than "+t.SUBS2+" value",t.INVALID_GREATER="Invalid operation - "+t.SUBS1+" value is greater than "+t.SUBS2+" value",t.INVALID_POSITIVE="Invalid operation - "+t.SUBS1+" value must be positive",t.INVALID_BY_Y_MINIMUM="Invalid operation - "+t.SUBS1+" value is less than Y minimum value of the waveform",t.INVALID_BY_Y_MAXIMUM="Invalid operation - "+t.SUBS1+" value is greater than Y maximum value of the waveform",t.INVALID_BY_X_MINIMUM="Invalid operation - "+t.SUBS1+" value is less than X minimum value of the waveform",t.INVALID_BY_X_MAXIMUM="Invalid operation - "+t.SUBS1+" value is greater than X maximum value of the waveform",t.CONFIRM_MESSAGE="Closing the "+t.SUBS1+" dialog will reset all options to the default values",t.EYE_BUTTON_NOT_SUPPORTED="Unsupported waveform type for "+t.SUBS1,t.EYE_BUTTON_VISIBILITY_DISABLED=t.SUBS1+"level is outside of currently visible Y range",t.EYE_BUTTON_NO_WAVEFORM="Waveform is not set",t.EYE_BUTTON_INCORRECT_VALUE="Incorect value for "+t.SUBS1,t.EYE_BUTTON_EMPTY_VALUE="Empty value for "+t.SUBS1,t}(),t;n.ToolMessages=i;t=function(){function n(){}return n.EDGE_TRIGGER="The polarity of the starting edge for each cycle",n.EDGE_TRIGGER_ANY="Rising or Falling Starting Edge",n.EDGE_TRIGGER_RISE="Rising Starting Edge",n.EDGE_TRIGGER_FALL="Falling Starting Edge",n.SLEWRATE_EDGE_TRIGGER_ANY="Rising or Falling Edges",n.SLEWRATE_EDGE_TRIGGER_RISE="Rising Edges",n.SLEWRATE_EDGE_TRIGGER_FALL="Falling Edges",n.EDGE_TRIGGER_SLEWRATE="The type of edge to find",n.PULSE_POLARITY="The type of pulse to find",n.PULSE_POLARITY_ANY="Positive or Negative Pulses",n.PULSE_POLARITY_POS="Positive Pulses",n.PULSE_POLARITY_NEG="Negative Pulses",n.TOPLINE="The upper reference level used to find edges (the 100% level)",n.BASELINE="The lower reference level used to find edges (the 0% level)",n.RESULTS="Create markers or a new waveform",n.APPLY_TO="The portion of the waveform to use for the measurement",n.LEVEL_CROSS_Y_LEVEL="The level which the waveform must cross through",n.LEVEL_CROSS_SLOPE_AT_CROSSING="The slope of the waveform as it crosses the y level",n.SLOPE_ANY="Any Slope",n.SLOPE_POS="Positive Slope",n.SLOPE_NEG="Negative Slope",n.SLOPE_XVALUE="The x value where the slope is measured",n.SLOPE_TYPE="Show the slope value per decade or per octave",n.DTOA_HIGH_LEVEL="The high level of the generated waveform",n.DTOA_LOW_LEVEL="The low level of the generated waveform",n.DTOA_RISETIME="The risetime used between the low level and the high level of the generated waveform",n.DTOA_FALLTIME="The falltime used between the low level and the high level of the generated waveform",n.ATOD_HIGH_LEVEL="The level the waveform must rise to so a digital ‘1’ is generated",n.ATOD_LOW_LEVEL="The level the waveform must fall to so a digital ‘0’ is generated",n.OVERSHOOT_PERCENT="Show Overshoot as a percentage of waveform amplitude",n.UNDERSHOOT_PERCENT="Show Undershoot as a percentage of waveform amplitude",n.XLIMIT_START="The initial x value for the new waveform",n.XLIMIT_STOP="The final x value for the new waveform",n.SETTLETIME_TOLERANCE="The width of the tolerance band as a percentage of the waveform amplitude (topline – baseline)",n.WINAVE_POSITION="X window position",n}();n.ToolTooltips=t}(Operations||(Operations={})),function(n){var o=function(){function t(i,r,u){this.operationFieldWidth=n.ToolWindow.BUTTON_WIDTH;this.operationFieldWidth2=n.ToolWindow.BUTTON_WIDTH;this.comboWidth=40;this.greenButtonSize=16;this.betweenButtons=5;this.operationType=n.OPERATION_TYPE.UNARY_OPERATION;this.firstReadOnly=!1;this.secondReadOnly=!1;this.isEditable=!1;this.isValidArgs=!0;this.parentPanel=n.ToolUtils.createElement("div","",i,null);this.parentPanel.css({"margin-top":"10px"});this.waveContainer=r;this.toolPanel=u;this.greenButtonId=t.TOOL_CONTROL_COMBO_GREEN_BUTTON_ID+this.toolPanel.count;this.operationId=t.TOOL_CONTROL_OPERATION_ID+this.toolPanel.count;this.operationId2=t.TOOL_CONTROL_OPERATION_ID2+this.toolPanel.count;this.operationType=u.category.defaultOpType;this.createControls();this.setStyle();this.validate()}return t.prototype.setComboError=function(n){this.inputError=n;this.validate()},t.prototype.isUnaryOperation=function(){return this.operationType==n.OPERATION_TYPE.UNARY_OPERATION},t.prototype.updateComboLayout=function(){this.isUnaryOperation()?(this.operationFieldLabel.show(),this.operationFieldImg.show(),this.secondCombo.hide(),this.operationFieldLabel2.hide(),this.operationFieldImg2.hide()):(this.operationFieldLabel.hide(),this.operationFieldImg.hide(),this.secondCombo.show(),this.operationFieldLabel2.show(),this.operationFieldImg2.show())},t.prototype.createControls=function(){var n,r;this.operationFieldLabel=this.createOperationField(!0);n=t.TOOL_CONTROL_COMBO1_ID+this.toolPanel.count;this.firstCombo=new i(n,!0,this);this.operationFieldLabel2=this.createOperationField(!1);r=t.TOOL_CONTROL_COMBO2_ID+this.toolPanel.count;this.secondCombo=new i(r,!1,this);this.greenButton=this.createGreenButton();this.updateComboLayout()},t.prototype.setInitialWaveform=function(n){this.firstCombo.setWaveform(n);this.secondCombo.setWaveform(n)},t.prototype.getState=function(){var n=new u;return n.firstComboState=this.firstCombo.getState(),this.toolPanel.toolOperation&&this.toolPanel.toolOperation.isBinary()&&(n.secondComboState=this.secondCombo.getState()),n},t.prototype.setState=function(n){this.firstCombo.setState(n.firstComboState);this.toolPanel.toolOperation&&this.toolPanel.toolOperation.isBinary()&&this.secondCombo.setState(n.secondComboState)},t.prototype.setAsActive=function(n){this.activeCombo&&this.activeCombo!=n&&this.activeCombo.setReadOnlyMode();this.activeCombo=n},t.prototype.setCombosReadOnlyMode=function(){this.firstCombo&&this.firstCombo.setReadOnlyMode();this.secondCombo&&this.secondCombo.setReadOnlyMode()},t.prototype.setCombosEditableMode=function(){this.isEditable&&(this.firstCombo&&this.firstCombo.setEditableMode(),this.secondCombo&&this.secondCombo.setEditableMode())},t.prototype.createOperationField=function(i){var f=i?this.operationId:this.operationId2,r=n.ToolUtils.createElement("label",f,this.parentPanel,t.TOOL_CONTROL_LABEL_CLASS),e,u;return r.text(t.TOOL_CONTROL_OPERATION_INIT_NAME),r.width(this.toolPanel.getOpLabelWidth(this.operationType)),r.css({"text-align":"center"}),e="/Content/images/checkbox.png",u=n.ToolUtils.createElement("img",f+"_image",this.parentPanel,null,null,e),i?this.operationFieldImg=u:this.operationFieldImg2=u,r},t.prototype.setStyle=function(){this.parentPanel.find("."+t.TOOL_CONTROL_LABEL_CLASS).css("font-size",n.ToolWindow.FONT_SIZE)},t.prototype.getComboWidth=function(n){var t=$("#"+this.toolPanel.panelId).width(),i;return n?t-this.operationFieldWidth-this.greenButtonSize-4*this.betweenButtons+4:(i=t-this.operationFieldWidth2-this.greenButtonSize-4*this.betweenButtons,i/2)},t.prototype.blinkGreenButton=function(){var f=2,n=this.greenButton,i=200,e=1,r=!0,o=n.attr("src")==t.TOOL_CONTROL_OPERATION_APPLY_IMAGE,u;o&&(u=setInterval(function(){r?(r=!1,n.fadeTo(i,0)):(r=!0,n.fadeTo(i,1),e++==f&&clearInterval(u))},i))},t.prototype.createGreenButton=function(){var r=this,i=n.ToolUtils.createElement("img",this.greenButtonId,this.parentPanel,null,null,t.TOOL_CONTROL_OPERATION_ERROR_IMAGE);i.css({"margin-left":"5px"});i.on("click",function(){r.validate()&&(r.toolPanel.doApply(),r.toolPanel.updateInputControlLists())});return i.width(this.greenButtonSize),i},t.prototype.applyNumberOperation=function(t){var i=t.getOperation(),r=i.getValue();this.operationType==n.OPERATION_TYPE.BINARY_OPERATION&&this.activeCombo&&this.activeCombo.applyNumberOperation(i)},t.prototype.setOperation=function(i,r){var u,f;r==n.OPERATION_TYPE.NUMBER?this.applyNumberOperation(i):(this.operationType=r,this.updateComboLayout(),this.isEditable=i.isEditable,this.isEditable||this.setCombosReadOnlyMode(),u=this.isUnaryOperation(),this.updateOperationField(i,u),f=i.getOperation(),this.toolPanel.setOperation(f));this.toolPanel.toolOperation?(this.operationFieldLabel.removeClass(t.ERROR_OPERATION_CLASS),this.operationFieldLabel2.removeClass(t.ERROR_OPERATION_CLASS)):(this.operationFieldLabel.addClass(t.ERROR_OPERATION_CLASS),this.operationFieldLabel2.addClass(t.ERROR_OPERATION_CLASS));this.onResize();this.validate()},t.prototype.updateOperationField=function(t,i){var e;this.operationType=t.getOperationType();var r=i?this.operationFieldImg:this.operationFieldImg2,f=i?this.operationFieldLabel:this.operationFieldLabel2,u=i?this.operationFieldWidth:this.operationFieldWidth2;t.imageUrl&&t.showImage?(e="/Content/images/calculator/"+t.imageUrl,r.attr("src",e),f.hide(),r.show(),this.isUnaryOperation()?(r.css({"padding-right":"10px"}),u=r.width()+10):this.operationType==n.OPERATION_TYPE.BINARY_OPERATION&&(r.css({"padding-right":"0px"}),u=r.width())):(f.text(t.operationLabel),f.show(),u=WaveViewer.WaveUtils.calcLabelWidth(t.operationLabel,n.ToolWindow.FONT_SIZE)+10,f.width(u),r.hide());i?this.operationFieldWidth=u:this.operationFieldWidth2=u},t.prototype.validateCombos=function(){var t,i,r;if(!this.toolPanel.toolOperation)return n.ToolMessages.CHOOSE_OPERATION;if(this.isUnaryOperation()){if(this.firstCombo.isEmpty())return n.ToolMessages.EMPTY_INPUT}else{if(this.firstCombo.isEmpty())return n.ToolMessages.EMPTY_FIRST_INPUT;if(this.secondCombo.isEmpty())return n.ToolMessages.EMPTY_SECOND_INPUT}if(t=this.getArguments(),i=t.arg1.wf,this.toolPanel.toolOperation.isBinary()){if(this.toolPanel.toolOperation instanceof n.BaseMeasurement){if(!i)return n.ToolMessages.CHOOSE_FIRST_WAVEFORM;if(r=t.arg2.wf,!r)return n.ToolMessages.CHOOSE_SECOND_WAVEFORM}else if(this.toolPanel.toolOperation instanceof n.CalcFunction&&(r=t.arg2.wf,!i&&!r))return n.ToolMessages.CHOOSE_AT_LEAST_ONE_WAVEFORM}else if(!i)return n.ToolMessages.CHOOSE_WAVEFORM;return null},t.prototype.getArguments=function(){var e=this.toolPanel.toolOperation,f,n,t;if(!e)return null;var i=new r,u=new r,o=this.firstCombo.getSelectedWaveform();return o?i.wf=o:(n=new Project.PropertyFormatter,t=n.SIUnitPrefixes2Double(this.firstCombo.getInputText()),i.val=t),e.isBinary()&&(f=this.secondCombo.getSelectedWaveform(),f?u.wf=f:(n=new Project.PropertyFormatter,t=n.SIUnitPrefixes2Double(this.secondCombo.getInputText()),u.val=t)),{arg1:i,arg2:u}},t.prototype.validate=function(){var i=!1,n=null,r;return this.inputError?n=this.inputError:(this.panelError=this.validateCombos(),this.panelError?(this.greenButton.attr("src",t.TOOL_CONTROL_OPERATION_ERROR_IMAGE),n=this.panelError):(r=this.getArguments(),this.operationError=this.toolPanel.toolOperation.validate(r,this.toolPanel),this.operationError&&(this.greenButton.attr("src",t.TOOL_CONTROL_OPERATION_ERROR_IMAGE),n=this.operationError))),n?(this.greenButton.attr("src",t.TOOL_CONTROL_OPERATION_ERROR_IMAGE),i=!1):(this.greenButton.attr("src",t.TOOL_CONTROL_OPERATION_APPLY_IMAGE),i=!0),this.updateGreenButtonTooltip(n),i},t.prototype.updateGreenButtonTooltip=function(t){var i=t?t:n.ToolMessages.APPLY_OPERATION,r=this.greenButton.qtip("api");r?r.set("content.text",i):this.greenButton.qtip({content:{text:i},style:{classes:"svw-tooltip"},position:{my:"left top",at:"right middle"}})},t.prototype.onResize=function(){this.firstCombo&&this.firstCombo.onResize();this.secondCombo&&this.secondCombo.onResize()},t.prototype.updateCombos=function(){return this.firstCombo.updateComboBox(),this.secondCombo.updateComboBox()},t.TOOL_CONTROL_LABEL_CLASS="ToolControl_Label_Class",t.TOOL_CONTROL_COMBO1_ID="ToolControl_Combo_1",t.TOOL_CONTROL_COMBO2_ID="ToolControl_Combo_2",t.TOOL_CONTROL_OPERATION_ID="ToolControl_Operatin_Label",t.TOOL_CONTROL_OPERATION_ID2="ToolControl_Operatin_Label2",t.TOOL_CONTROL_COMBO_GREEN_BUTTON_ID="Calculator_Green_Button",t.TOOL_CONTROL_OPERATION_INIT_NAME="?",t.TOOL_CONTROL_OPERATION_APPLY_IMAGE="/Content/images/greenButton.png",t.TOOL_CONTROL_OPERATION_ERROR_IMAGE="/Content/images/model-error.png",t.ERROR_OPERATION_CLASS="wfOpTool_Error_Operation",t}(),t,i,r,e,u,f;n.ToolControl=o,function(n){n[n.NUMBER=0]="NUMBER";n[n.WAVEFORM=1]="WAVEFORM"}(n.ComboMode||(n.ComboMode={}));t=n.ComboMode;i=function(){function i(n,i,r){this.isFirstCombo=!0;this.readOnly=!0;this.isSelected=!1;this.mode=t.WAVEFORM;this.isFirstCombo=i;this.toolPanel=r.toolPanel;this.toolControl=r;this.combo=this.createCombo(n,i,r.parentPanel)}return i.prototype.isColor=function(n){if(!n)return!1;var t=""+n;return t==""?!1:t.charAt(0)=="#"?!0:!1},i.prototype.createCombo=function(t,r,u){var o=this,f=this,s=this.initDataSource(),c=n.ToolUtils.createElement("div",t,u,null),h=function(t){f.setReadOnlyMode();f.toolControl.setAsActive(null);var i=this.value();f.isColor(i)&&$(t.sender.element).data("kendoComboBox").input.css("color",i);f.toolPanel.updateOptionDialog(!1,n.TOOL_EVENT.WAVEFORM);f.toolControl.validate()},e=$("#"+t).kendoComboBox({dataTextField:"text",dataValueField:"color",dataSource:s,template:'<span class="'+i.TOOL_COMBO_ITEM_CLASS+'" plotId = "#:plotId#" style="color: #:color#">#:text#<\/span>',index:0,open:function(){f.hoverByItems()},close:h}).data("kendoComboBox");e.input.keyup(function(){f.testComboValue()});this.setReadOnlyMode();e.input.on("click",function(n){f.toolControl.isEditable&&(n.preventDefault(),n.stopPropagation(),f.setEditableMode(),f.toolControl.setAsActive(f),f.isSelected?f.isSelected=!1:(this.select(),f.isSelected=!0))});return e.input.attr("spellcheck","false"),e.input.mousemove(function(){}),e.input.mouseenter(function(){var n=o.getSelectedWaveform();n&&WaveViewer.getManager().getCrossHighlightManager().crossHighlightByWaveform(n,!0)}),e.input.mouseleave(function(){var n=o.getSelectedWaveform();n&&WaveViewer.getManager().getCrossHighlightManager().crossHighlightByWaveform(n,!1)}),e},i.prototype.hoverByItems=function(){var n=$("."+i.TOOL_COMBO_ITEM_CLASS).parent(),t;if(n){n.off(".waveform_tool");t=this;n.on("mouseenter.waveform_tool",function(){var r=this,i=$(this).children().first().attr("plotid"),n;i&&(n=t.toolControl.waveContainer.getPlottedWaveformByFlotId(i),n&&WaveViewer.getManager().getCrossHighlightManager().crossHighlightByWaveform(n,!0))});n.on("mouseleave.waveform_tool",function(){var r=this,i=$(this).children().first().attr("plotid"),n;i&&(n=t.toolControl.waveContainer.getPlottedWaveformByFlotId(i),n&&WaveViewer.getManager().getCrossHighlightManager().crossHighlightByWaveform(n,!1))})}},i.prototype.testComboValue=function(){var n,t,i;if(this.readOnly){this.toolControl.setComboError(null);return}n=this.combo.text();n?(t=Project.CompProperty.validator.ValidateInputValue("real",n),t.match("^Invalid")?this.toolControl.setComboError(t):this.toolControl.setComboError(null)):(i=this.isFirstCombo?"First":"Second",this.toolControl.setComboError(i+" argument is null"))},i.prototype.initDataSource=function(){for(var f,e,o,u=[],i=this.toolControl.waveContainer.getPlottedWaveforms(),r=0,t=0;t<i.length;t++)f=i[t].getFullWaveformName(),e=WaveViewer.WaveUtils.calcLabelWidth(f,n.ToolWindow.FONT_SIZE),r<e&&(r=e),u.push(this.getWfDataSourceEntity(f,t,i[t].color,i[t].getFlotWaveformId()));return(r+=30,this.toolControl.comboWidth=r+6,u.length==0)?null:(o=new kendo.data.DataSource,o.data(u),o)},i.prototype.getWfDataSourceEntity=function(n,t,i,r){return{text:n,value:""+t,color:i,plotId:r}},i.prototype.setEditableMode=function(){this.toolControl.isEditable&&(this.readOnly=!1,this.combo&&(this.combo.input.removeAttr("readonly"),this.combo.input.css({"background-color":"white"}),this.combo.input.css({color:"#31404d"})))},i.prototype.setReadOnlyMode=function(){this.readOnly=!0;this.combo&&(this.combo.input.attr("readonly","true"),this.combo.input.css({"background-color":"transparent"}))},i.prototype.hide=function(){this.combo.wrapper.hide()},i.prototype.show=function(){this.combo.wrapper.show()},i.prototype.setWaveform=function(n){for(var i=this.toolControl.waveContainer.getPlottedWaveforms(),t=0;t<i.length;t++)if(i[t].getFlotWaveformId()==n.getFlotWaveformId()){this.combo.select(t);this.combo.trigger("close");return}},i.prototype.applyNumberOperation=function(n){var t,i,r;this.combo.input.focus();n.getName()=="Backspace"?this.isTextSelected()?(this.combo.text(""),this.isSelected=!1):(t=this.combo.text(),t&&t.length>1?this.combo.text(t.substring(0,t.length-1)):this.combo.text("")):n.getName()=="+/-"?(t=this.combo.text(),t&&t.length>0&&(i=t.trim(),i.charAt(0)=="-"?this.combo.text(i.substring(1)):i.charAt(0)=="+"?this.combo.text("-"+i.substring(1)):this.combo.text("-"+i))):(r=n.getValue(),this.addNumber(r),this.isSelected=!1)},i.prototype.addNumber=function(n){if(this.isTextSelected())this.combo.text(n);else{var t=this.combo.text();t?this.combo.value(t+n):this.combo.value(n)}this.combo.input.focus();this.testComboValue()},i.prototype.isTextSelected=function(){if(this.combo.input.focus(),this.isSelected)return!0;var n=this.combo.input[0];return typeof n.selectionStart=="number"?n.selectionStart==0&&n.selectionEnd==n.value.length:!1},i.prototype.isEmpty=function(){var n=this.combo.text();return n==null||n==""?!0:!1},i.prototype.getInputText=function(){return this.combo.text()},i.prototype.onResize=function(){this.combo.wrapper.width(this.toolControl.getComboWidth(this.toolControl.isUnaryOperation()))},i.prototype.getMode=function(){var n=this.combo.dataItem();return n?t.WAVEFORM:t.NUMBER},i.prototype.updateComboBox=function(){var u=this.getMode(),e=null,o=this.combo.dataItem(),n,i,r,f;return o&&(e=o.plotId),n=!1,i=this.initDataSource(),this.combo&&(r=this.combo.text(),r&&r!=""||(u=t.WAVEFORM),i?(this.combo.setDataSource(i),n=!0):(this.combo.setDataSource(null),this.combo.text(""),this.combo.value(),n=!1),this.combo.enable(n),this.setReadOnlyMode(),u==t.NUMBER?this.combo.text(r):u==t.WAVEFORM&&(f=this.getItemIndex(e,i),f>=0&&(this.combo.select(f),this.combo.trigger("close"))),this.toolControl.validate(),this.combo.refresh()),n},i.prototype.getItemIndex=function(n,t){var r,i,u;if(!t||(r=t.data(),!r))return-1;if(!n)return 0;for(i=0;i<r.length;i++)if(u=r[i],r[i].plotId==n)return i;return 0},i.prototype.getSelectedWaveform=function(){var n=this.combo.dataItem();return n?this.toolPanel.toolWindow.getWaveContainer().getPlottedWaveformByFlotId(n.plotId):null},i.prototype.getSelectedWaveformFlotId=function(){var n=this.getSelectedWaveform();return n?n.getFlotWaveformId():null},i.prototype.getState=function(){var n=new f,i=this.getSelectedWaveform();return i?(n.wf=i,n.mode=t.WAVEFORM):(n.value=this.combo.text(),n.mode=t.NUMBER),n},i.prototype.setState=function(n){n&&n.mode==t.WAVEFORM&&this.setWaveform(n.wf)},i.TOOL_COMBO_ITEM_CLASS="Tool_Combo_Item_Class",i}();n.ToolCombo=i;r=function(){function n(){}return n.prototype.isWaveform=function(){return this.wf!=null},n}();n.ToolArg=r;e=function(){function n(){}return n}();n.ToolArguments=e;u=function(){function n(){}return n}();n.ToolControlState=u;f=function(){function n(){this.mode=t.WAVEFORM}return n}();n.ComboState=f}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t,s,o,i,u,f,e,r;(function(n){n[n.NOT_SUPPORTED=0]="NOT_SUPPORTED";n[n.VISIBILITY=1]="VISIBILITY";n[n.NO_WAVEFORM=2]="NO_WAVEFORM";n[n.INCORRECT_VALUE=3]="INCORRECT_VALUE";n[n.EMPTY_VALUE=4]="EMPTY_VALUE";n[n.NONE=5]="NONE"})(n.INPUT_ERRORS||(n.INPUT_ERRORS={}));t=n.INPUT_ERRORS,function(n){n[n.WAVEFORM=0]="WAVEFORM";n[n.VALUE=1]="VALUE";n[n.OPERATION=2]="OPERATION"}(n.INPUT_EVENTS||(n.INPUT_EVENTS={}));s=n.INPUT_EVENTS;o=function(){function u(t,i,r,f,e,o){var s,h;this.operationName=u.INPUT_OPERATION_INIT_NAME;this.comboWidth=40;this.greenButtonSize=16;this.betweenButtons=5;this.readOnly=!1;this.errorMessage="Operation is not chosen";this.defaultComboIndex=0;this.lineButtonEnabled=!0;this.inputMeasurementName=t;this.toolPanel=r;this.tooltip=e;this.wf=o;s=u.GLOBAL_INPUT_CONTROL_COUNT++;this.lineButtonId=u.INPUT_BUTTON_ID+s;this.operationId=u.INPUT_OPERATION_ID+s;this.comboId=u.INPUT_COMBO_ID+s;h="LineDiv_"+t+s;this.lineDiv=n.ToolUtils.createElement("div",h,i,null);this.createControls(f);n.ToolWindow.setToolStyle(this.lineDiv);this.setDefault();this.testAndSetState()}return u.prototype.containsValue=function(n,t){for(var i=0;i<n.length;i++)if(n[i]==t)return!0;return!1},u.prototype.getStaticComboList=function(){return this.inputMeasurementName==(new n.BaseLine).measurementName?u.BaseComboList:this.inputMeasurementName==(new n.TopLine).measurementName?u.TopComboList:null},u.prototype.addToComboList=function(){this.inputMeasurementName==(new n.BaseLine).measurementName?u.BaseComboList=this.addToComboListInternal(u.BaseComboList):this.inputMeasurementName==(new n.TopLine).measurementName&&(u.TopComboList=this.addToComboListInternal(u.TopComboList))},u.prototype.addToComboListInternal=function(t){var f=this.getValueAsNumber(),s,i,e,r,o;if(f==null||t==null||this.containsValue(t,f))return t;for(s=[],t.length==u.ComboListMaxLen&&(t=t.slice(1)),t.push(f),i=[],i.push({text:n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT,value:"0"}),e=0,r=0;r<t.length;r++)if(i.push({text:t[r],value:""+(r+1)}),e++,e==u.ComboListMaxLen)break;return o=new kendo.data.DataSource({data:i}),this.lineCombo.setDataSource(o),this.lineCombo.select(i.length-1),t},u.prototype.setStateAndHandle=function(n,u){u===void 0&&(u=t.NONE);u&&u!=t.NONE&&(n=i.DISABLED);switch(n){case i.DISABLED:this.inputControlState=new f(this,u);break;case i.ENABLED_AND_NOT_PRESSED:this.inputControlState=new r(this);break;case i.ENABLED_AND_PRESSED:this.inputControlState=new e(this);break;default:this.inputControlState=new r(this)}this.inputControlState&&this.inputControlState.handleState()},u.prototype.setWaveform=function(n){this.wf=n;this.inputControlState&&this.testAndSetState()},u.prototype.setOperation=function(){this.inputControlState=new r(this);this.testAndSetState()},u.prototype.createControls=function(n){this.lineLabel=this.createLineLabel();this.lineCombo=this.createCombo(this.comboId,n);this.lineButton=this.createLineButton()},u.prototype.setRangeCombo=function(n){this.rangeCombo=n},u.prototype.getRange=function(){return this.rangeCombo?this.rangeCombo.text():n.OptionsDialog.TOOL_RANGE_ENTIRE_WAVEFORM},u.prototype.updateByDragging=function(n){n&&this.lineCombo.text(n)},u.prototype.setDefault=function(){this.lineCombo&&this.lineCombo.select(this.defaultComboIndex);this.inputControlState=new r(this);this.testAndSetState()},u.prototype.areDefaultOptions=function(){return this.inputControlState.status!=i.ENABLED_AND_NOT_PRESSED?!1:this.lineCombo.select()!=this.defaultComboIndex?!1:!0},u.prototype.getValueAsNumber=function(){var t=this.lineCombo.text();return t!=n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT?n.ToolUtils.convertToNumber(t):null},u.prototype.isDefaultLevel=function(){var t=this.lineCombo.text();return t==n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT},u.prototype.createLineLabel=function(){var t=n.ToolUtils.createLabel(this.operationId,null,this.lineDiv,this.inputMeasurementName+":",this.tooltip,n.ToolWindow.TOOL_LEFT_COLUMN_CLASS);return t.css({"margin-top":"10px"}),t},u.prototype.createCombo=function(t,i){for(var s,u,e=this,o=this.getStaticComboList(),h=n.ToolUtils.createElement("div",t,this.lineDiv,null),f=[],r=0;r<i.length;r++)f.push({text:i[r],value:""+r});for(r=0;r<o.length;r++)f.push({text:o[r],value:""+(i.length+r)});return s=function(){e.testAndSetState()},u=$("#"+t).kendoComboBox({dataTextField:"text",dataValueField:"value",dataSource:f,index:0,close:s,suggest:!1}).data("kendoComboBox"),u.wrapper.width(n.ToolWindow.ADVANCE_FIELD_WIDTH),u.input.keyup(function(n){e.entryValue(n)}),u},u.prototype.entryValue=function(n){n.preventDefault();n.stopPropagation();this.inputControlState&&this.testAndSetState()},u.prototype.testAndSetState=function(){var t=this.testChangeEvent(),n;this.inputControlState&&(n=this.inputControlState.getNextState(t),n!=null&&this.setStateAndHandle(n,t))},u.prototype.testChangeEvent=function(){if(!this.wf)return t.NO_WAVEFORM;if(!this.wf.isForInputControl())return t.NOT_SUPPORTED;return this.testValue()},u.prototype.testValue=function(){var i=this.lineCombo.input.val(),f,r,u;if(i){if(i==n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT)return t.NONE;if(f=Project.CompProperty.validator.ValidateInputValue("real",i),f.match("^Invalid"))return t.INCORRECT_VALUE}else return t.EMPTY_VALUE;return(r=this.getValueAsNumber(),u=this.wf.getVisibleYRange(),r<u.ymin||r>u.ymax)?t.VISIBILITY:t.NONE},u.prototype.enableLineButton=function(n,t){t===void 0&&(t=!0);var i=n==null;this.lineButtonEnabled=i;t?this.toolPanel.toolCombo.setComboError(n):this.toolPanel.toolCombo.setComboError(null);i?this.lineButton.css({opacity:1}):this.lineButton.css({opacity:.2})},u.prototype.createLineButton=function(){var i=this,t=n.ToolUtils.createElement("button",this.lineButtonId,this.lineDiv,null);t.css({color:"black"});t.css({"margin-right":"3px"});t.css({"margin-left":"5px"});t.css({padding:"0px 2px 0px 2px"});var r=this,u={imageUrl:"/Content/images/eyeHidden.png",click:function(){r.toggleButton()}},f=t.kendoButton(u).data("kendoButton");return t.qtip({content:function(){return i.inputControlState?i.inputControlState.getEyeButtonMessage():"Not defined"},position:{my:"bottom right",at:"center"},style:{classes:"svw-tooltip"}}),t},u.prototype.toggleButton=function(){this.inputControlState&&this.inputControlState.toggleButton()},u.prototype.removeMarker=function(){this.inputControlMeasurement&&this.hideLevel()},u.prototype.hideLevel=function(){this.lineButton.removeClass(n.ToolPanel.TOOL_OPTION_SELECTED_CLASS);this.lineButton.find("img.k-image").css({content:"url("+u.INPUT_LEVEL_HIDE_IMAGE+")"});this.inputControlMeasurement&&this.inputControlMeasurement.markerManager.removeMarkers()},u.prototype.showLevel=function(){var r,i,f,t;this.lineButton.addClass(n.ToolPanel.TOOL_OPTION_SELECTED_CLASS);this.lineButton.find("img.k-image").css({content:"url("+u.INPUT_LEVEL_SHOW_IMAGE+")"});r=this.toolPanel.toolCombo.getArguments();i=!0;this.inputControlMeasurement?this.inputControlMeasurement.setWaveforms(r):this.createInputControlMeasurement(this.inputMeasurementName,r);this.inputControlMeasurement.hasLevel()?(this.inputControlMeasurement.showLevel(this.getValueAsNumber()),i=!1):this.inputControlMeasurement.isDefaultLevel()&&this.inputControlMeasurement.isEntireRange()&&(f=this.inputControlMeasurement.wf,t=WaveViewer.getManager().getWaveformInfoFromCache(f.simulationId,f.getWaveformHandle(),f.getFullWaveformName(),!1),t&&(this.inputMeasurementName==(new n.BaseLine).measurementName&&t.isBaselineSet?(this.inputControlMeasurement.showLevel(t.getBaseline()),i=!1):this.inputMeasurementName==(new n.TopLine).measurementName&&t.isToplineSet&&(this.inputControlMeasurement.showLevel(t.getTopline()),i=!1)));i&&this.inputControlMeasurement.doApply(r)},u.prototype.createInputControlMeasurement=function(t,i){(this.inputControlMeasurement=n.ToolUtils.getMeasurementByName(t),this.inputControlMeasurement.markerMode=n.MARKER_MODE.INPUT,this.inputControlMeasurement.inputControl=this,this.inputControlMeasurement.setRangeComboForInputControls(this.rangeCombo),i)&&(this.inputControlMeasurement.setWaveforms(i),this.inputControlMeasurement.markerManager=new n.MeasMarkerManager(this.inputControlMeasurement),this.inputControlMeasurement.waveContainer.containerMeasManager.addMeasurement(this.inputControlMeasurement))},u.INPUT_COMBO_ID="InputControl_Combo_",u.INPUT_OPERATION_ID="InputControl_Operatin_Label",u.INPUT_BUTTON_ID="InputControl_Button",u.INPUT_OPERATION_INIT_NAME="?",u.INPUT_OPERATION_APPLY_IMAGE="/Content/images/check.png",u.INPUT_OPERATION_ERROR_IMAGE="/Content/images/exclamationMark.png",u.INPUT_LEVEL_SHOW_IMAGE="/Content/images/eyeOpen.png",u.INPUT_LEVEL_HIDE_IMAGE="/Content/images/eyeHidden.png",u.GLOBAL_INPUT_CONTROL_COUNT=0,u.TopComboList=[],u.BaseComboList=[],u.ComboListMaxLen=3,u}();n.InputControl=o,function(n){n[n.DISABLED=0]="DISABLED";n[n.ENABLED_AND_PRESSED=1]="ENABLED_AND_PRESSED";n[n.ENABLED_AND_NOT_PRESSED=2]="ENABLED_AND_NOT_PRESSED"}(n.INPUT_CONTROL_STATUS||(n.INPUT_CONTROL_STATUS={}));i=n.INPUT_CONTROL_STATUS;u=function(){function r(n){this.status=i.ENABLED_AND_NOT_PRESSED;this.inputError=t.NONE;this.inputControl=n}return r.prototype.enableComboLabel=function(n){n?this.inputControl.lineLabel.css({opacity:1}):this.inputControl.lineLabel.css({opacity:.2})},r.prototype.enableCombo=function(n){this.inputControl.lineCombo.enable(n);n?this.inputControl.lineCombo.wrapper.css({opacity:1}):this.inputControl.lineCombo.wrapper.css({opacity:.4})},r.prototype.setEnabled=function(){this.enableCombo(!0);this.enableComboLabel(!0);this.inputControl.enableLineButton(null)},r.prototype.setDisabled=function(){var n=this.canEditCombo();this.enableCombo(n);this.enableComboLabel(n);this.inputControl.enableLineButton(this.getErrorMessage(),this.isCriticalOperationError())},r.prototype.isCriticalOperationError=function(){var n=this.inputError;return n==null?!1:this.inputError==t.INCORRECT_VALUE||this.inputError==t.EMPTY_VALUE?!0:!1},r.prototype.canEditCombo=function(){var n=this.inputError;return n==null?!0:this.inputError==t.NOT_SUPPORTED||this.inputError==t.NO_WAVEFORM?!1:!0},r.prototype.getEyeButtonMessage=function(){return this.getMessage()},r.prototype.getErrorMessage=function(){var i=this.inputError;return this.inputError==null||this.inputError==t.NONE?null:i==t.VISIBILITY?n.ToolMessages.getMessage(n.ToolMessages.EYE_BUTTON_VISIBILITY_DISABLED,this.inputControl.inputMeasurementName):i==t.NOT_SUPPORTED?n.ToolMessages.getMessage(n.ToolMessages.EYE_BUTTON_NOT_SUPPORTED,this.inputControl.inputMeasurementName):i==t.NO_WAVEFORM?n.ToolMessages.getMessage(n.ToolMessages.EYE_BUTTON_NO_WAVEFORM,this.inputControl.inputMeasurementName):i==t.INCORRECT_VALUE?n.ToolMessages.getMessage(n.ToolMessages.EYE_BUTTON_INCORRECT_VALUE,this.inputControl.inputMeasurementName):i==t.EMPTY_VALUE?n.ToolMessages.getMessage(n.ToolMessages.EYE_BUTTON_EMPTY_VALUE,this.inputControl.inputMeasurementName):null},r}();n.InputControlState=u;f=function(n){function r(t,r){n.call(this,t);this.status=i.DISABLED;this.inputError=r}return __extends(r,n),r.prototype.getMessage=function(){var n=this.getErrorMessage();return n?n:""},r.prototype.handleState=function(){this.inputControl.hideLevel();this.setDisabled()},r.prototype.toggleButton=function(){},r.prototype.getNextState=function(n){return n==t.NONE?i.ENABLED_AND_NOT_PRESSED:(this.inputError=n,this.handleState(),null)},r}(u);n.DisabledInputControl=f;e=function(n){function r(r){n.call(this,r);this.status=i.ENABLED_AND_PRESSED;this.inputError=t.NONE}return __extends(r,n),r.prototype.getMessage=function(){var n=this.getErrorMessage();return n?n:"Press to Hide"},r.prototype.handleState=function(){this.inputControl.hideLevel();this.setEnabled();this.inputControl.showLevel()},r.prototype.toggleButton=function(){this.inputControl.setStateAndHandle(i.ENABLED_AND_NOT_PRESSED)},r.prototype.getNextState=function(n){return n==t.NONE?(this.handleState(),null):i.DISABLED},r}(u);n.EnabledPressInputControl=e;r=function(n){function r(r){n.call(this,r);this.status=i.ENABLED_AND_NOT_PRESSED;this.inputError=t.NONE}return __extends(r,n),r.prototype.getMessage=function(){var n=this.getErrorMessage();return n?n:"Press to Show"},r.prototype.handleState=function(){this.inputControl.hideLevel();this.setEnabled()},r.prototype.toggleButton=function(){this.inputControl.setStateAndHandle(i.ENABLED_AND_PRESSED)},r.prototype.getNextState=function(n){return n==t.NONE?(this.handleState(),null):i.DISABLED},r}(u);n.EnabledNotPressInputControl=r}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var s,r,i,h,t,u,f,e,o;(function(n){n[n.NUMBER=0]="NUMBER";n[n.UNARY_OPERATION=1]="UNARY_OPERATION";n[n.BINARY_OPERATION=2]="BINARY_OPERATION"})(n.OPERATION_TYPE||(n.OPERATION_TYPE={}));s=n.OPERATION_TYPE,function(n){n[n.WAVEFORM=0]="WAVEFORM";n[n.OPERATION=1]="OPERATION";n[n.CATEGORY=2]="CATEGORY";n[n.OPEN_DIALOG=3]="OPEN_DIALOG"}(n.TOOL_EVENT||(n.TOOL_EVENT={}));r=n.TOOL_EVENT;i=function(){function i(n,t,r,u){this.panelIndex=0;this.count=0;var f=i.PANEL_COUNT++;this.toolWindow=n;this.count=f;this.panelId=i.TOOL_PANEL_ID+f;this.optionLinkId=i.TOOL_OPTION_DIV_ID+f;this.panelIndex=u;this.category=t;this.mainPanel=this.createPanel(r);this.mainPanel.width(r.width());this.mainPanel.height(r.height());this.toolWindow.addToToolWindow(this)}return i.prototype.onResize=function(){},i.prototype.selectButton=function(){this.selectedButtonId&&$("#"+this.selectedButtonId).trigger("click")},i.prototype.createPanel=function(t){var r=n.ToolUtils.createElement("div","source"+this.panelId,t,""),u=n.ToolWindow.DIALOG_HEIGHT-this.toolWindow.tabHeight-18,i;return r.height(u),r.css({display:"flex","flex-direction":"row","justify-content":"flex-start"}),i=n.ToolUtils.createElement("div",this.panelId,r,""),this.toolCombo=new n.ToolControl(i,this.toolWindow.getWaveContainer(),this),this.createOptionLink(i),i},i.prototype.getToolControlState=function(){return this.toolCombo.getState()},i.prototype.setToolControlState=function(n){this.toolCombo.setState(n);this.toolCombo.validate()},i.prototype.setOperation=function(n){this.setPreviousToolOperation();this.toolOperation=n;this.toolWindow.getWaveContainer().isEmpty()||this.toolOperation.setWaveforms(this.toolCombo.getArguments());this.optionLinkLabel.html(this.toolOperation.getName()+" Options");this.toolOperation.hasOptions()?this.optionLinkDiv.show():this.optionLinkDiv.hide();var t=this.isStateChanged();t&&this.previousToolOperation&&this.toolWindow.optionsDialog&&this.previousToolOperation.setDefault();this.updateOptionDialog(t,r.OPERATION)},i.prototype.removeInputMarkers=function(){this.toolOperation&&this.toolOperation.removeInputMarkers()},i.prototype.getLinkMargin=function(){return this instanceof t?"15px":"5px"},i.prototype.createOptionLink=function(t){var u=this,i=n.ToolUtils.createElement("div",this.optionLinkId,t,null),r=this.optionLinkId+"Operation_Options",f='<a href="#" id="'+r+'" class="sidebar_text_label" style ="margin-right:'+this.getLinkMargin()+'; float:right">Advanced Options<\/a>';i.append(f);i.css({"font-size":n.ToolWindow.FONT_SIZE,"margin-bottom":"10px"});i.height(n.ToolWindow.FONT_SIZE);i.click(function(n){u.openOptionDialog(n)});i.hide();this.optionLinkDiv=i;this.optionLinkLabel=$("#"+r)},i.prototype.doApply=function(){if(this.toolCombo.validate()){var t=this.toolCombo.getArguments();this.toolOperation instanceof n.BaseMeasurement?this.toolOperation.doApply(t):this.toolOperation instanceof n.CalcFunction&&this.toolOperation.doApply(t)}},i.prototype.hasOptions=function(){return this.toolOperation&&this.toolOperation.hasOptions()?!0:!1},i.prototype.isStateChanged=function(){return this.previousToolOperation?this.previousToolOperation==this.toolOperation?!1:!0:!0},i.prototype.openOptionDialog=function(){this.toolWindow&&this.hasOptions()&&(this.toolWindow.openOptionDialog(this),this.updateOptionDialog(this.isStateChanged(),r.OPEN_DIALOG))},i.prototype.getArguments=function(){return this.toolCombo.getArguments()},i.prototype.setPreviousToolOperation=function(){this.previousToolOperation=this.toolOperation},i.prototype.areDefaultOptions=function(){return this.toolOperation?this.toolOperation.areDefaultOptions():!0},i.prototype.setToDefault=function(){this.removeInputMarkers();this.toolCombo.setComboError(null);this.toolOperation.setDefault();this.toolWindow.useDefaultOptions(!0)},i.prototype.updateInputControlLists=function(){this.toolOperation&&this.toolWindow&&this.toolWindow.optionsDialog&&this.toolOperation.updateInputControlLists()},i.prototype.updateOptionDialog=function(n,t){this.toolOperation&&this.toolWindow&&this.toolWindow.optionsDialog&&(n||(n=t==r.OPEN_DIALOG),t!=r.OPEN_DIALOG||this.toolWindow.optionsDialog.isOpened()||(this.toolWindow.optionsDialog.open(),n=!0),this.toolOperation.setWaveforms(this.toolCombo.getArguments()),this.toolWindow.initOptionDialog||(n=!0,this.toolWindow.initOptionDialog=!0),n&&this.toolWindow.optionsDialog.updateContent(this.toolOperation))},i.TOOL_PANEL_ID="WfOpTool_Tool_Panel",i.TOOL_WF_COMBO_LABEL_ID="WfOpTool_Tool_Panel_Combo_Label",i.TOOL_OPTION_DIV_ID="WfOpTool_Tool_Panel_Option_Div_Id",i.TOOL_BUTTON_SELECTED_CLASS="wfOpTool_button_selected",i.TOOL_OPTION_SELECTED_CLASS="option_button_selected",i.PANEL_COUNT=0,i}();n.ToolPanel=i;h=function(t){function r(r,u,f,e){t.call(this,r,u,f,e);var o=i.TOOL_PANEL_ID+this.count,s=n.ToolUtils.createElement("div",o,this.mainPanel,null);this.fillButtonPanel(s)}return __extends(r,t),r.prototype.fillButtonPanel=function(t){var i,r,u;for(n.ToolUtils.initMeasurementList(),i=0;i<n.ToolUtils.measurementList.length;i++)r=n.ToolUtils.measurementList[i],r.hasCategory(this.category)&&(u=r.getButton(),u.addToPanel(t,this),r.measurementId==this.category.selectedOperationId&&(this.selectedButtonId=u.id))},r.prototype.getOpLabelWidth=function(){return n.ToolWindow.BUTTON_WIDTH},r}(i);n.MeasurementPanel=h;t=function(t){function r(r,u,f,e){t.call(this,r,u,f,e);var s=i.TOOL_PANEL_ID+this.count,o=n.ToolUtils.createElement("div",s,this.mainPanel,null);this.fillButtonPanel(o);o.css({display:"table",margin:"0 auto","margin-top":"10px"})}return __extends(r,t),r.prototype.getOpLabelWidth=function(n){return n==s.BINARY_OPERATION?r.SMALL_BUTTON_WIDTH:r.NORMAL_BUTTON_WIDTH},r.getCalculatorPanel=function(t,i,r,s){switch(i.id){case n.Category.CAT_CALCULATOR:return new u(t,i,r,s);case n.Category.CAT_TRANS:return new f(t,i,r,s);case n.Category.CAT_TRIG:return new e(t,i,r,s);case n.Category.CAT_LOGIC:return new o(t,i,r,s);default:return null}},r.prototype.onResize=function(){this.toolCombo&&this.toolCombo.onResize()},r.prototype.addRow=function(t,i){for(var f,o,e=n.ToolUtils.createElement("div",null,i,null),u=0;u<t.length;u++)f=t[u],o=f.addButton(e,this),f.id==this.category.selectedOperationId&&(this.selectedButtonId=o.id);e.width((r.NORMAL_BUTTON_WIDTH+3)*4+10)},r.NUM_BUTTON=5,r.NORMAL_BUTTON_WIDTH=72,r.SMALL_BUTTON_WIDTH=20,r.BUTTON_HEIGHT=26,r}(i);n.CalculatorPanel=t;u=function(t){function i(n,i,r,u){t.call(this,n,i,r,u)}return __extends(i,t),i.prototype.fillButtonPanel=function(n){this.addRow(this.buildRow0(),n);this.addRow(this.buildRow1(),n);this.addRow(this.buildRow2(),n);this.addRow(this.buildRow3(),n);this.addRow(this.buildRow4(),n)},i.prototype.buildRow0=function(){var t=[];return t.push(new n.BackspaceOperation),t.push(new n.NumSignOperation),t.push(new n.NumEOperation),t.push(new n.NumPiOperation),t},i.prototype.buildRow1=function(){var t=[];return t.push(new n.Num7Operation),t.push(new n.Num8Operation),t.push(new n.Num9Operation),t.push(new n.DivideOperation),t},i.prototype.buildRow2=function(){var t=[];return t.push(new n.Num4Operation),t.push(new n.Num5Operation),t.push(new n.Num6Operation),t.push(new n.MultiplyOperation),t},i.prototype.buildRow3=function(){var t=[];return t.push(new n.Num1Operation),t.push(new n.Num2Operation),t.push(new n.Num3Operation),t.push(new n.SubtractOperation),t},i.prototype.buildRow4=function(){var t=[];return t.push(new n.Num0Operation),t.push(new n.NumPointOperation),t.push(new n.AddOperation),t},i}(t);n.BaseCalculator=u;f=function(t){function i(n,i,r,u){t.call(this,n,i,r,u)}return __extends(i,t),i.prototype.fillButtonPanel=function(n){this.addRow(this.buildRow0(),n);this.addRow(this.buildRow1(),n);this.addRow(this.buildRow2(),n);this.addRow(this.buildRow3(),n)},i.prototype.buildRow0=function(){var t=[];return t.push(new n.DrvOperation),t.push(new n.IntegOperation),t.push(new n.ExpOperation),t.push(new n.LnOperation),t},i.prototype.buildRow1=function(){var t=[];return t.push(new n.SquareOperation),t.push(new n.SquareRootOperation),t.push(new n.Power10Operation),t.push(new n.LogarithmOperation),t},i.prototype.buildRow2=function(){var t=[];return t.push(new n.ReciprocalOperation),t.push(new n.PowerOperation),t.push(new n.AbsOperation),t.push(new n.WinAveOperation),t},i.prototype.buildRow3=function(){var t=[];return t.push(new n.DtoAOperation),t.push(new n.AtoDOperation),t.push(new n.XLimitOperation),t},i}(t);n.TransCalculator=f;e=function(t){function i(n,i,r,u){t.call(this,n,i,r,u)}return __extends(i,t),i.prototype.fillButtonPanel=function(n){this.addRow(this.buildRow0(),n);this.addRow(this.buildRow1(),n);this.addRow(this.buildRow2(),n)},i.prototype.buildRow0=function(){var t=[];return t.push(new n.SinOperation),t.push(new n.AsinOperation),t.push(new n.CosOperation),t.push(new n.AcosOperation),t},i.prototype.buildRow1=function(){var t=[];return t.push(new n.TanOperation),t.push(new n.AtanOperation),t.push(new n.SinhOperation),t.push(new n.AsinhOperation),t},i.prototype.buildRow2=function(){var t=[];return t.push(new n.CoshOperation),t.push(new n.AcoshOperation),t.push(new n.TanhOperation),t.push(new n.AtanhOperation),t},i}(t);n.TrigCalculator=e;o=function(t){function i(n,i,r,u){t.call(this,n,i,r,u)}return __extends(i,t),i.prototype.fillButtonPanel=function(n){this.addRow(this.buildRow0(),n);this.addRow(this.buildRow1(),n);this.addRow(this.buildRow2(),n)},i.prototype.buildRow0=function(){var t=[];return t.push(new n.AndOperation),t.push(new n.OrOperation),t.push(new n.NotOperation),t.push(new n.XorOperation),t},i.prototype.buildRow1=function(){var t=[];return t.push(new n.GtOperation),t.push(new n.LtOperation),t.push(new n.GeOperation),t.push(new n.LeOperation),t},i.prototype.buildRow2=function(){var t=[];return t.push(new n.EqOperation),t.push(new n.NeOperation),t.push(new n.EmptyOperation),t.push(new n.EmptyOperation),t},i}(t);n.LogicCalculator=o}(Operations||(Operations={})),function(n){var t=function(){function t(t){this.tabHeight=0;this.defaultPanelCategory=n.Category.CAT_LEVEL;this.currentPanelIndex=-1;this.panelArray=[];this.initOptionDialog=!1;this.useDefaultOptionsFlag=!0;this.waveContainer=t;this.createWindow();$.fn.qtip.zindex=60100}return t.prototype.getWaveContainer=function(){return this.waveContainer},t.prototype.setWaveContainer=function(n){this.waveContainer=n},t.prototype.useDefaultOptions=function(n){this.useDefaultOptionsFlag=n},t.prototype.areDefaultOptions=function(){return this.useDefaultOptionsFlag},t.prototype.getCurrentPostfix=function(){return WaveViewer.getManager().isWindowMode()?"_docked":"_undocked"},t.prototype.getCurrentPanel=function(){return this.panelArray&&this.panelArray.length>0?this.panelArray[this.currentPanelIndex]:null},t.prototype.createWindow=function(){var i=this,e=function(){i.tabPanel.resize();i.updateToolCombo()},c={visible:!0,title:t.TOOL_DIALOG_TITLE,modal:!1,resizable:!1,width:t.DIALOG_WIDTH,height:t.DIALOG_HEIGHT,resize:e,actions:["Close"],dragend:function(){i.reopenOptionDialog()},position:{top:0,left:0}},f,o,r,u,s,h;this.dialog=$("<div id='"+t.TOOL_DIALOG_ID+this.getCurrentPostfix()+"'><\/div>").appendTo(document.body).kendoWindow(c).data("kendoWindow");this.toolDialogWrapper=this.dialog.wrapper;this.dialog.wrapper.bind("resize",e);f='<div id = "'+t.TOOL_CONTENT_ID+this.getCurrentPostfix()+'" style="width: 100%; height: 100%; overflow: hidden;">';f+="<\/div>";this.dialog.content(f);this.toolDialogWrapper.find(".k-window-titlebar, .k-window-actions, .k-window-title").css("font-size",t.FONT_SIZE);this.toolDialogWrapper.find(".k-window-content.k-content").css("padding","0");this.dialog.bind("close",function(n){n.userTriggered&&n.preventDefault()});o=this.toolDialogWrapper.find(".k-i-close");o.click(function(){i.close()});r=n.ToolUtils.createElement("div",null,$("#"+t.TOOL_CONTENT_ID+this.getCurrentPostfix()),null);u=n.ToolUtils.createElement("ul",null,r,null);u.css({"line-height":"none","font-size":t.FONT_SIZE});this.tabHeight=u.height();s=function(){var t=i.getCurrentPanel(),n;t&&t.selectButton();i.updateToolCombo();i.setToolControlState();i.optionsDialog&&i.optionsDialog.isOpened()&&(n=i.getCurrentPanel(),n&&i.optionsDialog.updateContent(n.toolOperation))};h=function(n){i.toolControlState=i.getCurrentPanel().getToolControlState();i.currentPanelIndex=$(n.item).index();i.updateToolTitle()};this.generateTabPanels(u,r);r.kendoTabStrip({tabPosition:"bottom",animation:!1,select:h,activate:s});this.tabPanel=r.data("kendoTabStrip");this.setStyle();this.dialog.wrapper.css("z-index","60000");this.currentPanelIndex==-1&&(this.currentPanelIndex=this.findDefaultPanel())},t.prototype.setToolControlState=function(){this.toolControlState&&this.getCurrentPanel().setToolControlState(this.toolControlState)},t.prototype.close=function(){this.dialog&&this.dialog.close();this.optionsDialog&&this.optionsDialog.isOpened()&&this.optionsDialog.close()},t.prototype.findDefaultPanel=function(){for(var n=0;n<this.panelArray.length;n++)if(this.panelArray[n].category.id==this.defaultPanelCategory)return n;return 0},t.prototype.updateToolTitle=function(){var n=this.getCurrentPanel(),i=n?n.category.getPanelName()+" Operations":t.TOOL_DIALOG_TITLE;this.dialog.title(i)},t.prototype.openOptionDialog=function(t){this.canOpenOptions()&&(this.optionsDialog||(this.optionsDialog=new n.OptionsDialog(t)),this.optionsDialog.isOpened()||this.optionsDialog.open())},t.prototype.canOpenOptions=function(){return this.waveContainer&&!this.waveContainer.isEmpty()},t.prototype.reopenOptionDialog=function(){this.optionsDialog&&this.optionsDialog.isOpened()&&this.optionsDialog.open()},t.prototype.updateToolCombo=function(){for(var t,n=0;n<this.panelArray.length;n++)t=this.panelArray[n],t.toolCombo&&t.toolCombo.updateCombos(),t.onResize()},t.prototype.setSourceWaveform=function(n){for(var i,t=0;t<this.panelArray.length;t++)i=this.panelArray[t],i.toolCombo&&i.toolCombo.setInitialWaveform(n),i.onResize()},t.prototype.generateTabPanels=function(t,i){var u=[],o,r,f,e,s,h;for(u.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),u.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),u.push(n.ToolUtils.getCategory(n.Category.CAT_CALCULATOR)),u.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),u.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),r=0;r<u.length;r++)f=u[r],o=t.append("<li>"+f.getTabName()+"<\/li>");for(this.tabHeight=24,r=0;r<u.length;r++)f=u[r],e=n.ToolUtils.createElement("div","",i,null),f.isCalcCategory()?s=n.CalculatorPanel.getCalculatorPanel(this,f,e,r):h=new n.MeasurementPanel(this,f,e,r)},t.prototype.setStyle=function(){this.toolDialogWrapper.find("."+t.TOOL_PANEL_BUTTON_CLASS).css("font-size",t.FONT_SIZE);t.setToolStyle(this.toolDialogWrapper)},t.setToolStyle=function(n){n.find("span.k-link").css("padding","3px");n.find("."+t.TOOL_ICON_BUTTON_CLASS).css("margin-left","5px");n.find("."+t.TOOL_LEFT_COLUMN_CLASS).css("margin-top","10px").css("margin-left","5px").width(t.LEFT_COLUMN_WIDTH);n.find("."+t.TOOL_RIGHT_COLUMN_CLASS).not(".k-dropdown").css("margin-top","10px").css("margin-right","5px").width(t.ADVANCE_FIELD_WIDTH);t.setComboStyle(n);t.setLabelStyle(n);t.setButtonStyle(n);t.setInputStyle(n)},t.setInputStyle=function(n){n.find("input").css("font-size",t.FONT_SIZE).css("height",t.FONT_SIZE).css("border-radius","0px").css("padding-top","0px")},t.setLabelStyle=function(n){n.find("label").css("font-size",t.FONT_SIZE)},t.setButtonStyle=function(n){n.find("button").css("font-size",t.FONT_SIZE)},t.setComboStyle=function(n){n.find(".k-dropdown-wrap").css("height","14px").css("border-radius","0px");n.find(".k-input").css("font-size",t.FONT_SIZE).css("padding-top","1px").css("height",t.FONT_SIZE).css("line-height",t.FONT_SIZE);n.find(".k-select").css("line-height","none").css("min-height",t.FONT_SIZE);n.find(".k-icon").css("vertical-align","top")},t.prototype.isOpened=function(){return this.dialog?this.dialog.element.is(":hidden")?!1:!0:!1},t.prototype.open=function(n){var i=this,t;this.updateToolCombo();n&&this.setSourceWaveform(n);this.tabPanel.select(this.currentPanelIndex);t=this.getCurrentPanel().toolOperation;t&&setTimeout(function(){i.getCurrentPanel().toolCombo.setOperation(t.getButton(),t.getButton().getOperationType())},400);this.dialog.center().open()},t.prototype.selectNewWaveform=function(n){this.isOpened()&&(this.toolControlState=this.getCurrentPanel().getToolControlState(),n&&!this.isTheSameWaveform(n)&&this.setSourceWaveform(n))},t.prototype.isTheSameWaveform=function(n){var i=this.toolControlState.firstComboState.wf,t;return i&&n==i?!0:this.toolControlState.secondComboState&&(t=this.toolControlState.secondComboState.wf,t&&n==t)?!0:!1},t.prototype.addToToolWindow=function(n){this.panelArray.push(n)},t.TOOL_DIALOG_TITLE="Waveform Operations",t.TOOL_DIALOG_ID="WfOpTool_Dialog",t.TOOL_CONTENT_ID="WfOpTool_Dialog_Content",t.TOOL_PANEL_ID="WfOpTool_Dialog_Content_Panel",t.TOOL_ICON_BUTTON_CLASS="WfOpTool_Icon_Button",t.TOOL_LEFT_COLUMN_CLASS="WfOpTool_Left_Column",t.TOOL_RIGHT_COLUMN_CLASS="WfOpTool_Right_Column",t.TOOL_RADIO_BUTTON_CLASS="WfOpTool_radio_button",t.TOOL_RADIO_LABEL_CLASS="WfOpTool_radio_label",t.TOOL_PANEL_BUTTON_CLASS="WfOpTool_Panel_Button_class",t.TOOL_TOP_BOTTOM_DEFAULT="Default",t.PANEL_COUNT=0,t.DIALOG_WIDTH=332,t.DIALOG_HEIGHT=236,t.BUTTON_WIDTH=72,t.LEFT_COLUMN_WIDTH=t.BUTTON_WIDTH+"px",t.ADVANCE_FIELD_WIDTH=135,t.ADVANCE_DIALOG_WIDTH=235,t.FONT_SIZE="12px",t.IMAGE_SIZE="16px",t.DILOG_BORDER_COLOR="rgb(204, 204, 204)",t.opeartionChooserLabelName="?",t}();n.ToolWindow=t}(Operations||(Operations={})),function(n){var f,e,t,u,i,r;(function(n){n[n.FIRST=0]="FIRST";n[n.SECOND=1]="SECOND"})(n.WF_INDEX||(n.WF_INDEX={}));f=n.WF_INDEX,function(n){n[n.MEAS=0]="MEAS";n[n.INPUT=1]="INPUT"}(n.MARKER_MODE||(n.MARKER_MODE={}));e=n.MARKER_MODE,function(n){n[n.CAT_ROOT=0]="CAT_ROOT";n[n.CAT_HIDDEN=1]="CAT_HIDDEN";n[n.CAT_FREQUENCY=3]="CAT_FREQUENCY";n[n.CAT_GENERAL=4]="CAT_GENERAL";n[n.CAT_LEVEL=5]="CAT_LEVEL";n[n.CAT_STAT=6]="CAT_STAT";n[n.CAT_TIME=7]="CAT_TIME";n[n.CAT_CALCULATOR=8]="CAT_CALCULATOR";n[n.CAT_TRANS=9]="CAT_TRANS";n[n.CAT_TRIG=10]="CAT_TRIG";n[n.CAT_LOGIC=11]="CAT_LOGIC";n[n.CAT_INPUT=12]="CAT_INPUT"}(n.Category||(n.Category={}));t=n.Category;u=function(){function u(){}return u.initMeasurementList=function(){u.measurementList.length==0&&(u.measurementList.push(new n.AverageMeasurement),u.measurementList.push(new n.AmplitudeMeasurement),u.measurementList.push(new n.DutyCycleMeasurement),u.measurementList.push(new n.FalltimeMeasurement),u.measurementList.push(new n.FrequencyMeasurement),u.measurementList.push(new n.LevelCrossingMeasurement),u.measurementList.push(new n.LocalMaximumMeasurement),u.measurementList.push(new n.LocalMinimumMeasurement),u.measurementList.push(new n.MaximumMeasurement),u.measurementList.push(new n.MinimumMeasurement),u.measurementList.push(new n.OvershootMeasurement),u.measurementList.push(new n.PeakToPeakMeasurement),u.measurementList.push(new n.PeriodMeasurement),u.measurementList.push(new n.PulseWidthMeasurement),u.measurementList.push(new n.RisetimeMeasurement),u.measurementList.push(new n.RMSMeasurement),u.measurementList.push(new n.SettleTimeMeasurement),u.measurementList.push(new n.SlewRateMeasurement),u.measurementList.push(new n.SlopeMeasurementTime),u.measurementList.push(new n.UndershootMeasurement));u.inputMeasList.length==0&&(u.inputMeasList.push(new n.TopLine),u.inputMeasList.push(new n.BaseLine))},u.getCategoryList=function(){return this.categoryList.length==0&&(this.addToCatList(t.CAT_FREQUENCY,"Freq","Frequency-Domain",this.categoryList,n.OPERATION_TYPE.UNARY_OPERATION,!1,ServerStructures.MeasurementID.Slope),this.addToCatList(t.CAT_GENERAL,"General","General",this.categoryList,n.OPERATION_TYPE.UNARY_OPERATION,!1,ServerStructures.MeasurementID.Slope),this.addToCatList(t.CAT_LEVEL,"Level","Level",this.categoryList,n.OPERATION_TYPE.UNARY_OPERATION,!1,ServerStructures.MeasurementID.Average),this.addToCatList(t.CAT_STAT,"Stat","Statistical",this.categoryList,n.OPERATION_TYPE.UNARY_OPERATION,!1,ServerStructures.MeasurementID.Mean),this.addToCatList(t.CAT_TIME,"Time","Time-Domain",this.categoryList,n.OPERATION_TYPE.UNARY_OPERATION,!1,ServerStructures.MeasurementID.DutyCycle),this.addToCatList(t.CAT_CALCULATOR,"Calc","Calculator",this.categoryList,n.OPERATION_TYPE.BINARY_OPERATION,!0,n.CalcButtonId.BTN_ADD),this.addToCatList(t.CAT_TRANS,"Trans","Transformations",this.categoryList,n.OPERATION_TYPE.BINARY_OPERATION,!0,n.CalcButtonId.BTN_DIFFERENCIATE),this.addToCatList(t.CAT_LOGIC,"Logic","Logic",this.categoryList,n.OPERATION_TYPE.BINARY_OPERATION,!0,n.CalcButtonId.BTN_AND),this.addToCatList(t.CAT_TRIG,"Trig","Trigonometric",this.categoryList,n.OPERATION_TYPE.UNARY_OPERATION,!0,n.CalcButtonId.BTN_SIN),this.addToCatList(t.CAT_INPUT,"Input","Input",this.categoryList,n.OPERATION_TYPE.UNARY_OPERATION,!1,null)),this.categoryList},u.addToCatList=function(n,t,i,u,f,e,o){var s=new r(n,t,i,f,e,o);this.categoryList.push(s)},u.getCategory=function(n){for(var t,r=this.getCategoryList(),i=0;i<r.length;i++)if(t=r[i],t&&t.isCategory(n))return t;return null},u.getMeasurementByName=function(n){var t;for(u.initMeasurementList(),t=0;t<u.inputMeasList.length;t++)if(u.inputMeasList[t].getName()==n)return this.createMeasurementByClassName(u.inputMeasList[t].className);for(t=0;t<u.measurementList.length;t++)if(u.measurementList[t].getName()==n)return this.createMeasurementByClassName(u.measurementList[t].className);return null},u.createMeasurementByClassName=function(t){if(!t)return null;var i=Object.create(window[n.BaseMeasurement.MODULE_NAME][t].prototype);return new i.constructor},u.createMeasurementById=function(n){if(!n)return null;u.initMeasurementList();for(var t=0;t<u.measurementList.length;t++)if(u.measurementList[t].measurementId==n)return this.createMeasurementByClassName(u.measurementList[t].className);return null},u.getMeasurementNameById=function(n){if(!n)return null;u.initMeasurementList();for(var t=0;t<u.measurementList.length;t++)if(u.measurementList[t].measurementId==n)return u.measurementList[t].measurementName;return null},u.createEdgeGroupForEdge=function(t,r,f,e){var s,h;e===void 0&&(e=!1);var o=[],c=e?n.ToolTooltips.SLEWRATE_EDGE_TRIGGER_ANY:n.ToolTooltips.EDGE_TRIGGER_ANY,l=e?n.ToolTooltips.SLEWRATE_EDGE_TRIGGER_RISE:n.ToolTooltips.EDGE_TRIGGER_RISE,a=e?n.ToolTooltips.SLEWRATE_EDGE_TRIGGER_FALL:n.ToolTooltips.EDGE_TRIGGER_FALL,v=new i("RiseFallEdge.gif",ServerStructures.Trigger.EITHER.toString(),c,!0);return o.push(v),s=new i("RisingEdge.gif",ServerStructures.Trigger.RISING.toString(),l),o.push(s),h=new i("FallingEdge.gif",ServerStructures.Trigger.FALLING.toString(),a),o.push(h),u.createRadioButtonsGroup(t,r,f,o)},u.createEdgeGroupForCross=function(t,r,f){var e=[],h=new i("RiseFallEdge.gif",ServerStructures.Trigger.EITHER.toString(),n.ToolTooltips.SLOPE_ANY,!0),o,s;return e.push(h),o=new i("RisingEdge.gif",ServerStructures.Trigger.RISING.toString(),n.ToolTooltips.SLOPE_POS),e.push(o),s=new i("FallingEdge.gif",ServerStructures.Trigger.FALLING.toString(),n.ToolTooltips.SLOPE_NEG),e.push(s),u.createRadioButtonsGroup(t,r,f,e)},u.checkTriggerButton=function(n,t){var i,r;if(t)for(i=0;i<t.length;i++)r=t[i],r.prop("checked",i==n)},u.getCheckedTriggerButton=function(n){var t,i;if(n)for(t=0;t<n.length;t++)if(i=n[t],i.prop("checked"))return i;return null},u.createElement=function(n,t,i,r,u,f){var e,o;return u===void 0&&(u="text"),e=document.createElement(n),t&&(e.id=t),n=="input"?e.type=u:n=="img"&&(e.src=f),r&&e.classList.add(r),o=$(e),i.append(e),o},u.createRadioButtonsGroup=function(t,i,r,f){var c=[],l=u.GLOBAL_TOOL_UTILS_COUNT++,p="Tool_Utils_Radio_Group_"+l,a="Tool_Utils_Label_"+l,o=u.createElement("div",p,t,null),v=this.createLabel(a,null,o,i,r,n.ToolWindow.TOOL_LEFT_COLUMN_CLASS),e;for(v.css("margin-top","10px"),v.css("margin-right","10px"),e=0;e<f.length;e++){var y=a+"icon"+e,s=f[e],h=u.createRadioInput(y,i,o,n.ToolWindow.TOOL_ICON_BUTTON_CLASS,s.isDefault);h.addClass(n.ToolWindow.TOOL_RADIO_BUTTON_CLASS);h.val(s.value);u.createRadioImg(s,y,o);c.push(h)}return c},u.createRadioImg=function(t,i,r){var e="/Content/images/"+t.img,f=i+"label",o='<label id="'+f+'" class="'+n.ToolWindow.TOOL_RADIO_LABEL_CLASS+'" for="'+i+'" > <img src="'+e+'" > <\/label>';r.append(o);$("#"+f).qtip({content:function(){return t.tooltip?t.tooltip:""},position:{my:"bottom right",at:"top left"},style:{classes:"svw-tooltip"},show:{delay:u.TOOLTIP_DELAY}});$("#"+f).css("margin-right","10px")},u.createRadioInput=function(n,t,i,r,u){var f=document.createElement("input"),e;return n&&(f.id=n),f.type="radio",f.name=t,f.checked=u,r&&f.classList.add(r),e=$(f),i.append(f),e},u.createLabel=function(n,t,i,r,f,e){var o=u.createElement("label",n,i,e);return f&&o.qtip({content:function(){return f?f:""},position:{my:"bottom right",at:"top left"},style:{classes:"svw-tooltip"},show:{delay:u.TOOLTIP_DELAY}}),t&&o.attr("for",t),o.html(r),o},u.addValidateInputListener=function(n,t){function u(){t.toolCombo.validate()}var i,r=2e3;n.keydown(function(){clearTimeout(i);i=setTimeout(u,r)})},u.getInputError=function(t){var i=t.val(),r,u;return i==null?n.ToolMessages.IS_EMPTY:i.trim()==""?n.ToolMessages.IS_EMPTY:(r=new Project.PropertyFormatter,u=r.ValidateInputValue("real",i),u.match("^Invalid"))?n.ToolMessages.NOT_NUMBER:null},u.createInputField=function(t,i,r){var e=u.createElement("div",null,t,null),o=u.GLOBAL_TOOL_UTILS_COUNT++,s="Tool_Utils_Input_"+o,h="Tool_Utils_Label_"+o,f;return this.createLabel(h,s,e,i,r,n.ToolWindow.TOOL_LEFT_COLUMN_CLASS),f=u.createElement("input",s,e,n.ToolWindow.TOOL_RIGHT_COLUMN_CLASS),f.css({"vertical-align":"text-bottom"}),f},u.createCheckbox=function(n,t,i,r){var e=u.createElement("div",null,n,null),o=u.GLOBAL_TOOL_UTILS_COUNT++,f;e.css({"margin-top":"10px"});var s="Tool_Utils_Input_"+o,h="Tool_Utils_Label_"+o,c=this.createLabel(h,s,e,t,i,null);return c.css({"margin-left":"5px"}),f=u.createElement("input",s,e,null,"checkbox"),f.css({"margin-left":"5px"}),r&&f.prop("checked",!0),f},u.getWfExpression=function(n){return"[["+n.simulationId+"."+n.getWaveformHandle()+"]]"},u.createDropDownList=function(t,i,r,f){var p,h,e,c;f===void 0&&(f=null);var o=u.GLOBAL_TOOL_UTILS_COUNT++,a="Tool_Utils_Label_"+o,s="Tool_Utils_Combo_"+o,v="Tool_Utils_Div_"+o,l=u.createElement("div",v,t,null),y=this.createLabel(a,s,l,i,f,n.ToolWindow.TOOL_LEFT_COLUMN_CLASS);for(y.css({"margin-top":"10px"}),p=u.createElement("div",s,l,null),h=[],e=0;e<r.length;e++)h.push({text:r[e],value:""+e});return c=$("#"+s).kendoDropDownList({dataTextField:"text",dataValueField:"value",dataSource:h,index:0}).data("kendoDropDownList"),c.wrapper.width(n.ToolWindow.ADVANCE_FIELD_WIDTH),c},u.createButton=function(n,t){var r=u.GLOBAL_TOOL_UTILS_COUNT++,f="Tool_Utils_Button_"+r,e="Tool_Utils_Div_"+r,o=u.createElement("div",e,n,null),i=u.createElement("button",f,o,null),s;return i.html(t),s=i.kendoButton().data("kendoButton"),i},u.createInputControls=function(t,i){var e=t.getArguments(),r=e.arg1.wf,u,f;return r?(u=new n.InputControl((new n.TopLine).getName(),i,t,[n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT],n.TopLine.TOPLINE_TOOLTIP,r),f=new n.InputControl((new n.BaseLine).getName(),i,t,[n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT],n.BaseLine.BASELINE_TOOLTIP,r),{topControl:u,baseControl:f}):{topControl:null,baseControl:null}},u.convertToNumber=function(n){var i=new Project.PropertyFormatter,t=i.SIUnitPrefixes2Double(n);return isNaN(t)?0:t},u.replace=function(n,t,i,r){if(r===void 0&&(r=!1),n==null||t==null||i==null||t.length==0)return n;var u=r?"gi":"g",f=t.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");return n.replace(new RegExp(f,u),i)},u.GLOBAL_TOOL_UTILS_COUNT=0,u.TOOLTIP_DELAY=500,u.measurementList=[],u.inputMeasList=[],u.categoryList=[],u.functionList=[],u}();n.ToolUtils=u;i=function(){function n(n,t,i,r){r===void 0&&(r=!1);this.isDefault=!1;this.img=n;this.value=t;this.tooltip=i;this.isDefault=r}return n}();n.RadioDescription=i;r=function(){function t(t,i,r,u,f,e){this.operations=[];this.measClass="bbb";this.classInfo="";this.isCalculatorCategory=!1;this.defaultOpType=n.OPERATION_TYPE.UNARY_OPERATION;this.tabName=i;this.panelName=r;this.id=t;this.defaultOpType=u;this.isCalculatorCategory=f;this.selectedOperationId=e}return t.prototype.getTabName=function(){return this.tabName},t.prototype.getPanelName=function(){return this.panelName},t.prototype.isCategory=function(n){return this.id==n},t.prototype.getParent=function(){return null},t.prototype.getChildren=function(){return null},t.prototype.isCalcCategory=function(){return this.isCalculatorCategory},t}();n.ToolCategory=r}(Operations||(Operations={})),function(n){var t=function(){function t(n){n===void 0&&(n=null);this.keepDialogOpen=!0;this.createDialog();this.toolPanel=n}return t.prototype.createDialog=function(){var u={visible:!1,title:"Options",modal:!1,resizable:!0,width:t.DIALOG_WIDTH,height:t.DIALOG_HEIGHT,actions:["Close"],animation:{open:{effects:"slideIn:right fadeIn",duration:1e3},close:{effects:"slide:left fadeOut"}}},i,r;this.dialog=$("<div id='"+t.OPTIONS_DIALOG_ID+"'><\/div>").appendTo(document.body).kendoWindow(u).data("kendoWindow");this.dialog.content("<div id='"+t.OPTIONS_DIALOG_CONTENT_ID+"'><\/div>");this.optionsDialogWrapper=this.dialog.wrapper;this.optionsDialogWrapper.css("z-index",t.Z_INDEX);this.dialogContent=$("#"+t.OPTIONS_DIALOG_CONTENT_ID);this.optionsDialogWrapper.find(".k-window-titlebar, .k-window-actions, .k-window-title").css("font-size",n.ToolWindow.FONT_SIZE);this.optionsDialogWrapper.find(".k-window-content.k-content").css("padding","0");i=this;this.dialog.bind("close",function(n){i.keepDialogOpen&&n.preventDefault()});r=this.dialog.wrapper.find(".k-i-close");r.click(function(){i.closeInternal()});this.setStyle()},t.prototype.closeInternal=function(){this.toolPanel.areDefaultOptions()?this.clearAndClose():this.testForDefault()},t.prototype.clearAndClose=function(){this.keepDialogOpen=!1;this.toolPanel.setPreviousToolOperation();this.setToDefault();this.toolPanel.toolCombo.validate();this.dialog.close()},t.prototype.testForDefault=function(){var t=this;this.keepDialogOpen=!0;var i=this.toolPanel.toolOperation.getName()+" Options",r=n.ToolMessages.getMessage(n.ToolMessages.CONFIRM_MESSAGE,i),u=new Project.MultiBtnModalDialog("Confirm",r,["Yes","Cancel"]);jQuery.when(u.queryUser()).done(function(n){n==Project.BUTTON.BTN1&&t.clearAndClose()})},t.prototype.open=function(){var n=this.toolPanel.toolWindow.toolDialogWrapper,i=n.position(),t=$(window).width()-(n.offset().left+n.width()+this.optionsDialogWrapper.width())>0;t?this.showOnRight(n):this.showOnLeft(n);this.dialog.open()},t.prototype.showOnLeft=function(n){var t=n.position(),i=t.top,r=t.left-this.optionsDialogWrapper.width();this.optionsDialogWrapper.closest(".k-window").css({top:i,left:r});this.dialog.refresh({open:{effects:"slideIn:left fadeIn"}})},t.prototype.showOnRight=function(n){var t=n.position(),i=t.top,r=t.left+n.width();this.optionsDialogWrapper.closest(".k-window").css({top:i,left:r});this.dialog.refresh({open:{effects:"slideIn:right fadeIn"}})},t.prototype.isOpened=function(){return!this.dialog.element.is(":hidden")},t.prototype.close=function(){this.clearAndClose()},t.prototype.updateContent=function(i){var u=this,r;if(this.dialogContent.empty(),!i){this.close();return}if(!i.hasOptions()){this.close();return}this.toolPanel=this.toolPanel.toolWindow.getCurrentPanel();this.toolPanel.toolCombo.setComboError(null);i.createOptionPanel(this.toolPanel,this.dialogContent);this.toolPanel.toolWindow.useDefaultOptions(!0);r=n.ToolUtils.createButton(this.dialogContent,"Default");r.css("position","fixed").css("bottom","10px").css("right","10px");r.click(function(){u.setToDefault()});this.dialog.title(i.getName()+" Options");this.setStyle();this.dialog.wrapper.css("z-index",t.Z_INDEX)},t.prototype.setToDefault=function(){this.toolPanel.setToDefault()},t.prototype.setStyle=function(){this.optionsDialogWrapper.find("."+n.ToolWindow.TOOL_ICON_BUTTON_CLASS).css("margin-left","5px");this.optionsDialogWrapper.find("."+n.ToolWindow.TOOL_LEFT_COLUMN_CLASS).css("margin-top","10px").css("margin-left","5px").width(n.ToolWindow.LEFT_COLUMN_WIDTH);this.optionsDialogWrapper.find("."+n.ToolWindow.TOOL_RIGHT_COLUMN_CLASS).not(".k-dropdown").css("margin-top","10px").css("margin-right","5px").width(n.ToolWindow.ADVANCE_FIELD_WIDTH);n.ToolWindow.setToolStyle(this.optionsDialogWrapper)},t.OPTIONS_DIALOG_COUNT=0,t.OPTIONS_DIALOG_ID="Tool_Options_Dialog",t.OPTIONS_DIALOG_CONTENT_ID="Tool_Options_Dialog_Content",t.RANGE_COMBO_NAME="Apply to:",t.RANGE_COMBO_TOOLTIP=n.ToolTooltips.APPLY_TO,t.RESULTS_COMBO_NAME="Results:",t.RESULTS_COMBO_TOOLTIP=n.ToolTooltips.RESULTS,t.TOOL_RESULT_MARKERS="Markers",t.TOOL_RESULT_WAVEFORM="Waveform",t.TOOL_RESULT_LIST=[t.TOOL_RESULT_MARKERS,t.TOOL_RESULT_WAVEFORM],t.TOOL_RANGE_ENTIRE_WAVEFORM="Entire Waveform",t.TOOL_RANGE_VISIBLE_RANGE="Visible X Range",t.TOOL_RANGE_LIST=[t.TOOL_RANGE_ENTIRE_WAVEFORM,t.TOOL_RANGE_VISIBLE_RANGE],t.DIALOG_WIDTH=247,t.DIALOG_HEIGHT=219,t.INPUT_WIDTH=127,t.Z_INDEX="60100",t}();n.OptionsDialog=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(){function t(t,i,r,u,f,e,o){this.showImage=!0;this.isZero=!1;this.isEmpty=!1;this.isEditable=!1;this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.tooltip=e;this.id=t;this.label=u;this.imageUrl=f;this.buttonType=i;this.operationLabel=r;this.showImage=o}return t.prototype.addButtonTooltip=function(){$("#"+this.id).qtip({content:this.tooltip,position:{my:"bottom right",at:"center"},style:{classes:"svw-tooltip"},show:{delay:t.TOOLTIP_DELAY}})},t.prototype.isOperation=function(){return this.buttonType==n.OPERATION_TYPE.UNARY_OPERATION||this.buttonType==n.OPERATION_TYPE.BINARY_OPERATION},t.prototype.setOperation=function(n){this.toolOperation=n;this.isEditable=n.useNumbers()},t.prototype.getOperation=function(){return this.toolOperation},t.prototype.getOperationType=function(){return this.isOperation()?this.buttonType:n.OPERATION_TYPE.NUMBER},t.initFunctionList=function(){n.ToolUtils.functionList.length==0&&n.ToolUtils.functionList.push(new n.Num0Operation)},t.CALC_BUTTON_ID="Calculator_Button_",t.MEAS_BUTTON_ID="Measurement_Button_",t.GLOBAL_BUTTON_COUNT=0,t.TOOLTIP_DELAY=1e3,t}(),i,r,u,f,e,o;n.ToolButton=t;i=function(t){function i(n,i,r,u,f,e,o){t.call(this,n,i,r,u,f,e,!1);this.setOperation(o)}return __extends(i,t),i.prototype.addToPanel=function(t,i){var u,r,f,e;return this.toolPanel=i,u=n.ToolUtils.createElement("button",this.id,t,n.ToolWindow.TOOL_PANEL_BUTTON_CLASS),u.css({color:"black"}),u.css({"margin-right":"3px"}),u.css({padding:"1px"}),u.width(n.ToolWindow.BUTTON_WIDTH),this.label&&u.html(this.label),r=this,f={click:function(t){var i=t.event.target,e=$(i).text(),f,u;$("#"+r.toolPanel.selectedButtonId).removeClass(n.ToolPanel.TOOL_BUTTON_SELECTED_CLASS);r.toolPanel.selectedButtonId=i.id;$("#"+r.toolPanel.selectedButtonId).addClass(n.ToolPanel.TOOL_BUTTON_SELECTED_CLASS);f=t.sender.element[0].id;r.isOperation()&&r.toolPanel.toolCombo&&(u=r.getOperationType(),r.toolPanel.toolCombo.setOperation(r,u),r.toolPanel.toolCombo.blinkGreenButton())}},this.imageUrl&&(f.imageUrl="/Content/images/calculator/"+this.imageUrl),e=u.kendoButton(f).data("kendoButton"),this.addButtonTooltip(),u},i}(t);n.MeasButton=i;r=function(t){function i(n,i,r,u,f,e,o,s){t.call(this,n,i,r,u,f,e,s);this.setOperation(o)}return __extends(i,t),i.prototype.addToPanel=function(t,i){var u,r,f,e;this.toolPanel=i;u=n.ToolUtils.createElement("button",this.id,t,n.ToolWindow.TOOL_PANEL_BUTTON_CLASS);this.isZero?u.width(n.CalculatorPanel.NORMAL_BUTTON_WIDTH*2+3):this.isEmpty?(u.height(n.CalculatorPanel.BUTTON_HEIGHT),u.width(n.CalculatorPanel.NORMAL_BUTTON_WIDTH)):u.width(n.CalculatorPanel.NORMAL_BUTTON_WIDTH);u.css({color:"black"});u.css({"margin-right":"3px"});this.label&&u.html(this.label);r=this;f={click:function(t){var u=t.sender.element[0].id,i;r.isOperation()?($("#"+r.toolPanel.selectedButtonId).removeClass(n.ToolPanel.TOOL_BUTTON_SELECTED_CLASS),r.toolPanel.selectedButtonId=u,$("#"+r.toolPanel.selectedButtonId).addClass(n.ToolPanel.TOOL_BUTTON_SELECTED_CLASS),r.toolPanel.toolCombo&&(i=r.getOperationType(),r.toolPanel.toolCombo.setOperation(r,i),r.toolPanel.toolCombo.blinkGreenButton())):r.toolPanel.toolCombo&&(i=r.getOperationType(),r.toolPanel.toolCombo.setOperation(r,i))}};this.imageUrl&&(f.imageUrl="/Content/images/calculator/"+this.imageUrl);e=u.kendoButton(f).data("kendoButton");this.addButtonTooltip()},i}(t);n.CalcButton=r;u=function(n){function i(i,r,u,f,e,o){var s=t.MEAS_BUTTON_ID+i+t.GLOBAL_BUTTON_COUNT++;n.call(this,s,r,u,f,null,e,o)}return __extends(i,n),i}(i);n.MeasLabelButton=u;f=function(n){function i(i,r,u,f,e,o,s){var h=t.CALC_BUTTON_ID+i+t.GLOBAL_BUTTON_COUNT++;n.call(this,h,r,u,f,null,e,o,s)}return __extends(i,n),i}(r);n.CalcLabelButton=f;e=function(n){function i(i,r,u,f,e,o){var s=t.MEAS_BUTTON_ID+i+t.GLOBAL_BUTTON_COUNT++;n.call(this,s,r,u,null,f,e,o)}return __extends(i,n),i}(i);n.MeasImageButton=e;o=function(n){function i(i,r,u,f,e,o,s){var h=t.CALC_BUTTON_ID+i+t.GLOBAL_BUTTON_COUNT++;n.call(this,h,r,u,null,f,e,o,s)}return __extends(i,n),i}(r);n.CalcImageButton=o}(Operations||(Operations={})),function(n){var t=function(){function t(n){this.measurements=[];this.waveContainer=n}return t.prototype.clear=function(){this.measurements=[]},t.prototype.restoreWaveformMeasurements=function(t){for(var f,e=this,i=$.Deferred(),r=new ServerStructures.MeasurementRequest,u=0;u<t.length;u++)f=t[u],f&&f.addRequest(r);return this.waveContainer.showSpinner(),$.when(WaveViewer.ViewerRequests.createAndInitMeasurements(r)).done(function(u){var a,o,s,l;for(u||(a=new n.MeasRes,i.resolve()),o=0;o<u.length;o++){var h=r.MeasRequests[o],c=u[o],f=t[o];h.ReturnType==ServerStructures.ReturnType.LIST?(f.setResults(c.MeasurementValues),f.markerManager||(f.markerManager=new n.MeasMarkerManager(f)),f.restoredMarkerStates&&f.restoredMarkerStates.length!=0&&(f.markerManager.restoreMarkers(f.restoredMarkerStates),f.restoredMarkerStates=null)):h.ReturnType==ServerStructures.ReturnType.WAVEFORM&&(s=c.MeasurementWaveform,l=WaveViewer.WdbInfo.getExpressionWdbId(),e.waveContainer.getViewerWindow().plotWaveformByHandle(s.Metadata.ResultId,s.Metadata.Handle,l,null,!1))}e.waveContainer.hideSpinner();i.resolve()}),i.promise()},t.prototype.updateMarkers=function(){for(var t,n=0;n<this.measurements.length;n++)t=this.measurements[n].markerManager,t&&this.measurements[n].markerManager.updateMarkers()},t.prototype.updateWaveformMarkers=function(n){for(var t=0;t<this.measurements.length;t++)(this.measurements[t].wf==n||this.measurements[t].wf2==n)&&this.measurements[t].markerManager.updateWaveformMarkers(n)},t.prototype.removeWaveformMeasurements=function(n,t){var i,r;if(n&&!n.isEmptyWaveform()){for(i=this.measurements.length-1;i>=0;i--)r=this.measurements[i],r.wf==n&&(r.markerManager&&r.markerManager.removeMarkers(),this.measurements.splice(i,1),r=null);t&&n.updateMenu()}},t.prototype.removeMeasurement=function(n){for(var t,r=n.wf,u=n.wf2,i=this.measurements.length-1;i>=0;i--)t=this.measurements[i],t==n&&(t.markerManager&&t.markerManager.removeMarkers(),this.measurements.splice(i,1),t=null,r&&r.updateMenu(),u&&u!=r&&u.updateMenu())},t.prototype.hasWaveformMeasurementWithMarkers=function(n){for(var i,t=0;t<this.measurements.length;t++)if(i=this.measurements[t],i.wf==n&&i.hasMarkers)return!0;return!1},t.prototype.getWaveformMeasurements=function(n){for(var t,r=[],i=0;i<this.measurements.length;i++)t=this.measurements[i],t.wf==n&&t.hasMarkers&&r.push(t);return r},t.prototype.addMeasurement=function(n){if(n&&(this.measurements.push(n),n.hasMarkers)){var t=n.wf,i=n.wf2;t&&t.updateMenu();i&&i!=t&&i.updateMenu()}},t}();n.ContainerMeasManager=t}(Operations||(Operations={})),function(n){var o,t,i,r,u,f,e;(function(n){n[n.POINT=0]="POINT";n[n.VERTICAL_DELTA=1]="VERTICAL_DELTA";n[n.HORIZONTAL_DELTA=2]="HORIZONTAL_DELTA";n[n.VERTICAL_RANGE=3]="VERTICAL_RANGE";n[n.HORIZONTAL_RANGE=4]="HORIZONTAL_RANGE";n[n.VERTICAL_LEVEL=5]="VERTICAL_LEVEL";n[n.HORIZONTAL_LEVEL=6]="HORIZONTAL_LEVEL";n[n.OVER_UNDER=7]="OVER_UNDER"})(n.MARKER_TYPE||(n.MARKER_TYPE={}));o=n.MARKER_TYPE,function(n){n[n.FIRST=0]="FIRST";n[n.SECOND=1]="SECOND"}(n.POINT_INDEX||(n.POINT_INDEX={}));t=n.POINT_INDEX,function(n){n[n.LEFT=0]="LEFT";n[n.RIGHT=1]="RIGHT";n[n.TOP=2]="TOP";n[n.BOTTOM=3]="BOTTOM"}(n.POINT_POSITION||(n.POINT_POSITION={}));i=n.POINT_POSITION;r=function(){function n(t,i,r){this.markerObjects=[];this.markerArtefacts=[];this.resultIndex=0;this.isShown=!1;this.markerId="measurement_marker"+n.GLOBAL_MARKER_ID++;this.waveContainer=t.waveContainer;this.measurementText=i;this.resultIndex=r;this.markerManager=t;n.HIGHLIGHT_COLOR=WaveViewer.SVW_Colors.getCursorHighliteLineColor(this.waveContainer)}return n.prototype.getWaveform=function(n){return(n===void 0&&(n=Operations.WF_INDEX.FIRST),n==Operations.WF_INDEX.SECOND)?this.markerManager.measurement.wf2:this.markerManager.measurement.wf},n.prototype.getMarkerDefaultColor=function(){return this.markerManager.isInputControl()?n.INPUT_COLOR:n.MARKER_COLOR},n.prototype.update=function(){for(var n=0;n<this.markerObjects.length;n++)this.markerObjects[n].update();for(n=0;n<this.markerArtefacts.length;n++)this.markerArtefacts[n].remove();this.markerArtefacts=[]},n.prototype.remove=function(){var n;for(this.removeMenu(!0),n=0;n<this.markerObjects.length;n++)this.markerObjects[n].remove();for(this.markerObjects=[],n=0;n<this.markerArtefacts.length;n++)this.markerArtefacts[n].remove();this.markerArtefacts=[]},n.prototype.getMeasText=function(){return this.measurementText},n.prototype.showRange=function(){this.markerManager.measurement.showRange()},n.prototype.hideRange=function(){this.markerManager.measurement.hideRange()},n.prototype.show=function(){for(var t,n=0;n<this.markerObjects.length;n++)this.markerObjects[n].show();for(t=0;t<this.markerArtefacts.length;t++)this.markerArtefacts[t].show();this.setShown(!0)},n.prototype.hide=function(){for(var t,n=0;n<this.markerObjects.length;n++)this.markerObjects[n].hide();for(t=0;t<this.markerArtefacts.length;t++)this.markerArtefacts[t].hide();this.setShown(!1)},n.prototype.setShown=function(n){this.isShown=n},n.prototype.createMenu=function(){if(!this.markerMenu){var n=new SVWebContextMenu.MenuContent(this);n.addMenuElement("Copy Text",function(n){var t=n.getMeasText();WaveViewer.WaveUtils.copyToClipboard(t)});this.markerManager.isInputControl()||n.addMenuElement("Delete",function(n){var t=n.markerManager.measurement;t.waveContainer.removeMeasurement(t)});this.markerMenu=SVWebContextMenu.MenuHelper.createMenu(n)}},n.prototype.setMenu=function(){this.createMenu();this.bindMenu()},n.prototype.bindMenu=function(){var n,t;this.markerMenu&&(n=this.getMarkerLine(),n&&this.markerMenu.bindMenuTo($("#"+n.markerObjectId)),t=this.getTextObject(),t&&this.markerMenu.bindMenuTo($("#"+t.markerObjectId)))},n.prototype.removeMenu=function(n){this.markerMenu&&this.unbindMenu(n);this.markerMenu&&(this.markerMenu.removeMenu(),this.markerMenu=null)},n.prototype.unbindMenu=function(n){this.markerMenu&&this.markerMenu.unbindMenuFrom($("#"+this.markerId),n)},n.GLOBAL_MARKER_ID=0,n.HIGHLIGHT_COLOR="blue",n.MARKER_COLOR="black",n.INPUT_COLOR="red",n}();n.BaseMarker=r;u=function(){function n(n){this.waveformOrderNum=-1;this.waveformOrderNum2=-1;this.isShown=!1;this.markerType=n}return n.prototype.saveBaseState=function(n){var t,i;this.resultIndex=n.resultIndex;t=n.getWaveform(Operations.WF_INDEX.FIRST);this.flotWaveformId=t.getFlotWaveformId();this.waveformOrderNum=t.getWaveContainer().getPlottedWaveformIndex(this.flotWaveformId);i=n.getWaveform(Operations.WF_INDEX.SECOND);i&&(this.flotWaveformId2=i.getFlotWaveformId(),this.waveformOrderNum2=t.getWaveContainer().getPlottedWaveformIndex(this.flotWaveformId2));this.measText=n.getMeasText();this.isShown=n.isShown;n.getTextObject()&&(this.textState=n.getTextObject().getState())},n}();n.MarkerState=u;f=function(){function n(n,r,u){this.pointIndex=t.FIRST;this.pointPosition=i.LEFT;this.xValue=n;this.yValue=r;this.pointIndex=u}return n}();n.LinePoint=f;e=function(){function n(){}return n}();n.MeasPoint=e}(Markers||(Markers={})),function(n){var e=function(){function i(u,f,e,o){e===void 0&&(e=Operations.WF_INDEX.FIRST);this.lineWidth=0;this.wfIndex=Operations.WF_INDEX.FIRST;this.color=u.getMarkerDefaultColor();this.lineWidth=i.LINE_WIDTH;this.parentMarker=u;this.markerObjectId="measurement_marker_object"+n.BaseMarker.GLOBAL_MARKER_ID++;this.dragAttributes=o?o:new r(t.NONE);this.windowArea=new n.MarkerObjectArea(this.getWaveform());this.markerArea=f;this.wfIndex=e}return i.prototype.getMarkerDefaultColor=function(){return this.parentMarker.getMarkerDefaultColor()},i.prototype.getWaveform=function(){return this.parentMarker.getWaveform(this.wfIndex)},i.prototype.fixYPositionByWindow=function(n,t){var r=this.windowArea.yRange.getMinYPosition(),i;return n<r?r:(i=this.windowArea.yRange.getMaxYPosition(),n+t>i&&(n=i-t),n)},i.prototype.fixXPositionByWindow=function(n,t){var r=this.windowArea.xRange.getMaxXPosition(),i;return n+t>r&&(n=r-t),i=this.windowArea.xRange.getMinXPosition(),n<i&&(n=i),n},i.prototype.fixYPosByMarkerArea=function(n,t){var r=this.markerArea.yRange.getMinYPosition(),i;return n<r&&(n=r),i=this.markerArea.yRange.getMaxYPosition(),n+t>i&&(n=i-t),n},i.prototype.fixXPosByMarkerArea=function(n,t){var r=this.markerArea.xRange.getMinXPosition(),i;return n<r?r:(i=this.markerArea.xRange.getMaxXPosition(),n+t>i)?i-t:n},i.prototype.getDragDirection=function(){return this.dragAttributes.dragDirection},i.prototype.isDraggable=function(){return this.dragAttributes.dragDirection!=t.NONE&&this.dragAttributes.dragDirection!=t.MEASUREMENT},i.prototype.isForMeasurement=function(){return this.dragAttributes.dragDirection==t.MEASUREMENT},i.LINE_WIDTH=1,i.DASH_STROKE="5, 5",i.TEXT_DRAG_DELTA=20,i}(),u,i,f,r,o,t;n.MarkerObject=e;u=function(){function n(){this.xValue1=0;this.yValue1=0;this.xValue2=0;this.yValue2=0;this.xAttachBy=i.NONE;this.yAttachBy=i.NONE;this.dragDirection=t.NONE;this.xBoxValue=0;this.yBoxValue=0}return n}();n.MarkerObjectState=u,function(n){n[n.TOP=0]="TOP";n[n.BOTTOM=1]="BOTTOM";n[n.LEFT=2]="LEFT";n[n.RIGHT=3]="RIGHT";n[n.MIDDLE_VERTICAL=4]="MIDDLE_VERTICAL";n[n.MIDDLE_HORIZONTAL=5]="MIDDLE_HORIZONTAL";n[n.TOP_OUTSIDE=6]="TOP_OUTSIDE";n[n.BOTTOM_OUTSIDE=7]="BOTTOM_OUTSIDE";n[n.LEFT_OUTSIDE=8]="LEFT_OUTSIDE";n[n.RIGHT_OUTSIDE=9]="RIGHT_OUTSIDE";n[n.NONE=10]="NONE"}(n.TEXT_ATTACH_POSITION||(n.TEXT_ATTACH_POSITION={}));i=n.TEXT_ATTACH_POSITION;f=function(){function n(n,t,i,r){this.xPos1=n;this.yPos1=t;this.xPos2=i;this.yPos2=r}return n}();n.MarkerObjectPosition=f;r=function(){function n(n){this.dragDirection=t.NONE;this.dragDirection=n}return n}();n.DragAttributes=r,function(n){n[n.TOP=0]="TOP";n[n.BOTTOM=1]="BOTTOM";n[n.LEFT=2]="LEFT";n[n.RIGHT=3]="RIGHT"}(n.ARROW_DIRECTION||(n.ARROW_DIRECTION={}));o=n.ARROW_DIRECTION,function(n){n[n.VERTICAL=0]="VERTICAL";n[n.HORIZONTAL=1]="HORIZONTAL";n[n.NONE=2]="NONE";n[n.ANY=3]="ANY";n[n.WAVEFORM=4]="WAVEFORM";n[n.MEASUREMENT=5]="MEASUREMENT"}(n.DRAG_DIRECTION||(n.DRAG_DIRECTION={}));t=n.DRAG_DIRECTION}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var u=function(t){function i(i,r,u,f){t.call(this,i,r,f,new n.DragAttributes(n.DRAG_DIRECTION.ANY));this.xAttachBy=n.TEXT_ATTACH_POSITION.NONE;this.yAttachBy=n.TEXT_ATTACH_POSITION.NONE;this.verticalDelta=20;this.isHorizontalOnly=!1;this.outsideMargin=0;this.textInFlag=i.getMeasText();this.initDimensions();this.xAttachBy=r.xRange.attachBy;this.yAttachBy=r.yRange.attachBy;this.setOutsideMargin()}return __extends(i,t),i.prototype.createTextObject=function(){this.initXYPositions();this.draw();this.addHoverEventHandlers();this.addDragEventHandlers();this.hide()},i.prototype.draw=function(){this.drawTextInBox(this.xPos,this.yPos,this.boxWidth,this.boxHeight,this.textInFlag);this.updateBoxLineAttachedPoint()},i.prototype.update=function(){this.xPos=this.getXBoxPosition();this.yPos=this.getYBoxPosition();this.updateTextBox(this.xPos,this.yPos);this.outlineBox.toFront()},i.prototype.updateTextBox=function(n,t){this.updateTextInBox(n,t,this.boxWidth,this.boxHeight,this.textInFlag);this.updateBoxLineAttachedPoint()},i.prototype.updateBoxLineAttachedPoint=function(){},i.prototype.setXBoxValue=function(){this.xBoxValue=this.getWaveform().xaxis.c2p(this.xPos)},i.prototype.setYBoxValue=function(){this.yBoxValue=this.getWaveform().yaxis.c2p(this.yPos)},i.prototype.setOutsideMargin=function(){this.outsideMargin=i.OUTSIDE_LINE_LENGTH;var n=this.parentMarker.getMarkerLine();n&&!n.arrowInside&&(this.outsideMargin+=i.OUTSIDE_LINE_LENGTH)},i.prototype.setMeasText=function(n,t){this.textInFlag=n;this.initDimensions();t&&this.updateByPosition(this.xPos,this.yPos,!1)},i.prototype.fixOutsideYPosition=function(t){return this.yAttachBy==n.TEXT_ATTACH_POSITION.TOP_OUTSIDE?t+this.boxHeight>this.windowArea.yRange.getMaxYPosition()&&(this.yAttachBy=n.TEXT_ATTACH_POSITION.BOTTOM_OUTSIDE,t=this.getYBoxPosition()):t<this.windowArea.yRange.getMinYPosition()&&(this.yAttachBy=n.TEXT_ATTACH_POSITION.TOP_OUTSIDE,t=this.getYBoxPosition()),t},i.prototype.fixOutsideXPosition=function(t){return this.xAttachBy==n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE?t+this.boxWidth>this.windowArea.xRange.getMaxXPosition()&&(this.xAttachBy=n.TEXT_ATTACH_POSITION.RIGHT_OUTSIDE,t=this.getXBoxPosition()):t<this.windowArea.xRange.getMinXPosition()&&(this.xAttachBy=n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE,t=this.getXBoxPosition()),t},i.prototype.getMiddleXPosition=function(){return this.xPos+this.boxWidth/2},i.prototype.getMiddleYPosition=function(){return this.yPos+this.boxHeight/2},i.prototype.isYOutside=function(){return this.yAttachBy==n.TEXT_ATTACH_POSITION.TOP_OUTSIDE||this.yAttachBy==n.TEXT_ATTACH_POSITION.BOTTOM_OUTSIDE},i.prototype.isXOutside=function(){return this.xAttachBy==n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE||this.xAttachBy==n.TEXT_ATTACH_POSITION.RIGHT_OUTSIDE},i.prototype.setXReferencePosition=function(){},i.prototype.setYReferencePosition=function(){},i.prototype.remove=function(){this.text.remove();this.box.remove();this.boxLine&&this.boxLine.remove();this.outlineBox.remove()},i.prototype.show=function(){this.text.show();this.box.show();this.boxLine&&this.boxLine.show();this.outlineBox.show()},i.prototype.hide=function(){this.text.hide();this.box.hide();this.boxLine&&this.boxLine.hide();this.outlineBox.hide()},i.prototype.initDimensions=function(){var n=this.getTextParameters(this.textInFlag),t=n.width,r=n.height;this.boxWidth=Math.round(t+2*i.TEXT_MARGIN);this.boxHeight=Math.round(r)},i.prototype.getTextParameters=function(n){var r=this.getWaveform(),u=r.parentRow.getPaper(),t=u.text(0,0,n);t.attr({"font-size":WaveViewer.WaveRowCursor.CURSOR_STYLE.flagFontSize});var i=t.getBBox(),f=i.width,e=i.height;return t.remove(),{width:f,height:e}},i.prototype.drawTextInBox=function(n,t,i,r,u){var f=this.getWaveform(),e=f.parentRow.getPaper(),s,h,o,c,l;e&&(n=adjustPosition(n),t=adjustPosition(t),s=f.parentRow.getPlotOffset(),this.box=e.rect(n,t,i,r,0),this.box.attr({"stroke-width":this.lineWidth,stroke:this.color}),h=WaveViewer.SVW_Colors.getFillBackgroundColor(f.getWaveContainer()),this.box.attr({fill:h}),this.box.attr({opacity:1}),o=WaveViewer.WaveUtils.getTransformString(s.left,s.top),this.box.transform(o),c=adjustPosition(n+i/2),l=adjustPosition(t+r/2)-1,this.text=e.text(c,l,u),this.text.attr({"font-size":WaveViewer.WaveRowCursor.CURSOR_STYLE.flagFontSize}),this.text.attr({fill:f.getColor()}),this.text.transform(o),this.outlineBox=e.rect(n,t,i,r,0),this.outlineBox.attr({fill:f.getColor()}),this.outlineBox.attr({opacity:0}),this.outlineBox.transform(o),this.outlineBox.node.id=this.markerObjectId)},i.prototype.updateTextInBox=function(n,t,i,r,u){var f=this.getWaveform(),l=f.parentRow.getPaper(),e,s,o,h,c;l&&(n=adjustPosition(n),t=adjustPosition(t),e=f.parentRow.getPlotOffset(),this.box.attr({x:n}),this.box.attr({y:t}),this.box.attr({width:i}),s=WaveViewer.SVW_Colors.getFillBackgroundColor(f.getWaveContainer()),this.box.attr({fill:s}),this.box.attr({opacity:1}),o=WaveViewer.WaveUtils.getTransformString(e.left,e.top),this.box.transform(o),h=adjustPosition(n+i/2),c=adjustPosition(t+r/2)-1,this.text.attr({text:u}),this.text.attr({x:h}),this.text.attr({y:c}),this.text.attr({fill:f.getColor()}),this.text.transform(o),this.outlineBox.attr({x:n}),this.outlineBox.attr({y:t}),this.outlineBox.attr({width:i}),WaveViewer.getManager().getCrossHighlightManager().crossHighlightByWaveform(f,!0),WaveViewer.getManager().getCrossHighlightManager().crossHighlightByWaveform(f,!1))},i.prototype.highligh=function(){this.parentMarker.markerManager.isInputControl()||(this.box.attr({stroke:n.BaseMarker.HIGHLIGHT_COLOR}),this.boxLine&&this.boxLine.highligh())},i.prototype.unhighligh=function(){this.box.attr({stroke:this.color});this.boxLine&&this.boxLine.unhighligh()},i.prototype.boxToFront=function(){this.box.toFront();this.text.toFront();this.outlineBox.toFront()},i.prototype.addHoverEventHandlers=function(){var n=this,t=function(){WaveViewer.SVWEventHandler.getIsMoving()||(n.setCursorShape("move"),Project.Utility.isIE()||n.boxToFront(),n.parentMarker.highlight(),n.parentMarker.showRange())},i=function(){n.setCursorShape("default");n.parentMarker.unhighlight();n.parentMarker.hideRange()};this.outlineBox.hover(t,i)},i.prototype.addDragEventHandlers=function(){var n=this,t=function(t,i,r){if(WaveViewer.SVWEventHandler.getIsMoving()){console.log("Stil moving ");return}if(r.which!=3)return r.preventDefault(),WaveViewer.SVWEventHandler.setIsMoving(n.outlineBox),n.startDrag(),n.setCursorShape("move"),{}},i=function(t,i,r,u,f){if(WaveViewer.SVWEventHandler.getIsMoving()==n.outlineBox)return f.which==3?void 0:(f.preventDefault(),n.moveDrag(t,i),n.updateByPosition(n.xPos,n.yPos,!0),n.setCursorShape("move"),{})},r=function(t){if(WaveViewer.SVWEventHandler.getIsMoving()==n.outlineBox)return t.which==3?void 0:(WaveViewer.SVWEventHandler.setIsMoving(null),t.preventDefault(),n.stopDrag(),n.updateByPosition(n.xPos,n.yPos,!0),n.setCursorShape("default"),{})};this.outlineBox.drag(i,t,r)},i.prototype.setCursorShape=function(n){this.outlineBox.attr({cursor:n})},i.OUTSIDE_LINE_LENGTH=10,i.TEXT_MARGIN=5,i}(n.MarkerObject),t,i,r;n.MarkerTextObject=u;t=function(){function t(t,i,r,u){u===void 0&&(u=n.TEXT_ATTACH_POSITION.NONE);this.attachBy=n.TEXT_ATTACH_POSITION.NONE;this.useTopBottom=!1;this.useLeftRight=!1;this.waveform=r;this.attachBy=u;this.min=Math.min(t,i);this.max=Math.max(t,i)}return t.prototype.isEmpty=function(){return this.min==this.max},t.prototype.getMinValue=function(){return this.min},t.prototype.getMaxValue=function(){return this.max},t.prototype.getMinXPosition=function(){return this.waveform.xaxis.p2c(this.min)},t.prototype.getMaxXPosition=function(){return this.waveform.xaxis.p2c(this.max)},t.prototype.getMinYPosition=function(){return this.waveform.yaxis.p2c(this.max)},t.prototype.getMaxYPosition=function(){return this.waveform.yaxis.p2c(this.min)},t.prototype.getWidth=function(){return Math.abs(this.getMaxXPosition()-this.getMinXPosition())},t.prototype.getHeight=function(){return Math.abs(this.getMaxYPosition()-this.getMinYPosition())},t.prototype.getMiddleValue=function(){return(this.min+this.max)/2},t.prototype.getMiddleXPos=function(){return this.waveform.xaxis.p2c((this.min+this.max)/2)},t.prototype.getMiddleYPos=function(){return this.waveform.yaxis.p2c((this.min+this.max)/2)},t}();n.AttachRange=t;i=function(){function n(n){this.useBoxLine=!1;this.useBoxLine=n}return n}();n.TextAttributes=i;r=function(){function n(n){this.xRange=new t(n.xaxis.min,n.xaxis.max,n);this.yRange=new t(n.yaxis.min,n.yaxis.max,n)}return n}();n.MarkerObjectArea=r}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t,i,r;(function(n){n[n.ANY=0]="ANY";n[n.VERTICAL=1]="VERTICAL";n[n.HORIZONTAL=2]="HORIZONTAL"})(n.LINE_DIRECTION||(n.LINE_DIRECTION={}));t=n.LINE_DIRECTION;i=function(i){function r(r,u,f,e,o,s,h,c,l){l===void 0&&(l=Operations.WF_INDEX.FIRST);i.call(this,r,s,l,c);this.isReference=!1;this.showArrows=!1;this.lineDirection=t.ANY;this.arrowInside=!0;this.initYPos1=0;this.initXPos1=0;this.initYPos2=0;this.initXPos2=0;this.xValue1=u;this.yValue1=f;this.xValue2=e;this.yValue2=o;this.isReference=h.isReference;this.showArrows=h.showArrows;this.lineDirection=h.direction;var a=this.getWaveform();this.initXYPositions();this.lineDirection==t.HORIZONTAL?this.arrowInside=Math.abs(this.xPos1-this.xPos2)>n.MarkerTextObject.OUTSIDE_LINE_LENGTH*3:this.lineDirection==t.VERTICAL&&(this.arrowInside=Math.abs(this.yPos1-this.yPos2)>n.MarkerTextObject.OUTSIDE_LINE_LENGTH*3);this.draw();this.addHoverEventHandlers();this.isDraggable()&&this.addDragEventHandlers();this.hide()}return __extends(r,i),r.prototype.initXYPositions=function(){var n=this.getWaveform();this.yPos1=n.yaxis.p2c(this.yValue1);this.yPos2=n.yaxis.p2c(this.yValue2);this.xPos1=this.fixXPositionByWindow(n.xaxis.p2c(this.xValue1),0);this.xPos2=this.fixXPositionByWindow(n.xaxis.p2c(this.xValue2),0)},r.prototype.isPointVisibleByX=function(t){var i=new n.MarkerObjectArea(this.getWaveform());return t<i.xRange.getMinValue()?!1:t>i.xRange.getMaxValue()?!1:!0},r.prototype.update=function(){var n=this.getWaveform();this.initXYPositions();this.updateByPosition(this.xPos1,this.yPos1,this.xPos2,this.yPos2)},r.prototype.remove=function(){this.line&&this.line.remove();this.outlineBox&&this.outlineBox.remove();this.arrow1&&this.arrow1.remove();this.arrow2&&this.arrow2.remove()},r.prototype.show=function(){this.line&&this.line.show();this.outlineBox&&this.outlineBox.show();this.arrow1&&this.arrow1.show();this.arrow2&&this.arrow2.show()},r.prototype.hide=function(){this.line&&this.line.hide();this.outlineBox&&this.outlineBox.hide();this.arrow1&&this.arrow1.hide();this.arrow2&&this.arrow2.hide()},r.prototype.createArrows=function(){this.lineDirection==t.VERTICAL?this.yValue1>this.yValue2?(this.arrow1=new n.MarkerArrowObject(this.parentMarker,this.xValue1,this.yValue1,n.ARROW_DIRECTION.BOTTOM,this.arrowInside,null,this.wfIndex),this.arrow2=new n.MarkerArrowObject(this.parentMarker,this.xValue2,this.yValue2,n.ARROW_DIRECTION.TOP,this.arrowInside,null,this.wfIndex)):(this.arrow1=new n.MarkerArrowObject(this.parentMarker,this.xValue1,this.yValue1,n.ARROW_DIRECTION.TOP,this.arrowInside,null,this.wfIndex),this.arrow2=new n.MarkerArrowObject(this.parentMarker,this.xValue2,this.yValue2,n.ARROW_DIRECTION.BOTTOM,this.arrowInside,null,this.wfIndex)):this.lineDirection==t.HORIZONTAL&&(this.xValue1<this.xValue2?(this.isPointVisibleByX(this.xValue1)&&(this.arrow1=new n.MarkerArrowObject(this.parentMarker,this.xValue1,this.yValue1,n.ARROW_DIRECTION.LEFT,this.arrowInside,null,this.wfIndex)),this.isPointVisibleByX(this.xValue2)&&(this.arrow2=new n.MarkerArrowObject(this.parentMarker,this.xValue2,this.yValue2,n.ARROW_DIRECTION.RIGHT,this.arrowInside,null,this.wfIndex))):(this.isPointVisibleByX(this.xValue1)&&(this.arrow1=new n.MarkerArrowObject(this.parentMarker,this.xValue1,this.yValue1,n.ARROW_DIRECTION.RIGHT,this.arrowInside,null,this.wfIndex)),this.isPointVisibleByX(this.xValue2)&&(this.arrow2=new n.MarkerArrowObject(this.parentMarker,this.xValue2,this.yValue2,n.ARROW_DIRECTION.LEFT,this.arrowInside,null,this.wfIndex))))},r.prototype.draw=function(){var i=this.getWaveform(),e=i.parentRow.getPaper(),l=i.parentRow.getPlotOffset(),a=WaveViewer.WaveUtils.getTransformString(l.left,l.top),o=adjustPosition(this.xPos1),s=adjustPosition(this.yPos1),h=adjustPosition(this.xPos2),c=adjustPosition(this.yPos2),v="M "+o+" "+s,u,f;v+=" L "+h+" "+c;this.line=e.path(v);this.line.attr({"stroke-width":this.lineWidth,stroke:this.color});this.line.transform(a);this.isReference&&this.line.attr({"stroke-dasharray":n.MarkerObject.DASH_STROKE});this.showArrows&&this.createArrows();this.isDraggable()&&(this.lineDirection==t.VERTICAL?(u=Math.min(o,h),f=Math.min(s,c),this.outlineBox=e.rect(u-r.OTLINE_BOX_DELTA,f,r.OTLINE_BOX_SIZE,Math.abs(this.yPos2-this.yPos1)),this.outlineBox.attr({fill:i.getColor()})):this.lineDirection==t.HORIZONTAL&&(u=Math.min(o,h),f=Math.min(s,c),this.outlineBox=e.rect(u,f-r.OTLINE_BOX_DELTA,Math.abs(this.xPos2-this.xPos1),r.OTLINE_BOX_SIZE),this.outlineBox.attr({fill:i.getColor()})),this.outlineBox&&(this.outlineBox.attr({opacity:0}),this.outlineBox.transform(a),this.outlineBox.node.id=this.markerObjectId))},r.prototype.highligh=function(){this.parentMarker.markerManager.isInputControl()||(this.line.attr({stroke:n.BaseMarker.HIGHLIGHT_COLOR}),this.arrow1&&this.arrow1.highligh(),this.arrow2&&this.arrow2.highligh())},r.prototype.unhighligh=function(){this.line.attr({stroke:this.color});this.arrow1&&this.arrow1.unhighligh();this.arrow2&&this.arrow2.unhighligh()},r.prototype.revertArrows=function(){this.arrow1.showOutside();this.arrow2.showOutside()},r.prototype.getTopPointIndex=function(){return this.yPos1<this.yPos2?n.POINT_INDEX.FIRST:n.POINT_INDEX.SECOND},r.prototype.getBottomPointIndex=function(){return this.yPos1>this.yPos2?n.POINT_INDEX.FIRST:n.POINT_INDEX.SECOND},r.prototype.getLeftPointIndex=function(){return this.xPos1<this.xPos2?n.POINT_INDEX.FIRST:n.POINT_INDEX.SECOND},r.prototype.getRightPointIndex=function(){return this.xPos1>this.xPos2?n.POINT_INDEX.FIRST:n.POINT_INDEX.SECOND},r.prototype.setXPosition=function(t,i){var r=this.getWaveform();i==n.POINT_INDEX.FIRST?(this.xPos1=t,this.xValue1=r.xaxis.c2p(this.xPos1)):i==n.POINT_INDEX.SECOND&&(this.xPos2=t,this.xValue2=r.xaxis.c2p(this.xPos2));this.updateByPosition(this.xPos1,this.yPos1,this.xPos2,this.yPos2)},r.prototype.updateXPosition=function(n){n=this.fixXPositionByWindow(n,0);var t=this.getWaveform();this.xPos1=n;this.xValue1=t.xaxis.c2p(this.xPos1);this.xPos2=n;this.xValue2=t.xaxis.c2p(this.xPos2);this.updateByPosition(this.xPos1,this.yPos1,this.xPos2,this.yPos2,!1)},r.prototype.updateYPosition=function(n){n=this.fixYPositionByWindow(n,0);var t=this.getWaveform();this.yPos1=n;this.yValue1=t.yaxis.c2p(this.yPos1);this.yPos2=n;this.yValue2=t.yaxis.c2p(this.yPos2);this.updateByPosition(this.xPos1,this.yPos1,this.xPos2,this.yPos2,!1)},r.prototype.setYPosition=function(t,i){var r=this.getWaveform();i==n.POINT_INDEX.FIRST?(this.yPos1=t,this.yValue1=r.yaxis.c2p(this.yPos1)):i==n.POINT_INDEX.SECOND&&(this.yPos2=t,this.yValue2=r.yaxis.c2p(this.yPos2));this.updateByPosition(this.xPos1,this.yPos1,this.xPos2,this.yPos2)},r.prototype.getReferencePosition=function(){return this.lineDirection==t.HORIZONTAL?this.yPos1:this.lineDirection==t.VERTICAL?this.xPos1:void 0},r.prototype.getReferenceValue=function(){return this.lineDirection==t.HORIZONTAL?this.yValue1:this.lineDirection==t.VERTICAL?this.xValue1:void 0},r.prototype.updateByPosition=function(i,u,f,e,o){var c,s,h;o===void 0&&(o=!0);var l=this.getWaveform(),y=l.parentRow.getPaper(),a=l.parentRow.getPlotOffset(),v=WaveViewer.WaveUtils.getTransformString(a.left,a.top);i=adjustPosition(i);u=adjustPosition(u);f=adjustPosition(f);e=adjustPosition(e);c="M "+i+" "+u;c+=" L "+f+" "+e;this.line.attr({path:c});this.line.transform(v);this.isReference&&this.line.attr({"stroke-dasharray":n.MarkerObject.DASH_STROKE});this.showArrows&&(this.arrow1&&this.arrow1.updatByPosition(this.xPos1,this.yPos1),this.arrow2&&this.arrow2.updatByPosition(this.xPos2,this.yPos2));this.isDraggable()&&(this.lineDirection==t.VERTICAL?(s=Math.min(i,f),h=Math.min(u,e),this.outlineBox.attr({x:s-r.OTLINE_BOX_DELTA}),this.outlineBox.attr({y:h}),this.outlineBox.attr({width:r.OTLINE_BOX_SIZE}),this.outlineBox.attr({height:Math.abs(this.yPos2-this.yPos1)})):this.lineDirection==t.HORIZONTAL&&(s=Math.min(i,f),h=Math.min(u,e),this.outlineBox.attr({x:s}),this.outlineBox.attr({y:h-r.OTLINE_BOX_DELTA}),this.outlineBox.attr({width:Math.abs(this.xPos2-this.xPos1)}),this.outlineBox.attr({height:r.OTLINE_BOX_SIZE})));this.isDraggable()&&this.parentMarker.updateAssociated(this,o)},r.prototype.getXPosForDrag=function(n){return n=this.fixXPosByMarkerArea(n,0),this.fixXPositionByWindow(n,0)},r.prototype.getYPosForDrag=function(n){return n=this.fixYPosByMarkerArea(n,0),this.fixYPositionByWindow(n,0)},r.prototype.startDrag=function(){this.initXPos1=this.xPos1;this.initYPos1=this.yPos1;this.initXPos2=this.xPos2;this.initYPos2=this.yPos2},r.prototype.moveDrag=function(n,i){var r=this.initXPos1+n,u=this.initYPos1+i,f=this.initXPos2+n,e=this.initYPos2+i,o=this.getWaveform();this.lineDirection==t.VERTICAL?(this.xPos1=this.getXPosForDrag(r),this.xPos2=this.getXPosForDrag(f)):this.lineDirection==t.HORIZONTAL?(this.yPos1=this.getYPosForDrag(u),this.yPos2=this.getYPosForDrag(e),this.yValue1=o.yaxis.c2p(this.yPos1),this.yValue2=o.yaxis.c2p(this.yPos2)):(this.xPos1=this.getXPosForDrag(r),this.xPos2=this.getXPosForDrag(f),this.yPos1=this.getYPosForDrag(u),this.yPos2=this.getYPosForDrag(e))},r.prototype.stopDrag=function(){var n=this.getWaveform();this.lineDirection==t.VERTICAL?(this.xValue1=n.xaxis.c2p(this.xPos1),this.xValue2=n.xaxis.c2p(this.xPos2)):this.lineDirection==t.HORIZONTAL?(this.yValue1=n.yaxis.c2p(this.yPos1),this.yValue2=n.yaxis.c2p(this.yPos2)):(this.xValue1=n.xaxis.c2p(this.xPos1),this.xValue2=n.xaxis.c2p(this.xPos2),this.yValue1=n.yaxis.c2p(this.yPos1),this.yValue2=n.yaxis.c2p(this.yPos2))},r.prototype.addDragEventHandlers=function(){var n=this,t=this,i=function(i,r,u){if(!WaveViewer.SVWEventHandler.getIsMoving())return u.which!=1?void 0:(u.preventDefault(),WaveViewer.SVWEventHandler.setIsMoving(t.outlineBox),n.startDrag(),n.setCursorShape(n.getCursorShape()),{})},r=function(i,r,u,f,e){if(WaveViewer.SVWEventHandler.getIsMoving()==t.outlineBox)return e.which!=1?void 0:(e.preventDefault(),n.moveDrag(i,r),t.updateByPosition(n.xPos1,n.yPos1,n.xPos2,n.yPos2),n.setCursorShape(n.getCursorShape()),{})},u=function(i){if(WaveViewer.SVWEventHandler.getIsMoving()==t.outlineBox)return i.which!=1?void 0:(i.preventDefault(),WaveViewer.SVWEventHandler.setIsMoving(null),n.stopDrag(),t.updateByPosition(n.xPos1,n.yPos1,n.xPos2,n.yPos2),n.setCursorShape("auto"),{})};this.outlineBox&&this.outlineBox.drag(r,i,u)},r.prototype.addHoverEventHandlers=function(){var n=this,t=function(){WaveViewer.SVWEventHandler.getIsMoving()||(n.isDraggable()&&n.setCursorShape(n.getCursorShape()),n.parentMarker.highlight())},i=function(){n.setCursorShape("auto");n.parentMarker.unhighlight()};this.outlineBox&&this.outlineBox.hover(t,i)},r.prototype.setCursorShape=function(n){this.outlineBox.attr({cursor:n})},r.prototype.getCursorShape=function(){if(!this.isDraggable())return"auto";var n="move";return this.lineDirection==t.HORIZONTAL&&(n="ns-resize"),this.lineDirection==t.VERTICAL&&(n="ew-resize"),n},r.prototype.getState=function(){var t=new n.MarkerObjectState;return t.xValue1=this.xValue1,t.yValue1=this.yValue1,t.xValue2=this.xValue2,t.yValue2=this.yValue2,t.dragDirection=this.dragAttributes.dragDirection,t},r.prototype.setState=function(t){this.xValue1=t.xValue1;this.yValue1=t.yValue1;this.xValue2=t.xValue2;this.yValue2=t.yValue2;this.dragAttributes=new n.DragAttributes(t.dragDirection);this.update()},r.OTLINE_BOX_DELTA=5,r.OTLINE_BOX_SIZE=10,r}(n.MarkerObject);n.MarkerLineObject=i;r=function(){function n(n,i,r,u){u===void 0&&(u=!1);this.showArrows=!1;this.isReference=!1;this.direction=t.ANY;this.useSecond=!1;this.isReference=n;this.showArrows=i;this.direction=r;this.useSecond=u}return n}();n.LineAttributes=r}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r,u,f,e,o,s){s===void 0&&(s=Operations.WF_INDEX.FIRST);t.call(this,i,null,s,o);this.xValue=0;this.yValue=0;this.size=10;this.thickness=n.MarkerObject.LINE_WIDTH;this.arrowInside=!0;this.xPoints=[];this.yPoints=[];this.xValue=r;this.yValue=u;this.direction=f;this.size=n.MarkerTextObject.OUTSIDE_LINE_LENGTH;this.arrowInside=e;var h=this.getWaveform();this.xPos=h.xaxis.p2c(this.xValue);this.yPos=h.yaxis.p2c(this.yValue);this.draw();this.arrowInside||this.showOutside();this.hide()}return __extends(i,t),i.prototype.draw=function(){var n=this.getWaveform(),t=n.parentRow.getPlotOffset(),r=WaveViewer.WaveUtils.getTransformString(t.left,t.top),i,f,e,o;this.getArrowPoints(this.direction,this.xPos,this.yPos);var t=n.parentRow.getPlotOffset(),r=WaveViewer.WaveUtils.getTransformString(t.left,t.top),u="M "+this.xPoints[0]+" "+this.yPoints[0];u+=" L "+this.xPoints[1]+" "+this.yPoints[1];u+=" L "+this.xPoints[2]+" "+this.yPoints[2];i=n.parentRow.getPaper();this.arrow=i.path(u);this.arrow.attr({"stroke-width":this.thickness,stroke:this.color});this.arrow.transform(r);this.arrowInside||(this.getArrowLinePoints(this.direction,this.xPos,this.yPos),f="M "+this.xPoints[0]+" "+this.yPoints[0],f+=" L "+this.xPoints[1]+" "+this.yPoints[1],this.arrowLine=i.path(f),this.arrowLine.attr({"stroke-width":this.thickness,stroke:this.color}),this.arrowLine.transform(r));this.getArrowPoints(this.direction,this.xPos,this.yPos);e=Math.min(this.xPoints[0],this.xPoints[1],this.xPoints[2]);o=Math.min(this.yPoints[0],this.yPoints[1],this.yPoints[2]);this.outlineBox=i.rect(e,o,this.size,this.size);this.outlineBox.attr({fill:n.getColor()});this.outlineBox&&(this.outlineBox.attr({opacity:0}),this.outlineBox.transform(r))},i.prototype.highligh=function(){this.parentMarker.markerManager.isInputControl()||(this.arrow&&this.arrow.attr({stroke:n.BaseMarker.HIGHLIGHT_COLOR}),this.arrowLine&&this.arrowLine.attr({stroke:n.BaseMarker.HIGHLIGHT_COLOR}))},i.prototype.unhighligh=function(){this.arrow&&this.arrow.attr({stroke:this.color});this.arrowLine&&this.arrowLine.attr({stroke:this.color})},i.prototype.getArrowLinePoints=function(t,i,r){var f,e,u;this.xPoints=[];this.yPoints=[];f=this.size*2;e=this.size*2;switch(t){case n.ARROW_DIRECTION.LEFT:this.xPoints[0]=f;this.yPoints[0]=0;this.xPoints[1]=0;this.yPoints[1]=0;break;case n.ARROW_DIRECTION.RIGHT:this.xPoints[0]=-f;this.yPoints[0]=0;this.xPoints[1]=0;this.yPoints[1]=0;break;case n.ARROW_DIRECTION.TOP:this.xPoints[0]=0;this.yPoints[0]=e;this.xPoints[1]=0;this.yPoints[1]=0;break;case n.ARROW_DIRECTION.BOTTOM:this.xPoints[0]=0;this.yPoints[0]=-e;this.xPoints[1]=0;this.yPoints[1]=0}for(u=0;u<this.xPoints.length;u++)this.xPoints[u]=adjustPosition(this.xPoints[u]+i),this.yPoints[u]=adjustPosition(this.yPoints[u]+r)},i.prototype.showOutside=function(){this.arrowInside=!1;this.direction=this.getOppositeDirection();this.remove();this.draw()},i.prototype.getOppositeDirection=function(){switch(this.direction){case n.ARROW_DIRECTION.LEFT:return n.ARROW_DIRECTION.RIGHT;case n.ARROW_DIRECTION.RIGHT:return n.ARROW_DIRECTION.LEFT;case n.ARROW_DIRECTION.TOP:return n.ARROW_DIRECTION.BOTTOM;case n.ARROW_DIRECTION.BOTTOM:return n.ARROW_DIRECTION.TOP}},i.prototype.getArrowPoints=function(t,i,r){var u,f,e;this.xPoints=[];this.yPoints=[];u=this.size;f=this.size;switch(t){case n.ARROW_DIRECTION.LEFT:this.xPoints[0]=u;this.yPoints[0]=f/2;this.xPoints[1]=0;this.yPoints[1]=0;this.xPoints[2]=u;this.yPoints[2]=-f/2;break;case n.ARROW_DIRECTION.RIGHT:this.xPoints[0]=-u;this.yPoints[0]=f/2;this.xPoints[1]=0;this.yPoints[1]=0;this.xPoints[2]=-u;this.yPoints[2]=-f/2;break;case n.ARROW_DIRECTION.TOP:this.xPoints[0]=-u/2;this.yPoints[0]=-f;this.xPoints[1]=0;this.yPoints[1]=0;this.xPoints[2]=u/2;this.yPoints[2]=-f;break;case n.ARROW_DIRECTION.BOTTOM:this.xPoints[0]=-u/2;this.yPoints[0]=f;this.xPoints[1]=0;this.yPoints[1]=0;this.xPoints[2]=u/2;this.yPoints[2]=f}for(e=0;e<this.xPoints.length;e++)this.xPoints[e]=adjustPosition(this.xPoints[e]+i),this.yPoints[e]=adjustPosition(this.yPoints[e]+r)},i.prototype.updatByPosition=function(n,t){this.xPos=n;this.yPos=t;this.update()},i.prototype.update=function(){var t=this.getWaveform(),n=t.parentRow.getPlotOffset(),i=WaveViewer.WaveUtils.getTransformString(n.left,n.top),o,u,f,e;this.getArrowPoints(this.direction,this.xPos,this.yPos);var n=t.parentRow.getPlotOffset(),i=WaveViewer.WaveUtils.getTransformString(n.left,n.top),r="M "+this.xPoints[0]+" "+this.yPoints[0];r+=" L "+this.xPoints[1]+" "+this.yPoints[1];r+=" L "+this.xPoints[2]+" "+this.yPoints[2];o=t.parentRow.getPaper();this.arrow.attr({path:r});this.arrow.transform(i);this.arrowInside||(this.getArrowLinePoints(this.direction,this.xPos,this.yPos),u="M "+this.xPoints[0]+" "+this.yPoints[0],u+=" L "+this.xPoints[1]+" "+this.yPoints[1],this.arrowLine.attr({path:u}),this.arrowLine.transform(i));this.getArrowPoints(this.direction,this.xPos,this.yPos);f=Math.min(this.xPoints[0],this.xPoints[1],this.xPoints[2]);e=Math.min(this.yPoints[0],this.yPoints[1],this.yPoints[2]);this.outlineBox.attr({x:f});this.outlineBox.attr({y:e});this.outlineBox.attr({width:this.size});this.outlineBox.attr({height:this.size});this.outlineBox.transform(i)},i.prototype.remove=function(){this.arrow.remove();this.arrowLine&&this.arrowLine.remove();this.outlineBox&&this.outlineBox.remove()},i.prototype.show=function(){this.arrow.show();this.arrowLine&&this.arrowLine.show();this.outlineBox&&this.outlineBox.show()},i.prototype.hide=function(){this.arrow.hide();this.arrowLine&&this.arrowLine.hide();this.outlineBox&&this.outlineBox.hide()},i.prototype.addDragEventHandlers=function(){},i.prototype.getState=function(){var t=new n.MarkerObjectState;return t.xValue1=this.xValue,t.yValue1=this.yValue,t},i.prototype.setState=function(){},i}(n.MarkerObject);n.MarkerArrowObject=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(r,u,f,e,o,s,h){t.call(this,r,e,h,o);this.xValue=0;this.yValue=0;this.radius=i.POINT_RADIUS;this.outlineRadius=i.OUTLINE_RADIUS;this.deltaPos=20;this.attachBy=n.TEXT_ATTACH_POSITION.NONE;this.pointIndex=n.POINT_INDEX.FIRST;this.pointPosition=n.POINT_POSITION.LEFT;this.initYPos=0;this.initXPos=0;this.xValue=u;this.yValue=f;this.pointIndex=s;var c=this.getWaveform();this.xPos=c.xaxis.p2c(this.xValue);this.yPos=c.yaxis.p2c(this.yValue);this.radius=i.POINT_RADIUS;this.outlineRadius=this.parentMarker.markerManager.isMoving?0:i.OUTLINE_RADIUS;this.draw();this.isDraggable()&&this.addDragEventHandlers();this.isForMeasurement()&&this.addHoverEventHandlers();this.hide()}return __extends(i,t),i.prototype.update=function(){var n=this.getWaveform();this.xPos=n.xaxis.p2c(this.xValue);this.yPos=n.yaxis.p2c(this.yValue);this.updateByPosition(this.xPos,this.yPos);this.outlineCircle.toFront()},i.prototype.remove=function(){this.line1&&this.line1.remove();this.line2&&this.line2.remove();this.outlineCircle.remove();this.circle.remove();this.parentMarker.markerManager.removeMockPoint()},i.prototype.show=function(){this.line1&&this.line1.show();this.line2&&this.line2.show();this.outlineCircle.show();this.circle.show()},i.prototype.hide=function(){this.line1&&this.line1.hide();this.line2&&this.line2.hide();this.outlineCircle.hide();this.circle.hide()},i.prototype.draw=function(){var e=this.getWaveform(),i=e.parentRow.getPaper(),o=e.parentRow.getPlotOffset(),r=WaveViewer.WaveUtils.getTransformString(o.left,o.top),n=adjustPosition(this.xPos),t=adjustPosition(this.yPos),u,f;this.circle=i.circle(n,t,this.radius);this.circle.attr({"stroke-width":this.lineWidth,stroke:this.color,fill:this.color});this.circle.transform(r);this.outlineCircle=i.circle(n,t,this.outlineRadius);this.outlineCircle.attr({"stroke-width":this.lineWidth,stroke:this.color});this.outlineCircle.attr({fill:this.color,opacity:0});this.outlineCircle.transform(r);u="M "+n+" "+(t+this.radius);u+=" L "+n+" "+(t-this.radius);this.line1=i.path(u);this.line1.attr({"stroke-width":this.lineWidth,stroke:this.color});this.line1.transform(r);f="M "+(n-this.radius)+" "+t;f+=" L "+(n+this.radius)+" "+t;this.line2=i.path(f);this.line2.attr({"stroke-width":this.lineWidth,stroke:this.color});this.line2.transform(r);this.outlineCircle.toFront()},i.prototype.updateByPosition=function(n,t){var o=this.getWaveform(),h=o.parentRow.getPaper(),s=o.parentRow.getPlotOffset(),u=WaveViewer.WaveUtils.getTransformString(s.left,s.top),i=adjustPosition(n),r=adjustPosition(t),f,e;this.circle.attr({"stroke-width":this.lineWidth,stroke:this.color,fill:this.color});this.circle.attr({cx:i,cy:r,r:this.radius});this.circle.transform(u);this.outlineCircle.attr({"stroke-width":this.lineWidth,stroke:this.color});this.outlineCircle.attr({cx:i,cy:r,r:this.outlineRadius});this.outlineCircle.attr({fill:this.color,opacity:0});this.outlineCircle.transform(u);f="M "+i+" "+(r+this.radius);f+=" L "+i+" "+(r-this.radius);this.line1.attr({"stroke-width":this.lineWidth,stroke:this.color});this.line1.attr({path:f});this.line1.transform(u);e="M "+(i-this.radius)+" "+r;e+=" L "+(i+this.radius)+" "+r;this.line2.attr({"stroke-width":this.lineWidth,stroke:this.color});this.line2.attr({path:e});this.line2.transform(u);this.isDraggable()&&this.parentMarker.updateAssociated(this,!0);this.outlineCircle.toFront()},i.prototype.getXPosition=function(){var n=this.getWaveform();return n.xaxis.p2c(this.xValue)},i.prototype.getYPosition=function(){var n=this.getWaveform();return n.yaxis.p2c(this.yValue)},i.prototype.setRelativePositions=function(){this.parentMarker instanceof n.PointMarker&&this.parentMarker.markerManager.setTextRelativePositions(this.parentMarker)},i.prototype.addHoverEventHandlers=function(){var n=this;if(!this.parentMarker.markerManager.isMoving){var r=this.getWaveform(),t=this,u=function(){WaveViewer.SVWEventHandler.getIsMoving()||(n.outlineCircle.toFront(),n.isForMeasurement()&&n.outlineCircle.mousedown(function(){n.setRelativePositions();n.parentMarker.markerManager.createMockPoint(n.parentMarker.resultIndex,n)}),t.setCursorShape("move"),n.radius=i.HOVER_RADIUS,n.color=r.color,t.circle.animate({r:i.HOVER_RADIUS,fill:r.color},400))},f=function(){n.parentMarker.markerManager.isMoving||WaveViewer.SVWEventHandler.getIsMoving()||(n.radius=i.POINT_RADIUS,n.color=n.getMarkerDefaultColor(),t.setCursorShape("default"),t.circle.animate({r:t.radius,fill:t.color},400))};this.outlineCircle.hover(u,f)}},i.prototype.getWaveformPointForDrag=function(n,t){var e=this.xPos,o=this.yPos,i=this.getWaveform(),s=i.parentRow.getPlotArea(),h=i.getFlotWaveformId(),r=s.findNearbyItem(n,t,function(n){return n.getFlotWaveformId()==h}),u,f;return r?(u=r.datapoint[0],f=r.datapoint[1],n=i.xaxis.p2c(u),t=i.yaxis.p2c(f)):(n=e,t=o),{xPos:n,yPos:t}},i.prototype.getXPosForDrag=function(n){return n=this.fixXPosByMarkerArea(n,0),this.fixXPositionByWindow(n,0)},i.prototype.getYPosForDrag=function(n){return n=this.fixYPosByMarkerArea(n,0),this.fixYPositionByWindow(n,0)},i.prototype.startDrag=function(){this.initYPos=this.yPos;this.initXPos=this.xPos},i.prototype.moveDrag=function(t,i){var r=this.initXPos+t,u=this.initYPos+i,f,e;this.getDragDirection()==n.DRAG_DIRECTION.HORIZONTAL?this.xPos=this.getXPosForDrag(r):this.getDragDirection()==n.DRAG_DIRECTION.VERTICAL?this.yPos=this.getYPosForDrag(u):this.getDragDirection()==n.DRAG_DIRECTION.WAVEFORM?(f=this.getWaveform(),e=this.getWaveformPointForDrag(r,u),this.xPos=this.getXPosForDrag(e.xPos),this.yPos=this.getYPosForDrag(e.yPos),this.xValue=f.xaxis.c2p(this.xPos),this.yValue=f.yaxis.c2p(this.yPos)):(this.xPos=this.getXPosForDrag(r),this.yPos=this.getYPosForDrag(u))},i.prototype.stopDrag=function(){var t=this.getWaveform();this.getDragDirection()==n.DRAG_DIRECTION.HORIZONTAL?this.xValue=t.xaxis.c2p(this.xPos):this.getDragDirection()==n.DRAG_DIRECTION.VERTICAL?this.yValue=t.yaxis.c2p(this.yPos):(this.xValue=t.xaxis.c2p(this.xPos),this.yValue=t.yaxis.c2p(this.yPos))},i.prototype.addDragEventHandlers=function(){var n=this;if(!this.parentMarker.markerManager.isMoving){var r=this.getWaveform(),t=this,u=function(u,f,e){if(!WaveViewer.SVWEventHandler.getIsMoving())return e.which==3?void 0:(e.preventDefault(),e.stopPropagation(),WaveViewer.SVWEventHandler.setIsMoving(t.outlineCircle),n.startDrag(),t.setCursorShape("move"),t.radius=i.HOVER_RADIUS,t.circle.attr({r:i.HOVER_RADIUS}),n.radius=i.HOVER_RADIUS,n.color=r.color,{})},f=function(r,u,f,e,o){if(WaveViewer.SVWEventHandler.getIsMoving()==t.outlineCircle)return o.which==3?void 0:(o.preventDefault(),o.stopPropagation(),t.radius=i.HOVER_RADIUS,n.color=n.getWaveform().getColor(),n.moveDrag(r,u),t.updateByPosition(n.xPos,n.yPos),t.setCursorShape("move"),{})},e=function(r){if(WaveViewer.SVWEventHandler.getIsMoving()==t.outlineCircle)return r.which==3?void 0:(WaveViewer.SVWEventHandler.setIsMoving(null),r.preventDefault(),r.stopPropagation(),n.radius=i.POINT_RADIUS,n.color=n.getMarkerDefaultColor(),t.circle.animate({r:t.radius,fill:t.color},400),n.stopDrag(),t.updateByPosition(n.xPos,n.yPos),t.setCursorShape("default"),{})};this.outlineCircle.drag(f,u,e)}},i.prototype.getState=function(){var t=new n.MarkerObjectState;return t.xValue1=this.xValue,t.yValue1=this.yValue,t.xAttachBy=this.attachBy,t},i.prototype.setState=function(n){this.xValue=n.xValue1;this.yValue=n.yValue1;this.attachBy=n.xAttachBy;var t=this.getWaveform();this.xPos=t.xaxis.p2c(this.xValue);this.yPos=t.yaxis.p2c(this.yValue);this.updateByPosition(this.xPos,this.yPos)},i.prototype.setCursorShape=function(n){this.outlineCircle.attr({cursor:n})},i.prototype.unhoverPoint=function(){this.outlineCircle.attr({r:0})},i.POINT_RADIUS=3,i.OUTLINE_RADIUS=10,i.HOVER_RADIUS=10,i}(n.MarkerObject),i;n.MarkerPointObject=t;i=function(){function i(t){this.pointPosition=n.POINT_POSITION.LEFT;this.currentIndex=0;this.initYPos=0;this.initXPos=0;this.sourcePoint=t;this.markerManager=this.sourcePoint.parentMarker.markerManager;this.waveform=this.sourcePoint.getWaveform();this.xPos=t.xPos;this.yPos=t.yPos;this.currentIndex=this.sourcePoint.parentMarker.resultIndex;this.pointPosition=this.sourcePoint.pointPosition;this.draw();this.initDrag()}return i.prototype.createPoint=function(){},i.prototype.draw=function(){var n=this.sourcePoint.getWaveform(),i=n.parentRow.getPaper(),r=n.parentRow.getPlotOffset(),u=WaveViewer.WaveUtils.getTransformString(r.left,r.top),f=adjustPosition(this.xPos),e=adjustPosition(this.yPos);this.bigcircle=i.circle(f,e,t.HOVER_RADIUS);this.bigcircle.attr({"stroke-width":this.sourcePoint.lineWidth,stroke:n.getColor(),fill:"transparent"});this.bigcircle.transform(u);this.circle=i.circle(f,e,t.POINT_RADIUS);this.circle.attr({"stroke-width":this.sourcePoint.lineWidth,stroke:n.getColor(),fill:this.sourcePoint.getMarkerDefaultColor()});this.circle.transform(u);this.circle.toFront()},i.prototype.updateByPosition=function(n,t){var i=this.sourcePoint.getWaveform(),o=i.parentRow.getPaper(),r=i.parentRow.getPlotOffset(),u=WaveViewer.WaveUtils.getTransformString(r.left,r.top),f=adjustPosition(n),e=adjustPosition(t);this.bigcircle.attr({cx:f,cy:e});this.bigcircle.transform(u);this.circle.attr({cx:f,cy:e});this.circle.transform(u);this.circle.toFront()},i.prototype.remove=function(){this.bigcircle.remove();this.circle.remove()},i.prototype.hide=function(){this.bigcircle.hide();this.circle.hide()},i.prototype.startDrag=function(){this.sourcePoint.unhoverPoint();this.initYPos=this.yPos;this.initXPos=this.xPos;this.markerManager.isMoving=!0},i.prototype.moveDrag=function(n){var r=this.xPos;n=this.sourcePoint.fixXPositionByWindow(n,0);var t=this.sourcePoint.getWaveform(),u=t.xaxis.c2p(n),f=n-r,e=this.currentIndex,i=this.markerManager.getNextPoint(u,0,this.currentIndex,this.sourcePoint.pointIndex,f,this.pointPosition);this.currentIndex=i.index;e!=this.currentIndex&&(this.xPos=t.xaxis.p2c(i.XValue),this.yPos=t.yaxis.p2c(i.YValue),this.updateByPosition(this.xPos,this.yPos))},i.prototype.stopDrag=function(){this.setCursorShape("default");this.markerManager.isMoving=!1;this.sourcePoint.parentMarker.markerManager.hideMockPoint();this.sourcePoint.parentMarker.markerManager.repaintMarker(this.currentIndex)},i.prototype.initDrag=function(){var n=this;WaveViewer.SVWEventHandler.setIsMoving(this.circle);this.markerManager.isMoving=!0;$(document).on("mousemove.mockPointEvent",function(t){if(WaveViewer.SVWEventHandler.getIsMoving()==n.circle&&t.which!=3){event.preventDefault();event.stopPropagation();var i=n.sourcePoint.getWaveform(),r=i.parentRow.getOffset(),u=Math.max(0,Math.min(t.pageX-r.left,i.parentRow.getRowWidth()));n.moveDrag(u);n.setCursorShape("move")}});$(document).on("mouseup.mockPointEvent",function(t){WaveViewer.SVWEventHandler.getIsMoving()==n.circle&&t.which!=3&&(WaveViewer.SVWEventHandler.setIsMoving(null),n.stopDrag(),$(document).unbind(".mockPointEvent"))})},i.prototype.setCursorShape=function(n){this.circle.attr({cursor:n})},i}();n.MockPointObject=i}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r,u,f){f===void 0&&(f=Operations.WF_INDEX.FIRST);t.call(this,n,r,u,f);this.initYPos=0;this.initXPos=0;var e=this.getWaveform();this.mainYPos=e.yaxis.p2c(i);this.createTextObject()}return __extends(i,t),i.prototype.initXYPositions=function(){var t;this.yPos=this.getYBoxPosition();this.markerArea.xRange.getWidth()<this.boxWidth||this.windowArea.xRange.getWidth()<this.boxWidth?(this.xAttachBy=n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE,t=this.getXBoxPosition(),this.xPos=this.fixOutsideXPosition(t)):(t=this.markerArea.xRange.getMiddleXPos()-this.boxWidth/2,this.xPos=this.fixInsideXPosition(t),this.setXBoxValue())},i.prototype.fixInsideXPosition=function(t){var i=this.windowArea.xRange.getMaxXPosition(),r=this.windowArea.xRange.getMinXPosition();return t+this.boxWidth>i&&(t=i-this.boxWidth,Math.abs(t-this.markerArea.xRange.getMinXPosition())<this.boxWidth&&(this.xAttachBy=n.TEXT_ATTACH_POSITION.RIGHT_OUTSIDE,t=this.getXBoxPosition(),t=this.fixOutsideXPosition(t))),t<r&&(t=r,Math.abs(t-this.markerArea.xRange.getMaxXPosition())<this.boxWidth&&(this.xAttachBy=n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE,t=this.getXBoxPosition(),t=this.fixOutsideXPosition(t))),t},i.prototype.getXPosForDrag=function(t){return this.isXOutside()?(t<this.markerArea.xRange.getMiddleXPos()?this.xAttachBy=n.TEXT_ATTACH_POSITION.RIGHT_OUTSIDE:t>this.markerArea.xRange.getMiddleXPos()&&(this.xAttachBy=n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE),t=this.getXBoxPosition(),this.fixOutsideXPosition(t)):(t=this.fixXPosByMarkerArea(t,this.boxWidth),t=this.fixXPositionByWindow(t,this.boxWidth),t)},i.prototype.getYPosForDrag=function(n){return n=this.fixYPosByMarkerArea(n,0),this.fixYPositionByWindow(n,0)},i.prototype.setYReferencePosition=function(n){this.mainYPos=n;this.yPos=this.getYBoxPosition();this.updateByPosition(this.xPos,this.yPos,!1)},i.prototype.updateByPosition=function(n,t,i){this.updateTextBox(n,t);i&&this.parentMarker.updateMarkerLine(this.mainYPos)},i.prototype.getXBoxPosition=function(){var t=this.xPos;return this.xAttachBy==n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE?t=this.markerArea.xRange.getMaxXPosition()+this.outsideMargin:this.xAttachBy==n.TEXT_ATTACH_POSITION.RIGHT_OUTSIDE&&(t=this.markerArea.xRange.getMinXPosition()-this.boxWidth-this.outsideMargin),t},i.prototype.getYBoxPosition=function(){var t=this.mainYPos;return this.yAttachBy==n.TEXT_ATTACH_POSITION.BOTTOM?t=this.mainYPos-this.boxHeight:this.yAttachBy==n.TEXT_ATTACH_POSITION.TOP?t=this.mainYPos:this.yAttachBy==n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL&&(t=this.mainYPos-this.boxHeight/2),t},i.prototype.startDrag=function(){this.initYPos=this.mainYPos;this.initXPos=this.xPos},i.prototype.moveDrag=function(n,t){var i=this.initXPos+n,r=this.initYPos+t;this.xPos=this.getXPosForDrag(i);this.mainYPos=this.getYPosForDrag(r);this.yPos=this.getYBoxPosition()},i.prototype.stopDrag=function(){this.setXBoxValue()},i.prototype.getState=function(){var t=new n.MarkerObjectState;return t.xAttachBy=this.xAttachBy,t.yAttachBy=this.yAttachBy,t.xBoxValue=this.xBoxValue,t},i.prototype.setState=function(t){var r=!1,i=t.xAttachBy,u=i==n.TEXT_ATTACH_POSITION.LEFT_OUTSIDE||i==n.TEXT_ATTACH_POSITION.RIGHT_OUTSIDE;r=this.isXOutside()!=u;r||(this.xAttachBy=i,this.yAttachBy=t.yAttachBy,this.yPos=this.getYBoxPosition(),this.isXOutside()?this.xPos=this.getXBoxPosition():(this.xPos=this.getWaveform().xaxis.p2c(t.xBoxValue),this.setXBoxValue()));this.updateByPosition(this.xPos,this.yPos,!1)},i}(n.MarkerTextObject);n.HorizontalDeltaMarkerText=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r,u,f){f===void 0&&(f=Operations.WF_INDEX.FIRST);t.call(this,n,r,u,f);this.initYPos=0;this.initXPos=0;var e=this.getWaveform();this.mainXPos=e.xaxis.p2c(i);this.createTextObject()}return __extends(i,t),i.prototype.initXYPositions=function(){var t;this.xAttachBy=n.TEXT_ATTACH_POSITION.MIDDLE_HORIZONTAL;this.xPos=this.getXBoxPosition();this.xPos=this.fixXPositionByWindow(this.xPos,this.boxWidth);this.markerArea.yRange.getHeight()<this.boxHeight||this.windowArea.yRange.getHeight()<this.boxHeight?(this.yAttachBy=n.TEXT_ATTACH_POSITION.BOTTOM_OUTSIDE,t=this.getYBoxPosition(),this.yPos=this.fixOutsideYPosition(t)):(this.yAttachBy=n.TEXT_ATTACH_POSITION.NONE,t=this.markerArea.yRange.getMiddleYPos()-this.boxHeight/2,this.yPos=this.fixYPositionByWindow(t,this.boxHeight/2),this.setYBoxValue())},i.prototype.getXPosForDrag=function(n){return this.fixXPosByMarkerArea(n,0)},i.prototype.getYPosForDrag=function(t){return this.isYOutside()?(t<this.markerArea.yRange.getMiddleYPos()?this.yAttachBy=n.TEXT_ATTACH_POSITION.TOP_OUTSIDE:t>this.markerArea.yRange.getMiddleYPos()&&(this.yAttachBy=n.TEXT_ATTACH_POSITION.BOTTOM_OUTSIDE),t=this.getYBoxPosition(),this.fixOutsideYPosition(t)):(t=this.fixYPosByMarkerArea(t,this.boxHeight),t=this.fixYPositionByWindow(t,this.boxHeight),t)},i.prototype.setXReferencePosition=function(n){this.mainXPos=n;var n=this.getXBoxPosition();this.xPos=this.fixXPositionByWindow(n,this.boxWidth);this.updateByPosition(this.xPos,this.yPos,!1)},i.prototype.updateByPosition=function(n,t,i){this.updateTextBox(n,t);i&&this.parentMarker.updateMarkerLine(this.mainXPos)},i.prototype.getYBoxPosition=function(){var t=this.yPos;return this.yAttachBy==n.TEXT_ATTACH_POSITION.BOTTOM_OUTSIDE?t=this.markerArea.yRange.getMinYPosition()-this.boxHeight-this.outsideMargin:this.yAttachBy==n.TEXT_ATTACH_POSITION.TOP_OUTSIDE&&(t=this.markerArea.yRange.getMaxYPosition()+this.outsideMargin),t},i.prototype.getXBoxPosition=function(){var t=this.mainXPos;return this.xAttachBy==n.TEXT_ATTACH_POSITION.RIGHT?t=this.mainXPos-this.boxWidth:this.xAttachBy==n.TEXT_ATTACH_POSITION.LEFT?t=this.mainXPos:this.xAttachBy==n.TEXT_ATTACH_POSITION.MIDDLE_HORIZONTAL&&(t=this.mainXPos-this.boxWidth/2),t},i.prototype.startDrag=function(){this.initXPos=this.mainXPos;this.initYPos=this.yPos},i.prototype.moveDrag=function(n,t){var i=this.initXPos+n,r=this.initYPos+t;this.yPos=this.getYPosForDrag(r);this.mainXPos=this.getXPosForDrag(i);this.xPos=this.getXBoxPosition();this.xPos=this.fixXPositionByWindow(this.xPos,this.boxWidth)},i.prototype.stopDrag=function(){this.setYBoxValue()},i.prototype.getState=function(){var t=new n.MarkerObjectState;return t.xAttachBy=this.xAttachBy,t.yAttachBy=this.yAttachBy,t.yBoxValue=this.yBoxValue,t},i.prototype.setState=function(t){var r=!1,i=t.yAttachBy,u=i==n.TEXT_ATTACH_POSITION.TOP_OUTSIDE||i==n.TEXT_ATTACH_POSITION.BOTTOM_OUTSIDE;r=this.isYOutside()!=u;r||(this.yAttachBy=i,this.xAttachBy=t.xAttachBy,this.xPos=this.getXBoxPosition(),this.xPos=this.fixXPositionByWindow(this.xPos,this.boxWidth),this.isYOutside()?this.yPos=this.getYBoxPosition():(this.yPos=this.getWaveform().yaxis.p2c(t.yBoxValue),this.yPos=this.fixYPositionByWindow(this.yPos,this.boxHeight/2),this.setYBoxValue()));this.updateByPosition(this.xPos,this.yPos,!1)},i}(n.MarkerTextObject);n.VerticalMarkerText=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r,u,f){f===void 0&&(f=Operations.WF_INDEX.FIRST);t.call(this,n,r,u,f);this.initYPos=0;this.initXPos=0;var e=this.getWaveform();this.mainYPos=e.yaxis.p2c(i);this.createTextObject()}return __extends(i,t),i.prototype.initXYPositions=function(){this.yAttachBy=n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL;this.yPos=this.getYBoxPosition();var t=this.markerArea.xRange.getMinXPosition();this.xPos=this.fixXPositionByWindow(t,this.boxWidth);this.setXBoxValue()},i.prototype.setYReferencePosition=function(n){this.mainYPos=n;this.yPos=this.getYBoxPosition();this.updateByPosition(this.xPos,this.yPos,!1)},i.prototype.getXPosForDrag=function(n){return n=this.fixXPosByMarkerArea(n,0),this.fixXPositionByWindow(n,this.boxWidth)},i.prototype.getYPosForDrag=function(t){return this.yAttachBy=t>this.mainYPos+this.boxHeight?n.TEXT_ATTACH_POSITION.TOP:t<this.mainYPos-this.boxHeight?n.TEXT_ATTACH_POSITION.BOTTOM:n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL,t=this.getYBoxPosition(),this.fixYPositionByWindow(t,this.boxHeight)},i.prototype.updateByPosition=function(n,t,i){this.updateTextBox(n,t);i&&this.parentMarker.updateMarkerLine(this.mainYPos)},i.prototype.getXBoxPosition=function(){return this.xPos},i.prototype.getYBoxPosition=function(){var t=this.mainYPos;return this.yAttachBy==n.TEXT_ATTACH_POSITION.BOTTOM?t=this.mainYPos-this.boxHeight:this.yAttachBy==n.TEXT_ATTACH_POSITION.TOP?t=this.mainYPos:this.yAttachBy==n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL&&(t=this.mainYPos-this.boxHeight/2),t},i.prototype.startDrag=function(){this.initYPos=this.yPos;this.initXPos=this.xPos},i.prototype.moveDrag=function(n,t){var i=this.initXPos+n,r=this.initYPos+t;this.xPos=this.getXPosForDrag(i);this.yPos=this.getYPosForDrag(r)},i.prototype.stopDrag=function(){this.setXBoxValue()},i.prototype.getState=function(){var t=new n.MarkerObjectState;return t.xAttachBy=this.xAttachBy,t.yAttachBy=this.yAttachBy,t.xBoxValue=this.xBoxValue,t},i.prototype.setState=function(n){this.xAttachBy=n.xAttachBy;this.yAttachBy=n.yAttachBy;this.yPos=this.getYBoxPosition();this.xPos=this.fixXPositionByWindow(this.getWaveform().xaxis.p2c(n.xBoxValue),this.boxWidth);this.setXBoxValue();this.updateByPosition(this.xPos,this.yPos,!1)},i}(n.MarkerTextObject);n.HorizontalLevelMarkerText=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r,u,f,e,o){o===void 0&&(o=Operations.WF_INDEX.FIRST);t.call(this,i,f,e,o);this.initYPos=0;this.initXPos=0;this.xBoxValue=r;this.yBoxValue=u;var s=new n.LineAttributes(!1,!1,n.LINE_DIRECTION.ANY);e.useBoxLine&&(this.boxLine=new n.MarkerLineObject(i,r,u,r,u,f,s,null,o));this.createTextObject()}return __extends(i,t),i.prototype.initXYPositions=function(){var t,i;this.xAttachBy=n.TEXT_ATTACH_POSITION.NONE;t=this.getWaveform().xaxis.p2c(this.xBoxValue);this.parentMarker.markerManager.relXBoxPos!=0&&(t+=this.parentMarker.markerManager.relXBoxPos,this.xBoxValue=this.getWaveform().xaxis.c2p(t));this.xPos=this.fixXPositionByWindow(t,this.boxWidth);i=this.getWaveform().yaxis.p2c(this.yBoxValue);this.parentMarker.markerManager.relYBoxPos!=0&&(i+=this.parentMarker.markerManager.relYBoxPos,this.yBoxValue=this.getWaveform().yaxis.c2p(i));this.yPos=this.fixYPositionByWindow(i,this.boxHeight)},i.prototype.getXPosForDrag=function(n){return n=this.fixXPosByMarkerArea(n,this.boxWidth),this.fixXPositionByWindow(n,this.boxWidth)},i.prototype.getYPosForDrag=function(n){return n=this.fixYPosByMarkerArea(n,0),this.fixYPositionByWindow(n,this.boxHeight)},i.prototype.updateByPosition=function(n,t,i){this.updateTextBox(n,t);i&&this.parentMarker.updateMarkerLine(this.xPos)},i.prototype.updateBoxLineAttachedPoint=function(){this.boxLine&&(this.boxLine.setXPosition(this.getMiddleXPosition(),n.POINT_INDEX.SECOND),this.boxLine.setYPosition(this.getMiddleYPosition(),n.POINT_INDEX.SECOND),this.boxLine.update())},i.prototype.setBoxLineFirstPoint=function(t,i){this.boxLine&&(this.boxLine.setXPosition(t,n.POINT_INDEX.FIRST),this.boxLine.setYPosition(i,n.POINT_INDEX.FIRST),this.boxLine.update())},i.prototype.getYBoxPosition=function(){return this.yPos},i.prototype.getXBoxPosition=function(){return this.xPos},i.prototype.startDrag=function(){this.initXPos=this.xPos;this.initYPos=this.yPos},i.prototype.moveDrag=function(n,t){var i=this.initXPos+n,r=this.initYPos+t;this.yPos=this.getYPosForDrag(r);this.xPos=this.getXPosForDrag(i)},i.prototype.stopDrag=function(){this.setXBoxValue();this.setYBoxValue()},i.prototype.getState=function(){var t=new n.MarkerObjectState;return t.xAttachBy=this.xAttachBy,t.yAttachBy=this.yAttachBy,t.xBoxValue=this.xBoxValue,t.yBoxValue=this.yBoxValue,t},i.prototype.setState=function(n){this.yAttachBy=n.yAttachBy;this.xAttachBy=n.xAttachBy;this.xPos=this.getWaveform().xaxis.p2c(n.xBoxValue);this.xPos=this.fixXPositionByWindow(this.xPos,this.boxWidth);this.setXBoxValue();this.yPos=this.getWaveform().yaxis.p2c(n.yBoxValue);this.yPos=this.fixYPositionByWindow(this.yPos,this.boxHeight);this.setYBoxValue();this.updateByPosition(this.xPos,this.yPos,!1)},i.INITIAL_TEXT_SHIFT=20,i}(n.MarkerTextObject);n.PointMarkerText=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(i){function r(t,r,u,f,e){var h,l;i.call(this,t,u,e);this.yValue=0;this.yValue=r;this.dragDirection=f;var o=this.getWaveform(),a=o.getXWaveformMin(),v=o.getXWaveformMax();this.markerObjects=[];var s=new n.MarkerObjectArea(o),y=new n.LineAttributes(!1,!1,n.LINE_DIRECTION.HORIZONTAL),c=null;f!=n.DRAG_DIRECTION.NONE?(c=new n.DragAttributes(f),h=o.getVisibleYRange(),s.yRange=new n.AttachRange(h.ymin,h.ymax,o,n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL)):s.yRange=new n.AttachRange(r,r,o,n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL);this.markerMainLine=new n.MarkerLineObject(this,a,r,v,r,s,y,c);this.markerObjects.push(this.markerMainLine);l=new n.TextAttributes(!1);this.markerText=new n.HorizontalLevelMarkerText(this,r,s,l,e);this.markerObjects.push(this.markerText);this.setMenu()}return __extends(r,i),r.prototype.updateAssociated=function(t,i){var r,u;t instanceof n.MarkerLineObject&&(r=t.getReferencePosition(),t.getDragDirection()==n.DRAG_DIRECTION.VERTICAL&&(this.markerText&&i&&(this.markerText.setMeasText(this.markerManager.getMeasTextForYValue(t.getReferenceValue()),!1),this.markerText.setYReferencePosition(r)),i&&(u=WaveViewer.AxisUnits.formatDataValueForMeasurement(t.getReferenceValue(),3,null),this.markerManager.updateInputControlByDragging(u))))},r.prototype.updateMarkerLine=function(n){this.markerMainLine.updateYPosition(n)},r.prototype.getTextObject=function(){return this.markerText},r.prototype.getMarkerLine=function(){return this.markerMainLine},r.prototype.getRequest=function(){return new t(this)},r.restoreMarker=function(n,t,i){var f=i.getPlottedWaveformByFlotId(t.flotWaveformId),u;return f?(u=new r(n,t.yValue,t.measText,t.dragDirection,t.resultIndex),u.markerText&&t.textState&&u.markerText.setState(t.textState),u):null},r.prototype.highlight=function(){var t=this.getTextObject(),n;t&&t.highligh();n=this.getMarkerLine();n&&n.highligh()},r.prototype.unhighlight=function(){var t=this.getTextObject(),n;t&&t.unhighligh();n=this.getMarkerLine();n&&n.unhighligh()},r}(n.BaseMarker),t;n.HorizontalLevelMarker=i;t=function(t){function i(i){t.call(this,n.MARKER_TYPE.HORIZONTAL_LEVEL);this.saveState(i)}return __extends(i,t),i.prototype.saveState=function(n){t.prototype.saveBaseState.call(this,n);this.yValue=n.yValue;this.dragDirection=n.dragDirection},i}(n.MarkerState);n.HorizontalLevelMarkerState=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(i){function r(t,r,u,f,e,o,s){var h,c,a,l,p,v,y;i.call(this,t,f,o);this.showLevel=!1;this.xValue=r;this.yValue=u;this.dragDirection=e;this.showLevel=s;this.markerObjects=[];h=this.getWaveform();c=new n.MarkerObjectArea(h);s&&(a=new n.LineAttributes(!1,!1,n.LINE_DIRECTION.HORIZONTAL),l=new n.MarkerObjectArea(h),l.yRange=new n.AttachRange(u,u,h,n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL),p=h.xaxis.min,this.markerRefLine=new n.MarkerLineObject(this,h.xaxis.min,u,h.xaxis.max,u,l,a,null),this.markerObjects.push(this.markerRefLine));v=new n.DragAttributes(e);this.markerPoint=new n.MarkerPointObject(this,r,u,c,v,0,Operations.WF_INDEX.FIRST);this.markerObjects.push(this.markerPoint);y=new n.TextAttributes(!0);this.markerText=new n.PointMarkerText(this,r,u,c,y,o);this.markerObjects.push(this.markerText);this.setMenu()}return __extends(r,i),r.prototype.updateAssociated=function(t){t instanceof n.MarkerPointObject&&(this.markerText.setMeasText(this.markerManager.getMeasTextForXYValue(t.xValue,t.yValue),!0),this.markerText.setBoxLineFirstPoint(t.xPos,t.yPos))},r.prototype.updateMarkerLine=function(){},r.prototype.getTextObject=function(){return this.markerText},r.prototype.getPointObject=function(){return this.markerPoint},r.prototype.getMarkerLine=function(){return null},r.prototype.getRequest=function(){return new t(this)},r.restoreMarker=function(n,t,i){var f=i.getPlottedWaveformByFlotId(t.flotWaveformId),u;return f?(u=new r(n,t.xValue,t.yValue,t.measText,t.dragDirection,t.resultIndex,t.showLevel),u.markerPoint.setState(t.pointState),u.markerText&&t.textState&&u.markerText.setState(t.textState),u):null},r.prototype.highlight=function(){var t=this.getTextObject(),n;t&&t.highligh();n=this.getMarkerLine();n&&n.highligh();this.markerRefLine&&this.markerRefLine.highligh()},r.prototype.unhighlight=function(){var t=this.getTextObject(),n;t&&t.unhighligh();n=this.getMarkerLine();n&&n.unhighligh();this.markerRefLine&&this.markerRefLine.unhighligh()},r}(n.BaseMarker),t;n.PointMarker=i;t=function(t){function i(i){t.call(this,n.MARKER_TYPE.POINT);this.showLevel=!1;this.saveState(i)}return __extends(i,t),i.prototype.saveState=function(n){t.prototype.saveBaseState.call(this,n);this.xValue=n.xValue;this.yValue=n.yValue;this.pointState=n.getPointObject().getState();this.dragDirection=n.dragDirection;this.showLevel=n.showLevel},i}(n.MarkerState);n.PointMarkerState=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(i){function r(n,t,r,u,f,e,o){i.call(this,n,e,o);this.deltaPos=20;this.isVerticalOnly=!1;this.xValue1=t;this.xValue2=u;this.yValue1=r;this.yValue2=f;this.xValue1==this.xValue2&&(this.deltaPos=0);this.markerManager.isMoving&&this.markerManager.showInEasyMode?this.getEasyStructure():(this.setupMarker(),this.setMenu())}return __extends(r,i),r.prototype.getEasyStructure=function(){var e;this.markerObjects=[];var i=this.getLeftOrTopPoint(),f=this.getRightOrBottomPoint(),t=i.pointPosition==this.markerManager.getMockPointPosition()?i:f,r=this.getWaveform(),u=new n.MarkerObjectArea(r);u.xRange=new n.AttachRange(t.xValue,t.xValue,r,n.TEXT_ATTACH_POSITION.NONE);u.yRange=new n.AttachRange(t.yValue,t.yValue-.1*Math.abs(i.yValue-f.yValue),r,n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL);e=new n.TextAttributes(!1);this.markerText=new n.HorizontalDeltaMarkerText(this,t.yValue,u,e);this.markerObjects.push(this.markerText)},r.prototype.setupMarker=function(){var e,o,s,w,h,c,a,v;this.isVerticalOnly=this.xValue1==this.xValue2;var t=this.getWaveform(),f=this.isVerticalOnly?this.xValue1:(this.xValue2+this.xValue1)/2,b=t.xaxis.c2p(this.deltaPos),l=t.xaxis.p2c(f),y=t.xaxis.c2p(l+this.deltaPos),p=t.xaxis.c2p(l-this.deltaPos);this.markerObjects=[];var r=this.getLeftOrTopPoint(),u=this.getRightOrBottomPoint(),i=new n.MarkerObjectArea(t);i.xRange=new n.AttachRange(this.xValue1,this.xValue2,t,n.TEXT_ATTACH_POSITION.MIDDLE_HORIZONTAL);i.yRange=new n.AttachRange(this.yValue1,this.yValue2,t,n.TEXT_ATTACH_POSITION.NONE);e=null;this.markerManager.hasMultipleResults()&&(e=new n.DragAttributes(n.DRAG_DIRECTION.MEASUREMENT));o=new n.MarkerPointObject(this,r.xValue,r.yValue,i,e,r.pointIndex,Operations.WF_INDEX.FIRST);o.pointPosition=n.POINT_POSITION.LEFT;this.markerObjects.push(o);s=new n.MarkerPointObject(this,u.xValue,u.yValue,i,e,u.pointIndex,Operations.WF_INDEX.FIRST);s.pointPosition=n.POINT_POSITION.RIGHT;this.markerObjects.push(s);w=t.getMiddleLevel();this.isVerticalOnly||(h=new n.LineAttributes(!0,!1,n.LINE_DIRECTION.HORIZONTAL),this.leftRefLine=new n.MarkerLineObject(this,r.xValue,r.yValue,y,r.yValue,i,h,null),this.markerObjects.push(this.leftRefLine),this.rightRefLine=new n.MarkerLineObject(this,p,u.yValue,u.xValue,u.yValue,i,h,null),this.markerObjects.push(this.rightRefLine));c=null;this.isVerticalOnly||(c=new n.DragAttributes(n.DRAG_DIRECTION.HORIZONTAL));a=new n.LineAttributes(!1,!0,n.LINE_DIRECTION.VERTICAL);this.markerMainLine=new n.MarkerLineObject(this,f,this.yValue1,f,this.yValue2,i,a,c);this.markerObjects.push(this.markerMainLine);v=new n.TextAttributes(!1);this.markerText=new n.VerticalMarkerText(this,f,i,v,this.resultIndex);this.markerObjects.push(this.markerText)},r.prototype.isPointVisibleByY=function(t){var i=new n.MarkerObjectArea(this.getWaveform());return t.yValue<i.yRange.getMinValue()?!1:t.yValue>i.yRange.getMaxValue()?!1:!0},r.prototype.getLeftOrTopPoint=function(){return this.isVerticalOnly?this.yValue1>this.yValue2?new n.LinePoint(this.xValue1,this.yValue1,n.POINT_INDEX.FIRST):new n.LinePoint(this.xValue2,this.yValue2,n.POINT_INDEX.SECOND):this.xValue1<this.xValue2?new n.LinePoint(this.xValue1,this.yValue1,n.POINT_INDEX.FIRST):new n.LinePoint(this.xValue2,this.yValue2,n.POINT_INDEX.SECOND)},r.prototype.getRightOrBottomPoint=function(){return this.isVerticalOnly?this.yValue1<this.yValue2?new n.LinePoint(this.xValue1,this.yValue1,n.POINT_INDEX.FIRST):new n.LinePoint(this.xValue2,this.yValue2,n.POINT_INDEX.SECOND):this.xValue1>this.xValue2?new n.LinePoint(this.xValue1,this.yValue1,n.POINT_INDEX.FIRST):new n.LinePoint(this.xValue2,this.yValue2,n.POINT_INDEX.SECOND)},r.prototype.updateMarkerLine=function(n){this.markerMainLine.updateXPosition(n)},r.prototype.updateAssociated=function(t){if(t instanceof n.MarkerLineObject&&t.getDragDirection()==n.DRAG_DIRECTION.HORIZONTAL){var i=t.getReferencePosition();this.markerText&&this.markerText.setXReferencePosition(i);this.isVerticalOnly||(this.leftRefLine.setXPosition(i+this.deltaPos,this.leftRefLine.getRightPointIndex()),this.rightRefLine.setXPosition(i-this.deltaPos,this.rightRefLine.getLeftPointIndex()))}},r.prototype.getTextObject=function(){return this.markerText},r.prototype.getMarkerLine=function(){return this.markerMainLine},r.prototype.getRequest=function(){return new t(this)},r.restoreMarker=function(n,t,i){var f=i.getPlottedWaveformByFlotId(t.flotWaveformId),u;return f?(u=new r(n,t.xValue1,t.yValue1,t.xValue2,t.yValue2,t.measText,t.resultIndex),u.markerMainLine.setState(t.markerLineState),u.markerText&&t.textState&&u.markerText.setState(t.textState),u):null},r.prototype.highlight=function(){var t=this.getTextObject(),n;t&&t.highligh();n=this.getMarkerLine();n&&n.highligh();this.leftRefLine&&this.leftRefLine.highligh();this.rightRefLine&&this.rightRefLine.highligh()},r.prototype.unhighlight=function(){var t=this.getTextObject(),n;t&&t.unhighligh();n=this.getMarkerLine();n&&n.unhighligh();this.leftRefLine&&this.leftRefLine.unhighligh();this.rightRefLine&&this.rightRefLine.unhighligh()},r}(n.BaseMarker),t;n.VerticalDeltaMarker=i;t=function(t){function i(i){t.call(this,n.MARKER_TYPE.VERTICAL_DELTA);this.saveState(i)}return __extends(i,t),i.prototype.saveState=function(n){t.prototype.saveBaseState.call(this,n);this.xValue1=n.xValue1;this.yValue1=n.yValue1;this.xValue2=n.xValue2;this.yValue2=n.yValue2;this.markerLineState=n.getMarkerLine().getState()},i}(n.MarkerState);n.VerticalDeltaMarkerState=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(i){function r(n,t,r,u,f){i.call(this,n,u,f);this.deltaPos=20;this.verticalDelta=20;this.isHorizontalOnly=!1;this.topWfIndex=Operations.WF_INDEX.FIRST;this.bottomWfIndex=Operations.WF_INDEX.SECOND;this.isSingleRow=!1;this.firstSourcePoint=t;this.secondSourcePoint=r;t.xValue==r.xValue&&(this.deltaPos=0);this.isHorizontalOnly=t.yValue==r.yValue;this.setPointPosition(t,r);n.isMoving&&n.showInEasyMode?this.getEasyStructure():(this.topRowSetup(),this.bottomRowSetup(),this.isSingleRow||this.middleRowsSetup(),this.setMenu())}return __extends(r,i),r.prototype.getEasyStructure=function(){var f;this.markerObjects=[];var s=Math.min(this.topLeftPoint.xValue,this.bottomRightPoint.xValue),h=Math.max(this.topLeftPoint.xValue,this.bottomRightPoint.xValue),e=Math.min(this.topLeftPoint.yValue,this.bottomRightPoint.yValue),o=Math.max(this.topLeftPoint.yValue,this.bottomRightPoint.yValue),t=this.topLeftPoint.pointPosition==this.markerManager.getMockPointPosition()?this.topLeftPoint:this.bottomRightPoint,u=this.topLeftPoint.pointPosition==this.markerManager.getMockPointPosition()?this.topWfIndex:this.bottomWfIndex,i=this.getWaveform(u),r=new n.MarkerObjectArea(i);r.xRange=new n.AttachRange(t.xValue,t.xValue,i,n.TEXT_ATTACH_POSITION.NONE);r.yRange=new n.AttachRange(t.yValue,t.yValue-.1*(o-e),i,n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL);f=new n.TextAttributes(!1);this.markerText=new n.HorizontalDeltaMarkerText(this,t.yValue,r,f,u);this.markerObjects.push(this.markerText)},r.prototype.setPointPosition=function(t,i){var f=this.getWaveform(Operations.WF_INDEX.FIRST),r=this.waveContainer.getCurrentRowIndex(f.parentRow),e=this.getWaveform(Operations.WF_INDEX.SECOND),u=this.waveContainer.getCurrentRowIndex(e.parentRow);r==u?(this.isSingleRow=!0,this.isHorizontalOnly?this.setLeftRightPositions(t,i):this.setTopBottomPositions(t,i)):r<u?(this.topLeftPoint=t,this.topLeftPoint.pointPosition=n.POINT_POSITION.TOP,this.bottomRightPoint=i,this.bottomRightPoint.pointPosition=n.POINT_POSITION.BOTTOM,this.topWfIndex=Operations.WF_INDEX.FIRST,this.bottomWfIndex=Operations.WF_INDEX.SECOND):(this.topLeftPoint=i,this.topLeftPoint.pointPosition=n.POINT_POSITION.TOP,this.bottomRightPoint=t,this.bottomRightPoint.pointPosition=n.POINT_POSITION.BOTTOM,this.topWfIndex=Operations.WF_INDEX.SECOND,this.bottomWfIndex=Operations.WF_INDEX.FIRST)},r.prototype.setLeftRightPositions=function(t,i){t.xValue<i.xValue?(this.topLeftPoint=t,this.topLeftPoint.pointPosition=n.POINT_POSITION.LEFT,this.bottomRightPoint=i,this.bottomRightPoint.pointPosition=n.POINT_POSITION.RIGHT,this.topWfIndex=Operations.WF_INDEX.FIRST,this.bottomWfIndex=Operations.WF_INDEX.SECOND):(this.topLeftPoint=i,this.topLeftPoint.pointPosition=n.POINT_POSITION.LEFT,this.bottomRightPoint=t,this.bottomRightPoint.pointPosition=n.POINT_POSITION.RIGHT,this.topWfIndex=Operations.WF_INDEX.SECOND,this.bottomWfIndex=Operations.WF_INDEX.FIRST)},r.prototype.setTopBottomPositions=function(t,i){t.yValue>i.yValue?(this.topLeftPoint=t,this.topLeftPoint.pointPosition=n.POINT_POSITION.TOP,this.bottomRightPoint=i,this.bottomRightPoint.pointPosition=n.POINT_POSITION.BOTTOM,this.topWfIndex=Operations.WF_INDEX.FIRST,this.bottomWfIndex=Operations.WF_INDEX.SECOND):(this.topLeftPoint=i,this.topLeftPoint.pointPosition=n.POINT_POSITION.TOP,this.bottomRightPoint=t,this.bottomRightPoint.pointPosition=n.POINT_POSITION.BOTTOM,this.topWfIndex=Operations.WF_INDEX.SECOND,this.bottomWfIndex=Operations.WF_INDEX.FIRST)},r.prototype.topRowSetup=function(){var r=this.topWfIndex,t=this.getWaveform(r),i,e,o,s,a,v;this.firstRow=t.parentRow;var h=Math.min(this.topLeftPoint.xValue,this.bottomRightPoint.xValue),c=Math.max(this.topLeftPoint.xValue,this.bottomRightPoint.xValue),p=Math.min(this.topLeftPoint.yValue,this.bottomRightPoint.yValue),w=Math.max(this.topLeftPoint.yValue,this.bottomRightPoint.yValue),u=t.yaxis.c2p(this.firstRow.getRowHeight()+this.verticalDelta);this.isSingleRow&&(u=this.bottomRightPoint.yValue);var f=this.isHorizontalOnly?this.topLeftPoint.yValue:(u+this.topLeftPoint.yValue)/2,l=t.yaxis.p2c(f),b=t.yaxis.c2p(l+this.deltaPos),y=t.yaxis.c2p(l-this.deltaPos),k=(this.topLeftPoint.xValue+this.bottomRightPoint.xValue)/2;this.markerObjects=[];this.markerArtefacts=[];i=new n.MarkerObjectArea(t);i.xRange=new n.AttachRange(h,c,t,n.TEXT_ATTACH_POSITION.NONE);i.yRange=new n.AttachRange(this.topLeftPoint.yValue,u,t,n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL);this.isPointVisibleByX(this.topLeftPoint)&&(e=null,this.markerManager.hasMultipleResults()&&(e=new n.DragAttributes(n.DRAG_DIRECTION.MEASUREMENT)),this.markerPoint1=new n.MarkerPointObject(this,this.topLeftPoint.xValue,this.topLeftPoint.yValue,i,e,this.topLeftPoint.pointIndex,r),this.markerPoint1.pointPosition=this.topLeftPoint.pointPosition,this.markerObjects.push(this.markerPoint1));this.isHorizontalOnly||(o=new n.LineAttributes(!0,!1,n.LINE_DIRECTION.VERTICAL),this.isPointVisibleByX(this.topLeftPoint)&&(this.upRefLine=new n.MarkerLineObject(this,this.topLeftPoint.xValue,this.topLeftPoint.yValue,this.topLeftPoint.xValue,u,i,o,null,r),this.markerObjects.push(this.upRefLine)),this.isPointVisibleByX(this.bottomRightPoint)&&(this.downRefLine=new n.MarkerLineObject(this,this.bottomRightPoint.xValue,y,this.bottomRightPoint.xValue,u,i,o,null,r),this.markerObjects.push(this.downRefLine)));s=null;this.isHorizontalOnly||(s=new n.DragAttributes(n.DRAG_DIRECTION.VERTICAL));a=new n.LineAttributes(!1,!0,n.LINE_DIRECTION.HORIZONTAL);this.markerMainLine=new n.MarkerLineObject(this,h,f,c,f,i,a,s,r);this.markerObjects.push(this.markerMainLine);v=new n.TextAttributes(!1);(this.isPointVisibleByX(this.topLeftPoint)||this.isPointVisibleByX(this.bottomRightPoint))&&(this.markerText=new n.HorizontalDeltaMarkerText(this,f,i,v,r),this.markerObjects.push(this.markerText))},r.prototype.isPointVisibleByX=function(t){var i=new n.MarkerObjectArea(this.getWaveform());return t.xValue<i.xRange.getMinValue()?!1:t.xValue>i.xRange.getMaxValue()?!1:!0},r.prototype.bottomRowSetup=function(){var u=this.bottomWfIndex,i=this.getWaveform(u),e,t,f,o,r;this.lastRow=i.parentRow;e=i.yaxis.c2p(-this.verticalDelta);t=new n.MeasPoint;t.xValue1=this.bottomRightPoint.xValue;t.yValue1=this.bottomRightPoint.yValue;t.xValue2=this.bottomRightPoint.xValue;t.yValue2=e;this.isPointVisibleByX(this.bottomRightPoint)&&(r=new n.MarkerObjectArea(i),f=null,this.markerManager.hasMultipleResults()&&(f=new n.DragAttributes(n.DRAG_DIRECTION.MEASUREMENT)),this.markerPoint2=new n.MarkerPointObject(this,t.xValue1,t.yValue1,r,f,this.bottomRightPoint.pointIndex,u),this.markerPoint2.pointPosition=n.POINT_POSITION.BOTTOM,this.markerObjects.push(this.markerPoint2));this.isHorizontalOnly||this.isSingleRow||(o=new n.LineAttributes(!0,!1,n.LINE_DIRECTION.VERTICAL),this.isPointVisibleByX(this.bottomRightPoint)&&(r=new n.MarkerObjectArea(i),this.downRefLine2=new n.MarkerLineObject(this,t.xValue1,t.yValue1,t.xValue2,t.yValue2,r,o,null,u),this.markerObjects.push(this.downRefLine2)))},r.prototype.middleRowsSetup=function(){for(var n,r=this.getWaveform(this.bottomWfIndex),u=r.xaxis.p2c(this.bottomRightPoint.xValue),i=!1,t=0;t<this.waveContainer.getRows().length;t++)if(n=this.waveContainer.getRows()[t],i)if(n!=this.lastRow)this.drawArtefactLine(u,n);else break;else n==this.firstRow&&(i=!0)},r.prototype.drawArtefactLine=function(t,i){var r=i.getPaper(),o=r.canvas.clientHeight?r.canvas.clientHeight:r.height,f=i.getPlotOffset(),s=WaveViewer.WaveUtils.getTransformString(f.left,f.top),h=adjustPosition(t),c=adjustPosition(t),l=o,e="M "+h+" 0",u;e+=" L "+c+" "+l;u=r.path(e);u.attr({"stroke-width":n.MarkerObject.LINE_WIDTH,stroke:this.getMarkerDefaultColor(),"stroke-dasharray":n.MarkerObject.DASH_STROKE});u.transform(s);this.markerArtefacts.push(u)},r.prototype.updateMarkerLine=function(n){this.markerMainLine.updateYPosition(n)},r.prototype.updateAssociated=function(t,i){if(t instanceof n.MarkerLineObject){var r=t.getReferencePosition();t.getDragDirection()==n.DRAG_DIRECTION.VERTICAL&&(this.markerText&&i&&this.markerText.setYReferencePosition(r),this.isHorizontalOnly||(this.upRefLine&&this.upRefLine.setYPosition(r+this.deltaPos,this.upRefLine.getBottomPointIndex()),this.downRefLine&&this.downRefLine.setYPosition(r-this.deltaPos,this.downRefLine.getTopPointIndex())))}},r.prototype.getTextObject=function(){return this.markerText},r.prototype.getMarkerLine=function(){return this.markerMainLine},r.prototype.getRequest=function(){return new t(this)},r.restoreMarker=function(t,i,u){var e=u.getPlottedWaveformByFlotId(i.flotWaveformId);if(e){var o=new n.LinePoint(i.topXValue,i.topYValue,i.topPointIndex),s=new n.LinePoint(i.bottomXValue,i.bottomYValue,i.bottomPointIndex),f=new r(t,o,s,i.measText,i.resultIndex);return f.markerMainLine.setState(i.markerLineState),f.markerText&&i.textState&&f.markerText.setState(i.textState),f}return null},r.prototype.highlight=function(){var r=this.getTextObject(),i,t;if(r&&r.highligh(),i=this.getMarkerLine(),i&&i.highligh(),this.upRefLine&&this.upRefLine.highligh(),this.downRefLine&&this.downRefLine.highligh(),this.downRefLine2&&this.downRefLine2.highligh(),!this.markerManager.isInputControl())for(t=0;t<this.markerArtefacts.length;t++)this.markerArtefacts[t].attr({stroke:n.BaseMarker.HIGHLIGHT_COLOR})},r.prototype.unhighlight=function(){var i=this.getTextObject(),t,n;for(i&&i.unhighligh(),t=this.getMarkerLine(),t&&t.unhighligh(),this.upRefLine&&this.upRefLine.unhighligh(),this.downRefLine&&this.downRefLine.unhighligh(),this.downRefLine2&&this.downRefLine2.unhighligh(),n=0;n<this.markerArtefacts.length;n++)this.markerArtefacts[n].attr({stroke:this.getMarkerDefaultColor()})},r}(n.BaseMarker),t;n.HorizontalDeltaMarker=i;t=function(t){function i(i){t.call(this,n.MARKER_TYPE.HORIZONTAL_DELTA);this.topPointIndex=n.POINT_INDEX.FIRST;this.bottomPointIndex=n.POINT_INDEX.SECOND;this.saveState(i)}return __extends(i,t),i.prototype.saveState=function(n){t.prototype.saveBaseState.call(this,n);this.topXValue=n.firstSourcePoint.xValue;this.topYValue=n.firstSourcePoint.yValue;this.bottomXValue=n.secondSourcePoint.xValue;this.bottomYValue=n.secondSourcePoint.yValue;this.topPointIndex=n.firstSourcePoint.pointIndex;this.bottomPointIndex=n.secondSourcePoint.pointIndex;this.markerLineState=n.getMarkerLine().getState()},i}(n.MarkerState);n.HorizontalDeltaMarkerState=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(i){function r(t,r,u,f,e,o){var l,w,b,k;i.call(this,t,e,o);this.deltaPos=20;this.isVerticalOnly=!1;this.yValue1=u;this.yValue2=f;this.xValue1=r;this.xValue2=r;var s=this.getWaveform(),d=(this.yValue2+this.yValue1)/2,g=s.xaxis.p2c(d);this.markerObjects=[];var a=Math.min(this.yValue1,this.yValue2),v=Math.max(this.yValue1,this.yValue2),y=s.getXWaveformMin(),p=s.getXWaveformMax(),c=s.getMiddlePoint(),h=new n.MarkerObjectArea(s);h.yRange=new n.AttachRange(this.yValue1,this.yValue2,s,n.TEXT_ATTACH_POSITION.NONE);this.isVerticalOnly||(l=new n.LineAttributes(!0,!1,n.LINE_DIRECTION.HORIZONTAL),this.topRefLine=new n.MarkerLineObject(this,y,v,p,v,h,l,null),this.markerObjects.push(this.topRefLine),this.bottomRefLine=new n.MarkerLineObject(this,y,a,p,a,h,l,null),this.markerObjects.push(this.bottomRefLine));w=new n.DragAttributes(n.DRAG_DIRECTION.HORIZONTAL);b=new n.LineAttributes(!1,!0,n.LINE_DIRECTION.VERTICAL);this.markerMainLine=new n.MarkerLineObject(this,c,this.yValue1,c,this.yValue2,h,b,w);this.markerObjects.push(this.markerMainLine);k=new n.TextAttributes(!1);this.markerText=new n.VerticalMarkerText(this,c,h,k,o);this.markerObjects.push(this.markerText);this.setMenu()}return __extends(r,i),r.prototype.updateAssociated=function(t){if(t instanceof n.MarkerLineObject&&t.getDragDirection()==n.DRAG_DIRECTION.HORIZONTAL){var i=t.getReferencePosition();this.markerText.setXReferencePosition(i)}},r.prototype.updateMarkerLine=function(n){this.markerMainLine.updateXPosition(n)},r.prototype.getTextObject=function(){return this.markerText},r.prototype.getMarkerLine=function(){return this.markerMainLine},r.prototype.getRequest=function(){return new t(this)},r.restoreMarker=function(n,t,i){var f=i.getPlottedWaveformByFlotId(t.flotWaveformId),u;return f?(u=new r(n,t.xValue1,t.yValue1,t.yValue2,t.measText,t.resultIndex),u.markerMainLine.setState(t.markerLineState),u.markerText&&t.textState&&u.markerText.setState(t.textState),u):null},r.prototype.highlight=function(){var t=this.getTextObject(),n;t&&t.highligh();n=this.getMarkerLine();n&&n.highligh();this.topRefLine&&this.topRefLine.highligh();this.bottomRefLine&&this.bottomRefLine.highligh()},r.prototype.unhighlight=function(){var t=this.getTextObject(),n;t&&t.unhighligh();n=this.getMarkerLine();n&&n.unhighligh();this.topRefLine&&this.topRefLine.unhighligh();this.bottomRefLine&&this.bottomRefLine.unhighligh()},r}(n.BaseMarker),t;n.VerticalRangeMarker=i;t=function(t){function i(i){t.call(this,n.MARKER_TYPE.VERTICAL_RANGE);this.saveState(i)}return __extends(i,t),i.prototype.saveState=function(n){t.prototype.saveBaseState.call(this,n);this.xValue1=n.xValue1;this.yValue1=n.yValue1;this.xValue2=n.xValue2;this.yValue2=n.yValue2;this.markerLineState=n.getMarkerLine().getState()},i}(n.MarkerState);n.VerticalRangeMarkerState=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i=function(i){function r(n,t,r,u,f,e){i.call(this,n,f,e);this.xValue=t;this.yValue=r;this.yLevelValue=u;this.markerManager.isMoving&&this.markerManager.showInEasyMode?this.getEasyStructure():(this.setupMarker(),this.setMenu())}return __extends(r,i),r.prototype.getEasyStructure=function(){var u;this.markerObjects=[];var t=new n.LinePoint(this.xValue,this.yValue,n.POINT_INDEX.FIRST),i=this.getWaveform(),r=new n.MarkerObjectArea(i);r.xRange=new n.AttachRange(t.xValue,t.xValue,i,n.TEXT_ATTACH_POSITION.NONE);r.yRange=new n.AttachRange(t.yValue,t.yValue,i,n.TEXT_ATTACH_POSITION.MIDDLE_VERTICAL);u=new n.TextAttributes(!1);this.markerText=new n.HorizontalDeltaMarkerText(this,t.yValue,r,u);this.markerObjects.push(this.markerText)},r.prototype.setupMarker=function(){var t=this.getWaveform(),r,i,u,f,o,s;this.markerObjects=[];r=new n.LinePoint(this.xValue,this.yValue,n.POINT_INDEX.FIRST);i=new n.MarkerObjectArea(t);i.xRange=new n.AttachRange(this.xValue,this.xValue,t,n.TEXT_ATTACH_POSITION.MIDDLE_HORIZONTAL);i.yRange=new n.AttachRange(this.yValue,this.yLevelValue,t,n.TEXT_ATTACH_POSITION.NONE);u=null;this.markerManager.hasMultipleResults()&&(u=new n.DragAttributes(n.DRAG_DIRECTION.MEASUREMENT));f=new n.MarkerPointObject(this,r.xValue,r.yValue,i,u,r.pointIndex,Operations.WF_INDEX.FIRST);f.pointPosition=n.POINT_POSITION.TOP;this.markerObjects.push(f);var h=new n.LineAttributes(!0,!1,n.LINE_DIRECTION.HORIZONTAL),c=t.getXWaveformMin(),l=t.getXWaveformMax(),e=new n.MarkerObjectArea(t);e.yRange=new n.AttachRange(this.yLevelValue,this.yLevelValue,t,n.TEXT_ATTACH_POSITION.NONE);this.levelLine=new n.MarkerLineObject(this,c,this.yLevelValue,l,this.yLevelValue,e,h,null);this.markerObjects.push(this.levelLine);o=new n.LineAttributes(!1,!0,n.LINE_DIRECTION.VERTICAL);this.markerMainLine=new n.MarkerLineObject(this,this.xValue,this.yValue,this.xValue,this.yLevelValue,i,o,null);this.markerObjects.push(this.markerMainLine);s=new n.TextAttributes(!1);this.markerText=new n.VerticalMarkerText(this,this.xValue,i,s,this.resultIndex);this.markerObjects.push(this.markerText)},r.prototype.isPointVisibleByY=function(t){var i=new n.MarkerObjectArea(this.getWaveform());return t.yValue<i.yRange.getMinValue()?!1:t.yValue>i.yRange.getMaxValue()?!1:!0},r.prototype.updateMarkerLine=function(n){this.markerMainLine.updateXPosition(n)},r.prototype.updateAssociated=function(t){if(t instanceof n.MarkerLineObject&&t.getDragDirection()==n.DRAG_DIRECTION.HORIZONTAL){var i=t.getReferencePosition();this.markerText&&this.markerText.setXReferencePosition(i)}},r.prototype.getTextObject=function(){return this.markerText},r.prototype.getMarkerLine=function(){return this.markerMainLine},r.prototype.getRequest=function(){return new t(this)},r.restoreMarker=function(n,t,i){var f=i.getPlottedWaveformByFlotId(t.flotWaveformId),u;return f?(u=new r(n,t.xValue,t.yValue,t.yLevelValue,t.measText,t.resultIndex),u.markerMainLine.setState(t.markerLineState),u.markerText&&t.textState&&u.markerText.setState(t.textState),u):null},r.prototype.highlight=function(){var t=this.getTextObject(),n;t&&t.highligh();n=this.getMarkerLine();n&&n.highligh();this.levelLine&&this.levelLine.highligh()},r.prototype.unhighlight=function(){var t=this.getTextObject(),n;t&&t.unhighligh();n=this.getMarkerLine();n&&n.unhighligh();this.levelLine&&this.levelLine.unhighligh()},r}(n.BaseMarker),t;n.OverUnderMarker=i;t=function(t){function i(i){t.call(this,n.MARKER_TYPE.OVER_UNDER);this.saveState(i)}return __extends(i,t),i.prototype.saveState=function(n){t.prototype.saveBaseState.call(this,n);this.xValue=n.xValue;this.yValue=n.yValue;this.yLevelValue=n.yLevelValue;this.markerLineState=n.getMarkerLine().getState()},i}(n.MarkerState);n.OverUnderMarkerState=t}(Markers||(Markers={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var u=function(i){function r(){i.call(this);this.tags=[];this.tooltip="Measurement";this.markerMode=n.MARKER_MODE.MEAS;this.restoredMarkerStates=[];this.rangeComboIndexDefault=0;this.compoundIndex=0;this.hasMarkers=!1;this.measInstanceId="SystemVisionCom_Measurement"+r.MEASUREMENT_GLOBAL_COUNT++}return __extends(r,i),r.prototype.updateInputControls=function(){},r.prototype.getName=function(){return this.measurementName},r.prototype.isBinary=function(){return this.useTwoWaveforms()},r.prototype.createOptionPanel=function(t,i){var r=this;this.createAttributePanel(t,i);this.rangeCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RANGE_COMBO_NAME,n.OptionsDialog.TOOL_RANGE_LIST,n.OptionsDialog.RANGE_COMBO_TOOLTIP);this.rangeCombo.bind("change",function(){r.removeInputMarkers()});this.setRangeComboForInputControls(this.rangeCombo)},r.prototype.setBaseToDefault=function(){this.rangeCombo&&this.rangeCombo.select(this.rangeComboIndexDefault)},r.prototype.areBaseOptionsDefault=function(){if(this.rangeCombo)return this.isEntireRange()},r.prototype.setWaveforms=function(n){n&&(this.wf=n.arg1.wf,this.wf2=n.arg2.wf?n.arg2.wf:this.wf,this.wf&&(this.waveContainer=this.wf.waveContainer),this.updateInputControls(this.wf))},r.prototype.isInputControl=function(){var t=this.getCategories(),i;if(t&&t.length>0)for(i=0;i<t.length;i++)if(t[i].id==n.Category.CAT_INPUT)return!0;return!1},r.prototype.apply=function(){var i=this,r=new ServerStructures.MeasurementRequest;this.addRequest(r);this.waveContainer.showSpinner();$.when(WaveViewer.ViewerRequests.createAndInitMeasurements(r)).done(function(u){var f=new t,e,o,c,s,h,l;if(f.meas=i,f.measResult=!0,!u||u.length==0){f.measResult=!1;i.waveContainer.hideSpinner();return}if(e=u[0],!e){f.measResult=!1;i.waveContainer.hideSpinner();return}for(o=0;o<r.MeasRequests.length;o++)c=r.MeasRequests[o],c.ReturnType==ServerStructures.ReturnType.LIST?(i.setResults(e.MeasurementValues),i.hasMarkers=!0,i.markerManager||(i.markerManager=new n.MeasMarkerManager(i)),s=i.findFirstVisible(),s.index>=0&&(s.isVisible||i.waveContainer.viewAll(),i.markerManager.showMarker(s.index)),i.waveContainer.hideSpinner()):c.ReturnType==ServerStructures.ReturnType.WAVEFORM&&(i.hasMarkers=!1,h=e.MeasurementWaveform,l=WaveViewer.WdbInfo.getExpressionWdbId(),i.resultWaveformHandle=h.Metadata.Handle,i.resultWdbId=l,i.waveContainer.getViewerWindow().plotWaveformByHandle(h.Metadata.ResultId,h.Metadata.Handle,l,null,!1),i.waveContainer.moveToBottom())})},r.prototype.cloneMeasurement=function(t,i){var r=n.ToolUtils.getMeasurementByName(this.getName());return r.setWaveforms(t),r.waveContainer=r.wf.waveContainer,r.markerMode=this.markerMode,r.setState(i),r.hasMarkers=i.ReturnType==ServerStructures.ReturnType.LIST?!0:!1,r.waveContainer.containerMeasManager.addMeasurement(r),r},r.prototype.doApply=function(t,i){i===void 0&&(i=null);this.setWaveforms(t);i||(i=this.getRequest());var r=null;return this.markerMode==n.MARKER_MODE.INPUT?(r=this,r.setState(i)):r=this.cloneMeasurement(t,i),r.apply()},r.prototype.useNumbers=function(){return!1},r.prototype.addRestoredMarkerState=function(n){this.restoredMarkerStates||(this.restoredMarkerStates=[]);this.restoredMarkerStates.push(n)},r.prototype.getButton=function(){return new n.MeasLabelButton(this.measurementId,n.OPERATION_TYPE.UNARY_OPERATION,this.measurementName,this.measurementName,this.tooltip,this)},r.prototype.useResultsCombo=function(){return!1},r.prototype.useTwoWaveforms=function(){return!1},r.prototype.hasOptions=function(){return!0},r.prototype.hasMultipleResults=function(){return this.getAllResults().hasMultipleResults(this.compoundIndex)},r.prototype.findFirstVisible=function(){var n=this.wf,i=n.xaxis.min,r=n.xaxis.max,t=this.getAllResults();return t?t.findFirstVisible(this.compoundIndex,i,r):new ServerStructures.VisibleMarker(-1,!1)},r.prototype.isEasyMode=function(){var n=this.wf,t=n.xaxis.min,i=n.xaxis.max;return this.getAllResults().isEasyMode(this.compoundIndex,t,i)},r.prototype.hasNextResult=function(n){return this.getAllResults().hasNextResult(this.compoundIndex,n)},r.prototype.hasPrevResult=function(n){return this.getAllResults().hasPrevResult(this.compoundIndex,n)},r.prototype.findClosestResult=function(n,t,i,r,u){return this.getAllResults().findClosestResult(this.compoundIndex,n,t,i,r,u)},r.prototype.getMeasTextFromValue=function(n,t,i){var f,e;i===void 0&&(i=null);var o=WaveViewer.AxisUnits.formatDataValueForMeasurement(n,3,t),s=i?this.measurementName+i:this.measurementName,u=s+": "+o,r=this.getMeasRange();return r&&(f=WaveViewer.AxisUnits.formatDataValueForMeasurement(r.xmin,3,null),e=WaveViewer.AxisUnits.formatDataValueForMeasurement(r.xmax,3,null),u+="\n["+f+"; "+e+"]"),u},r.prototype.showRange=function(){var n=this.getMeasRange(),t;n&&(t=this.waveContainer.getRealXVisibleState(),t&&t.range&&(n.xmin<t.range.xmin&&(n.xmin=t.range.xmin),n.xmax>t.range.xmax&&(n.xmax=t.range.xmax)),this.waveContainer.showMeasurementRange(n.xmin,n.xmax))},r.prototype.hideRange=function(){var n=this.getMeasRange();n&&this.waveContainer.hideMeasurementRange()},r.prototype.setStandardParameters=function(n){n.MeasurementId=this.measurementId;n.ResultId=this.wf.simulationId;n.WaveformId=this.wf.getWaveformHandle();this.setRangeForState(n)},r.prototype.isEntireRange=function(){return this.rangeCombo&&this.rangeCombo.text()==n.OptionsDialog.TOOL_RANGE_VISIBLE_RANGE?!1:!0},r.prototype.hasCategory=function(n){for(var i=this.getCategories(),t=0;t<i.length;t++)if(i[t]==n)return!0;return!1},r.prototype.setRangeComboToVisibleRange=function(){this.rangeCombo&&this.rangeCombo.select(1)},r.prototype.setRangeForState=function(t){var i,r;this.rangeCombo&&(i=this.rangeCombo.text(),i==n.OptionsDialog.TOOL_RANGE_ENTIRE_WAVEFORM?(t.XBegin=null,t.XEnd=null):i==n.OptionsDialog.TOOL_RANGE_VISIBLE_RANGE&&(this.waveContainer.isViewAllForX()?(t.XBegin=null,t.XEnd=null):(r=this.waveContainer.getXAxisState().range,t.XBegin=r.xmin,t.XEnd=r.xmax)))},r.MEASUREMENT_GLOBAL_COUNT=0,r.MODULE_NAME="Operations",r}(n.ToolOperation),i,r,t;n.BaseMeasurement=u;i=function(){function n(){this.markerStates=[]}return n}();n.MarkerStates=i;r=function(){function n(n,t,i){this.index=0;this.index=n;this.XValue=t;this.YValue=i}return n}();n.CLosestResult=r;t=function(){function n(){}return n}();n.MeasRes=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.apply(this,arguments);this.edgeTriggerDefault=ServerStructures.Trigger.EITHER;this.countDefault=ServerStructures.CountType.ALL;this.returnTypeDefault=ServerStructures.ReturnType.LIST;this.resultComboIndexDefault=0;this.edgeTrigger=this.edgeTriggerDefault;this.count=this.countDefault;this.edgeTriggerButtons=[]}return __extends(i,t),i.prototype.getTopline=function(){return this.toplineControl?this.toplineControl.getValueAsNumber():null},i.prototype.getBaseline=function(){return this.baselineControl?this.baselineControl.getValueAsNumber():null},i.prototype.updateInputControls=function(n){return this.toplineControl&&this.toplineControl.setWaveform(n),this.baselineControl?this.baselineControl.setWaveform(n):void 0},i.prototype.createAttributePanel=function(t,i){this.edgeTriggerButtons=n.ToolUtils.createEdgeGroupForEdge(i,"Edge Trigger:",n.ToolTooltips.EDGE_TRIGGER);var r=n.ToolUtils.createInputControls(t,i);this.toplineControl=r.topControl;this.baselineControl=r.baseControl;this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP);this.setDefault()},i.prototype.removeInputMarkers=function(){this.toplineControl&&this.toplineControl.removeMarker();this.baselineControl&&this.baselineControl.removeMarker()},i.prototype.setRangeComboForInputControls=function(n){this.toplineControl&&this.toplineControl.setRangeCombo(n);this.baselineControl&&this.baselineControl.setRangeCombo(n)},i.prototype.updateInputControlLists=function(){this.toplineControl&&this.toplineControl.addToComboList();this.baselineControl&&this.baselineControl.addToComboList()},i.prototype.getRequest=function(){var n=new ServerStructures.CycleMeasurementRequest;return this.setStandardParameters(n),n.Topline=this.getTopline(),n.Baseline=this.getBaseline(),n.EdgeTrigger=this.getEdgeTriggerValue(),n.ReturnType=this.getReturnType(),n},i.prototype.areDefaultOptions=function(){var i=this.areBaseOptionsDefault(),n,t;return i?(n=this.getEdgeTriggerValue(),n!=this.edgeTriggerDefault)?!1:(t=this.getReturnType(),t!=this.returnTypeDefault)?!1:this.toplineControl&&!this.toplineControl.areDefaultOptions()?!1:this.baselineControl&&!this.baselineControl.areDefaultOptions()?!1:!0:!1},i.prototype.checkTriggerButton=function(t){n.ToolUtils.checkTriggerButton(t,this.edgeTriggerButtons)},i.prototype.getReturnType=function(){if(this.resultsCombo){var t=this.resultsCombo.text();if(t==n.OptionsDialog.TOOL_RESULT_MARKERS)return ServerStructures.ReturnType.LIST;if(t==n.OptionsDialog.TOOL_RESULT_WAVEFORM)return ServerStructures.ReturnType.WAVEFORM}return this.returnTypeDefault},i.prototype.setState=function(n){this.measurementState=n},i.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},i.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},i.prototype.getEdgeTriggerValue=function(){var t=n.ToolUtils.getCheckedTriggerButton(this.edgeTriggerButtons);return t?t.val():this.edgeTriggerDefault},i.prototype.useResultsCombo=function(){return!0},i}(n.BaseMeasurement);n.CycleMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t.prototype.setParameters=function(n){var i=n,t=n.rangeCombo.value();this.range=t},t.prototype.getRequest=function(){var n=new ServerStructures.BaseMeasurementRequest;return this.setStandardParameters(n),n},t.prototype.areDefaultOptions=function(){var n=this.areBaseOptionsDefault();return n?!0:!1},t.prototype.setState=function(n){this.measurementState=n},t.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},t.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},t.prototype.createAttributePanel=function(){},t.prototype.removeInputMarkers=function(){},t.prototype.setRangeComboForInputControls=function(){},t.prototype.updateInputControlLists=function(){},t.prototype.setDefault=function(){this.setBaseToDefault()},t}(n.BaseMeasurement);n.LevelMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(n.BaseMeasurement);n.OnePointMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t.prototype.getRequest=function(){var n=new ServerStructures.BaseMeasurementRequest;return this.setStandardParameters(n),n},t.prototype.areDefaultOptions=function(){var n=this.areBaseOptionsDefault();return n?!0:!1},t.prototype.setState=function(n){this.measurementState=n},t.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},t.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},t.prototype.createAttributePanel=function(){},t.prototype.removeInputMarkers=function(){},t.prototype.setRangeComboForInputControls=function(n){this.rangeCombo=n},t.prototype.updateInputControlLists=function(){},t}(n.BaseMeasurement);n.TwoPointsMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.useDefault=!0}return __extends(i,t),i.prototype.setResults=function(n){this.measResults=new ServerStructures.LevelResult(n);this.isEntireRange()&&this.trySetTopBaseLevel(n)},i.prototype.trySetTopBaseLevel=function(n){var t,r,i;this.wf&&(t=WaveViewer.getManager().getWaveformInfoFromCache(this.wf.simulationId,this.wf.getWaveformHandle(),this.wf.getFullWaveformName(),!1),t&&(r=n,i=r.results[0].Levels[0],this.measurementId==ServerStructures.MeasurementID.Baseline?t.setBaseline(i):t.setTopline(i)))},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(t){var i=this.measResults.getResult(this.compoundIndex,t);if(i){var r=i.Value,u=this.getMeasTextFromValue(r,null),f=this.markerMode==n.MARKER_MODE.INPUT?Markers.DRAG_DIRECTION.VERTICAL:Markers.DRAG_DIRECTION.NONE;return new Markers.HorizontalLevelMarker(this.markerManager,r,u,f,t)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.getRequest=function(){var n=new ServerStructures.BaseMeasurementRequest;return this.setStandardParameters(n),n},i.prototype.areDefaultOptions=function(){var n=this.areBaseOptionsDefault();return n?!0:!1},i.prototype.removeInputMarkers=function(){},i.prototype.updateInputControls=function(){},i.prototype.setRangeComboForInputControls=function(n){this.rangeCombo=n},i.prototype.updateInputControlLists=function(){},i.prototype.createAttributePanel=function(){},i.prototype.setDefault=function(){this.setBaseToDefault()},i.prototype.hasLevel=function(){if(!this.inputControl)return!1;var n=this.inputControl.getValueAsNumber();return n==null?!1:!0},i.prototype.isDefaultLevel=function(){return this.inputControl?this.inputControl.isDefaultLevel():!1},i.prototype.showLevel=function(t){var i,r;this.markerManager||(this.markerManager=new n.MeasMarkerManager(this));this.measResults||(this.measResults=new ServerStructures.LevelResult(null),i=new ServerStructures.LevelElementResult(null),i.addLevel(0),this.measResults.results.push(i),this.measResults.LevelType=ServerStructures.LevelType.HORIZONTAL,this.measResults.Units=null);r=this.measResults;r.results[this.compoundIndex].Levels[0]=t;this.measResults=r;this.markerManager.showMarker(0)},i}(n.TwoPointsMeasurement),i,r;n.InputControlMeasurement=t;i=function(t){function i(){t.call(this);this.measurementName="Topline";this.measurementId=ServerStructures.MeasurementID.Topline;this.className="TopLine"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_INPUT)),t},i.TOPLINE_TOOLTIP=n.ToolTooltips.TOPLINE,i}(t);n.TopLine=i;r=function(t){function i(){t.call(this);this.measurementName="Baseline";this.measurementId=ServerStructures.MeasurementID.Baseline;this.className="BaseLine"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_INPUT)),t},i.BASELINE_TOOLTIP=n.ToolTooltips.BASELINE,i}(t);n.BaseLine=r}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.UpperLevel=.9;this.MiddleLevel=.5;this.LowerLevel=.1;this.measurementName="SlewRate";this.className="SlewRateMeasurement";this.measurementId=ServerStructures.MeasurementID.SlewRate;this.tooltip="The ratio of the y difference between the upper and lower levels to the risetime (in the case of a rising edge) or the falltime (in the case of a falling edge)"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.TwoPointResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=this.getMeasTextFromValue(t.Value,this.measResults.Units),r=new Markers.LinePoint(t.X1,t.Y1,0),u=new Markers.LinePoint(t.X2,t.Y2,1);return new Markers.HorizontalDeltaMarker(this.markerManager,r,u,i,n)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault();this.checkTriggerButton(this.edgeTriggerDefault);this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i.prototype.getRequest=function(){var n=new ServerStructures.SlewRateMeasurementRequest;return this.setStandardParameters(n),n.Topline=this.getTopline(),n.Baseline=this.getBaseline(),n.EdgeTrigger=this.getEdgeTriggerValue(),n.ReturnType=this.getReturnType(),n},i.prototype.areDefaultOptions=function(){var i=this.areBaseOptionsDefault(),n,t;return i?(n=this.getEdgeTriggerValue(),n!=ServerStructures.Trigger.EITHER)?!1:(t=this.getReturnType(),t!=ServerStructures.ReturnType.LIST)?!1:this.toplineControl&&!this.toplineControl.areDefaultOptions()?!1:this.baselineControl&&!this.baselineControl.areDefaultOptions()?!1:!0:!1},i.prototype.createAttributePanel=function(t,i){this.edgeTriggerButtons=n.ToolUtils.createEdgeGroupForEdge(i,"Edge Trigger:",n.ToolTooltips.EDGE_TRIGGER_SLEWRATE,!0);var r=n.ToolUtils.createInputControls(t,i);this.toplineControl=r.topControl;this.baselineControl=r.baseControl;this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP)},i}(n.CycleMeasurement);n.SlewRateMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i,o,e,tt,it,rt,ut,si,ft,r,v,et,ot,st,ht,s,ct,lt,h,at,vt,yt,y,pt,wt,bt,hi,kt,t,u,c,p,f,w,l,a,b,k,d,g,dt,gt,ni,ti,ii,ri,ui,fi,nt,ei,oi;(function(n){n[n.NONE=0]="NONE";n[n.PER_OCTAVE=1]="PER_OCTAVE";n[n.PER_DECADE=2]="PER_DECADE"})(n.SlopeType||(n.SlopeType={}));i=n.SlopeType,function(n){n[n.LAST=-1]="LAST";n[n.ALL=-2]="ALL"}(n.CountType||(n.CountType={}));o=n.CountType,function(n){n[n.EITHER=0]="EITHER";n[n.RISING=1]="RISING";n[n.POSITIVE=1]="POSITIVE";n[n.FALLING=2]="FALLING";n[n.NEGATIVE=2]="NEGATIVE"}(n.Trigger||(n.Trigger={}));e=n.Trigger,function(n){n[n.EITHER=0]="EITHER";n[n.SAME=1]="SAME";n[n.OPPOSITE=2]="OPPOSITE"}(n.RefPolarity||(n.RefPolarity={}));tt=n.RefPolarity,function(n){n[n.ABSOLUTE=0]="ABSOLUTE";n[n.RELATIVE=1]="RELATIVE"}(n.AbsoluteRelative||(n.AbsoluteRelative={}));it=n.AbsoluteRelative,function(n){n[n.DEGREES=0]="DEGREES";n[n.RADIANS=1]="RADIANS"}(n.PhaseType||(n.PhaseType={}));rt=n.PhaseType,function(n){n[n.LIST=0]="LIST";n[n.WAVEFORM=1]="WAVEFORM"}(n.ReturnType||(n.ReturnType={}));ut=n.ReturnType,function(n){n[n.ACCoupledRMS=0]="ACCoupledRMS";n[n.Amplitude=1]="Amplitude";n[n.Average=2]="Average";n[n.Baseline=3]="Baseline";n[n.Maximum=4]="Maximum";n[n.Minimum=5]="Minimum";n[n.PeakToPeak=6]="PeakToPeak";n[n.RMS=7]="RMS";n[n.Topline=8]="Topline";n[n.XAtMaximum=9]="XAtMaximum";n[n.XAtMinimum=10]="XAtMinimum";n[n.LocalMaximum=11]="LocalMaximum";n[n.LocalMinimum=12]="LocalMinimum";n[n.BestFitLine=13]="BestFitLine";n[n.Mean=14]="Mean";n[n.MeanMinusNStandardDeviation=15]="MeanMinusNStandardDeviation";n[n.MeanPlusNStandardDeviation=16]="MeanPlusNStandardDeviation";n[n.Median=17]="Median";n[n.Range=18]="Range";n[n.StandardDeviation=19]="StandardDeviation";n[n.AtX=20]="AtX";n[n.LevelCrossing=21]="LevelCrossing";n[n.Slope=22]="Slope";n[n.WaveformCrossing=23]="WaveformCrossing";n[n.Delay=24]="Delay";n[n.DelayFromX=25]="DelayFromX";n[n.DutyCycle=26]="DutyCycle";n[n.Falltime=27]="Falltime";n[n.Frequency=28]="Frequency";n[n.Overshoot=29]="Overshoot";n[n.Period=30]="Period";n[n.PulseWidth=31]="PulseWidth";n[n.Risetime=32]="Risetime";n[n.SettleTime=33]="SettleTime";n[n.SlewRate=34]="SlewRate";n[n.Undershoot=35]="Undershoot";n[n.Bandpass=36]="Bandpass";n[n.GainMargin=37]="GainMargin";n[n.Highpass=38]="Highpass";n[n.Lowpass=39]="Lowpass";n[n.PhaseMargin=40]="PhaseMargin";n[n.Stopband=41]="Stopband";n[n.TopBase=42]="TopBase"}(n.MeasurementID||(n.MeasurementID={}));si=n.MeasurementID;ft=function(){function n(){this.MeasRequests=[]}return n}();n.MeasurementRequest=ft;r=function(){function n(){this.ReturnType=ut.LIST;this.markerStatesJson=[]}return n}();n.BaseMeasurementRequest=r;v=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(r);n.AtXMeasurementRequest=v;et=function(n){function t(){n.apply(this,arguments);this.SlopeType=i.NONE}return __extends(t,n),t.getSlopeNameByType=function(n){switch(n){case i.NONE:return"None";case i.PER_DECADE:return"PerDecade";case i.PER_OCTAVE:return"PerOctave";default:return"None"}},t.getSlopeTypeByIndex=function(n){switch(n){case i.NONE:return i.NONE;case i.PER_DECADE:return i.PER_DECADE;case i.PER_OCTAVE:return i.PER_OCTAVE;default:return i.NONE}},t}(v);n.SlopeMeasurementRequest=et;ot=function(n){function t(){n.apply(this,arguments);this.Slope=e.EITHER;this.Count=o.ALL}return __extends(t,n),t}(r);n.LevelCrossingMeasurementRequest=ot;st=function(n){function t(){n.apply(this,arguments);this.Topline=null;this.dbOffset=-3}return __extends(t,n),t}(r);n.PassMeasurementRequest=st;ht=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(r);n.SpecMeasurementRequest=ht;s=function(n){function t(){n.apply(this,arguments);this.Topline=null;this.Baseline=null;this.EdgeTrigger=e.EITHER;this.Count=o.ALL}return __extends(t,n),t}(r);n.CycleMeasurementRequest=s;ct=function(n){function t(){n.apply(this,arguments);this.RefTopline=null;this.RefBaseline=null;this.DelayLevel=.5;this.RefDelayLevel=.5;this.RelativePolarity=tt.EITHER}return __extends(t,n),t}(s);n.DelayMeasurementRequest=ct;lt=function(n){function t(){n.apply(this,arguments);this.DelayLevel=.5;this.XValue=0}return __extends(t,n),t}(s);n.DelayFromXMeasurementRequest=lt;h=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(s);n.SlewRateMeasurementRequest=h;at=function(n){function t(){n.call(this);this.EdgeTrigger=e.FALLING}return __extends(t,n),t}(h);n.FalltimeMeasurementRequest=at;vt=function(n){function t(){n.call(this);this.EdgeTrigger=e.RISING}return __extends(t,n),t}(h);n.RisetimeMeasurementRequest=vt;yt=function(n){function t(){n.apply(this,arguments);this.CrossoverPhase=-180;this.PhaseType=rt.DEGREES}return __extends(t,n),t}(r);n.MarginMeasurementRequest=yt;y=function(n){function t(){n.apply(this,arguments);this.Topline=null;this.Baseline=null;this.AbsoluteOrRelative=it.RELATIVE;this.Count=o.ALL}return __extends(t,n),t}(r);n.OverUnderMeasurementRequest=y;pt=function(n){function t(){n.apply(this,arguments);this.Tolerance=this.setToleranceValue(t.DEFAULT_TOLERANCE,!0)}return __extends(t,n),t.prototype.setToleranceValue=function(n,t){return(t===void 0&&(t=!0),t)?n*.01:n},t.DEFAULT_TOLERANCE=5,t}(y);n.SettleTimeMeasurementRequest=pt;wt=function(n){function t(){n.apply(this,arguments);this.Tolerance=.001;this.Count=o.ALL}return __extends(t,n),t}(r);n.LocalMeasurementRequest=wt;bt=function(n){function t(){n.apply(this,arguments);this.SlopeDifference=e.EITHER}return __extends(t,n),t}(r);n.WaveformCrossingMeasurementRequest=bt,function(n){n[n.HORIZONTAL=0]="HORIZONTAL";n[n.VERTICAL=1]="VERTICAL"}(n.LevelType||(n.LevelType={}));hi=n.LevelType;kt=function(){function n(){}return n.prototype.MeasurementResult=function(n){this.MeasurementId=n},n}();n.MeasurementResult=kt;t=function(){function n(n,t){this.index=0;this.isVisible=!1;this.index=n;this.isVisible=t}return n}();n.VisibleMarker=t;u=function(){function n(){}return n.prototype.hasNextResult=function(n,t){return this.testIndex(n,t+1)},n.prototype.hasPrevResult=function(n,t){return this.testIndex(n,t-1)},n}();n.BaseResult=u;c=function(){function n(n,t){n&&(this.X=n.X,this.Y=t?t.convertY(n.Y):n.Y,this.Value=n.Value)}return n.getOnePointValue=function(t){var i=new n(null,null);return i.X=0,i.Y=0,i.Value=t,i},n.prototype.calcDistance=function(n){return Math.abs(this.X-n)},n.prototype.getClosestResult=function(n){return new Operations.CLosestResult(n,this.X,this.Y)},n}();n.OnePointValue=c;p=function(){function n(n,t){n&&(this.X1=n.X1,this.Y1=t?t.convertY(n.Y1):n.Y1,this.X2=n.X2,this.Y2=t?t.convertY(n.Y2):n.Y2,this.Value=n.Value)}return n.prototype.getClosestResult=function(n,t){switch(t){case Markers.POINT_POSITION.TOP:return this.Y1>this.Y2?new Operations.CLosestResult(n,this.X1,this.Y1):new Operations.CLosestResult(n,this.X2,this.Y2);case Markers.POINT_POSITION.BOTTOM:return this.Y1<this.Y2?new Operations.CLosestResult(n,this.X1,this.Y1):new Operations.CLosestResult(n,this.X2,this.Y2);case Markers.POINT_POSITION.LEFT:return this.X1<this.X2?new Operations.CLosestResult(n,this.X1,this.Y1):new Operations.CLosestResult(n,this.X2,this.Y2);case Markers.POINT_POSITION.RIGHT:return this.X1>this.X2?new Operations.CLosestResult(n,this.X1,this.Y1):new Operations.CLosestResult(n,this.X2,this.Y2)}},n.prototype.calcDistance=function(n,t,i){var r;switch(i){case Markers.POINT_POSITION.TOP:return this.Y1>this.Y2?Math.abs(this.X1-n):Math.abs(this.X2-n);case Markers.POINT_POSITION.BOTTOM:return this.Y1<this.Y2?Math.abs(this.X1-n):Math.abs(this.X2-n);case Markers.POINT_POSITION.LEFT:return this.X1<this.X2?Math.abs(this.X1-n):Math.abs(this.X2-n);case Markers.POINT_POSITION.RIGHT:return this.X1>this.X2?Math.abs(this.X1-n):Math.abs(this.X2-n)}},n}();n.TwoPointValue=p;f=function(){function n(n){this.ParameterNames=[];this.ParameterValues=[];n&&(this.XBegin=n.XBegin,this.XEnd=n.XEnd,this.ParameterNames=n.ParameterNames,this.ParameterValues=n.ParameterValues)}return n.prototype.addParameter=function(n,t){this.ParameterNames.push(n);this.ParameterValues.push(t)},n}();n.ElementResult=f;w=function(n){function t(t,i){var r,u;for(n.call(this,t),this.Values=[],this.Values=[],r=0;r<t.Values.length;r++)u=new c(t.Values[r],i),this.Values.push(u)}return __extends(t,n),t}(f);n.OnePointElementResult=w;l=function(n){function t(t,i){var r,u;if(n.call(this,t),this.Values=[],this.Values=[],t)for(r=0;r<t.Values.length;r++)u=new p(t.Values[r],i),this.Values.push(u)}return __extends(t,n),t}(f);n.TwoPointElementResult=l;a=function(n){function t(t,i){n.call(this,t,i);this.Topline=t.Topline;this.Baseline=t.Baseline}return __extends(t,n),t}(l);n.CycleEdgeElementResult=a;b=function(n){function t(t,i){n.call(this,t,i);this.RefBaseline=t.RefBaseline;this.RefUpperLevel=t.RefUpperLevel;this.RefMiddleLevel=t.RefMiddleLevel;this.RefLowerLevel=t.RefLowerLevel;this.RefBaseline=t.RefBaseline}return __extends(t,n),t}(a);n.DelayElementResult=b;k=function(n){function t(t){n.call(this,t);this.Frequency=t.Frequency;this.Margin=t.Margin}return __extends(t,n),t}(f);n.MarginElementResult=k;d=function(n){function t(t){n.call(this,t);this.Topline=t.Topline;this.Level=t.Level;this.Frequency=t.Frequency}return __extends(t,n),t}(f);n.LowHighPassElementResult=d;g=function(n){function t(t){n.call(this,t);this.Topline=t.Topline;this.Level=t.Level;this.CenterFrequency=t.CenterFrequency;this.Q=t.Q;this.Bandwidth=t.Bandwidth}return __extends(t,n),t}(f);n.BandStopElementResult=g;dt=function(n){function i(t){var i,r;if(n.call(this),this.results=[],t){for(this.results=[],i=0;i<t.results.length;i++)r=new nt(t.results[i]),this.results.push(r);this.LevelType=t.LevelType;this.Units=t.Units}}return __extends(i,n),i.prototype.getResult=function(n,t){if(n<0||n>this.results.length-1||!this.results[n]||t<0||t>this.results[n].Levels.length-1)return null;var i=this.results[n],r=i.Levels[t];return c.getOnePointValue(r)},i.prototype.hasMultipleResults=function(){return!1},i.prototype.findFirstVisible=function(){return new t(0,!0)},i.prototype.isEasyMode=function(){return!1},i.prototype.testIndex=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?!1:t<0||t>this.results[n].Levels.length-1?!1:this.results[n].Levels[t]?!0:!1},i.prototype.findClosestResult=function(n,t,i,r){return new Operations.CLosestResult(r,0,0)},i}(u);n.LevelResult=dt;gt=function(n){function i(t,i){var r,u;for(n.call(this),this.results=[],this.results=[],r=0;r<t.results.length;r++)u=new a(t.results[r],i),this.results.push(u);this.Units=t.Units}return __extends(i,n),i.prototype.getResult=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?null:t<0||t>this.results[n].Values.length-1?null:this.results[n].Values[t]},i.prototype.hasMultipleResults=function(n){if(this.results&&this.results[n]){var t=this.results[n].Values;return t&&t.length>1}return!1},i.prototype.findFirstVisible=function(n,i,r){var f,u,e;if(this.results&&this.results[n])for(f=this.results[n].Values,u=0;u<f.length;u++)if(e=f[u].X1,e>=i&&e<=r)return new t(u,!0);return new t(0,!1)},i.prototype.isEasyMode=function(n,t,i){var r,u,f,e;if(this.results&&this.results[n]){if(r=this.results[n].Values,r.length<=Operations.MeasMarkerManager.MAX_SHOW_RES)return!1;for(u=0,f=0;f<r.length;f++)if(e=r[f].X1,e>=t&&e<=i&&(u+=1,u>Operations.MeasMarkerManager.MAX_SHOW_RES))return!0;return u>Operations.MeasMarkerManager.MAX_SHOW_RES}return!1},i.prototype.testIndex=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?!1:t<0||t>this.results[n].Values.length-1?!1:this.results[n].Values[t]?!0:!1},i.prototype.findClosestResult=function(n,t,i,r,u,f){var o=this.getResult(n,r),s=u>0?r+1:r-1,e=this.getResult(n,s),h,c;return o?e?(h=o.calcDistance(t,i,f),c=e.calcDistance(t,i,f),c<h)?e.getClosestResult(s,f):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0)},i}(u);n.CycleEdgeResult=gt;ni=function(n){function i(t,i){var r,u;for(n.call(this),this.results=[],this.results=[],r=0;r<t.results.length;r++)u=new b(t.results[r],i),this.results.push(u);this.Units=t.Units}return __extends(i,n),i.prototype.getResult=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?null:t<0||t>this.results[n].Values.length-1?null:this.results[n].Values[t]},i.prototype.hasMultipleResults=function(n){if(this.results&&this.results[n]){var t=this.results[n].Values;return t&&t.length>1}return!1},i.prototype.findFirstVisible=function(n,i,r){var f,u,e;if(this.results&&this.results[n])for(f=this.results[n].Values,u=0;u<f.length;u++)if(e=f[u].X1,e>=i&&e<=r)return new t(u,!0);return new t(0,!1)},i.prototype.isEasyMode=function(n,t,i){var r,u,f,e;if(this.results&&this.results[n]){if(r=this.results[n].Values,r.length<=Operations.MeasMarkerManager.MAX_SHOW_RES)return!1;for(u=0,f=0;f<r.length;f++)if(e=r[f].X1,e>=t&&e<=i&&(u+=1,u>Operations.MeasMarkerManager.MAX_SHOW_RES))return!0;return u>Operations.MeasMarkerManager.MAX_SHOW_RES}return!1},i.prototype.testIndex=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?!1:t<0||t>this.results[n].Values.length-1?!1:this.results[n].Values[t]?!0:!1},i.prototype.findClosestResult=function(n,t,i,r,u,f){var o=this.getResult(n,r),s=u>0?r+1:r-1,e=this.getResult(n,s),h,c;return o?e?(h=o.calcDistance(t,i,f),c=e.calcDistance(t,i,f),c<h)?e.getClosestResult(s,f):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0)},i}(u);n.DelayResult=ni;ti=function(n){function i(t,i){var r,u;if(n.call(this),this.results=[],t){for(this.results=[],r=0;r<t.results.length;r++)u=new w(t.results[r],i),this.results.push(u);this.Units=t.Units}}return __extends(i,n),i.prototype.getResult=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?null:t<0||t>this.results[n].Values.length-1?null:this.results[n].Values[t]},i.prototype.hasMultipleResults=function(n){if(this.results&&this.results[n]){var t=this.results[n].Values;return t&&t.length>1}return!1},i.prototype.findFirstVisible=function(n,i,r){var f,u,e;if(this.results&&this.results[n])for(f=this.results[n].Values,u=0;u<f.length;u++)if(e=f[u].X,e>=i&&e<=r)return new t(u,!0);return new t(0,!1)},i.prototype.isEasyMode=function(n,t,i){var r,u,f,e;if(this.results&&this.results[n]){if(r=this.results[n].Values,r.length<=Operations.MeasMarkerManager.MAX_SHOW_RES)return!1;for(u=0,f=0;f<r.length;f++)if(e=r[f].X,e>=t&&e<=i&&(u+=1,u>Operations.MeasMarkerManager.MAX_SHOW_RES))return!0;return u>Operations.MeasMarkerManager.MAX_SHOW_RES}return!1},i.prototype.testIndex=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?!1:t<0||t>this.results[n].Values.length-1?!1:this.results[n].Values[t]?!0:!1},i.prototype.findClosestResult=function(n,t,i,r,u,f){var o=this.getResult(n,r),s=u>0?r+1:r-1,e=this.getResult(n,s),h,c;return o?e?(h=o.calcDistance(t,i,f),c=e.calcDistance(t,i,f),c<h)?e.getClosestResult(s,f):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0)},i}(u);n.OnePointResult=ti;ii=function(n){function i(t,i){var r,u;if(n.call(this),this.results=[],t){for(this.results=[],r=0;r<t.results.length;r++)u=new l(t.results[r],i),this.results.push(u);this.Units=t.Units}}return __extends(i,n),i.prototype.getResult=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?null:t<0||t>this.results[n].Values.length-1?null:this.results[n].Values[t]},i.prototype.hasMultipleResults=function(n){if(this.results&&this.results[n]){var t=this.results[n].Values;return t&&t.length>1}return!1},i.prototype.findFirstVisible=function(n,i,r){var f,u,e;if(this.results&&this.results[n])for(f=this.results[n].Values,u=0;u<f.length;u++)if(e=f[u].X1,e>=i&&e<=r)return new t(u,!0);return new t(0,!1)},i.prototype.isEasyMode=function(n,t,i){var r,u,f,e;if(this.results&&this.results[n]){if(r=this.results[n].Values,r.length<=Operations.MeasMarkerManager.MAX_SHOW_RES)return!1;for(u=0,f=0;f<r.length;f++)if(e=r[f].X1,e>=t&&e<=i&&(u+=1,u>Operations.MeasMarkerManager.MAX_SHOW_RES))return!0;return u>Operations.MeasMarkerManager.MAX_SHOW_RES}return!1},i.prototype.testIndex=function(n,t){return n<0||n>this.results.length-1||!this.results[n]?!1:t<0||t>this.results[n].Values.length-1?!1:this.results[n].Values[t]?!0:!1},i.prototype.findClosestResult=function(n,t,i,r,u,f){var o=this.getResult(n,r),s=u>0?r+1:r-1,e=this.getResult(n,s),h,c;return o?e?(h=o.calcDistance(t,i,f),c=e.calcDistance(t,i,f),c<h)?e.getClosestResult(s,f):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0)},i}(u);n.TwoPointResult=ii;ri=function(n){function i(t){var i,r;for(n.call(this),this.results=[],this.results=[],i=0;i<t.results.length;i++)r=new k(t.results[i]),this.results.push(r);this.MarginUnits=t.MarginUnits}return __extends(i,n),i.prototype.getResult=function(n){return n<0||n>this.results.length-1||!this.results[n],null},i.prototype.hasMultipleResults=function(){return!1},i.prototype.findFirstVisible=function(){return new t(0,!0)},i.prototype.isEasyMode=function(){return!1},i.prototype.testIndex=function(){return!1},i.prototype.findClosestResult=function(n,t,i,r,u,f){var o=this.getResult(n,r),s=u>0?r+1:r-1,e=this.getResult(n,s),h,c;return o?e?(h=o.calcDistance(t,i,f),c=e.calcDistance(t,i,f),c<h)?e.getClosestResult(s,f):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0)},i}(u);n.MarginResult=ri;ui=function(n){function i(t){var i,r;for(n.call(this),this.results=[],this.results=[],i=0;i<t.results.length;i++)r=new d(t.results[i]),this.results.push(r)}return __extends(i,n),i.prototype.getResult=function(n){return n<0||n>this.results.length-1||!this.results[n],null},i.prototype.hasMultipleResults=function(){return!1},i.prototype.findFirstVisible=function(){return new t(0,!0)},i.prototype.isEasyMode=function(){return!1},i.prototype.testIndex=function(){return!1},i.prototype.findClosestResult=function(n,t,i,r,u,f){var o=this.getResult(n,r),s=u>0?r+1:r-1,e=this.getResult(n,s),h,c;return o?e?(h=o.calcDistance(t,i,f),c=e.calcDistance(t,i,f),c<h)?e.getClosestResult(s,f):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0)},i}(u);n.LowHighPassResult=ui;fi=function(n){function i(t){var i,r;for(n.call(this),this.results=[],this.results=[],i=0;i<t.results.length;i++)r=new g(t.results[i]),this.results.push(r);this.BandStopUnits=t.BandStopUnits}return __extends(i,n),i.prototype.getResult=function(n){return n<0||n>this.results.length-1||!this.results[n],null},i.prototype.hasMultipleResults=function(){return!1},i.prototype.findFirstVisible=function(){return new t(0,!0)},i.prototype.isEasyMode=function(){return!1},i.prototype.testIndex=function(){return!1},i.prototype.findClosestResult=function(n,t,i,r,u,f){var o=this.getResult(n,r),s=u>0?r+1:r-1,e=this.getResult(n,s),h,c;return o?e?(h=o.calcDistance(t,i,f),c=e.calcDistance(t,i,f),c<h)?e.getClosestResult(s,f):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0):new Operations.CLosestResult(r,0,0)},i}(u);n.BandStopResult=fi;nt=function(n){function t(t){if(n.call(this,t),this.Levels=[],this.Levels=[],t)for(var i=0;i<t.Levels.length;i++)this.Levels.push(t.Levels[i])}return __extends(t,n),t.prototype.addLevel=function(n){this.Levels=[];this.Levels.push(n)},t}(f);n.LevelElementResult=nt;ei=function(){function n(){this.TransferData=[]}return n}();n.MeasurementTransfer=ei;oi=function(){function n(){this.markerStatesJson=[];this.waveformIndex=-1;this.waveformIndex2=-1}return n}();n.BaseMeasurementState=oi}(ServerStructures||(ServerStructures={})),function(n){var t=function(){function t(n){this.markers=[];this.showInEasyMode=!1;this.isMoving=!1;this.relXBoxPos=Markers.PointMarkerText.INITIAL_TEXT_SHIFT;this.relYBoxPos=Markers.PointMarkerText.INITIAL_TEXT_SHIFT;this.pointIndex=Markers.POINT_INDEX.FIRST;this.pointPosition=Markers.POINT_POSITION.LEFT;this.waveContainer=n.waveContainer;this.measurement=n}return t.prototype.isInputControl=function(){return this.measurement.isInputControl()},t.prototype.updateInputControlByDragging=function(n){this.measurement.inputControl&&this.measurement.inputControl.updateByDragging(n)},t.prototype.setTextRelativePositions=function(n){var t,i,r,u;if(!n){this.relXBoxPos=Markers.PointMarkerText.INITIAL_TEXT_SHIFT;this.relYBoxPos=-Markers.PointMarkerText.INITIAL_TEXT_SHIFT;return}t=n.getTextObject();i=n.getPointObject();t&&i&&(r=t.xPos-i.xPos,u=t.yPos-i.yPos,this.relXBoxPos=r,this.relYBoxPos=u)},t.prototype.getMeasTextForYValue=function(n){return this.measurement.getMeasTextFromValue(n,this.measurement.wf.getYUnits())},t.prototype.getMeasTextForXYValue=function(t,i){if(this.measurement instanceof n.AtX)return this.measurement.getMeasTextForXYValue(t,i)},t.prototype.updateMarkers=function(){var n=this.getMarkerStates();this.removeMarkers();this.restoreMarkers(n)},t.prototype.updateWaveformMarkers=function(){var n=0;this.marker&&(n=this.marker.resultIndex);this.removeMarkers();this.showMarker(n)},t.prototype.removeMarkers=function(){for(var n=0;n<this.markers.length;n++)this.markers[n].remove();this.markers=[]},t.prototype.removeMarkersExceptOne=function(n){this.removeMarkers();this.showMarker(n)},t.prototype.addMarker=function(n){n&&this.markers.push(n)},t.prototype.getShownMarkerStates=function(){for(var t=[],n=0;n<this.markers.length;n++)this.markers[n].isShown&&t.push(this.markers[n].getRequest());return t},t.prototype.getMarkerStates=function(){for(var t=[],n=0;n<this.markers.length;n++)t.push(this.markers[n].getRequest());return t},t.prototype.restoreMarkers=function(n){for(var r,t,i=0;i<n.length;i++)r=n[i],t=this.restoreMarker(r,this.measurement.waveContainer),t&&(this.addMarker(t),r.isShown?t.show():t.hide())},t.prototype.restoreMarker=function(n,t){var i;switch(n.markerType){case Markers.MARKER_TYPE.POINT:return Markers.PointMarker.restoreMarker(this,n,t);case Markers.MARKER_TYPE.VERTICAL_DELTA:return Markers.VerticalDeltaMarker.restoreMarker(this,n,t);case Markers.MARKER_TYPE.HORIZONTAL_DELTA:return Markers.HorizontalDeltaMarker.restoreMarker(this,n,t);case Markers.MARKER_TYPE.VERTICAL_RANGE:return Markers.VerticalRangeMarker.restoreMarker(this,n,t);case Markers.MARKER_TYPE.HORIZONTAL_LEVEL:return Markers.HorizontalLevelMarker.restoreMarker(this,n,t);case Markers.MARKER_TYPE.OVER_UNDER:return Markers.OverUnderMarker.restoreMarker(this,n,t)}return null},t.prototype.showMarker=function(n){this.marker=this.findMarker(n);this.marker||(this.marker=this.createNewMarker(n));this.marker.show()},t.prototype.repaintMarker=function(n){this.removeMarkers();this.marker=this.createNewMarker(n);this.marker.show()},t.prototype.createMockPoint=function(n,t){this.mockPoint&&this.mockPoint.remove();this.removeMarkersExceptOne(n);this.pointIndex=t.pointIndex;this.pointPosition=t.pointPosition;this.setShowMode();this.mockPoint=new Markers.MockPointObject(t)},t.prototype.getMockPointPosition=function(){return this.pointPosition},t.prototype.removeMockPoint=function(){this.mockPoint&&this.mockPoint.remove()},t.prototype.hideMockPoint=function(){this.mockPoint&&this.mockPoint.hide()},t.prototype.hasMultipleResults=function(){return this.measurement.hasMultipleResults()},t.prototype.setShowMode=function(){this.showInEasyMode=this.measurement.isEasyMode()},t.prototype.getNextPoint=function(t,i,r,u,f,e){var o=this.measurement.findClosestResult(t,i,r,f,e),s;return o.index>=0&&o.index!=r?(s=this.findMarker(r),s&&s.hide(),this.showMarker(o.index),o):new n.CLosestResult(r,0,0)},t.prototype.findMarker=function(n){for(var t=0;t<this.markers.length;t++)if(this.markers[t].resultIndex==n)return this.markers[t];return null},t.prototype.hasNextResult=function(n){return this.measurement.hasNextResult(n)},t.prototype.hasPrevResult=function(n){return this.measurement.hasPrevResult(n)},t.prototype.createNewMarker=function(n){var t=this.measurement.createMarkerLocal(n);return t&&this.addMarker(t),t},t.prototype.getMarkerValue=function(n){var t=this.findMarker(n);return t?t.getMeasText():null},t.MAX_SHOW_RES=15,t}();n.MeasMarkerManager=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Average";this.className="AverageMeasurement";this.measurementId=ServerStructures.MeasurementID.Average;this.tooltip="The average level computed by integrating the waveform"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.LevelResult(n)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var i=this.measResults.getResult(this.compoundIndex,n),t,r;return i&&(t=i.Value,r=this.getMeasTextFromValue(t,this.measResults.Units),this.measResults.LevelType==ServerStructures.LevelType.HORIZONTAL)?new Markers.HorizontalLevelMarker(this.markerManager,t,r,Markers.DRAG_DIRECTION.NONE,n):null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault()},i}(n.LevelMeasurement);n.AverageMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Amplitude";this.className="AmplitudeMeasurement";this.measurementId=ServerStructures.MeasurementID.Amplitude;this.tooltip="The amplitude is the difference between the topline and baseline levels"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.TwoPointResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=t.Value,r=this.getMeasTextFromValue(i,this.measResults.Units);return new Markers.VerticalRangeMarker(this.markerManager,t.X1,t.Y1,t.Y2,r,n)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault()},i}(n.LevelMeasurement);n.AmplitudeMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="DutyCycle";this.className="DutyCycleMeasurement";this.measurementId=ServerStructures.MeasurementID.DutyCycle;this.tooltip="The ratio of the high portion of a cycle to the period"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.CycleEdgeResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=this.getMeasTextFromValue(t.Value,this.measResults.Units),r=new Markers.LinePoint(t.X1,t.Y1,0),u=new Markers.LinePoint(t.X2,t.Y2,1);return new Markers.HorizontalDeltaMarker(this.markerManager,r,u,i,n)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:i.isDigital()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault();this.checkTriggerButton(this.edgeTriggerDefault);this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.CycleMeasurement);n.DutyCycleMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Falltime";this.className="FalltimeMeasurement";this.measurementId=ServerStructures.MeasurementID.Falltime;this.tooltip="The X difference between the upper and lower levels"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.createAttributePanel=function(t,i){var r=n.ToolUtils.createInputControls(t,i);this.toplineControl=r.topControl;this.baselineControl=r.baseControl;this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP);this.setDefault()},i.prototype.removeInputMarkers=function(){this.toplineControl&&this.toplineControl.removeMarker();this.baselineControl&&this.baselineControl.removeMarker()},i.prototype.setRangeComboForInputControls=function(n){this.toplineControl&&this.toplineControl.setRangeCombo(n);this.baselineControl&&this.baselineControl.setRangeCombo(n)},i.prototype.updateInputControlLists=function(){this.toplineControl&&this.toplineControl.addToComboList();this.baselineControl&&this.baselineControl.addToComboList()},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.getRequest=function(){var n=new ServerStructures.SlewRateMeasurementRequest;return this.setStandardParameters(n),n.Topline=this.getTopline(),n.Baseline=this.getBaseline(),n.EdgeTrigger=ServerStructures.Trigger.FALLING,n.ReturnType=this.getReturnType(),n},i.prototype.areDefaultOptions=function(){var t=this.areBaseOptionsDefault(),n;return t?(n=this.getReturnType(),n!=this.returnTypeDefault)?!1:this.toplineControl&&!this.toplineControl.areDefaultOptions()?!1:this.baselineControl&&!this.baselineControl.areDefaultOptions()?!1:!0:!1},i.prototype.setDefault=function(){this.setBaseToDefault();this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.SlewRateMeasurement);n.FalltimeMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Frequency";this.className="FrequencyMeasurement";this.measurementId=ServerStructures.MeasurementID.Frequency;this.tooltip="The inverse of the period, where the period is calculated as the X difference between two consecutive edges of the same polarity"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.CycleEdgeResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=this.getMeasTextFromValue(t.Value,this.measResults.Units),r=new Markers.LinePoint(t.X1,t.Y1,0),u=new Markers.LinePoint(t.X2,t.Y2,1);return new Markers.HorizontalDeltaMarker(this.markerManager,r,u,i,n)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:i.isDigital()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault();this.checkTriggerButton(this.edgeTriggerDefault);this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.CycleMeasurement);n.FrequencyMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.slopeButtons=[];this.slopeIndexDefault=0;this.slopeDefault=ServerStructures.Trigger.EITHER;this.countDefault=ServerStructures.CountType.ALL;this.measurementName="LevelCross";this.className="LevelCrossingMeasurement";this.measurementId=ServerStructures.MeasurementID.LevelCrossing;this.tooltip="The X value(s) where the waveform is equal to the specified level"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.OnePointResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.setState=function(n){this.measurementState=n},i.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},i.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},i.prototype.getRequest=function(){var n=new ServerStructures.LevelCrossingMeasurementRequest;return this.setStandardParameters(n),n.Level=this.getLevel(),n.Slope=this.getSlope(),n.Count=ServerStructures.CountType.ALL,n},i.prototype.areDefaultOptions=function(){var i=this.areBaseOptionsDefault(),n,t;return i?(n=this.getLevel(),n!=this.wf.getMiddleLevel())?!1:(t=this.getSlope(),t!=this.slopeDefault)?!1:!0:!1},i.prototype.getLevel=function(){var t=this.wf.getMiddleLevel(),i,n;return this.yLevelInput&&this.yLevelInput.val()!=null&&(i=new Project.PropertyFormatter,n=i.SIUnitPrefixes2Double(this.yLevelInput.val()),isNaN(n)||(t=n)),t},i.prototype.getSlope=function(){var t=n.ToolUtils.getCheckedTriggerButton(this.slopeButtons);return t?t.val():this.slopeDefault},i.prototype.getMeasText=function(n){var f=WaveViewer.AxisUnits.formatDataValueForMeasurement(n,3,this.wf.getXUnits()),e=WaveViewer.AxisUnits.formatDataValueForMeasurement(this.measurementState.Level,3,this.wf.getYUnits()),i=this.measurementName+": ("+f+", "+e+")",t=this.getMeasRange(),r,u;return t&&(r=WaveViewer.AxisUnits.formatDataValueForMeasurement(t.xmin,3,null),u=WaveViewer.AxisUnits.formatDataValueForMeasurement(t.xmax,3,null),i+="\n["+r+"; "+u+"]"),i},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n),i,r;return t?(i=this.getMeasText(t.X),r=new Markers.PointMarker(this.markerManager,t.X,t.Y,i,Markers.DRAG_DIRECTION.MEASUREMENT,n,!0),r):null},i.prototype.createAttributePanel=function(t,i){this.yLevelInput=n.ToolUtils.createInputField(i,"Y Level:",n.ToolTooltips.LEVEL_CROSS_Y_LEVEL);this.slopeButtons=n.ToolUtils.createEdgeGroupForCross(i,"Slope at Crossing:",n.ToolTooltips.LEVEL_CROSS_SLOPE_AT_CROSSING);this.setDefault()},i.prototype.getDefaultYValue=function(){var n=this.wf.getMiddleLevel();return WaveViewer.AxisUnits.formatDataValueForMeasurement(n,3,null)},i.prototype.removeInputMarkers=function(){},i.prototype.setRangeComboForInputControls=function(){},i.prototype.updateInputControlLists=function(){},i.prototype.useResultsCombo=function(){return!1},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault();this.yLevelInput.val(this.getDefaultYValue());n.ToolUtils.checkTriggerButton(this.slopeIndexDefault,this.slopeButtons)},i}(n.BaseMeasurement);n.LevelCrossingMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.apply(this,arguments);this.countDefault=ServerStructures.CountType.ALL;this.returnTypeDefault=ServerStructures.ReturnType.LIST;this.resultComboIndexDefault=0;this.count=this.countDefault}return __extends(i,t),i.prototype.createAttributePanel=function(t,i){this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP);this.setDefault()},i.prototype.removeInputMarkers=function(){},i.prototype.setRangeComboForInputControls=function(){},i.prototype.updateInputControlLists=function(){},i.prototype.getRequest=function(){var n=new ServerStructures.LocalMeasurementRequest;return this.setStandardParameters(n),n.ReturnType=this.getReturnType(),n},i.prototype.areDefaultOptions=function(){var t=this.areBaseOptionsDefault(),n;return t?(n=this.getReturnType(),n!=this.returnTypeDefault)?!1:!0:!1},i.prototype.getReturnType=function(){if(this.resultsCombo){var t=this.resultsCombo.text();if(t==n.OptionsDialog.TOOL_RESULT_MARKERS)return ServerStructures.ReturnType.LIST;if(t==n.OptionsDialog.TOOL_RESULT_WAVEFORM)return ServerStructures.ReturnType.WAVEFORM}return this.returnTypeDefault},i.prototype.setState=function(n){this.measurementState=n},i.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},i.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},i.prototype.useResultsCombo=function(){return!0},i.prototype.setResults=function(n){this.measResults=new ServerStructures.OnePointResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.getMeasText=function(n,t){var e=WaveViewer.AxisUnits.formatDataValueForMeasurement(n,3,this.wf.getXUnits()),o=WaveViewer.AxisUnits.formatDataValueForMeasurement(t,3,this.wf.getYUnits()),r=this.measurementName+": ("+e+", "+o+")",i=this.getMeasRange(),u,f;return i&&(u=WaveViewer.AxisUnits.formatDataValueForMeasurement(i.xmin,3,null),f=WaveViewer.AxisUnits.formatDataValueForMeasurement(i.xmax,3,null),r+="\n["+u+"; "+f+"]"),r},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n),i,r;return t?(i=this.getMeasText(t.X,t.Y),r=new Markers.PointMarker(this.markerManager,t.X,t.Y,i,Markers.DRAG_DIRECTION.MEASUREMENT,n,!1),r):null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.BaseMeasurement),i,r;n.LocalMeasurement=t;i=function(t){function i(){t.call(this);this.measurementName="Local Max";this.className="LocalMaximumMeasurement";this.measurementId=ServerStructures.MeasurementID.LocalMaximum;this.tooltip="The local maximum points on the waveform"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i}(t);n.LocalMaximumMeasurement=i;r=function(t){function i(){t.call(this);this.measurementName="Local Min";this.className="LocalMinimumMeasurement";this.measurementId=ServerStructures.MeasurementID.LocalMinimum;this.tooltip="The local minimum points on the waveform"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i}(t);n.LocalMinimumMeasurement=r}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Maximum";this.className="MaximumMeasurement";this.measurementId=ServerStructures.MeasurementID.Maximum;this.tooltip="The maximum value"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.LevelResult(n)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(t){var i=this.measResults.getResult(this.compoundIndex,t);if(i){var r=i.Value,u=this.getMeasTextFromValue(r,this.measResults.Units),f=this.markerMode==n.MARKER_MODE.INPUT?Markers.DRAG_DIRECTION.VERTICAL:Markers.DRAG_DIRECTION.NONE;return new Markers.HorizontalLevelMarker(this.markerManager,r,u,f,t)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i}(n.LevelMeasurement);n.MaximumMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Minimum";this.className="MinimumMeasurement";this.measurementId=ServerStructures.MeasurementID.Minimum;this.tooltip="The minimum value"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.LevelResult(n)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(t){var i=this.measResults.getResult(this.compoundIndex,t);if(i){var r=i.Value,u=this.getMeasTextFromValue(r,this.measResults.Units),f=this.markerMode==n.MARKER_MODE.INPUT?Markers.DRAG_DIRECTION.VERTICAL:Markers.DRAG_DIRECTION.NONE;return new Markers.HorizontalLevelMarker(this.markerManager,r,u,f,t)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i}(n.LevelMeasurement);n.MinimumMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.apply(this,arguments);this.countDefault=ServerStructures.CountType.ALL;this.returnTypeDefault=ServerStructures.ReturnType.LIST;this.resultComboIndexDefault=0;this.relativeCheckboxDefault=!1;this.absoluteRelativeDefault=ServerStructures.AbsoluteRelative.ABSOLUTE;this.count=this.countDefault;this.labelTooltip=null}return __extends(i,t),i.prototype.getTopline=function(){return this.toplineControl?this.toplineControl.getValueAsNumber():null},i.prototype.getBaseline=function(){return this.baselineControl?this.baselineControl.getValueAsNumber():null},i.prototype.updateInputControls=function(n){return this.toplineControl&&this.toplineControl.setWaveform(n),this.baselineControl?this.baselineControl.setWaveform(n):void 0},i.prototype.createAttributePanel=function(t,i){var r=n.ToolUtils.createInputControls(t,i);this.toplineControl=r.topControl;this.baselineControl=r.baseControl;this.relativeCheckbox=n.ToolUtils.createCheckbox(i,"Show as Percentage:",this.labelTooltip,!1);this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP);this.setDefault()},i.prototype.removeInputMarkers=function(){this.toplineControl&&this.toplineControl.removeMarker();this.baselineControl&&this.baselineControl.removeMarker()},i.prototype.setRangeComboForInputControls=function(n){this.toplineControl&&this.toplineControl.setRangeCombo(n);this.baselineControl&&this.baselineControl.setRangeCombo(n)},i.prototype.updateInputControlLists=function(){this.toplineControl&&this.toplineControl.addToComboList();this.baselineControl&&this.baselineControl.addToComboList()},i.prototype.getRequest=function(){var n=new ServerStructures.OverUnderMeasurementRequest;return this.setStandardParameters(n),n.Topline=this.getTopline(),n.Baseline=this.getBaseline(),n.ReturnType=this.getReturnType(),n.AbsoluteOrRelative=this.getAbsoluteRelativeFlag(),n},i.prototype.getAbsoluteRelativeFlag=function(){return this.relativeCheckbox?this.relativeCheckbox.prop("checked")?ServerStructures.AbsoluteRelative.RELATIVE:ServerStructures.AbsoluteRelative.ABSOLUTE:this.absoluteRelativeDefault},i.prototype.getReturnType=function(){if(this.resultsCombo){var t=this.resultsCombo.text();if(t==n.OptionsDialog.TOOL_RESULT_MARKERS)return ServerStructures.ReturnType.LIST;if(t==n.OptionsDialog.TOOL_RESULT_WAVEFORM)return ServerStructures.ReturnType.WAVEFORM}return this.returnTypeDefault},i.prototype.setState=function(n){this.measurementState=n},i.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},i.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},i.prototype.useResultsCombo=function(){return!0},i.prototype.setResults=function(n){this.measResults=new ServerStructures.CycleEdgeResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.getMeasTextFromValueLocal=function(n,t){var u,r,i,f,e;return u=t=="%"?WaveViewer.AxisUnits.formatDataWithPercent(n)+t:WaveViewer.AxisUnits.formatDataValueForMeasurement(n,3,t),r=this.measurementName+": "+u,i=this.getMeasRange(),i&&(f=WaveViewer.AxisUnits.formatDataValueForMeasurement(i.xmin,3,null),e=WaveViewer.AxisUnits.formatDataValueForMeasurement(i.xmax,3,null),r+="\n["+f+"; "+e+"]"),r},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.areDefaultOptions=function(){var i=this.areBaseOptionsDefault(),n,t;return i?(n=this.getAbsoluteRelativeFlag(),n!=this.absoluteRelativeDefault)?!1:(t=this.getReturnType(),t!=this.returnTypeDefault)?!1:this.toplineControl&&!this.toplineControl.areDefaultOptions()?!1:this.baselineControl&&!this.baselineControl.areDefaultOptions()?!1:!0:!1},i.prototype.setDefault=function(){this.setBaseToDefault();this.relativeCheckbox.prop("checked",this.relativeCheckboxDefault);this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.BaseMeasurement),i,r;n.OverUnderMeasurement=t;i=function(t){function i(){t.call(this);this.measurementName="Overshoot";this.className="OvershootMeasurement";this.measurementId=ServerStructures.MeasurementID.Overshoot;this.tooltip="The difference between the maximum value of a pulse and the topline level";this.labelTooltip=n.ToolTooltips.OVERSHOOT_PERCENT}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var u=this.getMeasTextFromValueLocal(t.Value,this.measResults.Units),i=void 0,r=void 0;return t.Y1>t.Y2?(i=t.Y1,r=t.Y2):(i=t.Y2,r=t.Y1),new Markers.OverUnderMarker(this.markerManager,t.X1,i,r,u,n)}return null},i}(t);n.OvershootMeasurement=i;r=function(t){function i(){t.call(this);this.measurementName="Undershoot";this.className="UndershootMeasurement";this.measurementId=ServerStructures.MeasurementID.Undershoot;this.tooltip="The difference between the baseline level and the minimum value of a negative pulse";this.labelTooltip=n.ToolTooltips.UNDERSHOOT_PERCENT}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var u=this.getMeasTextFromValueLocal(t.Value,this.measResults.Units),i=void 0,r=void 0;return t.Y1<t.Y2?(i=t.Y1,r=t.Y2):(i=t.Y2,r=t.Y1),new Markers.OverUnderMarker(this.markerManager,t.X1,i,r,u,n)}return null},i}(t);n.UndershootMeasurement=r}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="PeakToPeak";this.className="PeakToPeakMeasurement";this.measurementId=ServerStructures.MeasurementID.PeakToPeak;this.tooltip="The difference between the maximum and minimum values of a waveform"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.TwoPointResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=t.Value,r=this.getMeasTextFromValue(i,this.measResults.Units);return new Markers.VerticalDeltaMarker(this.markerManager,t.X1,t.Y1,t.X2,t.Y2,r,n)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i}(n.LevelMeasurement);n.PeakToPeakMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Period";this.className="PeriodMeasurement";this.measurementId=ServerStructures.MeasurementID.Period;this.tooltip="The X difference between two consecutive edges of the same polarity"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.CycleEdgeResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=this.getMeasTextFromValue(t.Value,this.measResults.Units),r=new Markers.LinePoint(t.X1,t.Y1,0),u=new Markers.LinePoint(t.X2,t.Y2,1);return new Markers.HorizontalDeltaMarker(this.markerManager,r,u,i,n)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:i.isDigital()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault();this.checkTriggerButton(this.edgeTriggerDefault);this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.CycleMeasurement);n.PeriodMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="PulseWidth";this.className="PulseWidthMeasurement";this.measurementId=ServerStructures.MeasurementID.PulseWidth;this.tooltip="The width of a pulse that starts with a rising edge and ends with the next falling edge (a positive pulse) or starts with a falling edge and ends with the next rising edge (a negative pulse)"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.CycleEdgeResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=this.getMeasTextFromValue(t.Value,this.measResults.Units),r=new Markers.LinePoint(t.X1,t.Y1,0),u=new Markers.LinePoint(t.X2,t.Y2,1);return new Markers.HorizontalDeltaMarker(this.markerManager,r,u,i,n)}return null},i.prototype.createAttributePanel=function(t,i){var r=[],o=new n.RadioDescription("RiseFallPulse.gif",ServerStructures.Trigger.EITHER.toString(),n.ToolTooltips.PULSE_POLARITY_ANY,!0),f,e,u;r.push(o);f=new n.RadioDescription("RisingPulse.gif",ServerStructures.Trigger.POSITIVE.toString(),n.ToolTooltips.PULSE_POLARITY_POS);r.push(f);e=new n.RadioDescription("FallingPulse.gif",ServerStructures.Trigger.NEGATIVE.toString(),n.ToolTooltips.PULSE_POLARITY_NEG);r.push(e);this.edgeTriggerButtons=n.ToolUtils.createRadioButtonsGroup(i,"Pulse Polarity:",n.ToolTooltips.PULSE_POLARITY,r);u=n.ToolUtils.createInputControls(t,i);this.toplineControl=u.topControl;this.baselineControl=u.baseControl;this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP);this.setDefault()},i.prototype.removeInputMarkers=function(){this.toplineControl&&this.toplineControl.removeMarker();this.baselineControl&&this.baselineControl.removeMarker()},i.prototype.setRangeComboForInputControls=function(n){this.toplineControl&&this.toplineControl.setRangeCombo(n);this.baselineControl&&this.baselineControl.setRangeCombo(n)},i.prototype.updateInputControlLists=function(){this.toplineControl&&this.toplineControl.addToComboList();this.baselineControl&&this.baselineControl.addToComboList()},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:i.isDigital()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.setDefault=function(){this.setBaseToDefault();this.checkTriggerButton(this.edgeTriggerDefault);this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.CycleMeasurement);n.PulseWidthMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="Risetime";this.className="RisetimeMeasurement";this.measurementId=ServerStructures.MeasurementID.Risetime;this.tooltip="The X difference between the lower and upper levels"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.createAttributePanel=function(t,i){var r=n.ToolUtils.createInputControls(t,i);this.toplineControl=r.topControl;this.baselineControl=r.baseControl;this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP)},i.prototype.removeInputMarkers=function(){this.toplineControl&&this.toplineControl.removeMarker();this.baselineControl&&this.baselineControl.removeMarker()},i.prototype.setRangeComboForInputControls=function(n){this.toplineControl&&this.toplineControl.setRangeCombo(n);this.baselineControl&&this.baselineControl.setRangeCombo(n)},i.prototype.updateInputControlLists=function(){this.toplineControl&&this.toplineControl.addToComboList();this.baselineControl&&this.baselineControl.addToComboList()},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.getRequest=function(){var n=new ServerStructures.SlewRateMeasurementRequest;return this.setStandardParameters(n),n.Topline=this.getTopline(),n.Baseline=this.getBaseline(),n.EdgeTrigger=ServerStructures.Trigger.RISING,n.ReturnType=this.getReturnType(),n},i.prototype.areDefaultOptions=function(){var t=this.areBaseOptionsDefault(),n;return t?(n=this.getReturnType(),n!=ServerStructures.ReturnType.LIST)?!1:this.toplineControl&&!this.toplineControl.areDefaultOptions()?!1:this.baselineControl&&!this.baselineControl.areDefaultOptions()?!1:!0:!1},i.prototype.setDefault=function(){this.setBaseToDefault();this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i}(n.SlewRateMeasurement);n.RisetimeMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.measurementName="RMS";this.className="RMSMeasurement";this.measurementId=ServerStructures.MeasurementID.RMS;this.tooltip="The root-mean-square level"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LEVEL)),t},i.prototype.setResults=function(n){this.measResults=new ServerStructures.LevelResult(n)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var i=this.measResults.getResult(this.compoundIndex,n),t,r;return i&&(t=i.Value,r=this.getMeasTextFromValue(t,this.measResults.Units),this.measResults.LevelType==ServerStructures.LevelType.HORIZONTAL)?new Markers.HorizontalLevelMarker(this.markerManager,t,r,Markers.DRAG_DIRECTION.NONE,n):null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i}(n.LevelMeasurement);n.RMSMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.apply(this,arguments);this.xValueDefault="0.0"}return __extends(i,t),i.prototype.removeInputMarkers=function(){},i.prototype.setRangeComboForInputControls=function(){},i.prototype.updateInputControlLists=function(){},i.prototype.getRequest=function(){var n=new ServerStructures.SlopeMeasurementRequest;return this.setStandardParameters(n),n.XValue=this.xValueInput?this.getXValue():Number(this.xValueDefault),n.SlopeType=this.getSlopeType(),n},i.prototype.setState=function(n){this.measurementState=n},i.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},i.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},i.prototype.useResultsCombo=function(){return!0},i.prototype.setResults=function(n){this.measResults=new ServerStructures.OnePointResult(n,this.wf)},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var i=this.measResults.getResult(this.compoundIndex,n),t,r,u,f;return i?(t=this.measResults.Units,r=null,t.indexOf("per")>=0&&(r=t,t=null),u=this.getMeasTextFromValue(i.Value,t,r),f=new Markers.PointMarker(this.markerManager,i.X,i.Y,u,Markers.DRAG_DIRECTION.NONE,n,!1),f):null},i.prototype.validate=function(t){var i=t.arg1.wf,r,u,f,e;return i.isAnalogOrStep()?this.xValueInput?(r=n.ToolUtils.getInputError(this.xValueInput),r)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+r,"X Value"):(u=this.getXValue(),f=i.getXWaveformMin(),u<f)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_BY_X_MINIMUM,"X Value"):(e=i.getXWaveformMax(),u>e)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_BY_X_MAXIMUM,"X Value"):null:null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.getXValue=function(){var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.xValueInput.val())},i}(n.BaseMeasurement),i,r;n.SlopeMeasurementBase=t;i=function(t){function i(){t.call(this);this.measurementName="Slope";this.className="SlopeMeasurementTime";this.measurementId=ServerStructures.MeasurementID.Slope;this.tooltip="The slope of a waveform at the specified x value"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.createAttributePanel=function(t,i){var u,f,r,e,o;for(this.xValueInput=n.ToolUtils.createInputField(i,"X Value:",n.ToolTooltips.SLOPE_XVALUE),n.ToolUtils.addValidateInputListener(this.xValueInput,t),u=[],f=3,r=0;r<f;r++)e=ServerStructures.SlopeMeasurementRequest.getSlopeTypeByIndex(r),o=ServerStructures.SlopeMeasurementRequest.getSlopeNameByType(e),u.push(o);this.setDefault()},i.prototype.setDefault=function(){this.setBaseToDefault();this.xValueInput.val(this.xValueDefault)},i.prototype.getSlopeType=function(){return ServerStructures.SlopeType.NONE},i.prototype.areDefaultOptions=function(){var n=this.areBaseOptionsDefault();return n?this.xValueInput.val()!=this.xValueDefault?!1:!0:!1},i}(t);n.SlopeMeasurementTime=i;r=function(t){function i(){t.call(this);this.slopeTypeIndexDefault=0;this.slopeTypeValueDefault=ServerStructures.SlopeType.NONE;this.measurementName="Slope";this.className="SlopeMeasurementFrequency";this.measurementId=ServerStructures.MeasurementID.Slope;this.tooltip="Slope measurement"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_FREQUENCY)),t},i.prototype.createAttributePanel=function(t,i){var u,f,r,e,o;for(this.xValueInput=n.ToolUtils.createInputField(i,"X Value:",n.ToolTooltips.SLOPE_XVALUE),n.ToolUtils.addValidateInputListener(this.xValueInput,t),u=[],f=3,r=0;r<f;r++)e=ServerStructures.SlopeMeasurementRequest.getSlopeTypeByIndex(r),o=ServerStructures.SlopeMeasurementRequest.getSlopeNameByType(e),u.push(o);this.slopeTypeList=n.ToolUtils.createDropDownList(i,"Slope Type",u,n.ToolTooltips.SLOPE_TYPE);this.setDefault()},i.prototype.setDefault=function(){this.setBaseToDefault();this.xValueInput.val(this.xValueDefault);this.slopeTypeList.select(this.slopeTypeIndexDefault)},i.prototype.getSlopeType=function(){if(this.slopeTypeList){var n=this.slopeTypeList.select();return ServerStructures.SlopeMeasurementRequest.getSlopeTypeByIndex(n)}return this.slopeTypeValueDefault},i.prototype.areDefaultOptions=function(){var n=this.areBaseOptionsDefault();return n?this.xValueInput?this.slopeTypeList?this.xValueInput.val()!=this.xValueDefault?!1:this.slopeTypeList.select()!=this.slopeTypeIndexDefault?!1:!0:!0:!0:!1},i}(t);n.SlopeMeasurementFrequency=r}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this);this.countDefault=ServerStructures.CountType.ALL;this.returnTypeDefault=ServerStructures.ReturnType.LIST;this.resultComboIndexDefault=0;this.absoluteRelativeDefault=ServerStructures.AbsoluteRelative.RELATIVE;this.labelTooltip=null;this.measurementName="SettleTime";this.className="SettleTimeMeasurement";this.measurementId=ServerStructures.MeasurementID.SettleTime;this.tooltip="The time taken for a waveform to settle to within a tolerance band of the topline level (in the case of a rising edge) or the baseline level (in the case of a falling edge)";this.labelTooltip=n.ToolTooltips.SETTLETIME_TOLERANCE}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TIME)),t},i.prototype.getTopline=function(){return this.toplineControl?this.toplineControl.getValueAsNumber():null},i.prototype.getBaseline=function(){return this.baselineControl?this.baselineControl.getValueAsNumber():null},i.prototype.updateInputControls=function(n){return this.toplineControl&&this.toplineControl.setWaveform(n),this.baselineControl?this.baselineControl.setWaveform(n):void 0},i.prototype.createToleranceCombo=function(t){for(var i=n.ToolUtils.GLOBAL_TOOL_UTILS_COUNT++,f="Tool_Utils_Input_"+i,e="Tool_Utils_Label_"+i,o="Tool_Utils_Combo_"+i,u=[],r=1;r<11;r++)u.push(r+"%");this.toleranceCombo=n.ToolUtils.createDropDownList(t,"Tolerance",u,this.labelTooltip)},i.prototype.setDefaultTolerance=function(){if(this.toleranceCombo){var n=ServerStructures.SettleTimeMeasurementRequest.DEFAULT_TOLERANCE+"%";this.toleranceCombo.text(n)}},i.prototype.createAttributePanel=function(t,i){var r=n.ToolUtils.createInputControls(t,i);this.toplineControl=r.topControl;this.baselineControl=r.baseControl;this.createToleranceCombo(i);this.resultsCombo=n.ToolUtils.createDropDownList(i,n.OptionsDialog.RESULTS_COMBO_NAME,n.OptionsDialog.TOOL_RESULT_LIST,n.OptionsDialog.RESULTS_COMBO_TOOLTIP);this.setDefault()},i.prototype.removeInputMarkers=function(){this.toplineControl&&this.toplineControl.removeMarker();this.baselineControl&&this.baselineControl.removeMarker()},i.prototype.setRangeComboForInputControls=function(n){this.toplineControl&&this.toplineControl.setRangeCombo(n);this.baselineControl&&this.baselineControl.setRangeCombo(n)},i.prototype.updateInputControlLists=function(){this.toplineControl&&this.toplineControl.addToComboList();this.baselineControl&&this.baselineControl.addToComboList()},i.prototype.getRequest=function(){var n=new ServerStructures.SettleTimeMeasurementRequest;return this.setStandardParameters(n),n.Topline=this.getTopline(),n.Baseline=this.getBaseline(),n.ReturnType=this.getReturnType(),n.Count=this.countDefault,n.AbsoluteOrRelative=this.absoluteRelativeDefault,n.Tolerance=n.setToleranceValue(this.getTolerance()),n},i.prototype.getTolerance=function(){var n;return this.toleranceCombo?(n=this.toleranceCombo.text(),n=n.substring(0,n.lastIndexOf("%")),Number(n)):ServerStructures.SettleTimeMeasurementRequest.DEFAULT_TOLERANCE},i.prototype.getReturnType=function(){if(this.resultsCombo){var t=this.resultsCombo.text();if(t==n.OptionsDialog.TOOL_RESULT_MARKERS)return ServerStructures.ReturnType.LIST;if(t==n.OptionsDialog.TOOL_RESULT_WAVEFORM)return ServerStructures.ReturnType.WAVEFORM}return this.returnTypeDefault},i.prototype.setState=function(n){this.measurementState=n},i.prototype.addRequest=function(n){var t=this.measurementState;t&&(t.waveformName=this.wf.getFullWaveformName(),n.MeasRequests.push(t))},i.prototype.getMeasRange=function(){var n=this.measurementState;return n?n.XBegin==null&&n.XEnd==null?null:new WaveViewer.XWaveRange(n.XBegin,n.XEnd):null},i.prototype.useResultsCombo=function(){return!0},i.prototype.setResults=function(n){this.measResults=new ServerStructures.CycleEdgeResult(n,this.wf);this.measResults.Units=this.wf.getXUnits()},i.prototype.getAllResults=function(){return this.measResults},i.prototype.createMarkerLocal=function(n){var t=this.measResults.getResult(this.compoundIndex,n);if(t){var i=this.getMeasTextFromValue(t.Value,this.measResults.Units),r=new Markers.LinePoint(t.X1,t.Y1,0),u=new Markers.LinePoint(t.X2,t.Y2,1);return new Markers.HorizontalDeltaMarker(this.markerManager,r,u,i,n)}return null},i.prototype.validate=function(t){var i=t.arg1.wf;return i.isAnalogOrStep()?null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.areDefaultOptions=function(){var i=this.areBaseOptionsDefault(),n,t;return i?(n=this.getTolerance(),n!=ServerStructures.SettleTimeMeasurementRequest.DEFAULT_TOLERANCE)?!1:(t=this.getReturnType(),t!=ServerStructures.ReturnType.LIST)?!1:this.toplineControl&&!this.toplineControl.areDefaultOptions()?!1:this.baselineControl&&!this.baselineControl.areDefaultOptions()?!1:!0:!1},i.prototype.setDefault=function(){this.setBaseToDefault();this.setDefaultTolerance();this.toplineControl&&this.toplineControl.setDefault();this.baselineControl&&this.baselineControl.setDefault();this.resultsCombo.select(this.resultComboIndexDefault)},i.TOLERANCE_WIDTH="105px",i.UNITS_COMBO_WIDTH="44px",i.TOLERANCE_CLASS="tolerance_input_class",i}(n.BaseMeasurement);n.SettleTimeMeasurement=t}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var i,t,r,u,f;(function(n){n[n.BTN_ZERO=0]="BTN_ZERO";n[n.BTN_ONE=1]="BTN_ONE";n[n.BTN_TWO=2]="BTN_TWO";n[n.BTN_THREE=3]="BTN_THREE";n[n.BTN_FOUR=4]="BTN_FOUR";n[n.BTN_FIVE=5]="BTN_FIVE";n[n.BTN_SIX=6]="BTN_SIX";n[n.BTN_SEVEN=7]="BTN_SEVEN";n[n.BTN_EIGHT=8]="BTN_EIGHT";n[n.BTN_NINE=9]="BTN_NINE";n[n.BTN_POINT=10]="BTN_POINT";n[n.BTN_EXP_NOTATION=11]="BTN_EXP_NOTATION";n[n.BTN_ADD=12]="BTN_ADD";n[n.BTN_SUBTRACT=13]="BTN_SUBTRACT";n[n.BTN_MULTIPLY=14]="BTN_MULTIPLY";n[n.BTN_DIVIDE=15]="BTN_DIVIDE";n[n.BTN_PI=16]="BTN_PI";n[n.BTN_2PI=17]="BTN_2PI";n[n.BTN_EPSILON=18]="BTN_EPSILON";n[n.BTN_BOLTZMAN=19]="BTN_BOLTZMAN";n[n.BTN_SIN=20]="BTN_SIN";n[n.BTN_COS=21]="BTN_COS";n[n.BTN_TAN=22]="BTN_TAN";n[n.BTN_POWER=23]="BTN_POWER";n[n.BTN_LOG=24]="BTN_LOG";n[n.BTN_LN=25]="BTN_LN";n[n.BTN_SQRT=26]="BTN_SQRT";n[n.BTN_SHIFT=27]="BTN_SHIFT";n[n.BTN_RECIPROCAL=28]="BTN_RECIPROCAL";n[n.BTN_SIGN=29]="BTN_SIGN";n[n.BTN_INTEGRATE=30]="BTN_INTEGRATE";n[n.BTN_DIFFERENCIATE=31]="BTN_DIFFERENCIATE";n[n.BTN_EEX=32]="BTN_EEX";n[n.BTN_MOD=33]="BTN_MOD";n[n.BTN_MAGNITUDE=34]="BTN_MAGNITUDE";n[n.BTN_PHASE=35]="BTN_PHASE";n[n.BTN_REAL=36]="BTN_REAL";n[n.BTN_IMAGINARY=37]="BTN_IMAGINARY";n[n.BTN_ABS=38]="BTN_ABS";n[n.BTN_SINH=40]="BTN_SINH";n[n.BTN_ASINH=41]="BTN_ASINH";n[n.BTN_COSH=42]="BTN_COSH";n[n.BTN_ACOSH=43]="BTN_ACOSH";n[n.BTN_TANH=44]="BTN_TANH";n[n.BTN_ATANH=45]="BTN_ATANH";n[n.BTN_DTOA=46]="BTN_DTOA";n[n.BTN_AND=47]="BTN_AND";n[n.BTN_NOT=48]="BTN_NOT";n[n.BTN_OR=49]="BTN_OR";n[n.BTN_XOR=50]="BTN_XOR";n[n.BTN_SHIFTL=51]="BTN_SHIFTL";n[n.BTN_SHIFTR=52]="BTN_SHIFTR";n[n.BTN_MASK=53]="BTN_MASK";n[n.BTN_DELAY=54]="BTN_DELAY";n[n.BTN_PARITY=55]="BTN_PARITY";n[n.BTN_ATOD=56]="BTN_ATOD";n[n.BTN_ASIN=57]="BTN_ASIN";n[n.BTN_ACOS=58]="BTN_ACOS";n[n.BTN_ATAN=59]="BTN_ATAN";n[n.BTN_POW10=60]="BTN_POW10";n[n.BTN_POWE=61]="BTN_POWE";n[n.BTN_SQR=62]="BTN_SQR";n[n.BTN_CLEARENTRY=63]="BTN_CLEARENTRY";n[n.BTN_STORE=64]="BTN_STORE";n[n.BTN_RECALL=65]="BTN_RECALL";n[n.BTN_PLOT=66]="BTN_PLOT";n[n.BTN_EVAL=67]="BTN_EVAL";n[n.BTN_ENTER_MOVE=68]="BTN_ENTER_MOVE";n[n.BTN_CPHASE=69]="BTN_CPHASE";n[n.BTN_PRAN=70]="BTN_PRAN";n[n.BTN_DB=71]="BTN_DB";n[n.BTN_FFT=72]="BTN_FFT";n[n.BTN_IFFT=73]="BTN_IFFT";n[n.BTN_HIST=74]="BTN_HIST";n[n.BTN_RAND=75]="BTN_RAND";n[n.BTN_YY=76]="BTN_YY";n[n.BTN_SMPL=77]="BTN_SMPL";n[n.BTN_LIMITX=78]="BTN_LIMITX";n[n.BTN_LIMITY=79]="BTN_LIMITY";n[n.BTN_COMPARE=80]="BTN_COMPARE";n[n.BTN_ATTR=81]="BTN_ATTR";n[n.BTN_PARA=82]="BTN_PARA";n[n.BTN_LIMIT=83]="BTN_LIMIT";n[n.BTN_EQ=84]="BTN_EQ";n[n.BTN_NE=85]="BTN_NE";n[n.BTN_LT=86]="BTN_LT";n[n.BTN_LE=87]="BTN_LE";n[n.BTN_GE=88]="BTN_GE";n[n.BTN_GT=89]="BTN_GT";n[n.BTN_NAND=90]="BTN_NAND";n[n.BTN_NOR=91]="BTN_NOR";n[n.BTN_XSCALE=92]="BTN_XSCALE";n[n.BTN_XLIMIT=93]="BTN_XLIMIT";n[n.BTN_XSHIFT=94]="BTN_XSHIFT";n[n.BTN_XDATA=95]="BTN_XDATA";n[n.BTN_YDATA=96]="BTN_YDATA";n[n.BTN_APPEND=97]="BTN_APPEND";n[n.BTN_ANALOG=98]="BTN_ANALOG";n[n.BTN_STEP=99]="BTN_STEP";n[n.BTN_SCATTER=100]="BTN_SCATTER";n[n.BTN_SPECTRAL=101]="BTN_SPECTRAL";n[n.BTN_XSAMPLE=102]="BTN_XSAMPLE";n[n.BTN_TEMPCONV=103]="BTN_TEMPCONV";n[n.BTN_UNITCONV=104]="BTN_UNITCONV";n[n.BTN_YLIMIT=105]="BTN_YLIMIT";n[n.BTN_ENVELOPE=106]="BTN_ENVELOPE";n[n.BTN_FIXED=107]="BTN_FIXED";n[n.BTN_YVSX=108]="BTN_YVSX";n[n.BTN_BCSP=109]="BTN_BCSP";n[n.BTN_WINAVE=110]="BTN_WINAVE"})(n.CalcButtonId||(n.CalcButtonId={}));i=n.CalcButtonId;t=function(t){function r(){t.call(this);this.showImage=!0;this.isOperation=!0;this.useOptions=!1}return __extends(r,t),r.prototype.areDefaultOptions=function(){return!0},r.prototype.getName=function(){return this.name},r.prototype.isBinary=function(){return this.buttonType==n.OPERATION_TYPE.BINARY_OPERATION},r.prototype.createOptionPanel=function(n,t){this.createAttributePanel(n,t)},r.prototype.getButton=function(){var t;return t=this.imageUrl?new n.CalcImageButton(this.id,this.buttonType,this.operationLabel,this.imageUrl,this.tooltip,this,this.showImage):new n.CalcLabelButton(this.id,this.buttonType,this.operationLabel,this.buttonLabel,this.tooltip,this,!1),this.id==i.BTN_ZERO&&(t.isZero=!0),this.id==-1&&(t.isEmpty=!0),t},r.prototype.hasOptions=function(){return this.useOptions},r.prototype.getResultsFromServer=function(){return null},r.prototype.getRequest=function(){return null},r.prototype.doApply=function(n){var e=this,r=$.Deferred(),o=n.arg1.wf,s=n.arg2.wf,t=o?o.waveContainer:s.waveContainer,i,u,f;if(t)if(t.showSpinner(),i=new ServerStructures.ExpressionRequestClient,this.addExpressionRequestElement(i,n),u=WaveViewer.WdbInfo.getExpressionWdbId(),f=!0,i.ExprRequests.length!=0)$.when(WaveViewer.ViewerRequests.createAndInitExpressions(i)).done(function(n){var o,i;if(n&&n.length>0){for(o=0;o<n.length;o++)i=n[o],i?(e.resultWaveformHandle=i.handle,e.resultWdbId=u,t.getViewerWindow().plotWaveformByHandle(i.resultId,i.handle,u,null,!1)):f=!1;return t.moveToBottom(),t.hideSpinner(),r.resolve(f)}return t.hideSpinner(),r.resolve(!1)}).fail(function(){return t.hideSpinner(),r.resolve(!1)});else{t.hideSpinner();return}else{t.hideSpinner();return}},r.prototype.getWaveformExpression=function(t){var i="(",u,r;return this.isBinary()?(r=t.arg1.wf,i+=n.ToolUtils.getWfExpression(r)+", ",u=t.arg2.wf,i+=n.ToolUtils.getWfExpression(u)):(r=t.arg1.wf,i+=n.ToolUtils.getWfExpression(r)),i+")"},r.prototype.getExpressionName=function(t){var r="",f,u,e,i;return this.isBinary()?(i=t.arg1.wf,f=i?n.ToolUtils.getWfExpression(i):""+t.arg1.val,r+=f+", ",u=t.arg2.wf,e=u?n.ToolUtils.getWfExpression(u):""+t.arg2.val,r+=e):(i=t.arg1.wf,r+=n.ToolUtils.getWfExpression(i)),r},r.prototype.setWaveforms=function(){},r.prototype.removeInputMarkers=function(){},r.prototype.setRangeComboForInputControls=function(){},r.prototype.updateInputControlLists=function(){},r.prototype.addButton=function(n,t){var i=this.getButton();return i.addToPanel(n,t),i},r.prototype.useNumbers=function(){return!1},r.prototype.setDefault=function(){},r.prototype.addExpressionRequestElement=function(n,t){var i=new ServerStructures.ExpressionRequestElemClient,r;i.divisions=WaveViewer.ViewerRequests.getNumDivsForRequest(!1);i.xmin=null;i.xmax=null;i.name=this.getExpressionName(t);r=WaveViewer.WdbInfo.getExpressionWdbId();i.wdbId=r;i.containerUniqName=WaveViewer.SourceInfo.VIEWER_CONTAINER_NAME;i.expression=this.getExpression(t);n.ExprRequests.push(i)},r.prototype.isWaveformAnalogOrStep=function(t){var r=t.arg1.wf,u=t.arg2.wf,f=!0,i;return(r&&(f=r.isAnalogOrStep()?!0:!1),i=!0,this.isBinary()&&u&&(i=u.isAnalogOrStep()?!0:!1),f&&i)?null:n.ToolMessages.UNSUPPORTED_OPERATION},r.prototype.validate=function(n){var t=this.isWaveformAnalogOrStep(n);return t?t:null},r}(n.ToolOperation);n.CalcFunction=t;r=function(t){function i(){t.call(this)}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_CALCULATOR)),t},i.prototype.createAttributePanel=function(){},i}(t);n.MathOperation=r;u=function(t){function i(){t.call(this)}return __extends(i,t),i.prototype.createAttributePanel=function(){},i.prototype.getExpression=function(t){var i=this.name.toLowerCase()+"(",u,r;return this.isBinary()?(r=t.arg1.wf,i+=n.ToolUtils.getWfExpression(r)+", ",u=t.arg2.wf,i+=n.ToolUtils.getWfExpression(u)):(r=t.arg1.wf,i+=n.ToolUtils.getWfExpression(r)),i+")"},i.prototype.getExpressionName=function(n){var t="",r,i;return this.isBinary()?(i=n.arg1.wf,t+=i.getSimpleWaveformName(),t+="_"+this.operationLabel+"_",r=n.arg2.wf,t+=r.getSimpleWaveformName()):(i=n.arg1.wf,t+=this.operationLabel+"(",t+=i.getSimpleWaveformName(),t+=")"),t},i}(t);n.WfOperation=u;f=function(){function n(){this.text=null;this.wfId=null}return n}();n.ArgInfo=f}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.apply(this,arguments)}return __extends(i,t),i.prototype.doApply=function(n){var u=this,f=n.arg1.wf,e=n.arg2.wf,t=f?f.waveContainer:e.waveContainer,i,r;if(t)if(t.showSpinner(),i=new ServerStructures.ExpressionRequestClient,this.addExpressionRequestElement(i,n),r=WaveViewer.WdbInfo.getExpressionWdbId(),i.ExprRequests.length!=0)$.when(WaveViewer.ViewerRequests.createAndInitExpressions(i)).done(function(n){var f,i;if(n){for(f=0;f<n.length;f++)if(i=n[f],i)u.resultWaveformHandle=i.handle,u.resultWdbId=r,t.getViewerWindow().plotWaveformByHandle(i.resultId,i.handle,r,null,!1);else{t.hideSpinner();return}t.moveToBottom();t.hideSpinner();return}t.hideSpinner();return}).fail(function(){t.hideSpinner();return});else{t.hideSpinner();return}else{t.hideSpinner();return}},i.prototype.useNumbers=function(){return!0},i.prototype.getExpressionName=function(n){var t="",r=n.arg1.wf,f=r?r.getSimpleWaveformName():""+n.arg1.val,i,u;return t+=f,t+=this.operationLabel,i=n.arg2.wf,u=i?i.getSimpleWaveformName():""+n.arg2.val,t+u},i.prototype.getExpression=function(t){var i="",f,u,e,r;return this.isBinary()?(r=t.arg1.wf,f=r?n.ToolUtils.getWfExpression(r):""+t.arg1.val,i+=f,i+=this.operationLabel,u=t.arg2.wf,e=u?n.ToolUtils.getWfExpression(u):""+t.arg2.val,i+=e):(r=t.arg1.wf,i+=n.ToolUtils.getWfExpression(r)),i},i}(n.MathOperation),i,r,u,f;n.SimpleMathOperation=t;i=function(t){function i(){t.call(this);this.name="Divide";this.id=n.CalcButtonId.BTN_DIVIDE;this.imageUrl="CalcDivide.gif";this.tooltip="Divide";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.operationLabel="/"}return __extends(i,t),i.prototype.validate=function(t){var r=this.isWaveformAnalogOrStep(t),i;if(r)return r;if(i=t.arg2.wf,i){if(!this.canDivide(i))return n.ToolMessages.DIVIDE_ZERO_DENOMINATOR_WAVEFORM}else if(!t.arg2.val)return n.ToolMessages.DIVIDE_ZERO_DENOMINATOR;return null},i.prototype.canDivide=function(n){var t=n.getWholeYRange(),i;if(t.ymin==0&&t.ymax==0)return!1;if(t.useAsConstant)if(i=WaveViewer.getManager().getWaveformInfoFromCache(n.simulationId,null,n.getFullWaveformName(),!0),i){if(!i.canDivide())return!1}else if(t.ymin==-1&&t.ymax==1)return!1;return!0},i}(t);n.DivideOperation=i;r=function(t){function i(){t.call(this);this.name="Multiply";this.id=n.CalcButtonId.BTN_MULTIPLY;this.imageUrl="CalcMultiply.gif";this.tooltip="Multiply";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.operationLabel="*"}return __extends(i,t),i}(t);n.MultiplyOperation=r;u=function(t){function i(){t.call(this);this.name="Subtract";this.id=n.CalcButtonId.BTN_SUBTRACT;this.imageUrl="CalcMinus.gif";this.tooltip="Subtract";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.operationLabel="-"}return __extends(i,t),i}(t);n.SubtractOperation=u;f=function(t){function i(){t.call(this);this.name="Add";this.id=n.CalcButtonId.BTN_ADD;this.imageUrl="CalcAdd.gif";this.tooltip="Add";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.operationLabel="+"}return __extends(i,t),i}(t);n.AddOperation=f}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var l=function(t){function i(){t.call(this);this.name="drv";this.id=n.CalcButtonId.BTN_DIFFERENCIATE;this.imageUrl="CalcDiff.gif";this.tooltip="Derivative";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="drv"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation),t,i,r,u,f,e,o,s,h,c;n.DrvOperation=l;t=function(t){function i(){t.call(this);this.name="integ";this.id=n.CalcButtonId.BTN_INTEGRATE;this.imageUrl="CalcInteg.gif";this.tooltip="Integral";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="integ"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.IntegOperation=t;i=function(t){function i(){t.call(this);this.name="exp";this.id=n.CalcButtonId.BTN_EXP_NOTATION;this.imageUrl="CalcEPowerX.gif";this.tooltip="Exponential";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="exp";this.showImage=!1}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.ExpOperation=i;r=function(t){function i(){t.call(this);this.name="log";this.id=n.CalcButtonId.BTN_LN;this.tooltip="Natural Logarithm";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="ln";this.buttonLabel="ln"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.LnOperation=r;u=function(t){function i(){t.call(this);this.name="sqr";this.id=n.CalcButtonId.BTN_SQR;this.imageUrl="CalcSqr.gif";this.tooltip="Square";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="sqr";this.showImage=!1}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.SquareOperation=u;f=function(t){function i(){t.call(this);this.name="sqrt";this.id=n.CalcButtonId.BTN_SQRT;this.imageUrl="CalcSqrt.gif";this.tooltip="Square Root";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="sqrt";this.showImage=!1}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.SquareRootOperation=f;e=function(t){function i(){t.call(this);this.name="exp10";this.id=n.CalcButtonId.BTN_POW10;this.imageUrl="Calc10PowerX.gif";this.tooltip="10 to Power of X (inverse logarithm)";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="10**";this.showImage=!1}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.Power10Operation=e;o=function(t){function i(){t.call(this);this.name="log10";this.id=n.CalcButtonId.BTN_LOG;this.tooltip="Logarithm";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="log10";this.buttonLabel="log10"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.LogarithmOperation=o;s=function(t){function i(){t.call(this);this.name="1/";this.id=n.CalcButtonId.BTN_RECIPROCAL;this.tooltip="Reciprocal";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.operationLabel="1/";this.buttonLabel="1/X"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.ReciprocalOperation=s;h=function(t){function i(){t.call(this);this.name="**";this.id=n.CalcButtonId.BTN_POWER;this.imageUrl="CalcPower.gif";this.tooltip="Power: x**y";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.operationLabel="**";this.showImage=!1}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.getExpression=function(t){var i="",u=t.arg1.wf,r;return i+=n.ToolUtils.getWfExpression(u),i+=this.name,r=t.arg2.wf,i+n.ToolUtils.getWfExpression(r)},i}(n.WfOperation);n.PowerOperation=h;c=function(t){function i(){t.call(this);this.name="abs";this.id=n.CalcButtonId.BTN_ABS;this.tooltip="Absolute Value";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="|x|";this.operationLabel="abs"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i}(n.WfOperation);n.AbsOperation=c}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(){t.call(this)}return __extends(i,t),i.prototype.createAttributePanel=function(){},i.prototype.useNumbers=function(){return!0},i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_CALCULATOR)),t},i.prototype.doApply=function(){},i.prototype.getValue=function(){return this.name},i.prototype.getExpression=function(){return""},i}(n.CalcFunction),i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b;n.NumberOperation=t;i=function(t){function i(){t.call(this);this.name=" ";this.id=-1;this.tooltip="Not implemented";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel=" ";this.buttonLabel=" "}return __extends(i,t),i.prototype.getValue=function(){return""},i}(t);n.EmptyOperation=i;r=function(t){function i(){t.call(this);this.name="Backspace";this.id=n.CalcButtonId.BTN_BCSP;this.tooltip="Backspace";this.imageUrl="backspace.gif";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel=" ";this.buttonLabel="<--"}return __extends(i,t),i}(t);n.BackspaceOperation=r;u=function(t){function i(){t.call(this);this.name="0";this.id=n.CalcButtonId.BTN_ZERO;this.tooltip="Zero";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="0";this.buttonLabel="0"}return __extends(i,t),i}(t);n.Num0Operation=u;f=function(t){function i(){t.call(this);this.name="1";this.id=n.CalcButtonId.BTN_ONE;this.tooltip="One";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="1";this.buttonLabel="1"}return __extends(i,t),i}(t);n.Num1Operation=f;e=function(t){function i(){t.call(this);this.name="2";this.id=n.CalcButtonId.BTN_TWO;this.tooltip="Two";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="2";this.buttonLabel="2"}return __extends(i,t),i}(t);n.Num2Operation=e;o=function(t){function i(){t.call(this);this.name="3";this.id=n.CalcButtonId.BTN_THREE;this.tooltip="Three";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="3";this.buttonLabel="3"}return __extends(i,t),i}(t);n.Num3Operation=o;s=function(t){function i(){t.call(this);this.name="4";this.id=n.CalcButtonId.BTN_FOUR;this.tooltip="Four";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="4";this.buttonLabel="4"}return __extends(i,t),i}(t);n.Num4Operation=s;h=function(t){function i(){t.call(this);this.name="5";this.id=n.CalcButtonId.BTN_FIVE;this.tooltip="Five";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="5";this.buttonLabel="5"}return __extends(i,t),i}(t);n.Num5Operation=h;c=function(t){function i(){t.call(this);this.name="6";this.id=n.CalcButtonId.BTN_SIX;this.tooltip="Six";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="6";this.buttonLabel="6"}return __extends(i,t),i}(t);n.Num6Operation=c;l=function(t){function i(){t.call(this);this.name="7";this.id=n.CalcButtonId.BTN_SEVEN;this.tooltip="Seven";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="7";this.buttonLabel="7"}return __extends(i,t),i}(t);n.Num7Operation=l;a=function(t){function i(){t.call(this);this.name="8";this.id=n.CalcButtonId.BTN_EIGHT;this.tooltip="Eight";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="8";this.buttonLabel="8"}return __extends(i,t),i}(t);n.Num8Operation=a;v=function(t){function i(){t.call(this);this.name="9";this.id=n.CalcButtonId.BTN_NINE;this.tooltip="Nine";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="9";this.buttonLabel="9"}return __extends(i,t),i}(t);n.Num9Operation=v;y=function(t){function i(){t.call(this);this.name=".";this.id=n.CalcButtonId.BTN_POINT;this.tooltip="Decimal point";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel=".";this.buttonLabel="."}return __extends(i,t),i}(t);n.NumPointOperation=y;p=function(t){function i(){t.call(this);this.name="+/-";this.id=n.CalcButtonId.BTN_SIGN;this.tooltip="Change sign";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="+/-";this.buttonLabel="+/-"}return __extends(i,t),i.prototype.getValue=function(){return""},i}(t);n.NumSignOperation=p;w=function(t){function i(){t.call(this);this.name="E";this.id=n.CalcButtonId.BTN_EXP_NOTATION;this.tooltip="Exponent Notation";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="E";this.buttonLabel="E"}return __extends(i,t),i}(t);n.NumEOperation=w;b=function(t){function i(){t.call(this);this.name="pi";this.id=n.CalcButtonId.BTN_PI;this.imageUrl="pi.png";this.tooltip="Constant PI = 3.141592653589793";this.buttonType=n.OPERATION_TYPE.NUMBER;this.operationLabel="Pi";this.buttonLabel="Pi"}return __extends(i,t),i.prototype.getValue=function(){return"3.141592653589793"},i}(t);n.NumPiOperation=b}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var c=function(t){function i(){t.call(this);this.name="and";this.id=n.CalcButtonId.BTN_AND;this.tooltip="Logical AND";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="and";this.operationLabel="and"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(n){return"band"+this.getWaveformExpression(n)},i}(n.MathOperation),t,i,r,u,f,e,o,s,h;n.AndOperation=c;t=function(t){function i(){t.call(this);this.name="or";this.id=n.CalcButtonId.BTN_OR;this.tooltip="Logical OR";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="or";this.operationLabel="or"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(n){return"bor"+this.getWaveformExpression(n)},i}(n.MathOperation);n.OrOperation=t;i=function(t){function i(){t.call(this);this.name="not";this.id=n.CalcButtonId.BTN_NOT;this.tooltip="Logical NOT";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="not";this.operationLabel="not"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(n){return"bnot"+this.getWaveformExpression(n)},i}(n.MathOperation);n.NotOperation=i;r=function(t){function i(){t.call(this);this.name="xor";this.id=n.CalcButtonId.BTN_XOR;this.tooltip="Logical XOR";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="xor";this.operationLabel="xor"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(n){return"xor"+this.getWaveformExpression(n)},i}(n.MathOperation);n.XorOperation=r;u=function(t){function i(){t.call(this);this.name=">";this.id=n.CalcButtonId.BTN_GT;this.tooltip="Greater";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel=">";this.operationLabel=">"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(t){var i="",u=t.arg1.wf,r;return i+=n.ToolUtils.getWfExpression(u)+this.operationLabel,r=t.arg2.wf,i+n.ToolUtils.getWfExpression(r)},i}(n.MathOperation);n.GtOperation=u;f=function(t){function i(){t.call(this);this.name="<";this.id=n.CalcButtonId.BTN_LT;this.tooltip="Less";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="<";this.operationLabel="<"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(t){var i="",u=t.arg1.wf,r;return i+=n.ToolUtils.getWfExpression(u)+this.operationLabel,r=t.arg2.wf,i+n.ToolUtils.getWfExpression(r)},i}(n.MathOperation);n.LtOperation=f;e=function(t){function i(){t.call(this);this.name=">=";this.id=n.CalcButtonId.BTN_GE;this.tooltip="Greater or Equal";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel=">=";this.operationLabel=">="}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(t){var i="",u=t.arg1.wf,r;return i+=n.ToolUtils.getWfExpression(u)+this.operationLabel,r=t.arg2.wf,i+n.ToolUtils.getWfExpression(r)},i}(n.MathOperation);n.GeOperation=e;o=function(t){function i(){t.call(this);this.name="<=";this.id=n.CalcButtonId.BTN_LE;this.tooltip="Less or Equal";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="<=";this.operationLabel="<="}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(t){var i="",u=t.arg1.wf,r;return i+=n.ToolUtils.getWfExpression(u)+this.operationLabel,r=t.arg2.wf,i+n.ToolUtils.getWfExpression(r)},i}(n.MathOperation);n.LeOperation=o;s=function(t){function i(){t.call(this);this.name="==";this.id=n.CalcButtonId.BTN_EQ;this.tooltip="Equal";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="==";this.operationLabel="=="}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(t){var i="",u=t.arg1.wf,r;return i+=n.ToolUtils.getWfExpression(u)+this.operationLabel,r=t.arg2.wf,i+n.ToolUtils.getWfExpression(r)},i}(n.MathOperation);n.EqOperation=s;h=function(t){function i(){t.call(this);this.name="!=";this.id=n.CalcButtonId.BTN_NE;this.tooltip="Not Equal";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="!=";this.operationLabel="!="}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_LOGIC)),t},i.prototype.getExpression=function(t){var i="",u=t.arg1.wf,r;return i+=n.ToolUtils.getWfExpression(u)+this.operationLabel,r=t.arg2.wf,i+n.ToolUtils.getWfExpression(r)},i}(n.MathOperation);n.NeOperation=h}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var a=function(t){function i(){t.call(this);this.name="sin";this.id=n.CalcButtonId.BTN_SIN;this.tooltip="Sine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="sin";this.operationLabel="sin"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation),t,i,r,u,f,e,o,s,h,c,l;n.SinOperation=a;t=function(t){function i(){t.call(this);this.name="asin";this.id=n.CalcButtonId.BTN_ASIN;this.tooltip="Arc Sine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="asin";this.operationLabel="asin"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.AsinOperation=t;i=function(t){function i(){t.call(this);this.name="cos";this.id=n.CalcButtonId.BTN_COS;this.tooltip="Cosine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="cos";this.operationLabel="cos"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.CosOperation=i;r=function(t){function i(){t.call(this);this.name="acos";this.id=n.CalcButtonId.BTN_ACOS;this.tooltip="Arc Cosine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="acos";this.operationLabel="acos"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.AcosOperation=r;u=function(t){function i(){t.call(this);this.name="tan";this.id=n.CalcButtonId.BTN_TAN;this.tooltip="Tangent";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="tan";this.operationLabel="tan"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.TanOperation=u;f=function(t){function i(){t.call(this);this.name="atan";this.id=n.CalcButtonId.BTN_ATAN;this.tooltip="Arc Tangent";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="atan";this.operationLabel="atan"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.AtanOperation=f;e=function(t){function i(){t.call(this);this.name="sinh";this.id=n.CalcButtonId.BTN_SINH;this.tooltip="Hyperbolic Sine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="sinh";this.operationLabel="sinh"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.SinhOperation=e;o=function(t){function i(){t.call(this);this.name="asinh";this.id=n.CalcButtonId.BTN_ASINH;this.tooltip="Hyperbolic Arc Sine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="asinh";this.operationLabel="asinh"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.AsinhOperation=o;s=function(t){function i(){t.call(this);this.name="cosh";this.id=n.CalcButtonId.BTN_COSH;this.tooltip="Hyperbolic Cosine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="cosh";this.operationLabel="cosh"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.CoshOperation=s;h=function(t){function i(){t.call(this);this.name="acosh";this.id=n.CalcButtonId.BTN_ACOSH;this.tooltip="Hyperbolic Arc Cosine";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="acosh";this.operationLabel="acosh"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.AcoshOperation=h;c=function(t){function i(){t.call(this);this.name="tanh";this.id=n.CalcButtonId.BTN_TANH;this.tooltip="Hyperbolic Tangent";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="tanh";this.operationLabel="tanh"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.TanhOperation=c;l=function(t){function i(){t.call(this);this.name="atanh";this.id=n.CalcButtonId.BTN_ATANH;this.tooltip="Hyperbolic Arc Tangent";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="atanh";this.operationLabel="atanh"}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRIG)),t},i}(n.WfOperation);n.AtanhOperation=l}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var o=function(t){function i(){t.call(this);this.name="yvsx";this.id=n.CalcButtonId.BTN_YVSX;this.tooltip="Y versus X of 2 waveforms";this.buttonType=n.OPERATION_TYPE.BINARY_OPERATION;this.buttonLabel="YvsX";this.operationLabel="vs"}return __extends(i,t),i.prototype.createAttributePanel=function(){},i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.getExpression=function(n){return"yvsx"+this.getWaveformExpression(n)},i}(n.WfOperation),t,i,r,u,f,e;n.YvsXOperation=o;t=function(t){function i(){t.call(this);this.numPointsDefault="1024";this.samplingFrequencyDefault="None";this.normResDefault=!1;this.winFunctionIndexDefault=0;this.name="FFT";this.id=n.CalcButtonId.BTN_FFT;this.tooltip="FFT Function";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="FFT";this.operationLabel="FFT";this.useOptions=!0}return __extends(i,t),i.prototype.createAttributePanel=function(t,r){this.numPoints=n.ToolUtils.createInputField(r,"Number of Points:",null);this.numPoints.val(this.numPointsDefault);this.samplingFrequency=n.ToolUtils.createDropDownList(r,"Sampling Frequency:",[n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT]);this.samplingFrequency.select(0);this.normRes=n.ToolUtils.createCheckbox(r,"Normalize Results:","Normalize Results",!1);this.winFunction=n.ToolUtils.createDropDownList(r,"Window Function:",i.winFuncNames);this.winFunction.select(this.winFunctionIndexDefault)},i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.getExpression=function(t){var o=t.arg1.wf,r=this.name.toLowerCase()+"(",u,f,e;return r+=n.ToolUtils.getWfExpression(o)+",",u=this.numPoints==null,r+=(u?this.numPointsDefault:this.numPoints.val())+",",r+=(u?this.samplingFrequencyDefault:this.samplingFrequency.value())+",",f=u?this.normResDefault:this.normRes.is(":checked"),r+=(f?1:0)+",",e=u?this.winFunctionIndexDefault:this.winFunction.select(),r+='"'+i.winFuncNames[e]+'"',r+")"},i.prototype.setDefault=function(){this.numPoints.val(this.numPointsDefault);this.samplingFrequency.select(0);this.normRes.removeAttr("checked");this.winFunction.select(0)},i.prototype.areDefaultOptions=function(){return this.numPoints.val()!=this.numPointsDefault?!1:this.samplingFrequency.select()!=0?!1:this.normRes.prop("checked")?!1:this.winFunction.select()!=0?!1:!0},i.WINF_RECT=0,i.WINF_FLATTOP=1,i.WINF_HAMMING=2,i.WINF_HANNING=3,i.WINF_BARTLETT=4,i.winFuncNames=["Rectangular","FlatTop","Hamming","Hanning","Bartlett"],i}(n.WfOperation);n.FFTOperation=t;i=function(t){function i(){t.call(this);this.numPointsDefault="1024";this.samplingTimeDefault="None";this.normResDefault=!1;this.name="IFFT";this.id=n.CalcButtonId.BTN_IFFT;this.tooltip="IFFT Function";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="IFFT";this.operationLabel="IFFT";this.useOptions=!0}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.createAttributePanel=function(t,i){this.numPoints=n.ToolUtils.createInputField(i,"Number of Points:","This is number of points");this.numPoints.val(this.numPointsDefault);this.samplingTime=n.ToolUtils.createDropDownList(i,"Sampling Time:",[n.ToolWindow.TOOL_TOP_BOTTOM_DEFAULT]);this.samplingTime.select(0);this.normRes=n.ToolUtils.createCheckbox(i,"Normalize Results:","Normalize Results",!1)},i.prototype.getExpression=function(t){var f=t.arg1.wf,i=this.name.toLowerCase()+"(",r,u;return i+=n.ToolUtils.getWfExpression(f)+",",r=this.numPoints==null,i+=(r?this.numPointsDefault:this.numPoints.val())+",",i+=(r?this.samplingTimeDefault:this.samplingTime.value())+",",u=r?this.normResDefault:this.normRes.is(":checked"),i+=u?1:0,i+")"},i.prototype.setDefault=function(){this.numPoints.val(this.numPointsDefault);this.samplingTime.select(0);this.normRes.removeAttr("checked")},i.prototype.areDefaultOptions=function(){return this.numPoints.val()!=this.numPointsDefault?!1:this.samplingTime.select()!=0?!1:this.normRes.prop("checked")?!1:!0},i}(n.WfOperation);n.IFFTOperation=i;r=function(t){function i(){t.call(this);this.highLevelDefault=5;this.lowLevelDefault=0;this.risetimeDefault=1e-6;this.falltimeDefault=1e-6;this.name="dtoa";this.id=n.CalcButtonId.BTN_DTOA;this.tooltip="Transform Bit, Boolean or std_logic waveform to analog";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="DtoA";this.operationLabel="DtoA";this.useOptions=!0}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.createAttributePanel=function(t,i){this.highLevelInput=n.ToolUtils.createInputField(i,"High Level:",n.ToolTooltips.DTOA_HIGH_LEVEL);n.ToolUtils.addValidateInputListener(this.highLevelInput,t);this.lowLevelInput=n.ToolUtils.createInputField(i,"Low Level:",n.ToolTooltips.DTOA_LOW_LEVEL);n.ToolUtils.addValidateInputListener(this.lowLevelInput,t);this.risetimeInput=n.ToolUtils.createInputField(i,"Risetime:",n.ToolTooltips.DTOA_RISETIME);n.ToolUtils.addValidateInputListener(this.risetimeInput,t);this.falltimeInput=n.ToolUtils.createInputField(i,"Falltime:",n.ToolTooltips.DTOA_FALLTIME);n.ToolUtils.addValidateInputListener(this.falltimeInput,t);this.setDefault()},i.prototype.getLowLevel=function(){if(!this.lowLevelInput)return this.lowLevelDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.lowLevelInput.val())},i.prototype.getHighLevel=function(){if(!this.highLevelInput)return this.highLevelDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.highLevelInput.val())},i.prototype.getRisetime=function(){if(!this.risetimeInput)return this.risetimeDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.risetimeInput.val())},i.prototype.getFalltime=function(){if(!this.falltimeInput)return this.falltimeDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.falltimeInput.val())},i.prototype.getExpression=function(t){var r=t.arg1.wf,i=this.name.toLowerCase()+"(";return i+=n.ToolUtils.getWfExpression(r)+",",i+=this.getLowLevel()+",",i+=this.getHighLevel()+",",i+=this.getRisetime()+",",i+=this.getFalltime(),i+")"},i.prototype.setDefault=function(){this.highLevelInput.val(this.highLevelDefault);this.lowLevelInput.val(this.lowLevelDefault);this.risetimeInput.val(this.risetimeDefault.toExponential(1));this.falltimeInput.val(this.falltimeDefault.toExponential(1))},i.prototype.areDefaultOptions=function(){return n.ToolUtils.getInputError(this.lowLevelInput)?!1:n.ToolUtils.getInputError(this.highLevelInput)?!1:n.ToolUtils.getInputError(this.risetimeInput)?!1:n.ToolUtils.getInputError(this.falltimeInput)?!1:this.getLowLevel()!=this.lowLevelDefault?!1:this.getHighLevel()!=this.highLevelDefault?!1:this.getRisetime()!=this.risetimeDefault?!1:this.getFalltime()!=this.falltimeDefault?!1:!0},i.prototype.validate=function(t){var e=t.arg1.wf,i,r,u,f;return e.isDigitalToAnalogConvertible()?!this.lowLevelInput||!this.highLevelInput?null:!this.risetimeInput||!this.falltimeInput?null:(i=n.ToolUtils.getInputError(this.lowLevelInput),i)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+i,"Low Level"):(r=n.ToolUtils.getInputError(this.highLevelInput),r)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+i,"High Level"):(u=this.getLowLevel(),f=this.getHighLevel(),f<u)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_LESS,"High Level","Low Level"):null:n.ToolMessages.UNSUPPORTED_OPERATION},i}(n.WfOperation);n.DtoAOperation=r;u=function(t){function i(){t.call(this);this.highLevelDefault=2.5;this.lowLevelDefault=2.5;this.name="atod";this.id=n.CalcButtonId.BTN_ATOD;this.tooltip="Transform Analog waveform to std_logic";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="AtoD";this.operationLabel="AtoD";this.useOptions=!0}return __extends(i,t),i.prototype.validate=function(t){var e=t.arg1.wf,i,o,r,u,f,s,h;return e.isAnalogToDigitalConvertible()?!this.lowLevelInput||!this.highLevelInput?null:(i=n.ToolUtils.getInputError(this.lowLevelInput),i)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+i,"Low Level"):(o=n.ToolUtils.getInputError(this.highLevelInput),o)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+i,"High Level"):(r=this.getLowLevel(),u=this.getHighLevel(),u<r)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_LESS,"High Level","Low Level"):(f=e.getWholeYRange(),s=f.ymin,r<s)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_BY_Y_MINIMUM,"Low Level"):(h=f.ymax,u>h)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_BY_Y_MAXIMUM,"High Level"):null:n.ToolMessages.UNSUPPORTED_OPERATION},i.prototype.getLowLevel=function(){if(!this.lowLevelInput)return this.lowLevelDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.lowLevelInput.val())},i.prototype.getHighLevel=function(){if(!this.highLevelInput)return this.highLevelDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.highLevelInput.val())},i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.createAttributePanel=function(t,i){this.highLevelInput=n.ToolUtils.createInputField(i,"High Level:",n.ToolTooltips.ATOD_HIGH_LEVEL);n.ToolUtils.addValidateInputListener(this.highLevelInput,t);this.lowLevelInput=n.ToolUtils.createInputField(i,"Low Level:",n.ToolTooltips.ATOD_LOW_LEVEL);n.ToolUtils.addValidateInputListener(this.lowLevelInput,t);this.setDefault();t.toolCombo.validate()},i.prototype.getExpression=function(t){var r=t.arg1.wf,i=this.name.toLowerCase()+"(";return i+=n.ToolUtils.getWfExpression(r)+",",i+=this.getLowLevel()+",",i+=this.getHighLevel(),i+")"},i.prototype.setDefault=function(){this.highLevelInput.val(this.highLevelDefault);this.lowLevelInput.val(this.lowLevelDefault)},i.prototype.areDefaultOptions=function(){return n.ToolUtils.getInputError(this.lowLevelInput)?!1:n.ToolUtils.getInputError(this.highLevelInput)?!1:this.getLowLevel()!=this.lowLevelDefault?!1:this.getHighLevel()!=this.highLevelDefault?!1:!0},i}(n.WfOperation);n.AtoDOperation=u;f=function(t){function i(){t.call(this);this.xStartDefault=0;this.xStopDefault=1;this.name="xlimit";this.id=n.CalcButtonId.BTN_XLIMIT;this.tooltip="Limit x range of a waveform";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="XLimit";this.operationLabel="XLimit";this.useOptions=!0}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.validate=function(t){var i=t.arg1.wf,r,u,f,e,o,s;return i.isBus()?n.ToolMessages.UNSUPPORTED_OPERATION:!this.xStartInput||!this.xStopInput?null:(r=n.ToolUtils.getInputError(this.xStartInput),r)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+r,"X Start"):(u=n.ToolUtils.getInputError(this.xStopInput),u)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+u,"X Stop"):(f=this.getStart(),e=this.getStop(),e<=f)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_LESS,"X Stop","X Start"):(o=i.getXWaveformMin(),f<o)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_BY_X_MINIMUM,"X Start"):(s=i.getXWaveformMax(),e>s)?n.ToolMessages.getMessage(n.ToolMessages.INVALID_BY_X_MAXIMUM,"X Stop"):null},i.prototype.createAttributePanel=function(t,i){this.xStartInput=n.ToolUtils.createInputField(i,"X Start:",n.ToolTooltips.XLIMIT_START);n.ToolUtils.addValidateInputListener(this.xStartInput,t);this.xStopInput=n.ToolUtils.createInputField(i,"X Stop:",n.ToolTooltips.XLIMIT_STOP);n.ToolUtils.addValidateInputListener(this.xStopInput,t);this.setDefault();t.toolCombo.validate()},i.prototype.getStart=function(){if(!this.xStartInput)return this.xStartDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.xStartInput.val())},i.prototype.getStop=function(){if(!this.xStopInput)return this.xStopDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.xStopInput.val())},i.prototype.getExpression=function(t){var r=t.arg1.wf,i=this.name.toLowerCase()+"(";return i+=n.ToolUtils.getWfExpression(r)+",",i+=this.getStart()+",",i+=this.getStop(),i+")"},i.prototype.setDefault=function(){this.xStartInput.val(this.xStartDefault);this.xStopInput.val(this.xStopDefault)},i.prototype.areDefaultOptions=function(){return n.ToolUtils.getInputError(this.xStartInput)?!1:n.ToolUtils.getInputError(this.xStopInput)?!1:this.getStart()!=this.xStartDefault?!1:this.getStop()!=this.xStopDefault?!1:!0},i}(n.WfOperation);n.XLimitOperation=f;e=function(t){function i(){t.call(this);this.winWidthLabel="Window Width";this.winWidthDefault=1;this.positionDefault="EndOfWindow";this.name="winave";this.id=n.CalcButtonId.BTN_WINAVE;this.tooltip="Compute the average over the waveform using a sliding window";this.buttonType=n.OPERATION_TYPE.UNARY_OPERATION;this.buttonLabel="WinAve";this.operationLabel="WinAve";this.useOptions=!0}return __extends(i,t),i.prototype.getCategories=function(){var t=[];return t.push(n.ToolUtils.getCategory(n.Category.CAT_TRANS)),t},i.prototype.validate=function(t){var i=t.arg1.wf,r,u;if(!i.isAnalogOrStep())return n.ToolMessages.UNSUPPORTED_OPERATION;if(!this.winWidthInput)return null;if(r=n.ToolUtils.getInputError(this.winWidthInput),r)return n.ToolMessages.getMessage(n.ToolMessages.INVALID_OPERATION+r,this.winWidthLabel);if(u=this.getWinWidth(),u<=0)return n.ToolMessages.getMessage(n.ToolMessages.INVALID_POSITIVE,this.winWidthLabel);var f=i.getXWaveformMin(),e=i.getXWaveformMax(),o=Math.abs(e-f);return o<=u?n.ToolMessages.getMessage(n.ToolMessages.INVALID_GREATER,this.winWidthLabel,"X range"):null},i.prototype.createAttributePanel=function(t,i){this.winWidthInput=n.ToolUtils.createInputField(i,this.winWidthLabel+":","The width of the window over which the waveform will be averaged");n.ToolUtils.addValidateInputListener(this.winWidthInput,t);this.setDefault();t.toolCombo.validate()},i.prototype.getWinWidth=function(){if(!this.winWidthInput)return this.winWidthDefault;var n=new Project.PropertyFormatter;return n.SIUnitPrefixes2Double(this.winWidthInput.val())},i.prototype.getWinPosition=function(){return this.positionDefault},i.prototype.getExpression=function(t){var r=t.arg1.wf,i=this.name.toLowerCase()+"(";return i+=n.ToolUtils.getWfExpression(r)+",",i+=this.getWinWidth()+",",i+='"'+this.getWinPosition()+'"',i+")"},i.prototype.setDefault=function(){this.winWidthInput.val(this.winWidthDefault)},i.prototype.areDefaultOptions=function(){return n.ToolUtils.getInputError(this.winWidthInput)?!1:this.getWinWidth()!=this.winWidthDefault?!1:!0},i}(n.WfOperation);n.WinAveOperation=e}(Operations||(Operations={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var e,u,o,t,r,i,f,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt;(function(n){n[n.SINGLE=0]="SINGLE";n[n.FIRST=1]="FIRST";n[n.MIDDLE=2]="MIDDLE";n[n.LAST=3]="LAST"})(n.COMMAND_STEP||(n.COMMAND_STEP={}));e=n.COMMAND_STEP;u=function(){function t(n,t){this.step=e.SINGLE;this.design=n;t&&(this.step=t)}return t.prototype.calcEndState=function(){},t.prototype.addToStartState=function(){},t.prototype.redoCommand=function(){},t.prototype.undoCommand=function(){},t.prototype.cancelCommand=function(){},t.prototype.getCommandState=function(){return this.commandState},t.prototype.restoreCommandState=function(n,t){this.design=n;this.commandState=t},t.prototype.getCommandClassName=function(){return n.Utility.getClassName(this)},t.prototype.getCommandName=function(){return this.commandName},t.prototype.getStep=function(){return this.step},t.prototype.setStep=function(n){this.step=n},t.prototype.setCommandName=function(n){this.commandName=n},t.resetCommandIndex=function(){t.GLOBAL_COMMAND_INDEX=0},t.prototype.restoreComponent=function(t,i){var r=new n.Component(this.design,t,i.instName,i.instNameVisibility);return r.restore(i),r},t.MODULE_NAME="Project",t.GLOBAL_COMMAND_INDEX=0,t}();n.Command=u;o=function(t){function i(){t.apply(this,arguments)}return __extends(i,t),i.prototype.saveCompState=function(n,t){var i=new f;return n&&(i.dbComp=n.getDbComp(),i.saveData=n.getSaveData(),i.instName=i.saveData.instName,this.addCompState(i,t)),i},i.prototype.getCompState=function(t,i){return i==n.STATE_TYPE.START?this.getCompStartState(t):this.getCompEndState(t)},i.prototype.addCompState=function(t,i){i==n.STATE_TYPE.START?this.commandState.compStartStates.push(t):this.commandState.compEndStates.push(t)},i.prototype.getCompStartState=function(n){return this.commandState.compStartStates&&n<this.commandState.compStartStates.length?this.commandState.compStartStates[n]:null},i.prototype.getCompEndState=function(n){return this.commandState.compEndStates&&n<this.commandState.compEndStates.length?this.commandState.compEndStates[n]:null},i.prototype.getCompStartStateLength=function(){return this.commandState.compStartStates?this.commandState.compStartStates.length:0},i.prototype.getCompEndStateLength=function(){return this.commandState.compEndStates?this.commandState.compEndStates.length:0},i.prototype.getInstName=function(n,t){var i=this.getCompState(n,t);return i?i.instName:null},i}(u);n.ComponentCommand=o;t=function(){function n(){}return n}();n.CommandState=t;r=function(n){function t(){n.apply(this,arguments);this.compStartStates=[];this.compEndStates=[]}return __extends(t,n),t}(t);n.ComponentCommandState=r;i=function(n){function t(){n.apply(this,arguments);this.netStartStates=[];this.netEndStates=[];this.wireStartStates=[];this.wireEndStates=[];this.connStartStates=[];this.connEndStates=[];this.waveboxStartStates=[];this.waveboxEndStates=[]}return __extends(t,n),t}(r);n.ConnectionCommandState=i;f=function(){function n(){}return n}();n.ComponentDescription=f;s=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.DisconnectComponentCommandState=s;h=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.MoveComponentCommandState=h;c=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.XMirrorCommandState=c;l=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.YMirrorCommandState=l;a=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(r);n.AddComponentCommandState=a;v=function(n){function t(){n.apply(this,arguments);this.wireUniqNames=[]}return __extends(t,n),t}(t);n.NetCommandState=v;y=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.UpdateSimEndTimeCommandState=y;p=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.UpdateFreqSimCommandState=p;w=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.UpdateAdvancedOptionsCommandState=w;b=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(i);n.RotateCommandState=b;k=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.UpdatePropertyCommandState=k;d=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.RenameComponentCommandState=d;g=function(n){function t(){n.apply(this,arguments);this.wireUniqNames=[]}return __extends(t,n),t}(t);n.MergeNetsCommandState=g;nt=function(n){function t(){n.apply(this,arguments);this.probeIndex=0;this.wfId=""}return __extends(t,n),t}(t);n.ProbeCommandState1=nt;tt=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.WaveboxCommandState=tt;it=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.ComponentNametagCommandState=it;rt=function(n){function t(){n.apply(this,arguments)}return __extends(t,n),t}(t);n.WireNametagCommandState=rt}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){(function(n){n[n.START=0]="START";n[n.END=1]="END";n[n.NONE=2]="NONE"})(n.STATE_TYPE||(n.STATE_TYPE={}));var t=n.STATE_TYPE,i=function(i){function r(n,t){i.call(this,n,t)}return __extends(r,i),r.prototype.saveNetState=function(n,t){var r=this.getNetStates(t),i;if(n){for(i=0;i<r.length;++i)if(n.getName()==r[i].name)return;r.push(n.getSaveData())}},r.prototype.saveWireState=function(t,i){var f=!1,e=this.getWireStates(i),r,u;if(t&&!n.Utility.uniqNameInArray(t.getUniqName(),e)){if(r=t.getSaveData(),!r)return!1;u=t.getNet();u&&(r.netName=u.getName());e.push(r);f=!0}return f},r.prototype.saveConnState=function(t,i){var r=this.getConnStates(i);t&&!n.Utility.uniqNameInArray(t.getUniqName(),r)&&r.push(t.getSaveData())},r.prototype.saveComponentConnStates=function(n,i,r,u){var s,e,f,o;for(u===void 0&&(u=t.NONE),s=n.getPins(),e=0;e<s.length;++e)f=s[e].getConnection(),f&&f.getWire()&&(this.saveConnState(f,i),o=f.getWire(),u!=t.NONE&&this.saveNetState(o.getNet(),u),this.saveWireState(o,r),this.saveWireConnStates(o,i))},r.prototype.saveWireConnStates=function(n,t){for(var u,f,r=n.getSegments(),i=0;i<r.length;++i)u=r[i].getConnection(1),this.saveConnState(u,t),f=r[i].getConnection(2),this.saveConnState(f,t)},r.prototype.removeWires=function(n,t){var i,f,r,u,e;if(n)for(i=0;i<n.length;++i){for(f=!1,r=0;r<t.length;++r)if(n[i].uniqName==t[r].uniqName&&n[i].netName==t[r].netName){f=!0;break}f||(u=this.design.findObjectByUniqName(n[i].uniqName),e=u.getNet(),u&&u.remove(),e.removeIfEmpty())}},r.prototype.findNetState=function(n,t){if(!t)return null;for(var i=0;i<t.length;++i)if(n==t[i].name)return t[i];return null},r.prototype.restoreNet=function(n,t,i){var r=this.design.findNetByName(n),u;r||(u=this.findNetState(n,t),u&&(r=new BaseWire.Net(this.design,u,!1)));r&&!r.existsInDesign()&&r.addToDesign();r&&!r.containsWire(i)&&r.addWire(i);r&&r.buildNametags()},r.prototype.restoreWires=function(n,i){var f,e,u,o,r;for(i===void 0&&(i=null),n==t.START?(e=this.getWireStates(t.START),u=this.getWireStates(t.END)):(e=this.getWireStates(t.END),u=this.getWireStates(t.START)),i!=null&&(o=this.getNetStates(i)),this.removeWires(e,u),r=0;r<u.length;++r)f=this.design.findObjectByUniqName(u[r].uniqName),f&&f.restore(u[r]);for(r=0;r<u.length;++r)f=this.design.findObjectByUniqName(u[r].uniqName),f||(f=new BaseWire.Wire(this.design,u[r])),u[r].netName?this.restoreNet(u[r].netName,o,f):f.getNet()||new BaseWire.Net(this.design,f)},r.prototype.restoreConnections=function(n,t){var u,f,i,r;if(u=this.getConnStates(n),f=this.getConnStates(t),u)for(i=0;i<u.length;++i)r=this.design.findObjectByUniqName(u[i].uniqName),r&&(r.remove(),r.removeFromDesign());if(this.design.getConnMgr().clear(),f)for(i=0;i<f.length;++i)r=new BaseWire.Connection(this.design,f[i]),this.design.getConnMgr().manage(r);this.design.getConnMgr().finalize()},r.prototype.getNetStates=function(n){return n==t.START?this.commandState.netStartStates:this.commandState.netEndStates},r.prototype.getNetStartStateLength=function(){return this.commandState.netStartStates?this.commandState.netStartStates.length:0},r.prototype.getNetEndStateLength=function(){return this.commandState.netEndStates?this.commandState.netEndStates.length:0},r.prototype.getNetState=function(n,i){return i==t.START?this.getNetStartState(n):this.getNetEndState(n)},r.prototype.getNetStartState=function(n){return this.commandState.netStartStates&&n<this.commandState.netStartStates.length?this.commandState.netStartStates[n]:null},r.prototype.getNetEndState=function(n){return this.commandState.netEndStates&&n<this.commandState.netEndStates.length?this.commandState.netEndStates[n]:null},r.prototype.getWireStates=function(n){return n==t.START?this.commandState.wireStartStates:this.commandState.wireEndStates},r.prototype.getWireStartStateLength=function(){return this.commandState.wireStartStates?this.commandState.wireStartStates.length:0},r.prototype.getWireStartState=function(n){return this.commandState.wireStartStates&&n<this.commandState.wireStartStates.length?this.commandState.wireStartStates[n]:null},r.prototype.getConnStates=function(n){return n==t.START?this.commandState.connStartStates:n==t.END?this.commandState.connEndStates:null},r.prototype.getWaveboxStates=function(n){return n==t.START?this.commandState.waveboxStartStates:this.commandState.waveboxEndStates},r.prototype.saveWaveboxStates=function(n,i){return(i===void 0&&(i=[]),n==t.START)?this.saveWaveboxStartState(i):n==t.END?this.saveWaveboxEndState():!1},r.prototype.saveWaveboxEndState=function(){var u=this.getWaveboxStates(t.START),f=this.getWaveboxStates(t.END),n,o,e,i,r;for(n in u)o=u[n],e=f[n],e||(i=this.design.findObjectByUniqName(n),i&&(r=i.getSaveData(!0),r&&(f[n]=r)));return!1},r.prototype.saveWaveboxStartState=function(n){for(var r,u=!1,f=this.getWaveboxStates(t.START),i=0;i<n.length;i++){if(r=n[i].getSaveData(!0),!r)return!1;f[n[i].getUniqName()]=r;u=!0}return u},r.prototype.getAllWaveboxNames=function(){var r=[],f=this.getWaveboxStates(t.START),e=this.getWaveboxStates(t.END),i,u;for(i in f)u=f[i],u&&!n.Utility.uniqNameInArray(i,r)&&r.push(i);for(i in e)u=e[i],u&&!n.Utility.uniqNameInArray(i,r)&&r.push(i);return r},r.prototype.restoreWaveboxes=function(n){var e,o,s,f,i;for(n==t.START?(e=this.getWaveboxStates(t.START),o=this.getWaveboxStates(t.END)):(e=this.getWaveboxStates(t.END),o=this.getWaveboxStates(t.START)),s=this.getAllWaveboxNames(),f=0;f<s.length;f++){var r=s[f],h=e[r],u=o[r];h&&u?(i=this.design.findObjectByUniqName(r),i&&i.restore(u,!0)):u&&!h?(i=new ProbeModule.WaveBox(this.design,!0,r),i&&i.restore(u,!0)):!u&&h&&(i=this.design.findObjectByUniqName(r),i&&i.remove(!0))}},r}(n.ComponentCommand);n.ConnectionCommand=i}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r,u){if(t.call(this,i),r instanceof ProbeModule.WaveBox){this.commandState=new n.WaveboxCommandState;var f=r;this.commandState.instName=f.getUniqName();this.setStartState(f);this.setCommandName(u)}else this.restoreCommandState(i,r),this.setCommandName(u+" "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName)}return __extends(i,t),i.prototype.setStartState=function(n){n&&(this.commandState.startState=n.getSaveData(!0))},i.prototype.calcEndState=function(n){n&&(this.commandState.endState=n.getSaveData(!0))},i.prototype.redoCommand=function(){var n=this.design.findObjectByUniqName(this.commandState.instName);n&&this.commandState.endState&&n.restore(this.commandState.endState,!0)},i.prototype.undoCommand=function(){var n=this.design.findObjectByUniqName(this.commandState.instName);n&&this.commandState.startState&&n.restore(this.commandState.startState,!0)},i}(n.Command);n.WaveboxStateCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r,u){t.call(this,i,u);r?(this.restoreCommandState(i,r),this.setCommandName("Add Component "+n.Command.GLOBAL_COMMAND_INDEX+++this.commandState.instName)):this.commandState=new n.AddComponentCommandState}return __extends(i,t),i.prototype.calcEndState=function(t){if(t){var i=this.saveCompState(t,n.STATE_TYPE.END);this.setCommandName("Add Component "+i.instName);this.commandState.instName=i.instName}},i.prototype.redoCommand=function(){var n=this.getCompEndState(0);this.restoreComponent(n.dbComp,n.saveData)},i.prototype.undoCommand=function(){var t=this.getCompEndState(0),n=this.design.findCompByInstName(t.instName);n&&(this.design.getSelectionManager().clearSelection(),n.remove())},i}(n.ComponentCommand);n.AddComponentCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){t.call(this,i);r?(this.restoreCommandState(i,r),this.setCommandName("Add Net "+n.Command.GLOBAL_COMMAND_INDEX+++" "+this.commandState.uniqName)):(this.commandState=new n.ConnectionCommandState,this.setCommandName("Add Net"))}return __extends(i,t),i.prototype.calcEndState=function(t){if(t instanceof BaseWire.Wire){var i=t;this.commandState.uniqName=i.getUniqName();this.saveWireState(i,n.STATE_TYPE.END);this.saveWireConnStates(i,n.STATE_TYPE.END)}},i.prototype.redoCommand=function(){new BaseWire.Net(this.design,this.getNetEndState(0));this.restoreConnections(n.STATE_TYPE.NONE,n.STATE_TYPE.END)},i.prototype.undoCommand=function(){var t=this.design.findObjectByUniqName(this.commandState.uniqName);t&&(this.getNetEndStateLength()==0&&this.saveNetState(t.getNet(),n.STATE_TYPE.END),t.remove(),this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.NONE))},i}(n.ConnectionCommand);n.AddNetCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof BaseWire.Wire){this.commandState=new n.ConnectionCommandState;var u=r;this.commandState.uniqName=u.getUniqName();this.setStartState(u);this.setCommandName("Add Wire Segment")}else this.restoreCommandState(i,r),this.setCommandName("Add Wire Segment "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.uniqName)}return __extends(i,t),i.prototype.setStartState=function(n){this.addToStartState(n)},i.prototype.addToStartState=function(t){var i,r;t instanceof BaseWire.Wire?(i=t,this.saveNetState(i.getNet(),n.STATE_TYPE.START),this.saveWireState(i,n.STATE_TYPE.START)&&this.saveWireConnStates(i,n.STATE_TYPE.START)):t instanceof BaseWire.Net&&(r=t,this.saveNetState(r,n.STATE_TYPE.START),this.getWireStartStateLength()==1&&(this.getWireStartState(0).netName=r.getName()))},i.prototype.calcEndState=function(t){if(t instanceof BaseWire.Wire){var i=t;this.commandState.uniqName=i.getUniqName();this.saveWireState(i,n.STATE_TYPE.END);this.saveWireConnStates(i,n.STATE_TYPE.END)}},i.prototype.redoCommand=function(){this.restoreWires(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreConnections(n.STATE_TYPE.START,n.STATE_TYPE.END)},i.prototype.undoCommand=function(){var t=this.design.findObjectByUniqName(this.commandState.uniqName);this.getNetEndStateLength()==0&&this.saveNetState(t.getNet(),n.STATE_TYPE.END);this.restoreWires(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.START)},i}(n.ConnectionCommand);n.AddWireSegmentCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){t.call(this,i);r?(this.restoreCommandState(i,r),this.setCommandName("Delete Selection "+n.Command.GLOBAL_COMMAND_INDEX++)):(this.commandState=new n.ConnectionCommandState,this.setStartState(),this.setCommandName("Delete Selection"))}return __extends(i,t),i.prototype.setStartState=function(){for(var t,r,o,i,e=this.design.getSelectionManager().getSelectedSet(),u=[],f=0;f<e.length;f++)t=e[f],t instanceof n.Component?(r=t,this.saveCompState(r,n.STATE_TYPE.START),this.saveComponentConnStates(r,n.STATE_TYPE.START,n.STATE_TYPE.START),r.getWaveboxes(u)):t instanceof BaseWire.WireSegment&&(o=t,i=o.getWire(),this.saveNetState(i.getNet(),n.STATE_TYPE.START),this.saveWireState(i,n.STATE_TYPE.START),this.saveWireConnStates(i,n.STATE_TYPE.START),i.getWaveboxes(u));this.saveWaveboxStates(n.STATE_TYPE.START,u)},i.prototype.calcEndState=function(){for(var u,r,f,t,i=0;i<this.getWireStartStateLength();++i)for(u=this.getWireStartState(i),r=0;r<u.wireSegments.length;++r)f=this.design.findObjectByUniqName(u.wireSegments[r].uniqName),f&&(t=f.getWire(),t&&(this.saveNetState(t.getNet(),n.STATE_TYPE.END),this.saveWireState(t,n.STATE_TYPE.END),this.saveWireConnStates(t,n.STATE_TYPE.END)));this.saveWaveboxStates(n.STATE_TYPE.END)},i.prototype.redoCommand=function(){for(var i,t=0;t<this.getCompStartStateLength();++t)i=this.design.findCompByInstName(this.getInstName(t,n.STATE_TYPE.START)),i.remove();this.restoreWires(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreConnections(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreWaveboxes(n.STATE_TYPE.START)},i.prototype.undoCommand=function(){for(var i,t=0;t<this.getCompStartStateLength();++t)i=this.getCompState(t,n.STATE_TYPE.START),this.restoreComponent(i.dbComp,i.saveData);this.restoreWires(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreWaveboxes(n.STATE_TYPE.END)},i}(n.ConnectionCommand);n.DeleteSelectionCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r,u,f){if(t.call(this,i,u),r instanceof n.Component){this.commandState=new n.DisconnectComponentCommandState;var e=r;this.commandState.instName=e.getInstName();this.setCommandName(f);this.setStartState(e)}else this.restoreCommandState(i,r),this.setCommandName(f+" "+n.Command.GLOBAL_COMMAND_INDEX++)}return __extends(i,t),i.prototype.setStartState=function(t){this.saveComponentConnStates(t,n.STATE_TYPE.START,n.STATE_TYPE.START,n.STATE_TYPE.START)},i.prototype.calcEndState=function(){for(var u,r,f,t,i=0;i<this.getWireStartStateLength();++i)for(u=this.getWireStartState(i),r=0;r<u.wireSegments.length;++r)f=this.design.findObjectByUniqName(u.wireSegments[r].uniqName),f&&(t=f.getWire(),t&&(this.saveNetState(t.getNet(),n.STATE_TYPE.END),this.saveWireState(t,n.STATE_TYPE.END),this.saveWireConnStates(t,n.STATE_TYPE.END)))},i.prototype.redoCommand=function(){var t=this.design.findCompByInstName(this.commandState.instName);this.restoreWires(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreConnections(n.STATE_TYPE.START,n.STATE_TYPE.END)},i.prototype.undoCommand=function(){var t=this.design.findCompByInstName(this.commandState.instName);this.restoreWires(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.START)},i}(n.ConnectionCommand);n.DisconnectComponentCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof BaseWire.Wire){this.commandState=new n.MergeNetsCommandState;var u=r;this.setStartState(u);this.setCommandName("Merge Nets")}else this.restoreCommandState(i,r),this.setCommandName("Merge Nets "+n.Command.GLOBAL_COMMAND_INDEX++)}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.wireUniqNames.push(n.getUniqName());this.commandState.oldName=BaseWire.BusName.parse(n.getNet().getName())},i.prototype.addToStartState=function(n){this.commandState.wireUniqNames.push(n.getUniqName())},i.prototype.calcEndState=function(n){this.commandState.newName=typeof n=="string"?BaseWire.BusName.parse(n):n},i.prototype.redoCommand=function(){for(var t,i,r=this.design.findNetByName(this.commandState.newName.getPrefix()),n=0;n<this.commandState.wireUniqNames.length;++n)t=this.design.findObjectByUniqName(this.commandState.wireUniqNames[n]),i=t.getNet(),i.setBusBitIndices(t,this.commandState.newName);r.merge(i)},i.prototype.undoCommand=function(){for(var t,i=this.design.findNetByName(this.commandState.newName.getPrefix()),n=0;n<this.commandState.wireUniqNames.length;++n)t=this.design.findObjectByUniqName(this.commandState.wireUniqNames[n]),i.setBusBitIndices(t,this.commandState.oldName),i.split(t,this.commandState.oldName.getPrefix())},i}(n.Command);n.MergeNetsCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof BaseWire.Wire){this.commandState=new n.ConnectionCommandState;var u=r;this.commandState.uniqName=u.getUniqName();this.setStartState(u);this.setCommandName("Modify Wire")}else this.restoreCommandState(i,r),this.setCommandName("Modify Wire "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.uniqName)}return __extends(i,t),i.prototype.setStartState=function(t){this.saveWireState(t,n.STATE_TYPE.START);this.saveWireConnStates(t,n.STATE_TYPE.START)},i.prototype.addToStartState=function(t){this.saveNetState(t.getNet(),n.STATE_TYPE.START);this.saveWireState(t,n.STATE_TYPE.START)&&this.saveWireConnStates(t,n.STATE_TYPE.START)},i.prototype.calcEndState=function(){var t=this.design.findObjectByUniqName(this.commandState.uniqName);this.saveWireState(t,n.STATE_TYPE.END);this.saveWireConnStates(t,n.STATE_TYPE.END)},i.prototype.redoCommand=function(){this.restoreWires(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreConnections(n.STATE_TYPE.START,n.STATE_TYPE.END)},i.prototype.undoCommand=function(){this.restoreWires(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.START)},i}(n.ConnectionCommand);n.ModifyWireCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r,u){if(t.call(this,i,u),r instanceof n.Component){this.commandState=new n.MoveComponentCommandState;var f=r;this.setStartState(f)}else this.restoreCommandState(i,r),this.setCommandName("Move "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+r.instName)}return __extends(i,t),i.prototype.setStartState=function(t){if(t){var i=this.saveCompState(t,n.STATE_TYPE.START);this.commandState.instName=i.saveData.instName;this.setCommandName("Move "+i.saveData.instName)}this.saveComponentConnStates(t,n.STATE_TYPE.START,n.STATE_TYPE.START,n.STATE_TYPE.START)},i.prototype.addToStartState=function(t){if(t instanceof BaseWire.Wire){var i=t;this.saveNetState(i.getNet(),n.STATE_TYPE.START);this.saveWireState(i,n.STATE_TYPE.START)&&this.saveWireConnStates(i,n.STATE_TYPE.START)}},i.prototype.calcEndState=function(){var t=this.design.findCompByInstName(this.commandState.instName);t&&(this.saveCompState(t,n.STATE_TYPE.END),this.saveComponentConnStates(t,n.STATE_TYPE.END,n.STATE_TYPE.END,n.STATE_TYPE.END))},i.prototype.redoCommand=function(){var i=this.design.findCompByInstName(this.commandState.instName),t;i&&(t=this.getCompEndState(0),i.moveTo(t.saveData.cx,t.saveData.cy));this.restoreWires(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreConnections(n.STATE_TYPE.START,n.STATE_TYPE.END)},i.prototype.undoCommand=function(){var i=this.design.findCompByInstName(this.commandState.instName),t;i&&(t=this.getCompStartState(0),i.moveTo(t.saveData.cx,t.saveData.cy));this.restoreWires(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.START)},i}(n.ConnectionCommand);n.MoveComponentCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof n.Component){this.commandState=new n.ComponentNametagCommandState;var u=r;this.commandState.instName=u.getInstName();this.setStartState(u.getNametag());this.setCommandName("Move Component Label")}else this.restoreCommandState(i,r),this.setCommandName("Move Component Label "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName)}return __extends(i,t),i.prototype.setStartState=function(n){n&&(this.commandState.startState=n.getSaveData())},i.prototype.calcEndState=function(n){this.commandState.endState=n.getSaveData()},i.prototype.redoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&this.commandState.endState&&(n.getNametag().restore(this.commandState.endState),n.buildNametag())},i.prototype.undoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&this.commandState.startState&&(n.getNametag().restore(this.commandState.startState),n.buildNametag())},i}(n.Command);n.MoveComponentNametagCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){t.call(this,i);r?(this.restoreCommandState(i,r),this.setCommandName("Move Selection "+n.Command.GLOBAL_COMMAND_INDEX++)):(this.commandState=new n.ConnectionCommandState,this.setStartState(),this.setCommandName("Move Selection"))}return __extends(i,t),i.prototype.setStartState=function(){for(var t,u,e,i,f=this.design.getSelectionManager().getSelectedSet(),r=0;r<f.length;r++)t=f[r],t instanceof n.Component?(u=t,this.saveCompState(u,n.STATE_TYPE.START),this.saveComponentConnStates(u,n.STATE_TYPE.START,n.STATE_TYPE.START)):t instanceof BaseWire.WireSegment&&(e=t,i=e.getWire(),this.saveNetState(i.getNet(),n.STATE_TYPE.START),this.saveWireState(i,n.STATE_TYPE.START),this.saveWireConnStates(i,n.STATE_TYPE.START))},i.prototype.calcEndState=function(){for(var r,u,i,t=0;t<this.getCompStartStateLength();++t)r=this.design.findCompByInstName(this.getInstName(t,n.STATE_TYPE.START)),this.saveCompState(r,n.STATE_TYPE.END);for(t=0;t<this.getWireStartStateLength();++t)u=this.getWireStartState(t),i=this.design.findObjectByUniqName(u.uniqName),i&&(this.saveNetState(i.getNet(),n.STATE_TYPE.END),this.saveWireState(i,n.STATE_TYPE.END),this.saveWireConnStates(i,n.STATE_TYPE.END))},i.prototype.redoCommand=function(){for(var i,r,t=0;t<this.getCompEndStateLength();++t)i=this.getCompEndState(t),r=this.design.findCompByInstName(i.instName),r.moveTo(i.saveData.cx,i.saveData.cy),r.buildConnectedNametags();this.restoreWires(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreConnections(n.STATE_TYPE.START,n.STATE_TYPE.END)},i.prototype.undoCommand=function(){for(var i,r,t=0;t<this.getCompStartStateLength();++t)i=this.getCompStartState(t),r=this.design.findCompByInstName(i.instName),r.moveTo(i.saveData.cx,i.saveData.cy),r.buildConnectedNametags();this.restoreWires(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.START)},i}(n.ConnectionCommand);n.MoveSelectionCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof BaseWire.Wire){this.commandState=new n.WireNametagCommandState;var u=r;this.commandState.wireName=u.getUniqName();this.setStartState(u.getNametag());this.setCommandName("Move Wire Label")}else this.restoreCommandState(i,r),this.setCommandName("Move Wire Label "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.wireName)}return __extends(i,t),i.prototype.setStartState=function(n){n&&(this.commandState.startState=n.getSaveData())},i.prototype.calcEndState=function(n){this.commandState.endState=n.getSaveData()},i.prototype.redoCommand=function(){var n=this.design.findObjectByUniqName(this.commandState.wireName);n&&this.commandState.endState&&(n.getNametag().restore(this.commandState.endState),n.buildNametag())},i.prototype.undoCommand=function(){var n=this.design.findObjectByUniqName(this.commandState.wireName);n&&this.commandState.startState&&(n.getNametag().restore(this.commandState.startState),n.buildNametag())},i}(n.Command);n.MoveWireNametagCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){t.call(this,i);r?(this.restoreCommandState(i,r),this.setCommandName("Paste Selection "+n.Command.GLOBAL_COMMAND_INDEX++)):(this.commandState=new n.ConnectionCommandState,this.setCommandName("Paste Selection"))}return __extends(i,t),i.prototype.addToStartState=function(t){if(t instanceof BaseWire.Wire){var i=t;this.saveNetState(i.getNet(),n.STATE_TYPE.START);this.saveWireState(i,n.STATE_TYPE.START)&&this.saveWireConnStates(i,n.STATE_TYPE.START)}},i.prototype.calcEndState=function(){for(var t,u,e,i,f=this.design.getSelectionManager().getSelectedSet(),r=0;r<f.length;r++)t=f[r],t instanceof n.Component?(u=t,this.saveCompState(u,n.STATE_TYPE.END),this.saveComponentConnStates(u,n.STATE_TYPE.END,n.STATE_TYPE.END,n.STATE_TYPE.END)):t instanceof BaseWire.WireSegment&&(e=t,i=e.getWire(),this.saveNetState(i.getNet(),n.STATE_TYPE.END),this.saveWireState(i,n.STATE_TYPE.END)&&this.saveWireConnStates(i,n.STATE_TYPE.END))},i.prototype.redoCommand=function(){for(var i,t=0;t<this.getCompEndStateLength();++t)i=this.getCompEndState(t),this.restoreComponent(i.dbComp,i.saveData);this.restoreWires(n.STATE_TYPE.START,n.STATE_TYPE.END);this.restoreConnections(n.STATE_TYPE.START,n.STATE_TYPE.END)},i.prototype.undoCommand=function(){for(var i,t=0;t<this.getCompEndStateLength();++t)i=this.design.findCompByInstName(this.getInstName(t,n.STATE_TYPE.END)),i.remove();this.restoreWires(n.STATE_TYPE.END,n.STATE_TYPE.START);this.restoreConnections(n.STATE_TYPE.END,n.STATE_TYPE.START)},i}(n.ConnectionCommand);n.PasteSelectionCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){t.call(this,i);typeof r=="string"?(this.commandState=new n.RenameComponentCommandState,this.commandState.instName=r):(this.restoreCommandState(i,r),this.setCommandName("Rename "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName))}return __extends(i,t),i.prototype.calcEndState=function(n){this.commandState.newInstName=n;this.setCommandName("Rename "+this.commandState.instName+" to "+this.commandState.newInstName)},i.prototype.redoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.setInstName(this.commandState.newInstName)},i.prototype.undoCommand=function(){var n=this.design.findCompByInstName(this.commandState.newInstName);n&&n.setInstName(this.commandState.instName)},i}(n.Command);n.RenameComponentCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i,null),r instanceof BaseWire.Wire){this.commandState=new n.NetCommandState;var u=r;this.setStartState(u)}else this.restoreCommandState(i,r),this.oldName=BaseWire.BusName.parse(this.commandState.oldWireName),this.newName=BaseWire.BusName.parse(this.commandState.newWireName),this.setCommandName("Rename "+this.oldName.getPrefix()+" to "+this.newName.getPrefix())}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.wireUniqNames.push(n.getUniqName());this.oldName=BaseWire.BusName.parse(n.getName());this.commandState.oldWireName=n.getName()},i.prototype.calcEndState=function(n){typeof n=="string"?(this.newName=BaseWire.BusName.parse(n),this.commandState.newWireName=n):n instanceof BaseWire.BusName&&(this.newName=n,this.commandState.newWireName=n.getBaseName());this.setCommandName("Rename "+this.oldName.getPrefix()+" to "+this.newName.getPrefix())},i.prototype.redoCommand=function(){var n=this.design.findNetByName(this.oldName.getPrefix()),t;n&&(n.isBus()||n.hasBits()||this.newName.isBus()||this.newName.isBit()?(t=this.design.findObjectByUniqName(this.commandState.wireUniqNames[0]),n.renameBusBit(this.newName,t)):n.setNamePrefix(this.newName.getPrefix()))},i.prototype.undoCommand=function(){var n=this.design.findNetByName(this.newName.getPrefix()),t;n&&(n.isBus()||n.hasBits()||this.oldName.isBus()||this.oldName.isBit()?(t=this.design.findObjectByUniqName(this.commandState.wireUniqNames[0]),n.renameBusBit(this.oldName,t)):n.setNamePrefix(this.oldName.getPrefix()))},i}(n.Command);n.RenameNetCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(r,u,f){if(t.call(this,r,f),u instanceof n.Component){this.commandState=new n.RotateCommandState;var e=u;this.setStartState(e)}else this.restoreCommandState(r,u),this.setCommandName(i.getCommandNamePrefix()+" "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName)}return __extends(i,t),i.prototype.setStartState=function(t){this.commandState.instName=t.getInstName();this.commandState.rotation=t.getMirror()==n.MIRROR.MIRROR_NONE?n.ROTATION.ROT_90:n.ROTATION.ROT_MINUS90},i.prototype.redoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.rotate(this.commandState.rotation,!1,!1,!1)},i.prototype.undoCommand=function(){var t=this.design.findCompByInstName(this.commandState.instName),i;t&&(i=this.commandState.rotation==n.ROTATION.ROT_90?n.ROTATION.ROT_MINUS90:n.ROTATION.ROT_90,t.rotate(i,!1,!1,!1))},i.getCommandNamePrefix=function(){return"Rotate "},i}(n.ConnectionCommand);n.RotateCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof BaseWire.Wire){this.commandState=new n.NetCommandState;var u=r;this.setStartState(u);this.setCommandName("Split Net")}else this.restoreCommandState(i,r),this.oldName=BaseWire.BusName.parse(this.commandState.oldWireName),this.newName=BaseWire.BusName.parse(this.commandState.newWireName),this.setCommandName("Split Net "+n.Command.GLOBAL_COMMAND_INDEX++)}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.wireUniqNames.push(n.getUniqName());this.oldName=BaseWire.BusName.parse(n.getNet().getName())},i.prototype.addToStartState=function(n){this.commandState.wireUniqNames.push(n.getUniqName())},i.prototype.calcEndState=function(n){this.newName=typeof n=="string"?BaseWire.BusName.parse(n):n},i.prototype.redoCommand=function(){for(var t,i=this.design.findNetByName(this.oldName.getPrefix()),n=0;n<this.commandState.wireUniqNames.length;++n)t=this.design.findObjectByUniqName(this.commandState.wireUniqNames[n]),i.setBusBitIndices(t,this.newName),i.split(t,this.newName.getPrefix())},i.prototype.undoCommand=function(){for(var t,i,r=this.design.findNetByName(this.oldName.getPrefix()),n=0;n<this.commandState.wireUniqNames.length;++n)t=this.design.findObjectByUniqName(this.commandState.wireUniqNames[n]),i=t.getNet(),i.setBusBitIndices(t,this.oldName);r.merge(i)},i}(n.Command);n.SplitNetCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(r,u,f){if(t.call(this,r,f),u instanceof n.Component){this.commandState=new n.XMirrorCommandState;var e=u;this.setStartState(e)}else this.restoreCommandState(r,u),this.setCommandName(i.getCommandNamePrefix()+" "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName)}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.instName=n.getInstName()},i.prototype.redoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.xMirror(!1,!1,!1)},i.prototype.undoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.xMirror(!1,!1,!1)},i.getCommandNamePrefix=function(){return"X Mirror "},i}(n.ConnectionCommand);n.XMirrorCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(r,u,f){if(t.call(this,r,f),u instanceof n.Component){this.commandState=new n.YMirrorCommandState;var e=u;this.setStartState(e)}else this.restoreCommandState(r,u),this.setCommandName(i.getCommandNamePrefix()+" "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName)}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.instName=n.getInstName()},i.prototype.redoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.yMirror(!1,!1,!1)},i.prototype.undoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.yMirror(!1,!1,!1)},i.getCommandNamePrefix=function(){return"Y Mirror "},i}(n.ConnectionCommand);n.YMirrorCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof n.AdvancedOptions){this.commandState=new n.UpdateAdvancedOptionsCommandState;var u=r;this.setStartState(u);this.setCommandName("Update Advanced Options")}else this.restoreCommandState(i,r),this.setCommandName("Update Advanced Options "+n.Command.GLOBAL_COMMAND_INDEX++)}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.oldValue=n.getSaveData()},i.prototype.calcEndState=function(n){this.commandState.newValue=n},i.prototype.redoCommand=function(){var n=this.design.getSurface().getSimulationSidebar().getAdvancedPanel();n.setState(this.commandState.newValue)},i.prototype.undoCommand=function(){var n=this.design.getSurface().getSimulationSidebar().getAdvancedPanel();n.setState(this.commandState.oldValue)},i}(n.Command);n.UpdateAdvancedOptionsCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(){function n(n,t,i){this.instName=n;this.propName=t;this.oldPropValue=i}return n}(),i;n.PropertyData=t;i=function(i){function r(r,u,f){if(i.call(this,r,f),u instanceof t){this.commandState=new n.UpdatePropertyCommandState;var e=u;this.commandState.instName=e.instName;this.setStartState(e)}else this.restoreCommandState(r,u),this.setCommandName("Change "+this.commandState.oldPropValue+" "+this.commandState.propName+" to "+this.commandState.newPropValue)}return __extends(r,i),r.prototype.setStartState=function(n){this.commandState.propName=n.propName;this.commandState.oldPropValue=n.oldPropValue},r.prototype.calcEndState=function(n){this.commandState.newPropValue=n;this.setCommandName("Change "+this.commandState.oldPropValue+" "+this.commandState.propName+" to "+this.commandState.newPropValue)},r.prototype.redoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.setInstProp(this.commandState.propName,this.commandState.newPropValue)},r.prototype.undoCommand=function(){var n=this.design.findCompByInstName(this.commandState.instName);n&&n.setInstProp(this.commandState.propName,this.commandState.oldPropValue)},r}(n.Command);n.UpdatePropertyCommand=i}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof n.TransientSimulation){this.commandState=new n.UpdateSimEndTimeCommandState;var u=r;this.setStartState(u);this.setCommandName("Update Simulation End Time")}else this.restoreCommandState(i,r),this.setCommandName("Update Simulation End Time "+n.Command.GLOBAL_COMMAND_INDEX++)}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.simObj=n;this.commandState.oldPropValue=n.getEndTime()},i.prototype.calcEndState=function(n){this.commandState.newPropValue=n},i.prototype.redoCommand=function(){this.commandState.simObj.setEndTime(this.commandState.newPropValue)},i.prototype.undoCommand=function(){this.commandState.simObj.setEndTime(this.commandState.oldPropValue)},i}(n.Command);n.UpdateSimEndTimeCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof n.FrequencySimulation){this.commandState=new n.UpdateFreqSimCommandState;var u=r;this.setStartState(u);this.setCommandName("Update Frequency-Domain Simulation Settings")}else this.restoreCommandState(i,r),this.setCommandName("Update Frequency-Domain Simulation Settings "+n.Command.GLOBAL_COMMAND_INDEX++)}return __extends(i,t),i.prototype.setStartState=function(n){this.commandState.simObj=n;this.commandState.oldValue=n.getSaveData()},i.prototype.calcEndState=function(n){this.commandState.newValue=n},i.prototype.redoCommand=function(){var n=this.commandState.newValue,t=n.StartingFrequency,i=n.EndingFrequency;this.commandState.simObj.setStartFreq(t);this.commandState.simObj.setEndFreq(i)},i.prototype.undoCommand=function(){var n=this.commandState.oldValue,t=n.StartingFrequency,i=n.EndingFrequency;this.commandState.simObj.setStartFreq(t);this.commandState.simObj.setEndFreq(i)},i}(n.Command);n.UpdateFreqSimCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(n){function t(t,i){n.call(this,t,i,"Add Probe")}return __extends(t,n),t}(n.WaveboxStateCommand);n.AddProbeCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof ProbeModule.WaveBox){this.commandState=new n.WaveboxCommandState;var u=r;this.commandState.instName=u.getUniqName();this.setCommandName("Add Wavebox")}else this.restoreCommandState(i,r),this.setCommandName("Add Wavebox "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName)}return __extends(i,t),i.prototype.calcEndState=function(n){n&&(this.commandState.endState=n.getSaveData(!0))},i.prototype.redoCommand=function(){var n=new ProbeModule.WaveBox(this.design,!0,this.commandState.instName);n&&this.commandState.endState&&n.restore(this.commandState.endState,!0)},i.prototype.undoCommand=function(){var n=this.design.findObjectByUniqName(this.commandState.instName);n&&n.remove(!0)},i}(n.Command);n.AddWaveboxCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i,r){if(t.call(this,i),r instanceof ProbeModule.WaveBox){this.commandState=new n.WaveboxCommandState;var u=r;this.commandState.instName=u.getUniqName();this.setStartState(u);this.setCommandName("Remove Wavebox")}else this.restoreCommandState(i,r),this.setCommandName("Remove Wavebox "+n.Command.GLOBAL_COMMAND_INDEX+++" for "+this.commandState.instName)}return __extends(i,t),i.prototype.setStartState=function(n){n&&(this.commandState.startState=n.getSaveData(!0))},i.prototype.redoCommand=function(){var n=this.design.findObjectByUniqName(this.commandState.instName);n&&n.remove(!0)},i.prototype.undoCommand=function(){var n=new ProbeModule.WaveBox(this.design,!0,this.commandState.instName);n&&n.restore(this.commandState.startState,!0)},i}(n.Command);n.RemoveWaveboxCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(n){function t(t,i){n.call(this,t,i,"Resize Wavebox")}return __extends(t,n),t}(n.WaveboxStateCommand);n.ResizeWaveboxCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(n){function t(t,i){n.call(this,t,i,"Move Probe")}return __extends(t,n),t}(n.WaveboxStateCommand);n.MoveProbeCommand=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(n){function t(t,i){n.call(this,t,i,"Move Wavebox")}return __extends(t,n),t}(n.WaveboxStateCommand);n.MoveWaveboxCommand=t}(Project||(Project={})),function(n){(function(n){n[n.LEFT=0]="LEFT";n[n.RIGHT=1]="RIGHT"})(n.Orientation||(n.Orientation={}));var t=n.Orientation,i=function(){function n(n,t){this.isHidden=!1;this.whichSide=n;this.index=t}return n}(),r=function(){function n(n){this.leftSidebarDivs=[];this.rightSidebarDivs=[];this.slideTime=300;this.isLeftSidebarClosed=!1;this.isRightSidebarClosed=!1;this.defaultBackgroundColor="black";this.defaultBorderColor="black";this.leftButtonSrc="/Content/images/drawer-left-pro.png";this.rightButtonSrc="/Content/images/drawer-right-pro.png";this.topButtonSrc="/Content/images/drawer-top-pro.png";this.bottomButtonSrc="/Content/images/drawer-bottom-pro.png";this.viewer=n;this.leftSelectedIndex=-1;this.rightSelectedIndex=-1;this.namePositionMap=[];this.toggleLeftSidebarDiv=new Project.FadingElement($(TOGGLE_LEFT_SIDEBAR));this.toggleRightSidebarDiv=new Project.FadingElement($(TOGGLE_RIGHT_SIDEBAR));this.toggleViewerDiv=new Project.FadingElement($(TOGGLE_VIEWER));this.defineEvents();$(LEFT_SIDEBAR).show();$(RIGHT_SIDEBAR).show();this.toggleLeftSidebarDiv.getElement().show();this.toggleRightSidebarDiv.getElement().show();this.toggleViewerDiv.getElement().show()}return n.prototype.defineEvents=function(){var n=this,t=this;this.toggleLeftSidebarDiv.defineEvents();this.toggleRightSidebarDiv.defineEvents();this.toggleViewerDiv.defineEvents();this.toggleLeftSidebarDiv.getElement().click(function(){n.toggleLeftSidebarVisibility()});this.toggleRightSidebarDiv.getElement().click(function(){n.toggleRightSidebarVisibility()});this.toggleViewerDiv.getElement().click(function(){var n=$(".k-icon.k-expand-next");n.length?$(".k-icon.k-expand-next").trigger("click"):$(".k-icon.k-collapse-next").trigger("click");t.updateToggleViewer();surface.updateLandingPageButton()})},n.prototype.addSidebar=function(n,i){var u=n.getName(),r=i==t.LEFT?this.leftSidebarDivs:this.rightSidebarDivs,f=r.length;this.addToMap(u,i,f);r.push(n)},n.prototype.updateToggleViewer=function(){var n=$(VIEWER_PANE).height()+6;this.toggleViewerDiv.getElement().css("bottom",n+"px");n>6?$(TOGGLE_VIEWER_IMG).attr("src",this.bottomButtonSrc):$(TOGGLE_VIEWER_IMG).attr("src",this.topButtonSrc)},n.prototype.getSchematicToolbarPosition=function(){var n=$(MAIN_EDITOR).width();return(n-$(SCHEMATIC_TOOLBAR).width())/2},n.prototype.getRightEdgePosition=function(){var n=this.getVisibleWidth(t.RIGHT);return $(window).width()-n-1},n.prototype.resizeComponents=function(n){var r,i,f;n===void 0&&(n=!1);r=$(window).width()-1;$(MAIN_EDITOR).width(r);var u=this.getVisibleWidth(t.LEFT),e=this.getVisibleWidth(t.RIGHT),o=$(window).width()-u-e-1;this.viewer.setWindowWidth(o);$(VIEWER_PANE).css("left",u);i=$(window).height()-1;$(LEFT_SIDEBAR).height(i);surface.getComponentBrowserSidebar().refreshHeight();$(RIGHT_SIDEBAR).height(i);$(RIGHT_SIDEBAR).children().first().height(i);$(MAIN_EDITOR).height(i);f=this.getSchematicToolbarPosition();$(SCHEMATIC_TOOLBAR).css("margin-left",f);this.viewer.resize(n);this.updateToggleViewer();surface.updateLandingPageButton();surface.getFileSidebar()&&surface.getFileSidebar().refreshSize(i)},n.prototype.getVisibleWidth=function(n){switch(n){case t.LEFT:return this.isLeftSidebarClosed?0:SIDEBAR_WIDTH;case t.RIGHT:return this.isRightSidebarClosed?0:SIDEBAR_WIDTH}},n.prototype.openOrCloseSidebar=function(n,i){var r,u,f;if(this.namePositionMap[n]==undefined)if(i)throw n+" is not a recognized sidebar";else return;r=this.namePositionMap[n];r.whichSide==t.LEFT&&(u=this.leftSelectedIndex==r.index);r.whichSide==t.RIGHT&&(u=this.rightSelectedIndex==r.index);f=!i;i&&(r.whichSide==t.LEFT&&this.isLeftSidebarClosed?this.toggleLeftSidebarVisibility():r.whichSide==t.RIGHT&&this.isRightSidebarClosed&&this.toggleRightSidebarVisibility());i&&!u&&this.openSidebar(r.index,r.whichSide);f&&u&&this.openSidebar(r.index,r.whichSide)},n.prototype.openSidebarByName=function(n){this.openOrCloseSidebar(n,!0)},n.prototype.closeSidebarByName=function(n){this.openOrCloseSidebar(n,!1)},n.prototype.hideSidebarForSession=function(n){this.closeSidebarByName(n);var t=this.namePositionMap[n];t==undefined},n.prototype.createSidebarDiv=function(n,t,i){$(t).empty();var r=i[n].getDiv();r.on("mousedown",function(){surface.getPropertyEditor().closeIfUnpinned()});$(t).append(r);i[n].init()},n.prototype.openSidebar=function(n,i){var r="",u=-1,f=[];switch(i){case t.LEFT:r=LEFT_SIDEBAR;u=this.leftSelectedIndex;f=this.leftSidebarDivs;break;case t.RIGHT:r=RIGHT_SIDEBAR;u=this.rightSelectedIndex;f=this.rightSidebarDivs}u==-1?(i==t.LEFT?(this.leftSelectedIndex=n,this.leftSelectedName=this.getName(n,i)):(this.rightSelectedIndex=n,this.rightSelectedName=this.getName(n,i)),this.createSidebarDiv(n,r,f),$(r).width(SIDEBAR_WIDTH),this.resizeComponents()):u==n||(f[u].onClose(),i==t.LEFT?(this.leftSelectedIndex=n,this.leftSelectedName=this.getName(n,i)):(this.rightSelectedIndex=n,this.rightSelectedName=this.getName(n,i)),this.createSidebarDiv(n,r,f));this.resizeComponents()},n.prototype.setEditingMode=function(n){for(var t=0;t<this.leftSidebarDivs.length;++t)this.leftSidebarDivs[t].setEditingMode(n);for(t=0;t<this.rightSidebarDivs.length;++t)this.rightSidebarDivs[t].setEditingMode(n);n!=Schematic.EditingMode.EDITABLE&&this.hideSidebarForSession(COMPONENT_BROWSER_SIDEBAR_ID)},n.prototype.clear=function(){for(var n=0;n<this.leftSidebarDivs.length;++n)this.leftSidebarDivs[n].clear();for(n=0;n<this.rightSidebarDivs.length;++n)this.rightSidebarDivs[n].clear()},n.prototype.addToMap=function(n,t,r){if(this.namePositionMap[n]!=undefined)throw"Duplicate names are not allowed in map!";var u=new i(t,r);this.namePositionMap[n]=u},n.prototype.getName=function(n,t){var i,r;for(i in this.namePositionMap)if(this.namePositionMap.hasOwnProperty(i)&&(r=this.namePositionMap[i],n==r.index&&t==r.whichSide))return i;return null},n.prototype.toggleLeftSidebarVisibility=function(n){n===void 0&&(n=!1);var t=this,i=this.isLeftSidebarClosed,u=(i?0:-SIDEBAR_WIDTH)+"px",r=(i?SIDEBAR_WIDTH+1:1)+"px";this.isLeftSidebarClosed=!this.isLeftSidebarClosed;this.toggleLeftSidebarDiv.undefineEvents();this.toggleLeftSidebarDiv.getElement().stop().animate({left:r},t.slideTime);$(LEFT_SIDEBAR).stop().animate({"margin-left":u},t.slideTime,function(){var n=i?t.leftButtonSrc:t.rightButtonSrc;$(TOGGLE_LEFT_SIDEBAR_IMG).attr("src",n);t.toggleLeftSidebarDiv.reset("left",r);t.resizeComponents()})},n.prototype.toggleRightSidebarVisibility=function(){var n=this,t=this.isRightSidebarClosed,r=(t?0:-SIDEBAR_WIDTH)+"px",i=(t?SIDEBAR_WIDTH+1:1)+"px";this.isRightSidebarClosed=!this.isRightSidebarClosed;this.toggleRightSidebarDiv.undefineEvents();this.toggleRightSidebarDiv.getElement().stop().animate({right:i},n.slideTime);$(RIGHT_SIDEBAR).stop().animate({"margin-right":r},n.slideTime,function(){var r=t?n.rightButtonSrc:n.leftButtonSrc;$(TOGGLE_RIGHT_SIDEBAR_IMG).attr("src",r);n.toggleRightSidebarDiv.reset("right",i);n.resizeComponents()})},n.prototype.setInitialState=function(n,t){this.openSidebarByName(n);this.openSidebarByName(t)},n.prototype.disableAndCloseViewerWindow=function(){var n=$(".k-icon.k-collapse-next");n.length&&($(n).trigger("click"),this.toggleViewerDiv.getElement().hide(),$(MAIN_EDITOR).find(".k-splitbar").hide())},n.prototype.enableAndOpenViewerWindow=function(){var n=$(".k-icon.k-expand-next");n.length&&(this.toggleViewerDiv.getElement().show(),$(MAIN_EDITOR).find(".k-splitbar").show(),$(n).trigger("click"))},n}();n.Manager=r}(Sidebar||(Sidebar={})),function(n){var i=function(){function n(n,t,i,r){this.isStopRecord=!1;this.editmode_button_text="";this.manager=n;this.surface=t;this.simulationSidebar=i;this.name=r;this.saver=new Project.SaveDesign("saveDialog",this.surface,this.simulationSidebar);this.browser=new DesignBrowser.Browser(this.surface,this.manager,this.simulationSidebar);this.undoStack=new Project.UndoStackBrowser(this.surface);this.myDiv=this.createDiv();this.compCreator=new Project.CompCreator;this.compPromotion=new Project.CompPromotionManager}return n.prototype.getDiv=function(){return this.myDiv},n.prototype.refreshSize=function(n){this.myDiv&&this.myDiv.height(n-20)},n.prototype.getName=function(){return this.name},n.prototype.createDiv=function(){var n=$('<div style="margin: 10px; padding 5px; overflow-y:auto;"><\/div>'),t="width: "+(SIDEBAR_WIDTH-20)+"px";return this.load_button=$('<button type="button" id="load_button" class="btn sidebar_button icon-cloud-download" style="'+t+'">&nbspLoad Design<\/button>'),n.append(this.load_button),n.append("<p />"),this.saveAs_button=$('<button type="button" id="saveAs_button" class="btn sidebar_button icon-cloud-upload" style="'+t+'">&nbspSave Design As<\/button>'),n.append(this.saveAs_button),n.append("<p />"),this.save_button=$('<button type="button" id="dev_save_button" class="btn sidebar_button icon-cloud-upload" style="'+t+'">&nbspSave Design<\/button>'),n.append(this.save_button),n.append("<p />"),this.clear_button=$('<button type="button" class="btn sidebar_button icon-trash" style="'+t+'">&nbspClear Schematic<\/button>'),n.append(this.clear_button),n.append('<hr class="hr_sidebar" />'),this.netlist_button=$('<button type="button" id="netlist_button" class="btn sidebar_button icon-tasks" style="'+t+'">&nbspNetlist Design<\/button>'),this.netlister=new svw.Simulation.Control("simulation",this.surface),n.append(this.netlist_button),n.append('<hr class="hr_sidebar" />'),this.compPromotionButton=$('<button type="button" id="comp_promote_button" class="btn sidebar_button icon-tasks" style="'+t+'">&nbspPromote Comp Dialog<\/button>'),n.append(this.compPromotionButton),n.append("<p />"),this.simulation_log=$('<button type="button" id="simulation_detailed_log" class="btn sidebar_button icon-tasks" style="'+t+'">&nbspDetailed Sim Log<\/button>'),n.append(this.simulation_log),n.append("<p />"),this.wdb_button=$('<button type="button" id="get_wdb" class="btn sidebar_button icon-tasks" style="'+t+'">&nbspDownload Waveforms<\/button>'),n.append(this.wdb_button),n.append("<p />"),this.comp_button=$('<button type="button" id="create_comp" class="btn sidebar_button icon-tasks" style="'+t+'">&nbspCreate New Component<\/button>'),n.append(this.comp_button),n.append("<p />"),this.editmode_button=$('<button type="button" class="btn sidebar_button icon-adjust" style="'+t+'"><\/button>'),n.append(this.editmode_button),n.append('<hr class="hr_sidebar" />'),this.undoStackButton=$('<button type="button" class="btn sidebar_button icon-undo" style="'+t+'">&nbsp;Undo Stack<\/button>'),n.append(this.undoStackButton),n.append('<hr class="hr_sidebar" />'),this.dumpStateButton=$('<button type="button" class="btn sidebar_button icon-play" style="'+t+'">&nbsp;Dump Start State<\/button>'),n.append(this.dumpStateButton),n.append("<p />"),n.append('<hr class="hr_sidebar" />'),this.siteTestsCheckButton=$('<button type="button" class="btn sidebar_button icon-play" style="'+t+'">&nbsp;Check Site Tests<\/button>'),n.append(this.siteTestsCheckButton),n.append("<p />"),n.append('<hr class="hr_sidebar" />'),this.runDesignTestsButton=$('<button type="button" class="btn sidebar_button icon-play" style="'+t+'">&nbsp;Run Design Tests<\/button>'),n.append(this.runDesignTestsButton),n.append("<p />"),n.append('<hr class="hr_sidebar" />'),Project.Utility.setTooltip(this.runDesignTestsButton,"Run Pre-Checkin tests"),this.runClientTestsButton=$('<button type="button" class="btn sidebar_button icon-play" style="'+t+'">&nbsp;Run Client Tests<\/button>'),n.append(this.runClientTestsButton),n.append("<p />"),n.append('<hr class="hr_sidebar" />'),Project.Utility.setTooltip(this.runClientTestsButton,"Run client-side tests"),this.addDesignToTestButton=$('<button type="button" class="btn sidebar_button icon-cloud-upload" style="'+t+'">&nbsp;Add Design to Test Suite<\/button>'),n.append(this.addDesignToTestButton),n.append("<p />"),n.append('<hr class="hr_sidebar" />'),Project.Utility.setTooltip(this.addDesignToTestButton,"Open console window to see new test line"),this.addHelpButton=$('<button type="button" class="btn sidebar_button icon-question" style="'+t+'">&nbsp;Add Help<\/button>'),n.append(this.addHelpButton),n.append("<p />"),n.append('<hr class="hr_sidebar" />'),Project.Utility.setTooltip(this.addHelpButton,"Add Help topic"),this.configureEditModeButton(!1),n},n.prototype.init=function(){var n=this,i,r,u;this.load_button.click(function(){n.browser.show()});this.saver.init();this.saveAs_button.click(function(){n.saver.show()});this.save_button.click(function(){n.saver.doSave()});this.clear_button.click(function(){$.when(n.surface.clearDesign().done(function(t){t&&n.simulationSidebar.updateSimulationParameters()}))});this.netlist_button.click(function(){n.netlister.ShowNetlist()});$("#comp_promote_button").click(function(){n.compPromotion.showDialog()});$("#simulation_detailed_log").click(function(){var t=n.simulationSidebar.getSimulator().getSimulationId(),i,r;t&&t!=""||(i=n.surface.getDesign().getLatestSimulationResultInfo(),i&&(t=i.getSimulationId()));t&&t!=""?$.ajax({url:Project.Settings.APIURI()+"/log/?simulationId="+t,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(t){var i=t;i+="\n";i+=n.simulationSidebar.getDetailedSimulationLog();n.showDetailedSimulationLog(i)}}):(r=n.simulationSidebar.getDetailedSimulationLog(),n.showDetailedSimulationLog(r))});this.editmode_button.click(function(){n.configureEditModeButton(!0)});i=!1;r=!1;this.comp_button.click(function(){var t=$("#compWiz");t.data("kendoWindow")||t.kendoWindow({width:"820px",height:$("#main_editor").height()>750?"720px":$("#main_editor").height()-20+"px",title:"Component Creator",actions:["Pin","Minimize","Maximize","Close","Refresh"],resize:function(){},dragstart:function(){},dragend:function(){},content:"CompEdit/Editor",refresh:function(){kendo.ui.progress(t,!0);n.configureSVGEditor();$("#editorTabs").on("shown.bs.tab",function(t){t.target.innerText!="Symbol"||i||n.compCreator.updateCanvas();$(".CodeMirror").each(function(n,t){t.CodeMirror.refresh()})})}});t.data("kendoWindow").center().open()});this.wdb_button.click(function(){Project.ResultsInfo.GetResultID(n.surface.getDesign().getRevisionID()).done(function(t){t!=null&&t.length>0&&Project.ResultsInfo.GetSimulationInfo(t[t.length-1]).done(function(t){t!=null&&t.WaveformDatabaseURI!=null&&$.ajax({type:"GET",url:Project.Settings.APIURI()+"/results?wdbPath="+t.WaveformDatabaseURI+"&designName="+n.surface.getDesign().getName(),success:function(t){if(t!=null){var i=Project.Settings.APIURI()+"/results?tempID="+t+"&notUsed=true";n.surface.getDlIFrameSchematic().attr("src",i)}}})})})});this.undoStackButton.click(function(){n.undoStack.show()});u=this;this.dumpStateButton.click(function(){var r=n.isStopRecord?" End state":" Start state",i=!n.isStopRecord;i&&n.surface.getDesign().getUndoManager().clear();n.surface.getDesign().dumpDesignState(i,r);n.surface.getDesign().getUndoManager().dumpUndoManagerState(n.surface.getDesign(),i,r);i||t.openEditorWithTestData(surface);n.isStopRecord=!n.isStopRecord;n.isStopRecord?(n.dumpStateButton.removeClass().addClass("btn sidebar_button icon-stop"),n.dumpStateButton.html("&nbsp;Dump Stop State")):(n.dumpStateButton.removeClass().addClass("btn sidebar_button icon-play"),n.dumpStateButton.html("&nbsp;Dump Start State"))});this.siteTestsCheckButton.click(function(){function r(){var t=2e3,n=$("#SiteTestGrid").data("kendoGrid");n.thead.closest("table").width(t);n.tbody.closest("table").width(t);n.tbody.closest("table").height(500)}var t=10,u="Tests started  "+t+" minutes ago:\n",i=$("#SiteTestGrid").kendoGrid({dataBound:r,dataSource:{type:"json",transport:{read:function(n){$.ajax({url:Project.Settings.APIURI()+"/sitetests?timeWindow="+t,dataType:"json",success:function(t){t==null&&Project.MessageManager.showInfoMessage("No test results",!1);n.success(t)},error:function(t){t==null&&Project.MessageManager.showInfoMessage("No test results",!1);n.error(t)}})}},pageSize:7,group:{field:"Started",dir:"desc"}},scrollable:!0,sortable:!0,filterable:!0,pageable:{input:!0,numeric:!1},columns:[{field:"TestName",width:"220px"},{field:"Passed",width:"110px"},"Message","WorkerRole",{field:"Started",width:"200px"},{field:"Finished",width:"200px"},{field:"UpTime",width:"110px"},"JobId"]}),n=$("#SiteTestStateWindow");n.data("kendoWindow")||n.kendoWindow({width:"820px",height:$("#main_editor").height()>750?"650px":$("#main_editor").height()-100+"px",title:"Test State",actions:["Close"],resize:function(){}}).data("kendoWindow").content(i.val());n.data("kendoWindow").center().open()});this.runDesignTestsButton.click(function(){n.initDesignTestManager();n.designTester.runCheckInTests()});this.runClientTestsButton.click(function(){n.initClientTestManager();n.clientTester.runAllTests()});this.addDesignToTestButton.click(function(){n.initDesignTestManager();n.designTester.addTest(n.surface.getDesign())});this.addHelpButton.click(function(){var n=new Project.AppAddHelp;n.showAppHelpInputDialog()})},n.prototype.initDesignTestManager=function(){this.designTester=new Project.DesignTestManager(this.surface)},n.prototype.initClientTestManager=function(){this.clientTester=new Project.ClientTestManager(this.surface)},n.prototype.showTestResults=function(n){Project.MessageManager.showInfoMessage(n,!1)},n.prototype.configureSVGEditor=function(){var n=this;this.compCreator.setup();$("#symTab").append($('<iframe  width="100%" height="600px" id="svgedit" onload="initEmbed"><\/iframe>'));$("iframe#svgedit").attr("src","CompEdit/SvgFrame");$("#svgedit").load(function(){$(".CodeMirror").each(function(n,t){t.CodeMirror.refresh()});$("#svgedit").contents().find("#symbolEditorBody").show();$("#svgedit").contents().find("#symbolEditor").show();$("#svgedit").contents().find("#svg_editor").show();n.compCreator.setupCanvas();kendo.ui.progress($("#compWiz"),!1)});this.compCreator.setupCodeMirror();$(".CodeMirror").each(function(n,t){t.CodeMirror.refresh()})},n.prototype.configureEditModeButton=function(n){n&&this.surface.setEditingMode(this.nextEditMode);var t="",i="";switch(this.surface.getEditingMode()){case Schematic.EditingMode.EDITABLE:this.nextEditMode=Schematic.EditingMode.DESIGN_EXPLORATION;t="Design Exploration Mode";i="icon-signal";break;case Schematic.EditingMode.DESIGN_EXPLORATION:this.nextEditMode=Schematic.EditingMode.RESULTS_VIEWING;t="Results Viewing Mode";i="icon-lock";break;case Schematic.EditingMode.RESULTS_VIEWING:this.nextEditMode=Schematic.EditingMode.EDITABLE;t="Editing Mode";i="icon-unlock"}this.editmode_button.removeClass().addClass("btn sidebar_button "+i);this.editmode_button.html("&nbsp;"+t)},n.prototype.setEditingMode=function(){this.configureEditModeButton(!1)},n.prototype.clear=function(){this.undoStack.init()},n.prototype.onClose=function(){},n.prototype.getUndoStack=function(){return this.undoStack},n.prototype.showDetailedSimulationLog=function(n){n='<textarea readonly style="width:100%;height:100%">'+n+"<\/textarea>";$("#detailedSimulationLog").html("");$("#detailedSimulationLog").kendoWindow({actions:["Close"],draggable:!0,height:"430px",modal:!1,pinned:!1,position:{top:100,left:100},resizable:!0,width:"750px"});var t=$("#detailedSimulationLog").data("kendoWindow");t.center();t.title("Detailed Simulation Log");t.open();$("#detailedSimulationLog").scrollTop(0);$("#detailedSimulationLog").append(n)},n}(),t;n.FileMenu=i;t=function(){function n(){}return n.addToTestData=function(t,i){i?n.testVisibleData="":t+="<br/><br/>";var r=t.replace(/\n+/g,"<br/>");n.testVisibleData+=r},n.openEditorWithTestData=function(){var u="#TestTemporaryEditor",f="removeEditor",t,i,r,e;$("#TestTemporaryEditor").length?(i=$(u),t=i.data("kendoEditor"),t.value(""),t.value(n.testVisibleData)):($("<textarea id = 'TestTemporaryEditor' >< /textarea>").appendTo(document.body),i=$(u),i.kendoEditor({value:n.testVisibleData,tools:[{name:"custom",template:"<button id='"+f+"' class='k-button'>Close editor<\/button>"}]}),t=i.data("kendoEditor"));r=t.createRange();r.selectNodeContents(t.body);t.selectRange(r);e=t.getRange();$("#"+f).click(function(){n.closeEditor()})},n.closeEditor=function(){$("table.k-widget.k-editor.k-header").remove()},n.testVisibleData="",n}();n.DumpEditor=t}(Sidebar||(Sidebar={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){(function(n){n[n.INTERRUPT_SIMULATION=0]="INTERRUPT_SIMULATION";n[n.PROCESSING_RESULTS=1]="PROCESSING_RESULTS"})(n.INTERRUPT_MODE||(n.INTERRUPT_MODE={}));var t=n.INTERRUPT_MODE,i=function(i){function r(n,t,r){i.call(this,n);this.interruptDlg=null;this.plotCompleteCallback=null;this.plotCompleteCallbackContext=null;this.plotCompleteCallbackArgs=null;this.viewer=t;this.simulator=new Project.SimulateDesign(this.surface);this.firstSimRun=!0;this.processingUpdate=!1;this.interruptRequested=!1;this.interruptTimer=null;this.name=r;this.reportedOrphanTerminals=[]}return __extends(r,i),r.prototype.getSimulator=function(){return this.simulator},r.prototype.setSimulationType=function(n){if(this.simType=n,this.timeDomainInputs&&this.freqDomainInputs){this.destroyQtips();this.simType==Project.SIMULATION_TYPE.FREQUENCY_DOMAIN?(this.timeDomainInputs.hide(),this.freqDomainInputs.show()):(this.freqDomainInputs.hide(),this.timeDomainInputs.show());var t=this.simType.toString();this.simTypeSelector.val(t);this.hasValidInputs()}},r.prototype.getName=function(){return this.name},r.prototype.getAdvancedPanel=function(){return this.advancedPanel},r.prototype.getDiv=function(){var i=$('<div style="margin: 10px; padding 5px; height: 100%"><\/div>'),f,t,u,n;return this.allContainer=i,f="width: "+(SIDEBAR_WIDTH-20)+"px",t=$('<div id="'+r.SIMULATION_CONTROLS_ID+'" display="none"><\/div>'),i.append(t),this.playStopButton=$('<i id="'+r.PLAY_STOP_BUTTON_ID+'" class="icon-refresh"><\/i>'),t.append(this.playStopButton),u=$('<div class="progress active simulation_progress_bar_height" style="fixed"><\/div>'),this.pbar=$('<div class="bar simulation_progress_bar_height simulation_progress_color_gradient" style="width: 0%;"><\/div>'),u.append(this.pbar),u.append(this.simInfo),t.append(u),t.append('<div class="sidebar_text_label">Simulation Type<\/div>'),this.simTypeSelector=$('<select id="'+r.SIM_TYPE_SELECTOR_ID+'" style="width: 100%" class="form-control">'),this.simTypeSelector.append('<option value="'+Project.SIMULATION_TYPE.TIME_DOMAIN+'">Time-Domain<\/option>'),this.simTypeSelector.append('<option value="'+Project.SIMULATION_TYPE.FREQUENCY_DOMAIN+'">Frequency-Domain<\/option>'),this.simTypeSelector.append("<\/select>"),t.append(this.simTypeSelector),t.append("<br />"),this.timeDomainInputs=$('<div class="sidebar_text_label">Simulation End Time<\/div>'),n=$('<div id="'+r.END_TIME_GROUP_ID+'" class="input-group input input-group-sm" style="width: 100%"><\/div>'),this.endTimeInput=$('<input id="'+r.END_TIME_ID+'" type="text" class="form-control">'),this.defineUndoEvents(this.endTimeInput),n.append(this.endTimeInput),n.append('<span class="input-group-addon">secs<\/span>'),this.timeDomainInputs.append(n),this.timeDomainInputs.append("<br />"),t.append(this.timeDomainInputs),this.freqDomainInputs=$('<div class="sidebar_text_label">Simulation Start Frequency<\/div>'),n=$('<div id="'+r.START_FREQ_GROUP_ID+'" class="input-group input input-group-sm" style="width: 100%"><\/div>'),this.startFreqInput=$('<input id="'+r.START_FREQ_ID+'" type="text" class="form-control">'),this.defineUndoEvents(this.startFreqInput),n.append(this.startFreqInput),n.append('<span class="input-group-addon">Hz<\/span>'),this.freqDomainInputs.append(n),this.freqDomainInputs.append("<br />"),this.freqDomainInputs.append('<div class="sidebar_text_label">Simulation End Frequency<\/div>'),n=$('<div id="'+r.END_FREQ_GROUP_ID+'" class="input-group input input-group-sm" style="width: 100%"><\/div>'),this.endFreqInput=$('<input id="'+r.END_FREQ_ID+'" type="text" class="form-control">'),this.defineUndoEvents(this.endFreqInput),n.append(this.endFreqInput),n.append('<span class="input-group-addon">Hz<\/span>'),this.freqDomainInputs.append(n),this.freqDomainInputs.append("<br />"),t.append(this.freqDomainInputs),this.simInfo=$('<div class="hero-unit"> <\/div>'),t.append(this.simInfo),t.append('<hr class="hr_sidebar" />'),this.simOutputButton=$('<button type="button" id="'+r.SIM_OUTPUT_BUTTON_ID+'" class="btn sidebar_button icon-file-text-alt" style="'+f+'">&nbspSimulation Status<\/button>'),i.append(this.simOutputButton),i.append('<br style="padding: 3px" /><br />'),this.advancedRef=$('<div><a href="#" id="'+r.ADVANCED_REF_ID+'" class="sidebar_text_label" style ="margin-left:10px">Advanced Options<\/a><\/div>'),i.append(this.advancedRef),this.createAdvancedPanelIfNeeded(),this.advancedPanel.hide(),this.advancedRef.qtip({content:{text:Project.AdvancedOptions.ADVANCED_OPTIONS_TOOLTIP},position:{my:"top right",at:"top left"},style:{classes:"svw-tooltip"}}),i},r.prototype.getPlayStopButton=function(){return this.playStopButton},r.prototype.activatePlayStopClick=function(){var n=this,t,i;switch(this.getSimulator().getState()){case Project.SimulationResultsState.NOT_RUNNING:if(!this.hasValidInputs()){this.simType==Project.SIMULATION_TYPE.TIME_DOMAIN?Project.MessageManager.showErrorMessage("Simulation inputs are invalid.<br>Have you specified the Simulation End Time?"):Project.MessageManager.showErrorMessage("Simulation inputs are invalid.<br>Have you specified the Simulation Start Frequency and Simulation End Frequency?");return}if(this.prepareSimulation(),t=this.surface.getDesign(),!t.validate())return;this.showStartSimulation();ProbeModule.getWaveBoxManager().prepareToNewSimulation(this.simType);i=t.save();i.done(function(){n.interruptRequested?(Project.MessageManager.showInfoMessage("Simulation Interrupted"),n.enableSimulation()):n.getSimulator().start(n)});break;case Project.SimulationResultsState.RUNNING:this.requestInterruptSimulation()}},r.prototype.init=function(){var n=this,t=this;this.setSimulationType(Project.SIMULATION_TYPE.TIME_DOMAIN);this.getSimulator().getState()==Project.SimulationResultsState.NOT_RUNNING?this.enableSimulation():this.showStopIcon();this.enableControls();this.simTypeSelector.change(function(){n.setSimulationType(n.simTypeSelector.val())});this.endTimeInput.on("keyup",function(){n.destroyQtips();clearTimeout(n.timer);n.timer=setTimeout(function(){n.hasValidInputs()},250)});this.startFreqInput.on("keyup",function(){n.destroyQtips();clearTimeout(n.timer);n.timer=setTimeout(function(){n.hasValidInputs()},250)});this.endFreqInput.on("keyup",function(){n.destroyQtips();clearTimeout(n.timer);n.timer=setTimeout(function(){n.hasValidInputs()},250)});this.endTimeInput.on("blur change",function(){n.hasValidInputs()&&n.prepareTransSim()});this.startFreqInput.on("blur change",function(){n.hasValidInputs()&&n.prepareFreqSim()});this.endFreqInput.on("blur change",function(){n.hasValidInputs()&&n.prepareFreqSim()});this.advancedRef.click(function(){n.createAdvancedPanelIfNeeded();n.advancedPanel.toggleVisibility()});this.simOutputButton.click(function(){n.getSimulator().getState()==Project.SimulationResultsState.RUNNING?Project.MessageManager.showInfoMessage("Simulation in progress"):n.getSimulator().getSimulationId()?n.getSimulator().hasError()?n.processErrorMessage(n.getSimulator().getUserMessage()):n.getSimulator().getUserMessage()!=""?n.processWarningMessage(n.getSimulator().getUserMessage(),!0):n.processInfoMessage("Simulation completed successfully",!1,!0):Project.MessageManager.showInfoMessage("Simulation has not been run")});this.updateSimulationParameters();this.setEditingMode(this.surface.getEditingMode())},r.prototype.prepareTransSim=function(){var t=this.surface.getDesign().getLatestSimulationParameters(!0),n,i;t&&(t.setActiveSimulation(Project.SIMULATION_TYPE.TIME_DOMAIN),n=t.getTransParams(),n&&n.getEndTime()!=this.endTimeInput.val()&&(i=this.surface.getDesign().getUndoManager(),i.startUndoableCommand(Project.UpdateSimEndTimeCommand,this.surface.getDesign(),n),this.prepareSimulation(),i.finishUndoableCommand(n.getEndTime())))},r.prototype.prepareFreqSim=function(){var i=this.surface.getDesign().getLatestSimulationParameters(!0),n,t;i&&(i.setActiveSimulation(Project.SIMULATION_TYPE.FREQUENCY_DOMAIN),n=i.getFreqParams(),t=this.surface.getDesign().getUndoManager(),n.getStartFreq()!=this.startFreqInput.val()&&(t.startUndoableCommand(Project.UpdateFreqSimCommand,this.surface.getDesign(),n),this.prepareSimulation(),t.finishUndoableCommand(n.getSaveData())),n.getEndFreq()!=this.endFreqInput.val()&&(t.startUndoableCommand(Project.UpdateFreqSimCommand,this.surface.getDesign(),n),this.prepareSimulation(),t.finishUndoableCommand(n.getSaveData())))},r.prototype.setEditingMode=function(n){switch(n){case Schematic.EditingMode.EDITABLE:case Schematic.EditingMode.DESIGN_EXPLORATION:this.showSimulationControls();break;case Schematic.EditingMode.RESULTS_VIEWING:this.hideSimulationControls()}},r.prototype.clear=function(){},r.prototype.onClose=function(){},r.prototype.enableControls=function(){if(this.playStopButton){var n=this;this.playStopButton.off("click").click(function(){n.activatePlayStopClick()})}},r.prototype.disableControls=function(){this.playStopButton&&this.playStopButton.off("click")},r.prototype.hasValidInputs=function(){var n=!0,t,i,u;return this.simType==Project.SIMULATION_TYPE.TIME_DOMAIN?(t=r.END_TIME_GROUP_ID,this.IsNumeric(this.endTimeInput.val(),"time",t,this.endTimeInput)?$("#"+t).removeClass("has-error"):($("#"+t).addClass("has-error"),n=!1)):(i=r.START_FREQ_GROUP_ID,this.IsNumeric(this.startFreqInput.val(),"real",i,this.startFreqInput)?$("#"+i).removeClass("has-error"):($("#"+i).addClass("has-error"),n=!1),u=r.END_FREQ_GROUP_ID,this.IsNumeric(this.endFreqInput.val(),"real",u,this.endFreqInput)?$("#"+u).removeClass("has-error"):($("#"+u).addClass("has-error"),n=!1)),n},r.prototype.IsNumeric=function(n,t,i,r){var u=new Project.PropertyFormatter,f=u.ValidateInputValue(u.GetPropertyType(t),n,!0);return f.match("^Invalid")?($("#"+i).qtip("destroy"),$("#"+i).qtip({content:f,position:{my:"right top",at:"left bottom",target:r},style:{classes:"svw-tooltip"}}),$("#"+i).qtip("show"),!1):($("#"+i).qtip("destroy"),n.trim()!="")?!0:!1},r.prototype.updateSimulationParameters=function(){var f=this.surface.getDesign(),i=this.surface.getDesign().getLatestSimulationType();i==Project.SIMULATION_TYPE.NONE&&(i=Project.SIMULATION_TYPE.TIME_DOMAIN);this.setSimulationType(i);var u=new Project.AdvancedOptions,n=f.getLatestSimulationParameters(),r=null,t=null;n&&(r=n.getTransParams(),t=n.getFreqParams());r!=null?r.updateEndTimeField():this.endTimeInput.val("");t!=null?(t.updateStartFreqField(),t.updateEndFreqField()):(this.startFreqInput.val(""),this.endFreqInput.val(""));n&&n.getAdvancedOptions()&&(u=n.getAdvancedOptions());this.hasValidInputs();this.advancedPanel.setState(u.getSaveData())},r.prototype.updateEndTimeField=function(n){$("#"+r.END_TIME_ID).val(n)},r.prototype.updateStartFreqField=function(n){$("#"+r.START_FREQ_ID).val(n)},r.prototype.updateEndFreqField=function(n){$("#"+r.END_FREQ_ID).val(n)},r.prototype.destroyQtips=function(){$("#"+r.END_TIME_GROUP_ID).qtip("destroy");$("#"+r.START_FREQ_GROUP_ID).qtip("destroy");$("#"+r.END_FREQ_GROUP_ID).qtip("destroy")},r.prototype.hideSimulationControls=function(){$("#"+r.SIMULATION_CONTROLS_ID).hide();this.advancedPanel&&this.advancedPanel.hide();this.advancedRef&&this.advancedRef.hide()},r.prototype.showSimulationControls=function(){$("#"+r.SIMULATION_CONTROLS_ID).show();this.advancedRef.show()},r.prototype.createAdvancedPanelIfNeeded=function(){this.advancedPanel||(this.advancedPanel=new n.AdvancedPanel(this.surface,this.allContainer,this))},r.prototype.setAdvancedOptions=function(){var n=this.surface.getDesign().getLatestSimulationParameters(!0),i=n.getAdvancedOptions(),t;this.advancedPanel.stateChanged(i)&&(t=this.surface.getDesign().getUndoManager(),t.startUndoableCommand(Project.UpdateAdvancedOptionsCommand,this.surface.getDesign(),i),n.setAdvancedOptions(this.advancedPanel.getState()),this.surface.getDesign().setDirty(Project.DIRTY_FLAG.DIRTY_SIM_SETTINGS),t.finishUndoableCommand(n.getAdvancedOptions().getSaveData()))},r.prototype.prepareSimulation=function(){var n=this.surface.getDesign().getLatestSimulationParameters(!0),i,t,r;n&&(i=n.getTransParams(),i.setEndTime(this.endTimeInput.val()),t=n.getFreqParams(),t.setStartFreq(this.startFreqInput.val()),t.setEndFreq(this.endFreqInput.val()),this.advancedPanel&&n.setAdvancedOptions(this.advancedPanel.getState()),r=this.surface.getDesign().getName(),i.setName(r),t.setName(r),n.setActiveSimulation(this.simType))},r.prototype.updateUI=function(){var n=this;this.getSimulator().getState()!=Project.SimulationResultsState.NOT_RUNNING&&(this.processingUpdate||(this.processingUpdate=!0,this.interruptRequested?(this.startInterruptTimer(t.INTERRUPT_SIMULATION,r.INTERRUPT_TIMEOUT),$.when(this.getSimulator().stop()).done(function(){n.processingUpdate=!1;n.interruptRequested=!1;n.startInterruptTimer(t.PROCESSING_RESULTS,r.PROCESSING_RESULTS_TIMEOUT_1)})):$.when(this.getSimulator().updateSimulationInformation()).done(function(){n.updateUIHelper();n.processingUpdate=!1})),setTimeout(function(){n.updateUI()},500))},r.prototype.updateUIHelper=function(){var n=this,f=this.getSimulator().getState(),e,t,i,o,r,u;if(f==Project.SimulationResultsState.RUNNING)e=this.getSimulator().getPercentage(),this.pbar.css("width",e+"%"),t=this.getSimulator().getInfo(),t!=""&&this.simInfo.html(t);else if(f==Project.SimulationResultsState.RESULTS_AVAILABLE){if(this.cancelInterruptTimer(),this.getSimulator().hasError()?this.processErrorMessage(this.getSimulator().getUserMessage()):(i=this.getSimulator().getUserMessage(),i!=""?this.processWarningMessage(i,!1):this.surface.getDesign()&&(o=this.surface.getDesign(),r=this.getUnreportedOrphanTerminals(),(r&&r.length>0||!o.hasWaveBoxes())&&this.processInfoMessage("Simulation completed successfully",!0,!1))),this.getSimulator().hasWaveformData()){if(this.firstSimRun&&(this.firstSimRun=!1,WaveViewer.getManager().showViewer()),u=this.surface.getDesign().getSimulationData(),!u){this.plotCompleteCallback&&this.plotCompleteCallback(this.plotCompleteCallbackContext,this.plotCompleteCallbackArgs,!1);return}$.when(this.loadResults(u.getUniqueSimulations(),WaveViewer.UPDATING_MODE.BY_SIMULATION)).done(function(t){n.plotCompleteCallback&&n.plotCompleteCallback(n.plotCompleteCallbackContext,n.plotCompleteCallbackArgs,t)})}this.getSimulator().resultsProcessingComplete();this.enableSimulation();this.cancelInterruptTimer()}},r.prototype.setPlotCompleteCallback=function(n,t,i){this.plotCompleteCallback=n;this.plotCompleteCallbackContext=t;this.plotCompleteCallbackArgs=i},r.prototype.clearPlotCompleteCallback=function(){this.plotCompleteCallback=null;this.plotCompleteCallbackContext=null;this.plotCompleteCallbackArgs=null},r.prototype.startInterruptTimer=function(n,t){this.cancelInterruptTimer();var i=this;this.interruptTimer=setTimeout(function(n,t){return function(){i.showInterruptDialog(n,t)}}(i,n),t)},r.prototype.cancelInterruptTimer=function(){this.interruptTimer&&(clearTimeout(this.interruptTimer),this.interruptTimer=null,this.interruptDlg&&(this.interruptDlg.close(),this.interruptDlg=null))},r.prototype.showInterruptDialog=function(n,i){var h=this,f,u,e,o,s;i==t.INTERRUPT_SIMULATION?(f="Unresponsive Simulation",u="The simulation appears to be unresponsive. You can",u+="<br>kill the simulation or contiunue to wait.",e="Kill Simulation",o="Wait",s=r.INTERRUPT_TIMEOUT):(f="Processing Simulation Results",u="The simulation results are being processed. You can",u+="<br>abort the processing or contiunue to wait.",e="Abort Processing",o="Wait",s=r.PROCESSING_RESULTS_TIMEOUT_2);this.interruptDlg=new Project.MultiBtnNonModalDialog(f,u,[e,o]);jQuery.when(this.interruptDlg.queryUser()).done(function(t){h.interruptDlg=null;t==Project.BUTTON.BTN1?n.getSimulator().stop(!0):n.startInterruptTimer(i,s)})},r.prototype.processErrorMessage=function(n){var u=this,e=this.surface.getDesign().getOrphanTerminals(),f=this.getOrphanTerminalUUIDs(e),i=Project.Utility.convertNewlinesToHTML(n),t;this.isConvergenceError(i)?(t=i.length>500?Project.Utility.wrapLines(i).substr(0,200)+"...":Project.Utility.wrapLines(i),t+=this.getOrphanTerminalMsgs(e,f,!0),t+='<p><span class="btn-link convergenceError">',t+="Click here<\/span> for help solving convergence problems.<\/p>",t+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID),Project.MessageManager.showErrorMessage(t,!0),$(".convergenceError").click(function(){u.showDialog("Convergence Help",u.getConvergenceHelp())}),this.bindOrphanTerminals(f)):i.length>500?(t="There was a problem simulating your design. <br />",t+="Check that all components are connected properly and have appropriate values. <br />",t+=this.getOrphanTerminalMsgs(e,f,!0),t+='<p><span class="btn-link longSimulationError">',t+="Click here<\/span> for more information.<\/p>",t+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID),Project.MessageManager.showErrorMessage(t,!0),$(".longSimulationError").click(function(){u.showDialog("Simulation Log",i)}),this.bindOrphanTerminals(f)):i.toLowerCase().indexOf("time resolution")>0?(t=Project.Utility.wrapLines(i),t+="<br>Try enabling the <b>Time Resolution Enhancement<\/b> simulator option and",t+="<br>simulating again.",t+=this.getOrphanTerminalMsgs(e,f,!0),t+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID),Project.MessageManager.showErrorMessage(t,!0),this.bindOrphanTerminals(f),this.createAdvancedPanelIfNeeded(),this.advancedPanel.show()):i.toLowerCase().indexOf("exceeds the maximum end time allowed by the simulator")>0||i.toLowerCase().indexOf("has a time value larger than the maximum time allowed")>0?(t=Project.Utility.wrapLines(i),t+='<p><span class="btn-link endTimeError">',t+="Click here<\/span> for help increasing the simulation end time.<\/p>",t+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID),Project.MessageManager.showErrorMessage(t,!0),$(".endTimeError").click(function(){u.createAdvancedPanelIfNeeded();u.advancedPanel.show();u.showDialog("End Time Help",u.getEndTimeHelp())})):(t=Project.Utility.wrapLines(i),t+=this.getOrphanTerminalMsgs(e,f,!0),t+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID),Project.MessageManager.showErrorMessage(t,!0),this.bindOrphanTerminals(f));$("#"+r.MORE_INFO_ID).click(function(){u.showSimulationLog()})},r.prototype.processWarningMessage=function(n,t){var e=this,i=this.surface.getDesign().getOrphanTerminals(),u=this.getOrphanTerminalUUIDs(i),f=Project.Utility.wrapLines(Project.Utility.convertNewlinesToHTML(n))+this.getOrphanTerminalMsgs(i,u,!1);t&&(f+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID));Project.MessageManager.showWarningMessage(f,!0);this.bindOrphanTerminals(u);t&&$("#"+r.MORE_INFO_ID).click(function(){e.showSimulationLog()})},r.prototype.processInfoMessage=function(n,t,i){var h=this,u,e,s,o,f;if(i)u=this.surface.getDesign().getOrphanTerminals();else for(u=this.getUnreportedOrphanTerminals(),e=0;e<u.length;++e)s=u[e],this.reportedOrphanTerminals.push(s);u&&u.length>0?(o=this.getOrphanTerminalUUIDs(u),f=this.getOrphanTerminalMsgs(u,o,!1),i&&(f+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID)),Project.MessageManager.showWarningMessage(f,!0),this.bindOrphanTerminals(o)):(f=Project.Utility.wrapLines(Project.Utility.convertNewlinesToHTML(n)),i&&(f+=Project.Utility.getMoreInfoHtml(r.MORE_INFO_ID)),Project.MessageManager.showInfoMessage(f,t));i&&$("#"+r.MORE_INFO_ID).click(function(){h.showSimulationLog()})},r.prototype.getUnreportedOrphanTerminals=function(){for(var t,i=[],r=this.surface.getDesign().getOrphanTerminals(),n=0;n<r.length;++n)t=r[n],this.reportedOrphanTerminals.indexOf(t)==-1&&i.push(t);return i},r.prototype.showSimulationLog=function(){var n=this,t=this.getSimulator().getSimulationId();t&&t!=""?(this.showDialog("Simulation Log","Getting simulation log... please wait"),$.ajax({url:Project.Settings.APIURI()+"/log/?simulationId="+t,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(t){var i=Project.Utility.convertNewlinesToHTML(t);i=n.stripPaths(i);n.showDialog("Simulation Log",i)},error:function(){n.showDialog("Simulation Log","Simulation log not available")}})):this.showDialog("Simulation Log","Simulation log not available")},r.prototype.stripPaths=function(n){var t=n.replace(/<br>Loading c:.*?simworker\.simulatorstorage/gi,"<br>Loading ...");return t=t.replace(/<br>DC values written into file .*?<br>/gi,""),t=t.replace(/<br>Simulation results stored in .*?<br>/gi,""),t=t.replace(/<br>Compiling file C:[\\/]Resources.*?<br>/gi,""),t.replace(/Refer to the SystemVision documentation.*?<br>/gi,"")},r.prototype.showDialog=function(n,t){t===void 0&&(t=null);Project.KendoHelper.openLargeKendoWindow($(r.DIALOG),n,t)},r.prototype.getOrphanTerminalUUIDs=function(n){var i=[],t;if(n)for(t=0;t<n.length;t++)i.push(Project.Utility.createUUID());return i},r.prototype.getOrphanTerminalMsgs=function(n,t,i){var r="",u,e,f;if(n&&n.length>0)for(r+="<br/>",i?n.length>1?(r+="Possible error sources include the following components which<br/>",r+="have pins that are not connected to other components:<br/>"):(r+="Possible error sources include the following component which<br/>",r+="has a pin that is not connected to other components:<br/>"):r+=n.length>1?"The following components have pins that are not connected to other components:<br/>":"The following component has a pin that is not connected to other components:<br/>",u=0;u<n.length;u++)e=n[u].getComponent(),f=e.getInstName(),r+='<div class="errorMessageLink" id="',r+=t[u]+'" name="'+f+'">',r+="pin <strong>"+n[u].getName()+"<\/strong> on <strong>"+f+"<\/strong><\/div>";return r},r.prototype.bindOrphanTerminals=function(n){var t,i,r;if(n.length!=0)for(t=this.surface.getDesign(),this.surface.zoomToFit(t.getBoundingRect()),i=0;i<n.length;i++)r=$("#"+n[i]),r.click(function(n){var r=n.currentTarget.attributes.name.value,i;t.clearSelection();i=t.findCompByInstName(r);i&&t.selectObject(i)})},r.prototype.loadResults=function(n,t){var i=jQuery.Deferred(),o,r,s,u,h;if(n){if(!n.hasAnyResults())return i.resolve(!0),i.promise();if(o=WaveViewer.getManager().getChildBrowserWindow(),o){r=n.getSimulationDescriptions();for(s in r)u=r[s],u&&u.simulationId&&(h=t!=WaveViewer.UPDATING_MODE.BY_SIMULATION?!0:u.isLatest,h&&o.postMessage({action:WaveViewer.WaveManager.ADD_WDB,wdbId:u.simulationId},"*"))}if(Project.Utility.trace("Start simulation results loading",!0),t==WaveViewer.UPDATING_MODE.BY_SIMULATION)$.when(this.loadAndInitByOneSimulation(n.getLatestDesignSimulation(),t)).done(function(n){n?$.when(ProbeModule.getWaveBoxManager().completeWaveboxRestoring()).done(function(n){Project.Utility.trace("Wavebox updating completes",!0);i.resolve(n)}):i.resolve(!1)}).fail(function(){i.resolve(!1)});else{var f=null,e=null,r=n.getSimulationDescriptions();f=r[0]&&r[0].simulationId?r[0]:null;r.length>1&&(e=r[1]&&r[1].simulationId?r[1]:null);f||e?e?f?this.loadAndPlotTwoResultSets(f,e,t,i):this.loadAndPlotOneResultSet(e,t,i):this.loadAndPlotOneResultSet(f,t,i):i.resolve(!0)}}return i.promise()},r.prototype.loadAndPlotOneResultSet=function(n,t,i){$.when(this.loadAndInitByOneSimulation(n,t)).done(function(n){n?$.when(ProbeModule.getWaveBoxManager().completeWaveboxRestoring()).done(function(n){Project.Utility.trace("WaveboxUpdating completes1",!0);i.resolve(n)}):i.resolve(!1)}).fail(function(){i.resolve(!1)})},r.prototype.loadAndPlotTwoResultSets=function(n,t,i,r){var f=this,u=!1;$.when(this.loadAndInitByOneSimulation(n,i)).done(function(n){n||(u=!0);$.when(f.loadAndInitByOneSimulation(t,i)).done(function(n){n?$.when(ProbeModule.getWaveBoxManager().completeWaveboxRestoring()).done(function(n){u?r.resolve(!1):(Project.Utility.trace("WaveboxUpdating completes2",!0),r.resolve(n))}):u?r.resolve(!1):$.when(ProbeModule.getWaveBoxManager().completeWaveboxRestoring()).done(function(n){Project.Utility.trace("WaveboxUpdating completes3",!0);r.resolve(n)})})})},r.prototype.loadAndInitByOneSimulation=function(n,t){var r=this,i=$.Deferred();return Project.Utility.trace("before prepareToLoadSimulationResults",!0),$.when(ProbeModule.getWaveBoxManager().prepareToLoadSimulationResults(n.simulationType)).done(function(){Project.Utility.trace("after prepareToLoadSimulationResults",!0);var f=!n||n.isLatest,u=t==WaveViewer.UPDATING_MODE.BY_SIMULATION?f:!0;$.when(r.viewer.loadSimulationResults(n.simulationId)).done(function(r){Project.Utility.trace("after loadSimulationResults",!0);r?(u&&ProbeModule.getWaveBoxManager().setSimulationDescriptionForWavebox(n,t),Project.Utility.trace("End simulationDescription settings",!0),i.resolve(u)):(u&&ProbeModule.getWaveBoxManager().clearAllWaveboxesByError(),i.resolve(!1))}).fail(function(){u&&ProbeModule.getWaveBoxManager().clearAllWaveboxesByError();i.resolve(!1)})}),i.promise()},r.prototype.getDetailedSimulationLog=function(){return this.getSimulator().getErrorMessage()},r.prototype.showResultsForLoadedDesign=function(n){var t=jQuery.Deferred();return n.hasAnyResults()?(this.surface.getDesign().hasWaveBoxes()||WaveViewer.getManager().showViewer(),$.when(this.loadResults(n,WaveViewer.UPDATING_MODE.BY_STATE)).done(function(n){t.resolve(n)})):t.resolve(!1),t.promise()},r.prototype.enableSimulation=function(){this.showPlayIcon();this.pbar.css("width",0);this.simInfo.html("Ready");this.interruptRequested=!1;this.getSimulator()&&this.getSimulator().setState(Project.SimulationResultsState.NOT_RUNNING)},r.prototype.showStartSimulation=function(){Project.MessageManager.removeAllMessages();this.showStopIcon();this.getSimulator().setState(Project.SimulationResultsState.RUNNING);this.simInfo.html("Starting simulation")},r.prototype.requestInterruptSimulation=function(){this.showInterruptIcon();this.interruptRequested=!0;this.simInfo.html("Interrupting Simulation")},r.prototype.showPlayIcon=function(){$("#"+r.PLAY_STOP_BUTTON_ID).removeClass().addClass("play_button_available").css("font-size","1.5em");this.addTootipToSimButton("Run simulation")},r.prototype.showStopIcon=function(){$("#"+r.PLAY_STOP_BUTTON_ID).removeClass().addClass("stop_button_available").css("font-size","1.5em");this.addTootipToSimButton("Stop simulation")},r.prototype.showInterruptIcon=function(){$("#"+r.PLAY_STOP_BUTTON_ID).removeClass().addClass("icon-spinner icon-spin wait_button_available").css("font-size","1.5em");this.addTootipToSimButton("Wait until simulation is completed")},r.prototype.addTootipToSimButton=function(n){$("#"+r.PLAY_STOP_BUTTON_ID).qtip({content:{text:n},position:{my:"top right",at:"bottom left"},style:{classes:"svw-tooltip"}})},r.prototype.isConvergenceError=function(n){return n.toLowerCase().indexOf("singularit")>0||n.toLowerCase().indexOf("convergence")>0||n.toLowerCase().indexOf("dc solution could not be found")>0?!0:!1},r.prototype.getConvergenceHelp=function(){var n="";return n+="<h1>Convergence Recommendations for systemvision.com<\/h1>",n+="Systemvision.com may encounter convergence or singularity problems during a simulation. When this happens, the simulation will be terminated with an error message indicating the failure. This note describes a number of things to check and techniques you can use to overcome these convergence problems.",n+="<br/>",n+="<h3>Verify Component Connections<\/h3>",n+="Be sure all nets have at least two connected components. While it is valid for a net to have only a single connected component, it is not typical so systemvision.com will report a warning.",n+="<br/>",n+="<h3>Verify Ground Connections<\/h3>",n+="Systemvision.com will report an error if the design does not have a proper ground connection.  For circuits with one or more isolated blocks, be sure each of these blocks has a ground connection.",n+="<br/>",n+="<h3>Verify Parameter Values<\/h3>",n+="Check that all parameter values are correct keeping in mind the units specified on the property dialog.  For example, capacitance values are in F so a value of 0.001 is 1000 uF.",n+="<br/>",n+="<h3>Verify Connections on Voltage and Current Sources<\/h3>",n+="Be sure the circuit contains no voltage sources connected in parallel or current sources connected in series. Capacitors or inductors with a specified initial condition should also be considered.  For example, a capacitor with a specified initial condition acts like a constant voltage source during the DC phase of the simulation. Similarly, an inductor with an initial condition behaves as a current source during the DC phase.",n+="<br/>",n+="<h3>Verify Op-amp Connections<\/h3>",n+="If the circuit contains op-amps, be sure the positive and negative input terminals are connected properly.  Reversing these terminals can lead to unrealistically large output voltages which can cause convergence problems.",n+="<br/>",n+="<h3>Verify DC Path from All Nets to Ground<\/h3>",n+="Be sure there is a DC path from each net to ground. Note that a capacitor without an initial condition is an open circuit during the DC phase, so it does not provide a path to ground.",n+="<br/>",n+="<h3>Verify Current Sources Paths to Ground<\/h3>",n+="Be sure that all current sources have a current path to ground. An ideal current source with no path to ground will result a simulation error because no solution can be found for the voltage across the current source.",n+="<br/>",n+="<h3>Convergence Suggestions<\/h3>",n+="<p>Systemvision.com uses an iterative approach to compute the solution for design. Depending on the design, it may be necessary to use the <b>Advanced Options<\/b> simulation controls to achieve convergence.<\/p>",n+="<p>The <b>More Speed<\/b> and <b>More Accuracy<\/b> options change the simulation tolerances which may help with convergence problems.  The <b>More Speed<\/b> option relaxes the tolerances while the <b>More Accuracy<\/b> option tightens the tolerances.  Both of these options can be tried if a simulation is not converging.<\/p>",n+="<p>The <b>Time Resolution Enhancement<\/b> option allows the simulator to take smaller timesteps which may help with convergence of designs with very fast time constants.<\/p>",n+"<p>The <b>Convergence Assist<\/b> option allows the simulator to take more iterations before it rejects a timestep and tries a smaller timestep.  This option is useful for switching power supply designs.<\/p>"},r.prototype.getEndTimeHelp=function(){var n="";return n+="<p>The simulation end time can be increased using the <b>Manual Options Entry<\/b> under the <b>Advanced Options<\/b> on the simulation sidebar.  The table below shows several option entries that can be specified along with the corresponding maximum end time.<\/p>",n+" <body>  <table style='width:100%'>   <tr>     <th>Manual Option Value<\/th>     <th>Maximum End Time<\/th>\t\t   <\/tr>   <tr>     <td>.option resolution=1fs     <i>(default value)<\/i><\/td>     <td>9223s (~ 2.5 hrs)<\/td>\t\t   <\/tr>   <tr>     <td>.option resolution=10fs<\/td>     <td>92,233s (~ 25 hrs)<\/td>\t\t   <\/tr>   <tr>     <td>.option resolution=100fs<\/td>     <td>922,337s (~ 250 hrs)<\/td>\t\t   <\/tr>   <tr>     <td>.option resolution=1ps<\/td>     <td>9.22e6s (~ 2500 hrs)<\/td>\t\t   <\/tr> <\/table>  <\/body>"},r.SIMULATION_CONTROLS_ID="SimulationControls",r.ADVANCED_REF_ID="AdvancedReference",r.PLAY_STOP_BUTTON_ID="play_stop_simulation_button",r.SIM_TYPE_SELECTOR_ID="SimTypeSelector",r.END_TIME_GROUP_ID="end_time_input_group",r.END_TIME_ID="end_time_input",r.START_FREQ_GROUP_ID="start_freq_input_group",r.START_FREQ_ID="start_freq_input",r.END_FREQ_GROUP_ID="end_freq_input_group",r.END_FREQ_ID="end_freq_input",r.SIM_OUTPUT_BUTTON_ID="sim_output_button",r.DIALOG="#simulatorHelpDialog",r.MORE_INFO_ID="simulationMoreInfo",r.INTERRUPT_TIMEOUT=45e3,r.PROCESSING_RESULTS_TIMEOUT_1=5e3,r.PROCESSING_RESULTS_TIMEOUT_2=15e3,r}(Project.UndoableSection);n.SimulationMenu=i}(Sidebar||(Sidebar={})),function(n){var t=function(){function t(n,t,i,r,u){this.contextMenus={};this.categoryExclusions=["Popular","Shared Components","Glue Components","Datasheet Model Templates","Datasheet Models SVWebLib","DMB User Components"];this.defaultTooltipStyle={classes:"svw-tooltip"};this.defaultTooltipPosition={adjust:{x:0,y:30}};this.dmbTooltip="Automatically create a new model based on datasheet information";this.sch2VhdlTooltip="Automatically create a new model based on the active (visible) schematic";this.spiceTooltip="Create a SPICE component with the Component Editor";this.ceTooltip="Create a VHDL-AMS component with the Component Editor";this.createNewCompTooltipPosition={at:"right",adjust:{x:15,y:10}};this.partnerButtonTooltip="Pre-calibrated component models, by part number, from the manufacturers";this.partnerButtonTooltipStyle={classes:"svw-tooltip",tip:{corner:"bottom left"}};this.partnerButtonTooltipPosition={at:"right top",adjust:{x:0,y:-40}};this.partnerCategoryTooltips={Coilcraft:"Coilcraft power inductors"};this.partnerCategoryTooltipPosition={at:"bottom right",adjust:{x:0,y:-20}};this.table=Project.ComponentDataManager.SVWEB_LIB;this.searchPage=0;this.searchNumPerPage=10;this.searching=!1;this.dmbWindow=null;this.createCompClosing=!1;this.tooltipDelay=400;this.isSearchVisible=!1;this.surface=n;this.dataManager=t;this.dmbDataManager=Dmb.DataManager.getInstance();this.table=i;this.name=r;this.loadingCompsDeferred=u;this.container=$("<div><\/div>")}return t.prototype.getName=function(){return this.name},t.prototype.getDiv=function(){return this.container},t.prototype.init=function(){this.container.empty();this.loadCreateComp();this.loadSearchBox();this.loadPartnerComp();this.container.append('<div id="ghostSym"><\/div>');this.loadInitialData()},t.prototype.setEditingMode=function(){},t.prototype.clear=function(){},t.prototype.onClose=function(){},t.prototype.loadInitialData=function(){var i=this,n=this;$.when(this.dataManager.loadInitialData()).done(function(){n.closeAllTips();n.createSVWebPanelBar();n.createPartnerPanelBar();n.catHeaderHeight=i.getCategory(t.MY_FAVORITES_CATEGORY).find(".k-header").outerHeight();n.numCategories=$(t.PANEL_BAR+" li").length;n.partnerDivClosedHeight=$(t.PARTNER_COMP_DIV).outerHeight()-1;n.partnerDivMinOpenHeight=n.partnerDivClosedHeight+n.catHeaderHeight+186;n.table==Project.ComponentDataManager.SVWEB_LIB&&n.initModelingTools();n.refreshHeight();n.loadingCompsDeferred.resolve();$.when(n.dataManager.loadSVWebLibComponents()).done(function(){var i=n.getActiveCategory(),t;i&&(t=n.getCategoryName(i),n.isSVWebCategory(t)&&n.toggleCategory(t))});$.when(n.dataManager.loadUserComponents()).done(function(){var r=n.getActiveCategory(),i;r&&(i=n.getCategoryName(r),i==t.MY_COMPONENTS_CATEGORY&&n.toggleCategory(i))});$.when(n.dataManager.loadPartnerComponents()).done(function(){var i=n.getActiveCategory(),t;i&&(t=n.getCategoryName(i),n.isPartnerCategory(t)&&n.toggleCategory(t))})})},t.prototype.getCategoryID=function(n){return t.CAT_PREFIX_ID+n.replace(/ /g,"_")},t.prototype.getCategoryIDName=function(n){return t.CAT_PREFIX+n.replace(/ /g,"_")},t.prototype.getCategory=function(n){return $(this.getCategoryIDName(n))},t.prototype.getActiveCategory=function(){var i=$(t.PANEL_BAR),n=i.find(".k-state-active");return n.length==0&&(i=$(t.PARTNER_PANEL_BAR),n=i.find(".k-state-active"),n.length==0)?null:n},t.prototype.getActiveCategoryName=function(){var n=this.getActiveCategory();return n?this.getCategoryName(n):null},t.prototype.getCategoryName=function(n){var t=n.find(".symBrwsNameText");return t.length==0?null:t[0].textContent.trim()},t.prototype.getCategoryContent=function(n){return $(this.getCategoryIDName(n)+t.COMP_CONTENT_SUFFIX)},t.prototype.isSVWebCategory=function(n){var i=this.dataManager.getCategories(),r=this.dataManager.getPartnerCategories();return i.indexOf(n)!=-1&&r.indexOf(n)==-1&&n!=t.MY_COMPONENTS_CATEGORY},t.prototype.isPartnerCategory=function(n){var t=this.dataManager.getPartnerCategories();return t.indexOf(n)!=-1},t.prototype.getPartnerDivOpenHeight=function(){var i=$(t.CREATE_COMP_DIV).outerHeight()+$(t.SEARCH_BOX_DIV).outerHeight()+t.SIDEBAR_PADDING,r=i+this.catHeaderHeight,n,u,f;return window.innerHeight<r+this.partnerDivMinOpenHeight?window.innerHeight-r:(n=this.numCategories,this.isSearchVisible||--n,u=n*this.catHeaderHeight+8,f=window.innerHeight-i-u,Math.max(f,this.partnerDivMinOpenHeight))},t.prototype.getPartnerOpenHeight=function(){return $(t.PARTNER_COMP_DIV).outerHeight()-$(t.PARTNER_COMP_BUTTON_DIV).outerHeight()},t.prototype.getPanelBarHeight=function(n){n===void 0&&(n=!1);var i=n?this.partnerDivClosedHeight:$(t.PARTNER_COMP_DIV).outerHeight();return window.innerHeight-$(t.CREATE_COMP_DIV).outerHeight()-$(t.SEARCH_BOX_DIV).outerHeight()-i-t.SIDEBAR_PADDING-2},t.prototype.refreshHeight=function(){$(COMPONENT_BROWSER_DIV).outerHeight(window.innerHeight);this.isPartnerCompsOpen()&&($(t.PARTNER_COMP_DIV).height(this.getPartnerDivOpenHeight()),$(t.PARTNER_PANEL_BAR).height(this.getPartnerOpenHeight()));$(t.PANEL_BAR).height(this.getPanelBarHeight())},t.prototype.createSVWebPanelBar=function(){var n=this,r=this.dataManager.getCategories(),u=this.dataManager.getPartnerCategories(),i='<div id="'+t.PANEL_BAR_ID+'Div"><div id="'+t.PANEL_BAR_ID+'Organizer"><ul id="'+t.PANEL_BAR_ID+'"><li id="'+this.getCategoryID(t.SEARCH_RESULTS_CATEGORY)+'" style="display: none"><span class="symBrwsNameText">Search Results<\/span><div id="'+this.getCategoryID(t.SEARCH_RESULTS_CATEGORY)+t.COMP_CONTENT_SUFFIX+'"><\/div><\/li><li id="'+this.getCategoryID(t.MY_FAVORITES_CATEGORY)+'" class="k-state-active"><span class="symBrwsNameText">'+t.MY_FAVORITES_CATEGORY+'<\/span><div id="'+this.getCategoryID(t.MY_FAVORITES_CATEGORY)+t.COMP_CONTENT_SUFFIX+'"><\/div><\/li>';r.forEach(function(r){n.categoryExclusions.indexOf(r)==-1&&u.indexOf(r)==-1&&(i+='<li id="'+n.getCategoryID(r)+'"><span class="symBrwsNameText">'+r+'<\/span><div id="'+n.getCategoryID(r)+t.COMP_CONTENT_SUFFIX+'"><\/div><\/li>')});i+="<\/ul><\/div><\/div>";this.container.append(i);$(t.PANEL_BAR).kendoPanelBar({expandMode:"single",expand:this.onExpand,select:this.onPanelBarSelect})},t.prototype.createPartnerPanelBar=function(){var n=this,r=this.dataManager.getPartnerCategories(),i='<div id="'+t.PARTNER_PANEL_BAR_ID+'Div" style="display: none"><div id="'+t.PARTNER_PANEL_BAR_ID+'Organizer"><ul id="'+t.PARTNER_PANEL_BAR_ID+'">';r.forEach(function(r){i+='<li id="'+n.getCategoryID(r)+'"><span class="symBrwsNameText" style="display: none">'+r+'<\/span><div id="'+n.getCategoryID(r)+t.COMP_CONTENT_SUFFIX+'"><\/div><\/li>'});i+="<\/ul><\/div><\/div>";$(t.PARTNER_COMP_DIV).append(i);$(t.PARTNER_PANEL_BAR).kendoPanelBar({expandMode:"single",expand:this.onExpand,select:this.onPartnerPanelBarSelect});$.each($(t.PARTNER_PANEL_BAR).find(".k-header"),function(i,r){var f=$(r),u=$(r).children().first().text();f.append('<img class="symBrwsPartnerLogo" src="'+t.PARTNER_PATH+u+'.png"><\/img>');$(r).mouseenter(function(){n.showTooltip($(r),n.partnerCategoryTooltips[u],n.defaultTooltipStyle,n.partnerCategoryTooltipPosition)})})},t.prototype.onExpand=function(n){var i=surface.getComponentBrowserSidebar(),r=i.getCategoryName($(n.item));r==t.SEARCH_RESULTS_CATEGORY&&i.searching||i.toggleCategory(r)},t.prototype.onSelect=function(n,t){if($(n.item).hasClass("k-state-active")){var i=t.data("kendoPanelBar");i.collapse($("li",i.element),!0);$(".k-state-selected",i.element).removeClass("k-state-selected")}},t.prototype.onPanelBarSelect=function(n){var i=surface.getComponentBrowserSidebar();i.isPartnerCompsOpen()&&i.closePartnerComps();i.onSelect(n,$(t.PANEL_BAR))},t.prototype.onPartnerPanelBarSelect=function(n){surface.getComponentBrowserSidebar().onSelect(n,$(t.PARTNER_PANEL_BAR))},t.prototype.toggleCategory=function(n){if(this.getCategoryPanelBar(n).scrollTop(0),n==t.SEARCH_RESULTS_CATEGORY){this.showSearchResults();return}if(this.removeDomContents(n),this.isCatLoading(n)){this.showLoadingIcon(n);return}var i=this.getComps(n);i&&i.length!=0?(i.sort(this.dataManager.sortComponents),this.loadDomContents(n,i)):this.showNoCompsMessage(n)},t.prototype.isCatLoading=function(n){return n==t.MY_FAVORITES_CATEGORY?!1:n==t.MY_COMPONENTS_CATEGORY&&this.dataManager.isUserLoading()||this.isSVWebCategory(n)&&this.dataManager.isSVWebLoading()||this.isPartnerCategory(n)&&this.dataManager.isPartnerLoading()},t.prototype.addContextMenu=function(n,t){var i=new SVWebContextMenu.MenuContent(n),r;n.UserFavorite?i.addMenuElement("Remove Favorite",this.handleToggleFavorite):i.addMenuElement("Add Favorite",this.handleToggleFavorite);i.addSeparatorToMenu();i.addMenuElement("View/Copy Model",this.handleOpenCompEditor);this.isMemberOfOwnersGroup()&&i.addMenuElement("Promote Model",this.handleOpenCompMetaPromotion);(n.Author==Project.Settings.UUID||this.isMemberOfOwnersGroup())&&i.addMenuElement("Delete Model",this.handleDeleteComponent);r=SVWebContextMenu.MenuHelper.createMenu(i);r.bindMenuTo("#"+t);this.contextMenus[t]=r},t.prototype.updateContextMenu=function(n,t){this.contextMenus[t]&&(this.contextMenus[t].removeMenu(),this.addContextMenu(n,t))},t.prototype.removeContextMenus=function(){$.each(this.contextMenus,function(n,t){t.removeMenu()});this.contextMenus={}},t.prototype.showSearchResults=function(){var n=this.dataManager.getSearchResults();this.removeDomContents(t.SEARCH_RESULTS_CATEGORY);n&&n.length>0?(this.addDomComponents(n,t.SEARCH_RESULTS_CATEGORY,t.SEARCH_PREFIX),this.defineComponentEvents(t.SEARCH_PREFIX),n.length==(this.searchPage+1)*this.searchNumPerPage&&this.showFindMoreButton()):this.showNoCompsMessage(t.SEARCH_RESULTS_CATEGORY)},t.prototype.getComps=function(n){var r=this.dataManager.getComponents(),u=[],i=this.dataManager.getCompIndexesByCategory(n);return i&&i.length>0&&i.forEach(function(i){(n!=t.MY_COMPONENTS_CATEGORY||r[i].Author==Project.Settings.UUID)&&u.push(r[i])}),u},t.prototype.initModelingTools=function(){$(t.DMB_LINK).click(function(){this.dmbWindow=new Dmb.DmbWindow});$(t.SCH2VHDL_LINK).click(function(){var n=new Project.CeStructuralVhdlSplash(surface);n.showSch2VhdSplashDialog()});$(t.SPICE_LINK).click(function(){var n=new Project.SpiceSplash(surface);n.showSpiceSplashDialog()});$(t.CE_LINK).click(function(){Project.CeUtility.isOpen()||new Project.ModelEditor(surface,null,!1,Project.CE_MODEL_TYPE.VHDL,!1)})},t.prototype.toggleCreateCompDiv=function(){var n=this;this.createCompClosing||(this.createCompClosing=!0,$(t.CREATE_COMP_DRAWER).toggle("slide",null,"fast",function(){n.createCompClosing=!1}))},t.prototype.loadCreateComp=function(){var n=this,i=this,r;r='<div id="'+t.CREATE_COMP_DIV_ID+'"><button type="button" id="'+t.CREATE_COMP_BUTTON_ID+'" class="btn comp_browser_button">Create New Component<\/button><hr class="hr_sidebar"><div id="'+t.CREATE_COMP_DRAWER_ID+'"><div style="padding-top: '+t.SIDEBAR_PADDING+'px"><a href="#" id="'+t.DMB_LINK_ID+'" class="symBrwsNameText createCompOption">From Datasheet<\/a><a href="#" id="'+t.SCH2VHDL_LINK_ID+'" class="symBrwsNameText createCompOption">From Schematic<\/a><a href="#" id="'+t.CE_LINK_ID+'" class="symBrwsNameText createCompOption">From VHDL-AMS<\/a><a href="#" id="'+t.SPICE_LINK_ID+'" class="symBrwsNameText createCompOption">From SPICE<\/a><\/div><\/div><\/div>';this.container.append(r);$(t.CREATE_COMP_BUTTON).click(function(){i.toggleCreateCompDiv()});$(t.CREATE_COMP_DRAWER).mouseleave(function(){i.toggleCreateCompDiv()});$(t.DMB_LINK).mouseenter(function(){i.showTooltip($(t.DMB_LINK),n.dmbTooltip,n.defaultTooltipStyle,n.createNewCompTooltipPosition)});$(t.SCH2VHDL_LINK).mouseenter(function(){i.showTooltip($(t.SCH2VHDL_LINK),n.sch2VhdlTooltip,n.defaultTooltipStyle,n.createNewCompTooltipPosition)});$(t.SPICE_LINK).mouseenter(function(){i.showTooltip($(t.SPICE_LINK),n.spiceTooltip,n.defaultTooltipStyle,n.createNewCompTooltipPosition)});$(t.CE_LINK).mouseenter(function(){i.showTooltip($(t.CE_LINK),n.ceTooltip,n.defaultTooltipStyle,n.createNewCompTooltipPosition)})},t.prototype.loadSearchBox=function(){var n=this,i='<div id="'+t.SEARCH_BOX_DIV_ID+'"><input type="text" class="form-control" id="'+t.SEARCH_BOX_TEXT_ID+'" placeholder="Search Components..." /><\/div>';this.container.append(i);$(t.SEARCH_BOX_TEXT).keyup(function(){clearTimeout(n.timer);n.timer=setTimeout(function(){n.search()},150)})},t.prototype.loadPartnerComp=function(){var n=this,r=this,u='<div id="'+t.PARTNER_COMP_DIV_ID+'"><div class="symBrwsSplitter"><\/div><div id="'+t.PARTNER_COMP_BUTTON_DIV_ID+'"><button type="button" id="'+t.PARTNER_COMP_BUTTON_ID+'" class="btn comp_browser_button">'+t.PARTNER_COMP_BUTTON_SHOW_TEXT+"<\/button><\/div><\/div>",i;this.container.append(u);i=$(t.PARTNER_COMP_BUTTON);i.click(function(){r.togglePartnerComps()});i.mouseenter(function(){r.showTooltip($(t.PARTNER_COMP_BUTTON),n.partnerButtonTooltip,n.partnerButtonTooltipStyle,n.partnerButtonTooltipPosition)})},t.prototype.togglePartnerComps=function(){var r=this,n;this.closeAllTips();var u=$(t.PARTNER_COMP_DIV),f=$(t.PARTNER_COMP_BUTTON),i=200;this.isPartnerCompsOpen()?(n=$(t.PARTNER_PANEL_BAR).data("kendoPanelBar"),n.collapse($("li",n.element),!0),u.animate({height:this.partnerDivClosedHeight+"px"},i),$(t.PANEL_BAR).animate({height:this.getPanelBarHeight(!0)+"px"},i),f.html(t.PARTNER_COMP_BUTTON_SHOW_TEXT)):($(t.PARTNER_PANEL_BAR+"Div").show(),$(t.PARTNER_PANEL_BAR).data("kendoPanelBar").expand("> li:first",!0),n=$(t.PANEL_BAR).data("kendoPanelBar"),n.collapse($("li",n.element),!0),u.animate({height:this.getPartnerDivOpenHeight()+"px"},i,function(){$(t.PANEL_BAR).height(r.getPanelBarHeight());$(t.PARTNER_PANEL_BAR).height(r.getPartnerOpenHeight())}),f.html(t.PARTNER_COMP_BUTTON_HIDE_TEXT))},t.prototype.isPartnerCompsOpen=function(){return $(t.PARTNER_COMP_BUTTON).text()==t.PARTNER_COMP_BUTTON_HIDE_TEXT},t.prototype.closePartnerComps=function(){$(t.PARTNER_COMP_BUTTON).trigger("click")},t.prototype.removeDomContents=function(n){this.closeAllTips();this.removeContextMenus();this.getCategoryContent(n).empty()},t.prototype.loadDomContents=function(n,i){for(var u,f=[],r=0;r<i.length;++r)f.push(i[r]);u=n==t.MY_FAVORITES_CATEGORY?t.FAVE_PREFIX:t.COMP_PREFIX;this.addDomComponents(f,n,u);this.defineComponentEvents(u)},t.prototype.showNoCompsMessage=function(n){var i=this.getCategoryContent(n);switch(n){case t.SEARCH_RESULTS_CATEGORY:i.append('<div class="compBrowserMessage">No results found<\/div>');break;case t.MY_COMPONENTS_CATEGORY:i.append('<div class="compBrowserMessage">Create custom components by clicking the "Create New Component" button above.<\/div>');break;case t.MY_FAVORITES_CATEGORY:i.append('<div class="compBrowserMessage">Add components to your favorites from the right-click context menu.<\/div>');break;default:i.append('<div class="compBrowserMessage">Internal error: components could not be loaded.<\/div>')}},t.prototype.getCompIdSuffix=function(n){return Project.ComponentVhdlDto.getLib(n)+"_"+n.ComponentId},t.prototype.deleteComponent=function(n,i){for(var v,y,o,u,p,w=this,f=surface.getComponentBrowserSidebar(),s=surface.getComponentDataManager(),e=s.getComponent(n,i),h=[],c=s.getCategories(),l=!1,a=[],r=0;r<c.length;r++){for(u=0;u<this.categoryExclusions.length;u++)if(c[r]==this.categoryExclusions[u]){l=!0;break}if(l){l=!1;continue}else a.push(c[r])}for(v=!1,y=!1,r=0;r<e.Categories.length;r++){if(o=e.Categories[r],o==Project.ComponentDataManager.DMB_CATEGORY){y=!0;break}for(u=0;u<a.length;u++)a[u]==o&&(h.push(o),v=!0)}p=new Project.MultiBtnModalDialog("Confirm",'Are you sure you want to delete "'+e.Title+'"?<br>If you do, it will not be available to designs that use it.',["Yes","No"]);jQuery.when(p.queryUser()).done(function(i){i==Project.BUTTON.BTN1&&(kendo.ui.progress($(MAIN_EDITOR),!0),$.when(s.deleteComponent(n,e.ComponentId)).done(function(){kendo.ui.progress($(MAIN_EDITOR),!1);v||f.refreshCategory(t.MY_COMPONENTS_CATEGORY);f.refreshCategory(t.SEARCH_RESULTS_CATEGORY);for(var n=0;n<h.length;n++)f.refreshCategory(h[n]);y&&(f.dmbWindow&&f.dmbWindow.close(),w.dmbDataManager.deleteFromUsrDsArray(e.ComponentId))}))})},t.prototype.showLoadingIcon=function(n){this.closeAllTips();this.getCategoryContent(n).append('<img id="compCatLoading" src="'+t.SPINNER_ICON+'" class="centeredImage" style="padding: 10px; height: 30px; width: 30px;">')},t.prototype.getCompSplitter=function(){return'<div class="symBrwsSplitter"><\/div>'},t.prototype.addDomComponents=function(n,i,r){for(var e=this.getCategoryContent(i),u=0;u<n.length;u++){var o=this.getCompIdSuffix(n[u]),s=r+o,f='<div id="'+s+'" class="symBrwsContent">';f+='<div class="symBrwsImg">'+n[u].Img+'<\/div><div class="symBrwsName"><div class="symBrwsNameText">'+n[u].Title+"<\/div><\/div>";i==t.SEARCH_RESULTS_CATEGORY&&Project.ComponentVhdlDto.getLib(n[u])==Project.ComponentDataManager.USER_LIB&&(f+='<img class="user_icon" src="'+t.USER_ICON+'">');f+='<\/div><div style="clear: both"><\/div>';u<n.length-1&&(f+=this.getCompSplitter());e.append(f)}},t.prototype.showFindMoreButton=function(){var n=this.getCategoryContent(t.SEARCH_RESULTS_CATEGORY);n.append(this.getCompSplitter()+'<button type="button" class="btn comp_browser_button find_more_button" id="compFindMore" onclick="surface.getComponentBrowserSidebar().findMore()">Find More<\/button>')},t.prototype.hideFindMoreButton=function(){$("#compFindMore").remove()},t.prototype.search=function(){var i=this,n;this.closeAllTips();this.isPartnerCompsOpen()&&this.closePartnerComps();var u=$(t.PANEL_BAR).data("kendoPanelBar"),f=this.getCategoryIDName(t.SEARCH_RESULTS_CATEGORY),r=$(f);r.show();this.isSearchVisible=!0;this.hideFindMoreButton();this.searchPage==0&&this.removeDomContents(t.SEARCH_RESULTS_CATEGORY);this.searching=!0;u.expand(r,!0);this.searching=!1;n=$(t.SEARCH_BOX_TEXT).val().toLowerCase().trim();n.length==0?this.showNoCompsMessage(t.SEARCH_RESULTS_CATEGORY):(this.showLoadingIcon(t.SEARCH_RESULTS_CATEGORY),$.when(i.dataManager.search(n,this.searchPage,this.searchNumPerPage)).done(function(){i.showSearchResults()}))},t.prototype.findMore=function(){this.searchPage++;this.search()},t.prototype.isVisible=function(n){var t=this.getCategoryPanelBar(n);return t&&t.length>0},t.prototype.openCategory=function(n){var r,u;if(this.isVisible(n)){var f=this.dataManager.getPartnerCategories(),t=this.isPartnerCategory(n),i=this.isPartnerCompsOpen();(t&&!i||!t&&i)&&this.togglePartnerComps();n==this.getActiveCategoryName()?this.refreshCategory(n):(r=this.getCategoryPanelBar(n).data("kendoPanelBar"),u=this.getCategory(n),r.expand(u,!0))}},t.prototype.refreshCategory=function(n){if(n==this.getActiveCategoryName()){var t=this.getCategory(n);this.toggleCategory(n)}},t.prototype.getCategoryPanelBar=function(n){return this.isPartnerCategory(n)?$(t.PARTNER_PANEL_BAR):$(t.PANEL_BAR)},t.prototype.symbolClickHandler=function(n){this.surface.getDesign().placeComponent(n)},t.prototype.symbolDragStartHandler=function(n,t){var h=this,u,r,s,i;n.preventDefault();this.closeAllTips();var e=t.Img,a=0,v=0;if(this.isNumber(t.Cx)&&(a=t.Cx),this.isNumber(t.Cy)&&(v=t.Cy),u=1/this.surface.getScale(),r=Project.Utility.getSVGViewbox(e),e=Project.Utility.scaleSVGWidthAndHeight(e,r,u),e&&r){s=$("#ghostSym");s.html(e);var f=Math.round((a-r.x)*u),o=Math.round((v-r.y)*u),c=0,l=0;if(t.Pins&&t.Pins.length==1)switch(t.Pins[0].Orientation){case Project.PinOrientation.North:i=Math.round((r.height-t.Pins[0].Y)*u);l=i-o;o=i;break;case Project.PinOrientation.South:i=Math.round((t.Pins[0].Y-r.height)*u);l=i-o;o=i;break;case Project.PinOrientation.East:i=Math.round((t.Pins[0].X-r.width)*u);c=i-f;f=i;break;case Project.PinOrientation.West:i=Math.round((r.width-t.Pins[0].X)*u);c=i-f;f=i}s.css({"z-index":12800,cursor:"move",position:"absolute",opacity:.4,left:n.pageX-f,top:n.pageY-f});s.show();$(document).on("mousemove.compBrowser",function(n){$("#ghostSym").css({left:n.pageX-f,top:n.pageY-o})});$(document).on("keydown.compBrowser",function(n){n.which==Project.Design.EscKey&&h.terminatePlacement()});$("#ghostSym, "+SCHEMATIC).on("mouseup.compBrowser",function(n){var i=h.getCompPlacementBounds(),r;n.pageX>i[0]&&n.pageX<i[1]&&n.pageY>i[2]&&n.pageY<i[3]&&(n.pageX-=c,n.pageY-=l,r=Project.Utility.eventToPoint(surface.getDesign(),n),surface.getDesign().placeComponent(t,r,!0));h.terminatePlacement()})}},t.prototype.terminatePlacement=function(){$(document).unbind("mousemove.compBrowser");$(SCHEMATIC).unbind("mouseup.compBrowser");$("#ghostSym").unbind("mouseup.compBrowser");$("#ghostSym").hide()},t.prototype.getComponentFromDivId=function(n,t){var i=t.substring(n.length,t.lastIndexOf("_")),r=t.substring(t.lastIndexOf("_")+1);return this.dataManager.getComponent(i,r)},t.prototype.defineComponentEvents=function(n){var i=this,t=this,r=$("div[id^="+n+"]"),u;r.on("mouseup",function(r){var f,e,u;Messaging.Handler.sendSetFocusMessage();f=t.getComponentFromDivId(n,r.currentTarget.id);switch(r.which){case 1:t.symbolClickHandler(f);break;case 3:r.preventDefault();e=i.getCompIdSuffix(f);u=n+e;i.contextMenus[u]||(i.addContextMenu(f,u),i.contextMenus[u]&&$("#"+u).trigger("mouseup"))}});r.draggable({start:function(i){Messaging.Handler.sendSetFocusMessage();t.symbolDragStartHandler(i,t.getComponentFromDivId(n,i.currentTarget.id))}});u=function(i){t.showComponentToolTip($(this),t.getComponentFromDivId(n,i.currentTarget.id))};r.on("mouseenter",u)},t.prototype.closeAllTips=function(){$(".qtip").qtip("hide")},t.prototype.isNumber=function(n){return!isNaN(parseFloat(n))&&isFinite(n)},t.prototype.getCompPlacementBounds=function(){var t=[],r=$(SCHEMATIC_PANE).width(),i=this.surface.getSidebarManager(),u=i.getVisibleWidth(n.Orientation.LEFT),f=r-i.getVisibleWidth(n.Orientation.RIGHT),e=$(SCHEMATIC_PANE).height();return t.push(u),t.push(f),t.push(0),t.push(e),t},t.prototype.showComponentToolTip=function(n,i){var o=this,e;if(!i){console.warn("Tried to hover without active tooltip");return}var r=i.DescriptionToolTip,u=i.Description,f='<div class="comp_browser_text">';r||u?(r&&(r=r.trim()),u&&(u=u.trim()),r&&r.length!=0||(r=i.Title),f+=r+"<\/div>",u&&u.length>0&&(f+='<input type="hidden" id="symBrwsActiveCompTitle'+i.ComponentId+'" value="'+i.Title+'"><input type="hidden" id="symBrwsActiveCompDesc'+i.ComponentId+'" value="'+i.Description.replace(/"/g,"&quot;")+'">',f+=Project.Utility.getMoreInfoHtml(t.MORE_INFO,"white","3px"))):f+="No info available<\/div>";e=function(){setTimeout(function(){$("#"+t.MORE_INFO).click(function(n){var t=$(n.currentTarget.parentElement),i=t.find("input[id^=symBrwsActiveCompTitle]").val(),r=t.find("input[id^=symBrwsActiveCompDesc]").val();Project.Component.ShowDescription(i,r)})},o.tooltipDelay)};this.showTooltip(n,f,this.defaultTooltipStyle,this.defaultTooltipPosition,e)},t.prototype.showTooltip=function(n,t,i,r,u){u===void 0&&(u=null);var f={overwrite:!1,content:t,style:i,position:r,show:{ready:!0,delay:this.tooltipDelay},hide:{fixed:!0,delay:this.tooltipDelay},events:{hide:function(){$(this).qtip("destroy")}}};u&&(f.events.show=u);n.qtip(f)},t.prototype.updateFavorite=function(t){t.UserFavorite=t.UserFavorite==!0?!1:!0;t.UserFavorite?this.dataManager.addFavorite(Project.ComponentVhdlDto.getLib(t),t.ComponentId):this.dataManager.deleteFavorite(Project.ComponentVhdlDto.getLib(t),t.ComponentId);var i=surface.getComponentBrowserSidebar();i.refreshCategory(n.ComponentBrowser.MY_FAVORITES_CATEGORY)},t.prototype.handleFavoriteServerError=function(n,t){this.updateFavorite(n);Project.MessageManager.showWarningMessage("Could not update your favorites. "+t)},t.prototype.getCompDivId=function(n,i){var r;return r=n==t.SEARCH_RESULTS_CATEGORY?t.SEARCH_PREFIX:n==t.MY_FAVORITES_CATEGORY?t.FAVE_PREFIX:t.COMP_PREFIX,r+this.getCompIdSuffix(i)},t.prototype.handleToggleFavorite=function(n){var t=surface.getComponentBrowserSidebar(),i=t.dataManager.getComponent(Project.ComponentVhdlDto.getLib(n),n.ComponentId),r;i&&(t.updateFavorite(i),$.ajax(Project.Settings.APIURI()+"/favoriteComponents?library="+Project.ComponentVhdlDto.getLib(n)+"&componentID="+n.ComponentId,{dataType:"json",contentType:"application/json;charset=utf-8",type:i.UserFavorite?"POST":"DELETE",success:function(n){n&&t.handleFavoriteServerError(i,n)},error:function(n){t.handleFavoriteServerError(i,n.statusText)}}),r=t.getCompDivId(t.getActiveCategoryName(),n),t.updateContextMenu(n,r))},t.prototype.handleDeleteComponent=function(n){for(var i="SVWebLib",t=0;t<n.Categories.length;t++)if(n.Categories[t]=="My Components"){i="UserLib";break}surface.getComponentBrowserSidebar().deleteComponent(i,n.ComponentId)},t.prototype.handleOpenCompEditor=function(n){Project.CeUtility.isOpen()||new Project.ModelEditor(surface,n,!0,n.ModelType,!1)},t.prototype.handleOpenCompMetaPromotion=function(n){var i,t;if(!Project.CeUtility.isOpen()){for(i="SVWebLib",t=0;t<n.Categories.length;t++)if(n.Categories[t]=="My Components"){i="UserLib";break}new Project.CompMetadataPlusPromotion(i,n.ComponentId)}},t.prototype.isMemberOfOwnersGroup=function(){return Project.Settings.isProductionMode()||Project.Settings.UUID!=Project.CeUtility.SCOTT_ID&&Project.Settings.UUID!=Project.CeUtility.MIKE_ID?!1:!0},t.CREATE_COMP_DIV_ID="createCompDiv",t.CREATE_COMP_DIV="#"+t.CREATE_COMP_DIV_ID,t.CREATE_COMP_DRAWER_ID="createCompDrawer",t.CREATE_COMP_DRAWER="#"+t.CREATE_COMP_DRAWER_ID,t.CREATE_COMP_BUTTON_ID="createCompButton",t.CREATE_COMP_BUTTON="#"+t.CREATE_COMP_BUTTON_ID,t.DMB_LINK_ID="dmbOption",t.DMB_LINK="#"+t.DMB_LINK_ID,t.SCH2VHDL_LINK_ID="sch2VhdlOption",t.SCH2VHDL_LINK="#"+t.SCH2VHDL_LINK_ID,t.SPICE_LINK_ID="spiceOption",t.SPICE_LINK="#"+t.SPICE_LINK_ID,t.CE_LINK_ID="ceOption",t.CE_LINK="#"+t.CE_LINK_ID,t.SEARCH_BOX_DIV_ID="searchBoxDiv",t.SEARCH_BOX_DIV="#"+t.SEARCH_BOX_DIV_ID,t.SEARCH_BOX_TEXT_ID="searchBoxText",t.SEARCH_BOX_TEXT="#"+t.SEARCH_BOX_TEXT_ID,t.PARTNER_COMP_DIV_ID="partnerCompDiv",t.PARTNER_COMP_DIV="#"+t.PARTNER_COMP_DIV_ID,t.PARTNER_COMP_BUTTON_DIV_ID="partnerCompButtonDiv",t.PARTNER_COMP_BUTTON_DIV="#"+t.PARTNER_COMP_BUTTON_DIV_ID,t.PARTNER_COMP_BUTTON_ID="partnerCompButton",t.PARTNER_COMP_BUTTON="#"+t.PARTNER_COMP_BUTTON_ID,t.PANEL_BAR_ID="compBrowserPanelBar",t.PANEL_BAR="#"+t.PANEL_BAR_ID,t.PARTNER_PANEL_BAR_ID="compBrowserPartnerPanelBar",t.PARTNER_PANEL_BAR="#"+t.PARTNER_PANEL_BAR_ID,t.CAT_PREFIX_ID="compBrowserCat_",t.CAT_PREFIX="#"+t.CAT_PREFIX_ID,t.SEARCH_PREFIX="compBrowserSearch_",t.FAVE_PREFIX="compBrowserFave_",t.COMP_PREFIX="compBrowserComp_",t.COMP_CONTENT_SUFFIX="_Content",t.MORE_INFO="compBrowserMoreInfo",t.SEARCH_RESULTS_CATEGORY="Search Results",t.MY_FAVORITES_CATEGORY="My Favorites",t.MY_COMPONENTS_CATEGORY="My Components",t.PARTNER_COMP_BUTTON_SHOW_TEXT="Show Partner Components",t.PARTNER_COMP_BUTTON_HIDE_TEXT="Hide Partner Components",t.PARTNER_PATH="/Content/images/Partners/",t.USER_ICON="/Content/images/userIcon.png",t.SPINNER_ICON="/Content/images/spinner.gif",t.SEARCH_ICON="icon-search",t.SIDEBAR_PADDING=10,t}();n.ComponentBrowser=t}(Sidebar||(Sidebar={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var r=function(n){function r(u,f,e){var o=this,h,c,l,a,v,y,p;n.call(this,u);this.isShown=!1;this.isManualOptionsShown=!1;this.buttons=[];this.tableNumRow=9;this.simulationSidebar=e;this.panel=$('<div id="'+r.PANEL_ID+'" style="margin-top: 10px; padding 5px; outline: none;"><\/div>');f.append(this.panel);this.panel.append("<br/>");this.buttons=[];h=new t(Project.AdvancedOptions.BALANCE_GROUP_VALUE_NAME,Project.AdvancedOptions.SPEED,null);c=new i(Project.AdvancedOptions.SPEED_NAME,Project.AdvancedOptions.SPEED_TOOLTIP,h);this.buttons.push(c);l=new t(Project.AdvancedOptions.BALANCE_GROUP_VALUE_NAME,Project.AdvancedOptions.BALANCE,null);a=new i(Project.AdvancedOptions.BALANCE_NAME,Project.AdvancedOptions.BALANCE_TOOLTIP,l,!0);this.buttons.push(a);v=new t(Project.AdvancedOptions.BALANCE_GROUP_VALUE_NAME,Project.AdvancedOptions.ACCURACY,null);y=new i(Project.AdvancedOptions.ACCURACY_NAME,Project.AdvancedOptions.ACCURACY_TOOLTIP,v);this.buttons.push(y);this.balanceGroupId=this.addRadioGroup(this.panel,Project.AdvancedOptions.BALANCE_GROUP_NAME,this.buttons);this.panel.append('<hr class="hr_sidebar" />');p=new t(Project.AdvancedOptions.TIME_RESOLUTION_VALUE_NAME,Project.AdvancedOptions.TIME_RESOLUTION_SELECTED,Project.AdvancedOptions.TIME_RESOLUTION);this.timeResButton=new i(Project.AdvancedOptions.TIME_RESOLUTION_NAME,Project.AdvancedOptions.TIME_RESOLUTION_TOOLTIP,p);this.addCheckBox(this.panel,this.timeResButton);this.panel.append('<br style="padding: 3px" />');var w=new t(Project.AdvancedOptions.CONVERGENCE_ITL1_VALUE_NAME,Project.AdvancedOptions.CONVERGENCE_ITL1_SELECTED,Project.AdvancedOptions.CONVERGENCE_ITL1),b=new t(Project.AdvancedOptions.CONVERGENCE_ITL4_VALUE_NAME,Project.AdvancedOptions.CONVERGENCE_ITL4_SELECTED,Project.AdvancedOptions.CONVERGENCE_ITL4),s=[];s.push(w);s.push(b);this.conversionCheckbox=new i(Project.AdvancedOptions.CONVERGENCE_NAME,Project.AdvancedOptions.CONVERGENCE_TOOLTIP,s);this.addCheckBox(this.panel,this.conversionCheckbox);this.panel.append('<hr class="hr_sidebar" />');this.manualOptionsRefId=r.MANUAL_OPTIONS_REF_ID+r.GLOBAL_BUTTON_ID++;this.manualOptionsRef=$('<div><a href="#" id="'+this.manualOptionsRefId+'" class="sidebar_text_label" style ="margin-left: 10px">'+r.manualOptionsPanelName+"<\/a><\/div>");this.panel.append(this.manualOptionsRef);this.panel.append("<br />");this.manualOptionsRef.click(function(){o.manualOptionsTable?o.showHideManualOptions(!o.isManualOptionsShown):o.addManualOptionsTable(o.panel)});this.manualOptionsRef.qtip({content:{text:Project.AdvancedOptions.MANUAL_OPTIONS_TOOLTIP},position:{my:"top right",at:"top left"},style:{classes:"svw-tooltip"}})}return __extends(r,n),r.prototype.getState=function(){var n=new Project.AdvancedOptionsState,t;return n.Eps=this.getBalanceGroupValue(),n.Hmin=this.getTimeResolution(),t=this.getConvergence(),n.Itl1=t.itl1,n.Itl4=t.itl4,n.ManualOptions=this.getManualOptions(),n},r.prototype.stateChanged=function(n){var t=n.getSaveData(),i=this.getState();return t.Eps!=i.Eps||t.Hmin!=i.Hmin||t.Itl1!=i.Itl1||t.Itl4!=i.Itl4||t.ManualOptions!=i.ManualOptions},r.prototype.setState=function(n){var i,r,u,f,e,t;n?(i=n.Eps,r=n.Hmin,u=n.Itl1,f=n.ManualOptions):(e=new Project.AdvancedOptions,t=e.getSaveData(),i=t.Eps,r=t.Hmin,u=t.Itl1,f=t.ManualOptions);this.checkRadioButtonByValue(i);this.checkCheckboxByValue(Project.AdvancedOptions.TIME_RESOLUTION_VALUE_NAME,r,this.timeResButton);this.checkCheckboxByValue(Project.AdvancedOptions.CONVERGENCE_ITL1_VALUE_NAME,u,this.conversionCheckbox);this.setManualOptions(f)},r.prototype.checkRadioButtonByValue=function(n){for(var r,i,t=0;t<this.buttons.length;t++)for(r=this.buttons[t],i=0;i<r.values.length;i++)r.values[i].checkedValue==n&&this.setRadioButtonChecked(this.buttons[t].buttonId)},r.prototype.checkCheckboxByValue=function(n,t,i){for(var r=0;r<i.values.length;r++)i.values[r].valueName==n&&(i.values[r].checkedValue==t?this.setCheckBox(i.buttonId,!0):i.values[r].uncheckedValue==t&&this.setCheckBox(i.buttonId,!1))},r.prototype.dumpSettings=function(){var n="",e=this.getRadioButtonValue(Project.AdvancedOptions.BALANCE_GROUP_NAME),i,r,u,f,t;return n=e+" is selected \n Eps = "+this.getBalanceGroupValue(),i=this.isCheckBoxSelected(this.timeResButton),r=i?"is checked":"is not checked",n=n+"\n\n ("+Project.AdvancedOptions.TIME_RESOLUTION_NAME+" "+r+")\n Hmin = "+this.getTimeResolution(),u=this.isCheckBoxSelected(this.conversionCheckbox),f=u?"is checked":"is not checked",n=n+"\n\n ("+Project.AdvancedOptions.CONVERGENCE_NAME+" "+f+"): ",t=this.getConvergence(),n=n+"\n    Itl1 = "+t.itl1,n=n+"\n    Itl4 = "+t.itl4,n+"\n\n Expert options = "+this.getManualOptions()},r.prototype.getManualOptions=function(){var n="";return $("input.myrow").each(function(){var t=$(this).val();t&&t!=""&&(n+=t+"\n")}),n},r.prototype.setManualOptions=function(n){if(n&&n!=""){this.manualOptionsTable||this.addManualOptionsTable(this.panel);var i=n.split("\n"),t=0;$("input.myrow").each(function(){t<i.length&&i[t]?$(this).val(i[t]):$(this).val("");t++})}else this.manualOptionsTable&&$("input.myrow").each(function(){$(this).val("")})},r.prototype.getBalanceGroupValue=function(){for(var t=this.getRadioButtonValue(Project.AdvancedOptions.BALANCE_GROUP_NAME),n=0;n<this.buttons.length;n++)if(t==this.buttons[n].buttonName)return""+this.buttons[n].values[0].checkedValue;return""+Project.AdvancedOptions.SVWEB_DEFAULT_EPS},r.prototype.getTimeResolution=function(){return this.isCheckBoxSelected(this.timeResButton)?Project.AdvancedOptions.TIME_RESOLUTION_SELECTED:Project.AdvancedOptions.TIME_RESOLUTION},r.prototype.getConvergence=function(){return this.isCheckBoxSelected(this.conversionCheckbox)?{itl4:Project.AdvancedOptions.CONVERGENCE_ITL4_SELECTED,itl1:Project.AdvancedOptions.CONVERGENCE_ITL1_SELECTED}:{itl4:Project.AdvancedOptions.CONVERGENCE_ITL4,itl1:Project.AdvancedOptions.CONVERGENCE_ITL1}},r.prototype.addManualOptionsTable=function(n){var e,u,i,f,t;for(this.manualOptionsTableId=r.MANUAL_OPTIONS_TABLE_ID+r.GLOBAL_BUTTON_ID++,this.manualOptionsTable=$('<div id="'+this.manualOptionsTableId+'" class="mytable" style="overflow: auto; height: 150px;"><\/div>'),e=1,u=$('<div style="padding: 0px"><table style="width: 100%"><\/table><\/div>'),i=0;i<this.tableNumRow;++i)f=document.createElement("tr"),u.append($(f)),t=document.createElement("input"),t.setAttribute("id",r.MANUAL_OPTION_ID+i),t.setAttribute("class","myrow"),f.appendChild(t),e++%2==1?$(t).addClass("sidebar_alternate_row"):$(t).addClass("sidebar_first_row"),this.manualOptionsTable.append(u);n.append(this.manualOptionsTable);this.showHideManualOptions(!0)},r.prototype.show=function(){this.panel.show();$("div#"+r.PANEL_ID+" > div").show();$("div#"+r.PANEL_ID+" > hr").show();this.isShown=!0},r.prototype.hide=function(){$("div#"+r.PANEL_ID+" > div").hide();$("div#"+r.PANEL_ID+" > hr").hide();this.panel.hide();this.isShown=!1},r.prototype.toggleVisibility=function(){this.isShown?this.hide():this.show()},r.prototype.showHideManualOptions=function(n){var f=this,i=this.manualOptionsTableId,t,u;if(n)for($("div#"+i+" > div").show(),$("div#"+i+" > hr").show(),$("div#"+i).show(),t=0;t<this.tableNumRow;++t)u=$("#"+r.MANUAL_OPTION_ID+t),this.defineUndoEvents(u),u.bind("blur change",function(){f.simulationSidebar&&f.simulationSidebar.setAdvancedOptions()});else{for(t=0;t<this.tableNumRow;++t)u=$("#"+r.MANUAL_OPTION_ID+t),u.unbind();$("div#"+i+" > div").hide();$("div#"+i+" > hr").hide();$("div#"+i).hide()}this.isManualOptionsShown=n},r.prototype.addRadioGroup=function(n,t,i){var o=r.GLOBAL_RADIO_GROUP_ID++,f="advancedPanel_"+t+o,e=$('<div id="'+f+'"><\/div>'),u;for(n.append(e),u=0;u<i.length;u++)this.addRadioButton(e,t,f,i[u]);return f},r.prototype.addRadioButton=function(n,t,i,u){var s=this,e="svw_radiobutton"+r.GLOBAL_BUTTON_ID++;u.buttonId=e;var h=u.buttonName,f=$("<div><\/div>"),o=$('<input type="radio" id = "'+e+'" name = "'+t+'" value = "'+h+'" style="margin-left: 20px; margin-right: 10px;"/>'),c=$('<label for= "'+e+'">'+u.buttonName+"<\/label>");u.isSelected&&o.attr("checked","true");n.append(f);f.append(o);f.append(c);f.qtip({content:{text:u.buttonTooltip},position:{my:"top right",at:"top left"},style:{classes:"svw-tooltip"}});o.click(function(){s.simulationSidebar&&s.simulationSidebar.setAdvancedOptions()})},r.prototype.getRadioButtonValue=function(n){var t=$("input[name="+n+"]:radio:checked");return t.length>0?t.val():null},r.prototype.setRadioButtonChecked=function(n){var t=$("#"+n);t.length>0&&t.prop("checked",!0)},r.prototype.isCheckBoxSelected=function(n){var i=$("input:checkbox:checked"),t;if(i.length>0)for(t=0;t<i.length;t++)if($(i[t]).attr("id")==n.buttonId)return!0;return!1},r.prototype.setCheckBox=function(n,t){var i=$("#"+n);i.length>0&&i.prop("checked",t)},r.prototype.addCheckBox=function(n,t){var e=this,u="svw_checkbox"+r.GLOBAL_BUTTON_ID++;t.buttonId=u;var o=t.buttonName,i=$("<div />"),f=$('<input type="checkbox" id = "'+u+'" value = "'+o+'" style="margin-left: 20px; margin-right: 10px; vertical-align: top;"/>'),s=$('<label for= "'+u+'">'+o+"<\/label>");t.isSelected&&f.attr("checked","true");n.append(i);i.append(f);i.append(s);i.qtip({content:{text:t.buttonTooltip},position:{my:"top right",at:"top left"},style:{classes:"svw-tooltip"}});f.click(function(){e.simulationSidebar&&e.simulationSidebar.setAdvancedOptions()})},r.PANEL_ID="AdvancedSettingsPanel",r.MANUAL_OPTIONS_REF_ID="ExpertButton",r.MANUAL_OPTIONS_TABLE_ID="ManualOptionsTable",r.MANUAL_OPTION_ID="manual_option_",r.manualOptionsPanelName="Manual Options Entry",r.GLOBAL_BUTTON_ID=0,r.GLOBAL_RADIO_GROUP_ID=0,r}(Project.UndoableSection),t,i;n.AdvancedPanel=r;t=function(){function n(n,t,i){this.valueName=n;this.checkedValue=t;this.uncheckedValue=i!=null?i:this.checkedValue}return n}();n.ButtonValuesSet=t;i=function(){function n(n,t,i,r){this.isSelected=!1;this.buttonName=n;this.buttonTooltip=t;this.values=[];$.isArray(i)?this.values=i:this.values.push(i);r&&(this.isSelected=!0)}return n}();n.ButtonDescription=i}(Sidebar||(Sidebar={})),function(n){var t,f,r,u,i;(function(n){n[n.CURRENT=0]="CURRENT";n[n.STALE=1]="STALE";n[n.DIFF_REVISION=2]="DIFF_REVISION"})(n.StaleState||(n.StaleState={}));t=n.StaleState;f=function(){function i(i,r){if(this.simulationResultInfo=new n.SimulationResultInfo,this.simulationParameters=new u(i,r),r){var f=r;this.simulationResultInfo.load(f.simulationResultInfo)}this.staleState=t.CURRENT;this.revisionID=i.getRevisionID()}return i.prototype.getSimulationParameters=function(){return this.simulationParameters},i.prototype.getSimulationResultInfo=function(){return this.simulationResultInfo},i.prototype.getSaveData=function(){var n=new r;return n.simulationParameters=this.getSimulationParameters().getSaveData(),n.simulationResultInfo=this.simulationResultInfo.getSaveData(),n},i.prototype.hasResults=function(){return this.simulationResultInfo.hasResults()},i.prototype.getStaleState=function(){return this.staleState},i.prototype.clearResults=function(n){this.getSimulationResultInfo().clear();this.setRevisionID(n);this.staleState=t.CURRENT},i.prototype.updateStaleState=function(n){this.staleState=this.revisionID==n?t.STALE:t.DIFF_REVISION},i.prototype.getRevisionID=function(){return this.revisionID},i.prototype.setRevisionID=function(n){this.revisionID=n},i}();n.Simulation=f;r=function(){function n(){this.simulationParameters=new i}return n.prototype.compareTo=function(n,t,i,r){return this.simulationParameters.compareTo(n.simulationParameters,t,i,r)?this.simulationResultInfo.compareTo(n.simulationResultInfo,t,i,r)?!0:!1:!1},n}();n.SimulationState=r;u=function(){function t(t,i){this.design=t;this.advancedOptions=new n.AdvancedOptions;i?(i.simulationParameters.transParams?this.setTransParams(new n.TransientSimulation(t,i.simulationParameters.transParams)):this.setTransParams(new n.TransientSimulation(t)),i.simulationParameters.freqParams?this.setFreqParams(new n.FrequencySimulation(t,i.simulationParameters.freqParams)):this.setFreqParams(new n.FrequencySimulation(t)),this.setAdvancedOptions(i.simulationParameters.advancedOptions),this.setActiveSimulation(i.simulationParameters.activeSimulation)):(this.setTransParams(new n.TransientSimulation(t)),this.setFreqParams(new n.FrequencySimulation(t)),this.setActiveSimulation(n.SIMULATION_TYPE.TIME_DOMAIN))}return t.prototype.getSaveData=function(){var n=new i;return this.getTransParams()&&(n.transParams=this.getTransParams().getSaveData()),this.getFreqParams()&&(n.freqParams=this.getFreqParams().getSaveData()),n.advancedOptions=this.getAdvancedOptions().getSaveData(),n.activeSimulation=this.getActiveSimulation(),n},t.prototype.getTransParams=function(){return this.transParams},t.prototype.setTransParams=function(n){this.transParams=n},t.prototype.getFreqParams=function(){return this.freqParams},t.prototype.setFreqParams=function(n){this.freqParams=n},t.prototype.getActiveSimulation=function(){return this.activeSimulation},t.prototype.setActiveSimulation=function(n){this.activeSimulation=n},t.prototype.setAdvancedOptions=function(n){this.advancedOptions.setState(n)},t.prototype.getAdvancedOptions=function(){return this.advancedOptions},t}();n.AllSimulationParameters=u;i=function(){function t(){this.activeSimulation=n.SIMULATION_TYPE.NONE}return t.prototype.compareTo=function(n,t,i,r){return this.advancedOptions.compareTo(n.advancedOptions,t+"/AdvancedOptions",i,r)?this.transParams&&!this.transParams.compareTo(n.transParams,t,i,r)?!1:this.freqParams&&!this.freqParams.compareTo(n.freqParams,t,i,r)?!1:!0:!1},t}();n.AllSimulationParametersState=i}(Project||(Project={}));var SCHEMATIC_ID="schematic",SCHEMATIC="#schematic",MAIN_EDITOR="#main_editor",SCHEMATIC_PANE="#schematic-pane",SCHEMATIC_TOOLBAR="#schematic_toolbar",VIEWER_PANE="#viewer-pane",VIEWER_WINDOW_ID="viewerWindow",FILE_SIDEBAR_ID="file_sidebar",COMPONENT_BROWSER_SIDEBAR_ID="component_browser",COMPONENT_BROWSER_DIV="#componentBrowserDiv",COMPONENT_BROWSER_DIV_ID="componentBrowserDiv",COMPONENT_BROWSER_BOTTOM_MARGIN=40,SIMULATION_SIDEBAR_ID="simulation",LEFT_SIDEBAR="#left_sidebar",RIGHT_SIDEBAR="#right_sidebar",SIDEBAR_WIDTH=200,TOGGLE_LEFT_SIDEBAR="#toggle_left_sidebar",TOGGLE_RIGHT_SIDEBAR="#toggle_right_sidebar",TOGGLE_LEFT_SIDEBAR_IMG="#toggle_left_sidebar_img",TOGGLE_RIGHT_SIDEBAR_IMG="#toggle_right_sidebar_img",TOGGLE_VIEWER="#toggle_viewer",TOGGLE_VIEWER_IMG="#toggle_viewer_img",PROPERTY_EDITOR_ID="property_editor",PROPERTY_EDITOR="#property_editor",LOADING_CONTENT="#loading_content",LOADING_MESSAGE="#loading_message",LOADING_MESSAGE_TEXT="#loading_message_text",LOADING_DESIGN="Loading the design...",UNDO_STACK_DIALOG_ID="undo_stack_dialog",UNDO_STACK_DIALOG_CLASS="undo_stack_dialog_class",GRID_VAL_MSG="#gridValMsg",PROP_GRID_WINDOW="#propGridWindow",SYMBOL_LABEL_FORM="#symbolLabelForm",PROP_GRID="#propGrid",DMB_WINDOW="#dmbWindow",DMB_WINDOW_CLOSE="#dmbWindowClose",DMB_APP="#dmbApp",PROP_URL_WINDOW="#propUrlWindow",FOR_SVWEB_TESTS="#for_SVWEB_tests",NO_SIM_DATA_MESSAGE="NO_SIM_DATA_MESSAGE",DOUBLE_CLICK_SPEED=500,surface,file_sidebar,sidebar_manager,defaultLeftSidebar,defaultRightSidebar,loadingAppDeferredArray=[];var testMode=!1,DebugSource=function(){function n(){}return n.prototype.postMessage=function(n){console.log("postMessage() called, action = "+n.action)},n}(),DebugEvent=function(){function n(n){this.data={containerID:n};this.source=new DebugSource}return n}();window.onload=function(){$(FOR_SVWEB_TESTS).length>0&&(testMode=!0);exec()},function(n){var i,t,r,l,o,s,f,h,c,e,u;(function(n){n[n.ROT_0=0]="ROT_0";n[n.ROT_90=1]="ROT_90";n[n.ROT_180=2]="ROT_180";n[n.ROT_270=3]="ROT_270";n[n.ROT_MINUS90=-1]="ROT_MINUS90"})(n.ROTATION||(n.ROTATION={}));i=n.ROTATION,function(n){n[n.MIRROR_NONE=0]="MIRROR_NONE";n[n.MIRROR_X=1]="MIRROR_X";n[n.MIRROR_Y=2]="MIRROR_Y"}(n.MIRROR||(n.MIRROR={}));t=n.MIRROR,function(n){n[n.NONE=0]="NONE";n[n.SELECTED=1]="SELECTED";n[n.WARNING=2]="WARNING";n[n.ERROR=3]="ERROR";n[n.CROSS_HIGHLIGHT=4]="CROSS_HIGHLIGHT";n[n.HIGHLIGHT=5]="HIGHLIGHT"}(n.HIGHLIGHT_STATE||(n.HIGHLIGHT_STATE={}));r=n.HIGHLIGHT_STATE;l=function(){function u(u,e,o,s){var h;if(this.openingCompMenu=!1,this.highlightState=r.NONE,this.properties=[],this.propTracker={},this.probeList=[],this.dumpStr="",this.design=u,this.dbComp=e,this.svgElements=u.getSVGElements(e.Img),this.compName=e.Name,this.title=e.Title,this.library=n.ComponentVhdlDto.getLib(e),this.componentId=e.ComponentId,this.categories=e.Categories,this.computeCenterOffset(),this.rotation=i.ROT_0,this.mirror=t.MIRROR_NONE,this.stroke=[],this.pins=[],this.instProps=[],this.buildHighlightBox(),this.buildOverlay(),this.storeStrokes(),this.addPins(),this.defineEvents(),this.nametag=new f(u,this),this.instName=o?o:this.generateUniqueName(this.dbComp.Prefix),this.instNameVisibility=s!=null?s:!0,this.dbComp.Properties){for(h=0;h<this.dbComp.Properties.length;++h)this.properties.push(n.CompPropertyFactory.create(this.dbComp.Properties[h],this));for(this.addMetadataForSelectComponents(),this.insertExtraProperties(),h=0;h<this.properties.length;++h)this.properties[h].setParentsAndChildren(this.properties)}this.addToDesign();this.buildNametag();this.buildConnectedNametags();this.createGraphicsSet()}return u.prototype.getCriticalDeprecationMessage=function(n){var i,t;if(!surface.getComponentDataManager().isDeprecated(n))return"";for(i=-1,t=0;t<n.Revisions.length;++t)if(n.ComponentId==n.Revisions[t].ComponentId){i=t;break}if(i>-1)for(t=i+1;t<n.Revisions.length;++t)if(n.Revisions[t].Critical)return'<table style="margin-top: 5px"><tr><td style="padding-right: 5px"><i class="glyphicon glyphicon-arrow-right"><\/i><\/td><td>'+this.instName+": "+n.Title+"<\/td><\/tr><tr><td><\/td><td>"+n.Revisions[t].Description+"<\/td><\/tr><\/table>";return""},u.prototype.replace=function(n){var i=this.suspendConnections(),r=this.getSaveData(),t;return this.remove(),t=new u(this.design,n),t.restore(r),t.restoreConnections(i),this.design.getConnMgr().finalize(),t},u.prototype.restore=function(u){var f,p,s;this.restoring=!0;var h=u.rotation,c=u.mirror,w=u.cx,b=u.cy,o=u.instProps;h!=i.ROT_0&&this.rotate(h,!1,!0,!1);c!=t.MIRROR_NONE&&this.applyMirror(c);var l=this.getCenter(),a=new BaseWire.Point(w,b),v=a.x-l.x,y=a.y-l.y;if(this.transform(n.Utility.pointToTransform(v,y),!1),this.nametag.transform(v,y),o==null)this.instProps=[];else for(f=0;f<o.length;f++)for(p=new e(o[f].name,o[f].value,o[f].visible),this.instProps.push(p),s=0;s<this.properties.length;++s)if(this.properties[s].Name==o[f].name){this.properties[s].setInstValue(o[f].value);this.properties[s].PropVisibility=o[f].visible;break}this.validate().length>0&&this.showHighlightBox(r.WARNING,!1);this.nametag.restore(u.nametag);this.restoring=!1;this.buildNametag();this.buildConnectedNametags()},u.prototype.validate=function(){for(var i,e,f=!0,u=[],r,t=0;t<this.dbComp.Properties.length;t++){for(r=!1,i=0;i<this.instProps.length;i++)if(r=!1,this.instProps[i].getName()==this.dbComp.Properties[t].Name){r=!0;this.instProps[i].getValue()||(u.push(this.dbComp.Properties[t].Name),f=!1);break}r||(e=n.Utility.getPropTypFromMinTypMax(this.dbComp.Properties[t]),e||(u.push(this.dbComp.Properties[t].Name),f=!1))}return u},u.prototype.addProbe=function(t){this.probeList.push(t);this.design.setDirty(n.DIRTY_FLAG.DIRTY_WAVEBOX);this.makePencilUniquelyVisible(t)},u.prototype.removeProbe=function(t){this.makeAnotherPencilUniquelyVisible(t);var i=this.probeList.indexOf(t);i>=0&&this.probeList.splice(i,1);this.design.setDirty(n.DIRTY_FLAG.DIRTY_WAVEBOX)},u.prototype.getWaveboxes=function(t){for(var u,r,i=0;i<this.probeList.length;i++)u=this.probeList[i],u&&(r=u.getWavebox(),r&&!n.Utility.uniqNameInArray(r.getUniqName(),t)&&t.push(r))},u.prototype.getDistanceFrom=function(n){var t=this.getCenter();return t.distance(n)},u.prototype.getClosestPin=function(n){for(var r,i=null,u=1e4,t=0;t<this.pins.length;t++)r=this.pins[t].getLocation().distance(n),(!i||r<u)&&(i=this.pins[t],u=r);return i},u.prototype.getCompMenu=function(){return this.compMenu},u.prototype.getOpeningCompMenu=function(){return this.openingCompMenu},u.prototype.setOpeningCompMenu=function(n){this.openingCompMenu=n},u.prototype.moveTo=function(t,i){var u=this.getCenter(),r=new BaseWire.Point(t,i);r.placeOnGrid(n.Settings.SCH_GRID_SPACING);r.subtract(u);this.transform(n.Utility.pointToTransform(r.x,r.y));this.nametag.transform(r.x,r.y);this.buildNametag();this.buildConnectedNametags();this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.dragRelative=function(t,i,r){return this.nametag.transform(t,i),this.transform(n.Utility.pointToTransform(t,i),r)},u.prototype.remove=function(){var n;for(this.overlay.unhover(),this.svgElements.remove(),this.overlay.remove(),this.removeNametag(),n=0;n<this.pins.length;n++)this.pins[n].remove();for(this.design.getSymbolBar().hide(!1),this.design.getInputField().hideQueryField(!1),n=0;n<this.probeList.length;n++)this.probeList[n].updateConnection();this.probeList=[];this.removeFromDesign();this.highlightBox.remove();surface.getPropertyEditor().closeOrClear();setBodyCursor("auto")},u.prototype.hasAllConnections=function(){for(var n=0;n<this.pins.length;n++)if(!this.pins[n].isConnected())return!1;return!0},u.prototype.hasTerminalPin=function(){for(var t=0;t<this.pins.length;t++)if(this.pins[t].getType()==n.PIN_TYPE.TERMINAL)return!0;return!1},u.prototype.toFront=function(){this.highlightBox.toFront();this.svgElements.toFront();this.overlay.toFront();this.nametag.toFront();for(var n=0;n<this.pins.length;n++)this.pins[n].toFront()},u.prototype.unconnectedPinsToFront=function(){for(var n=0;n<this.pins.length;n++)this.pins[n].isConnected()||this.pins[n].toFront()},u.prototype.select=function(n){var t=surface.getPropertyEditor();this.showHighlightBox(r.SELECTED,n);this.toFront();this.isGroundOrReferenceComponent()?t.closeOrClear():this.updatePropWindow()},u.prototype.deselect=function(n){surface.getPropertyEditor().closeOrClear();this.resetHighlight(n);this.putProbesOnTop()},u.prototype.putProbesOnTop=function(){for(var n=0;n<this.probeList.length;n++)this.probeList[n].toFront()},u.prototype.makePencilUniquelyVisible=function(n){for(var i,t=0;t<this.probeList.length;t++)i=this.probeList[t],i!=n?i.makePencilTransparent():i.makePencilVisible()},u.prototype.makeAnotherPencilUniquelyVisible=function(n){for(var i,t=0;t<this.probeList.length;t++)if(i=this.probeList[t],i!=n){i.makePencilVisible();return}},u.prototype.isSelected=function(){return this.highlightState===r.SELECTED},u.prototype.isSinglySelected=function(){return this.isSelected()&&this.design.getSelectionManager().getNumSelected()==1?!0:!1},u.prototype.showHighlightBox=function(t,i){n.Utility.finishAnimation(this.highlightBox);this.hideHighlightBox(!1,!1);t!=null&&(this.highlightState=t);switch(this.highlightState){case r.SELECTED:this.highlightBox.attr("fill",Schematic.Surface.SELECTION_COLOR).attr("fill-opacity","1").attr("stroke","#000").attr("stroke-dasharray","");break;case r.WARNING:this.highlightBox.attr("fill-opacity","0").attr("stroke",Schematic.Surface.WARNING_HIGHLIGHT_COLOR).attr("stroke-dasharray","- ");break;case r.ERROR:this.highlightBox.attr("fill",Schematic.Surface.ERROR_HIGHLIGHT_COLOR).attr("fill-opacity","1").attr("stroke","#000").attr("stroke-dasharray","");break;case r.HIGHLIGHT:case r.CROSS_HIGHLIGHT:this.highlightBox.attr("fill",Schematic.Surface.CROSS_HIGHLIGHT_COLOR).attr("fill-opacity","0.5").attr("stroke","#000").attr("stroke-dasharray","")}this.highlightState!==r.NONE&&(i==null||i?this.highlightBox.animate({opacity:"0.8","stroke-opacity":"1"},300):this.highlightBox.attr("opacity","0.8").attr("stroke-opacity","1"))},u.prototype.hideHighlightBox=function(n,t){n==null||n?this.highlightBox.animate({opacity:"0","stroke-opacity":"0"},300):this.highlightBox.attr("opacity","0").attr("stroke-opacity","0");(t==null||t)&&(this.highlightState=r.NONE)},u.prototype.crossHighlight=function(){var n=this.highlightState;this.showHighlightBox(r.CROSS_HIGHLIGHT);this.highlightState=n},u.prototype.highlight=function(){var n=this.highlightState;this.showHighlightBox(r.HIGHLIGHT);this.highlightState=n;this.toFront()},u.prototype.unhighlight=function(){this.showHighlightBox(null,!1)},u.prototype.resetHighlight=function(n){this.validate().length>0?this.showHighlightBox(r.WARNING,n):this.hideHighlightBox(n)},u.prototype.getOverlay=function(){return this.overlay},u.prototype.getLibrary=function(){return this.library},u.prototype.getDesign=function(){return this.design},u.prototype.isGroundOrReferenceComponent=function(){return n.Utility.isReferenceComponent(this.compName,this.library)},u.prototype.getCompName=function(){return this.compName},u.prototype.getTitle=function(){return this.title},u.prototype.getInstName=function(){return this.instName},u.prototype.setInstNameInternal=function(n){var t=this.instName;this.instName=n;this.renameInDesign(t);this.buildNametag()},u.prototype.setPropEditorInstName=function(){var n=surface.getPropertyEditor();n.isOpen()&&n.getInstName()==this.instName&&n.setInstNameValue(this.instName)},u.prototype.getNextUniqueName=function(n){return this.design.getNextUniqueName(n,"comp")},u.prototype.generateUniqueName=function(n){return this.design.createUniqName(n,"comp")},u.prototype.setInstName=function(t){var e=this,r,i=$.Deferred(),u=n.Utility.convertToLegalVHDLName(t,"comp_"),f=this.design.findCompByInstName(u),o;return t==""?(r="Must specify a name for this component",n.MessageManager.showErrorMessage(r),i.reject(),i.promise()):u==""?(r='Specified component name "'+t+'" cannot be converted to a legal name',n.MessageManager.showErrorMessage(r),i.reject(),i.promise()):u==this.instName?(i.reject(),i.promise()):(t!=u&&(r="Specified component name was changed to be compatible with VHDL-AMS",n.MessageManager.showInfoMessage(r)),f!=null&&f!=this?(r="The name "+u+" is already in use. Clicking<br>OK will perform the following actions:<br><br>&nbsp;&nbsp;&#8226;&nbsp;"+this.instName+" will be renamed "+u+"<br>&nbsp;&nbsp;&#8226;&nbsp;"+f.getInstName()+" will be renamed "+e.getNextUniqueName(f.getDbComp().Prefix),o=new n.MultiBtnModalDialog("Component Name Conflict",r,["OK","Cancel"]),jQuery.when(o.queryUser()).done(function(t){if(t==n.BUTTON.BTN1){var o=e.generateUniqueName(f.getDbComp().Prefix),r=e.design.getUndoManager();r.startUndoableCommand(n.RenameComponentCommand,e.design,f.getInstName());f.setInstNameInternal(o);r.finishUndoableCommand(f.getInstName());e.setInstNameInternal(u);i.resolve()}else i.reject();e.setPropEditorInstName()})):(this.setInstNameInternal(u),i.resolve()),this.setPropEditorInstName(),i.promise())},u.prototype.getInstNameVisibility=function(){return this.instNameVisibility},u.prototype.setInstNameVisibility=function(t){this.instNameVisibility=t;this.buildNametag();this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},u.prototype.getProperties=function(){return this.properties},u.prototype.getDbComp=function(){return this.dbComp},u.prototype.getPins=function(){return this.pins},u.prototype.getDbCompProps=function(){return this.dbComp.Properties},u.prototype.getDbCompProp=function(n){for(var t=0;t<this.dbComp.Properties.length;++t)if(n==this.dbComp.Properties[t].Name)return this.dbComp.Properties[t];return null},u.prototype.getInstProps=function(){return this.instProps},u.prototype.getInstPropValue=function(n){for(var t=0;t<this.instProps.length;t++)if(n==this.instProps[t].getName())return this.instProps[t].getValue();return null},u.prototype.unsetInstProp=function(n){for(var f,r,e,o,t,i=0,u=this.properties;i<u.length;i++)if(f=u[i],n==f.Name){for(r=0,e=this.dbComp.Properties;r<e.length;r++)if(o=e[r],n==o.Name){f.setInstValue(o.Typical);break}break}for(t=0;t<this.instProps.length;++t)if(n==this.instProps[t].getName()){this.instProps.splice(t,1);break}this.buildNametag()},u.prototype.setInstProps=function(t){for(var s,y,p,h,w,i,k,o,r,c=!1,l=0,b=t;l<b.length;l++){var a=b[l],u=a.name,f=a.value,v=a.visible;for(s=0,y=this.properties;s<y.length;s++)if(i=y[s],u==i.Name){i.setInstValue(f);break}for(p=!1,h=0,w=this.instProps;h<w.length;h++)if(i=w[h],u==i.getName()){if(p=!0,f!=i.getValue()&&(i.setValue(f),c=!0),v!=null&&i.setVisibility(v),this.propTracker.hasOwnProperty(u))for(o=this.propTracker[u],r=0;r<o.length;r++)o[r].changeValue(f);break}if(!p&&(k=new e(u,f,v),this.instProps.push(k),c=!0,this.propTracker.hasOwnProperty(u)))for(o=this.propTracker[u],r=0;r<o.length;r++)o[r].changeValue(f)}c?this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_DIRTY_SIM_RESULTS):this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS);this.buildNametag()},u.prototype.setInstProp=function(n,t,i){var f,u,r;t?(f={name:n,value:t,visible:i},u=[],u.push(f),this.setInstProps(u)):this.unsetInstProp(n);r=surface.getPropertyEditor();r.isOpen()&&r.getInstName()==this.getInstName()&&r.setPropValue(n,t)},u.prototype.getPropValue=function(n){for(var t=0;t<this.instProps.length;t++)if(this.instProps[t].getName()==n)return this.instProps[t].getValue();for(t=0;t<this.dbComp.Properties.length;t++)if(this.dbComp.Properties[t].Name==n)return this.dbComp.Properties[t].Typical;return null},u.prototype.trackPropChange=function(n,t,i){var r=new s(this,n,t,i);this.propTracker.hasOwnProperty(n)||(this.propTracker[n]=[]);this.propTracker[n].push(r)},u.prototype.showExternalEditor=function(n){if(this.dbComp.Url){var t=$(PROP_URL_WINDOW).data("kendoWindow");n&&t.wrapper.css({top:n.clientY+"px",left:n.clientX+"px"});t.title(this.compName+" Properties");t.wrapper.css({width:800,height:600});t.refresh({iframe:!0,url:this.dbComp.Url+"&instanceName="+this.instName,headers:{TOKEN_HEADER:"a1b7ec9a-cb6f-a402-6202-0f9314db0dc6"}})}},u.prototype.showPropWindow=function(n,t){surface.getPropertyEditor().update(this);t&&this.showExternalEditor(n)},u.prototype.updatePropWindow=function(){this.showPropWindow(null,!1)},u.prototype.getCenter=function(){var n=this.getBBoxWithoutText(),r=n.x,u=n.y;switch(this.rotation){case i.ROT_0:switch(this.mirror){case t.MIRROR_NONE:r+=this.centerOffset.x;u+=this.centerOffset.y;break;case t.MIRROR_X:r+=this.centerOffset.x;u+=n.height-this.centerOffset.y;break;case t.MIRROR_Y:r+=n.width-this.centerOffset.x;u+=this.centerOffset.y}break;case i.ROT_90:switch(this.mirror){case t.MIRROR_NONE:r+=n.width-this.centerOffset.y;u+=this.centerOffset.x;break;case t.MIRROR_X:r+=this.centerOffset.y;u+=this.centerOffset.x;break;case t.MIRROR_Y:r+=n.width-this.centerOffset.y;u+=n.height-this.centerOffset.x}break;case i.ROT_180:switch(this.mirror){case t.MIRROR_NONE:r+=n.width-this.centerOffset.x;u+=n.height-this.centerOffset.y;break;case t.MIRROR_X:r+=n.width-this.centerOffset.x;u+=this.centerOffset.y;break;case t.MIRROR_Y:r+=this.centerOffset.x;u+=n.height-this.centerOffset.y}break;case i.ROT_270:switch(this.mirror){case t.MIRROR_NONE:r+=this.centerOffset.y;u+=n.height-this.centerOffset.x;break;case t.MIRROR_X:r+=n.width-this.centerOffset.y;u+=n.height-this.centerOffset.x;break;case t.MIRROR_Y:r+=this.centerOffset.y;u+=this.centerOffset.x}break;default:console.log("Illegal value for rotation index in getCenter")}return new BaseWire.Point(r,u)},u.prototype.getCenterOffset=function(){return this.centerOffset.clone()},u.prototype.getCategories=function(){return this.categories},u.prototype.getComponentId=function(){return this.componentId},u.prototype.getPinByName=function(n){for(var i,t=0;t<this.pins.length;t++)if(i=this.pins[t],n==i.getName())return i;return null},u.prototype.rotate=function(n,t,i,r){this.rotateOrMirror(n,null,t,i,r)},u.prototype.getRotation=function(){return this.rotation},u.prototype.xMirror=function(n,i,r){this.rotateOrMirror(null,t.MIRROR_X,n,i,r)},u.prototype.yMirror=function(n,i,r){this.rotateOrMirror(null,t.MIRROR_Y,n,i,r)},u.prototype.getMirror=function(){return this.mirror},u.prototype.getSaveData=function(){var i=this.getCenter(),n=new c,r,u,t,f,e;for(n.componentId=this.componentId,n.categories=this.categories,n.cx=Math.round(i.x),n.cy=Math.round(i.y),n.compName=this.compName,n.library=this.library,n.rotation=this.rotation,n.mirror=this.mirror,n.instName=this.instName,n.instNameVisibility=this.instNameVisibility,n.nametag=this.nametag.getSaveData(),n.instProps=[],n.pinConnections=[],t=0;t<this.instProps.length;++t)r=this.instProps[t],u=r.getSaveData(),n.instProps.push(u);for(t=0;t<this.pins.length;t++)f=this.pins[t],e=f.getSaveData(),n.pinConnections.push(e);return n},u.prototype.addToDump=function(n,t){var i=JSON.stringify(t);this.dumpStr+="\n"+n+": "+i},u.prototype.dumpPins=function(){for(var i,t="[",n=0;n<this.pins.length;n++)i=this.pins[n],t+=i.dumpPin();return t+"]"},u.prototype.dumpComponent=function(){return this.dumpStr="",this.addToDump("centerOffset",this.centerOffset),this.addToDump("compName",this.compName),this.addToDump("dbComp",this.getDbComp()),this.addToDump("highlightState",this.highlightState),this.addToDump("componentId",this.componentId),this.addToDump("categories",this.categories),this.addToDump("instName",this.instName),this.addToDump("instNameVisibility",this.instNameVisibility),this.addToDump("instProps",this.instProps),this.addToDump("library",this.library),this.addToDump("mirror",this.mirror),this.addToDump("pinConnections",this.dumpPins()),this.addToDump("rotation",this.rotation),this.addToDump("stroke",this.stroke),this.addToDump("cx",Math.round(this.getCenter().x)),this.addToDump("cy",Math.round(this.getCenter().y)),this.dumpStr},u.prototype.dumpDbComp=function(){var n=JSON.stringify(this.getDbComp());return"public dbComp: any = "+n+";"},u.prototype.getCloneData=function(){return new a(this)},u.prototype.tryToConnect=function(n,t){for(var f,o,h,e,c,s,l,u=null,r=[],i=0;i<this.pins.length;i++)f=this.pins[i].tryToConnect(n,t),f.connection!=null?r.push(this.pins[i].getConnection()):u==null&&f.message!=null&&(u=f.message);if(r.length>=2)for(o=!1,i=0;i<r.length;++i){for(h=r[i],e=i+1;e<r.length;++e)c=r[e],s=h.getConnectedWireSegment(c),s&&(s.remove(),o=!0);o&&this.design.getConnMgr().finalize()}u!=null&&(l=this.design.getWireMgr(),l.showConnectTTip(this.overlay.node,u,0,!0))},u.prototype.findPinUnderPoint=function(n,t){for(var i=0;i<this.pins.length;i++)if(this.pins[i]!=t&&this.pins[i].isPointInside(n))return this.pins[i];return null},u.prototype.isPointInside=function(t){var i=this.getBBoxWithoutText();return n.Utility.isPointInsideBoundingRect(i,t.x,t.y)},u.prototype.isWithinBox=function(n,t){var i=this.getBBoxWithoutText();return!(i.x>n.x+t||i.x2<n.x-t||i.y>n.y+t||i.y2<n.y-t)},u.prototype.getSymbolBarLocation=function(){for(var p,w,h=!0,c=!0,l=!0,a=!0,v=0;v<this.pins.length;v++){p=this.pins[v];w=p.getQuadrant();switch(w){case BaseWire.QUADRANT.NORTH:h=!1;break;case BaseWire.QUADRANT.EAST:c=!1;break;case BaseWire.QUADRANT.SOUTH:l=!1;break;case BaseWire.QUADRANT.WEST:a=!1}}var f=this.getBBoxWithoutText(),y=f.x,e=f.y,u=f.x2,s=f.y2,n,t,i,r=5;return!h||c||l||a?h?(n=(y+u)/2,t=e-r,i=BaseWire.COMPASS_POSITION.NORTH):c?(n=u+r,t=(e+s)/2,i=BaseWire.COMPASS_POSITION.EAST):l?(n=(y+u)/2,t=s+r,i=BaseWire.COMPASS_POSITION.SOUTH):a?(n=y,t=(e+s)/2,i=BaseWire.COMPASS_POSITION.WEST):(n=u+r,t=s+r,i=BaseWire.COMPASS_POSITION.SOUTH_EAST):(n=u+r,t=e-r,i=BaseWire.COMPASS_POSITION.NORTH_EAST),new o(n,t,i)},u.prototype.isInsideBox=function(n,t,i,r){var u=this.getBBoxWithoutText();return n<=u.x&&u.x+u.width<=i&&t<=u.y&&u.y+u.height<=r?!0:!1},u.prototype.dump=function(t,i){n.Utility.dumpHeading(t,i);n.Utility.dump(t,'component "'+this.compName+'" has componentId '+this.componentId+" and instName = "+this.instName);n.Utility.dump(t,"rotation =  "+this.rotation+", mirror = "+this.mirror);this.centerOffset.dump(t,"Center Offset: ");this.getCenter().dump(t,"Center point: ");n.Utility.dump(t,"Number of instance props = "+this.instProps.length);for(var r=0;r<this.pins.length;r++)this.pins[r].dump(t+1,"pin"+r)},u.prototype.getBBox=function(){return this.svgElements.getBBox()},u.prototype.getBBoxWithoutText=function(){for(var t,n=0;n<this.svgElements.length;++n)this.svgElements[n].type=="text"&&(this.svgElements[n].removed=1);for(t=this.svgElements.getBBox(),n=0;n<this.svgElements.length;++n)this.svgElements[n].type=="text"&&delete this.svgElements[n].removed;return t},u.prototype.computeCenterOffset=function(){var h=-1,c=-1,s,l,a,u;if(this.dbComp.Cx>=0&&this.dbComp.Cy>=0&&(h=this.dbComp.Cx,c=this.dbComp.Cy),h!=-1&&c!=-1)this.centerOffset=new BaseWire.Point(h,c);else if(this.dbComp.Pins.length>0){var r=null,f=null,e=null,o=null;for(s=0;s<this.dbComp.Pins.length;s++){var v=this.dbComp.Pins[s],t=v.X,i=v.Y;r==null?(r=t,f=t,e=i,o=i):(t<r&&(r=t),t>f&&(f=t),i<e&&(e=i),i>o&&(o=i))}l=(r+f)/2;a=(e+o)/2;this.centerOffset=new BaseWire.Point(l,a);this.centerOffset.placeOnGrid(n.Settings.SCH_GRID_SPACING)}else{var u=this.getBBoxWithoutText(),l=u.width/2,a=u.height/2;this.centerOffset=new BaseWire.Point(l,a)}u=this.getBBoxWithoutText();this.centerOffset.subtract(u.x,u.y)},u.prototype.buildOverlay=function(){var n=this.getBBoxWithoutText();this.overlay=this.design.getPaper().rect(n.x,n.y,n.width,n.height);this.overlay.attr("opacity","0");this.overlay.attr("fill","#ffff00")},u.prototype.buildHighlightBox=function(){var n=this.getBBoxWithoutText();this.highlightBox=this.design.getPaper().rect(n.x,n.y,n.width,n.height,4);this.highlightBox.attr("opacity","0")},u.prototype.defineNametagEvents=function(n,t,i){var r=this;n.click(function(){var u=r.design.getSelectionManager(),n;u.clearSelection();u.selectObject(r);r.showPropWindow(null,!0);n=surface.getPropertyEditor();n.open();t?n.focusOnInstName():n.focusOnPropValue(i)});n.hover(function(){r.design.getSymbolBar().hide();r.design.getWireBar().hide()},function(){})},u.prototype.getNametag=function(){return this.nametag},u.prototype.setNametagPoint=function(n){this.nametag.setPoint(n)},u.prototype.setNametagUserMoved=function(n){this.nametag.setUserMoved(n)},u.prototype.getInitNametagQuad=function(){for(var t=[],n=0;n<4;++n)t[n]=!1;for(n=0;n<this.pins.length;++n)t[this.pins[n].getQuadrant()]=!0;if(t[BaseWire.QUADRANT.SOUTH])if(t[BaseWire.QUADRANT.EAST]){if(!t[BaseWire.QUADRANT.NORTH])return BaseWire.QUADRANT.NORTH}else return BaseWire.QUADRANT.EAST;else return BaseWire.QUADRANT.SOUTH;return null},u.prototype.getInitNametagPoint=function(n){var t=this.getInitNametagQuad();switch(t){case BaseWire.QUADRANT.SOUTH:return new BaseWire.Point(n.x+10,n.y2+13);case BaseWire.QUADRANT.EAST:return new BaseWire.Point(n.x2+10,n.y+5);case BaseWire.QUADRANT.NORTH:return new BaseWire.Point(n.x+10,n.y-15);default:return new BaseWire.Point(n.x2+10,n.y-5)}},u.prototype.buildNametag=function(t,i,r){var a,o,f,c,v,l,e,s,y,h,p,w;if((t===void 0&&(t=!1),i===void 0&&(i=!1),r===void 0&&(r=!1),!this.restoring&&surface.areNametagsReadable()&&!this.nametag.isMoving())&&(this.removeNametag(),!this.isGroundOrReferenceComponent())){if(a=this.getBBoxWithoutText(),o=this.nametag.getPoint(),o&&o.x&&o.y?f=o.clone():(f=this.getInitNametagPoint(a),this.setNametagPoint(f.clone())),this.nametag.initLabel(),c=this.design.getNametagVisibility(),(i||c==n.NAMETAG_VISIBILITY.ALL||c==n.NAMETAG_VISIBILITY.CHOSEN&&this.instNameVisibility)&&(v=this.design.getPaper().text(f.x,f.y,this.getInstName()),this.defineNametagEvents(v,!0),this.nametag.push(v),f.y+=u.NametagYSpacing),!i&&c!=n.NAMETAG_VISIBILITY.NONE)for(l=0;l<this.properties.length;++l)(e=this.properties[l],e.shouldBeVisible()&&e.shouldBeEnabled())&&(s=e.PropVisibility,s&&s!=n.PROPERTY_VISIBILITY.NONE)&&(y=e.Name,h=e.getValue(),e.Metadata&&!$.isEmptyObject(e.Metadata.radioDisplayValues)&&(h=e.Metadata.radioDisplayValues[h]),s==n.PROPERTY_VISIBILITY.ALL?p=y+"="+h:s==n.PROPERTY_VISIBILITY.VALUE&&(p=h),w=this.design.getPaper().text(f.x,f.y,p),this.defineNametagEvents(w,!1,y),this.nametag.push(w),f.y+=u.NametagYSpacing);this.nametag.draw(a,t,r)}},u.prototype.removeNametag=function(n){n===void 0&&(n=!1);this.nametag.remove(n)},u.prototype.buildConnectedNametags=function(){for(var i,r,n,t=0;t<this.pins.length;++t)i=this.pins[t].getConnection(),i&&(r=i.getWireSegment(0),r&&(n=r.getWire(),n&&(n.getNametagSeg()||n.initNametag(),n.buildNametag())))},u.prototype.nametagOnlyVisibleOnHover=function(){return!this.isGroundOrReferenceComponent()&&this.design.getNametagVisibility()==n.NAMETAG_VISIBILITY.NONE},u.prototype.nametagOnMouseover=function(){this.nametagOnlyVisibleOnHover()?this.buildNametag(!0,!0,!0):this.buildNametag(!1,!1,!0)},u.prototype.nametagOnMouseout=function(){this.nametagOnlyVisibleOnHover()?this.removeNametag(!0):this.buildNametag()},u.prototype.storeStrokes=function(){for(var n=0;n<this.svgElements.length;n++)this.stroke[n]=this.svgElements[n].attr("stroke")},u.prototype.addPins=function(){for(var i,r,t=0;t<this.dbComp.Pins.length;t++)i=this.dbComp.Pins[t],r=new n.Pin(this.design,this,i),this.pins.push(r)},u.prototype.defineEvents=function(){var t=this;if(this.design.getSymbolBar()!=null){this.dragCompHandler=new v(this.design,this);n.Utility.hoverEventWithToFront(this.overlay,function(){t.hoverIn()},function(){t.hoverOut()});this.overlay.mousedown(function(n){(Messaging.Handler.sendSetFocusMessage(),t.design.getWireMgr().inWireMode())||(n.which==3&&($(document).bind("contextmenu",function(){return!1}),t.setCompMenu(),t.openingCompMenu=!0),t.isSelected()?t.design.getSurface().clearFocus():(t.design.selectObject(t,n),t.dragCompHandler.setSkipSelection()),t.openingCompMenu=!1)});var i=function(n,i,r){return t.dragCompHandler.dragStart(n,i,r),t.design.getWireMgr().destroyConnectTTip(),{}},r=function(n,i,r,u,f){return t.dragCompHandler.dragMove(n,i,r,u,f),{}},u=function(n){return t.dragCompHandler.dragEnd(n),{}};this.overlay.drag(r,i,u)}},u.prototype.createCompMenu=function(){var t=this,o=surface.getComponentDataManager(),s=surface.getComponentBrowserSidebar(),r=o.getComponent(t.library,t.componentId),f=null,e=r!=null&&n.Settings.UUID!=null&&n.Settings.UUID.length>0;e&&!r.UserFavorite?f="Add Favorite":e&&(f="Remove Favorite");var y=function(){alert("Copy")},h=function(){t.design.clearSelection();t.design.selectObject(t,null);t.design.deleteSelection()},c=function(){r&&s.handleToggleFavorite(r)},l=function(n){var i=surface.getPropertyEditor();t.design.clearSelection();t.design.selectObject(t,null);t.isGroundOrReferenceComponent()?i.closeOrClear():(t.showPropWindow(n,!0),i.open(),t.getCompMenu()&&t.getCompMenu().hide())},a=function(){n.CeUtility.isOpen()||new n.ModelEditor(t.design.getSurface(),t.dbComp,!0,t.dbComp.ModelType,!1)},v=function(){u.ShowDescription(t.title,t.dbComp.Description)},i=new SVWebContextMenu.MenuContent(this);surface.getEditingMode()==Schematic.EditingMode.EDITABLE&&i.addMenuElement("Delete",h);i.addMenuElement("Properties",l);i.addSeparatorToMenu();i.addMenuElement("More Info",v);f&&i.addMenuElement(f,c);i.addSeparatorToMenu();i.addMenuElement("View/Copy Model",a);t.compMenu=SVWebContextMenu.MenuHelper.createMenu(i)},u.prototype.setCompMenu=function(){this.createCompMenu();var n=$(this.overlay.node);this.compMenu.bindMenuTo(n)},u.prototype.crossHighlightInViewer=function(n){var t=this.instName.toLowerCase();WaveViewer.getManager().getCrossHighlightManager().crossHighlightBySchematicElement(t,!0,n)},u.prototype.hoverIn=function(){!this.dragCompHandler.isMoving()&&this.design.isHoverEnabled()&&(this.crossHighlightInViewer(!0),this.isEditable()&&(this.design.getWireBar().hide(),this.isSinglySelected()&&this.design.getSymbolBar().show(this),this.design.getWireMgr().inWireMode()?this.toFront():setBodyCursor("move"),this.showPinLabels()),this.nametagOnMouseover())},u.prototype.hoverOut=function(){!this.dragCompHandler.isMoving()&&this.design.isHoverEnabled()&&(this.crossHighlightInViewer(!1),this.isEditable()&&(this.design.getSymbolBar().hide(!0),setBodyCursor("auto"),this.hidePinLabels()),this.nametagOnMouseout(),this.design.getWireMgr().destroyConnectTTip())},u.prototype.finishAnimation=function(){for(var t=0;t<this.svgElements.length;t++)n.Utility.finishAnimation(this.svgElements[t]);for(n.Utility.finishAnimation(this.overlay),n.Utility.finishAnimation(this.highlightBox),t=0;t<this.pins.length;t++)this.pins[t].finishAnimation(!1);this.dragCompHandler.finishDragPinAnimation();this.dragCompHandler.clearDragPins();this.design.getConnMgr().finalize()},u.prototype.transform=function(t,i,r){var f=jQuery.Deferred(),u;if(r==null&&(r=!1),i){var o=300,s="linear",h=jQuery.Deferred(),c=Raphael.animation({transform:t},o,s,function(){h.resolve()}),e=[];for(this.graphicsSet.animate(c),e.push(h),u=0;u<this.pins.length;u++)e.push(this.pins[u].animate(t,o,s,r));$.when.apply($,e).done(function(){f.resolve()})}else{for(this.graphicsSet.transform(t),u=0;u<this.pins.length;u++)this.pins[u].transform(t,r);f.resolve()}return t!="...T0,0"&&this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS),f},u.prototype.suspendConnections=function(){for(var t,i=[],n=0;n<this.pins.length;n++)t=this.pins[n].suspendConnection(),t&&i.push(t);return i},u.prototype.restoreConnections=function(n){for(var t=0;t<n.length;t++){var i=n[t],u=i.getLocation(),r=this.findPinAtLocation(u);r?i.connectToPin(r):i.disconnectPin(null)}},u.prototype.findPinAtLocation=function(n){for(var i,t=0;t<this.pins.length;t++)if(i=this.pins[t].getLocation(),i.isAlmostEqual(n))return this.pins[t];return null},u.prototype.showPinLabels=function(){var n=this;this.design.getSelectionManager().isPasteActive()||(this.pinLabelTimer=window.setTimeout(function(){n.dragCompHandler.isMoving()||n.pins.forEach(function(n){n.showLabel()})},1e3))},u.prototype.hidePinLabels=function(){n.Pin.hideLabels();window.clearTimeout(this.pinLabelTimer)},u.prototype.applyMirror=function(n){switch(n){case t.MIRROR_X:this.xMirror(!1,!0,!1);break;case t.MIRROR_Y:this.yMirror(!1,!0,!1)}},u.prototype.willPinMove=function(n,r,u){var e=n.getLocation(),f=this.getCenter();return f.round(),r!=null?!e.isEqual(f):u==t.MIRROR_X?this.rotation==i.ROT_0||this.rotation==i.ROT_180?e.y!=f.y:e.x!=f.x:this.rotation==i.ROT_0||this.rotation==i.ROT_180?e.x!=f.x:e.y!=f.y},u.prototype.rotateOrMirror=function(r,u,f,e,o){var p=this,v,h,c,a,s,l,y;for(f==null&&(f=!0),e==null&&(e=!1),o==null&&(o=!0),this.finishAnimation(),v=r!=null?n.RotateCommand.getCommandNamePrefix()+this.instName:u==t.MIRROR_X?n.XMirrorCommand.getCommandNamePrefix()+this.instName:n.YMirrorCommand.getCommandNamePrefix()+this.instName,h=this.design.getUndoManager(),o&&h.startUndoableCommand(n.DisconnectComponentCommand,this.design,this,n.COMMAND_STEP.FIRST,v),c=0;c<this.pins.length;++c)this.willPinMove(this.pins[c],r,u)&&(this.pins[c].visibleDisconnect(),a=this.pins[c].getConnection(),a&&a.finalize());if(o&&h.finishUndoableCommand(null),r!=null)switch(r){case i.ROT_0:s="...R0,";break;case i.ROT_90:s="...R90,";break;case i.ROT_180:s="...R180,";break;case i.ROT_270:s="...R270,";break;case i.ROT_MINUS90:s="...R-90,";r=i.ROT_270;break;default:s="...R0,"}else s=u==t.MIRROR_X?"...S1,-1,":"...S-1,1,";l=this.getCenter();l.round();s+=l.x+","+l.y;o&&(r!=null?h.startUndoableCommand(n.RotateCommand,this.design,this,n.COMMAND_STEP.LAST):u==t.MIRROR_X?h.startUndoableCommand(n.XMirrorCommand,this.design,this,n.COMMAND_STEP.LAST):h.startUndoableCommand(n.YMirrorCommand,this.design,this,n.COMMAND_STEP.LAST),h.finishUndoableCommand(null));y=this.transform(s,f,!1);$.when(y).done(function(){p.setNametagUserMoved(!0)});e?r!=null?this.rotation=r:this.mirror=u:this.updateRotationAndMirror(r,u)},u.prototype.updateRotationAndMirror=function(n,r){switch(this.rotation){case i.ROT_0:switch(this.mirror){case t.MIRROR_NONE:n==i.ROT_90?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_NONE):n==i.ROT_270?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_NONE):r==t.MIRROR_X?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_X):r==t.MIRROR_Y?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_Y):this.rotationAndMirrorError(n,r);break;case t.MIRROR_X:n==i.ROT_90?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_X):n==i.ROT_270?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_X):r==t.MIRROR_X?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_NONE):r==t.MIRROR_Y?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_NONE):this.rotationAndMirrorError(n,r);break;case t.MIRROR_Y:n==i.ROT_90?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_X):n==i.ROT_270?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_Y):r==t.MIRROR_X?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_NONE):r==t.MIRROR_Y?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_NONE):this.rotationAndMirrorError(n,r)}break;case i.ROT_90:switch(this.mirror){case t.MIRROR_NONE:n==i.ROT_90?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_NONE):n==i.ROT_270?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_NONE):r==t.MIRROR_X?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_X):r==t.MIRROR_Y?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_Y):this.rotationAndMirrorError(n,r);break;case t.MIRROR_X:n==i.ROT_90?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_X):n==i.ROT_270?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_X):r==t.MIRROR_X?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_NONE):r==t.MIRROR_Y?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_NONE):this.rotationAndMirrorError(n,r);break;case t.MIRROR_Y:n==i.ROT_90?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_X):n==i.ROT_270?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_X):r==t.MIRROR_X?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_NONE):r==t.MIRROR_Y?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_NONE):this.rotationAndMirrorError(n,r)}break;case i.ROT_180:switch(this.mirror){case t.MIRROR_NONE:n==i.ROT_90?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_NONE):n==i.ROT_270?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_NONE):r==t.MIRROR_X?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_X):r==t.MIRROR_Y?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_X):this.rotationAndMirrorError(n,r);break;case t.MIRROR_X:n==i.ROT_90?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_X):n==i.ROT_270?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_X):r==t.MIRROR_X?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_NONE):r==t.MIRROR_Y?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_NONE):this.rotationAndMirrorError(n,r);break;case t.MIRROR_Y:this.rotationAndMirrorError(n,r)}break;case i.ROT_270:switch(this.mirror){case t.MIRROR_NONE:n==i.ROT_90?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_NONE):n==i.ROT_270?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_NONE):r==t.MIRROR_X?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_X):r==t.MIRROR_Y?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_X):this.rotationAndMirrorError(n,r);break;case t.MIRROR_X:n==i.ROT_90?(this.rotation=i.ROT_180,this.mirror=t.MIRROR_X):n==i.ROT_270?(this.rotation=i.ROT_0,this.mirror=t.MIRROR_X):r==t.MIRROR_X?(this.rotation=i.ROT_270,this.mirror=t.MIRROR_NONE):r==t.MIRROR_Y?(this.rotation=i.ROT_90,this.mirror=t.MIRROR_NONE):this.rotationAndMirrorError(n,r);break;case t.MIRROR_Y:this.rotationAndMirrorError(n,r)}break;default:this.rotationAndMirrorError(n,r)}},u.prototype.rotationAndMirrorError=function(n,t){console.log("Error related to rotation and mirror");console.log("  rot = "+n+", mirror = "+t);console.log("  Current settings are: rotation = "+this.rotation+", mirror = "+this.mirror)},u.prototype.isEditable=function(){return this.design.getSurface().isEditable()},u.prototype.addToDesign=function(){this.design.addComponent(this)},u.prototype.removeFromDesign=function(){this.design.removeComponent(this)},u.prototype.renameInDesign=function(n){this.design.renameComponent(this,n)},u.prototype.existsInDesign=function(){return this.design.componentExists(this)},u.prototype.createGraphicsSet=function(){this.graphicsSet=this.design.getPaper().set();for(var n=0;n<this.svgElements.length;++n)this.graphicsSet.push(this.svgElements[n]);this.graphicsSet.push(this.overlay);this.graphicsSet.push(this.highlightBox)},u.FormatDescription=function(n){var t="<h4>Detailed Model Description:<\/h4>",i=n.split("newParagraph"),r;if(i.length>1)for(t+=i[0],r=1;r<i.length;r++)t+="<br><br>"+i[r];else t+=n;return t},u.ShowDescription=function(t,i){n.KendoHelper.openLargeKendoWindow($(u.SYM_DESC),t,u.FormatDescription(i))},u.prototype.insertExtraProperties=function(){for(var t=0;t<this.properties.length;++t)if(this.properties[t].Metadata&&this.properties[t].Metadata.acProperty==n.AC_PROPERTY.MAGNITUDE){this.properties.splice(t,0,new n.ACCompProperty(this.properties[t],this.properties[t+1],this));break}},u.prototype.getACCheckbox=function(){for(var t=0;t<this.properties.length;++t)if(this.properties[t]instanceof n.ACCompProperty)return this.properties[t];return null},u.prototype.addMetadataForSelectComponents=function(){var r,f,i,e,u,o,s,t,l;if(this.getLibrary()==n.ComponentDataManager.SVWEB_LIB){for(r=0,f=this.properties;r<f.length;r++)if(i=f[r],i.Name.indexOf("use_initial_")==0){for(e=i.Name.substr(4),u=0,o=this.properties;u<o.length;u++)if(s=o[u],s.Name==e){i.Metadata=new n.CompPropertyMetadata({children:[{name:e,visibleValues:["true"]}]});s.Metadata=new n.CompPropertyMetadata({parents:[i.Name]});break}break}if(this.getTitle()=="Magnetic Core")this.properties[0].Metadata=new n.CompPropertyMetadata({displayName:"Area"}),this.properties[1].Metadata=new n.CompPropertyMetadata({displayName:"Length"}),this.properties[2].Metadata=new n.CompPropertyMetadata({displayName:"Magnetic Function Select",displayVisibility:!1,tooltip:"Choose magnetic characteristic behavior",radioDisplayValues:[{value:"1",displayValue:"Linear"},{value:"2",displayValue:"Non-linear with Saturation"},{value:"3",displayValue:"B vs. H from Table"}],children:[{name:"relative_permeability",visibleValues:["1","2"]},{name:"bsat",visibleValues:["2"]},{name:"bdata",visibleValues:["3"]},{name:"hdata",visibleValues:["3"]}],flipDisplayValue:!0}),this.properties[3].Metadata=new n.CompPropertyMetadata({displayName:"Relative permeability",tooltip:"Material permeability relative to free space",parents:["select_magnetic_function"]}),this.properties[4].Metadata=new n.CompPropertyMetadata({displayName:"Saturation flux density",parents:["select_magnetic_function"]}),this.properties[5].Metadata=new n.CompPropertyMetadata({displayName:"<div>B: Flux Density<\/div><div>[T]<\/div>",parents:["select_magnetic_function"],gridName:"h_vs_b_grid",gridColumn:1,monoIncreasing:!0,firstValueReadOnly:!0}),this.properties[6].Metadata=new n.CompPropertyMetadata({displayName:"<div>H: Field Str<\/div><div>[A*t/meter]<\/div",tooltip:"Enter corresponding H (field strength) and B (flux density) data pairs. Note:  Both sets of H and B values must be monotonically increasing, starting at 0.0",parents:["select_magnetic_function"],gridName:"h_vs_b_grid",gridColumn:0,monoIncreasing:!0,firstValueReadOnly:!0}),this.properties[7].Metadata=new n.CompPropertyMetadata({displayName:"Include Eddy Current Core Loss",displayVisibility:!1,children:[{name:"core_loss_volume_density",visibleValues:["true"]},{name:"frequency_loss_cal",visibleValues:["true"]},{name:"b_peak_loss_cal",visibleValues:["true"]}]}),this.properties[8].Metadata=new n.CompPropertyMetadata({displayName:"Loss per unit volume",parents:["include_eddy_loss"]}),this.properties[9].Metadata=new n.CompPropertyMetadata({displayName:"Loss calibration frequency",parents:["include_eddy_loss"]}),this.properties[10].Metadata=new n.CompPropertyMetadata({displayName:"Loss calibration flux density (zero to peak)",tooltip:"Sinusoidal flux density at which Loss was calibrated (zero to peak amplitude)",parents:["include_eddy_loss"]});else if(this.getTitle().indexOf("Function Generator")!=-1){t={};t["Angle Function Generator"]=["angle","angle","Angle","Angle"];t["Angular Velocity Function Generator"]=["angular_velocity","angular_velocity","Angular Velocity","Value"];t["Current Function Generator"]=["current","current","Current","Current Value"];t["Displacement Function Generator"]=["displacement","displacement","Displacement","Displacement"];t["Hydraulic Flow Function Generator"]=["flow","flow","Flow","Flow Value"];t["Flux Function Generator"]=["flux","flux","Flux","Flux Value"];t["Force Function Generator"]=["force","force","Force","Force Value"];t["Heat Flow Function Generator"]=["heat_flow","heat_flow","Heat Flow","Heat Flow"];t["MMF Function Generator"]=["mmf","mmf","MMF","MMF Value"];t["Pressure Function Generator"]=["pressure","pressure","Pressure","Pressure"];t["Quantity Function Generator"]=["constant","value","Value","Value"];t["Temperature Function Generator"]=["temperature","temperature","Temperature","Temperature"];t["Torque Function Generator (_r)"]=["torque","torque","Torque","Torque Value"];t["Torque Function Generator (_rv)"]=["torque","torque","Torque","Torque Value"];t["Voltage Function Generator"]=["voltage","voltage","Voltage","Voltage Value"];var a=t[this.title][0],h=t[this.title][1],c=t[this.title][2],v=t[this.title][3];this.properties[0].Metadata=new n.CompPropertyMetadata({displayName:"Select Function",tooltip:"Choose desired time-domain function type",radioDisplayValues:[{value:"1",displayValue:"DC"},{value:"2",displayValue:"Sine"},{value:"3",displayValue:"Pulse"},{value:"4",displayValue:"Ramp"},{value:"5",displayValue:"Table"}],children:[{name:a+"_level",visibleValues:["1"]},{name:"sine_frequency",visibleValues:["2"]},{name:"peak_amplitude",visibleValues:["2"]},{name:"offset",visibleValues:["2"]},{name:"initial_phase",visibleValues:["2"]},{name:"df",visibleValues:["2"]},{name:"initial_value",visibleValues:["3"]},{name:"pulse_value",visibleValues:["3"]},{name:"transtime_initial_to_pulse",visibleValues:["3"]},{name:"transtime_pulse_to_initial",visibleValues:["3"]},{name:"start_delay",visibleValues:["3"]},{name:"pulse_width",visibleValues:["3"]},{name:"pulse_period",visibleValues:["3"]},{name:"ramp_low_"+h,visibleValues:["4"]},{name:"ramp_high_"+h,visibleValues:["4"]},{name:"ramptime_low_to_high",visibleValues:["4"]},{name:"ramp_period",visibleValues:["4"]},{name:h+"_data",visibleValues:["5"]},{name:"time_data",visibleValues:["5"]},{name:"periodic_on",visibleValues:["5"]}]});this.properties[1].Metadata=new n.CompPropertyMetadata({displayName:"DC Level",parents:["select_function"]});this.properties[2].Metadata=new n.CompPropertyMetadata({displayName:"Frequency",parents:["select_function"]});this.properties[3].Metadata=new n.CompPropertyMetadata({displayName:"Amplitude (peak)",parents:["select_function"]});this.properties[4].Metadata=new n.CompPropertyMetadata({displayName:"DC Offset",parents:["select_function"]});this.properties[5].Metadata=new n.CompPropertyMetadata({displayName:"Initial Phase",parents:["select_function"]});this.properties[6].Metadata=new n.CompPropertyMetadata({displayName:"Exponential Damping",parents:["select_function"]});this.properties[7].Metadata=new n.CompPropertyMetadata({displayName:"Initial Value",parents:["select_function"]});this.properties[8].Metadata=new n.CompPropertyMetadata({displayName:"Pulse Value",parents:["select_function"]});this.properties[9].Metadata=new n.CompPropertyMetadata({displayName:"Transition Time (Initial to Pulse)",parents:["select_function"]});this.properties[10].Metadata=new n.CompPropertyMetadata({displayName:"Transition Time (Pulse to Initial)",parents:["select_function"]});this.properties[11].Metadata=new n.CompPropertyMetadata({displayName:"Start Delay",parents:["select_function"]});this.properties[12].Metadata=new n.CompPropertyMetadata({displayName:"Pulse Width",parents:["select_function"]});this.properties[13].Metadata=new n.CompPropertyMetadata({displayName:"Pulse Period",tooltip:"Repetition Period. Note: Pulse Period must be > Pulse Width + Transition Time (Initial to Pulse) + Transition Time (Pulse to Initial)",parents:["select_function"]});this.properties[14].Metadata=new n.CompPropertyMetadata({displayName:"Ramp Low Value",parents:["select_function"]});this.properties[15].Metadata=new n.CompPropertyMetadata({displayName:"Ramp High Value",parents:["select_function"]});this.properties[16].Metadata=new n.CompPropertyMetadata({displayName:"Ramp Time (Low to High)",tooltip:"Time for "+c+" to transition from Ramp Low Value to Ramp High Value. Note: Must be < Ramp Period",parents:["select_function"]});this.properties[17].Metadata=new n.CompPropertyMetadata({displayName:"Ramp Period",tooltip:"Ramp repetition time or period. Note: Ramp Period must be > Ramp Time (Low to High)",parents:["select_function"]});l=this.properties[18];this.properties[18].Metadata=new n.CompPropertyMetadata({displayName:"<div>"+v+"<\/div><div>["+l.Units+"]<\/div>",parents:["select_function"],gridName:"v_vs_t_grid",gridColumn:1});this.properties[19].Metadata=new n.CompPropertyMetadata({displayName:"<div>Time<\/div><div>[sec]<\/div>",tooltip:"Enter corresponding Time and "+c+" data pairs",parents:["select_function"],gridName:"v_vs_t_grid",gridColumn:0,monoIncreasing:!0,firstValueReadOnly:!0});this.properties[20].Metadata=new n.CompPropertyMetadata({displayName:"Periodic Function",displayVisibility:!1,tooltip:"If checked, function repeats with period equal to the time value of the last table data pair",parents:["select_function"]});this.properties[21].Metadata=new n.CompPropertyMetadata({displayName:"AC Magnitude",acProperty:0});this.properties[22].Metadata=new n.CompPropertyMetadata({displayName:"AC Phase",acProperty:1})}}},u.prototype.changePinWhiskerTechnology=function(n,t){for(var o,r=this.design.getCssClassMgr().getTerminalSubtype(n),u=this.design.getCssClassMgr().getSymPinWhiskerClass(r),r=this.design.getCssClassMgr().getTerminalSubtype(t),s=this.design.getCssClassMgr().getSymPinWhiskerClass(r),i=0;i<this.svgElements.length;++i)if(this.svgElements[i].type=="path"){var f=this.svgElements[i].node,e=$(f).attr("class"),h=e.indexOf(u);h>=0&&(o=e.replace(u,s),f.setAttribute("class",o))}},u.NametagYSpacing=14,u.SYM_DESC="#symDesc",u}();n.Component=l;o=function(){function n(n,t,i){this.x=n;this.y=t;this.pos=i}return n}();n.SymbolBarLocator=o;var v=function(){function t(n,t){this.skipSelection=!1;this.moving=!1;this.ctrlDragCopyPaste=!1;this.design=n;this.comp=t;this.dragPins=[]}return t.prototype.setSkipSelection=function(){this.skipSelection=!0},t.prototype.isMoving=function(){return this.moving},t.prototype.dragStart=function(t,i,r){(this.diffX=0,this.diffY=0,this.ctrlDragCopyPaste=!1,WaveViewer.SVWEventHandler.setIsMoving(this.comp),this.comp.hidePinLabels(),this.firstMovement=!0,this.comp.isEditable()&&!this.design.getWireMgr().inWireMode())&&(this.moving=!1,this.comp.toFront(),this.design.getSelectionManager().isPasteActive()?this.setSkipSelection():r.ctrlKey||r.metaKey||this.design.getUndoManager().startUndoableCommand(n.MoveComponentCommand,this.design,this.comp))},t.prototype.dragMove=function(t,i,r,u,f){if((t!=0||i!=0)&&this.comp.isEditable()&&!this.design.getWireMgr().inWireMode()&&typeof this.firstMovement!="undefined"&&(this.firstMovement&&(this.comp.finishAnimation(),f.ctrlKey||f.metaKey?(this.design.getSelectionManager().copySelection(),this.design.getSelectionManager().pasteSelection(!0,!1),this.ctrlDragCopyPaste=!0):this.initDragConnections(),this.design.getWireBar().disable(),this.design.getSymbolBar().disable(),this.comp.hidePinLabels(),this.firstMovement=!1),!this.ctrlDragCopyPaste)){var s=this.design.getSurface().getScale(),h=t*s,c=i*s,e=h-this.diffX,o=c-this.diffY;this.comp.transform(n.Utility.pointToTransform(e,o));this.comp.getNametag().transform(e,o);this.diffX=h;this.diffY=c;this.moving=!0;this.dragConnections(e,o)}},t.prototype.dragEnd=function(t){var i=this,s,f,e,r,u,c;if(this.moving=!1,this.design.getWireBar().enable(),this.design.getSymbolBar().enable(),typeof this.firstMovement!="undefined"){if(this.ctrlDragCopyPaste){this.finishDragEnd();return}var o=null,l=this.design.getSelectionManager(),h=l.getNumSelected()==1;if(this.diffX==0&&this.diffY==0){if(this.design.getWireMgr().inWireMode())return;this.skipSelection||(this.comp.setOpeningCompMenu(t.which==3),this.design.selectObject(this.comp,t),this.comp.setOpeningCompMenu(!1));this.doubleClickDetector?(this.doubleClickDetector=!1,s=surface.getPropertyEditor(),this.comp.isGroundOrReferenceComponent()?s.closeOrClear():(this.comp.showPropWindow(t,!0),s.open(),this.comp.getCompMenu()&&this.comp.getCompMenu().hide())):this.doubleClickDetector=!0;window.setTimeout(function(){i.doubleClickDetector=!1},DOUBLE_CLICK_SPEED)}else f=this.comp.getCenter(),e=f.clone(),e.placeOnGrid(n.Settings.SCH_GRID_SPACING),r=e.x-f.x,u=e.y-f.y,o=this.comp.transform(n.Utility.pointToTransform(r,u),h),this.comp.getNametag().transform(r,u);this.comp.isSinglySelected()&&this.comp.isEditable()&&this.design.getSymbolBar().show(this.comp);!this.firstMovement&&this.comp.isEditable()?(c=this.finalizeDragConnections(r,u),h&&(this.design.getConnMgr().disableFinalize(),this.comp.tryToConnect(r,u),this.design.getConnMgr().enableFinalize()),o?$.when(o,c).done(function(){i.design.getConnMgr().finalize();i.design.getSelectionManager().isPasteActive()||i.design.getUndoManager().finishUndoableCommand(null);i.comp.buildConnectedNametags()}):this.design.getUndoManager().clearActiveCommand()):this.design.getUndoManager().clearActiveCommand();this.finishDragEnd()}},t.prototype.finishDragEnd=function(){WaveViewer.SVWEventHandler.setIsMoving(null);this.skipSelection=!1},t.prototype.finishDragPinAnimation=function(){for(var n=0;n<this.dragPins.length;n++)this.dragPins[n].finishAnimation()},t.prototype.clearDragPins=function(){this.dragPins=[]},t.prototype.initDragConnections=function(){var i=this.design.getSelectionManager(),t,n,r,u;if(i.getNumSelected()==1)for(t=this.comp.getPins(),n=0;n<t.length;n++)r=t[n],u=new BaseWire.WireDragPin(this.design,r),this.dragPins.push(u);else i.initDragSelectedSet(this.comp)},t.prototype.dragConnections=function(n,t){var r=this.design.getSelectionManager(),i,u;if(r.getNumSelected()==1)for(i=0;i<this.dragPins.length;i++)u=this.dragPins[i],u.drag(n,t);else r.dragSelectedSet(this.comp,n,t)},t.prototype.finalizeDragConnections=function(n,t){var r=jQuery.Deferred(),f=this.design.getSelectionManager(),u,i,e;if(f.getNumSelected()==1){for(u=[],i=0;i<this.dragPins.length;i++)e=this.dragPins[i],u.push(e.finalize(n,t));$.when.apply($,u).done(function(){r.resolve()})}else f.finalizeDragSelectedSet(this.comp,n,t),r.resolve();return r},t}(),y=function(){function t(n,t){this.moving=!1;this.design=n;this.comp=t}return t.prototype.init=function(n){var t=this;this.nametag=n;var i=function(n,i,r){return t.dragStart(n,i,r),{}},r=function(n,i,r,u,f){return t.dragMove(n,i,r,u,f),{}},u=function(n){return t.dragEnd(n),{}};this.nametag.drag(r,i,u)},t.prototype.isMoving=function(){return this.moving},t.prototype.dragStart=function(){(WaveViewer.SVWEventHandler.setIsMoving(this.nametag),this.comp.isEditable())&&(this.design.getUndoManager().startUndoableCommand(n.MoveComponentNametagCommand,this.design,this.comp),this.moving=!0,this.design.getSelectionManager().clearSelection(),this.diffX=0,this.diffY=0)},t.prototype.dragMove=function(t,i){if((t!=0||i!=0)&&this.comp.isEditable()){this.diffX==0&&this.diffY==0&&this.comp.showHighlightBox(r.HIGHLIGHT,!0);var u=this.design.getSurface().getScale(),f=t*u,e=i*u,o=f-this.diffX,s=e-this.diffY;this.nametag.transform(n.Utility.pointToTransform(o,s));this.diffX=f;this.diffY=e}},t.prototype.dragEnd=function(){if(WaveViewer.SVWEventHandler.setIsMoving(null),this.moving=!1,this.comp.validate().length>0?this.comp.showHighlightBox(r.WARNING,!0):this.comp.hideHighlightBox(!0),(!this.diffX||this.diffX==0)&&(!this.diffY||this.diffY==0)){this.design.getUndoManager().clearActiveCommand();return}var i=this.nametag[0].getBBox(),u=new BaseWire.Point(i.x,i.y);u.add(t.LeftOffset,t.TopOffset);this.comp.setNametagPoint(u);this.comp.setNametagUserMoved(!0);this.comp.buildNametag();this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS);this.design.getUndoManager().finishUndoableCommand(this.comp.getNametag())},t.LeftOffset=-1,t.TopOffset=8,t}(),a=function(){function n(n){var e=n.getCenter(),o,i,t,r;for(e.round(),this.cx=e.x,this.cy=e.y,this.dbComp=n.getDbComp(),this.rotation=n.getRotation(),this.mirror=n.getMirror(),this.instName=n.getInstName(),this.nametag=new f(surface.getDesign(),n),this.nametag.setPoint(new BaseWire.Point(0,0)),this.nametag.setUserMoved(!1),this.instProps=[],o=n.getInstProps(),i=0;i<o.length;i++)t=new u,r=o[i],t.name=r.getName(),t.value=r.getValue(),t.visible=r.getVisibility(),this.instProps.push(t)}return n}();n.ComponentCloneData=a;s=function(){function n(n,t,i,r){this.comp=n;this.name=t;this.cb=i;this.context=r;this.value=this.comp.getPropValue(this.name)}return n.prototype.changeValue=function(n){this.value!=n&&(this.cb(this.context,name,n),this.value=n)},n}();n.PropertyTracker=s;f=function(){function t(n,t){this.label=null;this.point=null;this.userMoved=!1;this.design=n;this.component=t;this.dragNametagHandler=new y(n,t)}return t.prototype.getSaveData=function(){return new h(this)},t.prototype.restore=function(n){n&&(this.point=new BaseWire.Point(n.x,n.y),this.userMoved=n.userMoved)},t.prototype.getLabel=function(){return this.label},t.prototype.getX=function(){return this.point==null?null:this.point.x},t.prototype.getY=function(){return this.point==null?null:this.point.y},t.prototype.getPoint=function(){return this.point},t.prototype.setPoint=function(n){this.point=n.clone()},t.prototype.getUserMoved=function(){return this.userMoved},t.prototype.setUserMoved=function(n){this.userMoved=n},t.prototype.initLabel=function(){this.label=this.design.getPaper().set()},t.prototype.push=function(n){this.label&&this.label.push(n)},t.prototype.isMoving=function(){return this.dragNametagHandler.isMoving()},t.prototype.draw=function(t,i,r){var u,f;this.label.length>0&&(this.label.attr({"text-anchor":"start",fill:"#344449","font-size":12,opacity:0}).transform("...T.5,.5"),r&&this.label.attr({"font-weight":"bold"}),this.design.getSurface().isEditable()&&this.label.attr("cursor","move"),u=this.label[this.label.length-1].getBBox(),!this.userMoved&&Raphael.isBBoxIntersect(t,u)&&(f=u.y2-t.y+6,this.label.transform(n.Utility.pointToTransform(0,-f))),this.dragNametagHandler.init(this.label),i?this.label.animate({opacity:1},300):this.label.attr("opacity",1))},t.prototype.remove=function(n){var t=this;this.label&&(n?this.label.animate({opacity:0},300,null,function(){t.label.remove();t.label=null}):(this.label.remove(),this.label=null))},t.prototype.transform=function(t,i){this.point&&this.point.add(t,i);this.label&&this.label.transform(n.Utility.pointToTransform(t,i))},t.prototype.toFront=function(){this.label&&this.label.toFront()},t}();n.ComponentNametag=f;h=function(){function n(n){this.x=n.getX();this.y=n.getY();this.userMoved=n.getUserMoved()}return n}();n.ComponentNametagState=h;c=function(){function t(){this.instProps=[];this.pinConnections=[]}return t.prototype.compareTo=function(t,i,r,u){var f=i+PATH_SEPARATOR+this.compName;return n.Utility.comparePrimitives(this.compName,t.compName,"compName",i,r)?n.Utility.comparePrimitives(this.componentId,t.componentId,"componentId",f,r)?n.Utility.comparePrimitives(this.cx,t.cx,"cx",f,r)?n.Utility.comparePrimitives(this.cy,t.cy,"cy",f,r)?n.Utility.comparePrimitives(this.library,t.library,"library",f,r)?n.Utility.comparePrimitives(this.rotation,t.rotation,"rotation",f,r)?n.Utility.comparePrimitives(this.mirror,t.mirror,"mirror",f,r)?n.Utility.comparePrimitives(this.instName,t.instName,"instName",f,r)?n.Utility.comparePrimitives(this.instNameVisibility,t.instNameVisibility,"instNameVisibility",f,r)?this.compareInstProperty(this.instProps,t.instProps,f,r,u)?n.Utility.compareArrays(this.pinConnections,t.pinConnections,"pinName",f,r,u)?!0:!1:!1:!1:!1:!1:!1:!1:!1:!1:!1:!1},t.prototype.compareInstProperty=function(n,t,i,r,u){var e,s,o,f,h;if(!n||!t||n.length==0||t.length==0)return!0;for(n.length>=t.length?(e=n,s=t):(e=t,s=n),o=0;o<e.length;o++)if(f=e[o],f&&f.name&&f.name!=""&&(h=this.findInstPropByName(f.name,s),!f.compareTo(h,i,r,u)))return!1;return!0},t.prototype.findInstPropByName=function(n,t){for(var r,i=0;i<t.length;i++)if(r=t[i],r.name==n)return r;return null},t}();n.ComponentState=c;e=function(){function n(n,t,i){this.state=new u;this.state.name=n;this.state.value=t;this.state.visible=i}return n.prototype.getName=function(){return this.state.name},n.prototype.getValue=function(){return this.state.value},n.prototype.setValue=function(n){this.state.value=n},n.prototype.getVisibility=function(){return this.state.visible},n.prototype.setVisibility=function(n){this.state.visible=n},n.prototype.getSaveData=function(){var n=new u;return n.name=this.state.name,n.value=this.state.value,n.visible=this.state.visible,n},n}();n.InstanceProperty=e;u=function(){function t(){}return t.prototype.compareTo=function(t,i,r){var u=i+PATH_SEPARATOR+this.name,f;return t?n.Utility.comparePrimitives(this.name,t.name,"name",i,r)?this.compareInstancePropValue(t.value,u,r)?n.Utility.comparePrimitives(this.visible,t.visible,"visible",u,r)?!0:!1:!1:!1:(f="Instance Property for comp"+i+" with name "+this.name+" is NULL",n.Utility.showErrorInConsole(f,r),!1)},t.prototype.compareInstancePropValue=function(t,i,r){var u="Instance Property for comp"+i+" with name "+this.name+" has different values ("+this.value+" and "+t+")";return n.Utility.checkForNull(this.value,t,this.name,!0)==n.NULL_CHECK.ONE_NULL?(n.Utility.showErrorInConsole(u,r),!1):n.Utility.checkForNull(this.value,t,name,!0)==n.NULL_CHECK.BOTH_NULL?!0:this.value!=t?(n.Utility.showErrorInConsole(u,r),!1):!0},t}();n.InstancePropertyState=u}(Project||(Project={}));json_parse=function(){"use strict";var u,n,o={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},e,r=function(n){throw{name:"SyntaxError",message:n,at:u,text:e};},t=function(t){return t&&t!==n&&r("Expected '"+t+"' instead of '"+n+"'"),n=e.charAt(u),u+=1,n},s=function(){var u,i="";for(n==="-"&&(i="-",t("-"));n>="0"&&n<="9";)i+=n,t();if(n===".")for(i+=".";t()&&n>="0"&&n<="9";)i+=n;if(n==="e"||n==="E")for(i+=n,t(),(n==="-"||n==="+")&&(i+=n,t());n>="0"&&n<="9";)i+=n,t();if(u=+i,isFinite(u))return u;r("Bad number")},h=function(){var f,e,i="",u;if(n==='"')while(t()){if(n==='"')return t(),i;if(n==="\\")if(t(),n==="u"){for(u=0,e=0;e<4;e+=1){if(f=parseInt(t(),16),!isFinite(f))break;u=u*16+f}i+=String.fromCharCode(u)}else if(typeof o[n]=="string")i+=o[n];else break;else i+=n}r("Bad string")},i=function(){while(n&&n<=" ")t()},c=function(){switch(n){case"t":return t("t"),t("r"),t("u"),t("e"),!0;case"f":return t("f"),t("a"),t("l"),t("s"),t("e"),!1;case"n":return t("n"),t("u"),t("l"),t("l"),null}r("Unexpected '"+n+"'")},f,l=function(){var u=[];if(n==="["){if(t("["),i(),n==="]")return t("]"),u;while(n){if(u.push(f()),i(),n==="]")return t("]"),u;t(",");i()}}r("Bad array")},a=function(){var u,e={};if(n==="{"){if(t("{"),i(),n==="}")return t("}"),e;while(n){if(u=h(),i(),t(":"),Object.hasOwnProperty.call(e,u)&&r('Duplicate key "'+u+'"'),e[u]=f(),i(),n==="}")return t("}"),e;t(",");i()}}r("Bad object")};return f=function(){i();switch(n){case"{":return a();case"[":return l();case'"':return h();case"-":return s();default:return n>="0"&&n<="9"?s():c()}},function(t,o){var s;return e=t,u=0,n=" ",s=f(),i(),n&&r("Syntax error"),typeof o=="function"?function h(n,t){var r,u,i=n[t];if(i&&typeof i=="object")for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(u=h(i,r),u!==undefined?i[r]=u:delete i[r]);return o.call(n,t,i)}({"":s},""):s}}();typeof JSON!="object"&&(JSON={}),function(){"use strict";function i(n){return n<10?"0"+n:n}function o(n){return e.lastIndex=0,e.test(n)?'"'+n.replace(e,function(n){var t=s[n];return typeof t=="string"?t:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+n+'"'}function u(i,f){var s,l,h,a,v=n,c,e=f[i];e&&typeof e=="object"&&typeof e.toJSON=="function"&&(e=e.toJSON(i));typeof t=="function"&&(e=t.call(f,i,e));switch(typeof e){case"string":return o(e);case"number":return isFinite(e)?String(e):"null";case"boolean":case"null":return String(e);case"object":if(!e)return"null";if(n+=r,c=[],Object.prototype.toString.apply(e)==="[object Array]"){for(a=e.length,s=0;s<a;s+=1)c[s]=u(s,e)||"null";return h=c.length===0?"[]":n?"[\n"+n+c.join(",\n"+n)+"\n"+v+"]":"["+c.join(",")+"]",n=v,h}if(t&&typeof t=="object")for(a=t.length,s=0;s<a;s+=1)typeof t[s]=="string"&&(l=t[s],h=u(l,e),h&&c.push(o(l)+(n?": ":":")+h));else for(l in e)Object.prototype.hasOwnProperty.call(e,l)&&(h=u(l,e),h&&c.push(o(l)+(n?": ":":")+h));return h=c.length===0?"{}":n?"{\n"+n+c.join(",\n"+n)+"\n"+v+"}":"{"+c.join(",")+"}",n=v,h}}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+i(this.getUTCMonth()+1)+"-"+i(this.getUTCDate())+"T"+i(this.getUTCHours())+":"+i(this.getUTCMinutes())+":"+i(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var f=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,r,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},t;typeof JSON.stringify!="function"&&(JSON.stringify=function(i,f,e){var o;if(n="",r="",typeof e=="number")for(o=0;o<e;o+=1)r+=" ";else typeof e=="string"&&(r=e);if(t=f,f&&typeof f!="function"&&(typeof f!="object"||typeof f.length!="number"))throw new Error("JSON.stringify");return u("",{"":i})});typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(n,t){var r,u,i=n[t];if(i&&typeof i=="object")for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(u=walk(i,r),u!==undefined?i[r]=u:delete i[r]);return reviver.call(n,t,i)}var j;if(text=String(text),f.lastIndex=0,f.test(text)&&(text=text.replace(f,function(n){return"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse");})}(),function(n){var f,e,r,u,t,i;(function(n){n[n.IN=0]="IN";n[n.OUT=1]="OUT";n[n.INOUT=2]="INOUT";n[n.NONE=3]="NONE"})(n.PIN_MODE||(n.PIN_MODE={}));f=n.PIN_MODE,function(n){n[n.SIGNAL=0]="SIGNAL";n[n.QUANTITY=1]="QUANTITY";n[n.TERMINAL=2]="TERMINAL"}(n.PIN_TYPE||(n.PIN_TYPE={}));e=n.PIN_TYPE;r=function(){function r(n,t,i){this.typeVector=!1;this.vectorIndices=null;this.vectorGenericNamesIdx1=null;this.vectorGenericNamesIdx2=null;this.vectorGenericExprIdx1=null;this.vectorGenericExprIdx2=null;this.dumpStr="";this.design=n;this.comp=t;this.pinInfo=i;this.name=i.Name;this.x=parseInt(i.X);this.y=parseInt(i.Y);this.mode=parseInt(i.Mode);this.quadrant=parseInt(i.Orientation);this.type=parseInt(i.Type);this.subtype=i.SubType;this.processSubtype();this.draw();this.show();this.defineEvents();this.connection=null}return r.prototype.remove=function(){this.graphic&&this.graphic.remove();this.connection&&this.connection.disconnectPin(this);r.hideLabels()},r.prototype.transform=function(n,t){var i=this.graphic.transform(n);return t&&this.maintainConnection(),i},r.prototype.animate=function(n,t,i,r){var e=this,u,f=jQuery.Deferred();return u=Raphael.animation({transform:n},t,i,function(){r&&e.maintainConnection();f.resolve()}),this.graphic.animate(u),f},r.prototype.finishAnimation=function(t){n.Utility.finishAnimation(this.graphic);t&&this.maintainConnection()},r.prototype.toFront=function(){this.graphic.toFront()},r.prototype.highlight=function(){this.isVisible&&(this.graphic.animate({"stroke-width":"5"},400),this.graphic.attr("opacity",.9))},r.prototype.unhighlight=function(){this.isVisible&&(this.graphic.animate({"stroke-width":"1"},400),this.graphic.attr("opacity",r.OPACITY))},r.prototype.show=function(){this.isVisible||(this.graphic.attr("stroke-width","1"),this.graphic.attr("opacity",r.OPACITY),this.isVisible=!0)},r.prototype.hide=function(){this.isVisible&&(this.graphic.attr("opacity","0"),this.isVisible=!1)},r.prototype.showLabel=function(){var u=this.graphic.getBBox();if(u){var o=new BaseWire.Point(u.cx,u.cy),t=surface.schToScreen(o),e="compPinLabel_"+this.name;$(document.body).append('<div class="'+r.PIN_LABEL_CLASS+'" id="'+e+'"><span>'+this.name+"<\/span><\/div>");var n=$("#"+e),s=n.children().first(),f=s.width()+6,i=n.outerHeight();n.css("width",f);switch(this.getQuadrant()){case BaseWire.QUADRANT.NORTH:n.css("transform","rotate(270deg)");n.offset({left:t.x-i/2,top:t.y-f});break;case BaseWire.QUADRANT.EAST:n.offset({left:t.x,top:t.y-i/2});break;case BaseWire.QUADRANT.SOUTH:n.css("transform","rotate(270deg)");n.offset({left:t.x-i/2,top:t.y});break;case BaseWire.QUADRANT.WEST:n.offset({left:t.x-f,top:t.y-i/2})}}},r.hideLabels=function(){$("."+r.PIN_LABEL_CLASS).remove()},r.prototype.isEventInside=function(t){if(!t)return!1;var i=n.Utility.eventToPoint(this.design,t);return n.Utility.isPointInsideBoundingRect(this.graphic.getBBox(),i.x,i.y)},r.prototype.isPointInside=function(t){var i=this.graphic.getBBox();return n.Utility.isPointInsideBoundingRect(i,t.x,t.y)},r.prototype.getLocation=function(){var n=this.getExactLocation();return n.round(),n},r.prototype.getExactLocation=function(){var n=this.graphic.getBBox();return new BaseWire.Point(n.x+n.width/2,n.y+n.height/2)},r.prototype.getName=function(){return this.name},r.prototype.getComponent=function(){return this.comp},r.prototype.getMode=function(){return this.mode},r.prototype.getQuadrant=function(){var i=this.comp.getRotation(),r=this.comp.getMirror(),u=BaseWire.QUADRANT.NORTH,f=BaseWire.QUADRANT.SOUTH,e=BaseWire.QUADRANT.EAST,o=BaseWire.QUADRANT.WEST,t=BaseWire.Quadrant.rotatedQuadrant(this.quadrant,i);return r==n.MIRROR.MIRROR_X?i==n.ROTATION.ROT_0||i==n.ROTATION.ROT_180?(t==u||t==f)&&(t=BaseWire.Quadrant.opposite(t)):(t==e||t==o)&&(t=BaseWire.Quadrant.opposite(t)):r==n.MIRROR.MIRROR_Y&&(i==n.ROTATION.ROT_0||i==n.ROTATION.ROT_180?(t==e||t==o)&&(t=BaseWire.Quadrant.opposite(t)):(t==u||t==f)&&(t=BaseWire.Quadrant.opposite(t))),t},r.prototype.getType=function(){return this.type},r.prototype.getSubtype=function(){return this.subtype.toLowerCase()},r.prototype.getTechnology=function(){return n.Utility.getPinTechnology(this.getType(),this.getSubtype())},r.prototype.changeTechnology=function(n){var t=this.getTechnology();this.subtype=this.design.getCssClassMgr().getTerminalSubtype(n);this.comp.changePinWhiskerTechnology(t,n)},r.prototype.getClass=function(){return this.design.getCssClassMgr().getPinIndicatorClass(this.getTechnology())},r.prototype.isVector=function(){return this.typeVector},r.prototype.getVectorIndices=function(){return this.vectorIndices},r.prototype.getVectorWidth=function(){return this.isVector()?this.vectorIndices.getWidth():null},r.prototype.getVectorIndicesString=function(){return this.isVector()?this.vectorIndices.getBusString():""},r.prototype.isConnected=function(){return this.connection?!0:!1},r.prototype.getConnection=function(){return this.connection},r.prototype.getWire=function(){var n=this.getConnection();return n?n.getWire():null},r.prototype.disconnect=function(){this.connection&&this.connection.disconnectPin(this)},r.prototype.visibleDisconnect=function(){var n=this.connection,t,i;n&&(this.disconnect(),n.getNumConnections()==1&&n.getNumConnectedWireSegments()==1&&(t=n.getWireSegment(0),i=n.getWireSegmentEnd(0),t.shorten(i,3)))},r.prototype.attachConnection=function(t){this.connection=t;this.hide();this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},r.prototype.removeConnection=function(){this.connection=null;this.show();this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)},r.prototype.suspendConnection=function(){var t=this.connection;return t&&(this.connection.removePin(this),this.connection=null,this.design.setDirty(n.DIRTY_FLAG.DIRTY_SCHEMATIC_CLEAN_SIM_RESULTS)),t},r.prototype.getNetNamePrefix=function(){var n=null;return this.connection&&(n=this.connection.getNetNamePrefix()),n},r.prototype.getForcedNetName=function(){return this.getComponent().isGroundOrReferenceComponent()?r.FORCED_NET_NAME:null},r.prototype.tryToConnect=function(i,u){var e,f,o,s;return this.getConnection()!=null?new t(null,null):(e=this.getExactLocation(),e.add(i,u),e.round(),f=this.design.findObjectUnderPoint(e,this.getComponent()),f==null)?new t(null,null):(o=n.Utility.getIllegalConnectionMsg(f,this),o==null&&(f instanceof BaseWire.WireSegment?(s=f.getWire(),this.design.getUndoManager().addToStartState(s),this.connectToWireSegment(e,f)):f instanceof r&&this.connectToPin(f)),new t(this.getConnection(),o))},r.prototype.connectToWireSegment=function(n,t){var f=t.getClosest(n),r,u,i;f.isAlmostEqual(n)&&(r=t.getEndLocation(1),u=t.getEndLocation(2),r.isAlmostEqual(n)?t.connectEnd1(this):u.isAlmostEqual(n)?t.connectEnd2(this):(t.isBus()&&this.getVectorWidth()>0&&t.getWire()&&t.getWire().getWidth()==-1&&t.getWire().setBusIndices(this.getVectorIndices().clone()),i=new BaseWire.Connection(this.design),i.moveTo(n),t.split(i),i.connectToPin(this),this.getComponent().isGroundOrReferenceComponent()&&t.updateGroundComponentToMatchTechnology()))},r.prototype.connectToPin=function(n){var r=n.getLocation(),f=new BaseWire.Segment(r,r),u=this.isVector(),t=new BaseWire.WireSegment(this.design,f,u,this.getTechnology()),i=new BaseWire.Wire(this.design,t),e;u&&(this.getVectorWidth()>0?i.setBusIndices(this.getVectorIndices().clone()):i.setBusIndices(n.getVectorIndices().clone()));e=new BaseWire.Net(this.design,i);t.connectEnd1(n);t.connectEnd2(this)},r.prototype.maintainConnection=function(){var u=this.connection,i,r,n,t,o,f;if(u&&(i=u.getLocation(),r=this.getLocation(),!i.isEqual(r))){if(this.suspendConnection(),n=null,t=null,i.isDiagonal(r)){var s=i.clone(),e=new BaseWire.Point(i.x,r.y),c=r.clone(),h=new BaseWire.Segment(s,e),l=new BaseWire.Segment(e,c);n=new BaseWire.WireSegment(this.design,h,this.isVector(),this.getTechnology());t=new BaseWire.WireSegment(this.design,l,this.isVector(),this.getTechnology());o=new BaseWire.Connection(this.design);o.connectToWireSegment(n,2);o.connectToWireSegment(t,1)}else{var s=i.clone(),e=r.clone(),h=new BaseWire.Segment(s,e);n=new BaseWire.WireSegment(this.design,h,this.isVector(),this.getTechnology());t=n}f=u.getWire();f&&(f.addWireSegment(n),n!=t&&f.addWireSegment(t));u.connectToWireSegment(n,1);t.connectEnd2(this)}},r.prototype.dump=function(t,i){var u,f,r;n.Utility.dumpHeading(t,i);n.Utility.dump(t,'pin "'+this.name+'" is at '+this.x+","+this.y);n.Utility.dump(t,"mode =  "+this.mode+", type = "+this.type+", subtype = "+this.subtype+", quadrant = "+BaseWire.Quadrant.toString(this.quadrant));this.connection&&(u=this.connection.getWire(),u&&(f=u.getName(),r=this.connection.getNumConnections(),r==1?n.Utility.dump(t,"This pin has 1 connecction with name "+f):r>1&&n.Utility.dump(t,"This pin has "+r+" connections with name "+f)),this.connection.dump(t+1,"Connection info"))},r.prototype.defineEvents=function(){var t=this;this.graphic.mousedown(function(n){if(t.isEditable()&&!t.isConnected()&&n.which==1&&!t.design.getWireMgr().inWireMode()){var i=new BaseWire.WireActiveSegments(t.design,n,t.comp,t);t.hide();t.design.getWireMgr().destroyConnectTTip();WaveViewer.SVWEventHandler.setIsMoving(i);t.design.clearSelection()}});n.Utility.hoverEventWithToFront(this.graphic,function(n){t.hoverIn(n)},function(){t.hoverOut()})},r.prototype.hoverIn=function(n){this.isEditable()&&(!this.isConnected()||this.design.getWireMgr().inWireMode())&&this.design.isHoverEnabled()&&(this.mouseOverPin(n),this.design.getWireMgr().inWireMode()&&this.toFront())},r.prototype.hoverOut=function(){this.isEditable()&&(!this.isConnected()||this.design.getWireMgr().inWireMode())&&this.design.isHoverEnabled()&&(this.design.getWireMgr().setDefaultCursor(),this.design.getWireMgr().destroyConnectTTip(),this.unhighlight())},r.prototype.mouseOverPin=function(n){this.design.getWireBar().hide();this.design.getSymbolBar().hide();var r=!1,t=null,u=0,i=this.design.getWireMgr();i.mouseOverPin(this,n);i.inWireMode()?(t=i.getIllegalConnectionMsg(this),u=0,t==null&&(r=!0)):(r=!0,t="Start new connection from ",this.isVector()?t+="bus "+this.getName()+this.getVectorIndicesString():(t+="pin "+this.getName()+"<br/>",t+=this.getTTipString()),u=500);i.setConnectCursor(r);r&&this.highlight();i.showConnectTTip(this.graphic.node,t,u)},r.prototype.isEditable=function(){return this.design.getSurface().isEditable()?!0:!1},r.prototype.getSize=function(){return this.isVector()?r.SIZE_VECTOR:r.SIZE_SCALAR},r.prototype.getTTipString=function(){switch(this.getTechnology()){case n.TECHNOLOGY.ELEC:return" (Electrical Type)";case n.TECHNOLOGY.ROT_VEL:return" (Rotational Velocity Type)";case n.TECHNOLOGY.ROT:return" (Rotational Type)";case n.TECHNOLOGY.MAGNETIC:return" (Magnetic Type)";case n.TECHNOLOGY.QUANTITY:return" (Quantity Type)";case n.TECHNOLOGY.DIGITAL:return" (Digital Type)";case n.TECHNOLOGY.REAL:return" (Real Type)";case n.TECHNOLOGY.INTEGER:return" (Integer Type)";case n.TECHNOLOGY.BOOLEAN:return" (Boolean Type)";case n.TECHNOLOGY.BIT:return" (Bit Type)";case n.TECHNOLOGY.THERMAL:return" (Thermal Type)";case n.TECHNOLOGY.FLUIDIC:return" (Fluidic Type)";case n.TECHNOLOGY.TRAN:return" (Translational Type)";case n.TECHNOLOGY.OTHER_TERM:return" (Custom Terminal Type)";case n.TECHNOLOGY.OTHER_SIG:return" (Custom Signal Type)"}return""},r.prototype.draw=function(){var n=this.getSize(),i=this.x-n,r=this.y-n,t=n*2,u=t;this.graphic=this.design.getPaper().rect(i,r,t,u);this.graphic.attr("stroke-width","1");this.graphic.toFront();this.graphic.node.setAttribute("class",this.getClass())},r.prototype.processSubtype=function(){var t=this.getSubtype(),e=t.indexOf("_vector"),n=t.indexOf("("),u=t.lastIndexOf(")"),i,f,r,o,s;e>0&&(n==-1&&u==-1?(this.typeVector=!0,this.vectorIndices=new BaseWire.BusIndices(-1,-1)):n>e&&u>n&&(i=t.substr(n+1,u-n-1),i.indexOf("downto")>0?f="downto":i.indexOf("to")&&(f="to"),r=i.split(f),r.length==2&&(o=this.processIndex(r[0],1),s=this.processIndex(r[1],2),this.typeVector=!0,this.vectorIndices=new BaseWire.BusIndices(o,s))))},r.prototype.processIndex=function(n,t){var i=Number(n);return isNaN(i)&&(i=this.processVariableIndex(n,t)),i},r.prototype.processVariableIndex=function(n,t){var r,e,u,i,f,o;for(t==1?(this.vectorGenericNamesIdx1=[],this.vectorGenericExprIdx1=n,r=this.vectorGenericNamesIdx1):(this.vectorGenericNamesIdx2=[],this.vectorGenericExprIdx2=n,r=this.vectorGenericNamesIdx2),e=n.toLowerCase(),u=this.getComponent().getDbCompProps(),i=0;i<u.length;++i)f=u[i],o=f.Name.toLowerCase(),e.indexOf(o)>=0&&r.push(f.Name);return this.registerCallbacks(t),this.evaluateVariableIndex(t)},r.prototype.evaluateVariableIndex=function(idx){var arr,expr,i,name,value,retVal;for(idx==1?(arr=this.vectorGenericNamesIdx1,expr=this.vectorGenericExprIdx1):(arr=this.vectorGenericNamesIdx2,expr=this.vectorGenericExprIdx2),i=0;i<arr.length;++i){if(name=arr[i],value=this.getComponent().getPropValue(name),name&&value)eval(name+"="+value);else return-1;try{return retVal=Number(eval(expr)),isNaN(retVal)&&(retVal=-1),retVal}catch(err){return-1}}},r.prototype.registerCallbacks=function(n){for(var f=new u(this,n),r,i=n==1?this.vectorGenericNamesIdx1:this.vectorGenericNamesIdx2,t=0;t<i.length;++t)r=i[t],this.getComponent().trackPropChange(r,this.propChangeCB,f)},r.prototype.propChangeCB=function(n){var t=n.pin,i=n.index,r=t.evaluateVariableIndex(i);i==1?t.getVectorIndices().setIdx1(r):t.getVectorIndices().setIdx2(r);t.processVectorSizeChange()},r.prototype.processVectorSizeChange=function(){var i=this.connection,n,t;i&&(n=i.getWire(),n)&&(t=[],n.appendConnectedPins(t),t.length>1?(this.visibleDisconnect(),this.design.getConnMgr().finalize()):(n.setBusIndices(this.getVectorIndices().clone()),n.buildNametag()))},r.prototype.addToDump=function(n,t){var i=JSON.stringify(t);this.dumpStr+="\n"+n+": "+i},r.prototype.dumpPin=function(){return this.dumpStr="",this.addToDump("OPACITY",r.OPACITY),this.addToDump("SIZE_SCALAR",r.SIZE_SCALAR),this.addToDump("SIZE_VECTOR",r.SIZE_VECTOR),this.addToDump("isVisible",this.isVisible),this.addToDump("mode",this.mode),this.addToDump("name",this.name),this.addToDump("pinInfo",this.pinInfo),this.addToDump("quadrant",this.quadrant),this.addToDump("subtype",this.subtype),this.addToDump("type",this.type),this.addToDump("x",this.x),this.addToDump("y",this.y),this.dumpStr},r.prototype.getSaveData=function(){var n=new i,t=BaseWire.BUSTYPE.WIRE,u=-1,e=-1,r=this.getWire(),f;return r&&(t=r.getBusType(),t==BaseWire.BUSTYPE.BIT?u=r.getBitIndex():t==BaseWire.BUSTYPE.BUS&&(f=r.getBusIndices(),u=f.getIdx1(),e=f.getIdx2())),n.pinName=this.getName(),n.netName=this.getNetNamePrefix(),n.busType=t,n.busIdx1=u,n.busIdx2=e,n},r.SIZE_SCALAR=4,r.SIZE_VECTOR=6,r.OPACITY=.5,r.FORCED_NET_NAME="0",r.PIN_LABEL_CLASS="svw_sym_pin_label",r}();n.Pin=r;u=function(){function n(n,t){this.pin=n;this.index=t}return n}();t=function(){function n(n,t){this.connection=n;this.message=t}return n}();n.connectionAndMessage=t;i=function(){function t(){}return t.prototype.compareTo=function(t,i,r){var u=i+PATH_SEPARATOR+this.pinName;return n.Utility.comparePrimitives(this.pinName,t.pinName,"pinName",i,r)?n.Utility.comparePrimitives(this.netName,t.netName,"netName",u,r)?n.Utility.comparePrimitives(this.busType,t.busType,"busType",u,r)?n.Utility.comparePrimitives(this.busIdx1,t.busIdx1,"busIdx1",u,r)?n.Utility.comparePrimitives(this.busIdx2,t.busIdx2,"busIdx2",u,r)?!0:!1:!1:!1:!1:!1},t}();n.PinState=i}(Project||(Project={})),function(n){(function(n){n[n.HORIZONTAL=0]="HORIZONTAL";n[n.VERTICAL=1]="VERTICAL"})(n.SE_WHISKER_ORIENTATION||(n.SE_WHISKER_ORIENTATION={}));var i=n.SE_WHISKER_ORIENTATION,t=function(){function t(i,r,u){this.gridState=!0;this.minorGridSet=null;this.majorGridSet=null;this.BACKGROUND="schematicbackground";this.MAJOR_GRID="schematicmajorgrid";this.MINOR_GRID="schematicminorgrid";this.MINOR_COLOR="#F0F0F0";this.MAJOR_COLOR="#CCCCCC";this.ceSymTextArray=[];this.CeSymShapeArray=[];this.initialPinArray=[];this.initialPinArrayWithOffsets=[];this.pinArray=[];this.pinObjElements=[];this.paperWidth=530;this.paperHeight=530;this.scaleX=-1;this.scaleY=-1;this.isSilent=!1;this.imgBaseElements="";this.svgElements=[];var f="unknown";r&&r.Name&&(f=r.Name);n.Settings.notify("model symbol edit",{comp:f});t.GLOBAL_SYMBOL_EDITOR_INDEX++;$("body").append("<div id=symbolEditorDialog"+t.GLOBAL_SYMBOL_EDITOR_INDEX+"><\/div>");u||this.showSymbolEditor();this.surface=i;this.isSilent=u;this.CssClassManager=this.surface.getDesign().getCssClassMgr();this.ceSelectionManager=this.surface.getDesign().getCeSelectionManager();this.comp=new n.CeComponentClone(r);this.img=r.Img;this.fragment=document.createDocumentFragment();t.getSymbolEditorDomNode().html("");t.getSymbolEditorDomNode().css({cursor:"pointer",overflow:"auto"});this.addToolbar();this.addPaper();t.getSymbolEditorDomNode().append(this.fragment.childNodes);this.addEventHandlers();this.recreateSymbol();u&&this.saveComponent();this.setSEMenu()}return t.prototype.recreateSymbol=function(){var u,f,r,i,e,o,s,t;for(this.symEditPaper&&this.symEditPaper.clear(),this.symEditPaper=Raphael("symbolPaper",this.paperWidth,this.paperHeight),this.svgElements=n.CeUtility.getSVGElements(this.img,this.symEditPaper),this.symEditPaper=n.CeUtility.removeElementsByClassTag(this.symEditPaper,"whisker"),this.symEditPaper=n.CeUtility.removeElementsByClassTag(this.symEditPaper,"arrow"),this.svgElements=n.CeUtility.getPaperElements(this.symEditPaper),this.pinArray=n.CeUtility.updatePinArray(this.comp.Pins,this.symEditPaper,this.isSilent),this.svgElements=n.CeUtility.getPaperElements(this.symEditPaper),this.svgElementsSet=this.symEditPaper.set(),t=0;t<this.svgElements.length;t++)this.svgElementsSet.push(this.svgElements[t]);for(u=!1,f=!1,this.svgShapeElementsSet=this.symEditPaper.set(),t=0;t<this.svgElements.length;t++)if(this.svgElements[t][0]){for(r=this.svgElements[t][0].classList,i=0;i<r.length;i++)if(r[i].indexOf("arrow")>-1||r[i].indexOf("whisker")>-1||r[i].indexOf("indicator")>-1||r[i].indexOf("svw_sym_text")>-1||r[i].indexOf("swv_sym_title")>-1||r[i].indexOf("text_rect")>-1||r[i].indexOf("gridHoriz")>-1||r[i].indexOf("gridVert")>-1||r[i].indexOf("schematicbackground")>-1){u=!1;break}else u=!0;f=u&&this.svgElements[t].attr("opacity")!="0"?!0:!1;f&&this.svgShapeElementsSet.push(this.svgElements[t])}for(this.scaleSymbolToCanvas(),e=this.getPaperCenter(),o=new BaseWire.Point(this.scaleX*e.x,this.scaleY*e.y),this.moveToGrid(o.x,o.y),this.drawGridlines(n.Settings.SCH_GRID_SPACING),s=new n.CeSymBaseShapes(this,this.svgShapeElementsSet,null),t=0;t<this.pinArray.length;t++)this.pinObjElements.push(new n.CeSymPin(this,this.pinArray[t],this.comp.Pins[t]));this.svgElements=n.CeUtility.getPaperElements(this.symEditPaper);this.storeRemoveTextElements(this.svgElements)},t.prototype.saveComponent=function(){var t,i;this.hideSymbolEditor();this.preparePaperForSave();this.updateComponent();t=!0;this.comp.ComponentId?(i=n.Settings.APIURI()+"/components?library="+this.comp.Lib+"&componentId="+this.comp.ComponentId,t=!0):(i=n.Settings.APIURI()+"/components?library=UserLib",t=!1);n.CeDebug.isDebugPins&&n.CeDebug.showPins("SE pins (in save)",this.comp.Pins);this.uploadComponent(i,t,this.comp)},t.prototype.initTooltips=function(){n.Utility.setTooltip(t.TOGGLE_GRID_VISIBILITY_BUTTON,"Toggle grid visibility");n.Utility.setTooltip(t.TOGGLE_GRID_VISIBILITY_BUTTON,"Toggle grid visibility");n.Utility.setTooltip(t.FLIP_OBJECT_HORIZONTALLY_BUTTON,"Flip selected object(s) horizontally");n.Utility.setTooltip(t.FLIP_OBJECT_VERTICALLY_BUTTON,"Flip selected object(s) vertically");n.Utility.setTooltip(t.ROTATE_OBJECT_RIGHT_BUTTON,"Rotate selected object(s) right");n.Utility.setTooltip(t.ROTATE_OBJECT_LEFT_BUTTON,"Rotate selected object(s) left");n.Utility.setTooltip(t.ADD_TEXT_BUTTON,"Add text to symbol");n.Utility.setTooltip(t.IMPORT_IMAGE_BUTTON,"Add Image to Symbol (jpg, png, or gif)");n.Utility.setTooltip(t.SAVE_SYMBOL_BUTTON,"Save symbol and close symbol editor")},t.prototype.defineEvents=function(){var i=this,r=$("#symEditToolbar");r.hover(function(){r.stop().animate({opacity:.8},400)},function(){r.stop().animate({opacity:.2},400)});$("#symbolPaper").dblclick(function(){i.ceSelectionManager.clearSelection()});$(t.TOGGLE_GRID_VISIBILITY_BUTTON).click(function(){i.gridState==!0?(i.hideGrid(),i.gridState=!1):(i.showGrid(),i.gridState=!0)});$(t.FLIP_OBJECT_HORIZONTALLY_BUTTON).click(function(){i.selectedPin=i.ceSelectionManager.getSingleSelectedObject();i.selectedPin&&i.selectedPin.mirrorHoriz(i.selectedPin.pinSet)});$(t.FLIP_OBJECT_VERTICALLY_BUTTON).click(function(){i.selectedPin=i.ceSelectionManager.getSingleSelectedObject();i.selectedPin&&i.selectedPin.mirrorVert(i.selectedPin.pinSet)});$(t.ROTATE_OBJECT_RIGHT_BUTTON).click(function(){i.selectedPin=i.ceSelectionManager.getSingleSelectedObject();i.selectedPin&&i.selectedPin.rotateCW(i.selectedPin.pinSet)});$(t.ROTATE_OBJECT_LEFT_BUTTON).click(function(){i.selectedPin=i.ceSelectionManager.getSingleSelectedObject();i.selectedPin&&i.selectedPin.rotateCCW(i.selectedPin.pinSet)});$(t.ADD_TEXT_BUTTON).click(function(){i.addEditableTextBox()});$(t.IMPORT_IMAGE_BUTTON).click(function(){i.ceSymImage=new n.CeSymImage(i.surface,i.symEditPaper);i.ceSymImage.showImportImageDialog()});$(t.SAVE_SYMBOL_BUTTON).click(function(){i.saveComponent()})},t.prototype.drawGridlines=function(n){var e=this.symEditPaper.width,o=this.symEditPaper.height,s=n,h="1",i=0,r,u,f,t;for(this.majorGridSet=this.symEditPaper.set(),this.minorGridSet=this.symEditPaper.set(),r=this.symEditPaper.rect(0,0,e,o),r.attr("fill","#ff0000"),r.attr("opacity","0"),r.node.setAttribute("class",this.BACKGROUND),u=0;u<e;u+=s)t=this.symEditPaper.path("M "+u+" 0 v "+o),t.node.setAttribute("class","gridVert"),i%5==0?this.majorGridSet.push(t):this.minorGridSet.push(t),++i;for(i=0,f=0;f<o;f+=s)t=this.symEditPaper.path("M 0 "+f+" h "+e),t.node.setAttribute("class","gridHoriz"),i%5==0?this.majorGridSet.push(t):this.minorGridSet.push(t),++i;this.majorGridSet.attr("stroke-width",h);this.majorGridSet.attr("stroke",this.MAJOR_COLOR);this.minorGridSet.attr("stroke-width",h);this.minorGridSet.attr("stroke",this.MINOR_COLOR);this.gridToBack()},t.prototype.gridToBack=function(){this.majorGridSet&&this.minorGridSet&&(this.majorGridSet.toBack(),this.minorGridSet.toBack())},t.prototype.hideGrid=function(){this.majorGridSet&&this.minorGridSet&&(this.majorGridSet.hide(),this.minorGridSet.hide())},t.prototype.showGrid=function(){this.majorGridSet&&this.minorGridSet&&(this.majorGridSet.show(),this.minorGridSet.show())},t.prototype.removeGridFromDom=function(){$(".gridVert").remove();$(".gridHoriz").remove()},t.prototype.addToolbar=function(){var n=document.createElement("div");n.id="symbol_editor_toolbar";n.className="symEditToolbar";n.innerHTML='<button id="toggle_grid_visibility_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/grid-dot.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="flip_object_horizontally_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/flipH.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="flip_object_vertically_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/flipV.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="rotate_object_left_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/rotateLeft.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="rotate_object_right_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/rotateRight.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="add_text_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/text2.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="import_image_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/addImage.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="save_symbol_button" class="symbol_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/save.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button>';this.fragment.appendChild(n)},t.prototype.addPaper=function(){var n=document.createElement("div");n.innerHTML='<div id="symbolPaper"><\/div>';this.fragment.appendChild(n)},t.prototype.addEventHandlers=function(){this.defineEvents();this.initTooltips()},t.prototype.preparePaperForSave=function(){var r,u,t,f,i,e,o;for(this.ceSelectionManager.clearSelection(),this.hideGrid(),this.gridState=!1,r=n.CeUtility.getRoundedBBVals(n.CeUtility.getPaperBBoxWithoutTextPinIndicators(this.symEditPaper)),this.removeMiscElements(),this.svgElements=n.CeUtility.getPaperElements(this.symEditPaper),u=n.CeUtility.getRoundedBBVals(n.CeUtility.getPaperBBoxWithoutTextPinIndicators(this.symEditPaper)),t=0;t<this.svgElements.length;t++)if(this.svgElements[t][0])for(f=this.svgElements[t][0].classList,i=0;i<f.length;i++)f[i].indexOf("text_rect")>-1&&(e=Math.round(this.svgElements[t].attr("x")-u.x),o=Math.round(this.svgElements[t].attr("y")-u.y),this.svgElements[t].attr({x:e,y:o}));this.ceSymImage&&this.ceSymImage.extImage&&this.svgElementsSet.push(this.ceSymImage.extImage);this.svgElements=n.CeUtility.getPaperElements(this.symEditPaper);this.transform(n.Utility.pointToTransform(-r.x,-r.y));this.restoreDefaultSymbolScale();this.savePinPositionsOrientation();this.saveTextInfo()},t.prototype.savePinPositionsOrientation=function(){for(var i,u,r,t=0;t<this.comp.Pins.length;t++)for(i=0;i<this.pinObjElements.length;i++)this.comp.Pins[t].Name==this.pinObjElements[i].metaData.Name&&(u=this.pinObjElements[i].getPinOrientation(),this.comp.Pins[t].Orientation=u);for(t=0;t<this.comp.Pins.length;t++)if(n.CeDebug.isDebugSEPins&&console.log("Save pre-update (pins). x = "+this.comp.Pins[t].X+" y = "+this.comp.Pins[t].Y),r=this.symEditPaper.getById(this.comp.Pins[t].Index),r){var f=r.getBBox(),e=f.x+n.CeUtility.PIN_INDICATOR_WIDTH/2,o=f.y+n.CeUtility.PIN_INDICATOR_HEIGHT/2;this.comp.Pins[t].X=Math.round(e);this.comp.Pins[t].Y=Math.round(o);t==0?this.checkUpdateCenterRelativeToPin():this.enforcePinPositionRules(this.comp.Pins[t]);n.CeDebug.isDebugSEPins&&console.log("Save post-update (pins). x = "+this.comp.Pins[t].X+" y = "+this.comp.Pins[t].Y);r.remove()}this.symEditPaper=n.CeUtility.removeElementsByClassTag(this.symEditPaper,"whisker");this.symEditPaper=n.CeUtility.removeElementsByClassTag(this.symEditPaper,"arrow");this.svgElements=n.CeUtility.getPaperElements(this.symEditPaper);this.pinArray=n.CeUtility.updatePinArray(this.comp.Pins,this.symEditPaper,this.isSilent);this.symEditPaper=n.CeUtility.removeElementsByClassTag(this.symEditPaper,"svw_sym_pin_indicator");this.svgElements=n.CeUtility.getPaperElements(this.symEditPaper)},t.prototype.checkUpdateCenterRelativeToPin=function(){var r=this.getUpdatedSymbolCenterCalc(),o=this.symEditPaper.getById(this.comp.Pins[0].Index),e,t;o&&(e=o.getBBox());var s=r.x%n.Settings.SCH_GRID_SPACING,h=r.y%n.Settings.SCH_GRID_SPACING,c=(e.x+n.CeUtility.PIN_INDICATOR_WIDTH/2)%n.Settings.SCH_GRID_SPACING,l=(e.y+n.CeUtility.PIN_INDICATOR_HEIGHT/2)%n.Settings.SCH_GRID_SPACING,u=r.x,f=r.y,i=Math.round(s-c);i>0?i>5?(i=n.Settings.SCH_GRID_SPACING-i,u=r.x+i):(i=-i,u=r.x+i):i<0&&(i<-5?(i=-(n.Settings.SCH_GRID_SPACING+i),u=r.x+i):(i=-i,u=r.x+i));t=Math.round(h-l);t>0?t>5?(t=n.Settings.SCH_GRID_SPACING-t,f=r.y+t):(t=-t,f=r.y+t):t<0&&(t<-5?(t=-(n.Settings.SCH_GRID_SPACING+t),f=r.y+t):(t=-t,f=r.y+t));this.setCurrentSymbolCenterCxCy(u,f)},t.prototype.enforcePinPositionRules=function(t){var o=this.getCurrentSymbolCenterCxCy(),s=this.symEditPaper.getById(t.Index),e,i;s&&(e=s.getBBox());var h=o.x%n.Settings.SCH_GRID_SPACING,c=o.y%n.Settings.SCH_GRID_SPACING,l=(e.x+n.CeUtility.PIN_INDICATOR_WIDTH/2)%n.Settings.SCH_GRID_SPACING,a=(e.y+n.CeUtility.PIN_INDICATOR_HEIGHT/2)%n.Settings.SCH_GRID_SPACING,u=t.X,f=t.Y,r=Math.round(h-l);r>0?r>5?(r=n.Settings.SCH_GRID_SPACING-r,u=t.X+r):(r=-r,u=t.X+r):r<0&&(r<-5?(r=-(n.Settings.SCH_GRID_SPACING+r),u=t.X+r):(r=-r,u=t.X+r));i=Math.round(c-a);i>0?i>5?(i=n.Settings.SCH_GRID_SPACING-i,f=t.Y+i):(i=-i,f=t.Y+i):i<0&&(i<-5?(i=-(n.Settings.SCH_GRID_SPACING+i),f=t.Y+i):(i=-i,f=t.Y+i));t.X=u;t.Y=f},t.prototype.removeMiscElements=function(){for(var f,r,i=n.CeUtility.getPaperElements(this.symEditPaper),u=this.symEditPaper.set(),t=0;t<i.length;t++){if(i[t].attr("opacity")=="0"){u.push(i[t]);continue}if(i[t].type=="text"){u.push(i[t]);continue}if(i[t][0])for(f=i[t][0].classList,r=0;r<f.length;r++)if(f[r].indexOf("svw_sym_bbox")>-1)u.push(i[t]);else if(f[r].indexOf("svw_sym")>-1||f[r].indexOf("text_rect")>-1)break;else u.push(i[t])}u.remove()},t.prototype.saveTextInfo=function(){for(var i,u,f,r,t=0;t<this.ceSymTextArray.length;t++)this.ceSymTextArray[t].addRaphaelText(this.symEditPaper);for(i=n.CeUtility.getPaperElements(this.symEditPaper),u=this.symEditPaper.set(),t=0;t<i.length;t++)if(i[t][0])for(f=i[t][0].classList,r=0;r<f.length;r++)f[r].indexOf("text_rect")>-1&&u.push(i[t]);u.remove()},t.prototype.updateComponent=function(){var i=0,r=0,t=n.CeUtility.getRoundedBBVals(n.CeUtility.getPaperBBoxWithoutText(this.symEditPaper)),e;i=t.width;r=t.height;var f=0,o=i+f,s=r+f,u=this.symEditPaper.toSVG(0,0,i,r);u=u.replace(/&amp;quot;/g,'"');this.isSilent&&this.symEditPaper.clear();e=u.split("<svg");this.comp.Img='<svg viewbox="0,0,'+o+","+s+'"'+e[1];this.comp.Cx=this.getCurrentSymbolCenterCxCy().x;this.comp.Cy=this.getCurrentSymbolCenterCxCy().y;n.CeDebug.isDebugSEPins&&console.log("Final BB (no text) Cx, Cy = \n"+t.x+"  "+t.y+"  "+t.width+"  "+t.height+" Cx = "+this.comp.Cx+" Cy = "+this.comp.Cy+"\n")},t.prototype.uploadComponent=function(i,r,u){n.CeDebug.isDebugFlow&&n.CeDebug.showFlow("SE In uploadComponent");n.CeDebug.isDebugPins&&n.CeDebug.showPins("In SE, just before upload. Pins",u.Pins);$.ajax({headers:{TOKEN_HEADER:"97814435-7337-4390-be35-86ca540f7a1b",userID:n.Utility.getUserID()},type:r?"PUT":"POST",url:i,data:JSON.stringify(u),contentType:"application/json"}).done(function(i){var u,f;n.CeDebug.isDebugPins&&n.CeDebug.showPins("In SE, back from upload. Pins",i.Pins);u=getSchematic();r?(i.library=i.Lib?i.Lib:"UserLib",u.getComponentDataManager().updateCollection(i)):u.getComponentDataManager().addToCollection(i,"UserLib");surface.getComponentBrowserSidebar().openCategory(Sidebar.ComponentBrowser.MY_COMPONENTS_CATEGORY);$("#getCompFromServer").trigger("click",[i.ComponentId,i.Lib]);f=t.getSymbolEditorDomNode().data("kendoWindow");f&&f.close();t.getSymbolEditorDomNode().remove()}).fail(function(t){var i="Component could not be saved: <br />"+t.responseText+" <br />You may need to click the Save new model button so your component can be recreated.";n.MessageManager.showErrorMessage(i)})},t.prototype.showSymbolEditor=function(){function h(){var n=t.getSymbolEditorDomNode();n[0].clientHeight>=t.SYMBOL_EDITOR_HEIGHT?n.css({"overflow-y":"hidden"}):n[0].clientHeight<t.SYMBOL_EDITOR_HEIGHT&&n.css({"overflow-y":"scroll"});n[0].clientWidth>=t.SYMBOL_EDITOR_WIDTH?n.css({"overflow-x":"hidden"}):n[0].clientWidth<t.SYMBOL_EDITOR_WIDTH&&n.css({"overflow-x":"scroll"})}var r=t.SYMBOL_EDITOR_MINWIDTH,u=t.SYMBOL_EDITOR_MINHEIGHT,f=t.SYMBOL_EDITOR_MAXWIDTH,e=t.SYMBOL_EDITOR_MAXHEIGHT,o=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.SE,n.MODELING_APP_DIM.WIDTH),s=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.SE,n.MODELING_APP_DIM.HEIGHT),i;t.getSymbolEditorDomNode().kendoWindow({actions:["Close"],draggable:!0,height:s,width:o,modal:!0,pinned:!1,resizable:!0,title:"Symbol Editor",resize:h,maxHeight:e,maxWidth:f,minHeight:u,minWidth:r,deactivate:function(){this.destroy()}});i=t.getSymbolEditorDomNode().data("kendoWindow");i.center();i.open()},t.prototype.hideSymbolEditor=function(){t.getSymbolEditorDomNode().hide()},t.prototype.storeRemoveTextElements=function(t){var o,e,r,s,i,f,u;for(t=n.CeUtility.getPaperElements(this.symEditPaper),i=0;i<t.length;i++)if(t[i][0])for(f=t[i][0].classList,u=0;u<f.length;u++)(f[u].indexOf("svw_sym_text")>-1||f[u].indexOf("svw_sym_title")>-1)&&(n.CeDebug.isDebugText&&console.log("Read existing Raphael text info. font-size = "+t[i].attr("font-size")+" font-weight = "+t[i].attr("font-weight")+" font-family = "+t[i].attr("font-family")),o=t[i].attr("text"),o=o.replace(/&quot;/g,'"'),$("tspan",t[i].node).attr("dy",0),e=n.CeUtility.getRoundedBBVals(t[i].getBBox()),n.CeDebug.isDebugText&&(console.log("In SE, building ceSymText object. x = "+t[i].attr("x")+" y = "+t[i].attr("y")+" dy = "+$("tspan",t[i].node).attr("dy")),console.log("In SE, BB sent with ceSymText object. x = "+e.x+" y = "+e.y+" height = "+e.height)),r=new n.CeSymText(this),r.set_bb(e),r.set_val(o),r.set_orientation(n.CE_TEXT_ORIENTATION.HORIZ_LR),r.set_visibility(!0),r.set_fontSize(t[i].attr("font-size")),r.set_fontFamily(t[i].attr("font-family")),r.set_fontColor(t[i].attr("fill")),r.set_fontWeight(t[i].attr("font-weight")),r.set_textBoxId("#text"+this.ceSymTextArray.length),r.set_index(this.ceSymTextArray.length),r.initCeSymText(this),this.ceSymTextArray.push(r));for(s=this.symEditPaper.set(),i=0;i<t.length;i++)if(t[i][0])for(f=t[i][0].classList,u=0;u<f.length;u++)(f[u].indexOf("svw_sym_text")>-1||f[u].indexOf("svw_sym_title")>-1)&&s.push(t[i]);s.remove()},t.prototype.addEditableTextBox=function(){var t=new n.CeSymText(this);t.set_bb({x:100,x2:100,y:20,y2:20,width:30,height:20});t.set_val("text"+this.ceSymTextArray.length);t.set_orientation(n.CE_TEXT_ORIENTATION.HORIZ_LR);t.set_visibility(!0);t.set_fontSize(n.CeUtility.DEFAULT_FONT_SIZE);t.set_fontFamily(n.CeUtility.DEFAULT_FONT_FAMILY);t.set_fontColor(n.CeUtility.DEFAULT_FONT_COLOR);t.set_fontWeight(n.CeUtility.DEFAULT_FONT_WEIGHT);t.set_textBoxId("#text"+this.ceSymTextArray.length);t.set_index(this.ceSymTextArray.length);t.initCeSymText(this);this.ceSymTextArray.push(t);$(t.get_textBoxId()).select();n.CeDebug.isDebugText&&console.log("New single textbox. font-size = "+t.get_fontSize()+" font-weight = "+t.get_fontWeight()+" font-family = "+t.get_fontFamily())},t.getSymbolEditorDomNode=function(){return $("#symbolEditorDialog"+t.GLOBAL_SYMBOL_EDITOR_INDEX)},t.prototype.createSEMenu=function(){var i=this,u=function(){var n=t.getSymbolEditorDomNode().data("kendoWindow");n.close()},r,n;i.seMenu||(r="<b>Editor Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,r),n.addMenuElement("Close Symbol Editor",u),n.addSeparatorToMenu(),i.seMenu=SVWebContextMenu.MenuHelper.createMenu(n))},t.prototype.setSEMenu=function(){this.createSEMenu();this.seMenu.bindMenuTo(t.getSymbolEditorDomNode())},t.prototype.moveToGrid=function(t,i){var e=this.getUpdatedSymbolCenterCalc(),r=new BaseWire.Point(t,i),u;if(r.subtract(e),r.placeOnGrid(n.Settings.SCH_GRID_SPACING),this.comp.Pins[0]&&(u=this.symEditPaper.getById(this.comp.Pins[0].Index),u)){var f=u.getBBox(),o=f.x+n.CeUtility.PIN_INDICATOR_WIDTH/2,s=f.y+n.CeUtility.PIN_INDICATOR_HEIGHT/2;r.x-=o%n.Settings.SCH_GRID_SPACING;r.y-=s%n.Settings.SCH_GRID_SPACING}this.transform(n.Utility.pointToTransform(r.x,r.y))},t.prototype.getCurrentSymbolCenterCxCy=function(){return this.centerOffset=new BaseWire.Point(this.comp.Cx,this.comp.Cy),new BaseWire.Point(this.centerOffset.x,this.centerOffset.y)},t.prototype.setCurrentSymbolCenterCxCy=function(n,t){this.comp.Cx=n;this.comp.Cy=t},t.prototype.getUpdatedSymbolCenterCalc=function(){var t=n.CeUtility.getPaperBBoxWithoutTextPinIndicators(this.symEditPaper),i=Math.round(t.width/2),r=Math.round(t.height/2);return this.centerOffset=new BaseWire.Point(i,r),this.comp.Cx=this.centerOffset.x,this.comp.Cy=this.centerOffset.y,new BaseWire.Point(this.centerOffset.x,this.centerOffset.y)},t.prototype.getFontSaveOffsets=function(n){var t=new BaseWire.Point(0,0);return n>=13&&n<15?(t.x=-4,t.y=4):n>9&&n<13&&(t.x=-4,t.y=4),console.log("xOff = "+t.x+" yOff = "+t.y),t},t.prototype.getPaperCenter=function(){var n=this.paperWidth/2,t=this.paperHeight/2;return new BaseWire.Point(n,t)},t.prototype.transform=function(n){this.svgElementsSet.transform(n)},t.prototype.scaleSymbolToCanvas=function(){var i=n.CeUtility.getPaperBBoxWithoutText(this.symEditPaper),r=10,e=i.width,o=i.height,u=e+12*r,f=o+12*r,t=0;t=f>u?f:u;this.scaleX=t/this.paperWidth;this.scaleY=t/this.paperHeight;this.symEditPaper.setViewBox(0,0,t,t,!1)},t.prototype.restoreDefaultSymbolScale=function(){this.symEditPaper.setViewBox(0,0,this.paperWidth,this.paperHeight,!1)},t.GLOBAL_SYMBOL_EDITOR_INDEX=0,t.TOGGLE_GRID_VISIBILITY_BUTTON="#toggle_grid_visibility_button",t.FLIP_OBJECT_HORIZONTALLY_BUTTON="#flip_object_horizontally_button",t.FLIP_OBJECT_VERTICALLY_BUTTON="#flip_object_vertically_button",t.ROTATE_OBJECT_RIGHT_BUTTON="#rotate_object_right_button",t.ROTATE_OBJECT_LEFT_BUTTON="#rotate_object_left_button",t.ADD_TEXT_BUTTON="#add_text_button",t.IMPORT_IMAGE_BUTTON="#import_image_button",t.SAVE_SYMBOL_BUTTON="#save_symbol_button",t.LEFT_OFFSET=35,t.TOP_OFFSET=60,t.SYMBOL_EDITOR_WIDTH=600,t.SYMBOL_EDITOR_HEIGHT=600,t.SYMBOL_EDITOR_MINWIDTH=400,t.SYMBOL_EDITOR_MINHEIGHT=400,t.SYMBOL_EDITOR_MAXWIDTH=610,t.SYMBOL_EDITOR_MAXHEIGHT=620,t}();n.SymbolEditor=t}(Project||(Project={})),function(n){var r,t,i,f,u;(function(n){n[n.HELP=0]="HELP";n[n.COMPILE=1]="COMPILE";n[n.PREVIEW_2SYM=2]="PREVIEW_2SYM";n[n.PREVIEW_1SYM=3]="PREVIEW_1SYM";n[n.SAVE=4]="SAVE";n[n.NONE=5]="NONE"})(n.CE_INFO_PANE||(n.CE_INFO_PANE={}));r=n.CE_INFO_PANE,function(n){n[n.NEW_COPY_FIRST=0]="NEW_COPY_FIRST";n[n.INITIALIZE_ACTIVE=1]="INITIALIZE_ACTIVE";n[n.UPDATE_COMPILE=2]="UPDATE_COMPILE";n[n.UPDATE_NOCOMPILE=3]="UPDATE_NOCOMPILE";n[n.UPDATE_FROM_SE=4]="UPDATE_FROM_SE"}(n.CE_SAVE||(n.CE_SAVE={}));t=n.CE_SAVE,function(n){n[n.DB_COPY_COMP=0]="DB_COPY_COMP";n[n.AUTO_COMP=1]="AUTO_COMP";n[n.NEW_COMP=2]="NEW_COMP";n[n.NONE=3]="NONE"}(n.CE_ACTIVE_COMP||(n.CE_ACTIVE_COMP={}));i=n.CE_ACTIVE_COMP,function(n){n[n.ELECTRICAL_RESISTOR=0]="ELECTRICAL_RESISTOR";n[n.STRUCTURAL=1]="STRUCTURAL"}(n.TEMPLATE_MODEL_SOURCE||(n.TEMPLATE_MODEL_SOURCE={}));f=n.TEMPLATE_MODEL_SOURCE;u=function(){function u(r,f,e,o,s){var c=this,h;this.modelParsedSinceSave=!1;this.symAutoPaper=null;this.symDbPaper=null;this.symNewComponentPaper=null;this.saveState=t.NEW_COPY_FIRST;this.activeCompSel=i.NONE;this.isSpiceParsedOK=!0;this.compStatus=n.CE_STATUS.EDIT;this.myComponentId="";this.modelTitle="";this.modelName="";this.modelDescription="";this.modelDescriptionToolTip="";this.pinMetaData=[];this.compMetaData={};this.cmReadOnly=!1;this.isSpinnerActive=!1;this.isLaunchSE=!1;this.isLaunchSESilent=!1;this.isSVWebLib=!1;this.isOpenUserComp=!1;this.isUpdate=!1;this.isCopy=!1;this.modelType=n.CE_MODEL_TYPE.VHDL;this.editBtnHeight=20;this.editBtnWidth=48;this.selectBtnHeight=20;this.selectBtnWidth=54;this.entityStartLine=0;this.oldTitle="";this.oldName="";this.isUnitTest=!1;this.isUnitTest=s;this.isCopy=e;this.modelType=o;u.GLOBAL_COMPONENT_EDITOR_INDEX++;f?(this.dbCopyComp=new n.CeComponentClone(f),this.isMemberOfOwnersGroup(this.dbCopyComp.Author)?(this.saveState=t.INITIALIZE_ACTIVE,this.isOpenUserComp=!0):this.saveState=t.NEW_COPY_FIRST):(f=this.getStarterComp(),this.saveState=t.INITIALIZE_ACTIVE);this.activeComp=new n.CeComponentClone(f);this.newComponent=new n.CeComponentClone(f);s||(h="new",f&&f.Name&&(h=f.Name),n.Settings.notify("model editor open",{modelType:o,comp:h}),n.Settings.notify("model editor open "+o));$("body").append("<div id=modelEditorDialog"+u.GLOBAL_COMPONENT_EDITOR_INDEX+"><\/div>");this.CssClassManager=r.getDesign().getCssClassMgr();setTimeout(function(){c.initialize(r)},1e3)}return u.prototype.initialize=function(t){var s=this,i,r;if(this.surface=t,this.showModelEditor(),u.getModelEditorDomNode().parent().css("z-index",u.ME_Z_INDEX),u.getModelEditorDomNode().css("overflow","hidden"),this.fragment=document.createDocumentFragment(),u.getModelEditorDomNode().html(""),this.addToolbar(),this.addInfoPane(),this.addEditField(),this.cmReadOnly=!1,this.editModel(),u.getModelEditorDomNode().append(this.fragment.childNodes),setTimeout(function(){s.resizeME()},3e3),this.addEventHandlers(),this.dbCopyComp)if(this.isMemberOfOwnersGroup(this.dbCopyComp.Author)){this.myComponentId=this.dbCopyComp.ComponentId;var e=u.PAPER_WIDTH,o=u.PAPER_HEIGHT,f=n.CeUtility.getSvgWidthHeight(this.dbCopyComp.Img);f.length>1&&(i=parseInt(f[1]),i&&i>u.PAPER_HEIGHT&&(o=i),r=parseInt(f[0]),r&&r>u.PAPER_WIDTH&&(e=r),this.symNewComponentPaper=Raphael("symNewComponentPaperDiv",e,o))}else this.symNewComponentPaper=Raphael("symNewComponentPaperDiv",u.PAPER_WIDTH,u.PAPER_HEIGHT);else this.myComponentId="",this.symNewComponentPaper=Raphael("symNewComponentPaperDiv",u.PAPER_WIDTH,u.PAPER_HEIGHT);this.setMEMenu();this.ceHelp=new n.CeHelp},u.prototype.addEventHandlers=function(){this.defineEvents();this.initTooltips()},u.prototype.defineEvents=function(){var f=this,e=this;$(u.CLEAR_EDITS_BUTTON).click(function(){if($(u.CLEAR_EDITS_BUTTON).hasClass("disabled"))return!1;f.confirmDialog2Btn=new n.MultiBtnModalDialog("Confirm Clear Edits","Are you sure you want to clear all changes since last save?",["Yes","No"]);jQuery.when(f.confirmDialog2Btn.queryUser()).done(function(t){t==n.BUTTON.BTN1&&(f.newComponent.Src?f.cm.getDoc().setValue(f.newComponent.Src):f.cm.getDoc().setValue(f.loadedModel))})});$(u.UNDO_MODEL_BUTTON).click(function(){if($(u.UNDO_MODEL_BUTTON).hasClass("disabled"))return!1;f.cm.getDoc().undo()});$(u.REDO_MODEL_BUTTON).click(function(){if($(u.REDO_MODEL_BUTTON).hasClass("disabled"))return!1;f.cm.getDoc().redo()});$(u.SAVE_MODEL_BUTTON).click(function(){if($(u.SAVE_MODEL_BUTTON).hasClass("disabled"))return!1;f.saveState=t.UPDATE_NOCOMPILE;f.compileModel()});$(u.SAVEAS_MODEL_BUTTON).click(function(){f.saveState=t.NEW_COPY_FIRST;f.myComponentId="";f.compileModel()});$(u.MODEL_EDITOR_HELP_BUTTON).click(function(){f.setInfoPaneState(r.HELP);$("#modelEditorCM").css({height:"430px"});f.resizeME()});$(u.EDIT_SYMBOL_BUTTON).click(function(){$("#symNewComponentPaperDiv").trigger("click")});$(u.INFO_PANE_CLOSE_BUTTON).click(function(){f.setInfoPaneState(r.NONE);$("#modelEditorCM").css({height:"600px"});f.resizeME()});$(".linkCEHelp").click(function(){f.ceHelp.showCeHelpDialog();f.ceHelp.getCEHelp()});$(".linkModelingHelpMenu").click(function(){var t=new n.AppViewHelp;t.loadDialogContentsAddHandlers("3eefd0a8-19b5-463f-9ecb-df6ad04d4c7b")});$("#symDbPaperDiv").click(function(){f.activeCompSel=i.DB_COPY_COMP;f.compileModel();f.enableButtons()});$("#symAutoPaperDiv").click(function(){f.activeCompSel=i.AUTO_COMP;f.compileModel();f.enableButtons()});$("#symNewComponentPaperDiv").click(function(){if(f.activeCompSel=i.NEW_COMP,f.compStatus==n.CE_STATUS.DONE)f.compileModel();else n.MessageManager.showInfoMessage("Cannot edit symbol until model passes check (on save)");f.enableButtons()});$("#getCompFromServer").click(function(i,r,u){f.myComponentId=r;var e="?library="+u+"&componentId="+f.myComponentId;$.ajax({type:"GET",url:n.Settings.APIURI()+"/components/"+e,contentType:"application/json"}).done(function(i){i=i[0];n.CeDebug.isDebugPins&&n.CeDebug.showPins("In ME, back from SE. Pins",i.Pins);f.saveState=t.UPDATE_FROM_SE;f.activeComp=new n.CeComponentClone(i);f.preparePreview();f.isLaunchSESilent&&(f.isLaunchSESilent=!1)}).always(function(){})})},u.prototype.setupCodeMirror=function(){var t="",i="vhdlams";this.modelType==n.CE_MODEL_TYPE.SPICE?(t=this.getSpiceTemplateSrc(),i="spice"):this.modelType==n.CE_MODEL_TYPE.SCHEMATIC?(t=this.getHierarchicalTemplateSrc(),i="vhdlams"):(t=this.getVhdlTemplateSrc(),i="vhdlams");this.cm=CodeMirror($("#modelEditorCM").get(0),{value:t,mode:i,theme:"eclipseRSC",lineNumbers:!0,lineWrapping:!1,highlightSelectionMatches:{showToken:/\w/},extraKeys:{"Ctrl-S":function(){$(u.SAVE_MODEL_BUTTON).trigger("click")}}});this.cm.setSize("100%","100%")},u.prototype.editModel=function(){var t=this,i;this.isCopy?(this.loadedModel=null,this.parsedComponent=null,this.showSpinner(),i="?library="+this.dbCopyComp.Lib+"&componentId="+this.dbCopyComp.ComponentId,$.ajax({type:"GET",url:n.Settings.APIURI()+"/components/"+i,contentType:"application/json"}).done(function(n){t.hideSpinner();t.loadedModel=n[0].Src;t.setupCodeMirror();t.displayModel(t.dbCopyComp.Author);t.setInitialInfoPaneState(t.dbCopyComp.Author)}).fail(function(){n.MessageManager.showErrorMessage("Could not retrieve comp to copy from database")}).always(function(){t.hideSpinner()})):setTimeout(function(){t.loadedModel=t.activeComp.Src;t.setupCodeMirror();t.displayModel(t.activeComp.Author);t.setInitialInfoPaneState(t.activeComp.Author)},1e3)},u.prototype.compileModel=function(){var t=this,i=this.cm.getDoc().getValue(),r;this.modelType=n.CeUtility.getModelType(i);this.modelType==n.CE_MODEL_TYPE.SPICE?(this.cm.setOption("mode","spice"),r="OK",this.compileDone(r)):(this.cm.setOption("mode","vhdlams"),this.showSpinner(),$.ajax({type:"POST",url:n.Settings.APIURI()+"/componentcompiler",data:JSON.stringify({Model:i}),contentType:"application/json"}).done(function(n){t.compileDone(n)}).always(function(){t.hideSpinner()}))},u.prototype.compileDone=function(u){u=="OK"?(this.compStatus=n.CE_STATUS.DONE,this.parseModel()):(this.saveState=t.UPDATE_NOCOMPILE,this.activeCompSel=i.NONE,this.setInfoPaneState(r.COMPILE),this.compileResults=u,this.compStatus=n.CE_STATUS.EDIT,this.saveComponent())},u.prototype.parseModel=function(){var t=this,i=this.cm.getDoc().getValue();$.ajax({type:"POST",url:n.Settings.APIURI()+"/componentparser",data:JSON.stringify({Model:i}),contentType:"application/json"}).done(function(n){t.parseDone(n)}).always(function(){})},u.prototype.parseDone=function(i){if(this.isSpiceParsedOK=!0,this.parsedComponent=new n.CeComponentClone(i),this.parsedComponent.ModelType==n.CE_MODEL_TYPE.SPICE&&(this.parsedComponent.Name=n.Utility.convertToLegalVHDLName(this.parsedComponent.Name,"x"),this.parsedComponent.Comments)){var r=this.parsedComponent.Comments.toLowerCase();if(n.CeUtility.startsWith(r,"error")){this.isSpiceParsedOK=!1;n.MessageManager.showErrorMessage(this.parsedComponent.Comments);return}}this.saveState==t.NEW_COPY_FIRST?this.showTitleDialog():this.prepareForSave()},u.prototype.prepareForSave=function(){this.isCopy?this.saveState==t.NEW_COPY_FIRST?(this.preparePreview(),this.saveState=t.INITIALIZE_ACTIVE):(this.activeCompSel==i.DB_COPY_COMP?(this.activeComp=new n.CeComponentClone(this.dbCopyComp),this.isLaunchSE=!1,this.saveState=t.INITIALIZE_ACTIVE):this.activeCompSel==i.AUTO_COMP?(this.activeComp=new n.CeComponentClone(this.autoComp),this.isLaunchSE=!1,this.activeCompSel=i.NONE,this.saveState=t.INITIALIZE_ACTIVE):this.activeCompSel==i.NEW_COMP?(this.isLaunchSE=!0,this.activeCompSel=i.NONE,this.saveState=t.UPDATE_COMPILE):(this.isLaunchSE=!1,this.saveState=t.UPDATE_COMPILE),this.saveComponent()):(this.modelType==n.CE_MODEL_TYPE.SPICE&&this.parsedComponent.BaseName?this.activeComp=new n.CeComponentClone(this.parsedComponent):(this.generateSymbol(!1),this.activeComp=new n.CeComponentClone(this.autoComp)),this.isLaunchSE=!1,this.activeCompSel=i.NONE,this.saveState=t.INITIALIZE_ACTIVE,this.infoPane=r.PREVIEW_1SYM,this.setInfoPaneState(this.infoPane),this.preparePreview(),this.myComponentId||this.updateScratchModel(),this.isCopy=!0)},u.prototype.saveComponent=function(){var t,r,u,e,i,f;if(this.preparePreview(),this.isOpenUserComp){this.isOpenUserComp=!1;return}(this.updateComponent(this.activeComp),this.isLaunchSESilent)||(t="",this.isUpdate=!1,r="UserLib",this.newComponent.Lib&&this.newComponent.Lib=="SVWebLib"&&(r="SVWebLib"),this.myComponentId?(t=n.Settings.APIURI()+"/components?library="+r+"&componentId="+this.myComponentId,this.isUpdate=!0):(t=n.Settings.APIURI()+"/components?library=UserLib",this.isUpdate=!1,this.newComponent.ComponentId="",u=[],e=new n.CeRevision("","New Comp",!1,""),u.push(e),i=[],i.push("My Components"),i.push("Shared Components"),f=n.Settings.UUID,f=n.Settings.UUID,this.newComponent.Revisions=u,this.newComponent.Categories=i,this.newComponent.Author=f,this.newComponent.Lib="UserLib"),this.uploadComponent(t,this.isUpdate,this.newComponent))},u.prototype.uploadComponent=function(t,i,r){var u=this,f;n.Settings.notify("model save",{modelType:r.ModelType,modelName:r.Name});n.CeDebug.isDebugPins&&(n.CeDebug.showPins("Uploading from ME. Pins",r.Pins),console.log(r.Img+"\n\n"),f=JSON.stringify(r));$.ajax({headers:{TOKEN_HEADER:"97814435-7337-4390-be35-86ca540f7a1b",userID:n.Utility.getUserID()},type:i?"PUT":"POST",url:t,data:JSON.stringify(r),contentType:"application/json"}).done(function(n){u.uploadDone(n)}).fail(function(t){var i="Component could not be saved: <br />"+t.responseJSON.ExceptionMessage+" <br />You may need to click the Save new model button so your component can be recreated.";n.MessageManager.showErrorMessage(i)})},u.prototype.uploadDone=function(t){n.CeDebug.isDebugPins&&n.CeDebug.showPins("In ME, uploadDone. Pins",t.Pins);this.activeComp=new n.CeComponentClone(t);this.cm.getDoc().markClean();this.myComponentId=t.ComponentId;var i=getSchematic();this.isUpdate?(t.library=t.Lib?t.Lib:"UserLib",i.getComponentDataManager().updateCollection(t)):i.getComponentDataManager().addToCollection(t,"UserLib");surface.getComponentBrowserSidebar().openCategory(Sidebar.ComponentBrowser.MY_COMPONENTS_CATEGORY);this.isLaunchSE&&(this.showSymbolEditor(),this.isLaunchSE=!1);this.compStatus==n.CE_STATUS.DONE&&this.setInfoPaneState(r.PREVIEW_1SYM);this.enableButtons()},u.prototype.updateScratchModel=function(){var t,i,r;this.modelTitle||(this.modelTitle=this.activeComp.Title);this.newComponent.Title=this.modelTitle;this.modelName&&this.activeComp.ModelType!=n.CE_MODEL_TYPE.SPICE||(this.modelName=this.activeComp.Name);this.newComponent.Name=this.modelName;this.modelDescription||(this.modelDescription=this.activeComp.Description);this.newComponent.Description=this.modelDescription;this.modelDescriptionToolTip||(this.modelDescriptionToolTip=this.activeComp.DescriptionToolTip);this.newComponent.DescriptionToolTip=this.modelDescriptionToolTip;this.newComponent.Prefix=this.activeComp.ModelType==n.CE_MODEL_TYPE.SPICE?this.activeComp.Prefix:"u";this.newComponent.PartNumber=this.activeComp.PartNumber;this.newComponent.Src=this.loadedModel;this.newComponent.Lib="UserLib";this.newComponent.ShowComponent=!1;this.newComponent.BaseName=this.activeComp.BaseName;this.newComponent.Author=n.Settings.UUID;this.newComponent.Status=n.CE_STATUS.EDIT;this.newComponent.ComponentId=this.myComponentId;this.newComponent.Cx=40;this.newComponent.Cy=40;this.newComponent.ModelType=this.modelType;this.newComponent.Img=this.activeComp.Img;this.newComponent.Pins=this.activeComp.Pins;this.newComponent.Properties=this.activeComp.Properties;this.newComponent.Architectures=this.activeComp.Architectures;this.newComponent.Categories=["My Components","Shared Components"];this.newComponent.DateModified="";this.newComponent.CreationDate="";t=[];i=new n.CeRevision(this.myComponentId,"New Comp",!1,"");t.push(i);this.newComponent.Revisions=t;r=n.Settings.APIURI()+"/components?library=UserLib";this.uploadComponent(r,!1,this.newComponent)},u.prototype.updateComponent=function(t){var e,f,o,h,s,r,u,c,l;if(!t){console.log("No source component for updateComponent");return}if(e=this.cm.getDoc().getValue(),this.modelTitle||(this.modelTitle=t.Title),this.newComponent.Title=this.modelTitle,this.modelName||(this.modelName=t.Name),e=this.updateModelSourceWithName(e),this.newComponent.Name=this.modelName,this.newComponent.PartNumber=t.PartNumber,this.newComponent.Comments=t.Comments,this.newComponent.Prefix=t.ModelType==n.CE_MODEL_TYPE.SPICE?t.Prefix:"u",this.newComponent.Src=e,f=[],o=n.Settings.UUID,t.Lib&&t.Lib=="SVWebLib"?(this.newComponent.Lib="SVWebLib",f=t.Categories,o="SVWeb"):(this.newComponent.Lib="UserLib",t.BaseName&&f.push("DMB User Components"),f.push("My Components"),f.push("Shared Components"),o=n.Settings.UUID),this.newComponent.Categories=f,this.newComponent.Author=o,this.newComponent.ShowComponent=!1,this.newComponent.Tags=t.Tags,this.newComponent.Url=t.Url,this.newComponent.Visibility=t.Visibility,this.newComponent.DateModified=t.DateModified,this.newComponent.CreationDate=t.CreationDate,this.newComponent.BaseName=t.BaseName,this.newComponent.Status=this.compStatus,this.newComponent.ComponentId=this.myComponentId,this.compMetaData.cx&&this.activeCompSel!=i.DB_COPY_COMP||(this.compMetaData.cx=t.Cx),this.newComponent.Cx=this.compMetaData.cx,this.compMetaData.cy&&this.activeCompSel!=i.DB_COPY_COMP||(this.compMetaData.cy=t.Cy),this.newComponent.Cy=this.compMetaData.cy,this.activeCompSel=i.NONE,this.compMetaData.modelType||(this.compMetaData.modelType=t.ModelType),this.newComponent.ModelType=this.compMetaData.modelType,this.newComponent.Img=t.Img,t.Revisions.length>0?this.newComponent.Revisions=t.Revisions:this.newComponent.Revisions.length==0&&(h=new n.CeRevision(this.myComponentId,"New Comp",!1,t.CreationDate),s=[],s.push(h),this.newComponent.Revisions=s),this.compStatus==n.CE_STATUS.EDIT)this.newComponent.Description=t.Description,this.newComponent.DescriptionToolTip=t.DescriptionToolTip,this.newComponent.Properties=t.Properties,this.newComponent.Architectures=t.Architectures,this.newComponent.Pins=t.Pins;else if(this.compStatus==n.CE_STATUS.DONE){for(t.ModelType==n.CE_MODEL_TYPE.SPICE&&(this.newComponent.Name=this.parsedComponent.Name),this.newComponent.Description=this.parsedComponent.Description,this.newComponent.DescriptionToolTip=this.parsedComponent.DescriptionToolTip,this.newComponent.Architectures=this.parsedComponent.Architectures,this.newComponent.Properties=this.parsedComponent.Properties,r=0;r<this.newComponent.Properties.length;r++)for(u=0;u<t.Properties.length;u++)this.newComponent.Properties[r].Name==t.Properties[u].Name&&(this.newComponent.Properties[r].Minimum=t.Properties[u].Minimum,this.newComponent.Properties[r].Maximum=t.Properties[u].Maximum,this.newComponent.Properties[r].DistType=t.Properties[u].DistType);for(this.newComponent.Pins=this.parsedComponent.Pins,r=0;r<this.newComponent.Pins.length;r++)for(u=0;u<t.Pins.length;u++)this.newComponent.Pins[r].Name==t.Pins[u].Name&&(this.newComponent.Pins[r].X=t.Pins[u].X,this.newComponent.Pins[r].Y=t.Pins[u].Y,this.newComponent.Pins[r].Orientation=t.Pins[u].Orientation);n.CeDebug.isDebugPins&&(n.CeDebug.showPins("ME updateComponent. newComponent Pins",this.newComponent.Pins),n.CeDebug.showPins("ME updateComponent. srcComponent Pins",t.Pins))}this.checkPinConsistency(this.newComponent.Pins,this.activeComp.Pins)||(this.isLaunchSESilent=!0,c=new n.SymbolEditor(this.surface,this.newComponent,!0));this.isSVWebLib&&(this.isSVWebLib=!1,l=n.CeUtility.updatePinArray(this.newComponent.Pins,this.symNewComponentPaper,!0),this.newComponent.Img=n.CeUtility.getSvgFromPaper(this.newComponent.Img,this.symNewComponentPaper))},u.prototype.preparePreview=function(){var h,c,i,f,e,s,v;switch(this.saveState){case t.NEW_COPY_FIRST:n.CeDebug.isDebugFlow&&n.CeDebug.showFlow("In NEW_COPY_FIRST");h=Raphael("symDbPaperDiv",u.PAPER_WIDTH,u.PAPER_HEIGHT);c=this.dbCopyComp?n.CeUtility.getSVGElements(this.dbCopyComp.Img,h):n.CeUtility.getSVGElements(this.activeComp.Img,h);i=n.CeUtility.getRoundedBBVals(c.getBBox());n.CeDebug.isDebugBBox&&console.log("FauxBB for symDbPaper = "+i.x+" "+i.y+" "+i.width+" "+i.height);h.remove();this.symDbPaper!=null&&this.clearPaper("symDbPaper");$("#symDbPaperDiv").html("");f=i.height+this.selectBtnHeight+10;e=i.width<this.selectBtnWidth?this.selectBtnWidth:i.width;this.symDbPaper=Raphael("symDbPaperDiv",e,f);var y=$("#symDbImage").height(),w=$("#symDbImage").width(),o=y/2-f/2;o<0&&(o=0);s=0;$("#symDbPaperDiv").css({width:e,height:f,"margin-top":o,"margin-left":s});this.svgElements=this.dbCopyComp?n.CeUtility.getSVGElements(this.dbCopyComp.Img,this.symDbPaper):n.CeUtility.getSVGElements(this.activeComp.Img,this.symDbPaper);this.symDbPaper.setViewBox(0,0,e,f,!1);this.addSelectIcon(this.symDbPaper);this.generateSymbol(!1);this.setInfoPaneState(r.PREVIEW_2SYM);break;case t.INITIALIZE_ACTIVE:n.CeDebug.isDebugFlow&&n.CeDebug.showFlow("In INITIALIZE_ACTIVE");var l=Raphael("symNewComponentPaperDiv",u.PAPER_WIDTH,u.PAPER_HEIGHT),c=n.CeUtility.getSVGElements(this.activeComp.Img,l),i=n.CeUtility.getRoundedBBVals(c.getBBox());n.CeDebug.isDebugBBox&&console.log("FauxBB for INITIALIZE_ACTIVE = "+i.x+" "+i.y+" "+i.width+" "+i.height);l.remove();this.symNewComponentPaper!=null&&(this.clearPaper("symNewComponentPaper"),this.symNewComponentPaper.clear());$("#symNewComponentPaperDiv").html("");f=i.height+this.selectBtnHeight+10;e=i.width<this.selectBtnWidth?this.selectBtnWidth:i.width;this.symNewComponentPaper=Raphael("symNewComponentPaperDiv",e,f);var a=$("#symActiveImage").height(),p=$("#symActiveImage").width(),o=a/2-f/2;o<0&&(o=0);s=p/2-e/2;$("#symNewComponentPaperDiv").css({width:e,height:f,"margin-top":o,"margin-left":s});this.symNewComponentPaper.setViewBox(0,0,e,f,!1);v=n.CeUtility.getSVGElements(this.activeComp.Img,this.symNewComponentPaper);this.updateSymbolImages(this.activeComp);this.hasEditIcon(this.symNewComponentPaper)||this.hasIndicators(this.symNewComponentPaper)?this.setInfoPaneState(r.COMPILE):(this.addEditIcon(this.symNewComponentPaper),this.setInfoPaneState(r.PREVIEW_1SYM));break;case t.UPDATE_COMPILE:n.CeDebug.isDebugFlow&&n.CeDebug.showFlow("In UPDATE_COMPILE");this.symNewComponentPaper.clear();this.svgElements=n.CeUtility.getSVGElements(this.activeComp.Img,this.symNewComponentPaper);this.hasIndicators(this.symNewComponentPaper)&&this.removeFailedCompileIndicator(this.symNewComponentPaper);this.updateSymbolImages(this.activeComp);this.hasEditIcon(this.symNewComponentPaper)||this.addEditIcon(this.symNewComponentPaper);this.setInfoPaneState(r.PREVIEW_1SYM);break;case t.UPDATE_FROM_SE:n.CeDebug.isDebugFlow&&n.CeDebug.showFlow("In UPDATE_FROM_SE");var l=Raphael("symNewComponentPaperDiv",u.PAPER_WIDTH,u.PAPER_HEIGHT),c=n.CeUtility.getSVGElements(this.activeComp.Img,l),i=n.CeUtility.getRoundedBBVals(c.getBBox());n.CeDebug.isDebugBBox&&console.log("FauxBB for UPDATE_FROM_SE = "+i.x+" "+i.y+" "+i.width+" "+i.height);l.remove();this.symNewComponentPaper!=null&&(this.clearPaper("symNewComponentPaper"),this.symNewComponentPaper.clear());$("#symNewComponentPaperDiv").html("");f=i.height+this.selectBtnHeight+10;e=i.width<this.selectBtnWidth?this.selectBtnWidth:i.width;this.symNewComponentPaper=Raphael("symNewComponentPaperDiv",e,f);var a=$("#symActiveImage").height(),p=$("#symActiveImage").width(),o=a/2-f/2;o<0&&(o=0);s=0;$("#symNewComponentPaperDiv").css({width:e,height:f,"margin-top":o,"margin-left":s});this.symNewComponentPaper.setViewBox(i.x,i.y,e,f,!1);v=n.CeUtility.getSVGElements(this.activeComp.Img,this.symNewComponentPaper);this.updateSymbolImages(this.activeComp);this.hasEditIcon(this.symNewComponentPaper)||this.hasIndicators(this.symNewComponentPaper)||this.addEditIcon(this.symNewComponentPaper);this.setInfoPaneState(r.PREVIEW_1SYM);break;case t.UPDATE_NOCOMPILE:n.CeDebug.isDebugFlow&&n.CeDebug.showFlow("In UPDATE_NOCOMPILE");this.symNewComponentPaper.clear();this.svgElements=n.CeUtility.getSVGElements(this.activeComp.Img,this.symNewComponentPaper);this.hasIndicators(this.symNewComponentPaper)||this.addFailedCompileIndicator(this.symNewComponentPaper);this.updateSymbolImages(this.activeComp);this.setInfoPaneState(r.COMPILE)}this.resizeME()},u.prototype.updateSymbolImages=function(t){for(var o,f,r,e,s,u=n.CeUtility.getPaperElements(this.symNewComponentPaper),h=this.symNewComponentPaper.set(),i=0;i<u.length;i++)for(o=u[i][0].classList,f=0;f<o.length;f++)o[f].indexOf("svw_symbol_edit")>-1?u[i].remove():h.push(u[i]);r=n.CeUtility.getRoundedBBVals(n.CeUtility.getPaperBBoxWithoutText(this.symNewComponentPaper));e=this.symNewComponentPaper.toSVG(0,0,r.width,r.height);e=e.replace(/&amp;quot;/g,'"');s=e.split("<svg");t.Img='<svg viewbox="0,0,'+r.width+","+r.height+'"'+s[1];this.activeComp.Img=t.Img},u.prototype.addFailedCompileIndicator=function(t){var i,r;n.CeDebug.isDebugElements&&(r=n.CeUtility.getPaperElements(t),console.log("ME begin addFailedCompileIndicator #elems = "+r.length));i=n.CeUtility.getBBoxWithoutPinsText(this.svgElements);n.CeDebug.isDebugElements&&(r=n.CeUtility.getPaperElements(t),console.log("ME end addFailedCompileIndicator #elems = "+r.length));var u=24,f=24,o=i.x+i.width/2-u/2,s=i.y+i.height-f/2,e=t.image("/Content/images/model-error.png",o,s,u,f);e.attr({opacity:"0.6"});e.node.setAttribute("class","svw_model_failed");this.removeEditIcon(t)},u.prototype.removeFailedCompileIndicator=function(t){var c=!1,r=n.CeUtility.getPaperElements(t),e,f,s,u,h,i;for(n.CeDebug.isDebugElements&&console.log("ME begin removeFailedCompileIndicator #elems = "+r.length),i=r.length-1;i>=0;i--)for(e=r[i][0].classList,f=0;f<e.length;f++)e[f].indexOf("svw_model_failed")>-1&&(r[i].remove(),$("#symNewComponentPaper ."+e[f]).remove(),c=!0);if(c){for(s=t.set(),i=0;i<r.length;i++)s.push(r[i]);u=n.CeUtility.getRoundedBBVals(s.getBBox());n.CeDebug.isDebugBBox&&console.log("ME addFailedCompileIndicator \n"+u.x+"  "+u.y+"  "+u.width+"  "+u.height+"\n");h=t.toSVG(0,0,u.width,u.height);h=h.replace(/&amp;quot;/g,'"');var l=this.activeComp.Img.split(">"),o="",a=l[0]+">";for(o+=a,i=0;i<r.length;i++)r[i].node&&(o+=r[i].node.outerHTML);o+="<\/svg>";this.activeComp.Img=o}n.CeDebug.isDebugElements&&(r=n.CeUtility.getPaperElements(t),console.log("ME end removeFailedCompileIndicator #elems = "+r.length));this.hasEditIcon(t)||this.addEditIcon(t)},u.prototype.hasIndicators=function(t){var e=!1,u=n.CeUtility.getPaperElements(t),i,f,r;for(n.CeDebug.isDebugElements&&console.log("ME checkIndicators #elems = "+u.length),i=u.length-1;i>=0;i--)for(f=u[i][0].classList,r=0;r<f.length;r++)f[r].indexOf("svw_model_failed")>-1&&(e=!0);return e},u.prototype.addEditIcon=function(t){for(var u,f=n.CeUtility.getPaperElements(t),e=t.set(),r=0;r<f.length;r++)e.push(f[r]);var i=n.CeUtility.getRoundedBBVals(n.CeUtility.getBBoxWithoutPinsText(e)),o=this.editBtnWidth,s=this.editBtnHeight,h=i.x+i.width/2-o/2,c=i.y+i.height-s/4,l=t.image("/Content/images/blank-green-button.png",h,c,o,s);l.attr({opacity:"0.8"});u=t.text(h+25,c+10,"Edit");setTimeout(function(){u.attr({"font-family":"Verdana","font-size":"15",fill:"white"})});l.node.setAttribute("class","svw_symbol_edit");u.node.setAttribute("class","svw_symbol_edit")},u.prototype.removeEditIcon=function(t){for(var u,i,e=!1,f=n.CeUtility.getPaperElements(t),r=f.length-1;r>=0;r--)for(u=f[r][0].classList,i=0;i<u.length;i++)u[i].indexOf("svw_symbol_edit")>-1&&(f[r].remove(),$("#symNewComponentPaper ."+u[i]).remove(),e=!0)},u.prototype.hasEditIcon=function(t){for(var u,i,f=!1,e=n.CeUtility.getPaperElements(t),r=e.length-1;r>=0;r--)for(u=e[r][0].classList,i=0;i<u.length;i++)u[i].indexOf("svw_symbol_edit")>-1&&(f=!0);return f},u.prototype.addSelectIcon=function(t){for(var u,f=n.CeUtility.getPaperElements(t),e=t.set(),r=0;r<f.length;r++)e.push(f[r]);var i=n.CeUtility.getBBoxWithoutPinsText(e),o=this.selectBtnWidth,s=this.selectBtnHeight,h=i.x+i.width/2-o/2,c=i.y+i.height-s/4,l=t.image("/Content/images/blank-green-button.png",h,c,o,s);l.attr({opacity:"0.8"});u=t.text(h+27,c+9,"Select");setTimeout(function(){u.attr({"font-family":"Verdana","font-size":"15",fill:"white"})});l.node.setAttribute("class","svw_symbol_edit");u.node.setAttribute("class","svw_symbol_edit")},u.prototype.checkPinConsistency=function(n,t){for(var r,u=[],f=[],e=[],o=[],i=0;i<t.length;i++)e.push(t[i].Name);if(t){for(i=n.length-1;i>=0;i--)r=n[i].Name,-1===e.indexOf(r)&&u.push(r);for(i=0;i<n.length;i++)o.push(n[i].Name);for(i=t.length-1;i>=0;i--)r=t[i].Name,-1===o.indexOf(r)&&f.push(r)}return u.length>0||f.length>0?!1:!0},u.prototype.generateSymbol=function(t){var d=[],v=[],y=[],p=[],w=[],at,vt,ni,et,yt,ot,pt,si,r,u,f,e,o,a,l,ui,fi,ct,lt,li,ai,i,k;if(!t)for(i=0;i<this.parsedComponent.Pins.length;i++)this.parsedComponent.Pins[i].Type==2?d.push(this.parsedComponent.Pins[i]):this.parsedComponent.Pins[i].Type==1?this.parsedComponent.Pins[i].Mode==1?y.push(this.parsedComponent.Pins[i]):v.push(this.parsedComponent.Pins[i]):this.parsedComponent.Pins[i].Mode==1?w.push(this.parsedComponent.Pins[i]):p.push(this.parsedComponent.Pins[i]);at=d.length+v.length+p.length;vt=y.length+w.length;ni=at>vt?at:vt;var c=20,h=20,s=10,ei=0,oi=0;at>0&&(ei=c);vt>0&&(oi=c);et=80+ei+oi;yt=20+ni*c;t&&(et=80,yt=80);this.symAutoPaper!=null&&this.clearPaper("symAutoPaper");$("#symAutoPaperDiv").html("");ot=yt+this.selectBtnHeight;pt=et<this.selectBtnWidth?this.selectBtnWidth:et;this.symAutoPaper=Raphael("symAutoPaperDiv",pt,ot);var vi=$("#symAutoImage").height(),nr=$("#symAutoImage").width(),ti=vi/2-ot/2;ti<0&&(ti=0);si=0;$("#symAutoPaperDiv").css({width:pt,height:ot,"margin-top":ti,"margin-left":si});this.symAutoPaper.setViewBox(0,0,pt,ot,!1);var b=20,g=0,ii=80,hi=h+h*ni;t&&(b=0,hi=80);var nt=b-c,tt=g+h,wt=b+ii,bt=g+h,it=b-s,rt=g+h-s/2,ut=b+ii,ft=g+h-s/2,ci=[],st=[],ht=[],kt=[],dt=[],ri=this.symAutoPaper.rect(b,g,ii,hi);for(ri.attr("fill","white"),ri.attr("stroke-width",3),ri.node.setAttribute("class","svw_sym svw_sym_shape svw_sym_outline"),this.pinMetaData=[],r=0,l=0,i=0;i<d.length;i++)u=nt,f=tt+r,e=nt+c,o=tt+r,ci.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"Z")),ci[i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinWhiskerClass(d[i].SubType)),this.pinMetaData.push({Name:d[i].Name,Index:d[i].Index,X:u,Y:f,Orientation:3}),r+=h;for(i=0;i<v.length;i++)u=nt,f=tt+r,e=nt+c,o=tt+r,st.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"Z")),st[i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinWhiskerClass(v[i].Type)),this.pinMetaData.push({Name:v[i].Name,Index:v[i].Index,X:u,Y:f,Orientation:3}),u=it,f=rt+r,e=it,o=rt+r+s,a=it+s,l=rt+r+s/2,kt.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"L"+a+","+l+"Z")),kt[i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinArrowClass(v[i].Type)),r+=h;for(i=0;i<p.length;i++)u=nt,f=tt+r,e=nt+c,o=tt+r,ht.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"Z")),ht[i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinWhiskerClass(p[i].SubType)),this.pinMetaData.push({Name:p[i].Name,Index:p[i].Index,X:u,Y:f,Orientation:3}),u=it,f=rt+r,e=it,o=rt+r+s,a=it+s,l=rt+r+s/2,dt.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"L"+a+","+l+"Z")),dt[i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinArrowClass(p[i].SubType)),r+=h;for(r=0,ui=st.length,i=0;i<y.length;i++)u=wt,f=bt+r,e=wt+c,o=bt+r,st.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"Z")),st[ui+i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinWhiskerClass(y[i].Type)),this.pinMetaData.push({Name:y[i].Name,Index:y[i].Index,X:e,Y:o,Orientation:2}),u=ut,f=ft+r,e=ut,o=ft+r+s,a=ut+s,l=ft+r+s/2,kt.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"L"+a+","+l+"Z")),kt[ui+i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinArrowClass(y[i].Type)),r+=h;for(fi=ht.length,i=0;i<w.length;i++)u=wt,f=bt+r,e=wt+c,o=bt+r,ht.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"Z")),ht[fi+i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinWhiskerClass(w[i].SubType)),this.pinMetaData.push({Name:w[i].Name,Index:w[i].Index,X:e,Y:o,Orientation:2}),u=ut,f=ft+r,e=ut,o=ft+r+s,a=ut+s,l=ft+r+s/2,dt.push(this.symAutoPaper.path("M"+u+","+f+"L"+e+","+o+"L"+a+","+l+"Z")),dt[fi+i].node.setAttribute("class","svw_sym "+this.CssClassManager.getSymPinArrowClass(w[i].SubType)),r+=h;ct=et;lt=yt;this.compMetaData.cx=ct/2;this.compMetaData.cy=lt/2;this.compMetaData.modelType=0;var yi=b+10,pi=g+20,gt=this.symAutoPaper.text(yi,pi,this.modelTitle);$("tspan",gt.node).attr("dy")&&$("tspan",gt.node).attr("dy",0);var wi=n.CeUtility.DEFAULT_TITLE_FONT_SIZE,bi=n.CeUtility.DEFAULT_TITLE_FONT_WEIGHT,ki=n.CeUtility.DEFAULT_FONT_COLOR,di=n.CeUtility.DEFAULT_FONT_FAMILY,gi=n.CeUtility.DEFAULT_FONT_STYLE;for(gt.attr({"font-size":wi,"font-weight":bi,"font-family":di,fill:ki,"font-style":gi,"stroke-width":"1px","text-anchor":"start"}),gt.node.setAttribute("class","svw_sym_text swv_sym_title"),li=this.symAutoPaper.toSVG(0,0,ct,lt),ai=li.split("<svg"),this.autoGeneratedSymbol='<svg viewbox="0,0,'+ct+","+lt+'"'+ai[1],this.addSelectIcon(this.symAutoPaper),this.autoComp=new n.CeComponentClone(this.parsedComponent),this.autoComp.Img=this.autoGeneratedSymbol,this.autoComp.Cx=ct/2,this.autoComp.Cy=lt/2,this.autoComp.ModelType=this.modelType,i=0;i<this.autoComp.Pins.length;i++)for(k=0;k<this.pinMetaData.length;k++)this.autoComp.Pins[i].Name==this.pinMetaData[k].Name&&(this.autoComp.Pins[i].X=this.pinMetaData[k].X,this.autoComp.Pins[i].Y=this.pinMetaData[k].Y,this.autoComp.Pins[i].Orientation=this.pinMetaData[k].Orientation)},u.prototype.showTitleDialog=function(){var n=$("#modelTitleDialog").data("kendoWindow"),t;n?(n.open(),n.bind("close",function(){$(u.NEW_TITLE_OK_BUTTON).off("click");$(u.NEW_TITLE_CANCEL_BUTTON).off("click")}),this.updateTitleForNewModel()):(t=$("#modelTitleDialog"),t.kendoWindow({actions:[],draggable:!0,modal:!0,pinned:!1,resizable:!1,title:"Model Name",height:"120px",width:"400px",activate:function(){$("#titleInput").select()}}),n=t.data("kendoWindow"),n.center(),n.open(),n.bind("close",function(){$(u.NEW_TITLE_OK_BUTTON).off("click");$(u.NEW_TITLE_CANCEL_BUTTON).off("click")}),this.updateTitleForNewModel())},u.prototype.updateTitleForNewModel=function(){var t=this,f=$("#modelTitleDialog"),i=$("#titleInput"),r=$(u.NEW_TITLE_OK_BUTTON),e=$(u.NEW_TITLE_CANCEL_BUTTON);r.prop("disabled",!0);f.css({display:"block","z-index":u.ME_Z_INDEX+100});i.val("");f.on("keydown.modelEditor",function(t){t.which==13?i.val().trim()&&r.trigger("click"):t.which==n.Design.EscKey&&e.trigger("click")});i.keyup(function(){i.val().trim()?r.prop("disabled",!1):r.prop("disabled",!0)});r.on("click",function(){t.loadedModel=t.cm.getDoc().getValue();t.modelTitle=i.val().trim();t.loadedModel=t.updateModelSourceWithName(t.loadedModel);var n=f.data("kendoWindow");n.close();t.prepareForSave()});e.on("click",function(){t.confirmDialog2Btn=new n.MultiBtnModalDialog("Confirm Close Component Editor","Cancelling this dialog will close the Component Editor <br />and any model changes will be lost. <br />OK to close? ",["Yes","No"]);$.when(t.confirmDialog2Btn.queryUser()).done(function(i){if(i==n.BUTTON.BTN1){var r=f.data("kendoWindow");r.close();t.closeModelEditorDialog()}})})},u.prototype.closeModelEditorDialog=function(){var n=u.getModelEditorDomNode().data("kendoWindow");n&&n.close()},u.prototype.updateModelSourceWithName=function(t){var i;return this.activeComp.ModelType==n.CE_MODEL_TYPE.SPICE?t:(this.modelName=n.Utility.convertToLegalVHDLName(this.modelTitle,"model_"),i=t,this.modelSrcArray=i.split("\n"),this.getEntityStartLineNum(),this.getOldTitleName(),this.updateBoilerplateInfo(),this.updateName(),this.getUpdatedModelSource())},u.prototype.getEntityStartLineNum=function(){for(var u,s,e,f,t,r=[],o="",i=0;i<this.modelSrcArray.length;i++){if(n.CeUtility.startsWith(this.modelSrcArray[i].trim().toLowerCase(),"entity")){for(r.push(i),u=this.modelSrcArray[i].toLowerCase().split(/[\s]+/),s=[],t=0;t<u.length;t++)u[t]&&s.push(u[t]);o=u[1].toLowerCase()}if(n.CeUtility.startsWith(this.modelSrcArray[i].trim().toLowerCase(),"end")){for(e=this.modelSrcArray[i].toLowerCase().split(/[\s;]+/),f=[],t=0;t<e.length;t++)e[t]&&f.push(e[t]);f.length>1&&(f[1].trim().toLowerCase()=="entity"||f[1].trim().toLowerCase()==o)&&r.push(i)}}this.entityStartLine=r.length>2?r[r.length-3]:0},u.prototype.getOldTitleName=function(){for(var i=[],r=[],t=this.entityStartLine;t<this.modelSrcArray.length;t++)if(this.modelSrcArray[t].indexOf("Model Title:")>-1&&(i=this.modelSrcArray[t].split(":"),i&&i.length>1&&(this.oldTitle=i[1].trim())),n.CeUtility.startsWith(this.modelSrcArray[t].trim().toLowerCase(),"entity")){r=this.modelSrcArray[t].split(/[ ]+/);r&&r.length>1&&(this.oldName=r[1].trim());break}},u.prototype.updateBoilerplateInfo=function(){for(var t,n=this.entityStartLine;n<this.modelSrcArray.length;n++)this.modelTitle&&this.modelSrcArray[n].indexOf("Model Title:")>-1&&(this.modelSrcArray[n]="--Model Title: "+this.modelTitle),this.modelName&&this.modelSrcArray[n].indexOf("Entity Name:")>-1&&(this.modelSrcArray[n]="--Entity Name: "+this.modelName),this.modelSrcArray[n].indexOf("Author:")>-1&&(this.modelSrcArray[n]="-- Author: Enter name here"),this.modelSrcArray[n].indexOf("Created:")>-1&&(t=new Date,this.modelSrcArray[n]="-- Created: "+this.formatDateTime(t))},u.prototype.updateName=function(){var t,u,i,r;if(this.modelTitle&&this.modelName)for(t=this.entityStartLine;t<this.modelSrcArray.length;t++)if(!n.CeUtility.startsWith(this.modelSrcArray[t].trim().toLowerCase(),"--")){for(u="",i=this.modelSrcArray[t].split("--"),i[0]=this.performTitleNameSubstitution(i[0]),r=0;r<i.length;r++)u+=r==1?"--"+i[r]:i[r];this.modelSrcArray[t]=u}},u.prototype.performTitleNameSubstitution=function(n){var t=n,i;return this.oldTitle&&this.oldName&&this.oldTitle==this.oldName?(i=new RegExp(this.oldName,"g"),t=t.replace(i,this.modelName)):this.oldName&&(i=new RegExp(this.oldName,"g"),t=t.replace(i,this.modelName)),t},u.prototype.getUpdatedModelSource=function(){var i=this.modelSrcArray.join("\n"),r;return this.modelType!=n.CE_MODEL_TYPE.SPICE?(this.oldTitle.toLowerCase()!=this.modelTitle.toLowerCase()||this.oldName.toLowerCase()!=this.modelName.toLowerCase())&&(this.oldName.toLowerCase()==this.modelName.toLowerCase()||this.saveState==t.NEW_COPY_FIRST||n.Settings.DISABLE_STD_UI_MESSAGING||(r="All instances of <b>"+this.oldName+"<\/b> have been changed to <b>"+this.modelName+"<\/b>. <br />If you want to change your model's name, please click on the 'Save new model' button to <br /> create a new model (component), then specify the desired name in the 'Model Name' dialog.",n.MessageManager.showWarningMessage(r,!0)),this.cm.getDoc().setValue(i)):this.cm.getDoc().setValue(i),i},u.prototype.displayModel=function(t){n.CeUtility.getModelType(this.loadedModel)==n.CE_MODEL_TYPE.SPICE?this.cm.setOption("mode","spice"):this.cm.setOption("mode","vhdlams");this.cm.getDoc().setValue(this.loadedModel);this.cmReadOnly=!1;this.isMemberOfOwnersGroup(t)?this.enableButtons():this.disableButtons()},u.prototype.formatDateTime=function(n){var t=n.getHours(),i=n.getMinutes(),u=t>=12?"pm":"am",r;return t=t%12,t=t?t:12,i=i<10?"0"+i:i,r=t+":"+i+" "+u,n.getMonth()+1+PATH_SEPARATOR+n.getDate()+PATH_SEPARATOR+n.getFullYear()+" "+r},u.prototype.showModelEditor=function(){function c(n){var t=u.getModelEditorDomNode(),l=$("#symbolPreview"),a=$("#infoPane"),v=$("#quickHelp"),b=$("#infoPaneTitleClose"),it=$("#infoPaneClose"),rt=$("#infoPaneTitle"),ut=$("#previewNotes"),ft=$("#toolbarHelp"),vt=$("#model_editor_help"),y=$(".mdlEditToolbar"),k=$(".mdlEditHelp"),i=210,s=150,d=430,et=s+d,ot=2*s+d,f=$("#symActiveImage"),e=$("#symAutoImage"),p=$("#symDbImage"),st=$("#symNewComponentPaperDiv"),ht=$("#symAutoPaperDiv"),ct=$("#symDbPaperDiv"),g=t[0].clientWidth-40,nt=$("#modelEditorCM"),tt=y.width(),lt=$("#infoPaneTitle").width(),d=400,w=t[0].clientWidth/2-tt/2,at=t[0].clientWidth/2-lt/2-20,r=0,o,h,c;r=u.INITIAL_APP_WIDTH>=t[0].clientWidth?u.INITIAL_APP_WIDTH-t[0].clientWidth:t[0].clientWidth-u.INITIAL_APP_WIDTH;r<0?r=0:r>i&&(r=i);ft.css({width:"800px"});y.css({"margin-left":w+"px"});k.addClass("pull-right");k.css({"margin-right":850-t[0].clientWidth+"px"});l.css({width:u.COMPONENT_EDITOR_MAXWIDTH+"px"});ut.css({width:"400px","margin-left":"0px"});v.css({width:u.COMPONENT_EDITOR_MAXWIDTH+"px"});f.css({width:"120px"});e.css({width:"120px"});p.css({width:"120px"});f.css({"margin-left":i-r+"px"});st.css({"margin-left":"0px"});e.css({"margin-left":i-r+"px"});ht.css({"margin-left":"0px"});p.css({"margin-left":"0px"});ct.css({"margin-left":"0px"});a.css("display")=="none"?nt.css("height",n.height-80):nt.css("height",n.height-220);t[0].clientHeight>=u.COMPONENT_EDITOR_HEIGHT?t.css({"overflow-y":"hidden"}):t[0].clientHeight<u.COMPONENT_EDITOR_HEIGHT&&t.css({"overflow-y":"scroll"});t[0].clientWidth>=u.COMPONENT_EDITOR_WIDTH?(a.css({"overflow-x":"hidden"}),b.css({width:g+"px"}),f.css({"margin-left":i+"px"}),e.css({"margin-left":i-s+"px"}),w=u.COMPONENT_EDITOR_WIDTH/2-tt/2,y.css({"margin-left":w+"px"})):t[0].clientWidth<u.COMPONENT_EDITOR_WIDTH&&(a.css({"overflow-x":"scroll"}),it.css({"margin-right":"0px"}),rt.css({"margin-left":at+"px",width:"250px"}),b.css({width:g+"px"}),o=u.COMPONENT_EDITOR_WIDTH/2-t[0].clientWidth/2,i<o&&(o=i),h=i-o,h<0&&(h=0),c=i-o-s,c<0&&(c=0),f.css({"margin-left":h+"px"}),e.css({"margin-left":c+"px"}),v.is(":visible")?v.css({width:"800px"}):p.is(":visible")?l.css({width:e.offset().left+ot+"px"}):l.css({width:f.offset().left+et+"px"}))}var r=u.COMPONENT_EDITOR_MINWIDTH,f=u.COMPONENT_EDITOR_MINHEIGHT,e=u.COMPONENT_EDITOR_MAXWIDTH,o=u.COMPONENT_EDITOR_MAXHEIGHT,s=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.CE,n.MODELING_APP_DIM.WIDTH),h=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.CE,n.MODELING_APP_DIM.HEIGHT),t,i;u.getModelEditorDomNode().kendoWindow({actions:["Close"],draggable:!0,height:h,width:s,maxHeight:o,maxWidth:e,minHeight:f,minWidth:r,modal:!1,pinned:!1,deactivate:function(){this.destroy()},resizable:!0,title:"Component Editor - Version "+n.CeUtility.CE_VERSION,resize:c});t=u.getModelEditorDomNode().data("kendoWindow");t.center();t.open();t.bind("close",function(){var t=$("#modelTitleDialog").data("kendoWindow"),n;t&&t.close();n=$("#modelTitleDialog");n&&n.hide()});i=u.getModelEditorDomNode();u.INITIAL_APP_HEIGHT=i[0].clientHeight;u.INITIAL_APP_WIDTH=i[0].clientWidth},u.prototype.showSymbolEditor=function(){var t=new n.SymbolEditor(this.surface,this.newComponent,!1)},u.prototype.setInfoPaneState=function(n){var t;$("#infoPane").show().scrollTop(0);$("#infoPaneTitleClose").hide();$("#infoPaneTitle").hide();$("#infoPaneTitle").html("");$("#infoPaneClose").hide();$("#quickHelp").hide();$("#compileMessages").hide();$("#symbolPreview").hide();$("#symActiveImage").hide();$("#symDbImage").hide();$("#symAutoImage").hide();$("#previewNotes").hide();switch(n){case r.HELP:$("#infoPaneTitleClose").show();$("#infoPaneTitle").show();$("#infoPaneTitle").html('<span class="infoPaneTitleSpan" style="font-weight:bold">'+u.IP_HELP_TITLE+"<\/span>");$("#infoPaneClose").show();$("#quickHelp").show();break;case r.COMPILE:$("#infoPaneTitleClose").show();$("#infoPaneTitle").show();$("#infoPaneTitle").html('<span class="infoPaneTitleSpan" style="font-weight:bold">'+u.IP_COMPILE_TITLE+"<\/span>");$("#infoPaneClose").show();$("#symbolPreview").show();t=$("#previewNotes");$("#symActiveImage").show();this.configImageCss(i.NEW_COMP);t.addClass("col-xs-6");t.html('<p><span style="color:red">Model-check errors:<\/span><br> The model was saved, but you will not be able to simulate\\edit it\'s symbol until the error(s) are resolved.<br>  Click on the link below for more information:<\/p><span class="btn-link linkCompileMessages">Click here for model check results.<\/span>');t.show();this.addCompileLinkHandler();break;case r.PREVIEW_1SYM:$("#infoPaneTitleClose").show();$("#infoPaneTitle").show();$("#infoPaneTitle").html('<span class="infoPaneTitleSpan" style="font-weight:bold">'+u.IP_PREVIEW_MSG_TITLE+"<\/span>");$("#infoPaneClose").show();$("#symbolPreview").show();t=$("#previewNotes");$("#symActiveImage").show();this.configImageCss(i.NEW_COMP);t.addClass("col-xs-6");t.html("<p>Your component has been saved.<\/p><p>You can: <br>- Edit the symbol by clicking on the image to the left.<br>- Continue editing the model.<br>- Close the Component Editor.<\/p>");t.show();break;case r.PREVIEW_2SYM:$("#infoPaneTitleClose").show();$("#infoPaneTitle").show();$("#infoPaneTitle").html('<span class="infoPaneTitleSpan" style="font-weight:bold">'+u.IP_PREVIEW_MSG_TITLE+"<\/span>");$("#infoPaneClose").show();$("#symbolPreview").show();t=$("#previewNotes");$("#symDbImage").show();$("#symAutoImage").show();this.configImageCss(i.DB_COPY_COMP);this.configImageCss(i.AUTO_COMP);t.removeClass("col-xs-8");t.addClass("col-xs-6");t.html('<p><span style="color:red">Save is not complete!<br><\/span> Please<b> click on an image to the left<\/b> to select the initial symbol to use with your new model.<\/p> <p>On future saves you will have the option to edit the symbol.<\/p>');t.show();break;case r.SAVE:$("#infoPaneTitleClose").show();$("#infoPaneTitle").show();$("#infoPaneTitle").html('<span class="infoPaneTitleSpan" style="font-weight:bold">'+u.IP_SAVE_TITLE+"<\/span>");$("#infoPaneTitle").append('<p>Your component has been saved. You can continue editing or close the Component Editor.<\/p><p> You can access the component from the "My Components" category in the Component Browser.<\/p>');$("#infoPaneClose").show();break;case r.NONE:$("#infoPane").hide();$("#infoPaneTitleClose").hide();$("#infoPaneTitle").html("");$("#infoPaneTitle").hide();$("#infoPaneClose").hide();$("#quickHelp").hide();$("#compileMessages").hide();$("#symbolPreview").hide();$("#symDbImage").hide();$("#symAutoImage").hide();$("#symActiveImage").hide();$("#previewNotes").hide()}},u.prototype.configImageCss=function(t){var o,r,s,f,h,u,c,e,l,y,a,v,p,w;(t==i.DB_COPY_COMP?(o=$("#symDbImage"),r=this.symDbPaper,s=$("#symDbPaperDiv")):t==i.AUTO_COMP?(o=$("#symAutoImage"),r=this.symAutoPaper,s=$("#symAutoPaperDiv")):t==i.NEW_COMP?(o=$("#symActiveImage"),r=this.symNewComponentPaper,s=$("#symNewComponentPaperDiv")):console.log("In configImageCss. Could not find image to configure."),f=n.CeUtility.getRoundedBBVals(n.CeUtility.getPaperBBoxWithoutText(r)),f.height!=Number.POSITIVE_INFINITY&&f.height!=Number.NEGATIVE_INFINITY&&f.width!=Number.POSITIVE_INFINITY&&f.width!=Number.NEGATIVE_INFINITY)&&(h=o.height(),u=o.width(),this.symActiveImageWidthPrev&&u!=this.symActiveImageWidthPrev?Math.abs(this.symActiveImageWidthPrev-u)<6?u=this.symActiveImageWidthPrev:this.symActiveImageWidthPrev=u:this.symActiveImageWidthPrev||(this.symActiveImageWidthPrev=u),c=f.height,e=f.width,e<this.editBtnWidth&&(e=this.editBtnWidth),l=h/2-c/2,l<0&&(l=0),y=0,t!=i.DB_COPY_COMP&&(y=u/2-e/2),a=-1,v=-1,r.width>u?(p=Math.abs(r.width-u),a=e+p):a=r.width,r.height>h?(w=r.height-h,v=c+w):v=r.height,r.setViewBox(0,0,a,v,!1),s.css({width:e,height:c,"margin-top":l,"margin-left":y}),this.resizeME())},u.prototype.addCompileLinkHandler=function(){var n=this;$(".linkCompileMessages").click(function(){$("#previewNotes").html(n.cleanCompileMessage())})},u.prototype.clearPaper=function(n){var t;n=="symAutoPaper"?t=this.symAutoPaper.canvas:n=="symDbPaper"?t=this.symDbPaper.canvas:n=="symNewComponentPaper"&&(t=this.symNewComponentPaper.canvas);t.parentNode&&t.parentNode.removeChild(t)},u.prototype.showSpinner=function(){var t=this,i=$("#loading_me_spinner");this.isSpinnerActive=!0;setTimeout(function(){var n=u.getModelEditorDomNode();$(i).css({top:n.offset().top+100,left:n.offset().left+n.width()/2-75});t.isSpinnerActive&&$(i).fadeIn("slow")},n.CeUtility.minSpin);setTimeout(function(){t.isSpinnerActive&&($(i).fadeOut("slow"),t.isSpinnerActive=!1)},n.CeUtility.maxSpin)},u.prototype.hideSpinner=function(){$("#loading_me_spinner").fadeOut("slow");this.isSpinnerActive=!1},u.prototype.disableButtons=function(){$("#clear_edits_button").addClass("disabled");$("#undo_model_button").addClass("disabled");$("#redo_model_button").addClass("disabled");$("#save_model_button").addClass("disabled")},u.prototype.enableButtons=function(){$("#clear_edits_button").removeClass("disabled");$("#undo_model_button").removeClass("disabled");$("#redo_model_button").removeClass("disabled");$("#save_model_button").removeClass("disabled");$("#saveas_model_button").removeClass("disabled")},u.prototype.cleanCompileMessage=function(){var n=[],t=[];return n=this.compileResults.split("-------------------"),n.length>1?(t=n[1].split(/\^+/),t.length>1?"<b>Location:<\/b> at or near line #"+t[0]+"<br> <b>Message:<\/b> "+t[1]:"<b>Location:<\/b> at or near line #"+n[1]):this.compileResults},u.prototype.checkUpdateTitleText=function(){for(var r,i,u=this.svgElements.getBBox(),t=0;t<this.svgElements.length;t++)for(r=this.svgElements[t][0].classList,i=0;i<r.length;i++)r[i].indexOf("swv_sym_title")>-1&&this.svgElements[t].attr({text:this.modelTitle});this.symNewComponentPaper.clear();this.svgElements=n.CeUtility.getSVGElements(this.newComponent.Img,this.symNewComponentPaper)},u.prototype.highlightLine=function(n){var t=n-1},u.prototype.setInitialInfoPaneState=function(n){this.isMemberOfOwnersGroup(n)&&this.myComponentId?(this.cmReadOnly=!1,this.enableButtons(),this.compileModel(),this.infoPane=r.PREVIEW_1SYM):(this.disableButtons(),$("#saveas_model_button").removeClass("disabled"),this.cmReadOnly=!1,this.infoPane=r.HELP);this.setInfoPaneState(this.infoPane)},u.prototype.initTooltips=function(){n.Utility.setTooltip(u.CLEAR_EDITS_BUTTON,"Clear all edits since last save");n.Utility.setTooltip(u.UNDO_MODEL_BUTTON,"Undo last change (Ctrl-Z)");n.Utility.setTooltip(u.REDO_MODEL_BUTTON,"Redo last change (Ctrl-Y)");n.Utility.setTooltip(u.SAVE_MODEL_BUTTON,"Save model");n.Utility.setTooltip(u.SAVEAS_MODEL_BUTTON,"Save new model");n.Utility.setTooltip(u.MODEL_EDITOR_HELP_BUTTON,"Show Component Editor help");n.Utility.setTooltip(u.EDIT_SYMBOL_BUTTON,"Bring up the Symbol Editor");n.Utility.setTooltip(u.INFO_PANE_CLOSE_BUTTON,"Close the Help window. It will reopen automatically as necessary");n.Utility.setTooltip(u.SYM_NEW_COMPONENT_PAPER_DIV,"Click on image to edit the symbol");n.Utility.setTooltip(u.SYM_AUTO_PAPER_DIV,"Click on image to select your component's starter symbol");n.Utility.setTooltip(u.SYM_DB_PAPER_DIV,"Click on image to select your component's starter symbol")},u.prototype.addMeContainer=function(){var n=document.createElement("div");n.id="meContainer";u.getModelEditorDomNode().append(n)},u.prototype.addToolbar=function(){var n=document.createElement("div"),t,i;n.id="toolbarHelp";n.className="col-xs-12";t=document.createElement("div");t.id="model_editor_toolbar";t.className="col-xs-9 mdlEditToolbar";t.innerHTML='<button id="undo_model_button" class="model_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/undo.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="redo_model_button" class="model_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/redo.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="save_model_button" class="model_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/save.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button><button id="saveas_model_button" class="model_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/saveAs.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button>';i=document.createElement("div");i.id="model_editor_help";i.className="col-xs-2 mdlEditHelp";i.innerHTML='<button id="model_editor_help_button" class="model_editor_toolbar_button" style="border:none; outline:none"><img src="/Content/images/helpblue.png" width="26" height="26" style="vertical-align:text-bottom;"><\/button>';n.appendChild(t);n.appendChild(i);this.fragment.appendChild(n)},u.prototype.addInfoPane=function(){var t=document.createElement("div"),i,r,f,e,c,n,o,s,h,v,y,p,l,a;t.id="infoPane";t.className="col-xs-12";i=document.createElement("div");i.id="infoPaneTitleClose";i.className="col-xs-12";r=document.createElement("div");r.id="infoPaneTitle";r.className="col-xs-4";r.innerHTML='<p><span class="infoPaneTitleSpan" style="font-weight:bold">'+u.IP_HELP_TITLE+"<\/span><\/p>";f=document.createElement("div");f.id="infoPaneClose";f.className="pull-right";f.innerHTML='<div id="info_pane_close_button" type="button" data-dismiss="modal" aria-hidden="true">x<\/div>';i.appendChild(r);i.appendChild(f);e=document.createElement("div");e.id="quickHelp";e.className="col-xs-11";e.innerHTML='<p> The Component Editor allows you to view, edit or create VHDL-AMS/SPICE models that can be simulated with SystemVision.com.<\/p><span class="btn-link linkCEHelp">Click here<\/span> for a short list of Component Editor tips.<br/><span class="btn-link linkModelingHelpMenu">Click here<\/span> for links to modeling tips, tutorials, and additional information.<br/>Click the Save button to bring up the symbol preview image (you must own the component to save).';c=document.createElement("div");c.id="compileMessages";c.className="col-xs-12";n=document.createElement("div");n.id="symbolPreview";n.className="col-xs-12";o=document.createElement("div");o.id="symAutoImage";o.className="col-xs-2";s=document.createElement("div");s.id="symDbImage";s.className="col-xs-2";h=document.createElement("div");h.id="symActiveImage";h.className="col-xs-4";v=document.createElement("div");v.id="symAutoPaperDiv";y=document.createElement("div");y.id="symDbPaperDiv";p=document.createElement("div");p.id="symNewComponentPaperDiv";l=document.createElement("div");l.id="getCompFromServer";l.className="col-xs-0";a=document.createElement("div");a.id="previewNotes";a.className="col-xs-6";o.appendChild(v);s.appendChild(y);h.appendChild(p);n.appendChild(o);n.appendChild(s);n.appendChild(h);n.appendChild(l);n.appendChild(a);t.appendChild(i);t.appendChild(e);t.appendChild(c);t.appendChild(n);this.fragment.appendChild(t)},u.prototype.addEditField=function(){var n=document.createElement("div");n.id="modelEditorCM";n.style.width=u.MODEL_EDITOR_CM_WIDTH.toString();this.fragment.appendChild(n)},u.getModelEditorDomNode=function(){return $("#modelEditorDialog"+u.GLOBAL_COMPONENT_EDITOR_INDEX)},u.prototype.isMemberOfOwnersGroup=function(t){return t!=n.Settings.UUID&&(n.Settings.isProductionMode()||n.Settings.UUID!=n.CeUtility.SCOTT_ID&&n.Settings.UUID!=n.CeUtility.MIKE_ID)?!1:!0},u.prototype.getStarterComp=function(){var t=new n.CeComponent;return this.modelType==n.CE_MODEL_TYPE.VHDL?(t.Title="VHDL Default Title",t.Name="VHDL_Default_Name",t.Src=this.getVhdlTemplateSrc(),t.ModelType=n.CE_MODEL_TYPE.VHDL):this.modelType==n.CE_MODEL_TYPE.SPICE?(t.Title="SPICE Default Title",t.Name="SPICE_Default_Name",t.Src=this.getSpiceTemplateSrc(),t.ModelType=n.CE_MODEL_TYPE.SPICE):this.modelType==n.CE_MODEL_TYPE.SCHEMATIC&&(t.Title="Hierarchy Default Title",t.Name="Hierarchy_Default_Name",t.Src=n.CeStructuralVhdl.structuralVhdlString,t.ModelType=n.CE_MODEL_TYPE.SCHEMATIC),t.Description="",t.DescriptionToolTip="",t.Prefix="x",t.PartNumber="",t.Lib="UserLib",t.ShowComponent=!1,t.BaseName="",t.Author="SVWebLib",t.Status=n.CE_STATUS.EDIT,t.ComponentId="",t.Cx=-1,t.Cy=-1,t.Img=this.getTemplateImg(),t.Pins=[],t.Properties=[],t.Architectures=[],t.Categories=["My Components","Shared Components"],t.DateModified="",t.CreationDate="",t.Revisions=[],t},u.prototype.getSpiceTemplateSrc=function(){return"*\r\n* You can create new SPICE components using either .subckt or .model statements.\r\n* .libs are not supported at this time.\r\n*\r\n* .SUBCKT format:\r\n* =========================\r\n* .SUBCKT NAME p1 p2 etc... param: par1=val1 par2=val2 etc...\r\n* Subcircuit listing goes here...\r\n* .ENDS NAME (end of subcircuit)\r\n*\r\n* Example - RC Lowpass Filter:\r\n* ==========================\r\n* .subckt lowpass pin pout pgnd param: res=100 cap=1u\r\n*   rlp pin pout res\r\n*   clp pout pgnd cap\r\n* .ends\r\n*\r\n* .MODEL statements can also be used to create standalone components (with symbols) for the following devices:\r\n* D, NMOS, PMOS, NPN, PNP, NJF, PJF\r\n"},u.prototype.getTemplateImg=function(){return'<svg viewbox="0,0,80,80" style="overflow: hidden; position: relative;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="80" version="1.1" height="80">\r\n<rect transform="matrix(1,0,0,1,0,0)" x="0" y="0" width="80" height="80" rx="0" ry="0" fill="white" stroke="#000" stroke-width="3" r="0" class="svw_sym svw_sym_shape svw_sym_outline"><\/rect>\r\n<text transform="matrix(1,0,0,1,0,0)" style="text-anchor: start; font: normal normal bold 12px/normal Arial;" x="10" y="20" text-anchor="start"   stroke="none" fill="#000000" stroke-width="1"   class="svw_sym_text swv_sym_title"><tspan dy="0">Symbol<\/tspan><\/text><\/svg>\r\n'},u.prototype.getVhdlTemplateSrc=function(){return"-------------------------------------------------------------------------------\r\n-- Model Title: VHDL Default Title \r\n-- Entity Name: VHDL_Default_Title \r\n-- Author: My Name, Affiliation \r\n-- Created: 2015/06/07 \r\n-- Last update: \r\n-------------------------------------------------------------------------------\r\n-- Description: This description will appear as a tooltip when component is hovered in browser \r\n-- \r\n-- Additional description info can be placed here. It will also be available in the tooltip \r\n-------------------------------------------------------------------------------\r\n \r\nlibrary IEEE;\r\n-- The 'use' clause allows direct access to items in a given library (e.g. for items related to a given technology type) \r\nuse IEEE.electrical_systems.all;\r\n \r\n-- The entity specifies how this model interfaces with the outside world \r\nentity model_template is\r\n \r\n\t-- Generics are the parameters that the user of the model can change from the schematic \r\n\t-- An example of a generic called 'res' of type 'resistance' with units 'Ohm' is shown below \r\n\t-- generic (\r\n\t\t-- res : resistance); -- Generic description [Ohm]\r\n \r\n\t-- Ports represent the pins for the model. These pins are used to connect to other models in the schematic \r\n\t-- An example of two pins, p1 and p2, are specified below. These pins are of type terminal (which means they consist of \r\n\t-- both across and through aspects, and will obey conservation laws). They are also of the electrical subtype (nature) \r\n\t-- which means that the across aspect is voltage and the through aspect is current \r\n\t-- port (\r\n\t\t-- terminal p1, p2 : electrical);\r\n \r\nend entity model_template;\r\n \r\n-- The architecture specifies the functionality of the model \r\narchitecture default of model_template is\r\n \r\n\t-- 'Branch' quantities can be used to assign identifiers to across and through pin aspects so they can be used in equations\r\n\t-- In the example below, 'v' and 'i' are assigned as the respective across and through aspects for both p1 and p2 \r\n\t-- quantity v across i through p1 to p2;\r\n \r\nbegin\r\n \r\n\t-- Equation(s) that govern the model behavior\r\n\t-- Example below shows enforcement of Ohm's law using quantities 'v' and 'i', and generic 'res' \r\n\t\t-- v == i*res;\r\n \r\nend architecture default;\r\n \r\n"},u.prototype.getHierarchicalTemplateSrc=function(){return"-------------------------------------------------------------------------------\r\n-- Model Title: Model Template \r\n-- Entity Name: model_template \r\n-- Author: My Name, Affiliation \r\n-- Created: 2015/06/07 \r\n-- Last update: \r\n-------------------------------------------------------------------------------\r\n-- Description: This description will appear as a tooltip when component is hovered in browser \r\n-- \r\n-- Additional description info can be placed here. It will also be available in the tooltip \r\n-------------------------------------------------------------------------------\r\n"+this.LoadNewModelHeader()+0+" \r\n-- The entity specifies how this model interfaces with the outside world \r\nentity model_template is\r\n \r\n\t-- Generics are the parameters that the user of the model can change from the schematic \r\n\t-- An example of a generic called 'res' of type 'resistance' with units 'Ohm' is shown below \r\n\t-- generic (\r\n\t\t-- res : resistance); -- Generic description [Ohm]\r\n \r\n\t-- Ports represent the pins for the model. These pins are used to connect to other models in the schematic \r\n\t-- An example of two pins, p1 and p2, are specified below. These pins are of type terminal (which means they consist of \r\n\t-- both across and through aspects, and will obey conservation laws). They are also of the electrical subtype (nature) \r\n\t-- which means that the across aspect is voltage and the through aspect is current \r\n\t-- port (\r\n\t\t-- terminal p1, p2 : electrical);\r\n \r\nend entity model_template;\r\n \r\n-- The architecture specifies the functionality of the model \r\narchitecture default of model_template is\r\n \r\nend architecture default;\r\n \r\n"},u.prototype.getSpiceComparatorSrc=function(){return"*\r\n* COMPARATOR MACROMODEL LM139\r\n* USAGE XNAME <-> <+> <OUT> <VCC> <GND> LM139\r\n.SUBCKT LM139 11 14 10 13 15\r\nROO 10 98 1K\r\nCO 98 15 5P\r\nQO 10 5 15 QOM\r\nCBB 5 15 40P\r\nG 5 15 4 15 -36.7739U 2M\r\nJP 8 15 15 JMOD\r\nFEE 13 2 VON 2.43325\r\nVON 13 8 0\r\nFPOLY 15 4 POLY(2) VI1 VI2 0 1 -1\r\nVI2 6 15 0\r\nVI1 7 15 0\r\nDAR 2 1 DMOD\r\nD1 4 15 DM1\r\nD2 15 4 DM2\r\nDO 15 5 DMOD\r\nQ1 7 11 1 QM1\r\nQ2 6 14 1 QM2\r\nRPWR 15 13 1MEG\r\nRR 4 15 252.823K\r\nRB0 15 5 100K\r\n.MODEL JMOD NJF VTO=-3 BETA=4.6926666U\r\n.MODEL DMOD D\r\n.MODEL DM1 D TT=320N\r\n.MODEL DM2 D TT=535N\r\n.MODEL QOM NPN RC=42 BF=13.33 IS=200F\r\n.MODEL QM2 PNP BF=1938.03 IS=0.8F\r\n.MODEL QM1 PNP BF=2185.44 IS=0.740441F\r\n.ENDS LM139\r\n \r\n"},u.prototype.LoadNewModelHeader=function(){return"library ieee; \r\nuse ieee.std_logic_1164.all; \r\nuse ieee.electrical_systems.all; \r\nuse ieee.mechanical_systems.all; \r\nuse ieee.fluidic_systems.all; \r\nuse ieee.thermal_systems.all; \r\nuse ieee.radiant_systems.all; \r\nuse ieee.energy_systems.all; \r\nlibrary mgc_ams; \r\nuse mgc_ams.statistical.all; \r\nlibrary SVWebLib; \r\nuse work.all; \r\n"},u.prototype.createMEMenu=function(){var t=this,r=function(){var i=$("#modelTitleDialog").data("kendoWindow"),n;i&&i.close();n=$("#modelTitleDialog");n&&n.hide();t.closeModelEditorDialog()},i,n;t.meMenu||(i="<b>Editor Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,i),n.addMenuElement("Close Component Editor",r),n.addSeparatorToMenu(),t.meMenu=SVWebContextMenu.MenuHelper.createMenu(n))},u.prototype.setMEMenu=function(){this.createMEMenu();this.meMenu.bindMenuTo(u.getModelEditorDomNode())},u.prototype.resizeME=function(){var n=u.getModelEditorDomNode().data("kendoWindow");n&&n.resize(!0)},u.GLOBAL_COMPONENT_EDITOR_INDEX=0,u.CLEAR_EDITS_BUTTON="#clear_edits_button",u.SAVE_MODEL_BUTTON="#save_model_button",u.SAVEAS_MODEL_BUTTON="#saveas_model_button",u.UNDO_MODEL_BUTTON="#undo_model_button",u.REDO_MODEL_BUTTON="#redo_model_button",u.MODEL_EDITOR_HELP_BUTTON="#model_editor_help_button",u.NEW_TITLE_OK_BUTTON="#new_title_ok_button",u.NEW_TITLE_CANCEL_BUTTON="#new_title_cancel_button",u.EDIT_SYMBOL_BUTTON="#edit_symbol_button",u.INFO_PANE_CLOSE_BUTTON="#info_pane_close_button",u.SYM_NEW_COMPONENT_PAPER_DIV="#symNewComponentPaperDiv",u.SYM_AUTO_PAPER_DIV="#symAutoPaperDiv",u.SYM_DB_PAPER_DIV="#symDbPaperDiv",u.COMPONENT_EDITOR_WIDTH=875,u.COMPONENT_EDITOR_HEIGHT=665,u.COMPONENT_EDITOR_MINWIDTH=500,u.COMPONENT_EDITOR_MINHEIGHT=400,u.COMPONENT_EDITOR_MAXWIDTH=1500,u.COMPONENT_EDITOR_MAXHEIGHT=1500,u.MODEL_EDITOR_CM_WIDTH=u.COMPONENT_EDITOR_WIDTH-10,u.PAPER_WIDTH=120,u.PAPER_HEIGHT=120,u.IP_HELP_TITLE="Component Editor Help",u.IP_PREVIEW_MSG_TITLE="Component Symbol Preview",u.IP_PREVIEW_1SYM_TITLE="Component Preview",u.IP_PREVIEW_2SYM_TITLE="Initial Component Options Preview",u.IP_COMPILE_TITLE="Model Check Warning/Error Messages",u.IP_SAVE_TITLE="Component Successfully Saved",u.IP_PIN_INCONSISTENCY_TITLE="Mismatch Between Model/Symbol Pins",u.INITIAL_APP_WIDTH=-1,u.INITIAL_APP_HEIGHT=-1,u.ME_Z_INDEX=12500,u}();n.ModelEditor=u}(Project||(Project={})),function(n){var t=function(){function t(){this.selectedSet=[];this.hoverSet=[]}return t.prototype.getSingleSelectedObject=function(){return this.selectedSet[0]},t.prototype.getNumSelected=function(){return this.selectedSet.length},t.prototype.getSelectedSet=function(){return this.selectedSet},t.prototype.selectObject=function(n){this.clearSelection();this.select(n)},t.prototype.hoverObject=function(n){this.clearHover();this.hover(n)},t.prototype.toggleSelectObject=function(n){this.isSelected(n)?this.removeFromSelection(n):this.addToSelection(n)},t.prototype.addSelectObject=function(n){this.isSelected(n)||this.addToSelection(n)},t.prototype.deselectObject=function(n){this.isSelected(n)&&this.removeFromSelection(n)},t.prototype.clearSelection=function(){for(var n=0;n<this.getNumSelected();++n)this.selectedSet[n].deselect();this.selectedSet=[]},t.prototype.clearHover=function(){for(var n=0;n<this.hoverSet.length;++n)this.hoverSet[0].hoverOut();this.hoverSet=[]},t.prototype.addToSelection=function(n){this.isSelected(n)||this.select(n)},t.prototype.removeFromSelection=function(n){if(this.isSelected(n)){n.deselect();var t=this.selectedSet.indexOf(n);t>=0&&this.selectedSet.splice(t,1)}},t.prototype.select=function(n){n&&(n.select(),this.selectedSet.push(n))},t.prototype.hover=function(n){n&&(n.hoverIn(),this.hoverSet.push(n))},t.prototype.isSelected=function(n){return n.isSelected?!0:!1},t.prototype.moveSelectedSet=function(n,t){for(var r,i=0;i<this.selectedSet.length;++i)r=this.selectedSet[i],r.dragRelative(n,t)},t.prototype.moveSelectedSetOnGrid=function(){for(var f,i,e,r,u=null,t=0;t<this.selectedSet.length;++t)if(i=this.selectedSet[t],i instanceof n.Component){f=i;u=f.getCenter();break}if(u==null)for(t=0;t<this.selectedSet.length;++t)if(i=this.selectedSet[t],i instanceof BaseWire.WireSegment){e=i;u=e.getExactEndLocation(1);break}return r=u.clone(),r.placeOnGrid(n.Settings.SCH_GRID_SPACING),r.subtract(u),this.moveSelectedSet(r.x,r.y),r},t}();n.CeSelectionManager=t}(Project||(Project={})),function(n){var t=function(){function t(){this.userLibStagingComps=[];this.userLibProductionComps=[];this.showAllStaging=!1;this.showAllProduction=!1;this.prodUrl="";$("#cpmResults").html('<div class="col-md-6" id="resultsLeft"><\/div>');$("#cpmResults").append('<div class="col-md-5" id="resultsRight"><\/div>')}return t.prototype.showDialog=function(){var i=this,n=this,t;$("#compPromotionDialog").kendoWindow({actions:["Close"],draggable:!0,height:"630px",modal:!1,pinned:!1,position:{top:100,left:100},resizable:!1,title:"Component Copy & Promotion",width:"900px"});t=$("#compPromotionDialog").data("kendoWindow");t.center();t.open();$("#compPromotionDialog").parent().css("z-index",12500);this.loadContents();$("#cpmRefreshLists").click(function(){$("#cpmStatus").html("");i.loadContents()});$("#vendorCheckBox :checkbox").click(function(){n.showAllProduction=this.checked?!0:!1;n.loadProductionCompList()})},t.prototype.loadContents=function(){this.loadStagingCompList();this.loadProductionCompList()},t.prototype.loadStagingCompList=function(){$("#resultsLeft").html("Running query...");var i=Date.now(),n=this;$.ajax({url:t.STAGING_URI+"/components/",dataType:"json",type:"GET",contentType:"application/json;charset=utf-8",success:function(t){var u,f,r;for(n.userLibStagingComps=t,n.userLibStagingComps.sort(n.alphaTitleCompare),u=Date.now(),f=(u-i)/1e3,$("#resultsLeft").html('<span style="color: #00CC33; font-weight: bold;">Your UserLib staging Components<\/span><br>'),$("#resultsLeft").append("Elapsed time = "+f+"<br>"),$("#resultsLeft").append("# Of Components = "+n.userLibStagingComps.length+"<br>"),$("#resultsLeft").append('-- Click on title to copy to UserLib <span style="color: blue; font-weight: bold;">production<\/span> --<br>'),$("#resultsLeft").append("<br>"),r=0;r<n.userLibStagingComps.length;r++)$("#resultsLeft").append("<li><div ><a href='#' class='UserLibStaging2UserLibProductionLink' >"+n.userLibStagingComps[r].Title.trim()+"<\/a><\/div><\/li> ");n.initUserLibStaging2UserLibProductionCompHandlers()},error:function(n){$("#resultsLeft").append("<br>");$("#resultsLeft").append("Unable to read your staging UserLib components: "+n.responseText)}})},t.prototype.loadProductionCompList=function(){$("#resultsRight").html("Running query...");var r=Date.now(),i=this;this.prodUrl=i.showAllProduction&&n.Settings.UUID=="e5ce2305-99f6-4836-94b5-efa085b563fe"?t.PRODUCTION_URI+"/components/?library=UserLib":t.PRODUCTION_URI+"/components/";$.ajax({url:i.prodUrl,dataType:"json",type:"GET",contentType:"application/json;charset=utf-8",success:function(n){var u,f,t;for(i.userLibProductionComps=n,i.userLibProductionComps.sort(i.alphaTitleCompare),u=Date.now(),f=(u-r)/1e3,$("#resultsRight").html('<span style="color: blue; font-weight: bold;">Your UserLib production Components<\/span><br>'),$("#resultsRight").append("Elapsed time = "+f+"<br>"),$("#resultsRight").append("# Of Components = "+i.userLibProductionComps.length+"<br>"),$("#resultsRight").append('-- Click on title to copy to UserLib <span style="color: #00CC33; font-weight: bold;">staging<\/span> --<br>'),$("#resultsRight").append("<br>"),t=0;t<i.userLibProductionComps.length;t++)$("#resultsRight").append("<li><div ><a href='#' class='UserLibProduction2UserLibStagingLink' >"+i.userLibProductionComps[t].Title.trim()+"<\/a><\/div><\/li> ");i.initUserLibProduction2UserLibStagingCompHandlers()},error:function(n){$("#resultsRight").append("<br>");$("#resultsRight").append("Unable to read your production UserLib components: "+n.responseText)}})},t.prototype.initUserLibStaging2UserLibProductionCompHandlers=function(){for(var n=this,r,i=0;i<n.userLibStagingComps.length;i++)$(".UserLibStaging2UserLibProductionLink").eq(i).on("click",{value:i},function(i){var u=i.data.value,f="?library=UserLib&componentId="+n.userLibStagingComps[u].ComponentId;$.ajax({url:t.STAGING_URI+"/components/"+f,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(i){r=i[0];$.ajax({url:t.PRODUCTION_URI+"/components?library=UserLib",dataType:"json",type:"POST",data:JSON.stringify(i[0]),contentType:"application/json;charset=utf-8",success:function(t){$("#cpmStatus").html('<span style="color: #00CC33";>'+t.Title+" component has been copied to production<\/span>");n.loadProductionCompList()},error:function(i){i.responseText.indexOf("Component could not be added. Does it already exist?")?n.showUpdateDialog(t.PRODUCTION_URI,r,"production"):$("#cpmStatus").html('<span style="color: red";>Problem posting component: <\/span>'+i.responseText)}})},error:function(){$("#cpmStatus").html('<span style="color: red";>Error getting staging UserLib comp<\/span>')}})})},t.prototype.initUserLibProduction2UserLibStagingCompHandlers=function(){for(var i=this,r,u=0;u<i.userLibProductionComps.length;u++)$(".UserLibProduction2UserLibStagingLink").eq(u).on("click",{value:u},function(u){var f=u.data.value,e="?library=UserLib&componentId="+i.userLibProductionComps[f].ComponentId;$.ajax({url:t.PRODUCTION_URI+"/components/"+e,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(u){r=u[0];n.Settings.UUID=="e5ce2305-99f6-4836-94b5-efa085b563fe"&&(r.Author=n.Settings.UUID);$.ajax({url:t.STAGING_URI+"/components?library=UserLib",dataType:"json",type:"POST",data:JSON.stringify(r),contentType:"application/json;charset=utf-8",success:function(n){$("#cpmStatus").html('<span style="color: #00CC33";>'+n.Title+" component has been copied to staging<\/span>");i.loadStagingCompList()},error:function(n){n.responseText.indexOf("Component could not be added. Does it already exist?")?i.showUpdateDialog(t.STAGING_URI,r,"staging"):$("#cpmStatus").html('<span style="color: red";>Problem posting component: <\/span>'+n.responseText)}})},error:function(){$("#cpmStatus").html('<span style="color: red";>Error getting production UserLib comp<\/span>')}})})},t.prototype.showUpdateDialog=function(t,i,r){var u=this;u.confirmDialog2Btn=new n.MultiBtnModalDialog("Update Existing Component","It appears that this component already exists. Would you like to update it?",["Yes","No"]);jQuery.when(u.confirmDialog2Btn.queryUser()).done(function(f){f==n.BUTTON.BTN1&&u.updateComponent(t,i,r)})},t.prototype.updateComponent=function(n,t,i){var u=this,r=n+"/components?library=UserLib&componentId="+t.ComponentId;$.ajax({url:r,dataType:"json",type:"PUT",data:JSON.stringify(t),contentType:"application/json;charset=utf-8",success:function(n){$("#cpmStatus").html('<span style="color: #00CC33";>'+n.Title+" component has been updated in "+i+".<\/span>")},error:function(){$("#cpmStatus").html('<span style="color: red";>Problem updating component in '+i+".<\/span>")}})},t.prototype.alphaTitleCompare=function(n,t){var i,r,u,f;return(n.Title?(u=n.Title.split(" "),i=n.Title):i=n.Name,t.Title?(f=t.Title.split(" "),r=t.Title):r=t.Name,i.toLowerCase()<r.toLowerCase())?-1:i.toLowerCase()>r.toLowerCase()?1:0},t.PRODUCTION_URI="https://api.systemvision.com/api/1.0",t.STAGING_URI="https://staging-api.systemvision.com/api/1.0",t.LOCAL_URI="https://localhost:44300/api/1.0",t}();n.CompPromotionManager=t}(Project||(Project={})),function(n){var t=function(){function t(){this.allCompRevisions=[];this.updatedRevisions=[];this.isUpdate=!1;this.DEFAULT_REV_DATE="11/01/2015 1:00:00 AM";this.allPromisedUpdates=[];this.allPromisedGetRevs=[]}return t.prototype.updateRevisions=function(n,t,i){var r=this;this.deploy=n;this.promiseGetActiveComp=this.getActiveComp(t,i);$.when(this.promiseGetActiveComp).done(function(){r.promiseGetCompRevisions=r.getCompRevisions();$.when(r.promiseGetCompRevisions).done(function(){r.checkAddDefaultRevision();r.updateActiveCompRevInfo();r.addEntityRevisionSuffix();r.updateAllCompsRevInfo()})})},t.prototype.getActiveComp=function(t,i){var u=this,r=$.Deferred(),f="?library="+t+"&componentId="+i;return $.ajax({url:n.Settings.APIURI()+"/components/"+f,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8"}).done(function(n){u.activeComp=n[0];r.resolve()}).fail(function(){n.MessageManager.showErrorMessage("Error getting staging UserLib comp");r.resolve()}),r.promise()},t.prototype.checkAddDefaultRevision=function(){for(var t=0;t<this.allCompRevisions.length;t++)this.allCompRevisions[t].Revisions.length<1&&(this.activeComp.Revisions.unshift(new n.CeRevision(this.allCompRevisions[t].ComponentId,"New Comp",!1,this.DEFAULT_REV_DATE)),this.allCompRevisions[t].CreationDate=this.DEFAULT_REV_DATE)},t.prototype.updateActiveCompRevInfo=function(){for(var i,r,u=!1,n=0;n<this.allCompRevisions.length;n++)if(this.allCompRevisions[n].ComponentId!=this.activeComp.ComponentId)for(i=0;i<this.allCompRevisions[n].Revisions.length;i++){for(r=0;r<this.activeComp.Revisions.length;r++)if(this.allCompRevisions[n].Revisions[i].ComponentId==this.activeComp.Revisions[r].ComponentId){u=!0;break}u||(this.activeComp.Revisions.unshift(this.allCompRevisions[n].Revisions[i]),u=!1)}t.sortRevisionsByDateAscending(this.activeComp.Revisions)},t.prototype.addEntityRevisionSuffix=function(){var r,i,f,u;if(this.allCompRevisions.length>1)for(t.sortComponentsByDateAscending(this.allCompRevisions),r=new n.CeUtility,i=0;i<this.allCompRevisions.length-1;i++)for(r.oldName=this.allCompRevisions[i].Name,r.oldTitle=this.allCompRevisions[i].Title,this.allCompRevisions[i].Name=this.allCompRevisions[this.allCompRevisions.length-1].Name+"_v"+(i+1),r.updatedName=this.allCompRevisions[i].Name,f=r.updateModelSourceWithName(this.allCompRevisions[i].Src),this.allCompRevisions[i].Src=f,u=0;u<this.activeComp.Revisions.length;u++)this.activeComp.Revisions[u].ComponentId==this.allCompRevisions[i].ComponentId&&(this.activeComp.Revisions[u].Description.indexOf(r.updatedName)>-1||(this.activeComp.Revisions[u].Description=r.updatedName+": "+this.activeComp.Revisions[u].Description))},t.prototype.updateAllCompsRevInfo=function(){for(var t=0;t<this.allCompRevisions.length;t++)this.allCompRevisions[t].Revisions=this.activeComp.Revisions;for(this.isUpdate=!0,t=0;t<this.allCompRevisions.length;t++)this.allPromisedUpdates.push(this.postPutComponent(this.allCompRevisions[t]));$.when.apply($,this.allPromisedUpdates).done(function(){n.MessageManager.showInfoMessage("All component revisions have been updated!")})},t.prototype.getCompRevisions=function(){var n=this,t=$.Deferred();return this.allCompRevisions=[],this.promiseGetActiveCompV1=this.getSingleCompByName(this.activeComp.Lib,this.activeComp.Name+"_v1"),$.when(this.promiseGetActiveCompV1).done(function(){n.promiseGetCompsByName=n.getCompsByName(n.activeComp.Lib,n.activeComp.Name);$.when(n.promiseGetCompsByName).done(function(){var i,u,r;if(n.activeCompV1&&n.activeCompV1.Revisions.length!=0)for(i=0;i<n.activeCompV1.Revisions.length;i++){for(u=!1,r=0;r<n.allCompRevisions.length;r++)if(n.activeCompV1.Revisions[i].ComponentId==n.allCompRevisions[r].ComponentId){u=!0;break}u||n.allPromisedGetRevs.push(n.getCompById(n.activeCompV1.Lib,n.activeCompV1.Revisions[i].ComponentId))}else t.resolve();$.when.apply($,n.allPromisedGetRevs).done(function(){t.resolve()})})}),t.promise()},t.prototype.getCompsByName=function(t,i){var u=this,r=$.Deferred(),f="?library="+t+"&name="+i;return $.ajax({url:n.Settings.APIURI()+"/components/"+f,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8"}).done(function(n){u.allCompRevisions=n;r.resolve()}).fail(function(){n.MessageManager.showErrorMessage("Error getting SVWebLib comps by Name");r.resolve()}),r.promise()},t.prototype.getSingleCompByName=function(t,i){var r=this,u=$.Deferred(),f="?library="+t+"&name="+i;return $.ajax({url:n.Settings.APIURI()+"/components/"+f,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8"}).done(function(n){r.activeCompV1=n[0]?n[0]:null;u.resolve()}).fail(function(){r.activeCompV1=null;console.log("Error getting SVWebLib single comp by Name");u.resolve()}),u.promise()},t.prototype.getCompById=function(t,i){var u=this,r=$.Deferred(),f="?library="+t+"&componentId="+i;return $.ajax({url:n.Settings.APIURI()+"/components/"+f,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8"}).done(function(n){u.allCompRevisions.push(n[0]);r.resolve()}).fail(function(){console.log("Error getting SVWebLib comp by ID");r.resolve()}),r.promise()},t.prototype.postPutComponent=function(t){var u=jQuery.Deferred(),f="",e="POST",i=n.Settings.APIURI(),r,o;return this.deploy=="production"&&(r=i,i=r.indexOf("staging")>-1?r.replace("staging-api","api"):r.replace("stage","api")),this.isUpdate?(f=i+"/components?library=SVWebLib&componentId="+t.ComponentId,e="PUT"):(f=i+"/components?library=SVWebLib",e="POST",this.isUpdate=!1),o=JSON.stringify(t),$.ajax({headers:{TOKEN_HEADER:"97814435-7337-4390-be35-86ca540f7a1b",userID:n.Utility.getUserID()},url:f,dataType:"json",type:e,data:o,contentType:"application/json;charset=utf-8"}).done(function(t){var i=t,r;i.Title?(r="New component successfully saved.",n.MessageManager.showInfoMessage(r)):alert("New component not saved: "+i);u.resolve(!0)}).fail(function(t){var i="Post/Put error: "+t.responseText;n.MessageManager.showErrorMessage(i);u.resolve(!1)}),u.promise()},t.sortRevisionsByDateAscending=function(n){n.sort(function(n,t){return new Date(n.Date).getTime()-new Date(t.Date).getTime()})},t.sortRevisionsByDateDescending=function(n){n.sort(function(n,t){return new Date(t.Date).getTime()-new Date(n.Date).getTime()})},t.sortComponentsByDateAscending=function(n){n.sort(function(n,t){return new Date(n.CreationDate).getTime()-new Date(t.CreationDate).getTime()})},t.sortComponentsByDateDescending=function(n){n.sort(function(n,t){return new Date(t.CreationDate).getTime()-new Date(n.CreationDate).getTime()})},t}();n.CompRevisionControl=t}(Project||(Project={})),function(n){var t=function(){function t(n,t){var i=this;this.allCategories=[];this.isUpdate=!1;this.allPromisedUpdates=[];this.promiseGetActiveComp=this.getActiveComp(n,t);this.promiseGetCats=this.getAllCategories();$.when(this.promiseGetActiveComp,this.promiseGetCats).done(function(){i.showDialog();setTimeout(function(){i.loadForm();i.initializeButtonHandlers()},1e3)})}return t.prototype.loadForm=function(){var r,t,u,n,i;for($("#titleId").val(this.activeComp.Title),$("#nameId").val(this.activeComp.Name),$("#creationDateId").val(this.activeComp.CreationDate),$("#partNumId").val(this.activeComp.PartNumber),$("#descriptionId").val(this.activeComp.Description),$("#descriptionTTId").val(this.activeComp.DescriptionToolTip),$("#prefixId").val(this.activeComp.Prefix),$("#tagsId").val(this.activeComp.Tags),$("#commentsId").val(this.activeComp.Comments),$("#modelSourceId").val(this.activeComp.Src),$("#symbolSourceId").val(this.activeComp.Img),$("#modelLibId").val("SVWebLib"),$("#modelAuthorId").val("SVWeb"),this.activeComp.Cx&&$("#cxId").val(this.activeComp.Cx.toString()),this.activeComp.Cy&&$("#cyId").val(this.activeComp.Cy.toString()),r=$("#categoriesDiv :checkbox"),n=0;n<this.allCategories.length;n++)for(t=0;t<this.activeComp.Categories.length;t++)this.allCategories[n]==this.activeComp.Categories[t]&&$("#categoriesDiv :checkbox[value="+n+"]").prop("checked",!0);for(u=$("#propertiesDiv :radio"),n=0;n<this.activeComp.Properties.length;n++)this.activeComp.Properties[n].PropVisibility==2?($("#propertiesDiv :radio[value="+3*n+0+"]").prop("checked",!1),$("#propertiesDiv :radio[value="+3*n+1+"]").prop("checked",!1),$("#propertiesDiv :radio[value="+3*n+2+"]").prop("checked",!0)):this.activeComp.Properties[n].PropVisibility==1?($("#propertiesDiv :radio[value="+3*n+0+"]").prop("checked",!1),$("#propertiesDiv :radio[value="+3*n+1+"]").prop("checked",!0),$("#propertiesDiv :radio[value="+3*n+2+"]").prop("checked",!1)):($("#propertiesDiv :radio[value="+3*n+0+"]").prop("checked",!0),$("#propertiesDiv :radio[value="+3*n+1+"]").prop("checked",!1),$("#propertiesDiv :radio[value="+3*n+2+"]").prop("checked",!1));this.activeComp.Revisions&&this.activeComp.Revisions.length>0?(i=this.activeComp.Revisions[this.activeComp.Revisions.length-1],$("#compRevisionInfo").html("Latest Revision Date: "+i.Date),$("#criticalId").val(String(this.activeComp.Revisions[this.activeComp.Revisions.length-1].Critical)),$("#revDescriptionId").val(String(this.activeComp.Revisions[this.activeComp.Revisions.length-1].Description))):($("#criticalId").val("No revision info"),$("#revDescriptionId").val("No revision info"));$("#compMetaPromotionDialog").scrollTop(0)},t.prototype.initializeButtonHandlers=function(){var n=this,t=$("#saveCompStagingButton"),i=$("#updateCompStagingButton"),r=$("#copyCompProductionButton"),u=$("#updateCompProductionButton");if(t.hide(),i.hide(),r.hide(),u.hide(),this.activeComp.Lib&&this.activeComp.Lib=="UserLib"){t.show();t.on("click",function(){var t=n.getUpdatedComponent();n.isUpdate=!1;n.postPutComponent("staging",t)})}if(this.activeComp.Lib&&this.activeComp.Lib=="SVWebLib"){i.show();i.on("click",function(){var t=n.getUpdatedComponent();n.isUpdate=!0;n.postPutComponent("staging",t)})}if(this.activeComp.Lib&&this.activeComp.Lib=="SVWebLib"){r.show();r.on("click",function(){var t=n.getUpdatedComponent();n.isUpdate=!1;n.postPutComponent("production",t)})}if(this.activeComp.Lib&&this.activeComp.Lib=="SVWebLib"){u.show();u.on("click",function(){var t=n.getUpdatedComponent();n.isUpdate=!0;n.postPutComponent("production",t)})}},t.prototype.showDialog=function(){var n=$("#compMetaPromotionDialog").data("kendoWindow");if(n)n.open(),$("#compMetaPromotionDialog").parent().css("z-index",12500),this.loadContents();else{$("#compMetaPromotionDialog").kendoWindow({actions:["Close"],draggable:!0,height:"630px",modal:!1,pinned:!1,position:{top:100,left:100},resizable:!1,title:"Component Metadata & Promotion",width:"900px",close:t});n=$("#compMetaPromotionDialog").data("kendoWindow");n.center();n.open();function t(){$("#saveCompStagingButton").off("click");$("#updateCompStagingButton").off("click");$("#copyCompProductionButton").off("click");$("#updateCompProductionButton").off("click")}$("#compMetaPromotionDialog").parent().css("z-index",12500);this.loadContents()}},t.prototype.loadContents=function(){},t.prototype.getUpdatedComponent=function(){var r=this.updateComponentCategories(this.activeComp),u=this.updatePropertyVisibility(r),i=this.updatePinLocations(u),t=new n.CeComponent;return t.Architectures=i.Architectures,t.Author=$("#modelAuthorId").val(),t.BaseName=i.BaseName,t.Categories=i.Categories,t.Comments=$("#commentsId").val(),t.ComponentId=i.ComponentId,t.Cx=$("#cxId").val(),t.Cy=$("#cyId").val(),t.DateModified="AddDateHere",t.CreationDate=i.CreationDate,t.Description=$("#descriptionId").val(),t.DescriptionToolTip=$("#descriptionTTId").val(),t.Img=$("#symbolSourceId").val(),t.Lib=$("#modelLibId").val(),t.ModelType=0,t.Name=$("#nameId").val(),t.PartNumber=$("#partNumberId").val(),t.Pins=i.Pins,t.Prefix=$("#prefixId").val(),t.Properties=i.Properties,t.ShowComponent=!0,t.Src=$("#modelSourceId").val(),t.Status=2,t.Tags=$("#tagsId").val(),t.Title=$("#titleId").val(),t.Url="",t.Visibility=0,t.Revisions=i.Revisions,t.Revisions&&t.Revisions.length>0&&(t.Revisions[t.Revisions.length-1].Critical=$("#criticalId").val(),t.Revisions[t.Revisions.length-1].Description=$("#revDescriptionId").val()),t},t.prototype.updateComponentCategories=function(n){var u=this.allCategories,i=$("#categoriesDiv :checked"),t,r;for(n.Categories=[],t=0;t<i.length;t++)r=u[i[t].value],n.Categories.push(r);return n},t.prototype.updatePropertyVisibility=function(n){for(var t,r=$("#propertiesDiv :checked"),i=0;i<r.length;i++)for(t=0;t<n.Properties.length;t++)r[i].name==n.Properties[t].Name&&(n.Properties[t].PropVisibility=r[i].value);return n},t.prototype.updatePinLocations=function(n){for(var i,t=0;t<n.Pins.length;t++)i=n.Pins[t].Name,n.Pins[t].X=$("#"+i+"_X").val(),n.Pins[t].Y=$("#"+i+"_Y").val(),n.Pins[t].Orientation=$("#"+i+"_Orientation").val();return n},t.prototype.getActiveComp=function(t,i){var u=this,r=$.Deferred(),f="?library="+t+"&componentId="+i;return $.ajax({url:n.Settings.APIURI()+"/components/"+f,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){u.activeComp=n[0];r.resolve()},error:function(){alert("Error getting staging active comp");r.resolve()}}),r.promise()},t.prototype.getAllCategories=function(){var t=this,i=$.Deferred();return $.ajax({url:n.Settings.APIURI()+"/categories/?tableName=SVWebCat",dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){var r=n;t.allCategories=r;setTimeout(function(){t.displayComponentCategories(r);t.genericVisibilityDefault();t.displayComponentPins();t.initializeComponentPins();i.resolve()},3e3)},error:function(){i.resolve()}}),i.promise()},t.prototype.postPutComponent=function(t,i){var h=this,e=jQuery.Deferred(),o="",r="POST",u=n.Settings.APIURI(),f,s;return t=="production"&&(f=u,u=f.indexOf("staging")>-1?f.replace("staging-api","api"):f.replace("stage","api")),this.isUpdate?(o=u+"/components/?library=SVWebLib&componentId="+i.ComponentId,r="PUT"):(o=u+"/components/?library=SVWebLib",r="POST",this.isUpdate=!1),s=JSON.stringify(i),$.ajax({url:o,dataType:"json",headers:{TOKEN_HEADER:"97814435-7337-4390-be35-86ca540f7a1b",userID:n.Utility.getUserID()},type:r,data:s,contentType:"application/json;charset=utf-8"}).done(function(i){var u=i,f,o;u.Title&&r=="POST"?(f=new n.CompRevisionControl,f.updateRevisions(t,u.Lib,u.ComponentId),n.CeUtility.refreshComponentBrowser(u,!1)):u.Title?(n.CeUtility.refreshComponentBrowser(u,!0),o="Component successfully updated: "+u.Title,n.MessageManager.showInfoMessage(o)):alert("Post/Put success, but no comp returned: "+u.Title);e.resolve(!0)}).fail(function(t){var i=t.responseJSON.ExceptionMessage;i?n.MessageManager.showErrorMessage("POST/PUT error: "+i.split("ActivityId")[0]):n.MessageManager.showErrorMessage("POST/PUT error: "+t.responseText);e.resolve(!1)}).always(function(){h.close()}),e.promise()},t.prototype.close=function(){$("#compMetaPromotionDialog").data("kendoWindow").close()},t.prototype.displayComponentCategories=function(n){var o=$("#categoriesDiv"),u,f,t,i,r,e;for(o.html("<label class='control-label compPromoteLabelClass' id='categoryId'>Categories<\/label><br />"),u=document.createDocumentFragment(),$("#categoriesDiv").each(function(){$("#categoriesDiv div:not([class])").remove()}),f=0,t=0;t<n.length;t++){for(i=0;i<this.activeComp.Categories.length;i++)if(r="",this.activeComp.Categories[i].toLowerCase()==n[t].toLowerCase()){r="checked";continue}else r="";e=document.createElement("div");e.innerHTML='<div class="col-md-12 compPromoteCategoryClass" style="float: left;"><input type="checkbox" value='+t+" "+r+" />    "+n[t]+" <\/div>";u.appendChild(e);f++}$("#categoriesDiv").append(u.childNodes);$("#categoriesDiv").css({height:22*f});$("#categoriesDiv").show()},t.prototype.genericVisibilityDefault=function(){var t=$("#propertiesDiv"),i,n;for(t.html("<label class='control-label compPromoteLabelClass' id='propVisibilityId'>Property Visibility<\/label><br />"),t.append("<label class='compPromoteGenericsLabelClass col-md-3' id='propNameId'>Property Name<\/label>"),t.append("<label class='compPromoteGenericsLabelClass col-md-2' id='propNoneId'>Show none<\/label>"),t.append("<label class='compPromoteGenericsLabelClass col-md-2' id='propValueId'>Show value<\/label>"),t.append("<label class='compPromoteGenericsLabelClass col-md-2' id='propAllId'>Show all<\/label>"),i=document.createDocumentFragment(),$("#propertiesDiv").each(function(){$("#propertiesDiv div:not([class])").remove()}),n=0;n<this.activeComp.Properties.length;n++){var r=" name="+this.activeComp.Properties[n].Name,u=document.createElement("div"),f="checked",e="",o="";if(this.activeComp.Properties[n].PropVisibility==1)var f="",e="checked",o="";else if(this.activeComp.Properties[n].PropVisibility==2)var f="",e="",o="checked";else var f="checked",e="",o="";u.innerHTML='<div class="compPromoteGenericsClass" style="float: left; width: 25%;">'+this.activeComp.Properties[n].Name+'<\/div><div style="float: left; width: 25%;"><input '+r+' type="radio" value="0" '+f+' /><\/div><div style="float: left; width: 25%;"><input '+r+' type="radio" value="1" '+e+" /><\/div><input "+r+' type="radio" value="2" '+o+" />";i.appendChild(u)}$("#propertiesDiv").append(i.childNodes);$("#propertiesDiv").show()},t.prototype.displayComponentPins=function(){var n=$("#pinsDiv"),i,t;for(n.html(""),n.append("<br /><label class='compPromoteLabelClass col-md-3' id='pinNameId'>Pin Name<\/label>"),n.append("<label class='compPromoteLabelClass col-md-2' id='pinXId'>X<\/label>"),n.append("<label class='compPromoteLabelClass col-md-2' id='pinYd'>Y<\/label>"),n.append("<label class='compPromoteLabelClass col-md-2' id='pinOrientationId'>Orientation (NSEW)<\/label><br />"),i=document.createDocumentFragment(),$("#pinsDiv").each(function(){$("#pinsDiv div:not([class])").remove()}),t=0;t<this.activeComp.Pins.length;t++){var r=this.activeComp.Pins[t].Name,f=r+"_X",e=r+"_Y",o=r+"_Orientation",u=document.createElement("div");u.innerHTML='<div class="row"><div class="compPromoteGenericsClass col-md-2">'+this.activeComp.Pins[t].Name+'<\/div><div class="col-md-2 md-offset-1"><input autocomplete="off" type="text" class="input-small compPromotePinsInputClass" id="'+f+'" /><\/div><div class="col-md-3"><input autocomplete="off" type="text" class="input-small compPromotePinsInputClass" id="'+e+'" /><\/div><div class="col-md-3 md-offset-1"><input autocomplete="off" type="text" class="input-small compPromotePinsInputClass" id="'+o+'" /><\/div><\/div><br />';i.appendChild(u)}$("#pinsDiv").append(i.childNodes);$("#pinsDiv").show()},t.prototype.initializeComponentPins=function(){for(var t,i=this.activeComp,n=0;n<this.activeComp.Pins.length;n++)t=this.activeComp.Pins[n].Name,$("#"+t+"_X").val(i.Pins[n].X),$("#"+t+"_Y").val(i.Pins[n].Y),$("#"+t+"_Orientation").val(i.Pins[n].Orientation)},t}();n.CompMetadataPlusPromotion=t}(Project||(Project={})),function(n){var t,u,i,f,r;(function(n){n[n.DMB=0]="DMB";n[n.CE=1]="CE";n[n.SE=2]="SE";n[n.HELP=3]="HELP";n[n.SCH2VHD=4]="SCH2VHD";n[n.SPICE=5]="SPICE"})(n.MODELING_APP||(n.MODELING_APP={}));t=n.MODELING_APP,function(n){n[n.WIDTH=0]="WIDTH";n[n.HEIGHT=1]="HEIGHT"}(n.MODELING_APP_DIM||(n.MODELING_APP_DIM={}));u=n.MODELING_APP_DIM;i=function(){function i(){this.entityStartLine=0;this.oldTitle="";this.oldName="";this.updatedName=""}return i.endsWith=function(n,t){return n.indexOf(t,n.length-t.length)!==-1},i.startsWith=function(n,t){return n.indexOf(t)==0},i.getSvgWidthHeight=function(n){var t=[];if(!n)return t;for(var e=n.split(">"),o=e[0],i="",r="",u=n.indexOf("width=")+7,f=n.indexOf("height=")+8;!isNaN(n.charAt(u));)i=i+n.charAt(u),u++;while(!isNaN(n.charAt(f)))r=r+n.charAt(f),f++;return t.push(parseInt(i)),t.push(parseInt(r)),t},i.getSVGElements=function(n,t){var i=n.replace(/\s+</g,"<"),r=(new DOMParser).parseFromString(i,"text/xml");return t.importSVG(r)},i.getPaperElements=function(n){var t=[];return n.forEach(function(n){t.push(n)}),t},i.getPaperBBox=function(n){for(var r=i.getPaperElements(n),u=n.set(),t=0;t<r.length;t++)u.push(r[t]);return u.getBBox()},i.getSvgFromPaper=function(n,t){for(var f,e=i.getPaperElements(t),s=t.set(),u=0;u<e.length;u++)s.push(e[u]);f=this.getRoundedBBVals(s.getBBox());r.isDebugBBox&&console.log("CeUtility getSvgFromPaper BB: \n"+f.x+"  "+f.y+"  "+f.width+"  "+f.height+"\n");var l=t.toSVG(0,0,f.width,f.height),h=n.split(">"),o="",c=h[0]+">";for(o+=c,u=0;u<e.length;u++)e[u].node&&(o+=e[u].node.outerHTML);return o+"<\/svg>"},i.getRoundedBBVals=function(n){return n.x=Math.round(n.x),n.y=Math.round(n.y),n.x2=Math.round(n.x2),n.y2=Math.round(n.y2),n.width=Math.round(n.width),n.height=Math.round(n.height),n},i.getBBoxWithoutText=function(n){for(var i,t=0;t<n.length;++t)n[t].node.nodeName=="text"&&(n[t].removed=1);for(i=n.getBBox(),t=0;t<n.length;++t)delete n[t].removed;return i},i.getPaperBBoxWithoutText=function(n){for(var f,u,o,r=i.getPaperElements(n),e=n.set(),t=0;t<r.length;++t){if(r[t][0])for(e.push(r[t]),f=r[t][0].classList,u=0;u<f.length;u++)if(f[u].indexOf("svw_sym_text")>-1||f[u].indexOf("swv_sym_title")>-1||f[u].indexOf("text_rect")>-1){r[t].removed=1;break}r[t].node.nodeName=="text"&&(r[t].removed=1);r[t].attr("opacity")=="0"&&(r[t].removed=1)}for(o=e.getBBox(),t=0;t<r.length;++t)delete r[t].removed;return o},i.getPaperBBoxWithoutTextPinIndicators=function(n){for(var f,u,o,r=i.getPaperElements(n),e=n.set(),t=0;t<r.length;++t){if(r[t][0])for(e.push(r[t]),f=r[t][0].classList,u=0;u<f.length;u++)if(f[u].indexOf("indicator")>-1||f[u].indexOf("svw_sym_text")>-1||f[u].indexOf("swv_sym_title")>-1||f[u].indexOf("text_rect")>-1||f[u].indexOf("gridHoriz")>-1||f[u].indexOf("gridVert")>-1||f[u].indexOf("schematicbackground")>-1||f[u].indexOf("svw_sym_bbox")>-1){r[t].removed=1;break}r[t].node.nodeName=="text"&&(r[t].removed=1);r[t].attr("opacity")=="0"&&(r[t].removed=1)}for(o=e.getBBox(),t=0;t<r.length;++t)delete r[t].removed;return o},i.getPaperBBoxWithoutPinsText=function(n){for(var u,r,o,f=i.getPaperElements(n),e=n.set(),t=0;t<f.length;++t){if(f[t][0])for(e.push(f[t]),u=f[t][0].classList,r=0;r<u.length;r++)if(u[r].indexOf("arrow")>-1||u[r].indexOf("whisker")>-1||u[r].indexOf("indicator")>-1||u[r].indexOf("svw_sym_text")>-1||u[r].indexOf("swv_sym_title")>-1||u[r].indexOf("gridHoriz")>-1||u[r].indexOf("gridVert")>-1||u[r].indexOf("schematicbackground")>-1||u[r].indexOf("text_rect")>-1||u[r].indexOf("svw_sym_bbox")>-1){f[t].removed=1;break}f[t].node.nodeName=="text"&&(f[t].removed=1);f[t].attr("opacity")=="0"&&(f[t].removed=1)}for(o=e.getBBox(),t=0;t<f.length;++t)delete f[t].removed;return o},i.getBBoxWithoutPinsText=function(n){for(var r,i,u,t=0;t<n.length;++t){if(n[t][0])for(r=n[t][0].classList,i=0;i<r.length;i++)if(r[i].indexOf("arrow")>-1||r[i].indexOf("whisker")>-1||r[i].indexOf("indicator")>-1||r[i].indexOf("svw_sym_text")>-1||r[i].indexOf("swv_sym_title")>-1||r[i].indexOf("text_rect")>-1||r[i].indexOf("gridHoriz")>-1||r[i].indexOf("gridVert")>-1||r[i].indexOf("schematicbackground")>-1||r[i].indexOf("svw_sym_bbox")>-1){n[t].removed=1;break}n[t].node.nodeName=="text"&&(n[t].removed=1);n[t].attr("opacity")=="0"&&(n[t].removed=1)}for(u=n.getBBox(),t=0;t<n.length;++t)delete n[t].removed;return u},i.removeElementsByClassTag=function(n,t){for(var e,f,o=n.set(),u=i.getPaperElements(n),r=0;r<u.length;r++)if(u[r][0])for(e=u[r][0].classList,f=0;f<e.length;f++)e[f].indexOf(t)>-1&&o.push(u[r]);return o.remove(),n},i.convertFontStringToFontElements=function(n){for(var i={fontStyle:"",fontVariant:"",fontWeight:"",fontSize:"",fontFamily:""},t=[],u=[],t=n.split(" "),r=0;r<t.length;r++)t[r].trim();return i.fontStyle=t[0],i.fontVariant=t[1],i.fontWeight=t[2],t[3]&&(u=t[3].split("/"),i.fontSize=u[0]),i.fontFamily=t[4],i},i.updatePinArray=function(t,u){var ct=i.getPaperElements(u),f,s,l,ht;r.isDebugElements&&console.log("CeUtility uodatePinArray: #elems = "+ct.length);var h=surface.getDesign().getCssClassMgr(),o=[],e=[],d=[],nt=i.PIN_INDICATOR_WIDTH,tt=i.PIN_INDICATOR_HEIGHT,vt=i.PIN_WHISKER_WIDTH,k=i.PIN_WHISKER_LENGTH,a=0,v=0,y=0,p=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,c=i.getPaperBBoxWithoutPinsText(u),st=i.getGridPointOffset(c.x+c.width,c.y,n.Settings.SCH_GRID_SPACING),g=10;for(f=0;f<t.length;f++)if((t[f].X<0||t[f].Y<0)&&(t[f].X=c.x+c.width+st.X+n.Settings.SCH_GRID_SPACING,t[f].Y=c.y+st.Y+g,t[f].Orientation=n.CE_PIN_ORIENTATION.EAST,g=g+n.Settings.SCH_GRID_SPACING),t[f].Orientation==n.CE_PIN_ORIENTATION.NORTH?(a=t[f].X,v=t[f].Y,y=t[f].X,p=t[f].Y+k):t[f].Orientation==n.CE_PIN_ORIENTATION.SOUTH?(a=t[f].X,v=t[f].Y,y=t[f].X,p=t[f].Y-k):t[f].Orientation==n.CE_PIN_ORIENTATION.EAST?(a=t[f].X,v=t[f].Y,y=t[f].X-k,p=t[f].Y):t[f].Orientation==n.CE_PIN_ORIENTATION.WEST?(a=t[f].X,v=t[f].Y,y=t[f].X+k,p=t[f].Y):console.log("CeUtility: pin orientation not found for "+t[f].Name+"\n"),o.push(u.path("M"+a+","+v+"L"+y+","+p+"Z")),o[f].attr("stroke-width",3),o[f].attr("opacity",1),e.push(u.rect(t[f].X-nt/2,t[f].Y-tt/2,nt,tt)),e[f].attr("fill","gray"),e[f].attr("stroke-width",0),e[f].attr("opacity",.5),e[f].id=t[f].Index,t[f].Type==1?(e[f].node.setAttribute("class","svw_sym "+h.getSymPinIndicatorClass(t[f].Type)),o[f].node.setAttribute("class","svw_sym "+h.getSymPinWhiskerClass(t[f].Type))):(e[f].node.setAttribute("class","svw_sym "+h.getSymPinIndicatorClass(t[f].SubType)),o[f].node.setAttribute("class","svw_sym "+h.getSymPinWhiskerClass(t[f].SubType))),t[f].Type==2)d.push(u.set([o[f],e[f]]));else{s=this.getArrowCoords(t[f]);it=s.x0;rt=s.y0;ut=s.x1;ft=s.y1;et=s.x2;ot=s.y2;l=u.path("M"+it+","+rt+"L"+ut+","+ft+"L"+et+","+ot+"Z");l.attr("fill","red");l.attr("stroke-width",0);t[f].Type==1?l.node.setAttribute("class","svw_sym "+h.getSymPinArrowClass(t[f].Type)):l.node.setAttribute("class","svw_sym "+h.getSymPinArrowClass(t[f].SubType));var lt=t[f].X,at=t[f].Y,w=-1,b=-1;t[f].Mode==0&&(t[f].Orientation==n.CE_PIN_ORIENTATION.NORTH?(w=t[f].X,b=t[f].Y+15):t[f].Orientation==n.CE_PIN_ORIENTATION.SOUTH?(w=t[f].X,b=t[f].Y-15):t[f].Orientation==n.CE_PIN_ORIENTATION.EAST?(w=t[f].X-15,b=t[f].Y):(w=t[f].X+15,b=t[f].Y),ht="M"+lt+","+at+"L"+w+","+b,o[f].attr("path",ht));d.push(u.set([o[f],e[f],l]))}return d},i.getArrowCoords=function(n){var c=i.PIN_WHISKER_WIDTH,t=i.PIN_WHISKER_LENGTH,r=i.PIN_ARROW_HEIGHT,u,f,e,o,s,h=0;switch(n.Orientation){case 0:n.Mode==0?(u=n.X-r/2,f=n.Y+t/2,e=n.X+r/2,o=n.Y+t/2,s=n.X,h=n.Y+t):n.Mode==1?(u=n.X-r/2,f=n.Y+t,e=n.X,o=n.Y+t/2,s=n.X+r/2,h=n.Y+t):(u=n.X-r/2,f=n.Y+t/2,e=n.X+r/2,o=n.Y+t/2,s=n.X,h=n.Y+t);break;case 1:n.Mode==0?(u=n.X-r/2,f=n.Y-t/2,e=n.X,o=n.Y-t,s=n.X+r/2,h=n.Y-t/2):n.Mode==1?(u=n.X-r/2,f=n.Y-t,e=n.X+r/2,o=n.Y-t,s=n.X,h=n.Y-t+r):(u=n.X-r/2,f=n.Y-t/2,e=n.X,o=n.Y-t,s=n.X+r/2,h=n.Y-t/2);break;case 2:n.Mode==0?(u=n.X-t,f=n.Y,e=n.X-t/2,o=n.Y-r/2,s=n.X-t/2,h=n.Y+r/2):n.Mode==1?(u=n.X-t,f=n.Y-r/2,e=n.X-t/2,o=n.Y,s=n.X-t,h=n.Y+r/2):(u=n.X-t,f=n.Y-r/2,e=n.X-t/2,o=n.Y,s=n.X-t,h=n.Y+r/2);break;case 3:n.Mode==0?(u=n.X+t/2,f=n.Y-r/2,e=n.X+t,o=n.Y,s=n.X+t/2,h=n.Y+r/2):n.Mode==1?(u=n.X+t/2,f=n.Y,e=n.X+t,o=n.Y-r/2,s=n.X+t,h=n.Y+r/2):(u=n.X+t/2,f=n.Y-r/2,e=n.X+t,o=n.Y,s=n.X+t/2,h=n.Y+r/2)}return{x0:u,y0:f,x1:e,y1:o,x2:s,y2:h}},i.getGridPointOffset=function(n,t,i){var r=i,u=n%r,e=t%r,o=0,s=0;return o=u>5?-u+r:-u,s=e>5?-e+r:-e,new f(o,s)},i.getArrayMax=function(n){return Math.max.apply(Math,n)},i.getArrayMin=function(n){return Math.min.apply(Math,n)},i.getOpenCloseState=function(){for(var i,t=!1,n=0;n<20;n++)if(i=$("#modelEditorDialog"+n),i.length!=0){t=!0;break}return t},i.isOpen=function(){return i.getOpenCloseState()?(n.MessageManager.showInfoMessage("The Component Editor is already open. Multiple Component Editors cannot be invoked simultaneously."),!0):!1},i.getInitialModelingToolDim=function(i,r){var f=100,v=surface.getSidebarManager(),h=-1,c=-1,l=-1,a=-1,e=-1,o=-1,s=-1;return i==t.SE?(f=100,e=n.SymbolEditor.SYMBOL_EDITOR_HEIGHT,o=n.SymbolEditor.SYMBOL_EDITOR_WIDTH,h=n.SymbolEditor.SYMBOL_EDITOR_MINHEIGHT,c=n.SymbolEditor.SYMBOL_EDITOR_MINWIDTH,l=n.SymbolEditor.SYMBOL_EDITOR_MAXHEIGHT,a=n.SymbolEditor.SYMBOL_EDITOR_MAXWIDTH):i==t.CE?(f=100,e=n.ModelEditor.COMPONENT_EDITOR_HEIGHT,o=n.ModelEditor.COMPONENT_EDITOR_WIDTH,h=n.ModelEditor.COMPONENT_EDITOR_MINHEIGHT,c=n.ModelEditor.COMPONENT_EDITOR_MINWIDTH,l=n.ModelEditor.COMPONENT_EDITOR_MAXHEIGHT,a=n.ModelEditor.COMPONENT_EDITOR_MAXWIDTH):i==t.HELP?(f=100,e=n.CeHelp.CE_HELP_HEIGHT,o=n.CeHelp.CE_HELP_WIDTH,h=n.CeHelp.CE_HELP_MINHEIGHT,c=n.CeHelp.CE_HELP_MINWIDTH,l=n.CeHelp.CE_HELP_MAXHEIGHT,a=n.CeHelp.CE_HELP_MAXWIDTH):i==t.DMB?(f=100,e=Dmb.DmbWindow.DMB_HEIGHT,o=Dmb.DmbWindow.DMB_WIDTH,h=Dmb.DmbWindow.DMB_MINHEIGHT,c=Dmb.DmbWindow.DMB_MINWIDTH,l=Dmb.DmbWindow.DMB_MAXHEIGHT,a=Dmb.DmbWindow.DMB_MAXWIDTH):i==t.SCH2VHD?(f=100,e=n.CeStructuralVhdlSplash.SCH_VHD_HEIGHT,o=n.CeStructuralVhdlSplash.SCH_VHD_WIDTH,h=n.CeStructuralVhdlSplash.SCH_VHD_MINHEIGHT,c=n.CeStructuralVhdlSplash.SCH_VHD_MINWIDTH,l=n.CeStructuralVhdlSplash.SCH_VHD_MAXHEIGHT,a=n.CeStructuralVhdlSplash.SCH_VHD_MAXWIDTH):i==t.SPICE?(f=100,e=n.SpiceSplash.SPICE_HEIGHT,o=n.SpiceSplash.SPICE_WIDTH,h=n.SpiceSplash.SPICE_MINHEIGHT,c=n.SpiceSplash.SPICE_MINWIDTH,l=n.SpiceSplash.SPICE_MAXHEIGHT,a=n.SpiceSplash.SPICE_MAXWIDTH):console.log("Incorrect call for MODELING_APP"),r==u.HEIGHT?(s=$("#main_editor").height()-f,s>e&&(s=e)):r==u.WIDTH?(s=$("#main_editor").width()-f,s>o&&(s=o)):console.log("Incorrect call for MODELING_APP_DIM"),s},i.prototype.updateModelSourceWithName=function(n){var t=n;return this.modelSrcArray=t.split("\n"),this.getEntityStartLineNum(),this.updateName(),this.getUpdatedModelSource()},i.prototype.getEntityStartLineNum=function(){for(var u,s,e,f,n,r=[],o="",t=0;t<this.modelSrcArray.length;t++){if(i.startsWith(this.modelSrcArray[t].trim().toLowerCase(),"entity")){for(r.push(t),u=this.modelSrcArray[t].toLowerCase().split(/[\s]+/),s=[],n=0;n<u.length;n++)u[n]&&s.push(u[n]);o=u[1].toLowerCase()}if(i.startsWith(this.modelSrcArray[t].trim().toLowerCase(),"end")){for(e=this.modelSrcArray[t].toLowerCase().split(/[\s;]+/),f=[],n=0;n<e.length;n++)e[n]&&f.push(e[n]);f.length>1&&(f[1].trim().toLowerCase()=="entity"||f[1].trim().toLowerCase()==o)&&r.push(t)}}this.entityStartLine=r.length>2?r[r.length-3]:0},i.prototype.updateName=function(){var n,u,t,r;if(this.updatedName)for(n=this.entityStartLine;n<this.modelSrcArray.length;n++)if(!i.startsWith(this.modelSrcArray[n].trim().toLowerCase(),"--")){for(u="",t=this.modelSrcArray[n].split("--"),t[0]=this.performNameSubstitution(t[0]),r=0;r<t.length;r++)u+=r==1?"--"+t[r]:t[r];this.modelSrcArray[n]=u}},i.prototype.performNameSubstitution=function(n){var t=n,i;return t.indexOf(this.updatedName)>-1?t:(this.oldTitle&&this.oldName&&this.oldTitle==this.oldName?(i=new RegExp(this.oldName,"g"),t=t.replace(i,this.updatedName)):this.oldName&&(i=new RegExp(this.oldName,"g"),t=t.replace(i,this.updatedName)),t)},i.prototype.getUpdatedModelSource=function(){return this.modelSrcArray.join("\n")},i.refreshComponentBrowser=function(n,t){var i=getSchematic();t?(n.library=n.Lib?n.Lib:"UserLib",i.getComponentDataManager().updateCollection(n)):i.getComponentDataManager().addToCollection(n,n.Lib);n.Categories[0]?surface.getComponentBrowserSidebar().openCategory(n.Categories[0]):surface.getComponentBrowserSidebar().openCategory(Sidebar.ComponentBrowser.MY_COMPONENTS_CATEGORY)},i.getModelType=function(t){for(var f=n.CE_MODEL_TYPE.SPICE,e=t,u=e.split("\n"),r=0;r<u.length;r++)if(u[r]=u[r].trim(),i.startsWith(u[r].toLowerCase(),".subckt")||i.startsWith(u[r].toLowerCase(),".model")){f=n.CE_MODEL_TYPE.SPICE;break}else if(i.startsWith(u[r].toLowerCase(),"entity")||i.startsWith(u[r].toLowerCase(),"architecture")){f=n.CE_MODEL_TYPE.VHDL;break}else(u[r].toLowerCase().indexOf(".subckt")||u[r].toLowerCase().indexOf(".model"))&&(f=n.CE_MODEL_TYPE.SPICE);return f},i.CE_VERSION="1.0",i.PIN_INDICATOR_WIDTH=8,i.PIN_INDICATOR_HEIGHT=8,i.PIN_WHISKER_WIDTH=3,i.PIN_WHISKER_LENGTH=20,i.PIN_ARROW_WIDTH=10,i.PIN_ARROW_HEIGHT=10,i.SCOTT_ID="e5ce2305-99f6-4836-94b5-efa085b563fe",i.MIKE_ID="bfd03a2a-6bc2-4bea-bb76-d4d376761449",i.OFFSET_NO_PINS=30,i.OFFSET_WITH_PINS=10,i.DEFAULT_TITLE_FONT_SIZE="12",i.DEFAULT_TITLE_FONT_WEIGHT="bold",i.DEFAULT_FONT_SIZE="10",i.DEFAULT_FONT_FAMILY="Arial",i.DEFAULT_FONT_COLOR="#000000",i.DEFAULT_FONT_WEIGHT="normal",i.DEFAULT_FONT_STYLE="normal",i.minSpin=1e3,i.maxSpin=15e3,i}();n.CeUtility=i;f=function(){function n(n,t){this.X=n;this.Y=t}return n}();n.CePoint=f;r=function(){function n(){}return n.showFlow=function(n){console.log(n+" \n")},n.showPins=function(n,t){for(var r=n+" = \n",i=0;i<t.length;i++)r+=t[i].Name+" "+t[i].X+" "+t[i].Y+" "+t[i].Orientation+"\n";console.log(r)},n.showElems=function(n,t){for(var r,u="\n"+n+" length = "+t.length,i=0;i<t.length;i++)if(u+="\ntype = "+t[i].type+", ",t[i].node&&t[i].node.classList)for(r=0;r<t[i].node.classList.length;r++)u+="class = "+t[i].node.classList[r]+", ";console.log(u)},n.showSetElems=function(n,t){for(var r="\n"+n+" length = "+t.length,i=0;i<t.length;i++)r+="type = "+t[i].type+" ",r+="x = "+t[i].attr("x")+" ",r+="y = "+t[i].attr("y")+" ",r+="width = "+t[i].attr("width")+" ",r+="height = "+t[i].attr("height")+"\n";console.log(r)},n.showPaperElems=function(n,t){for(var f,r=i.getPaperElements(t),e="\n"+n+" length = "+r.length,u=0;u<r.length;u++)if(e+="\ntype = "+r[u].type+", ",r[u].node&&r[u].node.classList)for(f=0;f<r[u].node.classList.length;f++)e+="class = "+r[u].node.classList[f]+", ";console.log(e)},n.showElemsBB=function(n,t){var r=i.getRoundedBBVals(t.getBBox()),u="\n"+n+" = ";u+=r.x+"  "+r.y+"  "+r.x2+"  "+r.y2+"  "+r.width+"  "+r.height;console.log(u)},n.isDebugFlow=!1,n.isDebugPins=!1,n.isDebugBBox=!1,n.isDebugElements=!1,n.isDebugSymbolElements=!1,n.isDebugScaling=!1,n.isDebugText=!1,n.isDebugSEPins=!1,n}();n.CeDebug=r}(Project||(Project={})),function(n){var t=function(){function t(){this.LEFT_OFFSET=35;this.TOP_OFFSET=60;this.scaleX=-1;this.scaleY=-1;this.highlightState=n.HIGHLIGHT_STATE.NONE}return t.prototype.select=function(){this.showHighlightBox(n.HIGHLIGHT_STATE.SELECTED)},t.prototype.deselect=function(n){this.hideHighlightBox(n);this.highlightBox.attr("opacity","0").attr("stroke-opacity","0")},t.prototype.isSelected=function(){return this.highlightState===n.HIGHLIGHT_STATE.SELECTED},t.prototype.showHighlightBox=function(t,i){this.hideHighlightBox(!1,!1);t!=null&&(this.highlightState=t);switch(this.highlightState){case n.HIGHLIGHT_STATE.SELECTED:this.highlightBox.attr("fill",Schematic.Surface.SELECTION_COLOR).attr("fill-opacity","1").attr("stroke","#000").attr("stroke-dasharray","")}this.highlightState!==n.HIGHLIGHT_STATE.NONE&&(i==null||i?this.highlightBox.animate({opacity:"0.8","stroke-opacity":"1"},300):this.highlightBox.attr("opacity","0.8").attr("stroke-opacity","1"))},t.prototype.hideHighlightBox=function(t,i){t==null||t?this.highlightBox.animate({opacity:"0","stroke-opacity":"0"},300):this.highlightBox.attr("opacity","0").attr("stroke-opacity","0");(i==null||i)&&(this.highlightState=n.HIGHLIGHT_STATE.NONE)},t}();n.CeSymBase=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r){t.call(this);this.pinSet=null;this.metaData=null;this.se=n;this.scaleX=n.scaleX;this.scaleY=n.scaleY;this.pinSet=i;this.metaData=r;this.buildHighlightBox();this.buildOverlay();this.toFront();this.defineEvents(n,this,this.pinSet)}return __extends(i,t),i.prototype.defineEvents=function(t,i,r){function a(){$("#seToolTipId").hide();i.updateBaseSymbolBoundaries();e=o.wrapper.offset();s=e.left;h=e.top}function v(n,t,e,o){$("#seToolTipId").hide();var c=e-s-36,l=o-h-105;i.updatePinOrientation(c,l);i.translateSet(r,n*i.scaleX-u,t*i.scaleY-f);u=n*i.scaleX;f=t*i.scaleY}function y(){u=0;f=0;$("#seToolTipId").hide();var e=i.pinSet[1].getBBox(),o=n.CeUtility.getGridPointOffset(e.cx,e.cy,n.Settings.SCH_GRID_SPACING);i.translateSet(r,o.X,o.Y);t.ceSelectionManager.clearSelection();t.ceSelectionManager.selectObject(i)}function p(){t.ceSelectionManager.clearSelection();t.ceSelectionManager.selectObject(i)}function w(){alert("Dbl-clk handler")}var u,f,o,e,s,h,c,l;i.initTT();u=null;f=null;i.updateBaseSymbolBoundaries();o=$("#symbolEditorDialog"+n.SymbolEditor.GLOBAL_SYMBOL_EDITOR_INDEX).data("kendoWindow");this.pinSet.drag(v,a,y);c=function(){this[0].style.cursor="move"};l=function(){var n=this;this[0].style.cursor="auto"};this.pinSet.hover(c,l);r.click(p);r.dblclick(w)},i.prototype.rotateCW=function(n){this.rotateSet(n,90)},i.prototype.rotateCCW=function(n){this.rotateSet(n,-90)},i.prototype.mirrorHoriz=function(n){this.rotateSet(n,180)},i.prototype.mirrorVert=function(n){this.rotateSet(n,180)},i.prototype.buildHighlightBox=function(){var n=this.pinSet.getBBox();this.highlightBox=this.pinSet.paper.rect(n.x-1,n.y-1,n.width+2,n.height+2,1);this.highlightBox.attr("opacity","0");this.pinSet.push(this.highlightBox)},i.prototype.buildOverlay=function(){var n=this.pinSet.getBBox();this.overlay=this.pinSet.paper.rect(n.x-1,n.y-1,n.width+2,n.height+2,1);this.overlay.attr("opacity","0");this.overlay.attr("stroke-opacity","0");this.overlay.attr("fill","#ffff00");this.pinSet.push(this.overlay)},i.prototype.toFront=function(){this.pinSet.length==5?(this.pinSet[3].toFront(),this.pinSet[0].toFront(),this.pinSet[1].toFront(),this.pinSet[2].toFront(),this.pinSet[4].toFront()):(this.pinSet[2].toFront(),this.pinSet[0].toFront(),this.pinSet[1].toFront(),this.pinSet[3].toFront())},i.prototype.updateBaseSymbolBoundaries=function(){var t=n.CeUtility.getBBoxWithoutPinsText(this.se.svgShapeElementsSet);var r=t.x,u=t.y,f=t.width,e=t.height,i=$("#symbolEditorDialog"+n.SymbolEditor.GLOBAL_SYMBOL_EDITOR_INDEX);this.WB=r/this.scaleX-i.scrollLeft();this.EB=(r+f)/this.scaleX-i.scrollLeft();this.NB=u/this.scaleY-i.scrollTop();this.SB=(u+e)/this.scaleY-i.scrollTop()},i.prototype.initTT=function(){function f(){var f=t.getPinOrientation(),u=$("#seToolTipId"),h='<span id="textSpan" style="font-size: 12.5; font-weight: bold">'+t.metaData.Name+"<\/span>",e,o;u.html(h);u.fadeIn(100);e=$("#textSpan").width();o={width:e,position:"relative"};u.css(o);f==n.CE_PIN_ORIENTATION.NORTH?(i=0,r=-10/t.scaleY):f==n.CE_PIN_ORIENTATION.SOUTH?(i=0,r=10/t.scaleY):f==n.CE_PIN_ORIENTATION.EAST?(i=20/t.scaleX,r=-8):(i=5/t.scaleX,r=-8/t.scaleY);var s=t.pinSet[1].getBBox(),c=s.x/t.scaleX,l=t.scaleY,a=l/.47,v=250*a,y=-((v-s.y)/t.scaleY);u.css({left:c+i+"px",top:y+r+"px"})}function e(){$("#seToolTipId").hide()}var t=this,i=-1,r=-1,u;$("#symbolEditorDialog"+n.SymbolEditor.GLOBAL_SYMBOL_EDITOR_INDEX).append('<div id="seToolTipId"><\/div>');u=4;u=this.pinSet.length==5?4:3;n.Utility.hoverEventWithToFront(this.pinSet[u],function(){f()},function(){e()})},i.prototype.updatePinOrientation=function(t,i){var r=this.getPinOrientation();t<this.WB?r==n.CE_PIN_ORIENTATION.EAST?this.rotateSet(this.pinSet,180):r==n.CE_PIN_ORIENTATION.NORTH?this.rotateSet(this.pinSet,-90):r==n.CE_PIN_ORIENTATION.SOUTH&&this.rotateSet(this.pinSet,90):t>this.EB?r==n.CE_PIN_ORIENTATION.WEST?this.rotateSet(this.pinSet,180):r==n.CE_PIN_ORIENTATION.NORTH?this.rotateSet(this.pinSet,90):r==n.CE_PIN_ORIENTATION.SOUTH&&this.rotateSet(this.pinSet,-90):i<this.NB?r==n.CE_PIN_ORIENTATION.SOUTH?this.rotateSet(this.pinSet,180):r==n.CE_PIN_ORIENTATION.WEST?this.rotateSet(this.pinSet,90):r==n.CE_PIN_ORIENTATION.EAST&&this.rotateSet(this.pinSet,-90):i>this.SB&&(r==n.CE_PIN_ORIENTATION.NORTH?this.rotateSet(this.pinSet,180):r==n.CE_PIN_ORIENTATION.WEST?this.rotateSet(this.pinSet,-90):r==n.CE_PIN_ORIENTATION.EAST&&this.rotateSet(this.pinSet,90))},i.prototype.getPinOrientation=function(){for(var f,u,i,t,e=n.CE_PIN_ORIENTATION.WEST,o,s,h=n.SE_WHISKER_ORIENTATION.HORIZONTAL,r=0;r<this.pinSet.length;r++)if(this.pinSet[r][0])for(f=this.pinSet[r][0].classList,u=0;u<f.length;u++)f[u].indexOf("indicator")>-1&&(o=this.pinSet[r]),f[u].indexOf("whisker")>-1&&(s=this.pinSet[r]);return i=null,t=null,o&&(i=o.getBBox()),s&&(t=s.getBBox()),i&&t&&(h=Math.abs(t.y-t.y2)<5?n.SE_WHISKER_ORIENTATION.HORIZONTAL:n.SE_WHISKER_ORIENTATION.VERTICAL),h==n.SE_WHISKER_ORIENTATION.HORIZONTAL?e=i.x<t.x&&i.x<t.x2?n.CE_PIN_ORIENTATION.WEST:n.CE_PIN_ORIENTATION.EAST:(h=n.SE_WHISKER_ORIENTATION.VERTICAL)&&(e=i.y<t.y&&i.y<t.y2?n.CE_PIN_ORIENTATION.NORTH:n.CE_PIN_ORIENTATION.SOUTH),e},i.prototype.rotateSet=function(n,t){var i=this.getPinCenter(n),r="...R"+t+","+i.x+","+i.y;n.transform(r)},i.prototype.translateSet=function(n,t,i){var r="...T,"+t+","+i;n.transform(r)},i.prototype.getPinCenter=function(n){var t=n.getBBox(),i=Math.round(t.x+t.width/2),r=Math.round(t.y+t.height/2);return new BaseWire.Point(i,r)},i}(n.CeSymBase);n.CeSymPin=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(i){t.call(this);this._bb=null;this._val="";this._orientation=n.CE_TEXT_ORIENTATION.HORIZ_LR;this._visibility=!0;this._fontWeight="normal";this._fontSize="";this._fontFamily="";this._fontColor="";this._textBoxId="";this._textBoxOverlayId="";this._extendedTextBoxOverlayId="";this._index=-1;this._textWidth=-1;this._textHeight=-1;this._isDrag=!1;this.hAdj=4;this.tbLeftMargin=0;this.scaleX=i.scaleX;this.scaleY=i.scaleY;this.se=i;this.setTextMenu()}return __extends(i,t),i.prototype.initCeSymText=function(n){this.addTextRect(n);this.addDomTextBox();this.buildDomTextBoxOverlay();this.toFrontTextboxDom();this.defineEvents(n,this,this.get_textBoxId());$(this.get_textBoxId()).trigger("keyup")},i.prototype.addDomTextBox=function(){$("#symbolPaper").append('<input class="text_edit" id="text'+this.get_index()+'"><\/input>');$(this.get_textBoxId()).val(this.get_val());var t=n.CeUtility.getRoundedBBVals(this.get_textRect().getBBox()),i=this.LEFT_OFFSET+Math.round(t.x/this.scaleX)+this.tbLeftMargin,r=this.TOP_OFFSET+Math.round(t.y/this.scaleY),u=Math.round(t.width/this.scaleX),f=Math.round(t.height/this.scaleY),e=parseFloat(this.get_fontSize())/this.scaleY+"px";this.set_fontFamily("Arial");$(this.get_textBoxId()).css({position:"absolute",display:"none",top:r,left:i,width:u,height:f,margin:0,color:this.get_fontColor(),"font-size":e,"font-weight":this.get_fontWeight(),"font-family":this.get_fontFamily(),"background-color":"transparent","outline-style":"none",border:"none"});$(this.get_textBoxId()).show();n.CeDebug.isDebugText&&(console.log("In ceSymText addDomTextBox. BB via textRect. x = "+t.x+" y = "+t.y+" width = "+t.width+" height = "+t.height),console.log("In ceSymText addDomTextBox. BB via textRect & Scale. xLoc = "+i+" yLoc = "+r+" tWidth = "+u+" tHeight = "+f),console.log("In addDomTextBox. fontSize = "+parseFloat(this.get_fontSize())+" fontScaled = "+e+" scaleY = "+this.scaleY),console.log("New textbox. Scaled font-size = "+this.get_fontSize()+" font-weight = "+this.get_fontWeight()+" font-family = "+this.get_fontFamily()))},i.prototype.addTextRect=function(t){var i=n.CeUtility.getGridPointOffset(this.get_bb().x,this.get_bb().y,1),r=Math.round(this.get_bb().x+i.X),u=Math.round(this.get_bb().y+i.Y);this.set_textRect(t.symEditPaper.rect(r,u,this.get_bb().width,this.get_bb().height));this.get_textRect().attr("stroke-width",0).attr("stroke","blue").attr("fill","none");this.get_textRect().node.setAttribute("class","text_rect");n.CeDebug.isDebugText&&(console.log("In ceSymText BB (addTextRect, unscaled). x = "+this.get_bb().x+" y = "+this.get_bb().y+" height = "+this.get_bb().height),console.log("In ceSymText attributes (addTextRect, unscaled). x = "+this.get_textRect().attr("x")+" y = "+this.get_textRect().attr("y")+" dy = "+$("tspan",this.get_textRect().node).attr("dy")))},i.prototype.addRaphaelText=function(t){n.CeDebug.isDebugText&&console.log("In ceSymText BB, addRaphaelText (no pre-reset dy). x = "+this.get_bb().x+" y = "+this.get_bb().y+" height = "+this.get_bb().height);var r=this,u=n.CeUtility.getRoundedBBVals(r.get_textRect().getBBox()),i=t.text(u.x,u.y+this.getYposAdjustedForFontSize(),r.get_val());i.node.setAttribute("class","svw_sym_text");$("tspan",i.node).attr("dy")&&$("tspan",i.node).attr("dy",0);i.attr({"font-size":this.get_fontSize(),fill:r.get_fontColor(),"font-weight":r.get_fontWeight(),"font-family":r.get_fontFamily(),"text-anchor":"start"});n.CeDebug.isDebugText&&(console.log("In ceSymText attrs, addRaphaelText (no pre-reset dy). x = "+i.attr("x")+" y = "+i.attr("y")+" dy = "+$("tspan",i.node).attr("dy")),console.log("Write to Raphael. Standard (non-scaled) font-size = "+i.attr("font-size")+" font-weight = "+i.attr("font-weight")+" font-color = "+i.attr("fill")+" font-family = "+i.attr("font-family")+" text-anchor = "+i.attr("text-anchor")))},i.prototype.getYposAdjustedForFontSize=function(){var n=parseFloat(this.get_fontSize());return n>7?n+1:n>6?n:n>4?n+1:n},i.prototype.removeEditableText=function(){$(this.get_textBoxId()).remove();$(this.get_textBoxOverlayId()).remove()},i.prototype.defineEvents=function(t,i){function f(n,t){var u=document.createElement("canvas"),i=u.getContext("2d"),r;return i.font=t,r=i.measureText(n),r.width}var u=this,r=this;$(this.get_textBoxId()).click(function(){});$(this.get_textBoxOverlayId()).click(function(){});$(this.get_textBoxOverlayId()).mousedown(function(n){n.which==3&&($(document).bind("contextmenu",function(){return!1}),u.setTextMenu())});$(this.get_textBoxId()).keyup(function(){var t,i,e;r.set_val($(u.get_textBoxId()).val());t=r.get_fontSize();i=r.get_fontWeight()+" "+t+" "+r.get_fontFamily();r.set_textWidth(Math.round(f(r.get_val(),i)));r.set_textHeight(parseFloat(r.get_fontSize()));n.CeDebug.isDebugText&&console.log("Text Fonts 4 width meas. Scaled fontAdjust = "+t+" font-weight = "+r.get_fontWeight()+" font-family = "+r.get_fontFamily());e=5;$(r.get_textBoxId()).css({width:Math.round(r.get_textWidth()/r.scaleX)+e,height:Math.round(r.get_textHeight()/r.scaleY)+r.hAdj});r.updateRectangles()});$(this.get_textBoxOverlayId()).hover(function(){t.ceSelectionManager.clearHover();t.ceSelectionManager.hoverObject(i)},function(){t.ceSelectionManager.clearHover()});$(this.get_textBoxId()).hover(function(){t.ceSelectionManager.hoverObject(i)},function(){});$(this.get_textBoxOverlayId()).draggable({start:function(n){u.textDragStartHandler(n)}})},i.prototype.textDragStartHandler=function(t){var i=this,u=-1,f=-1,r=$(this.get_textBoxOverlayId()),e=$("#symbolPaper"),o=10;i.toFrontOverlayDom();i.set_isDrag(!0);u=parseInt(n.SymbolEditor.getSymbolEditorDomNode().parent().css("left"));f=parseInt(n.SymbolEditor.getSymbolEditorDomNode().parent().css("top"));var s=t.pageX-u-parseInt(r.css("left")),h=t.pageY-f-parseInt(r.css("top")),a=t.pageX,v=t.pageY,c=-1,l=-1;r.css({cursor:"move",position:"absolute",opacity:.4,left:t.pageX-u,top:t.pageY-f-35});e.on("mousemove.textOL",function(n){r.css({left:n.pageX-u-s,top:n.pageY-f-h});$(i.get_textBoxId()).css({left:n.pageX-u+o-s,top:n.pageY-f+o-h});r.css({border:"2px dashed blue",opacity:.4,cursor:"move"})});e.on("mouseup.textOL",function(n){e.unbind("mousemove.textOL");e.unbind("mouseup.textOL");i.toFrontTextboxDom();i.set_isDrag(!1);c=(n.pageX-a)*i.scaleX;l=(n.pageY-v)*i.scaleY;i.get_textRect().attr({transform:"...T"+c+","+l});r.css({border:"none",cursor:"auto"})})},i.prototype.rotateCW=function(n){n.rotate(90);$(this.get_textBoxId()).css({"-webkit-transform":"rotate(90deg)"})},i.prototype.rotateCCW=function(n){n.rotate(-90);$(this.get_textBoxId()).css({"-webkit-transform":"rotate(-90deg)"})},i.prototype.mirrorHoriz=function(n){n.rotate(180)},i.prototype.mirrorVert=function(n){n.rotate(180)},i.prototype.biggerText=function(){},i.prototype.smallerText=function(){},i.prototype.select=function(){},i.prototype.updateRectangles=function(){var n=10,u=$(this.get_textBoxOverlayId()),t=$(this.get_textBoxId()),f=parseFloat(t.css("left")),e=parseFloat(t.css("top")),i=parseFloat(t.css("width")),r=parseFloat(t.css("height"));u.css({position:"absolute",top:e-n+"px",left:f-n+"px",width:i+n+"px",height:r+2*n+"px"});this.get_textRect().attr("width",i*this.scaleX).attr("height",r*this.scaleY)},i.prototype.buildDomTextBoxOverlay=function(){var n;this.set_textBoxOverlayId("#textOverlay"+this.get_index());n=10;$("#symbolPaper").append('<div class="text_overlay" id="textOverlay'+this.get_index()+'"><\/div>');var t=$(this.get_textBoxId()),i=parseFloat(t.css("left")),r=parseFloat(t.css("top")),u=parseFloat(t.css("width")),f=parseFloat(t.css("height"));$(this.get_textBoxOverlayId()).css({position:"absolute",display:"none",top:r-n+"px",left:i-n+"px",width:u+n+"px",height:f+2*n+"px",margin:0,"background-color":"transparent","outline-style":"none",border:"none"});$(this.get_textBoxOverlayId()).show()},i.prototype.hoverIn=function(){var n=$(this.get_textBoxOverlayId());n.css({border:"2px dashed blue",opacity:.4,cursor:"move"})},i.prototype.hoverOut=function(){var n=$(this.get_textBoxOverlayId());n.css({border:"none",cursor:"auto"})},i.prototype.toFrontTextboxDom=function(){var i=n.SymbolEditor.getSymbolEditorDomNode().parent().css("z-index"),t=parseInt(i)+1e3,r=t+1e3;$(this.get_textBoxOverlayId()).css("z-index",t);$(this.get_textBoxId()).css("z-index",r)},i.prototype.toFrontOverlayDom=function(){var i=n.SymbolEditor.getSymbolEditorDomNode().parent().css("z-index"),t=parseInt(i)+1e3,r=t+1e3;$(this.get_textBoxId()).css("z-index",t);$(this.get_textBoxOverlayId()).css("z-index",r)},i.prototype.get_bb=function(){return this._bb},i.prototype.set_bb=function(n){this._bb=n},i.prototype.get_val=function(){return this._val},i.prototype.set_val=function(n){this._val=n},i.prototype.get_orientation=function(){return this._orientation},i.prototype.set_orientation=function(n){this._orientation=n},i.prototype.get_visibility=function(){return this._visibility},i.prototype.set_visibility=function(n){this._visibility=n},i.prototype.get_fontSize=function(){return this._fontSize},i.prototype.set_fontSize=function(t){this._fontSize=n.CeUtility.endsWith(t,"px")?t:t+"px"},i.prototype.get_fontWeight=function(){return this._fontWeight},i.prototype.set_fontWeight=function(n){this._fontWeight=n},i.prototype.get_fontFamily=function(){return this._fontFamily},i.prototype.set_fontFamily=function(n){this._fontFamily=n},i.prototype.get_fontColor=function(){return this._fontColor},i.prototype.set_fontColor=function(n){this._fontColor=n},i.prototype.get_textBoxId=function(){return this._textBoxId},i.prototype.set_textBoxId=function(n){this._textBoxId=n},i.prototype.get_textBoxOverlayId=function(){return this._textBoxOverlayId},i.prototype.set_textBoxOverlayId=function(n){this._textBoxOverlayId=n},i.prototype.get_index=function(){return this._index},i.prototype.set_index=function(n){this._index=n},i.prototype.get_textRect=function(){return this._textRect},i.prototype.set_textRect=function(n){this._textRect=n},i.prototype.get_textWidth=function(){return this._textWidth},i.prototype.set_textWidth=function(n){this._textWidth=n},i.prototype.get_textHeight=function(){return this._textHeight},i.prototype.set_textHeight=function(n){this._textHeight=n},i.prototype.get_isDrag=function(){return this._isDrag},i.prototype.set_isDrag=function(n){this._isDrag=n},i.prototype.createTextMenu=function(){var r=this,t=this,u=function(){r.removeEditableText(null)},i,n;t.textMenu||(i="<b>Text Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,i),n.addMenuElement("Delete",u),n.addSeparatorToMenu(),t.textMenu=SVWebContextMenu.MenuHelper.createMenu(n))},i.prototype.setTextMenu=function(){this.createTextMenu();this.textMenu.bindMenuTo(this.get_textBoxOverlayId())},i}(n.CeSymBase);n.CeSymText=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i){t.call(this);this.shapeSet=null;this.shapeSet.push(i);this.scaleX=n.scaleX;this.scaleY=n.scaleY;this.se=n;this.buildHighlightBox();this.buildOverlay();this.toFront();this.defineEvents(n,this,this.shapeSet)}return __extends(i,t),i.prototype.defineEvents=function(t,i,r){function o(){console.log("clicked on shape");t.ceSelectionManager.clearSelection();t.ceSelectionManager.selectObject(i)}function s(){alert("Dbl-clicked on shape")}var h=this,u=null,f=null,e=n.CeUtility.getRoundedBBVals(r.getBBox()),c=e.x,l=e.y,p=function(){console.log("hovered on shape");this[0].style.cursor="move";t.ceSelectionManager.clearHover();t.ceSelectionManager.hoverObject(i)},w=function(){console.log("unhovered on shape");this[0].style.cursor="auto"};r.click(o);r.dblclick(s)},i.prototype.select=function(){this.showHighlightBox(n.HIGHLIGHT_STATE.SELECTED)},i.prototype.buildHighlightBox=function(){var n=this.shapeSet.getBBox();this.highlightBox=this.shapeSet.paper.rect(n.x-1,n.y-1,n.width+2,n.height+2,1);this.highlightBox.attr("opacity","0");this.shapeSet.push(this.highlightBox)},i.prototype.buildOverlay=function(){var n=this.shapeSet.getBBox();this.overlay=this.shapeSet.paper.rect(n.x-1,n.y-1,n.width+2,n.height+2,1);this.overlay.attr("opacity","0");this.overlay.attr("stroke-opacity","0");this.overlay.attr("fill","#ffff00");this.shapeSet.push(this.overlay)},i.prototype.hoverIn=function(){this.shapeSet.attr("fill","blue")},i.prototype.hoverOut=function(){this.shapeSet.attr("fill","red")},i.prototype.toFront=function(){this.shapeSet[0].toFront();this.shapeSet[1].toFront();this.shapeSet[2].toFront()},i.prototype.rotateShape=function(n,t){var i=this.getShapeCenter(n),r="...R"+t+","+i.x+","+i.y;n.transform(r)},i.prototype.translateShape=function(n,t,i){var r="...T,"+t+","+i;n.transform(r)},i.prototype.getShapeCenter=function(n){var t=n.getBBox(),i=Math.round(t.x+t.width/2),r=Math.round(t.y+t.height/2);return new BaseWire.Point(i,r)},i}(n.CeSymBase);n.CeSymShape=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t=function(t){function i(n,i,r){t.call(this);this.shapesSet=null;this.metaData=null;this.origX=-1;this.origY=-1;this.scaleX=n.scaleX;this.scaleY=n.scaleY;this.shapesSet=i;this.metaData=r;this.buildHighlightBox();this.buildOverlay();this.defineEvents(n,this,i,r)}return __extends(i,t),i.prototype.defineEvents=function(t,i,r){var u=null,f=null,h=$("#symbolEditorDialog"+n.SymbolEditor.GLOBAL_SYMBOL_EDITOR_INDEX).data("kendoWindow"),e,o,s,c=function(){this[0].style.cursor="move"},l=function(){var n=this;this[0].style.cursor="auto"};this.shapesSet.hover(c,l)},i.prototype.buildHighlightBox=function(){var n=this.shapesSet.getBBox();this.highlightBox=this.shapesSet.paper.rect(n.x-1,n.y-1,n.width+2,n.height+2,1);this.highlightBox.attr("opacity","0");this.shapesSet.push(this.highlightBox)},i.prototype.buildOverlay=function(){var n=this.shapesSet.getBBox();this.overlay=this.shapesSet.paper.rect(n.x-1,n.y-1,n.width+2,n.height+2,1);this.overlay.attr("opacity","0");this.overlay.attr("stroke-opacity","0");this.overlay.attr("fill","#ffff00");this.shapesSet.push(this.overlay)},i.prototype.rotateSet=function(n,t){var i=this.getShapesCenter(n),r="...R"+t+","+i.x+","+i.y;n.transform(r)},i.prototype.translateSet=function(n,t,i){var r="...T,"+t+","+i;n.transform(r)},i.prototype.getShapesCenter=function(n){var t=n.getBBox(),i=Math.round(t.x+t.width/2),r=Math.round(t.y+t.height/2);return new BaseWire.Point(i,r)},i}(n.CeSymBase);n.CeSymBaseShapes=t}(Project||(Project={})),function(n){var t=function(){function t(n,t){this.extImage=null;this.messageList=[];this.importInstructionsString="To import an image:<br/>1) Create/save image on your computer.<br/>2) Click on the Choose File button.<br/>3) Browse to the saved image, click Open.<br/>4) Click OK.<br/>The image must be of type <b>jpg<\/b>, <b>gif<\/b>, or <b>png<\/b>.<br/>The image must be <b>< 500 KB.<\/b>";this.symEditPaper=t;this.surface=n;this.ceSelectionManager=this.surface.getDesign().getCeSelectionManager()}return t.prototype.getMessageList=function(){return this.messageList},t.prototype.showImportImageDialog=function(){var n=$("#importImageDialog"),i;n.kendoWindow({actions:[],draggable:!0,modal:!0,pinned:!1,resizable:!1,title:"Add Image to Symbol",height:"auto",width:"300px",activate:function(){$("#urlInput").select()}}).data("kendoWindow").open().center();i=n.data("kendoWindow");i.bind("close",function(){$(t.IMPORT_IMAGE_OK_BUTTON).off("click");$(t.IMPORT_IMAGE_CANCEL_BUTTON).off("click")});this.promiseImportImage=this.initializeImportDialog()},t.prototype.initializeImportDialog=function(){var i=this,e=$.Deferred(),s=$(t.IMPORT_IMAGE_OK_BUTTON),h=$(t.IMPORT_IMAGE_CANCEL_BUTTON),c=!1,o=!1,r=$("#importImageDialog"),u,l,f,a;r.css({display:"block","z-index":n.ModelEditor.ME_Z_INDEX+200});a=$("#imgFileLocalForm")[0];a.reset();r.on("keydown.symbolEditor",function(t){t.which==n.Design.EnterKey?s.trigger("click"):t.which==n.Design.EscKey&&h.trigger("click")});$("#imageImportInstructionsKeyword").click(function(){i.showInfoMessage(i.importInstructionsString,!1)});s.on("click",function(){var s,t,h;for(u=document.getElementById("imgFileLocal"),o=u&&u.files&&u.files[0]?!0:!1,s=n.CeUtility.getPaperElements(i.symEditPaper),t=0;t<s.length;t++)if(s[t].type=="image"){c=!0;break}if(c)i.confirmDialog2Btn=new n.MultiBtnModalDialog("Confirm Image Replacement","The symbol already has an image. OK to replace it? <br />",["Yes","No"]),$.when(i.confirmDialog2Btn.queryUser()).done(function(t){if(t==n.BUTTON.BTN1)n.CeUtility.removeElementsByClassTag(i.symEditPaper,"svw_sym_img"),e.resolve();else{var u=r.data("kendoWindow");u.close()}});else e.resolve();$.when(i.promiseImportImage).done(function(){o&&(l=u.files[0],f=new FileReader,f.onload=function(){i.addImg2Svg(f.result)},f.readAsDataURL(l))});h=r.data("kendoWindow");h.close()});h.on("click",function(){var n=r.data("kendoWindow");n.close()});return e.promise()},t.prototype.addImg2Svg=function(t){var i=t.split("data:"),u,o,f,e,r;if(i[1]&&i[1].indexOf("image/png")==-1&&i[1].indexOf("image/gif")==-1&&i[1].indexOf("image/jpeg")==-1){n.MessageManager.showErrorMessage("The file type you are importing is not supported. It must be gif, jpg, or png.",!0);return}if(i[1]){if(u=encodeURIComponent(t).match(/%[89ABab]/g),o=t.length+(u?u.length:0),o>7e5){n.MessageManager.showErrorMessage("The image you are importing is too large. It must be < 500 KB.",!0);return}f=0;e=0;this.ceSelectionManager.clearSelection();r=n.CeUtility.getPaperBBoxWithoutPinsText(this.symEditPaper);this.extImage=this.symEditPaper.image(t,r.x+f,r.y+f,r.width-e,r.height-e);this.extImage.node.setAttribute("class","svw_sym svw_sym_img");this.setStackingOrder()}},t.prototype.setStackingOrder=function(){for(var i,t,u=n.CeUtility.getPaperElements(this.symEditPaper),r=0;r<u.length;++r)if(u[r][0])for(i=u[r][0].classList,t=0;t<i.length;t++)if(i[t].indexOf("arrow")>-1||i[t].indexOf("whisker")>-1||i[t].indexOf("indicator")>-1||i[t].indexOf("svw_sym_text")>-1){u[r].toFront();break}},t.prototype.showInfoMessage=function(n,t,i){t===void 0&&(t=!0);i===void 0&&(i=5e3);var r=$("#notification").kendoNotification({stacking:"down",show:this.onShow,button:!0,autoHideAfter:t?i:0}).data("kendoNotification");r.show(n,"info");this.addToList(r)},t.prototype.removeAllMessages=function(){this.messageList.forEach(function(n){n.hide()});this.messageList=[]},t.prototype.addToList=function(n){n&&this.messageList.push(n)},t.prototype.onShow=function(t){var i,o,r,s;if(!$("."+t.sender._guid)[1]){var u=t.element.parent(),h=u.width(),l=u.height(),c=$(window).width(),a=$(window).height(),f,e;e=Math.floor(c/2-h/2);i=$("#importImageDialog").parent();o=i.offset();f=o.top-i.height()-50;t.element.parent().css({top:f,left:e});r=5e4;s=n.KendoHelper.getKendoWindowMaxZIndex();r=s+1e3;t.element.parent().css({zIndex:r})}},t.IMPORT_IMAGE_OK_BUTTON="#import_image_ok_button",t.IMPORT_IMAGE_CANCEL_BUTTON="#import_image_cancel_button",t}();n.CeSymImage=t}(Project||(Project={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var s,h,c,l,a,v,y,p,w,t,e,o,i,r,u,f;(function(n){n[n.NONE=0]="NONE";n[n.NORMAL=1]="NORMAL";n[n.UNIFORM=2]="UNIFORM"})(n.CE_DIST_TYPE||(n.CE_DIST_TYPE={}));s=n.CE_DIST_TYPE,function(n){n[n.NONE=0]="NONE";n[n.VALUE=1]="VALUE";n[n.ALL=2]="ALL"}(n.CE_PROP_VISIBILITY||(n.CE_PROP_VISIBILITY={}));h=n.CE_PROP_VISIBILITY,function(n){n[n.VHDL=0]="VHDL";n[n.SPICE=1]="SPICE";n[n.SCHEMATIC=2]="SCHEMATIC";n[n.NONE=3]="NONE"}(n.CE_MODEL_TYPE||(n.CE_MODEL_TYPE={}));c=n.CE_MODEL_TYPE,function(n){n[n.EDIT=0]="EDIT";n[n.COMPILE=1]="COMPILE";n[n.DONE=2]="DONE"}(n.CE_STATUS||(n.CE_STATUS={}));l=n.CE_STATUS,function(n){n[n.PUBLIC=0]="PUBLIC";n[n.PRIVATE=1]="PRIVATE";n[n.GROUP=2]="GROUP"}(n.CE_VISIBILITY||(n.CE_VISIBILITY={}));a=n.CE_VISIBILITY,function(n){n[n.SIGNAL=0]="SIGNAL";n[n.QUANTITY=1]="QUANTITY";n[n.TERMINAL=2]="TERMINAL"}(n.CE_PIN_TYPE||(n.CE_PIN_TYPE={}));v=n.CE_PIN_TYPE,function(n){n[n.IN=0]="IN";n[n.OUT=1]="OUT";n[n.INOUT=2]="INOUT";n[n.NONE=3]="NONE"}(n.CE_PIN_MODE||(n.CE_PIN_MODE={}));y=n.CE_PIN_MODE,function(n){n[n.NORTH=0]="NORTH";n[n.SOUTH=1]="SOUTH";n[n.EAST=2]="EAST";n[n.WEST=3]="WEST"}(n.CE_PIN_ORIENTATION||(n.CE_PIN_ORIENTATION={}));p=n.CE_PIN_ORIENTATION,function(n){n[n.HORIZ_LR=0]="HORIZ_LR";n[n.HORIZ_RL=1]="HORIZ_RL";n[n.VERT_TB=2]="VERT_TB";n[n.VERT_BT=3]="VERT_BT"}(n.CE_TEXT_ORIENTATION||(n.CE_TEXT_ORIENTATION={}));w=n.CE_TEXT_ORIENTATION;t=function(){function n(){}return n}();n.CeComponentBase=t;e=function(n){function t(){n.call(this)}return __extends(t,n),t}(t);n.CeComponent=e;o=function(n){function t(t){var c,l,s,a,o,v,h,e,y;for(n.call(this),this.Title=t.Title,this.Name=t.Name,this.PartNumber=t.PartNumber,this.Comments=t.Comments,this.Tags=t.Tags,this.Url=t.Url,this.Visibility=t.Visibility,this.DateModified=t.DateModified,this.CreationDate=t.CreationDate,this.Description=t.Description,this.DescriptionToolTip=t.DescriptionToolTip,this.Prefix=t.Prefix,this.Src=t.Src,this.Lib=t.Lib,this.ShowComponent=t.ShowComponent,this.BaseName=t.BaseName,this.Author=t.Author,this.Status=t.Status,this.ComponentId=t.ComponentId,this.Cx=t.Cx,this.Cy=t.Cy,this.ModelType=t.ModelType,this.Img=t.Img,this.Properties=[],this.Architectures=[],this.Categories=[],this.Pins=[],this.Revisions=[],c=t.Architectures,e=0;e<c.length;e++)l=new i(c[e].Name),this.Architectures.push(l);for(this.Categories=t.Categories,s=t.Properties,e=0;e<s.length;e++)a=new r(s[e].Name,s[e].Type,s[e].Typical,s[e].Minimum,s[e].Maximum,s[e].DistType,s[e].Description,s[e].Units,s[e].PropVisibility),this.Properties.push(a);for(o=t.Pins,e=0;e<o.length;e++)v=new u(o[e].Name,o[e].Type,o[e].SubType,o[e].Mode,o[e].Index,o[e].Description,o[e].InitialValue,o[e].X,o[e].Y,o[e].Orientation),this.Pins.push(v);if(t.Revisions)for(h=t.Revisions,e=0;e<h.length;e++)y=new f(h[e].ComponentId,h[e].Description,h[e].Critical,h[e].Date),this.Revisions.push(y)}return __extends(t,n),t}(t);n.CeComponentClone=o;i=function(){function n(n){this.Name=n}return n}();n.CeArchitecture=i;r=function(){function n(n,t,i,r,u,f,e,o,s){this.Name=n;this.Type=t;this.Typical=i;this.Minimum=r;this.Maximum=u;this.DistType=f;this.Description=e;this.Units=o;this.PropVisibility=s}return n}();n.CeProperty=r;u=function(){function n(n,t,i,r,u,f,e,o,s,h){this.Name=n;this.Type=t;this.SubType=i;this.Mode=r;this.Index=u;this.Description=f;this.InitialValue=e;this.X=o;this.Y=s;this.Orientation=h}return n}();n.CePin=u;f=function(){function n(n,t,i,r){this.ComponentId=n;this.Description=t;this.Critical=i;this.Date=r}return n}();n.CeRevision=f}(Project||(Project={})),function(n){var t=function(){function t(){this.msgTipsGen=[];this.msgTipsME=[];this.msgTipsSE=[];this.msgBugs=[]}return t.prototype.showCeHelpDialog=function(i,r){var s=i?i:50,h=r?r:50,c=t.CE_HELP_MINWIDTH,l=t.CE_HELP_MINHEIGHT,e=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.HELP,n.MODELING_APP_DIM.WIDTH),o=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.HELP,n.MODELING_APP_DIM.HEIGHT),u=$("#ceHelpDialog"),f=u.data("kendoWindow");f?(i||r||f.center(),f.open(),u.parent().css({width:e+"px",height:o+"px"}),u.scrollTop(0)):(u.kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,position:{top:s,left:h},resizable:!0,title:"Help",height:o,width:e,minWidth:c,minHeight:l}),f=u.data("kendoWindow"),i||r||f.center(),f.open(),$("#ceHelpDialogScrollable").css({width:t.CE_HELP_WIDTH-50+"px"}),$("#ceHelpDialogScrollable2").css({width:t.CE_HELP_WIDTH-50+"px"}),u.parent().css({width:e+"px",height:o+"px"}),u.scrollTop(0),this.setHelpMenu())},t.prototype.getCEHelp=function(){var r=this,f=$("#ceHelpDialogNavigation"),t=$("#ceHelpDialogContents"),o=$("#ceHelpDialogTitle"),u,e,i,s;for(t.html(""),o.html("<h3>Component Editor - Tips & Notes<br/>Version "+n.CeUtility.CE_VERSION+"<\/h3><br/>"),u=[],u.push("General"),u.push("Model Editor"),u.push("Symbol Editor"),u.push("About"),f.removeClass("row col-md-3"),f.addClass("row col-md-2"),t.removeClass("row col-md-8"),t.css("padding-left","0px"),f.css({width:"160px",float:"none"}),this.loadMsgStrings(),e="",e="<h4>General Tips<\/h4><ul><li>",i=0;i<r.msgTipsGen.length;i++)e+=r.msgTipsGen[i];for(t.html(e),t.scrollTop(0),o.html("Component Editor Help. Select topic from menu:<br/><br/>"),f.html(""),i=0;i<u.length;i++)s='<div id="newDiv'+i+'" class="helpNewDiv"><span id='+u[i]+' class="helpLink btn-link">'+u[i]+"<\/span><\/div>",f.append(s);$(".helpLink").click(function(i,u){var e;t.scrollTop(0);var f="",o=100,s=u?u:this.parentElement.id;switch(s){case"newDiv0":if(f="<h4>General Tips<\/h4><ul><li>",f.length<o)for(e=0;e<r.msgTipsGen.length;e++)f+=r.msgTipsGen[e];t.html(f);break;case"newDiv1":if(f="<h4>Model Editor Tips<\/h4><ul><li>",f.length<o)for(e=0;e<r.msgTipsME.length;e++)f+=r.msgTipsME[e];t.html(f);break;case"newDiv2":if(f="<h4>Symbol Editor Tips<\/h4><ul><li>",f.length<o)for(e=0;e<r.msgTipsSE.length;e++)f+=r.msgTipsSE[e];t.html(f);break;case"quickSch2VhdTip":t.load("/Content/html/QuickSch2VhdTip.htm");break;case"newDiv3":f="<h4>About Component Editor<\/h4><ul><li>";f+="Version "+n.CeUtility.CE_VERSION;t.html(f)}})},t.prototype.closeHelpDialog=function(){var n=$("#ceHelpDialog").data("kendoWindow");n&&n.close()},t.prototype.loadMsgStrings=function(){this.msgTipsGen.push('The Component Editor can be launched in three ways:<br/>1) Right-click  on the desired component in the Component Browser and select "View/Copy Model"; <br/>2) Right-click on an existing component that has been placed on the schematic canvas and select "View/Copy Model"; <br/>3) Select <span style="color: DarkRed;"> Create New Component > From VHDL-AMS/SPICE <\/span> from the Component Browser.<br/><br/> ');this.msgTipsGen.push("The Component Editor consists of two windows, one for model editing and one for symbol editing. The model editing window is the default window that comes up when you launch the Component Editor. The symbol editing window can optionally be invoked after saving a model.<br/><br/> ");this.msgTipsGen.push('If you invoke the Component Editor from an existing model that you did not create (i.e. that you do not own), start by clicking on the "Save new model" button to create your own copy of the model.<br/><br/> ');this.msgTipsGen.push("When selecting a name for your model you are encouraged to 1) keep the name short, and 2) use spaces in the name. This helps the name display well in the Component Browser. Note that for VHDL-AMS models, the spaces will be automatically replaced by underscores in the model source to conform to VHDL-AMS language conventions.<br/><br/> ");this.msgTipsGen.push("When you first save a new model that is based on an existing model, a choice of model symbols will be offered. You must select a symbol, after which, your copy of the model and symbol will be created and saved. On subsequent saves you will be given the option to edit the symbol.<br/><br/>");this.msgTipsGen.push("After updating a component, you will need to refresh the browser so the components on the schematic will reflect the latest updates. In some cases it may be best to delete and replace the relevant instances on the schematic.<br/><br/>");this.msgTipsGen.push("Be sure to save before exiting the Component Editor (you will not be warned). This check will be added shortly.<br/><br/>");this.msgTipsGen.push('When you invoke the Component Editor on a model that you do not own, you can edit that model.  However, you cannot update/save that model. You must first click the "Save new model" button to create your own copy of the model and save any edits you have made. You will be prompted to enter a name for your copy.<br/><br/>');this.msgTipsGen.push("If mirroring symbol on schematic causes pin whisker to end up in wrong location, use Rotate instead of Mirror-X/Y. You can re-drop the component on the schematic to start over.<br/><br/>");this.msgTipsGen.push("You can type/paste any model listing into the editor. However, the entity name in the model must match the actual name of the model (listed at the top of model listing below the Title as a comment). This will be automatically corrected if necessary on save.<br/><br/>");this.msgTipsGen.push('The term "model" is often used when referring to a VHDL-AMS/SPICE source description; the term "component" is often used when referring to both model and symbol as a single unit.<br/><br/> ');this.msgTipsME.push('Please follow the general format for comments shown in our factory "starter" models so your model will support standard SystemVision.com features like showing tooltips and descriptions in the Component Browser.<br/><br/> ');this.msgTipsME.push('The model editor supports several key commands or "hot-keys". The most commonly used are:<br/> <b>save<\/b>: Ctrl-S (PC), Cmd-S (Mac)<br/> <b>undo<\/b>: Ctrl-Z (PC), Cmd-Z (Mac)<br/> <b>redo<\/b>: Ctrl-Y (PC), Cmd-Y (Mac) <br/> <b>find<\/b>: Ctrl-F (PC), Cmd-F (Mac) <br/> <b>findNext<\/b>: Ctrl-G (PC), Cmd-G (Mac)<br/> <b>findPrev<\/b>: Shift-Ctrl-F (PC), Cmd-Alt-F (Mac)<br/>  <b>replace<\/b>: Shift-Ctrl-F (PC), Cmd-Alt-F (Mac)<br/> <b>replaceAll<\/b>: Shift-Ctrl-R (PC), Shift-Cmd-Alt-F (Mac)<br/><br/> ');this.msgTipsME.push("After performing a search, you can clear the highlights by again clicking Ctrl-F (then Esc if you do not want another search).<br/><br/> ");this.msgTipsSE.push("The function of the Symbol Editor is to allow you to reposition pins/text on your symbols. You cannot redraw or otherwise manipulate symbol graphics at this time.<br/><br/> ");this.msgTipsSE.push("You can bring up the Symbol Editor at any time by clicking on the symbol's preview image. You can bring up the preview image at any time by clicking on the Save button. Note that the Save button is only active if your are the owner of the component you are viewing.<br/><br/> ");this.msgTipsSE.push('The Symbol Editor is automatically closed on Save. You can manually close it with the close "x" button, or by right-clicking on the canvas and selecting Close Symbol Editor.<br/><br/> ');this.msgTipsSE.push('New text can be added by clicking on the "T" icon in the Symbol Editor toolbar.<br/><br/> ');this.msgTipsSE.push('When you mouse on or near text the cursor will indicate the mode you are in. If the cursor is an I-beam, you are in text-edit mode; if the cursor is a Move indicator, you are in text-drag mode. The "drag boundary" is  indicated by a dashed box in which you can click and drag to reposition the text.<br/><br/> ');this.msgTipsSE.push("Text can be removed as follows: 1) hover on its dashed box container (cursor changes to Move indicator), 2) right-click and 3) select Delete.<br/><br/> ");this.msgTipsSE.push("To use the mirror/rotate buttons in the Symbol Editor, first click on a pin to select it.<br/>You can only rotate symbol pins at this time.<br/><br/> ");this.msgTipsSE.push("To deselect a pin in the Symbol Editor, double-click on the canvas.<br/><br/> ");this.msgTipsSE.push("<b><u>Image Import Notes:<\/u><\/b><br/><br/> ");this.msgTipsSE.push('You can import an image from your local file system onto a symbol. This image will fill the "footprint" of the symbol space, but not cover pins or text. <br/><br/>The following image types can be imported: <b>png<\/b>, <b>jpg<\/b>, and <b>gif<\/b>. <br/><br/>The imported image size must be less than 500 KB. <br/><br/>Images can be imported as follows:<br/> <b>Open import dialog<\/b>: Click on the "Add Image to Symbol" button in the Symbol Editor, and click on the Choose File button in the resulting dialog.<br /> <b>Locate image<\/b>: Browse for an image. Select it and press the OK button in the file browser. The name of the image will appear next to the Choose File button.<br/> <b>Import image<\/b>: Click OK in the dialog.<br/><br/>Images cannot be directly deleted in the editor. However, you can do so from the "Add Image to Symbol" dialog by clicking OK without choosing a local image. Reply Yes when asked to replace the existing image.<br/><br/><br/> ')},t.prototype.createHelpMenu=function(){var t=this,r=function(){t.closeHelpDialog()},i,n;t.helpMenu||(i="<b>Help Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,i),n.addMenuElement("Close Help Dialog",r),n.addSeparatorToMenu(),t.helpMenu=SVWebContextMenu.MenuHelper.createMenu(n))},t.prototype.setHelpMenu=function(){this.createHelpMenu();this.helpMenu.bindMenuTo($("#ceHelpDialog"))},t.CE_HELP_WIDTH=750,t.CE_HELP_HEIGHT=510,t.CE_HELP_MINWIDTH=200,t.CE_HELP_MINHEIGHT=400,t.CE_HELP_MAXWIDTH=1500,t.CE_HELP_MAXHEIGHT=1500,t}();n.CeHelp=t}(Project||(Project={})),function(n){var t=function(){function t(t,i,r,u){this.designID="";this.revisionID="";this.isSpinnerActive=!1;this.surface=t;this.isUnitTest=u;$.ajaxSetup({headers:{TOKEN_HEADER:n.Settings.APIKEY,token:"5",userID:n.Settings.UUID}})}return t.prototype.generateVhdlFromSchematic=function(){var t=this,n=$.Deferred();return this.showSpinner(),$.when(this.saveTempDesignState()).done(function(i){i?$.when(t.generateStructuralVhdl()).done(function(i){i?$.when(t.deleteTempDesignState()).done(function(i){i?n.resolve(!0):n.resolve(!1);t.hideSpinner()}):n.resolve(!1)}):n.resolve(!1)}),n.promise()},t.prototype.saveTempDesignState=function(){var r=this,t=$.Deferred(),u=this.surface.getDesign(),i=u.getSaveData(),f=this.checkDesign(i),e;return f?(i.UserID=n.Utility.getUserID(),e=$.ajax({url:n.Settings.APIURI()+"/Designs",type:"POST",data:JSON.stringify(i),contentType:"application/json;charset=utf-8",success:function(n){r.designID=n.DesignID;r.revisionID=n.RevisionID;t.resolve(!0)},error:function(n,i){t.resolve(!1);alert("Error saving temp design: "+i)}}),t.promise()):(this.hideSpinner(),t.fail())},t.prototype.generateStructuralVhdl=function(){var r=this,i=$.Deferred(),u=$.ajax({url:n.Settings.APIURI()+"/ComponentStructuralVhdl/?designID="+this.designID+"&revisionID="+this.revisionID,type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(u){t.structuralVhdlString=u;t.structuralVhdlString&&!r.isUnitTest&&(n.CeUtility.startsWith(t.structuralVhdlString.toLocaleLowerCase(),"error")?n.MessageManager.showErrorMessage(t.structuralVhdlString):n.CeUtility.isOpen()||new n.ModelEditor(surface,null,!1,n.CE_MODEL_TYPE.SCHEMATIC,!1));i.resolve(!0)},error:function(n,r){t.structuralVhdlString="GET structural vhdl server request error: "+r;i.resolve(!1)}});return i.promise()},t.prototype.deleteTempDesignState=function(){var i=this,t=$.Deferred(),r=$.ajax({url:n.Settings.APIURI()+"/Designs?designID="+this.designID+"&revisionID="+this.revisionID,type:"DELETE",data:null,contentType:"application/json;charset=utf-8",success:function(n){n&&n.DesignID==i.designID?t.resolve(!0):alert("Error deleting temp design")},error:function(n,i){t.resolve(!1);alert("Error deleting temp design: "+i)}});return t.promise()},t.prototype.showSpinner=function(){var t=this,i=$("#loading_me_spinner"),r;this.isSpinnerActive=!0;r=surface.getSidebarManager();setTimeout(function(){$(i).css({top:($("#main_editor").height()-$("#viewer-pane").height())/2+"px",left:r.getVisibleWidth(Sidebar.Orientation.LEFT)+"px",right:r.getVisibleWidth(Sidebar.Orientation.RIGHT)+"px"});t.isSpinnerActive&&$(i).fadeIn("slow")},n.CeUtility.minSpin);setTimeout(function(){t.isSpinnerActive&&($(i).fadeOut("slow"),t.isSpinnerActive=!1)},n.CeUtility.maxSpin)},t.prototype.hideSpinner=function(){$("#loading_me_spinner").fadeOut("slow");this.isSpinnerActive=!1},t.prototype.checkDesign=function(t){return t.comps.length==0&&t.nets.length==0?(n.MessageManager.showErrorMessage("Error: You must have a design loaded before generating a model from it"),!1):this.checkPinNets(t)==!1?(n.MessageManager.showErrorMessage("Error: All component pins must have an attached net. It can be unattached at the other end"),!1):!0},t.prototype.checkPinNets=function(n){for(var i,t=0;t<n.comps.length;t++)for(i=0;i<n.comps[t].pinConnections.length;i++)if(!n.comps[t].pinConnections[i].netName)return!1;return!0},t}();n.CeStructuralVhdl=t}(Project||(Project={})),function(n){var t=function(){function t(n){this.msgTipsGen=[];this.dialogTitle=$("#sch2VhdSplashDialogTitle");this.dialogTipsButton=$("#sch2VhdSplashDialogTipsButton");this.dialogQuickTutorial=$("#sch2VhdSplashDialogQuickTutorial");this.surface=n}return t.prototype.showSch2VhdSplashDialog=function(){var e=t.SCH_VHD_MINWIDTH,o=t.SCH_VHD_MINHEIGHT,u=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.SCH2VHD,n.MODELING_APP_DIM.WIDTH),f=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.SCH2VHD,n.MODELING_APP_DIM.HEIGHT),i=$("#sch2VhdSplashDialog"),r=i.data("kendoWindow");r?(r.open(),i.parent().css({width:u+"px",height:f+"px"}),i.scrollTop(0)):(i.kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,resizable:!0,title:"Schematic-based Modeling Tips",height:f,width:u,position:{top:150,left:340},minWidth:e,minHeight:o}),r=i.data("kendoWindow"),r.open(),$("#sch2VhdSplashDialogScrollable").css({width:t.SCH_VHD_WIDTH-50+"px"}),i.parent().css({width:u+"px",height:f+"px"}),i.scrollTop(0),this.addDialogContents(),this.setSplashMenu(),this.defineEventHandlers(),this.setDialogStyles())},t.prototype.addDialogContents=function(){var i=this,n,r,t;if(this.loadMsgStrings(),this.dialogTitle.html("Schematic-to-Model Generation Starter Notes"),n="",r=100,n.length<r)for(t=0;t<i.msgTipsGen.length;t++)n+=i.msgTipsGen[t];this.dialogTipsButton.html(n);this.dialogTipsButton.append('<button id="generate_vhdl_button" type="button" class="btn btn-primary">Click here to generate model<\/button>');this.dialogQuickTutorial.load("/Content/html/QuickSch2VhdTip.htm")},t.prototype.defineEventHandlers=function(){$(t.GENERATE_VHDL_BUTTON).click(function(){var t=new n.CeStructuralVhdl(surface,null,!1,!1),i=t.generateVhdlFromSchematic()})},t.prototype.setDialogStyles=function(){$("#sch2VhdSplashDialog").parent().css("z-index",n.ModelEditor.ME_Z_INDEX)},t.prototype.closeSplashDialog=function(){var n=$("#sch2VhdSplashDialog").data("kendoWindow");n&&n.close()},t.prototype.loadMsgStrings=function(){this.msgTipsGen.push('<i class="glyphicon glyphicon-arrow-right "><\/i>  You must have a design loaded before you can generate a model from it. Please note that the design cannot include custom SPICE components at this time.<br/><br/> ');this.msgTipsGen.push('<i class="glyphicon glyphicon-arrow-right "><\/i>  Before generating a model, ensure that all model pins on the schematic have a net attached (even if unattached at the other end).<br/><br/> ');this.msgTipsGen.push('<i class="glyphicon glyphicon-arrow-right "><\/i>  It is best to type in meaningful names for all nets on the schematic that you intend to use as model pins.<br/><br/> ');this.msgTipsGen.push('<i class="glyphicon glyphicon-arrow-right "><\/i>  Schematic-to-model generation is a one-shot process at this time. After a model is generated from a schematic, the model can only be edited using the component editor.<br/><br/> ');this.msgTipsGen.push('<i class="glyphicon glyphicon-arrow-right "><\/i>  After the model is automatically generated, <b><span style="color: #7030A0;" > you must manually edit the model<\/span><\/b > in order to add pins, and (optionally) allow properties to be passed into the model from the schematic. This process is described below in a short tutorial.<br/><br/> ');this.msgTipsGen.push('<i class="glyphicon glyphicon-arrow-right "><\/i>  Click on the Save New button to save the model. You will be prompted to enter a name for the model.<br/><br/> ')},t.prototype.createSplashMenu=function(){var t=this,r=function(){t.closeSplashDialog()},i,n;t.splashMenu||(i="<b>Splash Dialog Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,i),n.addMenuElement("Close Schematic to Model Dialog",r),n.addSeparatorToMenu(),t.splashMenu=SVWebContextMenu.MenuHelper.createMenu(n))},t.prototype.setSplashMenu=function(){this.createSplashMenu();this.splashMenu.bindMenuTo($("#sch2VhdSplashDialog"))},t.SCH_VHD_WIDTH=750,t.SCH_VHD_HEIGHT=510,t.SCH_VHD_MINWIDTH=200,t.SCH_VHD_MINHEIGHT=300,t.SCH_VHD_MAXWIDTH=800,t.SCH_VHD_MAXHEIGHT=1500,t.GENERATE_VHDL_BUTTON="#generate_vhdl_button",t}();n.CeStructuralVhdlSplash=t}(Project||(Project={})),function(n){var t=function(){function t(t,i,r,u){this.designID="";this.revisionID="";this.isSpinnerActive=!1;this.surface=t;this.isUnitTest=u;$.ajaxSetup({headers:{TOKEN_HEADER:n.Settings.APIKEY,token:"5",userID:n.Settings.UUID}})}return t.prototype.createSpiceModel=function(){var t=this,n=$.Deferred();return this.showSpinner(),$.when(this.saveTempDesignState()).done(function(i){i?$.when(t.generateStructuralVhdl()).done(function(i){i?$.when(t.deleteTempDesignState()).done(function(i){i?n.resolve(!0):n.resolve(!1);t.hideSpinner()}):n.resolve(!1)}):n.resolve(!1)}),n.promise()},t.prototype.saveTempDesignState=function(){var r=this,t=$.Deferred(),u=this.surface.getDesign(),i=u.getSaveData(),f=this.checkDesign(i),e;return f?(i.UserID=n.Utility.getUserID(),e=$.ajax({url:n.Settings.APIURI()+"/Designs",type:"POST",data:JSON.stringify(i),contentType:"application/json;charset=utf-8",success:function(n){r.designID=n.DesignID;r.revisionID=n.RevisionID;t.resolve(!0)},error:function(n,i){t.resolve(!1);alert("Error saving temp design: "+i)}}),t.promise()):(this.hideSpinner(),t.fail())},t.prototype.generateStructuralVhdl=function(){var i=this,t=$.Deferred(),r=$.ajax({url:n.Settings.APIURI()+"/ComponentStructuralVhdl/?designID="+this.designID+"&revisionID="+this.revisionID,type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(r){n.CeStructuralVhdl.structuralVhdlString=r;n.CeStructuralVhdl.structuralVhdlString&&!i.isUnitTest&&(n.CeUtility.startsWith(n.CeStructuralVhdl.structuralVhdlString.toLocaleLowerCase(),"error")?n.MessageManager.showErrorMessage(n.CeStructuralVhdl.structuralVhdlString):n.CeUtility.isOpen()||new n.ModelEditor(surface,null,!1,n.CE_MODEL_TYPE.SCHEMATIC,!1));t.resolve(!0)},error:function(i,r){n.CeStructuralVhdl.structuralVhdlString="GET structural vhdl server request error: "+r;t.resolve(!1)}});return t.promise()},t.prototype.deleteTempDesignState=function(){var i=this,t=$.Deferred(),r=$.ajax({url:n.Settings.APIURI()+"/Designs?designID="+this.designID+"&revisionID="+this.revisionID,type:"DELETE",data:null,contentType:"application/json;charset=utf-8",success:function(n){n&&n.DesignID==i.designID?t.resolve(!0):alert("Error deleting temp design")},error:function(n,i){t.resolve(!1);alert("Error deleting temp design: "+i)}});return t.promise()},t.prototype.showSpinner=function(){var t=this,i=$("#loading_me_spinner"),r;this.isSpinnerActive=!0;r=surface.getSidebarManager();setTimeout(function(){$(i).css({top:($("#main_editor").height()-$("#viewer-pane").height())/2+"px",left:r.getVisibleWidth(Sidebar.Orientation.LEFT)+"px",right:r.getVisibleWidth(Sidebar.Orientation.RIGHT)+"px"});t.isSpinnerActive&&$(i).fadeIn("slow")},n.CeUtility.minSpin);setTimeout(function(){t.isSpinnerActive&&($(i).fadeOut("slow"),t.isSpinnerActive=!1)},n.CeUtility.maxSpin)},t.prototype.hideSpinner=function(){$("#loading_me_spinner").fadeOut("slow");this.isSpinnerActive=!1},t.prototype.checkDesign=function(t){return t.comps.length==0&&t.nets.length==0?(n.MessageManager.showErrorMessage("Error: You must have a design loaded before generating a model from it"),!1):this.checkPinNets(t)==!1?(n.MessageManager.showErrorMessage("Error: All component pins must have an attached net. It can be unattached at the other end"),!1):!0},t.prototype.checkPinNets=function(n){for(var i,t=0;t<n.comps.length;t++)for(i=0;i<n.comps[t].pinConnections.length;i++)if(!n.comps[t].pinConnections[i].netName)return!1;return!0},t}();n.SpiceModels=t}(Project||(Project={})),function(n){var t=function(){function t(n){this.msgTipsGen=[];this.dialogTitle=$("#spiceSplashDialogTitle");this.dialogTipsButton=$("#spiceSplashDialogTipsButton");this.dialogQuickTutorial=$("#spiceSplashDialogQuickTutorial");this.surface=n}return t.prototype.showSpiceSplashDialog=function(){var e=t.SPICE_MINWIDTH,o=t.SPICE_MINHEIGHT,u=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.SPICE,n.MODELING_APP_DIM.WIDTH),f=n.CeUtility.getInitialModelingToolDim(n.MODELING_APP.SPICE,n.MODELING_APP_DIM.HEIGHT),i=$("#spiceSplashDialog"),r=i.data("kendoWindow");r?(r.open(),i.parent().css({width:u+"px",height:f+"px"}),i.scrollTop(0)):(i.kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,resizable:!1,title:"SPICE Modeling Tips",height:f,width:u,position:{top:150,left:340},minWidth:e,minHeight:o}),r=i.data("kendoWindow"),r.open(),$("#spiceSplashDialogScrollable").css({width:t.SPICE_WIDTH-50+"px"}),i.scrollTop(0),this.addDialogContents(),this.setSplashMenu(),this.defineEventHandlers(),this.setDialogStyles())},t.prototype.addDialogContents=function(){var i=this,n,r,t;if(this.loadMsgStrings(),this.dialogTitle.html("SPICE Model Starter Notes"),n="",r=100,n.length<r)for(t=0;t<i.msgTipsGen.length;t++)n+=i.msgTipsGen[t];this.dialogTipsButton.html(n);this.dialogTipsButton.append('<button id="spice_model_button" type="button" class="btn btn-primary">Click here to create SPICE model<\/button>')},t.prototype.defineEventHandlers=function(){$(".linkSpiceHelpMenu").click(function(){var t=new n.AppViewHelp;t.loadDialogContentsAddHandlers("04a6103d-0e1b-4d96-b843-79c4a3420bae")});$(t.SPICE_MODEL_BUTTON).click(function(){if(!n.CeUtility.isOpen()){new n.ModelEditor(surface,null,!1,n.CE_MODEL_TYPE.SPICE,!1);var t=$("#spiceSplashDialog").data("kendoWindow");t.close()}})},t.prototype.setDialogStyles=function(){$("#spiceSplashDialog").parent().css("z-index",n.ModelEditor.ME_Z_INDEX)},t.prototype.closeSplashDialog=function(){var n=$("#spiceSplashDialog").data("kendoWindow");n&&n.close()},t.prototype.loadMsgStrings=function(){this.msgTipsGen.push('<p class="spiceSplashInstructions"><span style="font-weight:bold;color:red;">BETA Version<\/span><br/><\/p>');this.msgTipsGen.push('<p class="spiceSplashInstructions">You can paste a single .subckt (optionally with multiple .model statements) or a single .model <br/>statement (without .subckt statement) into the component editor to create a new SPICE-based component.<\/p>');this.msgTipsGen.push('<p class="spiceSplashInstructions"><span style="color:red;">Encrypted SPICE models and proprietary SPICE functionality <br/>(as available with PSpice and LTspice) are not supported at this time.<\/span><br/><\/p>');this.msgTipsGen.push('<p class="spiceSplashInstructions"><span class="btn-link linkSpiceHelpMenu">Click here for links to modeling tips, tutorials, and additional information.<\/span><br/><\/p>')},t.prototype.createSplashMenu=function(){var t=this,r=function(){t.closeSplashDialog()},i,n;t.splashMenu||(i="<b>Splash Dialog Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,i),n.addMenuElement("Close SPICE Model Dialog",r),n.addSeparatorToMenu(),t.splashMenu=SVWebContextMenu.MenuHelper.createMenu(n))},t.prototype.setSplashMenu=function(){this.createSplashMenu();this.splashMenu.bindMenuTo($("#spiceSplashDialog"))},t.SPICE_WIDTH=750,t.SPICE_HEIGHT=260,t.SPICE_MINWIDTH=200,t.SPICE_MINHEIGHT=200,t.SPICE_MAXWIDTH=800,t.SPICE_MAXHEIGHT=1500,t.SPICE_MODEL_BUTTON="#spice_model_button",t}();n.SpiceSplash=t}(Project||(Project={})),function(n){var t=function(){function t(){this._imageString="";this.extImage=null;this.messageList=[];this.importInstructionsString="To import an image:<br/>1) Create/save image on your computer.<br/>2) Click on the Choose File button.<br/>3) Browse to the saved image, click Open.<br/>4) Click OK.<br/>The image must be of type <b>jpg<\/b>, <b>gif<\/b>, or <b>png<\/b>."}return t.prototype.getMessageList=function(){return this.messageList},t.prototype.showImportImageDialog=function(){var n,i;return this.deferredImportImg=$.Deferred(),n=$("#importImageDialog"),n.kendoWindow({actions:[],draggable:!0,modal:!0,pinned:!1,resizable:!1,title:"Import Image",height:"auto",width:"300px",activate:function(){$("#urlInput").select()}}).data("kendoWindow").open().center(),i=n.data("kendoWindow"),i.bind("close",function(){$(t.IMPORT_IMAGE_OK_BUTTON).off("click");$(t.IMPORT_IMAGE_CANCEL_BUTTON).off("click")}),this.initializeImportDialog(),this.deferredImportImg.promise()},t.prototype.initializeImportDialog=function(){var f=this,o=$(t.IMPORT_IMAGE_OK_BUTTON),s=$(t.IMPORT_IMAGE_CANCEL_BUTTON),e=!1,r=$("#importImageDialog"),i,h,u,c;r.css({display:"block","z-index":n.AppAddHelp.ADD_HELP_Z_INDEX+200});c=$("#imgFileLocalForm")[0];c.reset();r.on("keydown.appAddHelp",function(t){t.which==n.Design.EnterKey?o.trigger("click"):t.which==n.Design.EscKey&&s.trigger("click")});$("#imageImportInstructionsKeyword").click(function(){f.showInfoMessage(f.importInstructionsString,!1)});o.on("click",function(){i=document.getElementById("imgFileLocal");e=i&&i.files&&i.files[0]?!0:!1;e&&(h=i.files[0],u=new FileReader,u.onload=function(){f.checkImageAndUpdateField(u.result)},u.readAsDataURL(h));var n=r.data("kendoWindow");n.close()});s.on("click",function(){var n=r.data("kendoWindow");n.close()})},t.prototype.checkImageAndUpdateField=function(t){var i=t.split("data:"),r;if(i[1]&&i[1].indexOf("image/png")==-1&&i[1].indexOf("image/gif")==-1&&i[1].indexOf("image/jpeg")==-1&&i[1].indexOf("application/pdf")==-1){n.MessageManager.showErrorMessage("The file type you are importing is not supported. It must be gif, jpg, or png.",!0);this.deferredImportImg.reject();return}i[1]&&(r=encodeURIComponent(t).match(/%[89ABab]/g),this.imageString=t,console.log(this.imageString),this.deferredImportImg.resolve())},t.prototype.showInfoMessage=function(n,t,i){t===void 0&&(t=!0);i===void 0&&(i=5e3);var r=$("#notification").kendoNotification({stacking:"down",show:this.onShow,button:!0,autoHideAfter:t?i:0}).data("kendoNotification");r.show(n,"info");this.addToList(r)},t.prototype.removeAllMessages=function(){this.messageList.forEach(function(n){n.hide()});this.messageList=[]},t.prototype.addToList=function(n){n&&this.messageList.push(n)},t.prototype.onShow=function(t){var i,o,r,s;if(!$("."+t.sender._guid)[1]){var u=t.element.parent(),h=u.width(),l=u.height(),c=$(window).width(),a=$(window).height(),f,e;e=Math.floor(c/2-h/2);i=$("#importImageDialog").parent();o=i.offset();f=o.top-i.height()-50;t.element.parent().css({top:f,left:e});r=5e4;s=n.KendoHelper.getKendoWindowMaxZIndex();r=s+1e3;t.element.parent().css({zIndex:r})}},Object.defineProperty(t.prototype,"imageString",{get:function(){return this._imageString},set:function(n){this._imageString=n},enumerable:!0,configurable:!0}),t.IMPORT_IMAGE_OK_BUTTON="#import_image_ok_button",t.IMPORT_IMAGE_CANCEL_BUTTON="#import_image_cancel_button",t}();n.AppLocalImageBrowser=t}(Project||(Project={})),function(n){var t=function(){function t(){this.docId="";this.docs=null;this.cloudImages=null;this.doc=null;this.docHtml="";this.isDocEdit=!1;t.GLOBAL_ADD_APP_HELP_INDEX++}return t.prototype.showAppHelpInputDialog=function(i,r,u){function l(){e=!0}var f=this,e,s;$("body").append('<div class="helpStyles" id=appHelpInputDialog'+t.GLOBAL_ADD_APP_HELP_INDEX+"><\/div>");this.appHelpInputDialog=t.getAppHelpAddDomNode();this.doc=new n.AppHelpDoc;i&&(this.docId=i);this.doc.Partner="SVWebHelp";var h=r?r:t.APP_ADD_HELP_TOP,c=u?u:t.APP_ADD_HELP_LEFT,o=this.appHelpInputDialog.data("kendoWindow");this.appHelpInputDialog.kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,position:{top:h,left:c},deactivate:function(){tinymce.editors=[];this.destroy()},resizable:!0,title:"Help Topic Creation Dialog",width:t.APP_ADD_HELP_WIDTH,minWidth:t.APP_ADD_HELP_MINWIDTH,minHeight:t.APP_ADD_HELP_MINHEIGHT,resize:l});o=this.appHelpInputDialog.data("kendoWindow");r||u||o.center();o.open();this.appHelpInputDialog.scrollTop(0);this.appHelpInputDialog.parent().css("z-index",t.ADD_HELP_Z_INDEX);this.appHelpInputDialog.parent().css("top",t.APP_ADD_HELP_TOP);this.setHelpMenu();this.getTinyAppHelpInput();e=!1;s=$("#appHelpInputDialog"+t.GLOBAL_ADD_APP_HELP_INDEX).parent();s.on("mouseup",function(){if(e){var n=$("#appHelpInputDialog"+t.GLOBAL_ADD_APP_HELP_INDEX).parent();n.find(".k-resize-n, .k-resize-s, .k-resize-nw, .k-resize-ne, .k-resize-sw").css({display:"none"});e=!1}});setTimeout(function(){f.appHelpInputDialog.show();$("#helpSaveNewBtn").on("click",function(){f.saveDoc(!0)});$("#helpCloseBtn").on("click",function(){f.closeDoc()});$("#helpPartnerId").val(f.doc.Partner)},t.EVENT_HANDLER_TIMEOUT_MAIN)},t.prototype.getTinyAppHelpInput=function(){var n=this,i=this,r,u,f;this.appHelpInputDialog.html('<form><textarea id="tinyEditorId" class="tinyEditClass" rows="10" cols="30" style="width:100%;height:440px"><p>Loading contents...<\/p><\/textarea><\/form>');this.appHelpInputDialog.hide();tinymce.init({selector:"#tinyEditorId",content_css:"Content/AppHelpStyles.css",style_formats:[{title:"Paragraph",block:"p",classes:"helpStyles"},{title:"Heading 1",block:"h1",classes:"helpStyles"},{title:"Heading 2",block:"h2",classes:"helpStyles"},{title:"Heading 3",block:"h3",classes:"helpStyles"},{title:"Heading 4",block:"h4",classes:"helpStyles"},{title:"Caption (center)",block:"p",classes:"CaptionCenter helpStyles"},{title:"Note",block:"p",classes:"Note helpStyles"},{title:"Normal Character",inline:"span",classes:"NormalCharacter helpStyles"},{title:"VHDL Paragraph",block:"p",classes:"VHDLParagraph helpStyles"},{title:"VHDL Character",inline:"span",classes:"VHDLParagraph helpStyles"},{title:"VHDL Keyword",inline:"span",classes:"VHDLKeyword helpStyles"},{title:"VHDL Comment",inline:"span",classes:"VHDLComment helpStyles"},{title:"Emphasis",inline:"span",classes:"Emphasis helpStyles"},{title:"Highlight",inline:"span",classes:"Highlight helpStyles"}],style_formats_merge:!1,menubar:!1,browser_spellcheck:!0,plugins:"table searchreplace colorpicker code advlist",toolbar1:"styleselect fontsizeselect fontselect | table | searchreplace removeformat | code | browseForHelpDocLinks browseForHelpDoc getImage",toolbar2:"undo redo | cut copy paste | bold italic underline superscript subscript | alignleft aligncenter alignright alignfull | bullist numlist advlist | outdent indent",setup:function(n){n.addMenuItem("Local",{text:"Local",context:"images",onclick:function(){i.showLocalImgBrowserDialog()}});n.addMenuItem("Cloud",{text:"Cloud",context:"images",onclick:function(){i.showCloudImgBrowserDialog()}});n.addButton("browseForHelpDoc",{title:"Browse for help doc",icon:"mce-ico mce-i-newdocument",onclick:function(){n.focus();i.isDocEdit=!0;i.showDocBrowserDialog()}});n.addButton("browseForHelpDocLinks",{title:"Browse for help doc link",icon:"mce-ico mce-i-link",onclick:function(){n.focus();i.isDocEdit=!1;i.showDocBrowserDialog()}});n.addButton("getImage",{type:"menubutton",text:"Get Image",icon:!1,menu:[{text:"Local",onclick:function(){i.showLocalImgBrowserDialog()}},{text:"Cloud",onclick:function(){i.showCloudImgBrowserDialog()}}]})}});this.appHelpInputDialog.append("<div id=helpNameDiv class=helpInputControl><\/div>");r=$("#helpNameDiv");r.append('<label class="control-label labelClass" id="helpNameLabelId" for="helpNameId"> Help Doc Name:<\/label>');r.append('<div class="controls appHelpInput"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "helpNameId" name= "helpName"title = "This is the name of this help topic" /><\/div>');this.appHelpInputDialog.append("<div id=helpTagsDiv class=helpInputControl><\/div>");u=$("#helpTagsDiv");u.append('<label class="control-label labelClass" id="helpTagsLabelId" for="helpTagsId"> Search tags:<\/label>');u.append('<div class="controls"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "helpTagsId" name= "helpTags"title = "Enter search words for this topic (space separated)" /><\/div>');this.appHelpInputDialog.append("<div id=helpPartnerDiv class=helpInputControl><\/div>");f=$("#helpPartnerDiv");f.append('<label class="control-label labelClass" id="helpPartnerLabelId" for="helpPartnerId"> Help Partner (owner):<\/label>');f.append('<div class="controls"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "helpPartnerId" name= "helpPartner"title = "Owner of the Help doc" /><\/div>');this.appHelpInputDialog.append('<div id="helpCreationBtnRow" class="row"><\/div>');$("#helpCreationBtnRow").html("");this.docId&&this.prependUpdateButton();$("#helpCreationBtnRow").append('<input type="button" value= "Save New" id= "helpSaveNewBtn" class="btn btn-primary btn-sm helpDocBtn" title = "Click to save this new help document" />');$("#helpCreationBtnRow").append('<input type="button" value= "Close" id= "helpCloseBtn" class="btn btn-primary btn-sm helpDocBtn" title = "Click to close this help document" />');this.docId?$.when(this.getHelpContent()).done(function(){n.setTinymceContent(n.doc.HtmlDoc);$("#helpNameId").val(n.doc.Name);$("#helpTagsId").val(n.doc.Tags);$("#helpPartnerId").val(n.doc.Partner);n.configDialog()}):setTimeout(function(){n.setTinymceContent("");n.configDialog()},t.EVENT_HANDLER_TIMEOUT)},t.prototype.getAppHelpInput=function(){var i=this,r=this,u,f,e;this.appHelpInputDialog.html('<form><textarea id="kendoEditorId" class="kendoEditClass" rows="10" cols="30" style="width:100%;height:440px"><p>Loading contents...<\/p><\/textarea><\/form>');this.appHelpInputDialog.hide();$("#kendoEditorId").kendoEditor({tools:["bold","italic","underline","strikethrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertUnorderedList","insertOrderedList","indent","outdent","subscript","superscript","createTable","addRowAbove","addRowBelow","addColumnLeft","addColumnRight","deleteRow","deleteColumn","viewHtml",{name:"browseForLinks",tooltip:"Browse for help doc links",exec:function(){var t=$("#kendoEditorId").data("kendoEditor"),i=t.selectedHtml();i?(r.isDocEdit=!1,r.showDocBrowserDialog()):n.MessageManager.showErrorMessage("Please select text before adding link")}},{name:"browseForHelpDoc",tooltip:"Browse for help doc",exec:function(){r.isDocEdit=!0;r.showDocBrowserDialog()}},{name:"imageBroeserTemplate",template:$("#imageBrowser-template").html()},"break",{name:"formatting",items:[{text:"Paragraph",value:"p.helpP"},{text:"Heading 1",value:"h1.helpH1"},{text:"Heading 2",value:"h2.helpH2"},{text:"Heading 3",value:"h3.helpH3"},{text:"Heading 4",value:"h4.helpH4"},{text:"Caption - center",value:"p.CaptionCenter"},{text:"Note",value:"p.Note"},{text:"Normal Word(s)",value:"span.helpP"},{text:"VHDL Paragraph",value:"p.VHDLParagraph"},{text:"VHDL Word(s)",value:"span.VHDLParagraph"},{text:"VHDL Keyword",value:"span.VHDLKeyword"},{text:"Emphasis",value:"span.Emphasis"},{text:"VHDL Comment",value:"span.VHDLComment"},]},"fontName",{name:"fontSize",items:[{text:"8pt",value:"8pt"},{text:"10pt",value:"10pt"},{text:"12pt",value:"12pt"},{text:"14pt",value:"14pt"},{text:"18pt",value:"18pt"},{text:"24pt",value:"24pt"},{text:"36pt",value:"36pt"},]}],stylesheets:["Content/AppHelpStyles.css"],resizable:{content:!0,toolbar:!1},change:this.onChange,execute:this.onKendoExecute});this.appHelpInputDialog.append("<div id=helpNameDiv class=helpInputControl><\/div>");u=$("#helpNameDiv");u.append('<label class="control-label labelClass" id="helpNameLabelId" for="helpNameId"> Help Doc Name:<\/label>');u.append('<div class="controls appHelpInput"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "helpNameId" name= "helpName"title = "This is the name of this help topic" /><\/div>');this.appHelpInputDialog.append("<div id=helpTagsDiv class=helpInputControl><\/div>");f=$("#helpTagsDiv");f.append('<label class="control-label labelClass" id="helpTagsLabelId" for="helpTagsId"> Search tags:<\/label>');f.append('<div class="controls"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "helpTagsId" name= "helpTags"title = "Enter search words for this topic (space separated)" /><\/div>');this.appHelpInputDialog.append("<div id=helpPartnerDiv class=helpInputControl><\/div>");e=$("#helpPartnerDiv");e.append('<label class="control-label labelClass" id="helpPartnerLabelId" for="helpPartnerId"> Help Partner (owner):<\/label>');e.append('<div class="controls"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "helpPartnerId" name= "helpPartner"title = "Owner of the Help doc" /><\/div>');this.appHelpInputDialog.append('<div id="helpCreationBtnRow" class="row"><\/div>');$("#helpCreationBtnRow").html("");this.docId&&this.prependUpdateButton();$("#helpCreationBtnRow").append('<input type="button" value= "Save New" id= "helpSaveNewBtn" class="btn btn-primary btn-sm helpDocBtn" title = "Click to save this new help document" />');$("#helpCreationBtnRow").append('<input type="button" value= "Close" id= "helpCloseBtn" class="btn btn-primary btn-sm helpDocBtn" title = "Click to close this help document" />');this.docId?$.when(this.getHelpContent()).done(function(){i.setTinymceContent(i.doc.HtmlDoc);$("#helpNameId").val(i.doc.Name);$("#helpTagsId").val(i.doc.Tags);$("#helpPartnerId").val(i.doc.Partner);i.configDialog()}):setTimeout(function(){i.setTinymceContent("");i.configDialog()},t.EVENT_HANDLER_TIMEOUT)},t.prototype.prependUpdateButton=function(){var n=this;$("#helpCreationBtnRow").prepend('<input type="button" value= "Update" id= "helpUpdateBtn" class="btn btn-primary btn-sm helpDocBtn" title = "Click to update this help document" />');setTimeout(function(){$("#helpUpdateBtn").on("click",function(){n.saveDoc(!1)})},t.EVENT_HANDLER_TIMEOUT)},t.prototype.onChange=function(){function f(){var n=t.getAppHelpAddDomNode(),i=$("#main_editor").height();n.parent().height()>i-200&&n.parent().css({height:i-200});n.parent().css({top:t.APP_ADD_HELP_TOP})}function e(n){var u,i;$("body").append("<div id=imgResizeDialog><\/div>");var r=$("#imgResizeDialog");r.kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,position:{top:50,left:50},deactivate:function(){this.destroy()},resizable:!1,title:"Set Image Size",height:t.IMG_RESIZE_HEIGHT,width:t.IMG_RESIZE_WIDTH});u=r.data("kendoWindow");u.center();u.open();r.append('<div id="inputFields" class="row"><\/div>');$("#inputFields").append('<div id="imgWidthDiv" class="helpInputControl col-sm-4"><\/div>');i=$("#imgWidthDiv");i.append('<label class="control-label labelClass" id="imgWidthLabelId" for="imgWidthId"> Width:<\/label>');i.append('<div class="controls appHelpInput"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "imgWidthId" name= "imgWidth"title = "Width of the image" /><\/div>');$("#inputFields").append('<div id="imgHeightDiv" class="helpInputControl col-sm-4"><\/div>');i=$("#imgHeightDiv");i.append('<label class="control-label labelClass" id="imgHeightLabelId" for="imgHeightId"> Height:<\/label>');i.append('<div class="controls appHelpInput"><input autocomplete="off" type= "text" class="input-small appHelpInputClass" id= "imgHeightId" name= "imgHeight"title = "Height of the image" /><\/div>');r.append('<div id="imgResizeBtnRow" class="row"><\/div>');$("#imgResizeBtnRow").html('<div class="col-sm-4" id="imgResizeOK" ><input type="button" value= "OK" id= "imgResizeOKBtn" class="btn btn-primary btn-sm" title = "Click to close dialog" /><\/div>');var f=$(n.target).closest("img"),e=f.height(),o=f.width();e&&o&&($("#imgHeightId").val(e),$("#imgWidthId").val(o));setTimeout(function(){$("#imgHeightId, #imgWidthId").on("keyup",function(){$(n.target).closest("img").width($("#imgWidthId").val()).height($("#imgHeightId").val())});$("#imgResizeOKBtn").on("click",function(){u.close()});var i=t.getAppHelpAddDomNode().css("z-index");r.parent().css("z-index",i+500)},t.EVENT_HANDLER_TIMEOUT)}var u,n,i,r;for(f(),u=$("#kendoEditorId").data("kendoEditor"),n=$(u.body).find(".imgClass"),n.css("cursor","context-menu"),i=0;i<n.length;i++){r=n[i];$(r).off();$(r).on("dblclick",function(n){var t=$("#imgResizeDialog").data("kendoWindow");t&&(t.close(),$("#imgResizeDialog").remove());e(n)})}},t.prototype.onKendoExecute=function(n){n.name=="createlink"&&n.preventDefault()},t.prototype.closeHelpDialog=function(){var n=$("#appHelpInputDialog").data("kendoWindow");n&&n.close()},t.prototype.createHelpMenu=function(){var t=this,r=function(){t.closeHelpDialog()},i,n;t.helpMenu||(i="<b>Help Input Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,i),n.addMenuElement("Close Help Input Dialog",r),n.addSeparatorToMenu(),t.helpMenu=SVWebContextMenu.MenuHelper.createMenu(n))},t.prototype.setHelpMenu=function(){this.createHelpMenu();this.helpMenu.bindMenuTo($("#appHelpInputDialog"))},t.prototype.saveDoc=function(t){var u=this,i,r;tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select("ol, ul, p"),"helpStyles");i="POST";r="";!this.doc.id||t?(this.doc.id="",this.doc.EmbeddedObjectRefs=[],i="POST",r="Your new Help document has been saved"):(i="PUT",r="Your existing Help document has been updated");this.doc.Name=$("#helpNameId").val();this.doc.Partner=$("#helpPartnerId").val();this.doc.Tags=$("#helpTagsId").val();this.doc.HtmlDoc=this.getTinymceContent();this.doc.HtmlDoc.indexOf("base64")>-1&&this.updateImages();this.setTinymceContent(this.doc.HtmlDoc);this.updateImageList(this.doc);var f=JSON.stringify(this.doc),e=this.GetAPIURI();$.ajax({url:e+"/appHelp?partner=SVWebHelp",dataType:"json",type:i,data:f,contentType:"application/json;charset=utf-8",success:function(t){n.MessageManager.showInfoMessage(r);i=="POST"&&($("#helpUpdateBtn").length<=0&&u.prependUpdateButton(),u.doc.id=t.id)},error:function(){console.log("Error adding doc to DB")}})},t.prototype.closeDoc=function(){var n=t.getAppHelpAddDomNode().data("kendoWindow");n.close()},t.prototype.GetAPIURI=function(){$.ajaxSetup({headers:{userID:n.Utility.getUserID(),TOKEN_HEADER:n.Settings.APIKEY}});return n.Settings.APIURI()},t.prototype.checkImageLists=function(n){var u=!0,t=[],i,r;if(t=this.getHtmlImageIds(n.HtmlDoc),t.length!=n.EmbeddedObjectRefs.length){this.updateImageList(n);return}for(i=0;i<n.EmbeddedObjectRefs.length;i++){for(r=0;r<t.length;r++)if(n.EmbeddedObjectRefs[i].Name==t[r]){u=!0;break}if(!u){this.updateImageList(n);return}}},t.prototype.updateImageList=function(n){var i=[],t,r;for(i=this.getHtmlImageIds(n.HtmlDoc),n.EmbeddedObjectRefs=[],t=0;t<i.length;t++)r={Name:i[t],Type:"Image"},n.EmbeddedObjectRefs.push(r);this.doc=n},t.prototype.getHtmlImageIds=function(n){var r=[],i=[],u,t;for(n.indexOf("help-svweb-images/")>-1&&(i=n.split("help-svweb-images/")),t=1;t<i.length;t++)u=i[t].split('"')[0],r.push(u.replace(/\\/g,""));return r},t.prototype.getTinymceContent=function(){return tinymce.triggerSave(),tinymce.activeEditor.getContent()},t.prototype.insertTinymceContent=function(n){var t=tinymce.activeEditor;t.execCommand("mceInsertContent",!1,n)},t.prototype.setTinymceContent=function(n){var t=tinymce.activeEditor;t.execCommand("mceSetContent",!1,n)},t.prototype.getKendoEditorContent=function(){var n=$("#kendoEditorId").data("kendoEditor");return n.value()},t.prototype.setKendoEditorContent=function(n){var t=$("#kendoEditorId").data("kendoEditor");t.value(n)},t.prototype.insertKendoEditorContent=function(n){var t=$("#kendoEditorId").data("kendoEditor");t.exec("inserthtml",{value:n})},t.prototype.getLocalImage=function(n){var t=n.match(/\"(.*?)\"/);return t[1].toString()},t.prototype.updateImages=function(){for(var f,r="",u="",i="",t=this.doc.HtmlDoc.split("<p"),n=1;n<t.length;n++)if(t[n].indexOf("base64")>-1){f=t[n].split("src=");r=this.getLocalImage(f[1]);u=r.split(",")[1];i=this.generateGUID();this.saveImage(i,u);var e=t[n].split('src="'),o=e[1].split(/"(.+)?/),s="<p"+e[0]+'src="https://sysvproduction.blob.core.windows.net/help-svweb-images/'+i+'"'+o[1];t[n]=s}else t[n]="<p"+t[n];for(this.doc.HtmlDoc="",n=0;n<t.length;n++)this.doc.HtmlDoc+=t[n]},t.prototype.saveImage=function(n,t){var i=this.GetAPIURI(),r="/BlobAppHelp?typeName=help-svweb-images&objectName="+n;$.ajax({url:i+r,dataType:"json",type:"POST",data:JSON.stringify(t),contentType:"application/json;charset=utf-8",success:function(){},error:function(){console.log("Error adding image to DB")}})},t.prototype.getHelpContent=function(){var t=this,n=$.Deferred(),i=this.GetAPIURI(),r="/AppHelp?partner=SVWebHelp&docId="+this.docId,u=$.ajax({url:i+r,type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(i){t.doc=i[0];n.resolve(!0)},error:function(){console.log("Error getting doc from DB");n.resolve(!1)}});return n.promise()},t.prototype.getAllHelpDocs=function(){var t=this,n=$.Deferred(),i=this.GetAPIURI(),r=$.ajax({url:i+"/AppHelp?partner=SVWebHelp",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(i){t.docs=i;n.resolve(!0)},error:function(){console.log("Error getting docs from DB");n.resolve(!1)}});return n.promise()},t.prototype.getAllCloudHelpImages=function(){var t=this,n=$.Deferred(),i=this.GetAPIURI(),r=$.ajax({url:i+"/BlobAppHelp?typeName=help-svweb-images",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(i){t.cloudImages=i;n.resolve(!0)},error:function(){console.log("Error getting images from DB");n.resolve(!1)}});return n.promise()},t.prototype.configDialog=function(){var n=this;$("#appHelpInputDialog"+t.GLOBAL_ADD_APP_HELP_INDEX+" .mce-listbox button").css({"padding-right":"5px"});$("#appHelpInputDialog"+t.GLOBAL_ADD_APP_HELP_INDEX+" span").remove(".k-tool-text");$("#appHelpInputDialog"+t.GLOBAL_ADD_APP_HELP_INDEX+" .k-toolbar-resizable").css({"white-space":"inherit"});$("#templateTool").kendoDropDownList({change:function(t){t.sender.value()=="local"?n.showLocalImgBrowserDialog():t.sender.value()=="cloud"&&n.showCloudImgBrowserDialog();t.sender.value("select")}});this.disableResizeHandlers()},t.prototype.disableResizeHandlers=function(){var n=$("#appHelpInputDialog"+t.GLOBAL_ADD_APP_HELP_INDEX).parent();n.find(".k-resize-n, .k-resize-s, .k-resize-nw, .k-resize-ne, .k-resize-sw").css({display:"none"})},t.prototype.generateGUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var t=Math.random()*16|0,i=n=="x"?t:t&3|8;return i.toString(16)})},t.getBrowseHelpDocDomNode=function(){return $("#docBrowserDialog"+t.GLOBAL_BROWSE_HELP_DOC_INDEX)},t.getAppHelpAddDomNode=function(){return $("#appHelpInputDialog"+t.GLOBAL_ADD_APP_HELP_INDEX)},t.prototype.getTestImage=function(n){return n=="gainBlock"?"/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAqAKIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiigAooooAKKKKAOOTR7fUfFmvzGS5guI/swjntZ2jZRs6ccMPYgitEp4l0wny5bfWYB0WUCCfH+8Pkb8kpdJ/5GvxF2+e2/wDRdb9AGFD4q07zktr/AM3S7knCxXymPd/uv91vwJrcVgy5FVp2tJ7OQ3Hky2rL83mYKFffPFZB8LRWuX0W+udMIORHEfMg/wC/T5Uf8B20AdDRXPf2jr+mHF/pi38I/wCW+nH5vxic5/JjVzTte0zU5DHa3gNwg+e3lUpKv1RsEflQBq0UUUAFFFFABRRRQAUUUUAFFFFAHntvrHiGI+eF8u3ikRTC1ufmDeblmY88YT/JqPTfFmrNZ2d1PM1zYyRxvNc/Y2QJI0Lt5YHXhxHz/tYr0ORFlRo3UFWGCD3FNjjjt4UhjRURFCIo4AA6CgDl/Ct9qk8WqyXzzS3e6GaO2kj8oJut4ztUnsX3j2INXjqviLt4ZX/wYJ/hW/RQBgf2p4h6/wDCN/h9vj/wo/tTxD/0Lf8A5Px/4Vv0UAct4cmup/EXiCS7s/ssxaD915ok48vrkV1NYGlf8jZ4i+tt0H/TOt+gDxTw758ttocXiG2UeFDfXMVsqSZWW6+0OUNwO6E7go6blGeor2nhf89azX0DSpNGk0Z9PgbTpM7rZh8rZbef1OfrS3+rabo0Mf2y8ht8jCIz/M/+6OrfhQBp1n6lpOnasgS/sorjZnYXT5k9cHqPwrOOraxqI26Vo7Qof+XnUiYV/CMfvD/wILR/wjct627W9Tub4Hg28f7i3/74U5P/AANmoAyLm8/se4a30TXZ764Uc6bJGbwr043r88f1ckVp22seJpLdJJvCvlSMMtH/AGjGdvtnFblnZ2un2629naxW0KjIjiQKB9AKs0AYH9p+Ief+Kc/K/j/wo/tPxD/0Ln5X8f8AhW/RQBkWV9q092sd3on2WEg7pDdrJj8BXML4u1GOYtN5IjMv+kxeUytYILhY/wB42ecoWOeOmfu131FAHmcni7UEvftA1C2gtrloYYRNC21ENzPGZRyMnYie3I7Vdh8XalMI7V44UuZ3hWAiFv3iM8itKB6YUH/ZzzXcXFrDdeV50QfypBLHn+Fh0NT0AcloWtGTw9psl3r9sblrWIyl4huLlBnPPXOaK62igAooooAKKKKACiiigDm7GeG18SeI5bmZIYlNtmSVgqj936mn/wDCTJenbolhc6oevnIPLgH/AG1bg/8AAd1YUFla3vxUv1uraGdUtIJFEsYbDYPzDPf3rvqAOe/s3XdR51HVBZxEY8jTR834yuM+nRVq7p2iaXpchks7NUmcfPO2Xlf6u2S34mtSigAooooAKKKKACiiigAooooAKKKKACiiigD/2Q==":"R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7"},t.prototype.showDocBrowserDialog=function(n,i){var r=this,e;t.GLOBAL_BROWSE_HELP_DOC_INDEX++;$("body").append("<div id=docBrowserDialog"+t.GLOBAL_BROWSE_HELP_DOC_INDEX+"><\/div>");var u=t.getBrowseHelpDocDomNode(),o=n?n:50,s=i?i:50,f=u.data("kendoWindow");f?(n||i||f.center(),f.open()):(u.kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,position:{top:o,left:s},deactivate:function(){this.destroy()},resizable:!1,title:"Select Help Doc",height:t.DOC_BROWSER_HEIGHT,width:t.DOC_BROWSER_WIDTH}),f=u.data("kendoWindow"),n||i||f.center(),f.open(),e=t.getAppHelpAddDomNode().css("z-index"),u.parent().css("z-index",e+500),r.setHelpMenu(),$.when(r.getAllHelpDocs()).done(function(){u.html("");for(var n=0;n<r.docs.length;n++)u.append("<ul><b>Name: "+r.docs[n].Name+'<\/b><br><b>Link: <\/b><a href="#" class="helpDocLink">'+r.docs[n].id+"<\/a><\/ul><br>");$("#docBrowserDialog"+t.GLOBAL_BROWSE_HELP_DOC_INDEX+" ul").css({padding:"0","font-size":"12px"});r.isDocEdit?r.initEditDocBrowseHandlers():r.initLinkDocBrowseHandlers()}))},t.prototype.showCloudImgBrowserDialog=function(n,i){var f=this;$("body").append("<div id=cloudImgBrowserDialog><\/div>");var r=$("#cloudImgBrowserDialog"),e=n?n:50,o=i?i:50,u=r.data("kendoWindow");u?(n||i||u.center(),u.open()):(r.kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,position:{top:e,left:o},resizable:!1,title:"Cloud Images",height:t.IMG_BROWSER_HEIGHT,width:t.IMG_BROWSER_WIDTH}),u=r.data("kendoWindow"),n||i||u.center(),u.open(),r.parent().css("z-index",t.ADD_HELP_Z_INDEX+500),f.setHelpMenu(),$.when(f.getAllCloudHelpImages()).done(function(){r.html("");for(var n=0;n<f.cloudImages.length;n++)r.append('<ul><img class="helpCloudImg" alt="" height="100" width="150"src= "https://sysvproduction.blob.core.windows.net/help-svweb-images/'+f.cloudImages[n]+'" /><\/ul>');f.initCloudImgBrowseHandlers()}))},t.prototype.showLocalImgBrowserDialog=function(){var i=this,r=tinymce.activeEditor,t=new n.AppLocalImageBrowser;t.promiseImportImage=t.showImportImageDialog();$.when(t.promiseImportImage).done(function(){var n='<p><img width="" height="" class="imgClass" src="'+t.imageString+'" /><\/p>';i.insertTinymceContent(n)})},t.prototype.initLinkDocBrowseHandlers=function(){var r=this,i="";i=this.docId==n.AppViewHelp.MAIN_BROWSER_DOC_ID?"help_browser_iframe":"help_iframe";$(".helpDocLink").click(function(){var u=$(this).closest("ul").find(".helpDocLink").text(),n=tinymce.activeEditor,f=n.selection.getContent(),e='<span><a class="helpA" href="https://staging-api.systemvision.com/api/1.0/AppHelp?html=true&partner=SVWebHelp&docId='+u+'" target= "'+i+'" >',r;n.execCommand("mceReplaceContent",!1,e+f+"<\/a><\/span> ");r=t.getBrowseHelpDocDomNode().data("kendoWindow");r.close()})},t.prototype.initEditDocBrowseHandlers=function(){var n=this;$(".helpDocLink").click(function(){n.docId=$(this).closest("ul").find(".helpDocLink").text();$.when(n.getHelpContent()).done(function(){n.setTinymceContent(n.doc.HtmlDoc);$("#helpNameId").val(n.doc.Name);$("#helpTagsId").val(n.doc.Tags);$("#helpPartnerId").val(n.doc.Partner);$("#helpUpdateBtn").length<=0&&n.prependUpdateButton()});var i=t.getBrowseHelpDocDomNode().data("kendoWindow");i.close()})},t.prototype.initCloudImgBrowseHandlers=function(){var i=this;$(".helpCloudImg").on("click",function(){var n=$(this).closest("ul").find(".helpCloudImg"),r=n[0].outerHTML.split("src=")[1].split(">")[0];i.insertTinymceContent('<p> <img class="imgClass" height="" width="" alt="" src= '+r+" /><\/p>");setTimeout(function(){i.reinitImageHandlers()},t.EVENT_HANDLER_TIMEOUT)});if(n.Utility.getUserID()==n.AppViewHelp.SCOTT_ID){$("#cloudImgBrowserDialog").prepend('<div id="imgHoverId" style="width:500px; height:40px; margin-left:20px; background-color:ghostwhite"><\/div>');$("#imgHoverId").show();$("#cloudImgBrowserDialog").scroll(function(){var n=$("#cloudImgBrowserDialog").scrollTop()+"px";$("#imgHoverId").css({top:n,position:"absolute"})});$(".helpCloudImg").hover(function(){var n=$(this).closest("ul").find(".helpCloudImg"),t=n[0].outerHTML.split("src=")[1].split(">")[0];$("#imgHoverId").html(t)},function(){$("#imgHoverId").html('<span style="color:green">Right-click for copy url to clipboard option (Ctrl+C then Enter or click OK)<\/span>')});$(".helpCloudImg").on("mousedown",function(n){var t=$(this).closest("ul").find(".helpCloudImg"),i=t[0].outerHTML.split("src=")[1].split(">")[0];switch(n.which){case 3:window.prompt("Copy to clipboard: Ctrl+C, Enter",i)}})}},t.prototype.reinitImageHandlers=function(){var r,n,t,i;for(this.checkDialogHeight(),r=tinymce.activeEditor,n=$(r.body).find(".imgClass"),n.css("cursor","context-menu"),t=0;t<n.length;t++){i=n[t];$(i).off();$(i).on("dblclick",function(){var n=$("#imgResizeDialog").data("kendoWindow");n&&(n.close(),$("#imgResizeDialog").remove())})}},t.prototype.checkDialogHeight=function(){var n=t.getAppHelpAddDomNode(),i=$("#main_editor").height();n.parent().height()>i-200&&n.parent().css({height:i-200});n.parent().css({top:t.APP_ADD_HELP_TOP})},t.APP_ADD_HELP_WIDTH=750,t.APP_ADD_HELP_HEIGHT=515,t.APP_ADD_HELP_MINWIDTH=200,t.APP_ADD_HELP_MINHEIGHT=300,t.APP_ADD_HELP_MAXWIDTH=1500,t.APP_ADD_HELP_MAXHEIGHT=1500,t.APP_ADD_HELP_TOP=100,t.APP_ADD_HELP_LEFT=50,t.IMG_BROWSER_WIDTH=570,t.IMG_BROWSER_HEIGHT=605,t.IMG_RESIZE_WIDTH=160,t.IMG_RESIZE_HEIGHT=170,t.DOC_BROWSER_WIDTH=360,t.DOC_BROWSER_HEIGHT=500,t.ADD_HELP_Z_INDEX=12500,t.EVENT_HANDLER_TIMEOUT_MAIN=3e3,t.EVENT_HANDLER_TIMEOUT=1e3,t.GLOBAL_ADD_APP_HELP_INDEX=0,t.GLOBAL_BROWSE_HELP_DOC_INDEX=0,t}();n.AppAddHelp=t}(Project||(Project={})),function(n){var t=function(){function t(){this.helpContent="";this.docHistory=[];this.docHistoryCurrentIndex=0;this.isDocHistoryAction=!1;this.activeDocId=""}return t.prototype.initMainBrowser=function(){var i=this,n=this,r;this.showHelpDialog();r="";$.when(this.getHelpContent(t.MAIN_BROWSER_DOC_ID)).done(function(){t.getAppHelpViewDomNode().html(i.helpContent);$("a[target='help_browser_iframe']").on("click",function(i){i.preventDefault();var r=$(this).attr("href");return n.activeDocId=r.split("docId=")[1],setTimeout(function(){n.loadDialogContentsAddHandlers()},t.EVENT_HANDLER_TIMEOUT),!0})});this.setHelpMenuMain()},t.prototype.loadDialogContentsAddHandlers=function(n){var u=this,i=this,r;n&&(this.activeDocId=n);r=t.getAppHelpIframeDomNode();r.length||(i.showDocIframeDialog(),r.html("Fetching help docs..."));$.when(this.getHelpContent(this.activeDocId)).done(function(){t.getAppHelpIframeDomNode().html(u.helpContent);$("a[target='help_iframe']").off();$("a[target='help_iframe']").on("click",function(n){n.preventDefault();var t=$(this).attr("href");i.activeDocId=t.split("docId=")[1];i.loadDialogContentsAddHandlers()});i.isDocHistoryAction||(i.docHistory.push(i.activeDocId),i.docHistoryCurrentIndex=i.docHistory.length-1);i.checkDialogHeight();i.setNavButtonStates();i.setHelpMenuDoc()})},t.prototype.showHelpDialog=function(){var r,i,u;n.Settings.notify("help open main",{helpTopic:"main"});var f=t.APP_VIEW_HELP_MINWIDTH,e=t.APP_VIEW_HELP_MINHEIGHT,o=t.APP_VIEW_HELP_MAXWIDTH,s=t.APP_VIEW_HELP_MAXHEIGHT,h=t.APP_VIEW_HELP_WIDTH,c=t.APP_VIEW_HELP_HEIGHT;$("body").append('<div class="helpStyles" id=appHelpOutputDialog'+t.GLOBAL_VIEW_HELP_MAIN_INDEX+"><\/div>");t.getAppHelpViewDomNode().kendoWindow({actions:["Close"],draggable:!0,width:h,maxHeight:s,maxWidth:o,minHeight:e,minWidth:f,modal:!1,pinned:!1,position:{top:100,left:50},deactivate:function(){this.destroy()},resizable:!0,title:"Help"});r=t.getAppHelpViewDomNode().data("kendoWindow");r.center();r.open();i=t.getAppHelpViewDomNode().parent();i.css("z-index",t.VIEW_HELP_Z_INDEX);i.css({left:$("#main_editor").width()-i.width()-50,top:50});u=t.getAppHelpViewDomNode();u.css({"margin-left":10,padding:0});$("div.helpStyles.k-window-content").css({"background-color":"transparent"})},t.prototype.getHelpContent=function(n){var i=this,t=$.Deferred(),r=this.GetAPIURI(),u="/AppHelp?partner=SVWebHelp&docId="+n,f=$.ajax({url:r+u,type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){i.helpContent=n[0].HtmlDoc;t.resolve(!0)},error:function(){console.log("Error getting doc from DB");t.resolve(!1)}});return t.promise()},t.prototype.GetAPIURI=function(){$.ajaxSetup({headers:{userID:n.Utility.getUserID(),TOKEN_HEADER:n.Settings.APIKEY}});return n.Settings.APIURI()},t.prototype.editHelpBrowserDialog=function(){var i=t.getAppHelpViewDomNode().data("kendoWindow"),r;i&&i.close();r=new n.AppAddHelp;r.showAppHelpInputDialog("57abe3e4-373c-462b-975a-fc1bafaad7e4")},t.prototype.editHelpDialogDoc=function(){var i=t.getAppHelpIframeDomNode().data("kendoWindow"),r;i&&(this.docHistory=[],i.close());r=new n.AppAddHelp;r.showAppHelpInputDialog(this.activeDocId)},t.prototype.closeHelpBrowserDialog=function(){var n=t.getAppHelpViewDomNode().data("kendoWindow");n&&n.close()},t.prototype.closeHelpDialogDoc=function(){var n=t.getAppHelpIframeDomNode().data("kendoWindow");n&&(this.docHistory=[],n.close())},t.prototype.createHelpMenuBrowser=function(){var r=this,f=function(){r.closeHelpBrowserDialog()},e=function(){r.editHelpBrowserDialog()},u,i;this.helpMenuMain||(u="<b>Help Actions<\/b> ",i=new SVWebContextMenu.MenuContent(this,u),n.Utility.getUserID()==t.SCOTT_ID&&(i.addMenuElement("Edit",e),i.addSeparatorToMenu()),i.addMenuElement("Close",f),i.addSeparatorToMenu(),this.helpMenuMain=SVWebContextMenu.MenuHelper.createMenu(i))},t.prototype.createHelpMenuDialogDoc=function(){var r=this,f=function(){r.closeHelpDialogDoc()},e=function(){r.editHelpDialogDoc()},u,i;this.helpMenuDoc||(u="<b>Help Actions<\/b> ",i=new SVWebContextMenu.MenuContent(this,u),n.Utility.getUserID()==t.SCOTT_ID&&(i.addMenuElement("Edit",e),i.addSeparatorToMenu()),i.addMenuElement("Close",f),i.addSeparatorToMenu(),this.helpMenuDoc=SVWebContextMenu.MenuHelper.createMenu(i))},t.prototype.setHelpMenuMain=function(){this.createHelpMenuBrowser();this.helpMenuMain.bindMenuTo(t.getAppHelpViewDomNode())},t.prototype.setHelpMenuDoc=function(){this.createHelpMenuDialogDoc();this.helpMenuDoc.bindMenuTo(t.getAppHelpIframeDomNode())},t.prototype.showDocIframeDialog=function(i,r){var u,o;n.Settings.notify("help open topic",{helpTopic:"any"});u=this;$("body").append('<div class="helpStyles" id=appHelpIframeOutputDialog'+t.GLOBAL_VIEW_HELP_IFRAME_INDEX+"><\/div>");var s=i?i:50,h=r?r:50,e=t.getAppHelpIframeDomNode(),f=e.data("kendoWindow");if(f)i||r||f.center(),f.open();else{e.kendoWindow({actions:["Arrow-w","Arrow-e","Close"],draggable:!0,modal:!1,pinned:!1,position:{top:s,left:h},deactivate:function(){this.destroy()},close:c,resizable:!0,title:"Help",maxHeight:t.DOC_IFRAME_MAXHEIGHT,width:t.DOC_IFRAME_WIDTH});function c(){u.docHistory=[]}f=e.data("kendoWindow");f.wrapper.find(".k-i-arrow-w").hide();f.wrapper.find(".k-i-arrow-e").hide();f.wrapper.find(".k-i-arrow-w").click(function(n){u.isDocHistoryAction=!0;u.docHistoryCurrentIndex>0&&u.docHistoryCurrentIndex--;u.activeDocId=u.docHistory[u.docHistoryCurrentIndex];u.docHistory.push(u.activeDocId);u.loadDialogContentsAddHandlers();n.preventDefault()});f.wrapper.find(".k-i-arrow-e").click(function(n){u.isDocHistoryAction=!0;u.docHistoryCurrentIndex<u.docHistory.length-1&&u.docHistoryCurrentIndex++;u.activeDocId=u.docHistory[u.docHistoryCurrentIndex];u.docHistory.push(u.activeDocId);u.loadDialogContentsAddHandlers();n.preventDefault()});i||r||f.center();f.open()}o=n.AppAddHelp.ADD_HELP_Z_INDEX+100;e.parent().css({"z-index":o});e.parent().css({top:100})},t.prototype.checkDialogHeight=function(){var n=t.getAppHelpIframeDomNode(),i=$("#main_editor").height();n.parent().height()>i-200&&n.parent().css({height:i-200})},t.prototype.setNavButtonStates=function(){var u=t.getAppHelpIframeDomNode(),n=u.data("kendoWindow"),i=n.wrapper.find(".k-i-arrow-w"),r=n.wrapper.find(".k-i-arrow-e");r.show();i.show();this.isDocHistoryAction=!1;this.docHistoryCurrentIndex>=this.docHistory.length-1&&r.hide();this.docHistoryCurrentIndex<1&&i.hide()},t.getAppHelpViewDomNode=function(){return $("#appHelpOutputDialog"+t.GLOBAL_VIEW_HELP_MAIN_INDEX)},t.getAppHelpIframeDomNode=function(){return $("#appHelpIframeOutputDialog"+t.GLOBAL_VIEW_HELP_IFRAME_INDEX)},t.APP_VIEW_HELP_WIDTH=225,t.APP_VIEW_HELP_HEIGHT=400,t.APP_VIEW_HELP_MINWIDTH=200,t.APP_VIEW_HELP_MINHEIGHT=200,t.APP_VIEW_HELP_MAXWIDTH=1500,t.APP_VIEW_HELP_MAXHEIGHT=1500,t.DOC_IFRAME_WIDTH=900,t.DOC_IFRAME_HEIGHT=500,t.DOC_IFRAME_MAXHEIGHT=800,t.GLOBAL_VIEW_HELP_IFRAME_INDEX=0,t.GLOBAL_VIEW_HELP_MAIN_INDEX=0,t.EVENT_HANDLER_TIMEOUT=1e3,t.VIEW_HELP_Z_INDEX=12500,t.MAIN_BROWSER_DOC_ID="57abe3e4-373c-462b-975a-fc1bafaad7e4",t.SCOTT_ID="e5ce2305-99f6-4836-94b5-efa085b563fe",t}();n.AppViewHelp=t}(Project||(Project={})),function(n){var i=function(){function n(){}return n}(),t;n.AppHelpDoc=i;t=function(){function n(){}return n}();n.EmbeddedObjRef=t}(Project||(Project={})),function(n){var t=function(){function t(){this.isSpinnerActive=!1}return t.prototype.showSpinner=function(){var n=this,i=$("#loading_dmb_spinner");this.isSpinnerActive=!0;setTimeout(function(){var t=$(DMB_WINDOW);$(i).css({top:t.offset().top+100,left:t.offset().left+t.width()/2-75});n.isSpinnerActive&&$(i).fadeIn("slow")},t.minSpin);setTimeout(function(){n.isSpinnerActive&&($(i).fadeOut("slow"),n.isSpinnerActive=!1)},t.maxSpin)},t.prototype.hideSpinner=function(){$("#loading_dmb_spinner").fadeOut("slow");this.isSpinnerActive=!1},t.prototype.setCookie=function(n,t,i){var r,u;i?(r=new Date,r.setTime(r.getTime()+i*864e5),u="; expires="+r.getUTCDate().toString()):u="";document.cookie=n+"="+t+u+"; path=/"},t.prototype.getCookie=function(n){for(var t,r=n+"=",u=document.cookie.split(";"),i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1,t.length);if(t.indexOf(r)==0)return t.substring(r.length,t.length)}return null},t.prototype.deleteCookie=function(n){this.setCookie(n,"",-1)},t.prototype.endsWith=function(n,t){return n.indexOf(t,n.length-t.length)!==-1},t.prototype.startsWith=function(n,t){return n.indexOf(t)==0},t.prototype.GetCategoryFromDefaultName=function(n){return{resistor_datasheet:"Resistor",inductor_datasheet:"Inductor",capacitor_datasheet:"Capacitor",capacitor_electrolytic_datasheet:"Capacitor (Electrolytic)",diode_datasheet:"Diode",opamp_3pin_datasheet:"Opamp (3-pin)",opamp_5pin_datasheet:"Opamp (5-pin)",linear_regulator_datasheet:"Linear Regulator",mosfet_n_datasheet:"MOSFET (N)",mosfet_p_datasheet:"MOSFET (P)",tline_2conductor_datasheet:"Tline (2-conductor)",zener_diode_datasheet:"Zener Diode",bjt_npn_datasheet:"BJT (NPN)",bjt_pnp_datasheet:"BJT (PNP)",optocoupler_datasheet:"Optocoupler",fuse_datasheet:"Fuse",lamp_incandescent_datasheet:"Lamp (Incandescent)"}[n]},t.prototype.GetSplashDisplayCategoryFromDefaultName=function(n){return{resistor_datasheet:"Resistor",inductor_datasheet:"Inductor",capacitor_datasheet:"Capacitor",capacitor_electrolytic_datasheet:"Capacitor (+/-)",diode_datasheet:"Diode",opamp_3pin_datasheet:"Opamp (3-pin)",opamp_5pin_datasheet:"Opamp (5-pin)",linear_regulator_datasheet:"Linear Regulator",mosfet_n_datasheet:"MOSFET (N)",mosfet_p_datasheet:"MOSFET (P)",tline_2conductor_datasheet:"Tline (2-conductor)",zener_diode_datasheet:"Zener Diode",bjt_npn_datasheet:"BJT (NPN)",bjt_pnp_datasheet:"BJT (PNP)",optocoupler_datasheet:"Optocoupler",fuse_datasheet:"Fuse",lamp_incandescent_datasheet:"Lamp"}[n]},t.prototype.GetDefaultNameFromCategory=function(n){return{Resistor:"resistor_datasheet",Inductor:"inductor_datasheet",Capacitor:"capacitor_datasheet","Capacitor (Electrolytic)":"capacitor_electrolytic_datasheet",Diode:"diode_datasheet","Opamp (3-pin)":"opamp_3pin_datasheet","Opamp (5-pin)":"opamp_5pin_datasheet","Linear Regulator":"linear_regulator_datasheet","MOSFET (N)":"mosfet_n_datasheet","MOSFET (P)":"mosfet_p_datasheet","Tline (2-conductor)":"tline_2conductor_datasheet","Zener Diode":"zener_diode_datasheet","BJT (NPN)":"bjt_npn_datasheet","BJT (PNP)":"bjt_pnp_datasheet",Optocoupler:"optocoupler_datasheet",Fuse:"fuse_datasheet","Lamp (Incandescent)":"lamp_incandescent_datasheet"}[n]},t.prototype.GetCategoryFromBaseName=function(n){return{dmb_resistor:"Resistor",dmb_inductor:"Inductor",dmb_capacitor:"Capacitor",dmb_capacitor_electrolytic:"Capacitor (Electrolytic)",dmb_diode:"Diode",dmb_opamp_3pin:"Opamp (3-pin)",dmb_opamp_5pin:"Opamp (5-pin)",dmb_linear_regulator:"Linear Regulator",dmb_mosfet_n:"MOSFET (N)",dmb_mosfet_p:"MOSFET (P)",dmb_tline_2conductor:"Tline (2-conductor)",dmb_zener_diode:"Zener Diode",dmb_bjt_npn:"BJT (NPN)",dmb_bjt_pnp:"BJT (PNP)",dmb_optocoupler:"Optocoupler",dmb_fuse:"Fuse",dmb_lamp_incandescent:"Lamp (Incandescent)"}[n]},t.prototype.DmbGetPropertyType=function(n){return{integer:"integer",real:"real",std_logic:"std_logic",boolean:"boolean",bit:"bit",time:"time",integer_vector:"integer_vector",real_vector:"real_vector",std_logic_vector:"std_logic_vector",boolean_vector:"boolean_vector",bit_vector:"bit_vector",time_vector:"time_vector",energy:"real",power:"real",periodicity:"real",real_across:"real",real_through:"real",energy_vector:"real_vector",power_vector:"real_vector",periodicity_vector:"real_vector",real_across_vector:"unspecified_vector'across;",real_through_vector:"unspecified_vector'through;",voltage:"real",current:"real",charge:"real",resistance:"real",conductance:"real",capacitance:"real",mmf:"real",electric_flux:"real",electric_flux_density:"real",electric_field_strength:"real",magnetic_flux:"real",magnetic_flux_density:"real",magnetic_field_strength:"real",inductance:"real",reluctance:"real",voltage_vector:"electrical_vector'across;",current_vector:"electrical_vector'through;",mmf_vector:"magnetic_vector'across;",magnetic_flux_vector:"magnetic_vector'through;",charge_vector:"real_vector",resistance_vector:"real_vector",conductance_vector:"real_vector",capacitance_vector:"real_vector",electric_flux_vector:"real_vector",electric_flux_density_vector:"real_vector",electric_field_strength_vector:"real_vector",magnetic_flux_density_vector:"real_vector",magnetic_field_strength_vector:"real_vector",inductance_vector:"real_vector",reluctance_vector:"real_vector",displacement:"real",force:"real",velocity:"real",acceleration:"real",mass:"real",stiffness:"real",damping:"real",momentum:"real",angle:"real",torque:"real",angular_velocity:"real",angular_acceleration:"real",moment_inertia:"real",angular_momentum:"real",angular_stiffness:"real",angular_damping:"real",displacement_vector:"translational_vector'across;",force_vector:"translational_vector'through;",velocity_vector:"translational_velocity_vector'across;",force_velocity_vector:"translational_velocity_vector'through;",angle_vector:"rotational_vector'across;",torque_vector:"rotational_vector'through;",angular_velocity_vector:"rotational_velocity_vector'across;",torque_velocity_vector:"rotational_velocity_vector'through;",acceleration_vector:"real_vector",mass_vector:"real_vector",stiffness_vector:"real_vector",damping_vector:"real_vector",momentum_vector:"real_vector",angular_acceleration_vector:"real_vector",moment_inertia_vector:"real_vector",angular_momentum_vector:"real_vector",angular_stiffness_vector:"real_vector",angular_damping_vector:"real_vector",illuminance:"real",luminous_flux:"real",luminous_intensity:"real",irradiance:"real",luminous_intensity_vector:"radiant_vector'across;",luminous_flux_vector:"radiant_vector'through;",illuminance_vector:"real_vector",irradiance_vector:"real_vector",temperature:"real",heat_flow:"real",thermal_capacitance:"real",thermal_resistance:"real",thermal_conductance:"real",temperature_vector:"thermal_vector'across;",heat_flow_vector:"thermal_vector'through;",thermal_capacitance_vector:"real_vector",thermal_resistance_vector:"real_vector",thermal_conductance_vector:"real_vector",pressure:"real",vflow_rate:"real",mass_flow_rate:"real",volume:"real",density:"real",viscosity:"real",fresistance:"real",fconductance:"real",fcapacitance:"real",inertance:"real",cfresistance:"real",cfcapacitance:"real",cfinertance:"real",cfconductance:"real",pressure_vector:"fluidic_vector'across;",vflow_rate_vector:"fluidic_vector'through;",mass_flow_rate_vector:"compressible_fluidic_vector'through;",volume_vector:"real_vector",density_vector:"real_vector",viscosity_vector:"real_vector",fresistance_vector:"real_vector",fconductance_vector:"real_vector",fcapacitance_vector:"real_vector",inertance_vector:"real_vector",cfresistance_vector:"real_vector",cfconductance_vector:"real_vector",cfcapacitance_vector:"real_vector",cfinertance_vector:"real_vector"}[n]},t.prototype.GetAPIURI=function(){$.ajaxSetup({headers:{TOKEN_HEADER:Project.Settings.APIKEY}});return Project.Settings.APIURI()},t.prototype.GetScaledImage=function(n){for(var i="",r="",f='/(viewbox="")/',u=n.indexOf("width=")+7,t=n.indexOf("height=")+8;!isNaN(n.charAt(u));)i=i+n.charAt(u),u++;while(!isNaN(n.charAt(t)))r=r+n.charAt(t),t++;return n.match(f)?n.replace(f,"viewbox=0,0,"+i+","+r):[n.slice(0,t+1),' viewbox="0,0,'+i+","+r+'" ',n.slice(t+1)].join("")},t.prototype.alphaCompare=function(n,t){return n==null?-1:t==null?1:n.Name<t.Name?-1:n.Name>t.Name?1:0},t.prototype.sign=function(n){return typeof n=="number"?n?n<0?-1:1:n===n?0:NaN:NaN},t.prototype.getLegalNameFromTitle=function(n){name=n.replace(/[^a-zA-Z0-9]/g,"_").replace(/_+/g,"_");name=name.replace(/^_+/,"");name=name.replace(/_+$/,"");var t=name.charAt(0);return name==""||t.match(/[a-zA-Z]/i)||(name="model_"+name),name},t.prototype.updateCurveDisplays=function(){for(var c,l,u,i,a,v,e=[],o=[],rt=$("#dmbCurveData").data("kendoGrid"),r=rt.dataSource.data(),s=new n.PropertyFormatter,p=0,w=0,t=0;t<r.length;t++)p=s.IsSIPrefix(r[t].independent.toString())?s.SIUnitPrefixes2Double(r[t].independent.toString()):r[t].independent,w=s.IsSIPrefix(r[t].dependent.toString())?s.SIUnitPrefixes2Double(r[t].dependent.toString()):r[t].dependent,e.push(p),o.push(w);var b=0,y=25,lt=document.getElementById("dmbCurveData"),at=document.getElementById("dmbCurveCanvasDiv"),u=document.getElementById("dmbCurveCanvas"),k=245,ut=295-y;$("#dmbCurveCanvasDiv").css({height:k});$("#dmbCurveCanvas").css({height:k-y,width:ut,"margin-left":y});var ft=u.width*.95,et=ft-b,d=0,ot=u.height*.95,st=ot-d,ht=this.getArrayMax(e),g=this.getArrayMin(e),ct=this.getArrayMax(o),nt=this.getArrayMin(o),tt=0,it=0,f=[],h=[];for(c=0;c<e.length;c++)tt=(e[c]-g)/(ht-g),f.push(b+et*tt);for(l=0;l<o.length;l++)it=(o[l]-nt)/(ct-nt),h.push(d+st*(1-it));if(u=document.getElementById("dmbCurveCanvas"),u.getContext)for(i=u.getContext("2d"),i.clearRect(0,0,u.width,u.height),a=8,v=8,i.fillStyle="rgba(200, 0, 0, 1.0)",i.strokeStyle="#0000ff",t=0;t<f.length;t++)i.fillRect(f[t],h[t],a,v),t<f.length-1&&(i.beginPath(),i.moveTo(f[t]+a/2,h[t]+v/2),i.lineTo(f[t+1]+a/2,h[t+1]+v/2),i.stroke())},t.prototype.getArrayMax=function(n){return Math.max.apply(Math,n)},t.prototype.getArrayMin=function(n){return Math.min.apply(Math,n)},t.prototype.placeModal=function(n){var u=$("#"+n),i=550,r=400,t=this.getDmbBoundingBox(),e=Math.round(t.x+t.width/4-i/2),f=Math.round(t.y+t.height/4-r/2);u.css({position:"absolute",top:f+"px",width:i+"px","max-height":r+"px"})},t.prototype.getDmbBoundingBox=function(){var n=$(DMB_WINDOW);return{x:n.offset().left,y:n.offset().top,width:n.width(),height:n.height()}},t.prototype.showValidationDialog=function(n,t){var i=this.getDmbBoundingBox(),r=i.x+i.width/2-300,u=i.y+i.height/2-30,f=new Project.MultiBtnModalDialog(n,t,["OK"],r,u);f.queryUser()},t.prototype.doesDataSourceHaveChanges=function(n){var t=!1;return $.each(n._data,function(){this.dirty==!0&&(t=!0)}),n._destroyed.length>0&&(t=!0),t},t.minSpin=1e3,t.maxSpin=15e3,t}();n.Helpers=t}(Dmb||(Dmb={})),function(n){var t=function(){function n(){}return n.prototype.AnimateTB=function(){$("#dmbTestBench").slideToggle(500);$("#TbImage").fadeToggle(500)},n.prototype.crossHighlight=function(){$("#typeModelPartNum").hover(function(){$("#dmbPartNumberId").css({"background-color":"lightblue"})},function(){$("#dmbPartNumberId").css({"background-color":"white"})});$("#typeModelComments").hover(function(){$("#dmbModelCommentsId").css({"background-color":"lightblue"})},function(){$("#dmbModelCommentsId").css({"background-color":"white"})});$("#preloadComboBox").hover(function(){$("#dmbComboBoxControlId").css({"background-color":"lightblue"})},function(){$("#dmbComboBoxControlId").css({"background-color":"transparent"})});$("#ratingsVal").hover(function(){$(".gridRatingsTypEditable").css({"background-color":"lightblue"})},function(){var n=$("#ratingsGrid").data("kendoGrid");n.dataSource.read()});$("#elecMin").hover(function(){$(".gridElectricalMinEditable").css({"background-color":"lightblue"})},function(){var n=$("#electricalGrid").data("kendoGrid");n.dataSource.read()});$("#elecTyp").hover(function(){$(".gridElectricalTypEditable").css({"background-color":"lightblue"})},function(){var n=$("#electricalGrid").data("kendoGrid");n.dataSource.read()});$("#elecMax").hover(function(){$(".gridElectricalMaxEditable").css({"background-color":"lightblue"})},function(){var n=$("#electricalGrid").data("kendoGrid");n.dataSource.read()});$("#distSettings").hover(function(){for(var r=$("#electricalGrid").data("kendoGrid"),t=r.dataSource.data(),i=[],n=0;n<t.length;n++)i.push("Parameter = "+t[n].Name+" Distribution = "+t[n].DistType);alert(i)},function(){})},n}();n.Animation=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.animation=new n.Animation;this.help=new n.Help;this.toolTips=new n.ToolTips;this.helpers=new n.Helpers;this.categoryModelsComboBox=new n.CategoryModelsComboBox;this.toolbar=new n.Toolbar;this.propertyGrids=new n.PropertyGrids;this.dataManager=n.DataManager.getInstance()}return t.prototype.DmbModelPageManager=function(t){var i,r;$("#dmbTestBench").hide();$("#TbImage").hide();$("#lessFormHelp").hide();$("#InstructionsRow").hide();$("#additionalInstructionsText").hide();$("#stillLessFormHelp").hide();$("#lessModelInfo").hide();$("#moreModelInfoRow").hide();$("#modelDetails").hide();$("#dmbTestButton").hide();i=$("#dmbPartNumberId");i.focusout(function(){i.val()?i.css({"border-color":"black"}):i.css({"border-color":"red"})});this.help.addModelPageHelpToDom();this.animation.crossHighlight();this.dataManager.isModelUpdate=!1;this.toolTips.DmbHoverFormToolTips();$("#modelDetails").parent().css("z-index","12600");this.dataManager.compInfoData=null;this.dataManager.isUpdated=!1;r=json_parse(t);r&&(this.dataManager.activeNameOrPartNum=r);this.GetSymMdlFromServer(this.dataManager.activeId,this.dataManager.library,this.dataManager.activeNameOrPartNum);this.toolTips.DmbHoverPropGridToolTips();this.dataManager.library==n.LIBRARY.UserLib?$("#dmbDelete").show():$("#dmbDelete").hide();this.toolbar.ModelsMenuLink();this.help.HelpButtons()},t.prototype.GetSymMdlFromServer=function(t,i,r){var l=this.helpers.GetAPIURI(),e,o,u,f;if(i==n.LIBRARY.UserLib){for(e=this.dataManager.usrDsArray,u=null,f=0;f<e.length;f++)e[f].PartNumber==r&&(u=e[f]);$("#dmbPartNumberId").val(u.PartNumber);$("#dmbModelCommentsId").val(u.Comments);this.propertyGrids.DmbPropertyGrids(u);this.getModelsByCategory(u);this.dataManager.activeCategory=this.helpers.GetCategoryFromBaseName(u.BaseName)}else{for(o=this.dataManager.mgcDsArray,u=null,f=0;f<o.length;f++)o[f].Name==r&&(u=o[f]);if(this.propertyGrids.DmbPropertyGrids(u),this.getModelsByCategory(u),this.dataManager.activeCategory=this.helpers.GetCategoryFromBaseName(u.BaseName),this.dataManager.isModelSaved==!0){this.dataManager.isModelSaved=!1;var s=this.helpers.getDmbBoundingBox(),h=s.x+s.width/2-300,c=s.y+s.height/2-30;this.confirm1BtnDialog=new Project.MultiBtnModalDialog("Component Saved","Your component can be accessed using the standard Component Browser. You can now: <br/> - Click OK and create another component using the Datasheet Model Builder. <br/> - Click OK, close the main Datasheet Model Builder window and continue working. <br/>",["OK"],h,c);this.confirm1BtnDialog.queryUser()}}},t.prototype.getModelsByCategory=function(n){var t=this.dataManager.usrDsArray,r=[],i;if(t&&t.length>0)for(i=0;i<t.length;i++)t[i].BaseName==n.BaseName&&t[i].Author==Project.Settings.UUID&&r.push(t[i]);this.categoryModelsComboBox.DmbCreateComboBox(r)},t}();n.ModelPageManager=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.dmbCompCounts=[];this.APIURI="";this.mgcDatasheetCompsArray=[];this.usrDatasheetCompsArray=[];this.author="";this.helpers=new n.Helpers;this.toolTips=new n.ToolTips;this.APIURI=this.helpers.GetAPIURI();this.author=Project.Settings.UUID;this.dataManager=n.DataManager.getInstance();this.help=new n.Help}return t.prototype.DmbModelNavigation=function(){var n=this,i,t;this.dataManager.isModelSaved=!1;this.dataManager.isModelUpdate=!1;this.dataManager.comboBoxIndex=0;this.dataManager.activeNameOrPartNum=null;this.help.addSplashScreenHelpToDom();$("#mgcView").show();$("#categoryDiv").hide();$("#categoryWindow").hide();$("#usrDiv").hide();$("#lessMenuHelp").hide();$("#selectModelInstructionsRow").hide();i=$("#categoryWindow").kendoWindow({actions:["Close"],modal:!0,title:"Create Model From:"}).data("kendoWindow");$("#moreMenuHelp").click(function(){$("#moreMenuHelp").hide();$("#lessMenuHelp").show();$("#selectModelInstructionsRow").slideDown()});$("#lessMenuHelp").click(function(){$("#moreMenuHelp").show();$("#lessMenuHelp").hide();$("#selectModelInstructionsRow").slideUp()});this.dataManager.mgcDsArray.length==0?(t=this.getMgcDatasheetModels(),$.when(t).done(function(){n.mgcDataSource=new kendo.data.DataSource({data:n.mgcDatasheetCompsArray});n.mgcDataSource.read();n.initiateGetUserModels()})):(this.mgcDatasheetCompsArray=this.dataManager.mgcDsArray,this.mgcDatasheetCompsArray.sort(this.helpers.alphaCompare),this.mgcDataSource=new kendo.data.DataSource({data:this.mgcDatasheetCompsArray}),this.mgcDataSource.read(),this.initiateGetUserModels())},t.prototype.getMgcDatasheetModels=function(){var n=this,t=jQuery.Deferred();return this.mgcDatasheetCompsArray.length=0,$.ajax(this.APIURI+"/components/?library=SVWebLib&category=Datasheet Models SVWebLib").done(function(i){n.mgcDatasheetCompsArray=i;n.dataManager.mgcDsArray=i;n.mgcDatasheetCompsArray.sort(n.helpers.alphaCompare);t.resolve()}).fail(function(n,i){t.resolve();alert("Error retrieving all components : "+i)}),t.promise()},t.prototype.initiateGetUserModels=function(){var n=this,t=this.getUsrDatasheetModels();$.when(t).done(function(){var r=n.mgcDatasheetCompsArray.length,t,i;for(r<15&&alert("arraySize is < 15: debug this in DmbModelNavigation");r--;)n.dmbCompCounts.push(1);for(t=0;t<n.usrDatasheetCompsArray.length;t++)for(i=0;i<n.mgcDatasheetCompsArray.length;i++)n.usrDatasheetCompsArray[t].BaseName==n.mgcDatasheetCompsArray[i].BaseName&&n.usrDatasheetCompsArray[t].Author==n.author&&n.dmbCompCounts[i]++;n.RenderListView()})},t.prototype.getUsrDatasheetModels=function(){var n=this,t=jQuery.Deferred();return this.usrDatasheetCompsArray.length=0,$.ajax(this.APIURI+"/components/?library=UserLib&category=DMB User Components").done(function(i){n.usrDatasheetCompsArray=i;n.dataManager.usrDsArray=i;n.usrDatasheetCompsArray.sort(n.helpers.alphaCompare);t.resolve()}).fail(function(n,i){t.resolve();alert("Error retrieving all components : "+i)}),t.promise()},t.prototype.RenderListView=function(){var i=this,s=kendo.template($("#mgcTemplate").html()),u=$("#mgcView").kendoListView({dataSource:this.mgcDataSource,selectable:!0,template:s}),t,o;this.toolTips.DmbHoverCategoryToolTips(u,this.mgcDataSource);u.delegate(".btn","click",function(t){$(".qtip").remove();var f=$(this),u=$(this).closest(".btn").index(),r=i.mgcDataSource.view()[u];i.dataManager.activeNameOrPartNum=r.Name;i.dataManager.activeCategory=i.helpers.GetCategoryFromDefaultName(r.Name);i.dataManager.activeId=r.ComponentId;i.dataManager.library=n.LIBRARY.SVWebLib;$.ajaxSetup({cache:!0});$("#dmbApp").load("/Dmb/DmbSymMdlView/?symMdlName="+r.Name);t.preventDefault()});var h=$("#mgcView").data("kendoListView"),r=h.element.children(),f=this.mgcDataSource.data(),e="";for(t=0;t<r.length;t++)e=this.helpers.GetSplashDisplayCategoryFromDefaultName(f[t].Name),r[t].childNodes[1].innerHTML='<span class="badge badge-info">'+this.dmbCompCounts[t]+"<\/span>",o=this.helpers.GetScaledImage(f[t].Img),r[t].childNodes[3].innerHTML='<span class="modelImg">'+o+"<\/span>",r[t].childNodes[5].innerHTML='<h6 id="dmbCategory"><span><strong>'+e+"<\/strong><\/span><\/h6>"},t}();n.ModelNavigation=t}(Dmb||(Dmb={})),function(n){var t=function(){function n(){}return n.prototype.DmbHoverCategoryToolTips=function(n,t){var i=this;n.delegate(".btn","mouseenter mouseleave",function(n){var u=$(this),i=$(this).closest(".btn").index(),r=t.view()[i];$(this).qtip({overwrite:!1,content:r.DescriptionToolTip,position:{at:"bottom right",adjust:{x:-20,y:-10}},show:{event:n.type,ready:!0},style:{classes:"svw-tooltip"}})})},n.prototype.DmbHoverFormToolTips=function(){var n=this;$(".dmbTrigger").on("mouseenter mouseleave",function(n){$(this).qtip({overwrite:!1,content:$($(this).attr("data-tooltip")),position:{at:"bottom right",adjust:{x:-20,y:-10}},show:{event:n.type,ready:!0},style:{classes:"svw-tooltip"}})})},n.prototype.DmbHoverPropGridToolTips=function(){$("#electricalGrid").on("mouseenter mouseleave","td",function(n){var t=$("#electricalGrid").data("kendoGrid"),r=n.currentTarget.cellIndex,u=n.currentTarget.parentNode.rowIndex,i;r==0&&(i=t.dataItem(n.currentTarget.parentNode).get("Name")+": "+t.dataItem(n.currentTarget.parentNode).get("Description"),$(this).qtip({overwrite:!1,content:i,position:{at:"bottom right",adjust:{x:-20,y:-10}},show:{event:n.type,ready:!0},style:{classes:"svw-tooltip"}}))});$("#ratingsGrid").on("mouseenter mouseleave","td",function(n){var t=$("#ratingsGrid").data("kendoGrid"),r=n.currentTarget.cellIndex,u=n.currentTarget.parentNode.rowIndex,i;r==0&&(i=t.dataItem(n.currentTarget.parentNode).get("Name")+": "+t.dataItem(n.currentTarget.parentNode).get("Description"),$(this).qtip({overwrite:!1,content:i,position:{at:"bottom right",adjust:{x:-20,y:-10}},show:{event:n.type,ready:!0},style:{classes:"svw-tooltip"}}))})},n}();n.ToolTips=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){var t=this;this.isSaving=!1;this.isSaved=!1;this.isDeleting=!1;this.helpers=new n.Helpers;this.dataManager=n.DataManager.getInstance();this.formValidation=new n.FormValidation;this.standardValueFormatter=new n.StandardValueFormatter;this.propertyFormatter=new n.PropertyFormatter;$("#dmbSaveButton").click(function(){t.isSaving||(t.isSaving=!0,t.Save())});$("#dmbCancelButton").click(function(){t.Cancel()});$("#dmbDelete").click(function(){t.isDeleting||(t.isDeleting=!0,t.Destroy())})}return t.prototype.Cancel=function(){var t=600,n=this.helpers.getDmbBoundingBox(),i=n.x+n.width/2-t/2,r=n.y+n.height/2-30;this.confirm2BtnDialog=new Project.MultiBtnModalDialog("Clear Unsaved Changes Request","<p>You are attempting to clear changes that have not been saved. You can now: <\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Click OK to clear the changes. All unsaved model values will be lost. <\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Click Cancel to cancel the operation. <\/p>",["OK","Cancel"],i,r);$("#twoBtnModalDialog").css({width:t});jQuery.when(this.confirm2BtnDialog.queryUser()).done(function(n){var t,i,r,u;n==Project.BUTTON.BTN1&&(t=$("#electricalGrid").data("kendoGrid"),t.cancelChanges(),i=$("#ratingsGrid").data("kendoGrid"),i.cancelChanges(),r=$("#dmbPartNumberId"),r.val(""),u=$("#dmbModelCommentsId"),u.val(""))})},t.prototype.Save=function(){var f=this,u=this.dataManager.usrDsArray,i=!1,e,o,t;if(this.dataManager.isModelUpdate=!1,e=$("#dmbPartNumberId").val(),o=this.helpers.getLegalNameFromTitle(e),this.dataManager.library==n.LIBRARY.SVWebLib)i=!1;else for(t=0;t<u.length;t++)if(u[t].ComponentId==this.dataManager.activeId&&u[t].Name==o){i=!0;break}else i=!1;if(i){var s=600,r=this.helpers.getDmbBoundingBox(),h=r.x+r.width/2-s/2,c=r.y+r.height/2-30;this.confirm2BtnDialog=new Project.MultiBtnModalDialog("Overwrite Component Request","<p>You are attempting to overwrite an existing component. You can now: <\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Click OK to overwrite this component. The component will be updated to the currently displayed values. <p><i class='glyphicon glyphicon-arrow-right'><\/i> Click Cancel to avoid the overwrite, then type in a new Part # and click Save. <\/p>",["OK","Cancel"],h,c);$("#twoBtnModalDialog").css({width:s});jQuery.when(this.confirm2BtnDialog.queryUser()).done(function(n){n==Project.BUTTON.BTN1&&(f.dataManager.isModelUpdate=!0,setTimeout(function(){f.SaveContinue()},1e3))})}else this.dataManager.isModelUpdate=!1,this.SaveContinue()},t.prototype.SaveContinue=function(){var o=this,i,r,u,f,e,t,n;if(this.isSaved=!1,i=!1,r=!1,!this.formValidation.validateForm()){this.isSaving=!1;return}if(u=this.formValidation.validateElectricalRow(),f=this.formValidation.validateRatingsRow(),u||f){this.isSaving=!1;return}for(e=$("#electricalGrid").data("kendoGrid"),t=e.dataSource.data(),n=0;n<t.length;n++)t[n].Minimum&&t[n].Maximum&&(i=!0);i&&this.DistributionDialog();this.isSaved||this.getNewCompData();$("#closeModal").click(function(){r=!1});$("#saveModal").click(function(){for(var n,f=$("#electricalGrid").data("kendoGrid"),i=f.dataSource.data(),u=$("#radioButtonDiv :checked"),t=0;t<u.length;t++)for(n=0;n<i.length;n++)u[t].name==i[n].Name&&(i[n].DistType=u[t].value);o.getNewCompData();r=!0})},t.prototype.getNewCompData=function(){var e,r,n,u,t;if(this.dataManager.isUpdated==!1){this.dataManager.isUpdated=!0;var i=[],o=$("#electricalGrid").data("kendoGrid"),f=o.dataSource.data();for(n=0;n<f.length;n++)i.push(f[n]);for(e=$("#ratingsGrid").data("kendoGrid"),r=e.dataSource.data(),n=0;n<r.length;n++)i.push(r[n]);u=$("#dmbCurveData").data("kendoGrid");u&&(this.pwlData=u.dataSource.data());t={};t.partNumber=$("#dmbPartNumberId").val();t.modelComments=$("#dmbModelCommentsId").val();t.modelName=this.helpers.getLegalNameFromTitle($("#dmbPartNumberId").val());var s=this.helpers.GetAPIURI();this.SaveToServer(this.dataManager.compInfoData,t,i)}else this.dataManager.isUpdated=!1},t.prototype.SaveToServer=function(n,t,i){var r;this.dataFromDB=n;this.dataFromForm=t;this.componentProps=i;r=this;this.helpers.showSpinner();var o=n.BaseName,u=null,s="",f="",e=this.helpers.GetAPIURI();$.ajax({url:e+"/components/?library=SVWebLib&category=Datasheet Model Templates",dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){for(var t=0;t<n.length;t++)o==n[t].BaseName&&(u=n[t]);s=JSON.stringify(u.Categories);$.ajax({url:e+"/components/?library=SVWebLib&componentId="+u.ComponentId,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){f=r.UpdateComponentSource(n[0]);r.PostToServer(f)},error:function(n){alert("No success for getting dmb_ model template data. x = "+n.responseText)}})},error:function(n){alert("No success for getting dmb_ model template data. x = "+n.responseText)}})},t.prototype.UpdateComponentSource=function(n){for(var y=n.Src,s=!1,i=[],u,a,f,v,e,o,t,i=y.split("\n"),r=0;r<i.length;r++){if(s&&this.helpers.startsWith(i[r].trim(),");")&&(s=!1),i[r].indexOf(this.dataFromDB.BaseName)!=-1)i[r]=i[r].replace(this.dataFromDB.BaseName,this.dataFromForm.modelName);else if(s){for(u=i[r].trim().split(/[:=;\-\-]+/),t=0;t<u.length;t++)u[t]=u[t].trim(),u[t]==""&&(u.splice(t,1),t--);if(this.helpers.endsWith(u[1],"_vector")){var p=u[3].split(/[{}]+/),l=p[1].split(","),h=0,c=0;if(l[1].trim()=="independent"){for(this.indepString="(",t=0;t<this.pwlData.length;t++)this.indepString+=this.formatData(this.pwlData[t].independent,"real"),t<this.pwlData.length-1&&(this.indepString+=", "),h=this.indepString.length-c,h>60&&(c=this.indepString.length,this.indepString+=" \n\t\t\t\t");this.indepString+=")";i[r]=i[r].replace("dummyValue",this.indepString+" ")}else if(l[1].trim()=="dependent"){for(this.depString="(",t=0;t<this.pwlData.length;t++)this.depString+=this.formatData(this.pwlData[t].dependent,"real"),t<this.pwlData.length-1&&(this.depString+=", "),h=this.depString.length-c,h>60&&(c=this.depString.length,this.depString+=" \n\t\t\t\t");this.depString+=")";i[r]=i[r].replace("dummyValue",this.depString+" ")}}else for(t=0;t<this.componentProps.length;t++){var w=u[0].toLowerCase().trim(),b=u[1].toLowerCase().trim(),k=this.helpers.DmbGetPropertyType(b);this.componentProps[t].Name.toLowerCase()==w&&(a=Project.Utility.getPropTypFromMinTypMax(this.componentProps[t]),i[r]=i[r].replace("dummyValue",this.standardValueFormatter.GetStandardValue(k,a)+" "))}}if(this.helpers.startsWith(i[r].trim(),"generic")&&this.helpers.endsWith(i[r].trim(),"(")&&(s=!0),i[r].indexOf("-- Model Title:")!=-1&&(i[r]="-- Part #: "+this.dataFromForm.partNumber),i[r].indexOf("-- Author:")!=-1&&(i[r]="-- Author:"),i[r].indexOf("-- Created:")!=-1&&(f=new Date,v="-- Component Creation Date: "+(f.getMonth()+1)+PATH_SEPARATOR+f.getDate()+PATH_SEPARATOR+f.getFullYear()+" @ "+f.getHours()+":"+f.getMinutes()+":"+f.getSeconds(),i[r]=v),i[r].indexOf("-- Description:")!=-1)for(i[r]=i[r].replace("Description","Base Model Description"),e=[],e=this.dataFromForm.modelComments.split("\n"),e.length>0&&i.splice(r,0,"--"),o=0,t=0;t<e.length;t++)o=t,o==0?i.splice(r+o,0,"-- Comments: "+e[t]):i.splice(r+o,0,"-- "+e[t])}return i.join("\n")},t.prototype.PostToServer=function(t){for(var o,f,w,s,b,c,l,a,i,d,r=this,g=this.helpers.GetAPIURI(),e=[],h=!1,u=0;u<this.dataFromDB.Properties.length;u++){for(o=0;o<this.componentProps.length;o++)this.dataFromDB.Properties[u].Name==this.componentProps[o].Name&&(e.push(this.componentProps[o]),h=!0);h||(f=this.dataFromDB.Properties[u],w=new Project.CeProperty(f.Name,f.Type,f.Typical,f.Minimum,f.Maximum,f.DistType,f.Description,f.Units,f.PropVisibility),e.push(w),s=e[e.length-1],this.helpers.endsWith(s.Type,"_vector")&&(b=s.Description.split(/[{}]+/),c=b[1].split(","),c[1].trim()=="independent"?s.Typical=this.indepString:c[1].trim()=="dependent"&&(s.Typical=this.depString)));h=!1}for(l=[],u=0;u<this.dataFromDB.Architectures.length;u++)l.push(this.dataFromDB.Architectures[u]);for(a=[],u=0;u<this.dataFromDB.Pins.length;u++)a.push(this.dataFromDB.Pins[u]);var k=[],nt=new Project.CeRevision(this.dataFromDB.ComponentId,"New Comp",!1,"");k.push(nt);var v="",y="",p="";this.dataManager.isModelUpdate?(y="/components?library=UserLib&componentId="+this.dataFromDB.ComponentId,p="PUT",v=this.dataFromDB.ComponentId):(y="/components?library=UserLib",p="POST",v="");Project.Settings.notify("model DMB Save",{modelType:this.dataFromDB.BaseName});i=new Project.CeComponent;i.Name=this.dataFromForm.modelName;i.Title=this.dataFromForm.partNumber;i.Description=this.dataFromDB.Description;i.DescriptionToolTip=this.dataFromDB.DescriptionToolTip;i.Tags=this.dataFromDB.Tags;i.PartNumber=this.dataFromForm.partNumber;i.Prefix=this.dataFromDB.Prefix;i.Src=t;i.Img=this.dataFromDB.Img;i.Lib="UserLib";i.Url="";i.ShowComponent=!1;i.Comments=this.dataFromForm.modelComments;i.BaseName=this.dataFromDB.BaseName;i.Author=Project.Settings.UUID;i.Status=2;i.Visibility=0;i.DateModified="";i.ComponentId=v;i.Cx=this.dataFromDB.Cx;i.Cy=this.dataFromDB.Cy;i.ModelType=0;i.Properties=e;i.Architectures=l;i.Pins=a;i.Categories=["DMB User Components","My Components","Shared Components"];this.dataFromDB.Revisions&&this.dataFromDB.Revisions.length>0?(i.Revisions=this.dataFromDB.Revisions,i.CreationDate=this.dataFromDB.CreationDate):(i.CreationDate="",i.Revisions=k);d=JSON.stringify(i);$.ajax({url:g+y,dataType:"json",type:p,data:d,contentType:"application/json;charset=utf-8",success:function(t){var i,u;if(r.dataManager.activeNameOrPartNum=r.dataFromForm.modelName,r.dataManager.library=n.LIBRARY.SVWebLib,r.dataManager.isModelSaved=!0,r.dataManager.comboBoxIndex=0,r.dataManager.isModelUpdate)for(i=0;i<r.dataManager.usrDsArray.length;i++)r.dataManager.usrDsArray[i].ComponentId==t.ComponentId&&(r.dataManager.usrDsArray[i]=t);else r.dataManager.addToUsrDsArray(t);u=getSchematic();r.dataManager.isModelUpdate?u.getComponentDataManager().updateCollection(t):u.getComponentDataManager().addToCollection(t,"UserLib");u.getComponentBrowserSidebar().openCategory(Sidebar.ComponentBrowser.MY_COMPONENTS_CATEGORY);$.ajaxSetup({cache:!0});$("#dmbApp").load("/Dmb/DmbSymMdlView/?symMdlName="+r.helpers.GetDefaultNameFromCategory(r.helpers.GetCategoryFromBaseName(r.dataFromDB.BaseName)));r.helpers.hideSpinner();r.isSaving=!1},error:function(t){var u=json_parse(t.responseText),i="",r;if(u.ModelState.error)for(r=0;r<u.ModelState.error.length;r++)i=i+u.ModelState.error[r]+"\n\n";else i="Unable to complete server request";alert(i);this.dataManager.comboBoxIndex=0;this.dataManager.library=n.LIBRARY.SVWebLib;this.isSaving=!1;$.ajaxSetup({cache:!0});$("#dmbApp").load("/Dmb/DmbSymMdlView/?symMdlName="+this.helpers.GetDefaultNameFromCategory(this.dataManager.activeCategory))}})},t.prototype.Destroy=function(){var t=this,i=600,n=this.helpers.getDmbBoundingBox(),r=n.x+n.width/2-i/2,u=n.y+n.height/2-30;this.confirm2BtnDialog=new Project.MultiBtnModalDialog("Delete Component Request","<p>You are attempting to delete a component. You can now: <\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Click OK to delete this component. It will no longer be available in the    Datasheet Model Builder or Component Browser. <\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Click Cancel to keep this component and cancel the operation. <\/p>",["OK","Cancel"],r,u);$("#twoBtnModalDialog").css({width:i});jQuery.when(this.confirm2BtnDialog.queryUser()).done(function(n){n==Project.BUTTON.BTN1?(t.dataManager.isModelUpdate=!1,t.DeleteFromServer()):t.isDeleting=!1})},t.prototype.PostDeleteFromServer=function(t){var i,r,u;this.dataManager.comboBoxIndex=0;this.dataManager.library=n.LIBRARY.SVWebLib;i=this.dataManager.activeCategory;r=this.helpers.GetDefaultNameFromCategory(i);this.dataManager.activeNameOrPartNum=r;this.dataManager.deleteFromUsrDsArray(t);u=getSchematic();u.getComponentBrowserSidebar().openCategory(Sidebar.ComponentBrowser.MY_COMPONENTS_CATEGORY);this.isDeleting=!1;$.ajaxSetup({cache:!0});$("#dmbApp").load("/Dmb/DmbSymMdlView/?symMdlName="+this.helpers.GetDefaultNameFromCategory(this.dataManager.activeCategory))},t.prototype.DeleteFromServer=function(){var t=this,i=this,n;this.helpers.showSpinner();n=this.dataManager.activeId;$.when(getSchematic().getComponentDataManager().deleteComponent(Project.ComponentDataManager.USER_LIB,n)).done(function(){t.helpers.hideSpinner();i.PostDeleteFromServer(n)})},t.prototype.CloseDmb=function(){},t.prototype.DistributionDialog=function(){var o=$("#electricalGrid").data("kendoGrid"),t=o.dataSource.data(),u=document.createDocumentFragment(),n;for($("#radioButtonDiv").each(function(){$("#radioButtonDiv div:not([class])").remove()}),n=0;n<t.length;n++)if(t[n].Minimum&&t[n].Maximum){var f=" name="+t[n].Name,e=document.createElement("div"),i="checked",r="";t[n].DistType==2?(i="",r="checked"):(i="checked",r="");e.innerHTML='<div style="float: left; width: 33%;">'+t[n].Name+'<\/div><div style="float: left; width: 33%;"><input '+f+' type="radio" value="1" '+i+" /><\/div><input "+f+' type="radio" value="2" '+r+" />";u.appendChild(e)}$("#radioButtonDiv").append(u.childNodes);$("#distModal").modal({backdrop:!1});this.helpers.placeModal("distModal");$("#distModal").modal("show");$("#distModal").draggable();this.isSaved=!0},t.prototype.ModelsMenuLink=function(){var n=this;$(".linkModelsMenu").click(function(){var r=$("#electricalGrid").data("kendoGrid"),u=r.dataSource,f=$("#ratingsGrid").data("kendoGrid"),e=f.dataSource;if(n.helpers.doesDataSourceHaveChanges(u)||n.helpers.doesDataSourceHaveChanges(e)){var i=600,t=n.helpers.getDmbBoundingBox(),o=t.x+t.width/2-i/2,s=t.y+t.height/2-30;n.confirm2BtnDialog=new Project.MultiBtnModalDialog("Change Page with Unsaved Changes Request","<p>You are attempting to change to a new page with unsaved changed to the current page. You can now: <\/p><p><i class='glyphicon glyphicon-arrow-right'><\/i> Click OK to change the page. All unsaved model values will be lost. <p><i class='glyphicon glyphicon-arrow-right'><\/i> Click Cancel to stay on the current page. <\/p>",["OK","Cancel"],o,s);$("#twoBtnModalDialog").css({width:i});jQuery.when(n.confirm2BtnDialog.queryUser()).done(function(n){n==Project.BUTTON.BTN1&&($.ajaxSetup({cache:!0}),$("#dmbApp").load("/Dmb/DmbIndex"))})}else $.ajaxSetup({cache:!0}),$("#dmbApp").load("/Dmb/DmbIndex")})},t.prototype.formatData=function(n){var t=null;return t=this.propertyFormatter.IsSIPrefix(n)?this.propertyFormatter.SIUnitPrefixes2Double(n):Number(n),t==Math.floor(t)?t.toFixed(1):t.toString()},t}();n.Toolbar=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.propertyFormatter=new n.PropertyFormatter;this.helpers=new n.Helpers}return t.prototype.GetStandardValue=function(n,t){var o=n.toLowerCase(),f,r,s,y,i,u,e,h,c,l,a,v;return t==""?"":o=="real"?(f=this.StandardRealFormat(t),r=parseFloat(f),isNaN(Number(r))?"Invalid":(r>0&&(r>=1e3||r<=.001)||r<0&&(r<=-1e3||r>=-.001)?(f=r.toExponential().toLocaleLowerCase().toString(),s=[],s=f.split("e"),y=this.FormatRealPeriodZeros(s[0]),f=y+"e"+s[1]):f=this.FormatRealPeriodZeros(r.toString()),f)):o=="time"?(i=this.StandardTimeFormat(t),u=parseFloat(i),isNaN(Number(u)))?"Invalid":(u>0&&(u>=1e3||u<=.001)||u<0&&(u<=-1e3||u>=-.001)?i=this.propertyFormatter.Double2SIUnitPrefixes(u)+"s":i.indexOf(".")!=-1?(this.helpers.startsWith(i,".")?i="0"+i:this.helpers.endsWith(i,".")&&(i=i+"0"),i=i+"sec"):i=i+"sec",i):o=="integer"?(e=this.StandardIntegerFormat(t),h="",isNaN(Number(e)))?"Invalid":(c=parseInt(e),c>=1e3||c<=-1e3?(e=this.Integer2ExponentialNotation(c),h=e?e:"Invalid"):h=e,h):o=="std_logic"?(l=this.StandardLogicFormat(t),l==null?"Invalid":l):o=="boolean"?(a=this.StandardBooleanFormat(t),a==null?"Invalid":a):o=="bit"?(v=this.StandardBitFormat(t),v==null?"Invalid":v):t},t.prototype.StandardRealFormat=function(n){return this.CheckRealSINotation(n)?this.propertyFormatter.SIUnitPrefixes2Double(n).toString():n},t.prototype.StandardTimeFormat=function(n){return this.CheckTimeSINotation(n)?this.propertyFormatter.SIUnitPrefixes2Double(n).toString():n},t.prototype.StandardIntegerFormat=function(n){var i,f,o;if(this.CheckIntegerSINotation(n))return this.SIUnitPrefixes2Integer(n);if(n.toLowerCase().indexOf("e")!=-1){i=[];i=n.toLowerCase().split("e");var t=i[0],r=0,u=0,e=i[1];return isNaN(Number(t))?null:this.helpers.startsWith(e,"-")?null:t.indexOf(".")!=-1?n:this.helpers.endsWith(t,".")?n:(f=t.length-1-t.indexOf("."),o=e[e.length-1],u<f?null:(r=parseFloat(t),r=r*Math.pow(10,f),u=u-f,r.toString()+"e+"+u.toString()))}return isNaN(Number(n))?null:n},t.prototype.StandardLogicFormat=function(n){return this.CheckStdLogicNotation(n)?n:null},t.prototype.StandardBitFormat=function(n){return this.CheckBitNotation(n)?n:null},t.prototype.StandardBooleanFormat=function(n){return this.CheckBooleanNotation(n)?n:null},t.prototype.CheckRealSINotation=function(n){var t=n.toUpperCase().trim(),i;return this.helpers.endsWith(t,"K")||this.helpers.endsWith(t,"MEG")||this.helpers.endsWith(t,"G")||this.helpers.endsWith(t,"T")||this.helpers.endsWith(t,"M")||this.helpers.endsWith(t,"U")||this.helpers.endsWith(t,"N")||this.helpers.endsWith(t,"P")||this.helpers.endsWith(t,"F")?(i=this.helpers.endsWith(t,"MEG")?t.substring(0,t.length-3):t.substring(0,t.length-1),isNaN(Number(i))?!1:!0):!1},t.prototype.CheckTimeSINotation=function(n){var t=n.toUpperCase().trim(),i;return this.helpers.endsWith(t,"K")||this.helpers.endsWith(t,"MEG")||this.helpers.endsWith(t,"G")||this.helpers.endsWith(t,"T")||this.helpers.endsWith(t,"M")||this.helpers.endsWith(t,"U")||this.helpers.endsWith(t,"N")||this.helpers.endsWith(t,"P")||this.helpers.endsWith(t,"F")?(i=t.substring(0,t.length-1),isNaN(Number(i))?!1:!0):!1},t.prototype.CheckIntegerSINotation=function(n){var t=n.toUpperCase().trim(),i;return this.helpers.endsWith(t,"K")||this.helpers.endsWith(t,"MEG")||this.helpers.endsWith(t,"G")?(i=this.helpers.endsWith(t,"MEG")?t.substring(0,t.length-3):t.substring(0,t.length-1),isNaN(Number(i))?!1:!0):!1},t.prototype.CheckStdLogicNotation=function(n){var t=n.toUpperCase().trim();return t=="X"||t=="'X'"||t=="Z"||t=="'Z'"||t=="W"||t=="'W'"||t=="L"||t=="'L'"||t=="H"||t=="'H'"||t=="0"||t=="'0'"||t=="1"||t=="'1'"||t=="-"||t=="U"||t=="'U'"?!0:!1},t.prototype.CheckBitNotation=function(n){var t=n.toUpperCase().trim();return n=="0"||n=="'0'"||n=="1"||n=="'1'"?!0:!1},t.prototype.CheckBooleanNotation=function(n){var t=n.toUpperCase().trim();return t=="TRUE"||t=="'TRUE'"||t=="FALSE"||t=="'FALSE'"?!0:!1},t.prototype.FormatRealPeriodZeros=function(n){return n.indexOf(".")==-1?n=n+".0":n.indexOf(".")!=-1&&(this.helpers.startsWith(n,".")?n="0"+n:this.helpers.endsWith(n,".")&&(n=n+"0")),n},t.prototype.Integer2ExponentialNotation=function(n){var t=n,i=this.NumberOfTrailingZeros(t),r=(t/Math.pow(10,i)).toString();return isNaN(Number(r))?null:r+"e+"+i},t.prototype.SIUnitPrefixes2Integer=function(n){var t=n.toString().toUpperCase(),i="";return this.helpers.endsWith(t.trim(),"K")?(i=t.substring(0,t.length-1),this.IntegerSIPrefix2ScaledInteger(i,1e3)):this.helpers.endsWith(t.trim(),"MEG")?(i=t.substring(0,t.length-3),this.IntegerSIPrefix2ScaledInteger(i,1e6)):t.Trim().EndsWith("G")?(i=t.substring(0,t.length-1),this.IntegerSIPrefix2ScaledInteger(i,1e9)):n},t.prototype.IntegerSIPrefix2ScaledInteger=function(n,t){return isNaN(Number(n))?null:(n*t).toString()},t.prototype.NumberOfTrailingZeros=function(n){if(n==0)return 1;for(var t=0;n%10==0;)n=n/10,t++;return t},t}();n.StandardValueFormatter=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.errorWarningMessages=new n.ErrorWarningMessages}return t.prototype.ValidateInputValue=function(n,t){var i=n.toLowerCase();return t==""?"":i=="real"?this.CheckRealValue(t)!=null?t:this.errorWarningMessages.ErrorDoubleFormat():i=="time"?this.CheckTimeValue(t)!=null?t:this.errorWarningMessages.ErrorTimeFormat():i=="integer"?this.CheckIntegerValue(t)!=null?t:this.errorWarningMessages.ErrorIntegerFormat():i=="std_logic"?this.CheckStdLogicValue(t)!=null?t:this.errorWarningMessages.ErrorStdLogicFormat():i=="boolean"?this.CheckBooleanValue(t)!=null?t:this.errorWarningMessages.ErrorBooleanFormat():i=="bit"?this.CheckBitValue(t)!=null?t:this.errorWarningMessages.ErrorBitFormat():t},t.prototype.CheckRealValue=function(n){var t=n.toString().toUpperCase();return t?(this.IsSIPrefix(t)&&(t=t.match("MEG")?t.substr(0,t.length-3):t.substr(0,t.length-1)),isNaN(Number(t))?null:n):null},t.prototype.CheckTimeValue=function(n){var t=n.toString().toUpperCase();return t?(this.IsTimePrefix(t)&&(t=t.substr(0,t.length-1)),isNaN(Number(t))?null:n):null},t.prototype.CheckIntegerValue=function(n){var t=n.toString().toUpperCase();return t?(this.IsIntSIPrefix(t)&&(t=t.match("MEG")?t.substr(0,t.length-3):t.substr(0,t.length-1)),isNaN(Number(t))?null:this.IsInt(t)?n:null):null},t.prototype.CheckStdLogicValue=function(n){var t=n.toString().toUpperCase();return this.IsStdLogic(t)?n:null},t.prototype.CheckBitValue=function(n){return this.IsBit(n)?n:null},t.prototype.CheckBooleanValue=function(n){var t=n.toString().toUpperCase();return this.IsBoolean(t)?n:null},t.prototype.IsInt=function(n){var t=n.indexOf("E"),i=n.substring(0,t!=-1?t:n.length),r;return t!=-1&&n.charAt(t+1)=="-"&&(r=n.substring(t+2,n.length),i/Math.pow(10,r)<.99)?!1:!isNaN(parseInt(i.toString()))&&parseFloat(i.toString())==parseInt(i.toString())},t.prototype.IsSIPrefix=function(n){var t=n.toUpperCase();return t.length>1&&(t.match(/K$/)||t.match(/MEG$/)||t.match(/G$/)||t.match(/T$/)||t.match(/M$/)||t.match(/U$/)||t.match(/N$/)||t.match(/P$/)||t.match(/F$/))?!0:!1},t.prototype.IsIntSIPrefix=function(n){var t=n.toUpperCase();return t.length>1&&(t.match(/K$/)||t.match(/MEG$/)||t.match(/G$/))?!0:!1},t.prototype.IsTimePrefix=function(n){var t=n.toUpperCase();return t.length>1&&(t.match(/K$/)||t.match(/MEG$/)||t.match(/G$/)||t.match(/T$/)||t.match(/M$/)||t.match(/U$/)||t.match(/N$/)||t.match(/P$/)||t.match(/F$/))?!0:!1},t.prototype.IsStdLogic=function(n){return n=="X"||n=="'X'"||n=="Z"||n=="'Z'"||n=="W"||n=="'W'"||n=="L"||n=="'L'"||n=="H"||n=="'H'"||n=="0"||n=="'0'"||n=="1"||n=="'1'"||n=="-"||n=="U"||n=="'U'"?!0:!1},t.prototype.IsBit=function(n){return n=="0"||n=="'0'"||n=="1"||n=="'1'"?!0:!1},t.prototype.IsBoolean=function(n){return n=="TRUE"||n=="'TRUE'"||n=="FALSE"||n=="'FALSE'"?!0:!1},t.prototype.Double2SIUnitPrefixes=function(n){var t=n;return t>=1e3&&t<1e6?(t/1e3).toString()+"K":t>=1e6&&t<1e9?(t/1e6).toString()+"Meg":t>=1e9&&t<1e12?(t/1e9).toString()+"G":t>=1e12?(t/1e12).toString()+"T":t<1&&t>=.001?(t*1e3).toString()+"m":t<=.001&&t>=1e-6?(t*1e6).toString()+"u":t<=1e-6&&t>=1e-9?(t*1e9).toString()+"n":t<=1e-9&&t>=1e-12?(t*1e12).toString()+"p":t<=1e-12&&t>0?(t*1e15).toString()+"f":n.toString()},t.prototype.SIUnitPrefixes2Double=function(n){var t=n.toString().toUpperCase();return t.match(/K$/)?parseFloat(t)*1e3:t.match(/MEG$/)?parseFloat(t)*1e6:t.match(/G$/)?parseFloat(t)*1e9:t.match(/T$/)?parseFloat(t)*1e12:t.match(/M$/)?parseFloat(t)*.001:t.match(/U$/)?parseFloat(t)*1e-6:t.match(/N$/)?parseFloat(t)*1e-9:t.match(/P$/)?parseFloat(t)*1e-12:t.match(/F$/)?parseFloat(t)*1e-15:"-1"},t}();n.PropertyFormatter=t}(Dmb||(Dmb={})),function(n){var t=function(){function n(){}return n.prototype.ErrorDoubleFormat=function(){return'Invalid "real" format - please re-enter the value and press Enter or Tab to clear this message. <br /><br /> Acceptable unit prefixes (from small to large) are: f, p, n, u, m, K, Meg, G, and T. <br /><br />Notes:<br />These prefixes are not case-sensitive.<br />Do not add units.<br />'},n.prototype.ErrorTimeFormat=function(){return'Invalid "time" format - please re-enter the value and press Enter or Tab to clear this message. <br /><br /> Acceptable unit prefixes (from small to large) are: f, p, n, u, m, K, Meg, G, and T. <br /><br />Notes:<br />These prefixes are not case-sensitive.<br />Do not add units.<br />'},n.prototype.ErrorIntegerFormat=function(){return'Invalid "integer" format - please re-enter the value and press Enter or Tab to clear this message. <br /><br />Acceptable prefixes (from small to large) are: K, Meg, and G. <br /><br />Notes:<br />These values are not case-sensitive.<br />Do not include fractional values or units.'},n.prototype.ErrorBooleanFormat=function(){return'Invalid "boolean" format - please re-enter the value and press Enter or Tab to clear this message. <br /><br />Acceptable values are: true or false. Notes:<br />These values are not case-sensitive.'},n.prototype.ErrorBitFormat=function(){return"Invalid \"bit\" format - please re-enter the value and press Enter or Tab to clear this message. <br /><br />Acceptable values are: '0' or '1'. <br /><br /> Notes:<br />These values are not case-sensitive and single quotes are optional."},n.prototype.ErrorStdLogicFormat=function(){return"Invalid \"std_logic\" format - please re-enter the value and press Enter or Tab to clear this message. <br /><br />Acceptable values are: 'X', '0', '1', 'Z', 'W', 'L', 'H', or '-'. <br /><br /> Notes:<br />These values are not case-sensitive and single quotes are optional."},n.prototype.ErrorUnrecognizedFormat=function(){return"Invalid parameter type. Valid parameter types are: real (or real subtype), time, integer, bit, boolean, and std_logic."},n.prototype.ErrorNoValue=function(){return"Invalid specification in Maximum Ratings table: <br /><br /> Value parameter must be specified"},n.prototype.ErrorNoMinTypMax=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> At least one parameter must be supplied for each property"},n.prototype.ErrorNoTypical=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> Parameter does not have a Typical value"},n.prototype.ErrorNoMaximum=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> If Minimum value is supplied, Maximum value must also be supplied"},n.prototype.ErrorNoMinimum=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> If Maximum value is supplied, Minimum value must also be supplied"},n.prototype.ErrorTypMax=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> Typical value must be <= Maximum value"},n.prototype.ErrorMinTyp=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> Minimum value must be <= Typical value"},n.prototype.ErrorMinMax=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> Minimum value must be <= Maximum value"},n.prototype.ErrorMinTypMax=function(){return"Invalid specification in Electrical Characteristics table: <br /><br /> Minimum value must be <= Typical value, which must be <= Maximum value"},n}();n.ErrorWarningMessages=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.errorWarningMessages=new n.ErrorWarningMessages;this.propertyFormatter=new n.PropertyFormatter;this.helpers=new n.Helpers}return t.prototype.validateForm=function(){return $("#dmbPartNumberId").val()?!0:(Project.MessageManager.showErrorMessage("Please enter a Part # (model name)"),$(".k-animation-container").css({"z-index":12700}),!1)},t.prototype.validateRatingsRow=function(){for(var n=[],r=!1,u=!1,f=$("#ratingsGrid").data("kendoGrid"),i=f.dataSource.data(),t=0;t<i.length;t++)n.push(i[t].Name),n.push(i[t].Typical),n[1]||Project.Settings.DISABLE_STD_UI_MESSAGING||(alert('"'+n[0]+'" parameter: '+this.errorWarningMessages.ErrorNoValue()),r=!0),r&&(u=!0),n.length=0;return u},t.prototype.validateElectricalRow=function(){for(var u,i=[],r=!1,f=$("#electricalGrid").data("kendoGrid"),t=f.dataSource.data(),n=0;n<t.length;n++)i.push(t[n].Name),t[n].Minimum?i.push(this.propertyFormatter.ValidateInputValue(this.helpers.DmbGetPropertyType(t[n].Type),t[n].Minimum)):i.push(""),t[n].Typical?i.push(this.propertyFormatter.ValidateInputValue(this.helpers.DmbGetPropertyType(t[n].Type),t[n].Typical)):i.push(""),t[n].Maximum?i.push(this.propertyFormatter.ValidateInputValue(this.helpers.DmbGetPropertyType(t[n].Type),t[n].Maximum)):i.push(""),u=this.ValidateRow(i),u&&(r=!0),i.length=0;return r},t.prototype.ValidateRow=function(n){var i=!1,r,t,u,f,e;return this.propertyFormatter.IsSIPrefix(n[1])&&(n[1]=this.propertyFormatter.SIUnitPrefixes2Double(n[1])),this.propertyFormatter.IsSIPrefix(n[2])&&(n[2]=this.propertyFormatter.SIUnitPrefixes2Double(n[2])),this.propertyFormatter.IsSIPrefix(n[3])&&(n[3]=this.propertyFormatter.SIUnitPrefixes2Double(n[3])),f="",e="Invalid Value Combination",!n[1]&&n[2]&&n[3]?(t=parseFloat(n[2]),u=parseFloat(n[3]),this.helpers.sign(t)==this.helpers.sign(u)?Math.abs(t)>Math.abs(u)&&(i=!0):t>u&&(i=!0),i&&!Project.Settings.DISABLE_STD_UI_MESSAGING&&(f='"'+n[0]+'" parameter: '+this.errorWarningMessages.ErrorTypMax(),this.helpers.showValidationDialog(e,f))):n[1]&&n[2]&&!n[3]?(r=parseFloat(n[1]),t=parseFloat(n[2]),this.helpers.sign(r)==this.helpers.sign(t)?Math.abs(r)>Math.abs(t)&&(i=!0):r>t&&(i=!0),i&&!Project.Settings.DISABLE_STD_UI_MESSAGING&&(f='"'+n[0]+'" parameter: '+this.errorWarningMessages.ErrorMinTyp(),this.helpers.showValidationDialog(e,f))):n[1]&&!n[2]&&n[3]?(r=parseFloat(n[1]),u=parseFloat(n[3]),this.helpers.sign(r)==this.helpers.sign(u)?Math.abs(r)>Math.abs(u)&&(i=!0):r>u&&(i=!0),i&&!Project.Settings.DISABLE_STD_UI_MESSAGING&&(f='"'+n[0]+'" parameter: '+this.errorWarningMessages.ErrorMinMax(),this.helpers.showValidationDialog(e,f))):n[1]&&n[2]&&n[3]?(r=parseFloat(n[1]),t=parseFloat(n[2]),u=parseFloat(n[3]),this.helpers.sign(r)==this.helpers.sign(t)&&this.helpers.sign(t)==this.helpers.sign(u)?(Math.abs(r)>Math.abs(t)||Math.abs(r)>Math.abs(u)||Math.abs(t)>Math.abs(u))&&(i=!0):(r>t||r>u||t>u)&&(i=!0),i&&!Project.Settings.DISABLE_STD_UI_MESSAGING&&(f='"'+n[0]+'" parameter: '+this.errorWarningMessages.ErrorMinTypMax(),this.helpers.showValidationDialog(e,f))):n[1]||n[2]||n[3]||(i=!0,Project.Settings.DISABLE_STD_UI_MESSAGING||(f='"'+n[0]+'" parameter: '+this.errorWarningMessages.ErrorNoMinTypMax(),this.helpers.showValidationDialog(e,f))),i},t}();n.FormValidation=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.helpers=new n.Helpers;this.dataManager=n.DataManager.getInstance()}return t.prototype.DmbCreateComboBox=function(t){function s(t){r.dataManager.comboBoxIndex=t.item.index();var i=this.dataItem(t.item.index());i&&(i.PartNumber=i.PartNumber.replace(/['"]/g,""),r.dataManager.activeId=i.ID,t.item.index()==0?(r.dataManager.library=n.LIBRARY.SVWebLib,$.ajaxSetup({cache:!0}),$("#dmbApp").load("/Dmb/DmbSymMdlView/?symMdlName="+r.helpers.GetDefaultNameFromCategory(r.dataManager.activeCategory))):(r.dataManager.library=n.LIBRARY.UserLib,$.ajaxSetup({cache:!0}),$("#dmbApp").load("/Dmb/DmbSymMdlView/?symMdlName="+encodeURIComponent(i.PartNumber.trim()))))}var r=this,u=this.dataManager.mgcDsArray,f,e,o,i;for(u.sort(this.helpers.alphaCompare),f=0,i=0;i<u.length;i++)if(this.helpers.GetCategoryFromBaseName(u[i].BaseName)==this.dataManager.activeCategory){f=i;break}for(e=[],o="Default Values",u[f].Comments&&(o=u[f].Comments),e.push({PartNumber:o,ID:f}),i=0;i<t.length;i++)t[i].PartNumber&&t[i].ComponentId?(e.push({PartNumber:t[i].PartNumber,ID:t[i].ComponentId}),this.dataManager.isModelSaved&&t[i].PartNumber==this.dataManager.activeNameOrPartNum&&(this.dataManager.comboBoxIndex=i+1,this.dataManager.isModelSaved=!1,this.dataManager.activeNameOrPartNum=null)):console.log("UserLib comp was in comps array, but did not have PartNumber and/or ID");$("#dmbComboBoxInput").kendoComboBox({dataTextField:"PartNumber",dataValueField:"ID",dataSource:e,select:s,filter:"contains",suggest:!0,index:this.dataManager.comboBoxIndex})},t}();n.CategoryModelsComboBox=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.splashScreendHelp=[];this.modelPageStandardHelp=[];this.modelPageAdditionalHelp=[];this.helpers=new n.Helpers}return t.prototype.HelpButtons=function(){var n=this;this.moreFormHelp=$("#moreFormHelp");this.stillMoreFormHelp=$("#stillMoreFormHelp");this.lessFormHelp=$("#lessFormHelp");this.stillLessFormHelp=$("#stillLessFormHelp");this.additionalInstructionsText=$("#additionalInstructionsText");this.instructionsRow=$("#InstructionsRow");this.moreModelInfo=$("#moreModelInfo");this.lessModelInfo=$("#lessModelInfo");this.moreFormHelp.css("cursor","pointer");this.lessFormHelp.css("cursor","pointer");this.moreModelInfo.css("cursor","pointer");this.lessModelInfo.css("cursor","pointer");this.moreFormHelp.click(function(){n.moreFormHelp.hide();n.lessFormHelp.show();n.instructionsRow.slideDown()});this.lessFormHelp.click(function(){n.moreFormHelp.show();n.lessFormHelp.hide();n.instructionsRow.slideUp();n.additionalInstructionsText.slideUp();n.stillMoreFormHelp.show();n.stillLessFormHelp.hide()});this.stillMoreFormHelp.click(function(){n.stillMoreFormHelp.hide();n.stillLessFormHelp.show();n.additionalInstructionsText.slideDown()});this.stillLessFormHelp.click(function(){n.stillMoreFormHelp.show();n.stillLessFormHelp.hide();n.additionalInstructionsText.slideUp()});this.moreModelInfo.click(function(){var r=t.DMB_HELP_MINWIDTH,u=t.DMB_HELP_MINHEIGHT,f=Project.CeUtility.getInitialModelingToolDim(Project.MODELING_APP.HELP,Project.MODELING_APP_DIM.WIDTH),e=Project.CeUtility.getInitialModelingToolDim(Project.MODELING_APP.HELP,Project.MODELING_APP_DIM.HEIGHT),i=$("#modelDetails"),n=i.data("kendoWindow"),n=$("#modelDetails").data("kendoWindow");n?(n.center(),n.open()):(n=i.kendoWindow({actions:["Close"],modal:!1,resizable:!0,draggable:!0,position:{top:50,left:50},width:f,height:e,minWidth:r,minHeight:u,title:"Model Details"}).data("kendoWindow"),n.center(),n.open());$("#symMdlSchImage").show();$("#symMdlDescriptionFull").show();n.bind("close",function(){$("#symMdlSchImage").hide();$("#symMdlDescriptionFull").hide()})});$("#help").css("cursor","pointer");$("#help").click(function(){alert("Notes\n-- Quick walkthrough demo from DMB launch to \n    simulating design in SV\n-- May be an issue if no delete actual model \n     How can we update an existing Model?")})},t.prototype.addSplashScreenHelpToDom=function(){var t,n;for(this.loadSplashScreenHelpStrings(),t=$("#selectModelInstructionsText"),n=0;n<this.splashScreendHelp.length;n++)t.append(this.splashScreendHelp[n])},t.prototype.addModelPageHelpToDom=function(){var t,n;for(this.loadStandardHelpStrings(),t=$("#instructionsText"),n=0;n<this.modelPageStandardHelp.length;n++)t.append(this.modelPageStandardHelp[n]);for($("#stillLessFormHelp").hide(),this.loadAdditionalHelpStrings(),n=0;n<this.modelPageAdditionalHelp.length;n++)$("#additionalInstructionsText").append(this.modelPageAdditionalHelp[n])},t.prototype.loadSplashScreenHelpStrings=function(){this.splashScreendHelp.push("<p>The Datasheet Model Builder is a tool that automatically creates simulatable models (and symbols) for various types of devices<\/p><p>Several device types are available from which to create a new model. Each device type contains at least one default set of parameters along with additional parameter sets for any models you have previously created. The number of available parameter sets for a given device type are indicated above the model image <\/p><p><U>To create a new model:<\/U> <\/p><p>Click on the device type of interest (a tool tip is also available when you hover over a device type)<\/p><p>You will be taken to a new page for the selected device type that allows you to parameterize and save a new model. Detailed help for creating a new model is available from the device page<\/p>")},t.prototype.loadStandardHelpStrings=function(){this.modelPageStandardHelp.push("<p>To create a new model (component), fill out the fields under the New Model Info heading and add/ update data in the two tables as desired. Details are given below <br/><\/p>");this.modelPageStandardHelp.push('<span><strong>[Required] Type in a part number (or name) in the <span class="crossHighlight" id="typeModelPartNum"> Part # <\/span>field<\/strong><\/span><br/><br/>The information you supply for the Part # field is used to list the component in the component browser. A "sanitized" version of the Part # will be used as the name of the model itself<br/><br/>');this.modelPageStandardHelp.push('<span><strong>[Optional] Type in a comment in the <span class="crossHighlight" id="typeModelComments"> Comments <\/span>field<\/strong><\/span><br/><br/>');this.modelPageStandardHelp.push('<span><strong>[Optional] Preload tables with data from existing device parameters using the <span class="crossHighlight" id="preloadComboBox"> drop-down <\/span>menu<\/strong><\/span><br/><br/>This can be useful to either create a new model based on existing data, or to create a new model that is similar to an existing model which would then only require minor tweaks to existing values. <br/>You can select initial model data directly from the menu, or search for a model by typing directly into the menu display field<br/><br/>');this.modelPageStandardHelp.push('<span><strong>Type in desired values in the <U>Electrical Characteristics<\/U> table<\/strong><\/span><br/><br/>The Electrical Characteristics table contains parameters that control the functional specifications of the model. Please note the following:<br/><br/>At least one the following values: <span class="crossHighlight" id="elecMin">Minimum,<\/span> <span class="crossHighlight" id="elecTyp"> Typical,<\/span>or <span class="crossHighlight" id= "elecMax" > Maximum <\/span> is required<br/><br/>If only one value is supplied, it will be used as the nominal simulation value<br/><br/>If the Typical value is supplied, it will always be used as the nominal simulation value<br/><br/>In the future, min / typ / max values will be used together in support of parametric and statistical analysis<br/><br/>Several input formats are supported (e.g. "10k", "10K", "10 K", "10e3", "10.0e3", "10000", "10000.0" are allowed) If an unsupported format or value is entered, an error message will be generated<br/><br/>');this.modelPageStandardHelp.push('<span><strong>Type in the desired values in the <U>Maximum Ratings<\/U> table<\/strong><\/span><br/><br/>The Maximum Ratings table contains parameters that support stress analysis <br/><br/>[Required] The <span class="crossHighlight" id="ratingsVal"> Value <\/span> value is required for all parameters<br/> (default values are acceptable if non-blank)<br/><br/>');this.modelPageStandardHelp.push('<span><strong>Click the Save button and follow prompts. Your new model can now be found:<\/strong><\/span><br/><br/>    1) In the My Components and Shared Components (if applicable) folders of the SystemVision component browser<br/><br/>    2) By clicking on the proper category in the Datasheet Model Builder Models Menu page and selecting the model from the       "Initialize with:" drop- down menu<br/><br/>');this.modelPageStandardHelp.push('<span><strong>The Models Menu page is loaded when the Datasheet Model Builder is first launched<\/strong><\/span><br/>You can also navigate to the Models Menu page from the page you are currently viewing by clicking on the <span class="btn-link linkModelsMenu"> Models Menu<\/span> link<br/><br/>');this.modelPageStandardHelp.push("<p>If you specified Minimum and Maximum values for any of the model parameters, a dialog will be presented when you click Save, which allows you to choose a distribution type for corresponding parameters. The distribution type specifies how parameter values within the Minimum/ Maximum range will be weighted during simulation, for example, in a Monte Carlo analysis (not currently supported) <br/><br/>You can view the distribution settings for any model parameter set by clicking on the More Model Info button <br/><br/>You can view additional general Help topics by clicking on the More Help button below<\/p>");this.modelPageStandardHelp.push('<h3 id="stillMoreFormHelp" class="col-md-offset-5 btn btn-sm"><i class="glyphicon glyphicon-question-sign"> <\/i> More Help<\/h3>');this.modelPageStandardHelp.push('<h3 id="stillLessFormHelp" class="col-md-offset-5 btn btn-sm"><i class="glyphicon glyphicon-question-sign"> <\/i> Less Help<\/h3>')},t.prototype.loadAdditionalHelpStrings=function(){this.modelPageAdditionalHelp.push('<h3 class="centered-text" id="instructionsTitle"> Datasheet Model Builder<br/><span class="centered-text" style="font-size: 14pt"> Additional Notes<\/span><\/h3>');this.modelPageAdditionalHelp.push("The Delete button will only be visible when the page is initialized with non-default model data. When a model is deleted, it is removedfrom the Datasheet Model Builder. Any corresponding component (if it exists) will also be removed from the SystemVision component browser<br/><br/>");this.modelPageAdditionalHelp.push("The Clear Changes button removes all edits since the page was loaded<br/><br/>");this.modelPageAdditionalHelp.push('When a model is saved, both a model and a symbol (collectively referred to as a "component") are automatically generated and are available from the standard SystemVision component browser<br/><br/>');this.modelPageAdditionalHelp.push("In addition to the Part # information, the model also contains any Comments supplied by the user when created. The model listing can be accessed from within SystemVision using the component editor<br/><br/>");this.modelPageAdditionalHelp.push("Any model created by the Datasheet Model Builder can be updated (over-written) by first selecting the model using the drop-down list, and then changing any values. The underlying component will be updated with the new values. Note: you can only update models that you originally created<br/><br/>");this.modelPageAdditionalHelp.push("Once a model is created, if you would like to change any parameters in the model, you can either update it using the Datasheet Model Builder, or you can temporarily assign new values to a component instance once you place the component on a schematic, using the property editor. The base component (the component that appears in the component browser) will always default to the values set by the Datasheet Model Builder<br/><br/>");this.modelPageAdditionalHelp.push("Currently, simulations will be run using a nominal (typical) parameter value. If you do not supply a typical value, the other values (min and/or max) will  be used to algorithmically determine this value. You can view the value that was calculated by viewing the model in the component editor<br/><br/>");this.modelPageAdditionalHelp.push("In order to perform statistical analysis on a parameter (not currently supported), all three values, Minimum, Typical, and Maximum must be supplied. For example, if you want to create a 100 Ohm, 1 % resistor, you would specify Minimum: 99, Typical: 100, Maximum 101<br/> Note: The plan is to semi-automate this in the future so users can just specify a tolerance value (e.g. 100, 1 %), and the Datasheet Model Builder will populate the fields as necessary<br/><br/>");this.modelPageAdditionalHelp.push("The Datasheet Model Builder disables the page browsing functionality of the alt-left-arrow, alt-right-arrow, and backspace keys. This helps avoid unintentional page changing which can possibly result in losing your input data<br/><br/>");this.modelPageAdditionalHelp.push("When you attempt to save with an illegal value (or non-value) in a table cell, an error message will be generated. This message will be cleared after you correct the input, and then press either the Return or the Tab key<br/><br/>");this.modelPageAdditionalHelp.push("Known Issue: The drop-down model selection control has only partially functioning search capability. Typing in this control will display a filtered view of available model data sets. If your desired data set is highlighted and you press Return, that data set will not be loaded.However, if you first use an arrow key or the mouse to navigate to the desired data set, then it will initialize properly<br/><br/>")},t.DMB_HELP_WIDTH=750,t.DMB_HELP_HEIGHT=510,t.DMB_HELP_MINWIDTH=200,t.DMB_HELP_MINHEIGHT=400,t.DMB_HELP_MAXWIDTH=1500,t.DMB_HELP_MAXHEIGHT=1500,t}();n.Help=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.helpers=new n.Helpers;this.symMdlInfo=new n.SymMdlInfo}return t.prototype.DmbPropertyGrids=function(t){function o(t,i){var e=new n.PropertyFormatter,u=new n.Helpers;$('<input id="propValEdit" data-text-field="ValueName"" data-value-field="ValueName" data-bind="value:'+i.field+'"/>').appendTo(t);$("#propValEdit").focus(function(){$(this).select()});$("#propValEdit").change({options:i,container:t},function(){var o=$("#propValEdit").val().trim(),s=i.model.Type,f;if(s||(s="real"),r=e.ValidateInputValue(u.DmbGetPropertyType(s),o),r.match("Invalid")){var n=u.getDmbBoundingBox(),h=n.x+n.width/2-300,c=n.y+n.height/2-30;this.confirm1BtnDialog=new Project.MultiBtnModalDialog("Illegal Input Error",r,["OK"],h,c);this.confirm1BtnDialog.queryUser()}else if($("#propValEdit").val())$("#propValEdit").val(o),t.removeClass("emptyPropEditCell");else for(f=0;f<t[0].classList.length;f++)if(t[0].classList[f]=="gridRatingsTypEditable"){$("#propValEdit").val(o);t.addClass("emptyPropEditCell");break}});$("#propValEdit").blur(function(){f.length>0&&u.updateCurveDisplays()})}var e=this,c=$("#dmbPartNumberId"),u,k,a,s,h,i;c.val()?c.css({"border-color":"black"}):c.css({"border-color":"red"});var r="",l=[],w=[],f=[],b=[];for(i=0;i<t.Properties.length;i++)u=t.Properties[i].Name.toLowerCase().trim(),k=t.Properties[i].Type.toLowerCase().trim(),this.helpers.endsWith(k,"_vector")?(a=t.Properties[i].Description.split(/[{}]+/),a.length>1&&f.push(t.Properties[i])):this.helpers.endsWith(u,"sr_max")?l.push(t.Properties[i]):this.helpers.endsWith(u,"_max")||u=="tau"||this.helpers.endsWith(u,"_ic")||this.helpers.endsWith(u,"initial_voltage")||this.helpers.endsWith(u,"initial_current")||this.helpers.endsWith(u,"device_temp")||this.helpers.startsWith(u,"temp_derating")||this.helpers.startsWith(u,"derating_ref")?this.helpers.endsWith(u,"_ic")||this.helpers.endsWith(u,"initial_voltage")||this.helpers.endsWith(u,"initial_current")||this.helpers.endsWith(u,"device_temp")||u=="tau"||w.push(t.Properties[i]):l.push(t.Properties[i]);if(f.length>0){for(s=[],h=[],i=0;i<f.length;i++){var a=f[i].Description.split(/[{}]+/),d=a[1].split(","),g=f[i].Typical.match(/\(([^)]+)\)/)[1],nt=g.split(",").map(Number);s.push(nt);h.push(d[2]+" ("+f[i].Units+")")}for(i=0;i<s[0].length;i++)b.push({independent:s[0][i],dependent:s[1][i]});$("#dmbTableCurveHeadings1").append('<div class="col-md-4 text-center" id="dmbPwlDataHeading" > PWL Parameter Data <\/div>');$("#dmbTableCurveHeadings1").append('<div class="col-md-4 text-center" id="dmbPwlCurveHeading"> PWL Parameter Curve(s) <\/div>');$("#dmbTableDataCurve").append('<div class="col-md-5" id="dmbCurveDataTop"><\/div>');$("#dmbCurveDataTop").append('<div class="col-md-12" id="dmbCurveDataButtons"><\/div>');$("#dmbCurveDataButtons").append('<input class="col-md-3 btn btn-xs" type="button" value="Insert Row" id="dmbPwlInsertRow" title ="Click to append row to table or click on a cell first to insert new row after selected cell" / > ');$("#dmbCurveDataButtons").append('<input class="col-md-3 btn btn-xs" type="button" value="Delete Row" id="dmbPwlDeleteRow" title ="Click on a cell first before attempting to delete" / >');$("#dmbCurveDataTop").append('<div class="col-md-11" id="dmbCurveData"><\/div>');$("#dmbTableDataCurve").append('<div class="col-md-5 col-md-offset-1" id="dmbCurveCanvasDiv" width="400" height="240"><\/div>');$("#dmbCurveCanvasDiv").append('<canvas id="dmbCurveCanvas"><\/canvas>')}var v=new kendo.data.DataSource({data:t,batch:!0,pageSize:10,schema:{model:{id:"SymMdlPropID",fields:{Name:{editable:!1,nullable:!0},Description:{editable:!1,nullable:!0},Minimum:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}},Typical:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}},Maximum:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}},DistType:{editable:!0},Units:{editable:!1,nullable:!1}}},data:function(n){return e.symMdlInfo.GetSymMdlInfoData(n),l}}}),y=new kendo.data.DataSource({data:t,batch:!0,pageSize:10,schema:{model:{id:"SymMdlPropID",fields:{Name:{editable:!1,nullable:!0},Description:{editable:!1,nullable:!0},Minimum:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}},Typical:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}},Maximum:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}},DistType:{editable:!0},Units:{editable:!1,nullable:!1}}},data:function(n){return e.symMdlInfo.GetSymMdlInfoData(n),w}}}),p=new kendo.data.DataSource({data:t,batch:!0,pageSize:10,schema:{model:{fields:{independent:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}},dependent:{type:"string",validation:{custom:function(n){return n.attr("data-custom-msg",r),r.match("^Invalid")?!1:!0}}}}},data:function(n){return e.symMdlInfo.GetSymMdlInfoData(n),b}}});$("#electricalGrid").kendoGrid({dataSource:v,scrollable:!0,navigatable:!0,resizable:!0,columns:[{field:"Name",attributes:{"class":"trigger gridCellNonEditable"},title:"Param",width:85},{field:"Minimum",attributes:{"class":"gridCellEditable gridElectricalMinEditable"},title:"Min",width:60,editor:o},{field:"Typical",attributes:{"class":"gridCellEditable gridElectricalTypEditable"},title:"Typ",width:60,editor:o},{field:"Maximum",attributes:{"class":"gridCellEditable gridElectricalMaxEditable"},title:"Max",width:60,editor:o},{field:"Units",attributes:{"class":"gridCellNonEditable"},title:"Units",width:70}],selectable:!0,editable:!0});$("#ratingsGrid").kendoGrid({dataSource:y,scrollable:!0,navigatable:!0,resizable:!0,columns:[{field:"Name",attributes:{"class":"trigger gridCellNonEditable"},title:"Param",width:85},{field:"Typical",attributes:{"class":"gridCellEditable gridRatingsTypEditable"},title:"Value",width:60,editor:o},{field:"Units",attributes:{"class":"gridCellNonEditable"},title:"Units",width:70}],selectable:!0,editable:!0});v.read();v.pageSize(50);y.read();y.pageSize(50);f.length>0&&($("#dmbCurveData").kendoGrid({dataSource:p,scrollable:!1,navigatable:!0,resizable:!1,columns:[{field:"independent",attributes:{"class":"gridCellEditable gridRatingsTypEditable"},title:h[0],width:70,editor:o},{field:"dependent",attributes:{"class":"gridCellEditable gridRatingsTypEditable"},title:h[1],width:70,editor:o}],selectable:!0,editable:!0,pageable:!0}),p.read(),p.pageSize(10),this.helpers.updateCurveDisplays());$("#dmbPwlInsertRow").on("click",function(){var n=$("#dmbCurveData").data("kendoGrid"),t=n.dataSource.indexOf(n.dataItem(n.select()));e.insertRowAfter(n,t);e.helpers.updateCurveDisplays()});$("#dmbPwlDeleteRow").on("click",function(){var n=$("#dmbCurveData").data("kendoGrid"),i=n.dataItem(n.select()),t;i?(t=n.select(),n.removeRow(t),e.helpers.updateCurveDisplays()):alert("Please select a cell to delete its row")})},t.prototype.insertRowAfter=function(n,i){var r=n.dataSource.data(),f,u,e,o;(i==-1&&(i=r.length-1),r[i]&&r[i].independent&&r[i].dependent)&&(f=this.getNumber(r[i].independent),u=0,r.length>i+1?(e=this.getNumber(r[i+1].independent),u=(e+f)/2):u=f+.01,o=Number(u.toFixed(t.NUMBER_PRECISION)).toString(),n.dataSource.insert(i+1,{independent:o,dependent:r[i].dependent}))},t.prototype.getNumber=function(t){var i=new n.PropertyFormatter;return i.IsSIPrefix(t)?i.SIUnitPrefixes2Double(t):Number(t)},t.NUMBER_PRECISION=4,t}();n.PropertyGrids=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.helpers=new n.Helpers;this.dataManager=n.DataManager.getInstance()}return t.prototype.GetSymMdlInfoData=function(n){var u,f,h,c,l,r,i,t,e,o,s,k;if(this.dataManager.compInfoData=n,u="<h4>Detailed Model Description:<\/h4>",f=n.Description.split("newParagraph"),f.length>1)for(u+=f[0],t=1;t<f.length;t++)u+="<br><br>"+f[t];else u+=n.Description;h=this.helpers.GetCategoryFromBaseName(n.BaseName);$("#symMdlName").html("<h4 span4>"+h+"<\/h4>");$("#symMdlDescriptionTip").html("<h5>"+n.DescriptionToolTip+"<\/h5>");c=this.helpers.GetScaledImage(n.Img);$("#symMdlImage").html('<span class="modelImg">'+c+"<\/span>");l=$("#electricalGrid").data("kendoGrid");r=l.dataSource.data();$("#symMdlDescriptionFull").each(function(){$("#symMdlDescriptionFull div:not([class])").remove()});var a=document.createElement("div"),v=document.createElement("div"),y=document.createElement("div"),p=document.createElement("div"),w=document.createElement("div"),b=document.createElement("div");for(a.innerHTML='<div style="float: left; width: 100%;"><h4>General Model Information:<\/h4><\/div><br />',v.innerHTML='<div style="float: left; width: 100%;"><h5>[Note: Type in a new Part # to create a new model; select an existing component from dropdown menu to update it]<\/h5><\/div>',y.innerHTML='<div style="float: left; width: 100%;">Part #:  '+n.PartNumber+"<\/div><br />",p.innerHTML='<div style="float: left; width: 100%;">Comments:  '+n.Comments+"<\/div><br />",w.innerHTML='<div style="float: left; width: 100%;"><h4>Distribution Information:<\/h4><\/div><br />',b.innerHTML='<div style="float: left; width: 100%;"><h5>[Note: Type in an existing Part # and click Save to add/change distribution settings. Distribution information only applies to parameters with Minimum, Typical, and Maximum values]<\/h5><\/div>',i=document.createDocumentFragment(),i.appendChild(a),i.appendChild(y),i.appendChild(p),i.appendChild(v),i.appendChild(w),t=0;t<r.length;t++)r[t].Minimum&&r[t].Maximum&&(e=document.createElement("div"),o="",o=r[t].DistType==1?"Normal":"Uniform",e.innerHTML='<div style="float: left; width: 100%;">'+r[t].Name+": Distrubution = "+o+"<\/div><br />",i.appendChild(e));i.appendChild(b);s=document.createElement("div");s.innerHTML='<div style="float: left; width: 100%;"><br />'+u+"<\/div><br />";i.appendChild(s);$("#symMdlDescriptionFull").append(i.childNodes);k="/Content/images/Dmb/"+n.BaseName+"_schematic.png";$("#symMdlSchImage img").attr({src:k});var d=$("#modelDetails");$("#symMdlSchImage").css({width:"100%",height:"50%","margin-left":"20px"});$("#symMdlDescriptionFull").css({width:"90%",height:"50%","margin-left":"20px","margin-right":"20px"});$("#symMdlSchImage img").css({width:"100%",height:"100%"})},t}();n.SymMdlInfo=t}(Dmb||(Dmb={})),function(n){var t=function(){function t(){this.showDMB();this.setDMBMenu()}return t.prototype.showDMB=function(){function o(){var n=$(DMB_WINDOW);n[0].clientWidth>=t.DMB_WIDTH?n.css({"overflow-x":"hidden"}):n[0].clientWidth<t.DMB_WIDTH&&n.css({"overflow-x":"scroll"})}var f=t.DMB_MINWIDTH,e=t.DMB_MINHEIGHT,r=Project.CeUtility.getInitialModelingToolDim(Project.MODELING_APP.DMB,Project.MODELING_APP_DIM.WIDTH),u=Project.CeUtility.getInitialModelingToolDim(Project.MODELING_APP.DMB,Project.MODELING_APP_DIM.HEIGHT),i=$(DMB_WINDOW).data("kendoWindow");i?(i.open(),$(DMB_WINDOW).parent().css({width:r+"px",height:u+"px"}),$(DMB_WINDOW).scrollTop(0),i.resize(!0),$("#dmbApp").load("/Dmb/DmbIndex")):($(DMB_WINDOW).kendoWindow({actions:["Close"],draggable:!0,modal:!1,pinned:!1,resizable:!0,title:"Datasheet Model Builder",height:u,width:r,minHeight:e,minWidth:f,resize:o}),i=$(DMB_WINDOW).data("kendoWindow"),i.center(),i.open(),i.bind("close",function(t){var i=new n.Helpers,r,u,f=$("#electricalGrid").data("kendoGrid"),e=$("#ratingsGrid").data("kendoGrid");f&&e&&(r=f.dataSource,u=e.dataSource,(i.doesDataSourceHaveChanges(r)||i.doesDataSourceHaveChanges(u))&&(confirm("OK to close? Any unsaved changes will be lost.")||t.preventDefault()))}),$.ajaxSetup({cache:!0}),$(DMB_APP).load("/Dmb/DmbIndex"),$(DMB_WINDOW).parent().css({"z-index":10200}),i.resize(!0))},t.prototype.createDMBMenu=function(){var t=this,r=function(){var n=$(DMB_WINDOW).data("kendoWindow");n.close()},i,n;t.dmbMenu||(i="<b>DMB Actions<\/b> ",n=new SVWebContextMenu.MenuContent(this,i),n.addMenuElement("Close Datasheet Model Builder",r),n.addSeparatorToMenu(),t.dmbMenu=SVWebContextMenu.MenuHelper.createMenu(n))},t.prototype.setDMBMenu=function(){this.createDMBMenu();this.dmbMenu.bindMenuTo($(DMB_WINDOW))},t.prototype.resizeDMB=function(){var n=$(DMB_WINDOW).data("kendoWindow");n.resize(!0)},t.DMB_WIDTH=700,t.DMB_HEIGHT=610,t.DMB_MINWIDTH=200,t.DMB_MINHEIGHT=300,t.DMB_MAXWIDTH=700,t.DMB_MAXHEIGHT=1500,t}();n.DmbWindow=t}(Dmb||(Dmb={})),function(n){(function(n){n[n.UserLib=0]="UserLib";n[n.SVWebLib=1]="SVWebLib";n[n.PartnerLib=2]="PartnerLib";n[n.NONE=3]="NONE"})(n.LIBRARY||(n.LIBRARY={}));var i=n.LIBRARY,t=function(){function n(){this._mgcDsArray=[];this._usrDsArray=[]}return n.getInstance=function(){return this.dataManagerInstance==null&&(this.dataManagerInstance=new n),this.dataManagerInstance},n.prototype.deleteFromUsrDsArray=function(n){if(this.usrDsArray)for(var t=0;t<this.usrDsArray.length;t++)if(this.usrDsArray[t].ComponentId==n){this.usrDsArray.splice(t,1);break}},n.prototype.addToUsrDsArray=function(n){this.usrDsArray.push(n)},Object.defineProperty(n.prototype,"isModelSaved",{get:function(){return this._isModelSaved},set:function(n){this._isModelSaved=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isModelUpdate",{get:function(){return this._isModelUpdate},set:function(n){this._isModelUpdate=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isUpdated",{get:function(){return this._isUpdated},set:function(n){this._isUpdated=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"activeNameOrPartNum",{get:function(){return this._activeNameOrPartNum},set:function(n){this._activeNameOrPartNum=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"activeId",{get:function(){return this._activeId},set:function(n){this._activeId=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"comboBoxIndex",{get:function(){return this._comboBoxIndex},set:function(n){this._comboBoxIndex=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"activeCategory",{get:function(){return this._activeCategory},set:function(n){this._activeCategory=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"library",{get:function(){return this._library},set:function(n){this._library=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"compInfoData",{get:function(){return this._compInfoData},set:function(n){this._compInfoData=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"mgcDsArray",{get:function(){return this._mgcDsArray},set:function(n){this._mgcDsArray=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"usrDsArray",{get:function(){return this._usrDsArray},set:function(n){this._usrDsArray=n},enumerable:!0,configurable:!0}),n}();n.DataManager=t}(Dmb||(Dmb={})),function(n){if(typeof exports=="object"&&typeof module=="object")module.exports=n();else{if(typeof define=="function"&&define.amd)return define([],n);this.CodeMirror=n()}}(function(){"use strict";function t(n,i){var r,h,u,o,f,e;if(!(this instanceof t))return new t(n,i);this.options=i=i?vt(i):{};vt(kv,i,!1);ss(i);r=i.value;typeof r=="string"&&(r=new nt(r,i.mode));this.doc=r;h=new t.inputStyles[i.inputStyle](this);u=this.display=new aw(n,r,h);u.wrapper.CodeMirror=this;ul(this);rl(this);i.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");i.autofocus&&!eu&&u.input.focus();fl(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new bf,keySeq:null,specialChars:null};o=this;s&&a<11&&setTimeout(function(){o.display.input.reset(!0)},20);tk(this);rg();ar(this);this.curOp.forceUpdate=!0;rp(this,r);i.autofocus&&!eu||o.hasFocus()?setTimeout(ne(vh,this),20):du(this);for(f in gi)gi.hasOwnProperty(f)&&gi[f](this,i[f],bh);for(ol(this),i.finishInit&&i.finishInit(this),e=0;e<ho.length;++e)ho[e](this);vr(this);p&&i.lineWrapping&&getComputedStyle(u.lineDiv).textRendering=="optimizelegibility"&&(u.lineDiv.style.textRendering="auto")}function aw(n,t,r){var u=this;this.input=r;u.scrollbarFiller=i("div",null,"CodeMirror-scrollbar-filler");u.scrollbarFiller.setAttribute("cm-not-content","true");u.gutterFiller=i("div",null,"CodeMirror-gutter-filler");u.gutterFiller.setAttribute("cm-not-content","true");u.lineDiv=i("div",null,"CodeMirror-code");u.selectionDiv=i("div",null,null,"position: relative; z-index: 1");u.cursorDiv=i("div",null,"CodeMirror-cursors");u.measure=i("div",null,"CodeMirror-measure");u.lineMeasure=i("div",null,"CodeMirror-measure");u.lineSpace=i("div",[u.measure,u.lineMeasure,u.selectionDiv,u.cursorDiv,u.lineDiv],null,"position: relative; outline: none");u.mover=i("div",[i("div",[u.lineSpace],"CodeMirror-lines")],null,"position: relative");u.sizer=i("div",[u.mover],"CodeMirror-sizer");u.sizerWidth=null;u.heightForcer=i("div",null,null,"position: absolute; height: "+vp+"px; width: 1px;");u.gutters=i("div",null,"CodeMirror-gutters");u.lineGutter=null;u.scroller=i("div",[u.sizer,u.heightForcer,u.gutters],"CodeMirror-scroll");u.scroller.setAttribute("tabIndex","-1");u.wrapper=i("div",[u.scrollbarFiller,u.gutterFiller,u.scroller],"CodeMirror");s&&a<8&&(u.gutters.style.zIndex=-1,u.scroller.style.paddingRight=0);p||yi&&eu||(u.scroller.draggable=!0);n&&(n.appendChild?n.appendChild(u.wrapper):n(u.wrapper));u.viewFrom=u.viewTo=t.first;u.reportedViewFrom=u.reportedViewTo=t.first;u.view=[];u.renderedView=null;u.externalMeasured=null;u.viewOffset=0;u.lastWrapHeight=u.lastWrapWidth=0;u.updateLineNumbers=null;u.nativeBarWidth=u.barHeight=u.barWidth=0;u.scrollbarsClipped=!1;u.lineNumWidth=u.lineNumInnerWidth=u.lineNumChars=null;u.alignWidgets=!1;u.cachedCharWidth=u.cachedTextHeight=u.cachedPaddingH=null;u.maxLine=null;u.maxLineLength=0;u.maxLineChanged=!1;u.wheelDX=u.wheelDY=u.wheelStartX=u.wheelStartY=null;u.shift=!1;u.selForContextMenu=null;u.activeTouch=null;r.init(u)}function us(n){n.doc.mode=t.getMode(n.options,n.doc.modeOption);ou(n)}function ou(n){n.doc.iter(function(n){n.stateAfter&&(n.stateAfter=null);n.styles&&(n.styles=null)});n.doc.frontier=n.doc.first;vu(n,100);n.state.modeGen++;n.curOp&&it(n)}function vw(n){n.options.lineWrapping?(fu(n.display.wrapper,"CodeMirror-wrap"),n.display.sizer.style.minWidth="",n.display.sizerWidth=null):(uu(n.display.wrapper,"CodeMirror-wrap"),os(n));fs(n);it(n);pu(n);setTimeout(function(){cr(n)},100)}function il(n){var t=bi(n.display),i=n.options.lineWrapping,r=i&&Math.max(5,n.display.scroller.clientWidth/wu(n.display)-3);return function(u){var e,f;if(ir(n.doc,u))return 0;if(e=0,u.widgets)for(f=0;f<u.widgets.length;f++)u.widgets[f].height&&(e+=u.widgets[f].height);return i?e+(Math.ceil(u.text.length/r)||1)*t:e+t}}function fs(n){var t=n.doc,i=il(n);t.iter(function(n){var t=i(n);t!=n.height&&wt(n,t)})}function rl(n){n.display.wrapper.className=n.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+n.options.theme.replace(/(^|\s)\s*/g," cm-s-");pu(n)}function su(n){ul(n);it(n);setTimeout(function(){as(n)},20)}function ul(n){var r=n.display.gutters,e=n.options.gutters,t,u,f;for(sr(r),t=0;t<e.length;++t)u=e[t],f=r.appendChild(i("div",null,"CodeMirror-gutter "+u)),u=="CodeMirror-linenumbers"&&(n.display.lineGutter=f,f.style.width=(n.display.lineNumWidth||1)+"px");r.style.display=t?"":"none";es(n)}function es(n){var t=n.display.gutters.offsetWidth;n.display.sizer.style.marginLeft=t+"px"}function ue(n){var r,u,t,i;if(n.height==0)return 0;for(r=n.text.length,t=n;u=ey(t);)i=u.find(0,!0),t=i.from.line,r+=i.from.ch-i.to.ch;for(t=n;u=sf(t);)i=u.find(0,!0),r-=t.text.length-i.from.ch,t=i.to.line,r+=t.text.length-i.to.ch;return r}function os(n){var t=n.display,i=n.doc;t.maxLine=r(i,i.first);t.maxLineLength=ue(t.maxLine);t.maxLineChanged=!0;i.iter(function(n){var i=ue(n);i>t.maxLineLength&&(t.maxLineLength=i,t.maxLine=n)})}function ss(n){var t=g(n.gutters,"CodeMirror-linenumbers");t==-1&&n.lineNumbers?n.gutters=n.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!n.lineNumbers&&(n.gutters=n.gutters.slice(0),n.gutters.splice(t,1))}function hu(n){var t=n.display,i=t.gutters.offsetWidth,r=Math.round(n.doc.height+uh(n.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:n.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+yt(n)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}function hs(n,t,r){this.cm=r;var f=this.vert=i("div",[i("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),e=this.horiz=i("div",[i("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");n(f);n(e);u(f,"scroll",function(){f.clientHeight&&t(f.scrollTop,"vertical")});u(e,"scroll",function(){e.clientWidth&&t(e.scrollLeft,"horizontal")});this.checkedOverlay=!1;s&&a<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function cs(){}function fl(n){n.display.scrollbars&&(n.display.scrollbars.clear(),n.display.scrollbars.addClass&&uu(n.display.wrapper,n.display.scrollbars.addClass));n.display.scrollbars=new t.scrollbarModel[n.options.scrollbarStyle](function(t){n.display.wrapper.insertBefore(t,n.display.scrollbarFiller);u(t,"mousedown",function(){n.state.focused&&setTimeout(function(){n.display.input.focus()},0)});t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?pr(n,t):bu(n,t)},n);n.display.scrollbars.addClass&&fu(n.display.wrapper,n.display.scrollbars.addClass)}function cr(n,t){var i,r,u;for(t||(t=hu(n)),i=n.display.barWidth,r=n.display.barHeight,el(n,t),u=0;u<4&&i!=n.display.barWidth||r!=n.display.barHeight;u++)i!=n.display.barWidth&&n.options.lineWrapping&&ee(n),el(n,hu(n)),i=n.display.barWidth,r=n.display.barHeight}function el(n,t){var i=n.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px";i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px";r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="";r.bottom&&n.options.coverGutterNextToScrollbar&&n.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}function ls(n,t,i){var f=i&&i.top!=null?Math.max(0,i.top):n.scroller.scrollTop,o,s;f=Math.floor(f-we(n));var h=i&&i.bottom!=null?i.bottom:f+n.wrapper.clientHeight,u=fr(t,f),e=fr(t,h);return i&&i.ensure&&(o=i.ensure.from.line,s=i.ensure.to.line,o<u?(u=o,e=fr(t,ei(r(t,o))+n.wrapper.clientHeight)):Math.min(s,t.lastLine())>=e&&(u=fr(t,ei(r(t,s))-n.wrapper.clientHeight),e=s)),{from:u,to:Math.max(e,u+1)}}function as(n){var t=n.display,r=t.view,i,u,f;if(t.alignWidgets||t.gutters.firstChild&&n.options.fixedGutter){var e=ys(t)-t.scroller.scrollLeft+n.doc.scrollLeft,s=t.gutters.offsetWidth,o=e+"px";for(i=0;i<r.length;i++)if(!r[i].hidden&&(n.options.fixedGutter&&r[i].gutter&&(r[i].gutter.style.left=o),u=r[i].alignable,u))for(f=0;f<u.length;f++)u[f].style.left=o;n.options.fixedGutter&&(t.gutters.style.left=e+s+"px")}}function ol(n){if(!n.options.lineNumbers)return!1;var u=n.doc,r=vs(n.options,u.first+u.size-1),t=n.display;if(r.length!=t.lineNumChars){var f=t.measure.appendChild(i("div",[i("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),e=f.firstChild.offsetWidth,o=f.offsetWidth-e;return t.lineGutter.style.width="",t.lineNumInnerWidth=Math.max(e,t.lineGutter.offsetWidth-o)+1,t.lineNumWidth=t.lineNumInnerWidth+o,t.lineNumChars=t.lineNumInnerWidth?r.length:-1,t.lineGutter.style.width=t.lineNumWidth+"px",es(n),!0}return!1}function vs(n,t){return String(n.lineNumberFormatter(t+n.firstLineNumber))}function ys(n){return n.scroller.getBoundingClientRect().left-n.sizer.getBoundingClientRect().left}function fe(n,t,i){var r=n.display;this.viewport=t;this.visible=ls(r,n.doc,t);this.editorIsHidden=!r.wrapper.offsetWidth;this.wrapperHeight=r.wrapper.clientHeight;this.wrapperWidth=r.wrapper.clientWidth;this.oldDisplayWidth=hi(n);this.force=i;this.dims=ks(n);this.events=[]}function yw(n){var t=n.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=yt(n)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=yt(n)+"px",t.scrollbarsClipped=!0)}function ps(n,t){var i=n.display,o=n.doc,h,s,e;if(t.editorIsHidden)return ci(n),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&tv(n)==0)return!1;ol(n)&&(ci(n),t.dims=ks(n));var c=o.first+o.size,u=Math.max(t.visible.from-n.options.viewportMargin,o.first),f=Math.min(c,t.visible.to+n.options.viewportMargin);return(i.viewFrom<u&&u-i.viewFrom<20&&(u=Math.max(o.first,i.viewFrom)),i.viewTo>f&&i.viewTo-f<20&&(f=Math.min(c,i.viewTo)),si&&(u=gh(n.doc,u),f=sy(n.doc,f)),h=u!=i.viewFrom||f!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth,nk(n,u,f),i.viewOffset=ei(r(n.doc,i.viewFrom)),n.display.mover.style.top=i.viewOffset+"px",s=tv(n),!h&&s==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))?!1:(e=gt(),s>4&&(i.lineDiv.style.display="none"),pw(n,i.updateLineNumbers,t.dims),s>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,e&&gt()!=e&&e.offsetHeight&&e.focus(),sr(i.cursorDiv),sr(i.selectionDiv),i.gutters.style.height=0,h&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,vu(n,400)),i.updateLineNumbers=null,!0)}function sl(n,t){for(var r,i=t.viewport,u=!0;;u=!1){if((!u||!n.options.lineWrapping||t.oldDisplayWidth==hi(n))&&(i&&i.top!=null&&(i={top:Math.min(n.doc.height+uh(n.display)-fh(n),i.top)}),t.visible=ls(n.display,n.doc,i),t.visible.from>=n.display.viewFrom&&t.visible.to<=n.display.viewTo))break;if(!ps(n,t))break;ee(n);r=hu(n);au(n);bs(n,r);cr(n,r)}t.signal(n,"update",n);(n.display.viewFrom!=n.display.reportedViewFrom||n.display.viewTo!=n.display.reportedViewTo)&&(t.signal(n,"viewportChange",n,n.display.viewFrom,n.display.viewTo),n.display.reportedViewFrom=n.display.viewFrom,n.display.reportedViewTo=n.display.viewTo)}function ws(n,t){var i=new fe(n,t),r;ps(n,i)&&(ee(n),sl(n,i),r=hu(n),au(n),bs(n,r),cr(n,r),i.finish())}function bs(n,t){n.display.sizer.style.minHeight=t.docHeight+"px";var i=t.docHeight+n.display.barHeight;n.display.heightForcer.style.top=i+"px";n.display.gutters.style.height=Math.max(i+yt(n),t.clientHeight)+"px"}function ee(n){for(var t,i,e,o,h,u,r=n.display,c=r.lineDiv.offsetTop,f=0;f<r.view.length;f++)if((t=r.view[f],!t.hidden)&&(s&&a<8?(e=t.node.offsetTop+t.node.offsetHeight,i=e-c,c=e):(o=t.node.getBoundingClientRect(),i=o.bottom-o.top),h=t.line.height-i,i<2&&(i=bi(r)),(h>.001||h<-.001)&&(wt(t.line,i),hl(t.line),t.rest)))for(u=0;u<t.rest.length;u++)hl(t.rest[u])}function hl(n){if(n.widgets)for(var t=0;t<n.widgets.length;++t)n.widgets[t].height=n.widgets[t].node.offsetHeight}function ks(n){for(var i=n.display,u={},f={},e=i.gutters.clientLeft,t=i.gutters.firstChild,r=0;t;t=t.nextSibling,++r)u[n.options.gutters[r]]=t.offsetLeft+t.clientLeft+e,f[n.options.gutters[r]]=t.clientWidth;return{fixedPos:ys(i),gutterTotalWidth:i.gutters.offsetWidth,gutterLeft:u,gutterWidth:f,wrapperWidth:i.wrapper.clientWidth}}function pw(n,t,i){function c(t){var i=t.nextSibling;return p&&ct&&n.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),i}for(var r,a,h,e=n.display,v=n.options.lineNumbers,o=e.lineDiv,u=o.firstChild,l=e.view,f=e.viewFrom,s=0;s<l.length;s++){if(r=l[s],!r.hidden)if(r.node&&r.node.parentNode==o){while(u!=r.node)u=c(u);h=v&&t!=null&&t<=f&&r.lineNumber;r.changes&&(g(r.changes,"gutter")>-1&&(h=!1),cl(n,r,f,i));h&&(sr(r.lineNumber),r.lineNumber.appendChild(document.createTextNode(vs(n.options,f))));u=r.node.nextSibling}else a=dw(n,r,f,i),o.insertBefore(a,u);f+=r.size}while(u)u=c(u)}function cl(n,t,i,r){for(var u,f=0;f<t.changes.length;f++)u=t.changes[f],u=="text"?bw(n,t):u=="gutter"?al(n,t,i,r):u=="class"?ds(t):u=="widget"&&kw(n,t,r);t.changes=null}function oe(n){return n.node==n.text&&(n.node=i("div",null,null,"position: relative"),n.text.parentNode&&n.text.parentNode.replaceChild(n.node,n.text),n.node.appendChild(n.text),s&&a<8&&(n.node.style.zIndex=2)),n.node}function ww(n){var t=n.bgClass?n.bgClass+" "+(n.line.bgClass||""):n.line.bgClass,r;t&&(t+=" CodeMirror-linebackground");n.background?t?n.background.className=t:(n.background.parentNode.removeChild(n.background),n.background=null):t&&(r=oe(n),n.background=r.insertBefore(i("div",null,t),r.firstChild))}function ll(n,t){var i=n.display.externalMeasured;return i&&i.line==t.line?(n.display.externalMeasured=null,t.measure=i.measure,i.built):dy(n,t)}function bw(n,t){var r=t.text.className,i=ll(n,t);t.text==t.node&&(t.node=i.pre);t.text.parentNode.replaceChild(i.pre,t.text);t.text=i.pre;i.bgClass!=t.bgClass||i.textClass!=t.textClass?(t.bgClass=i.bgClass,t.textClass=i.textClass,ds(t)):r&&(t.text.className=r)}function ds(n){ww(n);n.line.wrapClass?oe(n).className=n.line.wrapClass:n.node!=n.text&&(n.node.className="");var t=n.textClass?n.textClass+" "+(n.line.textClass||""):n.line.textClass;n.text.className=t||""}function al(n,t,r,u){var f,c,e,s,o,h;if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),f=t.line.gutterMarkers,(n.options.lineNumbers||f)&&(c=oe(t),e=t.gutter=i("div",null,"CodeMirror-gutter-wrapper","left: "+(n.options.fixedGutter?u.fixedPos:-u.gutterTotalWidth)+"px; width: "+u.gutterTotalWidth+"px"),n.display.input.setUneditable(e),c.insertBefore(e,t.text),t.line.gutterClass&&(e.className+=" "+t.line.gutterClass),!n.options.lineNumbers||f&&f["CodeMirror-linenumbers"]||(t.lineNumber=e.appendChild(i("div",vs(n.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+u.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+n.display.lineNumInnerWidth+"px"))),f))for(s=0;s<n.options.gutters.length;++s)o=n.options.gutters[s],h=f.hasOwnProperty(o)&&f[o],h&&e.appendChild(i("div",[h],"CodeMirror-gutter-elt","left: "+u.gutterLeft[o]+"px; width: "+u.gutterWidth[o]+"px"))}function kw(n,t,i){var r,u;for(t.alignable&&(t.alignable=null),r=t.node.firstChild;r;r=u)u=r.nextSibling,r.className=="CodeMirror-linewidget"&&t.node.removeChild(r);vl(n,t,i)}function dw(n,t,i,r){var u=ll(n,t);return t.text=t.node=u.pre,u.bgClass&&(t.bgClass=u.bgClass),u.textClass&&(t.textClass=u.textClass),ds(t),al(n,t,i,r),vl(n,t,r),t.node}function vl(n,t,i){if(yl(n,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)yl(n,t.rest[r],t,i,!1)}function yl(n,t,r,u,f){var h,s,c,e,o;if(t.widgets)for(h=oe(r),s=0,c=t.widgets;s<c.length;++s)e=c[s],o=i("div",[e.node],"CodeMirror-linewidget"),e.handleMouseEvents||o.setAttribute("cm-ignore-events","true"),gw(e,o,r,u),n.display.input.setUneditable(o),f&&e.above?h.insertBefore(o,r.gutter||r.text):h.appendChild(o),tt(e,"redraw")}function gw(n,t,i,r){if(n.noHScroll){(i.alignable||(i.alignable=[])).push(t);var u=r.wrapperWidth;t.style.left=r.fixedPos+"px";n.coverGutter||(u-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px");t.style.width=u+"px"}n.coverGutter&&(t.style.zIndex=5,t.style.position="relative",n.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function gs(t){return n(t.line,t.ch)}function se(n,t){return f(n,t)<0?t:n}function he(n,t){return f(n,t)<0?n:t}function pl(n){n.state.focused||(n.display.input.focus(),vh(n))}function ce(n){return n.options.readOnly||n.doc.cantEdit}function le(t,i,u,f,e){var w=t.doc,s,b,p;t.display.shift=!1;f||(f=w.sel);var l=t.state.pasteIncoming||e=="paste",a=vi(i),o=null;for(l&&f.ranges.length>1&&(ft&&ft.join("\n")==i?o=f.ranges.length%ft.length==0&&df(ft,vi):a.length==f.ranges.length&&(o=df(a,function(n){return[n]}))),s=f.ranges.length-1;s>=0;s--){var y=f.ranges[s],v=y.from(),c=y.to();y.empty()&&(u&&u>0?v=n(v.line,v.ch-u):t.state.overwrite&&!l&&(c=n(c.line,Math.min(r(w,c.line).text.length,c.ch+h(a).length))));b=t.curOp.updateInput;p={from:v,to:c,text:o?o[s%o.length]:a,origin:e||(l?"paste":t.state.cutIncoming?"cut":"+input")};wr(t.doc,p);tt(t,"inputRead",t,p)}i&&!l&&bl(t,i);br(t);t.curOp.updateInput=b;t.curOp.typing=!0;t.state.pasteIncoming=t.state.cutIncoming=!1}function wl(n,t){var i=n.clipboardData&&n.clipboardData.getData("text/plain");if(i)return n.preventDefault(),ut(t,function(){le(t,i,0,null,"paste")}),!0}function bl(n,t){var e,u,i,f,o,s;if(n.options.electricChars&&n.options.smartIndent)for(e=n.doc.sel,u=e.ranges.length-1;u>=0;u--)if(i=e.ranges[u],!(i.head.ch>100)&&(!u||e.ranges[u-1].head.line!=i.head.line)){if(f=n.getModeAt(i.head),o=!1,f.electricChars){for(s=0;s<f.electricChars.length;s++)if(t.indexOf(f.electricChars.charAt(s))>-1){o=tf(n,i.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(r(n.doc,i.head.line).text.slice(0,i.head.ch))&&(o=tf(n,i.head.line,"smart"));o&&tt(n,"electricInput",n,i.head.line)}}function kl(t){for(var u,i,f=[],e=[],r=0;r<t.doc.sel.ranges.length;r++)u=t.doc.sel.ranges[r].head.line,i={anchor:n(u,0),head:n(u+1,0)},e.push(i),f.push(t.getRange(i.anchor,i.head));return{text:f,ranges:e}}function dl(n){n.setAttribute("autocorrect","off");n.setAttribute("autocapitalize","off");n.setAttribute("spellcheck","false")}function nh(n){this.cm=n;this.prevInput="";this.pollingFast=!1;this.polling=new bf;this.inaccurateSelection=!1;this.hasSelection=!1;this.composing=null}function gl(){var n=i("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=i("div",[n],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return p?n.style.width="1000px":n.setAttribute("wrap","off"),hr&&(n.style.border="1px solid black"),dl(n),t}function th(n){this.cm=n;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new bf;this.gracePeriod=!1}function na(n,t){var u=eh(n,t.line),s,i;if(!u||u.hidden)return null;var f=r(n.doc,t.line),h=ca(u,f,t.line),e=at(f),o="left";return e&&(s=is(e,t.ch),o=s%2?"right":"left"),i=va(h.map,t.ch,o),i.offset=i.collapse=="right"?i.end:i.start,i}function lr(n,t){return t&&(n.bad=!0),n}function ae(t,i,r){var u,f,e;if(i==t.display.lineDiv){if(u=t.display.lineDiv.childNodes[r],!u)return lr(t.clipPos(n(t.display.viewTo-1)),!0);i=null;r=0}else for(u=i;;u=u.parentNode){if(!u||u==t.display.lineDiv)return null;if(u.parentNode&&u.parentNode==t.display.lineDiv)break}for(f=0;f<t.display.view.length;f++)if(e=t.display.view[f],e.node==u)return nb(e,i,r)}function nb(t,i,r){function b(i,r,u){for(var o,e,s,l,h,f=-1;f<(y?y.length:0);f++)for(o=f<0?w.map:y[f],e=0;e<o.length;e+=3)if(s=o[e+2],s==i||s==r)return l=c(f<0?t.line:t.rest[f]),h=o[e]+u,(u<0||s!=i)&&(h=o[e+(u?1:0)]),n(l,h)}var v=t.text.firstChild,a=!1,p,e,o,w,y,u,f,l,s;if(!i||!go(v,i))return lr(n(c(t.line),0),!0);if(i==v&&(a=!0,i=v.childNodes[r],r=0,!i))return p=t.rest?h(t.rest):t.line,lr(n(c(p),p.text.length),a);for(e=i.nodeType==3?i:null,o=i,e||i.childNodes.length!=1||i.firstChild.nodeType!=3||(e=i.firstChild,r&&(r=e.nodeValue.length));o.parentNode!=v;)o=o.parentNode;if(w=t.measure,y=w.maps,u=b(e,o,r),u)return lr(u,a);for(f=o.nextSibling,s=e?e.nodeValue.length-r:0;f;f=f.nextSibling){if(u=b(f,f.firstChild,0),u)return lr(n(u.line,u.ch-s),a);s+=f.textContent.length}for(l=o.previousSibling,s=r;l;l=l.previousSibling){if(u=b(l,l.firstChild,-1),u)return lr(n(u.line,u.ch+s),a);s+=f.textContent.length}}function tb(t,i,r,u,f){function h(n){return function(t){return t.id==n}}function s(i){var r,l,a,v,c,y;if(i.nodeType==1){if(r=i.getAttribute("cm-text"),r!=null){r==""&&(r=i.textContent.replace(/\u200b/g,""));e+=r;return}if(l=i.getAttribute("cm-marker"),l){v=t.findMarks(n(u,0),n(f+1,0),h(+l));v.length&&(a=v[0].find())&&(e+=ur(t.doc,a.from,a.to).join("\n"));return}if(i.getAttribute("contenteditable")=="false")return;for(c=0;c<i.childNodes.length;c++)s(i.childNodes[c]);/^(pre|div|p)$/i.test(i.nodeName)&&(o=!0)}else if(i.nodeType==3){if(y=i.nodeValue,!y)return;o&&(e+="\n",o=!1);e+=y}}for(var e="",o=!1;;){if(s(i),i==r)break;i=i.nextSibling}return e}function ni(n,t){this.ranges=n;this.primIndex=t}function l(n,t){this.anchor=n;this.head=t}function lt(n,t){var h=n[t],i,u,r;for(n.sort(function(n,t){return f(n.from(),t.from())}),t=g(n,h),i=1;i<n.length;i++)if(u=n[i],r=n[i-1],f(r.to(),u.from())>=0){var e=he(r.from(),u.from()),o=se(r.to(),u.to()),s=r.empty()?u.from()==u.head:r.from()==r.head;i<=t&&--t;n.splice(--i,2,new l(s?o:e,s?e:o))}return new ni(n,t)}function ti(n,t){return new ni([new l(n,t||n)],0)}function ta(n,t){return Math.max(n.first,Math.min(t,n.first+n.size-1))}function e(t,i){if(i.line<t.first)return n(t.first,0);var u=t.first+t.size-1;return i.line>u?n(u,r(t,u).text.length):ib(i,r(t,i.line).text.length)}function ib(t,i){var r=t.ch;return r==null||r>i?n(t.line,i):r<0?n(t.line,0):t}function cu(n,t){return t>=n.first&&t<n.first+n.size}function rb(n,t){for(var r=[],i=0;i<t.length;i++)r[i]=e(n,t[i]);return r}function lu(n,t,i,r){var u,e;return n.cm&&n.cm.display.shift||n.extend?(u=t.anchor,r&&(e=f(i,u)<0,e!=f(r,u)<0?(u=i,i=r):e!=f(i,r)<0&&(i=r)),new l(u,i)):new l(r||i,i)}function ve(n,t,i,r){w(n,new ni([lu(n,n.sel.primary(),t,i)],0),r)}function ia(n,t,i){for(var f,u=[],r=0;r<n.sel.ranges.length;r++)u[r]=lu(n,n.sel.ranges[r],t[r],null);f=lt(u,n.sel.primIndex);w(n,f,i)}function ih(n,t,i,r){var u=n.sel.ranges.slice(0);u[t]=i;w(n,lt(u,n.sel.primIndex),r)}function ra(n,t,i,r){w(n,ti(t,i),r)}function ub(n,t){var i={ranges:t.ranges,update:function(t){this.ranges=[];for(var i=0;i<t.length;i++)this.ranges[i]=new l(e(n,t[i].anchor),e(n,t[i].head))}};return y(n,"beforeSelectionChange",n,i),n.cm&&y(n.cm,"beforeSelectionChange",n.cm,i),i.ranges!=t.ranges?lt(i.ranges,i.ranges.length-1):t}function ua(n,t,i){var r=n.history.done,u=h(r);u&&u.ranges?(r[r.length-1]=t,ye(n,t,i)):w(n,t,i)}function w(n,t,i){ye(n,t,i);gd(n,n.sel,n.cm?n.cm.curOp.id:NaN,i)}function ye(n,t,i){(et(n,"beforeSelectionChange")||n.cm&&et(n.cm,"beforeSelectionChange"))&&(t=ub(n,t));var r=i&&i.bias||(f(t.primary().head,n.sel.primary().head)<0?-1:1);fa(n,oa(n,t,r,!0));i&&i.scroll===!1||!n.cm||br(n.cm)}function fa(n,t){t.equals(n.sel)||(n.sel=t,n.cm&&(n.cm.curOp.updateInput=n.cm.curOp.selectionChanged=!0,ap(n.cm)),tt(n,"cursorActivity",n))}function ea(n){fa(n,oa(n,n.sel,null,!1),dt)}function oa(n,t,i,r){for(var u,f=0;f<t.ranges.length;f++){var e=t.ranges[f],o=pe(n,e.anchor,i,r),s=pe(n,e.head,i,r);(u||o!=e.anchor||s!=e.head)&&(u||(u=t.ranges.slice(0,f)),u[f]=new l(o,s))}return u?lt(u,t.primIndex):t}function pe(t,i,u,o){var w=!1,h=i,p=u||1,a,v,c,l,s;t.cantEdit=!1;n:for(;;){if(a=r(t,h.line),a.markedSpans)for(v=0;v<a.markedSpans.length;++v)if(c=a.markedSpans[v],l=c.marker,(c.from==null||(l.inclusiveLeft?c.from<=h.ch:c.from<h.ch))&&(c.to==null||(l.inclusiveRight?c.to>=h.ch:c.to>h.ch))){if(o&&(y(l,"beforeCursorEnter"),l.explicitlyCleared))if(a.markedSpans){--v;continue}else break;if(!l.atomic)continue;if(s=l.find(p<0?-1:1),f(s,h)==0&&(s.ch+=p,s.ch<0?s=s.line>t.first?e(t,n(s.line-1)):null:s.ch>a.text.length&&(s=s.line<t.first+t.size-1?n(s.line+1,0):null),!s)){if(w)return o?(t.cantEdit=!0,n(t.first,0)):pe(t,i,u,!0);w=!0;s=i;p=-p}h=s;continue n}return h}}function au(n){n.display.input.showSelection(n.display.input.prepareSelection())}function sa(n,t){for(var r,e,u=n.doc,f={},o=f.cursors=document.createDocumentFragment(),s=f.selection=document.createDocumentFragment(),i=0;i<u.sel.ranges.length;i++)(t!==!1||i!=u.sel.primIndex)&&(r=u.sel.ranges[i],e=r.empty(),(e||n.options.showCursorWhenSelecting)&&fb(n,r,o),e||eb(n,r,s));return f}function fb(n,t,r){var u=ii(n,t.head,"div",null,null,!n.options.singleCursorHeightPerLine),e=r.appendChild(i("div"," ","CodeMirror-cursor")),f;e.style.left=u.left+"px";e.style.top=u.top+"px";e.style.height=Math.max(0,u.bottom-u.top)*n.options.cursorHeight+"px";u.other&&(f=r.appendChild(i("div"," ","CodeMirror-cursor CodeMirror-secondarycursor")),f.style.display="",f.style.left=u.other.left+"px",f.style.top=u.other.top+"px",f.style.height=(u.other.bottom-u.other.top)*.85+"px")}function eb(t,u,f){function o(n,t,r,u){t<0&&(t=0);t=Math.round(t);u=Math.round(u);w.appendChild(i("div",null,"CodeMirror-selected","position: absolute; left: "+n+"px; top: "+t+"px; width: "+(r==null?k-n:r)+"px; height: "+(u-t)+"px"))}function v(i,u,f){function v(r,u){return hh(t,n(i,r),"div",c,u)}var c=r(a,i),l=c.text.length,e,s;return hg(at(c),u||0,f==null?l:f,function(n,t,i){var r=v(n,"left"),c,a,y,p;n==t?(c=r,a=y=r.left):(c=v(t-1,"right"),i=="rtl"&&(p=r,r=c,c=p),a=r.left,y=c.right);u==null&&n==0&&(a=h);c.top-r.top>3&&(o(a,r.top,null,r.bottom),a=h,r.bottom<c.top&&o(a,r.bottom,null,c.top));f==null&&t==l&&(y=k);(!e||r.top<e.top||r.top==e.top&&r.left<e.left)&&(e=r);(!s||c.bottom>s.bottom||c.bottom==s.bottom&&c.right>s.right)&&(s=c);a<h+1&&(a=h);o(a,c.top,y-a,c.bottom)}),{start:e,end:s}}var p=t.display,a=t.doc,w=document.createDocumentFragment(),b=ha(t.display),h=b.left,k=Math.max(p.sizerWidth,hi(t)-p.sizer.offsetLeft)-b.right,c=u.from(),l=u.to();if(c.line==l.line)v(c.line,c.ch,l.ch);else{var d=r(a,c.line),g=r(a,l.line),y=pt(d)==pt(g),e=v(c.line,c.ch,y?d.text.length+1:null).end,s=v(l.line,y?0:null,l.ch).start;y&&(e.top<s.top-2?(o(e.right,e.top,null,e.bottom),o(h,s.top,s.left,s.bottom)):o(e.right,e.top,s.left-e.right,e.bottom));e.bottom<s.top&&o(h,e.bottom,null,s.top)}f.appendChild(w)}function rh(n){var t,i;n.state.focused&&(t=n.display,clearInterval(t.blinker),i=!0,t.cursorDiv.style.visibility="",n.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},n.options.cursorBlinkRate):n.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden"))}function vu(n,t){n.doc.mode.startState&&n.doc.frontier<n.display.viewTo&&n.state.highlight.set(t,ne(ob,n))}function ob(n){var t=n.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=n.display.viewTo)){var u=+new Date+n.options.workTime,i=tr(t.mode,yu(n,t.frontier)),r=[];t.iter(t.frontier,Math.min(t.first+t.size,n.display.viewTo+500),function(f){var s,l,o,e,c,h;if(t.frontier>=n.display.viewFrom){for(s=f.styles,l=yy(n,f,i,!0),f.styles=l.styles,o=f.styleClasses,e=l.classes,e?f.styleClasses=e:o&&(f.styleClasses=null),c=!s||s.length!=f.styles.length||o!=e&&(!o||!e||o.bgClass!=e.bgClass||o.textClass!=e.textClass),h=0;!c&&h<s.length;++h)c=s[h]!=f.styles[h];c&&r.push(t.frontier);f.stateAfter=tr(t.mode,i)}else ic(n,f.text,i),f.stateAfter=t.frontier%5==0?tr(t.mode,i):null;return++t.frontier,+new Date>u?(vu(n,n.options.workDelay),!0):void 0});r.length&&ut(n,function(){for(var t=0;t<r.length;t++)ri(n,r[t],"text")})}}function sb(n,t,i){for(var o,s,h,e,f=n.doc,c=i?-1:t-(n.doc.mode.innerMode?1e3:100),u=t;u>c;--u){if(u<=f.first)return f.first;if(o=r(f,u-1),o.stateAfter&&(!i||u<=f.frontier))return u;s=ot(o.text,null,n.options.tabSize);(e==null||h>s)&&(e=u-1,h=s)}return e}function yu(n,t,i){var f=n.doc,o=n.display,u,e;return f.mode.startState?(u=sb(n,t,i),e=u>f.first&&r(f,u-1).stateAfter,e=e?tr(f.mode,e):dv(f.mode),f.iter(u,t,function(i){ic(n,i.text,e);var r=u==t-1||u%5==0||u>=o.viewFrom&&u<o.viewTo;i.stateAfter=r?tr(f.mode,e):null;++u}),i&&(f.frontier=u),e):!0}function we(n){return n.lineSpace.offsetTop}function uh(n){return n.mover.offsetHeight-n.lineSpace.offsetHeight}function ha(n){if(n.cachedPaddingH)return n.cachedPaddingH;var r=st(n.measure,i("pre","x")),u=window.getComputedStyle?window.getComputedStyle(r):r.currentStyle,t={left:parseInt(u.paddingLeft),right:parseInt(u.paddingRight)};return isNaN(t.left)||isNaN(t.right)||(n.cachedPaddingH=t),t}function yt(n){return vp-n.display.nativeBarWidth}function hi(n){return n.display.scroller.clientWidth-yt(n)-n.display.barWidth}function fh(n){return n.display.scroller.clientHeight-yt(n)-n.display.barHeight}function hb(n,t,i){var f=n.options.lineWrapping,h=f&&hi(n),e,u,r,o,s;if(!t.measure.heights||f&&t.measure.width!=h){if(e=t.measure.heights=[],f)for(t.measure.width=h,u=t.text.firstChild.getClientRects(),r=0;r<u.length-1;r++)o=u[r],s=u[r+1],Math.abs(o.bottom-s.bottom)>2&&e.push((o.bottom+s.top)/2-i.top);e.push(i.bottom-i.top)}}function ca(n,t,i){var r;if(n.line==t)return{map:n.measure.map,cache:n.measure.cache};for(r=0;r<n.rest.length;r++)if(n.rest[r]==t)return{map:n.measure.maps[r],cache:n.measure.caches[r]};for(r=0;r<n.rest.length;r++)if(c(n.rest[r])>i)return{map:n.measure.maps[r],cache:n.measure.caches[r],before:!0}}function cb(n,t){var r,i,u;return t=pt(t),r=c(t),i=n.display.externalMeasured=new nv(n.doc,t,r),i.lineN=r,u=i.built=dy(n,i),i.text=u.pre,st(n.display.lineMeasure,u.pre),i}function la(n,t,i,r){return aa(n,oh(n,t),i,r)}function eh(n,t){if(t>=n.display.viewFrom&&t<n.display.viewTo)return n.display.view[di(n,t)];var i=n.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function oh(n,t){var u=c(t),i=eh(n,u),r;return i&&!i.text?i=null:i&&i.changes&&cl(n,i,u,ks(n)),i||(i=cb(n,t)),r=ca(i,t,u),{line:t,view:i,rect:null,map:r.map,cache:r.cache,before:r.before,hasHeights:!1}}function aa(n,t,i,r,u){t.before&&(i=-1);var e=i+(r||""),f;return t.cache.hasOwnProperty(e)?f=t.cache[e]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(hb(n,t.view,t.rect),t.hasHeights=!0),f=lb(n,t,i,r),f.bogus||(t.cache[e]=f)),{left:f.left,right:f.right,top:u?f.rtop:f.top,bottom:u?f.rbottom:f.bottom}}function va(n,t,i){for(var e,f,s,u,h,o,r=0;r<n.length;r+=3)if(e=n[r],f=n[r+1],t<e?(u=0,h=1,o="left"):t<f?(u=t-e,h=u+1):(r==n.length-3||t==f&&n[r+3]>t)&&(h=f-e,u=h-1,t>=f&&(o="right")),u!=null){if(s=n[r+2],e==f&&i==(s.insertLeft?"left":"right")&&(o=i),i=="left"&&u==0)while(r&&n[r-2]==n[r-3]&&n[r-1].insertLeft)s=n[(r-=3)+2],o="left";if(i=="right"&&u==f-e)while(r<n.length-3&&n[r+3]==n[r+4]&&!n[r+5].insertLeft)s=n[(r+=3)+2],o="right";break}return{node:s,start:u,end:h,collapse:o,coverStart:e,coverEnd:f}}function lb(n,t,i,r){var e=va(t.map,i,r),h=e.node,f=e.start,c=e.end,y=e.collapse,u,l,v,o;if(h.nodeType==3){for(o=0;o<4;o++){while(f&&te(t.line.text.charAt(e.coverStart+f)))--f;while(e.coverStart+c<e.coverEnd&&te(t.line.text.charAt(e.coverStart+c)))++c;if(s&&a<9&&f==0&&c==e.coverEnd-e.coverStart?u=h.parentNode.getBoundingClientRect():s&&n.options.lineWrapping?(l=or(h,f,c).getClientRects(),u=l.length?l[r=="right"?l.length-1:0]:be):u=or(h,f,c).getBoundingClientRect()||be,u.left||u.right||f==0)break;c=f;f=f-1;y="right"}s&&a<11&&(u=ab(n.display.measure,u))}else f>0&&(y=r="right"),u=n.options.lineWrapping&&(l=h.getClientRects()).length>1?l[r=="right"?l.length-1:0]:h.getBoundingClientRect();s&&a<9&&!f&&(!u||!u.left&&!u.right)&&(v=h.parentNode.getClientRects()[0],u=v?{left:v.left,right:v.left+wu(n.display),top:v.top,bottom:v.bottom}:be);var b=u.top-t.rect.top,k=u.bottom-t.rect.top,d=(b+k)/2,p=t.view.measure.heights;for(o=0;o<p.length-1;o++)if(d<p[o])break;var g=o?p[o-1]:0,nt=p[o],w={left:(y=="right"?u.right:u.left)-t.rect.left,right:(y=="left"?u.left:u.right)-t.rect.left,top:g,bottom:nt};return u.left||u.right||(w.bogus=!0),n.options.singleCursorHeightPerLine||(w.rtop=b,w.rbottom=k),w}function ab(n,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!sg(n))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function ya(n){if(n.measure&&(n.measure.cache={},n.measure.heights=null,n.rest))for(var t=0;t<n.rest.length;t++)n.measure.caches[t]={}}function pa(n){n.display.externalMeasure=null;sr(n.display.lineMeasure);for(var t=0;t<n.display.view.length;t++)ya(n.display.view[t])}function pu(n){pa(n);n.display.cachedCharWidth=n.display.cachedTextHeight=n.display.cachedPaddingH=null;n.options.lineWrapping||(n.display.maxLineChanged=!0);n.display.lineNumChars=null}function wa(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ba(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function sh(n,t,i,r){var f,e,u,o,s;if(t.widgets)for(f=0;f<t.widgets.length;++f)t.widgets[f].above&&(e=cf(t.widgets[f]),i.top+=e,i.bottom+=e);return r=="line"?i:(r||(r="local"),u=ei(t),r=="local"?u+=we(n.display):u-=n.display.viewOffset,(r=="page"||r=="window")&&(o=n.display.lineSpace.getBoundingClientRect(),u+=o.top+(r=="window"?0:ba()),s=o.left+(r=="window"?0:wa()),i.left+=s,i.right+=s),i.top+=u,i.bottom+=u,i)}function ka(n,t,i){var r,u,f,e;return i=="div"?t:(r=t.left,u=t.top,i=="page"?(r-=wa(),u-=ba()):i!="local"&&i||(f=n.display.sizer.getBoundingClientRect(),r+=f.left,u+=f.top),e=n.display.lineSpace.getBoundingClientRect(),{left:r-e.left,top:u-e.top})}function hh(n,t,i,u,f){return u||(u=r(n.doc,t.line)),sh(n,u,la(n,u,t.ch,f),i)}function ii(n,t,i,u,f,e){function h(t,r){var o=aa(n,f,t,r?"right":"left",e);return r?o.left=o.right:o.right=o.left,sh(n,u,o,i)}function l(n,t){var i=o[t],r=i.level%2;return(n==yc(i)&&t&&i.level<o[t-1].level?(i=o[--t],n=pc(i)-(i.level%2?0:1),r=!0):n==pc(i)&&t<o.length-1&&i.level<o[t+1].level&&(i=o[++t],n=yc(i)-i.level%2,r=!1),r&&n==i.to&&n>i.from)?h(n-1):h(n,r)}var o,s,a,c;return(u=u||r(n.doc,t.line),f||(f=oh(n,u)),o=at(u),s=t.ch,!o)?h(s):(a=is(o,s),c=l(s,a),re!=null&&(c.other=l(s,re)),c)}function da(n,t){var i=0,t=e(n.doc,t),u,f;return n.options.lineWrapping||(i=wu(n.display)*t.ch),u=r(n.doc,t.line),f=ei(u)+we(n.display),{left:i,right:i,top:f,bottom:f+u.height}}function ke(t,i,r,u){var f=n(t,i);return f.xRel=u,r&&(f.outside=!0),f}function ch(n,t,i){var u=n.doc,f,s,e;if(i+=n.display.viewOffset,i<0)return ke(u.first,0,!0,-1);if(f=fr(u,i),s=u.first+u.size-1,f>s)return ke(u.first+u.size-1,r(u,s).text.length,!0,1);for(t<0&&(t=0),e=r(u,f);;){var o=vb(n,e,f,t,i),h=sf(e),l=h&&h.find(0,!0);if(h&&(o.ch>l.from.ch||o.ch==l.from.ch&&o.xRel>0))f=c(e=l.to.line);else return o}}function vb(t,i,r,u,f){function p(u){var f=ii(t,n(r,u),"line",i,rt);return(h=!0,g>f.bottom)?f.left-nt:g<f.top?f.left+nt:(h=!1,f.left)}var g=f-ei(i),h=!1,nt=2*t.display.wrapper.clientWidth,rt=oh(t,i),tt=at(i),w=i.text.length,e=ns(i),o=ts(i),v=p(e),it=h,l=p(o),b=h,c,k,a,s,d,y;if(u>l)return ke(r,o,b,1);for(;;){if(tt?o==e||o==bc(i,e,1):o-e<=1){for(c=u<v||u-v<=l-u?e:o,k=u-(c==e?v:l);te(i.text.charAt(c));)++c;return ke(r,c,c==e?it:b,k<-1?-1:k>1?1:0)}if(a=Math.ceil(w/2),s=e+a,tt)for(s=e,d=0;d<a;++d)s=bc(i,s,1);y=p(s);y>u?(o=s,l=y,(b=h)&&(l+=1e3),w=a):(e=s,v=y,it=h,w-=a)}}function bi(n){var r,t;if(n.cachedTextHeight!=null)return n.cachedTextHeight;if(wi==null){for(wi=i("pre"),r=0;r<49;++r)wi.appendChild(document.createTextNode("x")),wi.appendChild(i("br"));wi.appendChild(document.createTextNode("x"))}return st(n.measure,wi),t=wi.offsetHeight/50,t>3&&(n.cachedTextHeight=t),sr(n.measure),t||1}function wu(n){var r,f,u,t;return n.cachedCharWidth!=null?n.cachedCharWidth:(r=i("span","xxxxxxxxxx"),f=i("pre",[r]),st(n.measure,f),u=r.getBoundingClientRect(),t=(u.right-u.left)/10,t>2&&(n.cachedCharWidth=t),t||10)}function ar(n){n.curOp={cm:n,viewChanged:!1,startHeight:n.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++ga};ki?ki.ops.push(n.curOp):n.curOp.ownsGroup=ki={ops:[n.curOp],delayedCallbacks:[]}}function yb(n){var u=n.delayedCallbacks,i=0,r,t;do{for(;i<u.length;i++)u[i]();for(r=0;r<n.ops.length;r++)if(t=n.ops[r],t.cursorActivityHandlers)while(t.cursorActivityCalled<t.cursorActivityHandlers.length)t.cursorActivityHandlers[t.cursorActivityCalled++](t.cm)}while(i<u.length)}function vr(n){var r=n.curOp,t=r.ownsGroup,i;if(t)try{yb(t)}finally{for(ki=null,i=0;i<t.ops.length;i++)t.ops[i].cm.curOp=null;pb(t)}}function pb(n){for(var i=n.ops,t=0;t<i.length;t++)wb(i[t]);for(t=0;t<i.length;t++)bb(i[t]);for(t=0;t<i.length;t++)kb(i[t]);for(t=0;t<i.length;t++)db(i[t]);for(t=0;t<i.length;t++)gb(i[t])}function wb(n){var t=n.cm,i=t.display;yw(t);n.updateMaxLine&&os(t);n.mustUpdate=n.viewChanged||n.forceUpdate||n.scrollTop!=null||n.scrollToPos&&(n.scrollToPos.from.line<i.viewFrom||n.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping;n.update=n.mustUpdate&&new fe(t,n.mustUpdate&&{top:n.scrollTop,ensure:n.scrollToPos},n.forceUpdate)}function bb(n){n.updatedDisplay=n.mustUpdate&&ps(n.cm,n.update)}function kb(n){var t=n.cm,i=t.display;n.updatedDisplay&&ee(t);n.barMeasure=hu(t);i.maxLineChanged&&!t.options.lineWrapping&&(n.adjustWidthTo=la(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=n.adjustWidthTo,n.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+n.adjustWidthTo+yt(t)+t.display.barWidth),n.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+n.adjustWidthTo-hi(t)));(n.updatedDisplay||n.selectionChanged)&&(n.preparedSelection=i.input.prepareSelection())}function db(n){var t=n.cm;n.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=n.adjustWidthTo+"px",n.maxScrollLeft<t.doc.scrollLeft&&pr(t,Math.min(t.display.scroller.scrollLeft,n.maxScrollLeft),!0),t.display.maxLineChanged=!1);n.preparedSelection&&t.display.input.showSelection(n.preparedSelection);n.updatedDisplay&&bs(t,n.barMeasure);(n.updatedDisplay||n.startHeight!=t.doc.height)&&cr(t,n.barMeasure);n.selectionChanged&&rh(t);t.state.focused&&n.updateInput&&t.display.input.reset(n.typing);n.focus&&n.focus==gt()&&pl(n.cm)}function gb(n){var i=n.cm,t=i.display,u=i.doc,s,f,o,r;if(n.updatedDisplay&&sl(i,n.update),t.wheelStartX!=null&&(n.scrollTop!=null||n.scrollLeft!=null||n.scrollToPos)&&(t.wheelStartX=t.wheelStartY=null),n.scrollTop!=null&&(t.scroller.scrollTop!=n.scrollTop||n.forceScroll)&&(u.scrollTop=Math.max(0,Math.min(t.scroller.scrollHeight-t.scroller.clientHeight,n.scrollTop)),t.scrollbars.setScrollTop(u.scrollTop),t.scroller.scrollTop=u.scrollTop),n.scrollLeft!=null&&(t.scroller.scrollLeft!=n.scrollLeft||n.forceScroll)&&(u.scrollLeft=Math.max(0,Math.min(t.scroller.scrollWidth-hi(i),n.scrollLeft)),t.scrollbars.setScrollLeft(u.scrollLeft),t.scroller.scrollLeft=u.scrollLeft,as(i)),n.scrollToPos&&(s=bk(i,e(u,n.scrollToPos.from),e(u,n.scrollToPos.to),n.scrollToPos.margin),n.scrollToPos.isCursor&&i.state.focused&&wk(i,s)),f=n.maybeHiddenMarkers,o=n.maybeUnhiddenMarkers,f)for(r=0;r<f.length;++r)f[r].lines.length||y(f[r],"hide");if(o)for(r=0;r<o.length;++r)o[r].lines.length&&y(o[r],"unhide");t.wrapper.offsetHeight&&(u.scrollTop=i.display.scroller.scrollTop);n.changeObjs&&y(i,"changes",i,n.changeObjs);n.update&&n.update.finish()}function ut(n,t){if(n.curOp)return t();ar(n);try{return t()}finally{vr(n)}}function v(n,t){return function(){if(n.curOp)return t.apply(n,arguments);ar(n);try{return t.apply(n,arguments)}finally{vr(n)}}}function b(n){return function(){if(this.curOp)return n.apply(this,arguments);ar(this);try{return n.apply(this,arguments)}finally{vr(this)}}}function d(n){return function(){var t=this.cm;if(!t||t.curOp)return n.apply(this,arguments);ar(t);try{return n.apply(this,arguments)}finally{vr(t)}}}function nv(n,t,i){this.line=t;this.rest=hd(t);this.size=this.rest?c(h(this.rest))-i+1:1;this.node=this.text=null;this.hidden=ir(n,t)}function de(n,t,i){for(var f,e=[],o,u=t;u<i;u=o)f=new nv(n.doc,r(n.doc,u),u),o=u+f.size,e.push(f);return e}function it(n,t,i,r){var u,f,o,s,e;t==null&&(t=n.doc.first);i==null&&(i=n.doc.first+n.doc.size);r||(r=0);u=n.display;r&&i<u.viewTo&&(u.updateLineNumbers==null||u.updateLineNumbers>t)&&(u.updateLineNumbers=t);n.curOp.viewChanged=!0;t>=u.viewTo?si&&gh(n.doc,t)<u.viewTo&&ci(n):i<=u.viewFrom?si&&sy(n.doc,i+r)>u.viewFrom?ci(n):(u.viewFrom+=r,u.viewTo+=r):t<=u.viewFrom&&i>=u.viewTo?ci(n):t<=u.viewFrom?(f=ge(n,i,i+r,1),f?(u.view=u.view.slice(f.index),u.viewFrom=f.lineN,u.viewTo+=r):ci(n)):i>=u.viewTo?(f=ge(n,t,t,-1),f?(u.view=u.view.slice(0,f.index),u.viewTo=f.lineN):ci(n)):(o=ge(n,t,t,-1),s=ge(n,i,i+r,1),o&&s?(u.view=u.view.slice(0,o.index).concat(de(n,o.lineN,s.lineN)).concat(u.view.slice(s.index)),u.viewTo+=r):ci(n));e=u.externalMeasured;e&&(i<e.lineN?e.lineN+=r:t<e.lineN+e.size&&(u.externalMeasured=null))}function ri(n,t,i){var r,u,f,e;(n.curOp.viewChanged=!0,r=n.display,u=n.display.externalMeasured,u&&t>=u.lineN&&t<u.lineN+u.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)||(f=r.view[di(n,t)],f.node!=null)&&(e=f.changes||(f.changes=[]),g(e,i)==-1&&e.push(i))}function ci(n){n.display.viewFrom=n.display.viewTo=n.doc.first;n.display.view=[];n.display.viewOffset=0}function di(n,t){var r,i;if(t>=n.display.viewTo||(t-=n.display.viewFrom,t<0))return null;for(r=n.display.view,i=0;i<r.length;i++)if(t-=r[i].size,t<0)return i}function ge(n,t,i,r){var u=di(n,t),o,f=n.display.view,s,e;if(!si||i==n.doc.first+n.doc.size)return{index:u,lineN:i};for(s=0,e=n.display.viewFrom;s<u;s++)e+=f[s].size;if(e!=t){if(r>0){if(u==f.length-1)return null;o=e+f[u].size-t;u++}else o=e-t;t+=o;i+=o}while(gh(n.doc,i)!=i){if(u==(r<0?0:f.length-1))return null;i+=r*f[u-(r<0?1:0)].size;u+=r}return{index:u,lineN:i}}function nk(n,t,i){var r=n.display,u=r.view;u.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=de(n,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=de(n,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(di(n,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(de(n,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,di(n,i))));r.viewTo=i}function tv(n){for(var t,r=n.display.view,u=0,i=0;i<r.length;i++)t=r[i],t.hidden||t.node&&!t.changes||++u;return u}function tk(t){function h(){i.activeTouch&&(o=setTimeout(function(){i.activeTouch=null},1e3),f=i.activeTouch,f.end=+new Date)}function p(n){if(n.touches.length!=1)return!1;var t=n.touches[0];return t.radiusX<=1&&t.radiusY<=1}function c(n,t){if(t.left==null)return!0;var i=t.left-n.left,r=t.top-n.top;return i*i+r*r>400}var i=t.display,o,f,r;u(i.scroller,"mousedown",v(t,iv));s&&a<11?u(i.scroller,"dblclick",v(t,function(n){var i,r;kt(t,n)||(i=yr(t,n),!i||uv(t,n)||ui(t.display,n))||(k(n),r=t.findWordAt(i),ve(t.doc,r.anchor,r.head))})):u(i.scroller,"dblclick",function(n){kt(t,n)||k(n)});rs||u(i.scroller,"contextmenu",function(n){lv(t,n)});f={end:0};u(i.scroller,"touchstart",function(n){if(!p(n)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,moved:!1,prev:t-f.end<=300?f:null};n.touches.length==1&&(i.activeTouch.left=n.touches[0].pageX,i.activeTouch.top=n.touches[0].pageY)}});u(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)});u(i.scroller,"touchend",function(r){var u=i.activeTouch,f,o;u&&!ui(i,r)&&u.left!=null&&!u.moved&&new Date-u.start<300&&(f=t.coordsChar(i.activeTouch,"page"),o=!u.prev||c(u,u.prev)?new l(f,f):!u.prev.prev||c(u,u.prev.prev)?t.findWordAt(f):new l(n(f.line,0),e(t.doc,n(f.line+1,0))),t.setSelection(o.anchor,o.head),t.focus(),k(r));h()});u(i.scroller,"touchcancel",h);u(i.scroller,"scroll",function(){i.scroller.clientHeight&&(bu(t,i.scroller.scrollTop),pr(t,i.scroller.scrollLeft,!0),y(t,"scroll",t))});u(i.scroller,"mousewheel",function(n){fv(t,n)});u(i.scroller,"DOMMouseScroll",function(n){fv(t,n)});u(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0});i.dragFunctions={simple:function(n){kt(t,n)||bo(n)},start:function(n){sk(t,n)},drop:v(t,ok)};r=i.input.getField();u(r,"keyup",function(n){hv.call(t,n)});u(r,"keydown",v(t,sv));u(r,"keypress",v(t,cv));u(r,"focus",ne(vh,t));u(r,"blur",ne(du,t))}function ik(n,i,r){var o=r&&r!=t.Init,f,e;!i!=!o&&(f=n.display.dragFunctions,e=i?u:bt,e(n.display.scroller,"dragstart",f.start),e(n.display.scroller,"dragenter",f.simple),e(n.display.scroller,"dragover",f.simple),e(n.display.scroller,"drop",f.drop))}function rk(n){var t=n.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,n.setSize())}function ui(n,t){for(var i=yf(t);i!=n.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==n.sizer&&i!=n.mover)return!0}function yr(t,i,u,f){var a=t.display,s,c,h,e,o,l;if(!u&&yf(i).getAttribute("cm-not-content")=="true")return null;h=a.lineSpace.getBoundingClientRect();try{s=i.clientX-h.left;c=i.clientY-h.top}catch(i){return null}return e=ch(t,s,c),f&&e.xRel==1&&(o=r(t.doc,e.line).text).length==e.ch&&(l=ot(o,o.length,t.options.tabSize)-o.length,e=n(e.line,Math.max(0,Math.round((s-ha(t.display).left)/wu(t.display))-l))),e}function iv(n){var t=this,i=t.display,r;if((!i.activeTouch||!i.input.supportsTouch())&&!kt(t,n)){if(i.shift=n.shiftKey,ui(i,n)){p||(i.scroller.draggable=!1,setTimeout(function(){i.scroller.draggable=!0},100));return}if(!uv(t,n)){r=yr(t,n);window.focus();switch(lp(n)){case 1:r?uk(t,n,r):yf(n)==i.scroller&&k(n);break;case 2:p&&(t.state.lastMiddleDown=+new Date);r&&ve(t.doc,r);setTimeout(function(){i.input.focus()},20);k(n);break;case 3:rs?lv(t,n):ak(t)}}}}function uk(n,t,i){var r,u,o,h,e;s?setTimeout(ne(pl,n),0):n.curOp.focus=gt();r=+new Date;to&&to.time>r-400&&f(to.pos,i)==0?u="triple":no&&no.time>r-400&&f(no.pos,i)==0?(u="double",to={time:r,pos:i}):(u="single",no={time:r,pos:i});o=n.doc.sel;h=ct?t.metaKey:t.ctrlKey;n.options.dragDrop&&tw&&!ce(n)&&u=="single"&&(e=o.contains(i))>-1&&(f((e=o.ranges[e]).from(),i)<0||i.xRel>0)&&(f(e.to(),i)>0||i.xRel<0)?fk(n,t,i,h):ek(n,t,i,u,h)}function fk(n,t,i,r){var f=n.display,o=+new Date,e=v(n,function(u){p&&(f.scroller.draggable=!1);n.state.draggingText=!1;bt(document,"mouseup",e);bt(f.scroller,"drop",e);Math.abs(t.clientX-u.clientX)+Math.abs(t.clientY-u.clientY)<10&&(k(u),!r&&+new Date-200<o&&ve(n.doc,i),p||s&&a==9?setTimeout(function(){document.body.focus();f.input.focus()},20):f.input.focus())});p&&(f.scroller.draggable=!0);n.state.draggingText=e;f.scroller.dragDrop&&f.scroller.dragDrop();u(document,"mouseup",e);u(f.scroller,"drop",e)}function ek(t,i,o,s,h){function ht(i){var h,st,d,p,v,u;if(f(it,i)!=0)if(it=i,s=="rect"){var u=[],k=t.options.tabSize,rt=ot(r(c,o.line).text,o.ch,k),ut=ot(r(c,i.line).text,i.ch,k),ft=Math.min(rt,ut),et=Math.max(rt,ut);for(h=Math.min(o.line,i.line),st=Math.min(t.lastLine(),Math.max(o.line,i.line));h<=st;h++)d=r(c,h).text,p=pp(d,ft,k),ft==et?u.push(new l(n(h,p),n(h,p))):d.length>p&&u.push(new l(n(h,p),n(h,pp(d,et,k))));u.length||u.push(new l(o,o));w(c,lt(b.ranges.slice(0,a).concat(u),a),{origin:"*mouse",scroll:!1});t.scrollIntoView(i)}else{var nt=y,g=nt.anchor,tt=i;s!="single"&&(v=s=="double"?t.findWordAt(i):new l(n(i.line,0),e(c,n(i.line+1,0))),f(v.anchor,g)>0?(tt=v.head,g=he(nt.from(),v.anchor)):(tt=v.anchor,g=se(nt.to(),v.head)));u=b.ranges.slice(0);u[a]=new l(e(c,g),tt);w(c,lt(u,a),oc)}}function ut(n){var e=++d,i=yr(t,n,!0,s=="rect"),r,u;i&&(f(i,it)!=0?(t.curOp.focus=gt(),ht(i),r=ls(g,c),(i.line>=r.to||i.line<r.from)&&setTimeout(v(t,function(){d==e&&ut(n)}),150)):(u=n.clientY<rt.top?-20:n.clientY>rt.bottom?20:0,u&&setTimeout(v(t,function(){d==e&&(g.scroller.scrollTop+=u,ut(n))}),50)))}function st(n){d=Infinity;k(n);g.input.focus();bt(document,"mousemove",ft);bt(document,"mouseup",et);c.history.lastSelOrigin=null}var g=t.display,c=t.doc,y,a,b,p,nt,tt,it,rt,d,ft,et;k(i);b=c.sel;p=b.ranges;h&&!i.shiftKey?(a=c.sel.contains(o),y=a>-1?p[a]:new l(o,o)):(y=c.sel.primary(),a=c.sel.primIndex);i.altKey?(s="rect",h||(y=new l(o,o)),o=yr(t,i,!0,!0),a=-1):s=="double"?(nt=t.findWordAt(o),y=t.display.shift||c.extend?lu(c,y,nt.anchor,nt.head):nt):s=="triple"?(tt=new l(n(o.line,0),e(c,n(o.line+1,0))),y=t.display.shift||c.extend?lu(c,y,tt.anchor,tt.head):tt):y=lu(c,y,o);h?a==-1?(a=p.length,w(c,lt(p.concat([y]),a),{scroll:!1,origin:"*mouse"})):p.length>1&&p[a].empty()&&s=="single"&&!i.shiftKey?(w(c,lt(p.slice(0,a).concat(p.slice(a+1)),0)),b=c.sel):ih(c,a,y,oc):(a=0,w(c,new ni([y],0),oc),b=c.sel);it=o;rt=g.wrapper.getBoundingClientRect();d=0;ft=v(t,function(n){lp(n)?ut(n):st(n)});et=v(t,st);u(document,"mousemove",ft);u(document,"mouseup",et)}function rv(n,t,i,r,u){var s,e,o,h,f,c,l,a;try{s=t.clientX;e=t.clientY}catch(t){return!1}if(s>=Math.floor(n.display.gutters.getBoundingClientRect().right))return!1;if(r&&k(t),o=n.display,h=o.lineDiv.getBoundingClientRect(),e>h.bottom||!et(n,i))return ec(t);for(e-=h.top-o.viewOffset,f=0;f<n.options.gutters.length;++f)if(c=o.gutters.childNodes[f],c&&c.getBoundingClientRect().right>=s)return l=fr(n.doc,e),a=n.options.gutters[f],u(n,i,n,l,a,t),ec(t)}function uv(n,t){return rv(n,t,"gutterClick",!0,tt)}function ok(n){var t=this,i,u,f,o,r;if(!kt(t,n)&&!ui(t.display,n)&&(k(n),s&&(lh=+new Date),i=yr(t,n,!0),u=n.dataTransfer.files,i&&!ce(t)))if(u&&u.length&&window.FileReader&&window.File){var h=u.length,f=Array(h),c=0,l=function(n,r){var u=new FileReader;u.onload=v(t,function(){if(f[r]=u.result,++c==h){i=e(t.doc,i);var n={from:i,to:i,text:vi(f.join("\n")),origin:"paste"};wr(t.doc,n);ua(t.doc,ti(i,li(n)))}});u.readAsText(n)};for(r=0;r<h;++r)l(u[r],r)}else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(n);setTimeout(function(){t.display.input.focus()},20);return}try{if(f=n.dataTransfer.getData("Text"),f){if(!t.state.draggingText||(ct?n.altKey:n.ctrlKey)||(o=t.listSelections()),ye(t.doc,ti(i,i)),o)for(r=0;r<o.length;++r)nf(t.doc,"",o[r].anchor,o[r].head,"drag");t.replaceSelection(f,"around","paste");t.display.input.focus()}}catch(n){}}}function sk(n,t){if(s&&(!n.state.draggingText||+new Date-lh<100)){bo(t);return}if(!kt(n,t)&&!ui(n.display,t)&&(t.dataTransfer.setData("Text",n.getSelection()),t.dataTransfer.setDragImage&&!gc)){var r=i("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";ht&&(r.width=r.height=1,n.display.wrapper.appendChild(r),r._top=r.offsetTop);t.dataTransfer.setDragImage(r,0,0);ht&&r.parentNode.removeChild(r)}}function bu(n,t){Math.abs(n.doc.scrollTop-t)<2||(n.doc.scrollTop=t,yi||ws(n,{top:t}),n.display.scroller.scrollTop!=t&&(n.display.scroller.scrollTop=t),n.display.scrollbars.setScrollTop(t),yi&&ws(n),vu(n,100))}function pr(n,t,i){(i?t==n.doc.scrollLeft:Math.abs(n.doc.scrollLeft-t)<2)||(t=Math.min(t,n.display.scroller.scrollWidth-n.display.scroller.clientWidth),n.doc.scrollLeft=t,as(n),n.display.scroller.scrollLeft!=t&&(n.display.scroller.scrollLeft=t),n.display.scrollbars.setScrollLeft(t))}function fv(n,t){var a=ah(t),e=a.x,u=a.y,i=n.display,r=i.scroller,f,h,o;if(e&&r.scrollWidth>r.clientWidth||u&&r.scrollHeight>r.clientHeight){if(u&&ct&&p)n:for(f=t.target,h=i.view;f!=r;f=f.parentNode)for(o=0;o<h.length;o++)if(h[o].node==f){n.display.currentWheelTarget=f;break n}if(e&&!yi&&!ht&&rt!=null){u&&bu(n,Math.max(0,Math.min(r.scrollTop+u*rt,r.scrollHeight-r.clientHeight)));pr(n,Math.max(0,Math.min(r.scrollLeft+e*rt,r.scrollWidth-r.clientWidth)));k(t);i.wheelStartX=null;return}if(u&&rt!=null){var c=u*rt,s=n.doc.scrollTop,l=s+i.wrapper.clientHeight;c<0?s=Math.max(0,s+c-50):l=Math.min(n.doc.height,l+c+50);ws(n,{top:s,bottom:l})}ku<20&&(i.wheelStartX==null?(i.wheelStartX=r.scrollLeft,i.wheelStartY=r.scrollTop,i.wheelDX=e,i.wheelDY=u,setTimeout(function(){if(i.wheelStartX!=null){var n=r.scrollLeft-i.wheelStartX,t=r.scrollTop-i.wheelStartY,u=t&&i.wheelDY&&t/i.wheelDY||n&&i.wheelDX&&n/i.wheelDX;(i.wheelStartX=i.wheelStartY=null,u)&&(rt=(rt*ku+u)/(ku+1),++ku)}},200)):(i.wheelDX+=e,i.wheelDY+=u))}}function io(n,t,i){if(typeof t=="string"&&(t=rf[t],!t))return!1;n.display.input.ensurePolled();var u=n.display.shift,r=!1;try{ce(n)&&(n.state.suppressEdits=!0);i&&(n.display.shift=!1);r=t(n)!=yp}finally{n.display.shift=u;n.state.suppressEdits=!1}return r}function hk(n,t,i){for(var u,r=0;r<n.state.keyMaps.length;r++)if(u=uf(t,n.state.keyMaps[r],i,n),u)return u;return n.options.extraKeys&&uf(t,n.options.extraKeys,i,n)||uf(t,n.options.keyMap,i,n)}function ro(n,t,i,r){var f=n.state.keySeq,u;if(f){if(gk(t))return"handled";ev.set(50,function(){n.state.keySeq==f&&(n.state.keySeq=null,n.display.input.reset())});t=f+" "+t}return(u=hk(n,t,r),u=="multi"&&(n.state.keySeq=t),u=="handled"&&tt(n,"keyHandled",n,t,i),(u=="handled"||u=="multi")&&(k(i),rh(n)),f&&!u&&/\'$/.test(t))?(k(i),!0):!!u}function ov(n,t){var i=nd(t,!0);return i?t.shiftKey&&!n.state.keySeq?ro(n,"Shift-"+i,t,function(t){return io(n,t,!0)})||ro(n,i,t,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return io(n,t)}):ro(n,i,t,function(t){return io(n,t)}):!1}function ck(n,t,i){return ro(n,"'"+i+"'",t,function(t){return io(n,t,!0)})}function sv(n){var t=this,i,r;(t.curOp.focus=gt(),kt(t,n))||(s&&a<11&&n.keyCode==27&&(n.returnValue=!1),i=n.keyCode,t.display.shift=i==16||n.shiftKey,r=ov(t,n),ht&&(uo=r?i:null,r||i!=88||iw||!(ct?n.metaKey:n.ctrlKey)||t.replaceSelection("",null,"cut")),i!=18||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||lk(t))}function lk(n){function t(n){n.keyCode!=18&&n.altKey||(uu(i,"CodeMirror-crosshair"),bt(document,"keyup",t),bt(document,"mouseover",t))}var i=n.display.lineDiv;fu(i,"CodeMirror-crosshair");u(document,"keyup",t);u(document,"mouseover",t)}function hv(n){n.keyCode==16&&(this.doc.sel.shift=!1);kt(this,n)}function cv(n){var t=this,i,r,u;if(!ui(t.display,n)&&!kt(t,n)&&(!n.ctrlKey||n.altKey)&&(!ct||!n.metaKey)){if(i=n.keyCode,r=n.charCode,ht&&i==uo){uo=null;k(n);return}if((!ht||!(!n.which||n.which<10)||!ov(t,n))&&(u=String.fromCharCode(r==null?i:r),!ck(t,n,u)))t.display.input.onKeyPress(n)}}function ak(n){n.state.delayingBlurEvent=!0;setTimeout(function(){n.state.delayingBlurEvent&&(n.state.delayingBlurEvent=!1,du(n))},100)}function vh(n){(n.state.delayingBlurEvent&&(n.state.delayingBlurEvent=!1),n.options.readOnly!="nocursor")&&(n.state.focused||(y(n,"focus",n),n.state.focused=!0,fu(n.display.wrapper,"CodeMirror-focused"),n.curOp||n.display.selForContextMenu==n.doc.sel||(n.display.input.reset(),p&&setTimeout(function(){n.display.input.reset(!0)},20)),n.display.input.receivedFocus()),rh(n))}function du(n){n.state.delayingBlurEvent||(n.state.focused&&(y(n,"blur",n),n.state.focused=!1,uu(n.display.wrapper,"CodeMirror-focused")),clearInterval(n.display.blinker),setTimeout(function(){n.state.focused||(n.display.shift=!1)},150))}function lv(n,t){if(!ui(n.display,t)&&!vk(n,t))n.display.input.onContextMenu(t)}function vk(n,t){return et(n,"gutterContextMenu")?rv(n,t,"gutterContextMenu",!1,y):!1}function av(t,i){if(f(t,i.from)<0)return t;if(f(t,i.to)<=0)return li(i);var u=t.line+i.text.length-(i.to.line-i.from.line)-1,r=t.ch;return t.line==i.to.line&&(r+=li(i).ch-i.to.ch),n(u,r)}function yh(n,t){for(var r,u=[],i=0;i<n.sel.ranges.length;i++)r=n.sel.ranges[i],u.push(new l(av(r.anchor,t),av(r.head,t)));return lt(u,n.sel.primIndex)}function vv(t,i,r){return t.line==i.line?n(r.line,t.ch-i.ch+r.ch):n(r.line+(t.line-i.line),t.ch)}function yk(t,i,r){for(var v,y,s=[],e=n(t.first,0),h=e,u=0;u<i.length;u++){var c=i[u],o=vv(c.from,e,h),a=vv(li(c),e,h);e=c.to;h=a;r=="around"?(v=t.sel.ranges[u],y=f(v.head,v.anchor)<0,s[u]=new l(y?a:o,y?o:a)):s[u]=new l(o,o)}return new ni(s,t.sel.primIndex)}function yv(n,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return(i&&(r.update=function(t,i,r,u){t&&(this.from=e(n,t));i&&(this.to=e(n,i));r&&(this.text=r);u!==undefined&&(this.origin=u)}),y(n,"beforeChange",n,r),n.cm&&y(n.cm,"beforeChange",n.cm,r),r.canceled)?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function wr(n,t,i){var u,r;if(n.cm){if(!n.cm.curOp)return v(n.cm,wr)(n,t,i);if(n.cm.state.suppressEdits)return}if(!et(n,"beforeChange")&&(!n.cm||!et(n.cm,"beforeChange"))||(t=yv(n,t,!0),t))if(u=tl&&!i&&sd(n,t.from,t.to),u)for(r=u.length-1;r>=0;--r)pv(n,{from:u[r].from,to:u[r].to,text:r?[""]:t.text});else pv(n,t)}function pv(n,t){var i,r;(t.text.length!=1||t.text[0]!=""||f(t.from,t.to)!=0)&&(i=yh(n,t),fp(n,t,i,n.cm?n.cm.curOp.id:NaN),gu(n,t,i,dh(n,t)),r=[],rr(n,function(n,i){i||g(r,n.history)!=-1||(hp(n.history,t),r.push(n.history));gu(n,t,null,dh(n,t))}))}function fo(n,t,i){var c,v,f,u,y,l;if(!n.cm||!n.cm.state.suppressEdits){var e=n.history,r,a=n.sel,o=t=="undo"?e.done:e.undone,s=t=="undo"?e.undone:e.done;for(f=0;f<o.length;f++)if(r=o[f],i?r.ranges&&!r.equals(n.sel):!r.ranges)break;if(f!=o.length){for(e.lastOrigin=e.lastSelOrigin=null;;)if(r=o.pop(),r.ranges){if(wo(r,s),i&&!r.equals(n.sel)){w(n,r,{clearRedo:!1});return}a=r}else break;for(c=[],wo(a,s),s.push({changes:c,generation:e.generation}),e.generation=r.generation||++e.maxGeneration,v=et(n,"beforeChange")||n.cm&&et(n.cm,"beforeChange"),f=r.changes.length-1;f>=0;--f){if(u=r.changes[f],u.origin=t,v&&!yv(n,u,!1)){o.length=0;return}c.push(fc(n,u));y=f?yh(n,u):h(o);gu(n,u,y,ty(n,u));!f&&n.cm&&n.cm.scrollIntoView({from:u.from,to:li(u)});l=[];rr(n,function(n,t){t||g(l,n.history)!=-1||(hp(n.history,u),l.push(n.history));gu(n,u,null,ty(n,u))})}}}}function wv(t,i){if(i!=0&&(t.first+=i,t.sel=new ni(df(t.sel.ranges,function(t){return new l(n(t.anchor.line+i,t.anchor.ch),n(t.head.line+i,t.head.ch))}),t.sel.primIndex),t.cm)){it(t.cm,t.first,t.first-i,i);for(var u=t.cm.display,r=u.viewFrom;r<u.viewTo;r++)ri(t.cm,r,"gutter")}}function gu(t,i,u,f){var o,e;if(t.cm&&!t.cm.curOp)return v(t.cm,gu)(t,i,u,f);if(i.to.line<t.first){wv(t,i.text.length-1-(i.to.line-i.from.line));return}i.from.line>t.lastLine()||(i.from.line<t.first&&(o=i.text.length-1-(t.first-i.from.line),wv(t,o),i={from:n(t.first,0),to:n(i.to.line+o,i.to.ch),text:[h(i.text)],origin:i.origin}),e=t.lastLine(),i.to.line>e&&(i={from:i.from,to:n(e,r(t,e).text.length),text:[i.text[0]],origin:i.origin}),i.removed=ur(t,i.from,i.to),u||(u=yh(t,i)),t.cm?pk(t.cm,i,f):rc(t,i,f),ye(t,u,dt))}function pk(n,t,i){var f=n.doc,e=n.display,u=t.from,o=t.to,s=!1,h=u.line,y,l,a,v;n.options.lineWrapping||(h=c(pt(r(f,u.line))),f.iter(h,o.line+1,function(n){if(n==e.maxLine)return s=!0,!0}));f.sel.contains(t.from,t.to)>-1&&ap(n);rc(f,t,i,il(n));n.options.lineWrapping||(f.iter(h,u.line+t.text.length,function(n){var t=ue(n);t>e.maxLineLength&&(e.maxLine=n,e.maxLineLength=t,e.maxLineChanged=!0,s=!1)}),s&&(n.curOp.updateMaxLine=!0));f.frontier=Math.min(f.frontier,u.line);vu(n,400);y=t.text.length-(o.line-u.line)-1;t.full?it(n):u.line!=o.line||t.text.length!=1||np(n.doc,t)?it(n,u.line,o.line+1,y):ri(n,u.line,"text");l=et(n,"changes");a=et(n,"change");(a||l)&&(v={from:u,to:o,text:t.text,removed:t.removed,origin:t.origin},a&&tt(n,"change",n,v),l&&(n.curOp.changeObjs||(n.curOp.changeObjs=[])).push(v));n.display.selForContextMenu=null}function nf(n,t,i,r,u){if(r||(r=i),f(r,i)<0){var e=r;r=i;i=e}typeof t=="string"&&(t=vi(t));wr(n,{from:i,to:r,text:t,origin:u})}function wk(n,t){var u;if(!kt(n,"scrollCursorIntoView")){var f=n.display,e=f.sizer.getBoundingClientRect(),r=null;t.top+e.top<0?r=!0:t.bottom+e.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1);r==null||cw||(u=i("div","​",null,"position: absolute; top: "+(t.top-f.viewOffset-we(n.display))+"px; height: "+(t.bottom-t.top+yt(n)+f.barHeight)+"px; left: "+t.left+"px; width: 2px;"),n.display.lineSpace.appendChild(u),u.scrollIntoView(r),n.display.lineSpace.removeChild(u))}}function bk(n,t,i,r){var o;for(r==null&&(r=0),o=0;o<5;o++){var s=!1,u=ii(n,t),f=!i||i==t?u:ii(n,i),e=eo(n,Math.min(u.left,f.left),Math.min(u.top,f.top)-r,Math.max(u.left,f.left),Math.max(u.bottom,f.bottom)+r),h=n.doc.scrollTop,c=n.doc.scrollLeft;if(e.scrollTop!=null&&(bu(n,e.scrollTop),Math.abs(n.doc.scrollTop-h)>1&&(s=!0)),e.scrollLeft!=null&&(pr(n,e.scrollLeft),Math.abs(n.doc.scrollLeft-c)>1&&(s=!0)),!s)break}return u}function kk(n,t,i,r,u){var f=eo(n,t,i,r,u);f.scrollTop!=null&&bu(n,f.scrollTop);f.scrollLeft!=null&&pr(n,f.scrollLeft)}function eo(n,t,i,r,u){var e=n.display,a=bi(n.display),c;i<0&&(i=0);var h=n.curOp&&n.curOp.scrollTop!=null?n.curOp.scrollTop:e.scroller.scrollTop,o=fh(n),f={};u-i>o&&(u=i+o);var v=n.doc.height+uh(e),p=i<a,w=u>v-a;i<h?f.scrollTop=p?0:i:u>h+o&&(c=Math.min(i,(w?v:u)-o),c!=h&&(f.scrollTop=c));var y=n.curOp&&n.curOp.scrollLeft!=null?n.curOp.scrollLeft:e.scroller.scrollLeft,s=hi(n)-(n.options.fixedGutter?e.gutters.offsetWidth:0),l=r-t>s;return l&&(r=t+s),t<10?f.scrollLeft=0:t<y?f.scrollLeft=Math.max(0,t-(l?0:10)):r>s+y-3&&(f.scrollLeft=r+(l?0:10)-s),f}function ph(n,t,i){(t!=null||i!=null)&&oo(n);t!=null&&(n.curOp.scrollLeft=(n.curOp.scrollLeft==null?n.doc.scrollLeft:n.curOp.scrollLeft)+t);i!=null&&(n.curOp.scrollTop=(n.curOp.scrollTop==null?n.doc.scrollTop:n.curOp.scrollTop)+i)}function br(t){oo(t);var i=t.getCursor(),r=i,u=i;t.options.lineWrapping||(r=i.ch?n(i.line,i.ch-1):i,u=n(i.line,i.ch+1));t.curOp.scrollToPos={from:r,to:u,margin:t.options.cursorScrollMargin,isCursor:!0}}function oo(n){var t=n.curOp.scrollToPos;if(t){n.curOp.scrollToPos=null;var i=da(n,t.from),r=da(n,t.to),u=eo(n,Math.min(i.left,r.left),Math.min(i.top,r.top)-t.margin,Math.max(i.right,r.right),Math.max(i.bottom,r.bottom)+t.margin);n.scrollTo(u.scrollLeft,u.scrollTop)}}function tf(t,i,u,f){var o=t.doc,b,a,e,v,h,w,c;u==null&&(u="add");u=="smart"&&(o.mode.indent?b=yu(t,i):u="prev");var y=t.options.tabSize,s=r(o,i),p=ot(s.text,null,y);if(s.stateAfter&&(s.stateAfter=null),a=s.text.match(/^\s*/)[0],f||/\S/.test(s.text)){if(u=="smart"&&(e=o.mode.indent(b,s.text.slice(a.length),s.text),e==yp||e>150)){if(!f)return;u="prev"}}else e=0,u="not";if(u=="prev"?e=i>o.first?ot(r(o,i-1).text,null,y):0:u=="add"?e=p+t.options.indentUnit:u=="subtract"?e=p-t.options.indentUnit:typeof u=="number"&&(e=p+u),e=Math.max(0,e),v="",c=0,t.options.indentWithTabs)for(h=Math.floor(e/y);h;--h)c+=y,v+="\t";if(c<e&&(v+=wp(e-c)),v!=a)return nf(o,v,n(i,0),n(i,a.length),"+input"),s.stateAfter=null,!0;for(h=0;h<o.sel.ranges.length;h++)if(w=o.sel.ranges[h],w.head.line==i&&w.head.ch<a.length){c=n(i,a.length);ih(o,h,new l(c,c));break}}function so(n,t,i,u){var f=t,e=t;return(typeof t=="number"?e=r(n,ta(n,t)):f=c(t),f==null)?null:(u(e,f)&&n.cm&&ri(n.cm,f,i),e)}function kr(n,t){for(var r,e,o=n.doc.sel.ranges,i=[],u=0;u<o.length;u++){for(r=t(o[u]);i.length&&f(r.from,h(i).to)<=0;)if(e=i.pop(),f(e.from,r.from)<0){r.from=e.from;break}i.push(r)}ut(n,function(){for(var t=i.length-1;t>=0;t--)nf(n.doc,"",i[t].from,i[t].to,"+delete");br(n)})}function wh(t,i,u,f,e){function d(){var n=a+u;return n<t.first||n>=t.first+t.size?y=!1:(a=n,h=r(t,n))}function c(n){var t=(e?bc:fw)(h,o,u,!0);if(t==null)if(!n&&d())o=e?(u<0?ts:ns)(h):u<0?h.text.length:0;else return y=!1;else o=t;return!0}var a=i.line,o=i.ch,k=u,h=r(t,a),y=!0,l,v,s,b;if(f=="char")c();else if(f=="column")c(!0);else if(f=="word"||f=="group"){var p=null,w=f=="group",g=t.cm&&t.cm.getHelper(i,"wordChars");for(l=!0;;l=!1){if(u<0&&!c(!l))break;if(v=h.text.charAt(o)||"\n",s=ko(v,g)?"w":w&&v=="\n"?"n":!w||/\s/.test(v)?null:"p",!w||l||s||(s="s"),p&&p!=s){u<0&&(u=1,c());break}if(s&&(p=s),u>0&&!c(!l))break}}return b=pe(t,n(a,o),k,!0),y||(b.hitSide=!0),b}function bv(n,t,i,r){var o=n.doc,s=t.left,u,e,f;for(r=="page"?(e=Math.min(n.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=t.top+i*(e-(i<0?1.5:.5)*bi(n.display))):r=="line"&&(u=i>0?t.bottom+3:t.top-3);;){if(f=ch(n,s,u),!f.outside)break;if(i<0?u<=0:u>=o.height){f.hitSide=!0;break}u+=i*5}return f}function o(n,i,r,u){t.defaults[n]=i;r&&(gi[n]=u?function(n,t,i){i!=bh&&r(n,t,i)}:r)}function dk(n){for(var t,i=n.split(/-(?!$)/),n=i[i.length-1],u,f,e,o,r=0;r<i.length-1;r++)if(t=i[r],/^(cmd|meta|m)$/i.test(t))o=!0;else if(/^a(lt)?$/i.test(t))u=!0;else if(/^(c|ctrl|control)$/i.test(t))f=!0;else if(/^s(hift)$/i.test(t))e=!0;else throw new Error("Unrecognized modifier name: "+t);return u&&(n="Alt-"+n),f&&(n="Ctrl-"+n),o&&(n="Cmd-"+n),e&&(n="Shift-"+n),n}function co(n){return typeof n=="string"?fi[n]:n}function nu(n,t,r,e,o){var s,a,c,h,y,l;if(e&&e.shared)return td(n,t,r,e,o);if(n.cm&&!n.cm.curOp)return v(n.cm,nu)(n,t,r,e,o);if(s=new ai(n,o),a=f(t,r),e&&vt(e,s,!1),a>0||a==0&&s.clearWhenEmpty!==!1)return s;if(s.replacedWith&&(s.collapsed=!0,s.widgetNode=i("span",[s.replacedWith],"CodeMirror-widget"),e.handleMouseEvents||s.widgetNode.setAttribute("cm-ignore-events","true"),e.insertLeft&&(s.widgetNode.insertLeft=!0)),s.collapsed){if(oy(n,t.line,t,r,s)||t.line!=r.line&&oy(n,r.line,t,r,s))throw new Error("Inserting collapsed marker partially overlapping an existing one");si=!0}if(s.addToHistory&&fp(n,{from:t,to:r,origin:"markText"},n.sel,NaN),c=t.line,h=n.cm,n.iter(c,r.line+1,function(n){h&&s.collapsed&&!h.options.lineWrapping&&pt(n)==h.display.maxLine&&(y=!0);s.collapsed&&c!=t.line&&wt(n,0);fd(n,new ao(s,c==t.line?t.ch:null,c==r.line?r.ch:null));++c}),s.collapsed&&n.iter(t.line,r.line+1,function(t){ir(n,t)&&wt(t,0)}),s.clearOnEnter&&u(s,"beforeCursorEnter",function(){s.clear()}),s.readOnly&&(tl=!0,(n.history.done.length||n.history.undone.length)&&n.clearHistory()),s.collapsed&&(s.id=++lo,s.atomic=!0),h){if(y&&(h.curOp.updateMaxLine=!0),s.collapsed)it(h,t.line,r.line+1);else if(s.className||s.title||s.startStyle||s.endStyle||s.css)for(l=t.line;l<=r.line;l++)ri(h,l,"text");s.atomic&&ea(h.doc);tt(h,"markerAdded",h,s)}return s}function td(n,t,i,r,u){r=vt(r);r.shared=!1;var f=[nu(n,t,i,r,u)],o=f[0],s=r.widgetNode;return rr(n,function(n){s&&(r.widgetNode=s.cloneNode(!0));f.push(nu(n,e(n,t),e(n,i),r,u));for(var c=0;c<n.linked.length;++c)if(n.linked[c].isParent)return;o=h(f)}),new ef(f,o)}function gv(t){return t.findMarks(n(t.first,0),t.clipPos(n(t.lastLine())),function(n){return n.parent})}function id(n,t){for(var u,r=0;r<t.length;r++){var i=t[r],e=i.find(),o=n.clipPos(e.from),s=n.clipPos(e.to);f(o,s)&&(u=nu(n,o,s,i.primary,i.primary.type),i.markers.push(u),u.parent=i)}}function rd(n){for(var t,u,i,f,r=0;r<n.length;r++)for(t=n[r],u=[t.primary.doc],rr(t.primary.doc,function(n){u.push(n)}),i=0;i<t.markers.length;i++)f=t.markers[i],g(u,f.doc)==-1&&(f.parent=null,t.markers.splice(i--,1))}function ao(n,t,i){this.marker=n;this.from=t;this.to=i}function of(n,t){var i,r;if(n)for(i=0;i<n.length;++i)if(r=n[i],r.marker==t)return r}function ud(n,t){for(var r,i=0;i<n.length;++i)n[i]!=t&&(r||(r=[])).push(n[i]);return r}function fd(n,t){n.markedSpans=n.markedSpans?n.markedSpans.concat([t]):[t];t.marker.attachLine(n)}function ed(n,t,i){var u,e,o;if(n)for(u=0;u<n.length;++u){var r=n[u],f=r.marker,s=r.from==null||(f.inclusiveLeft?r.from<=t:r.from<t);!s&&(r.from!=t||f.type!="bookmark"||i&&r.marker.insertLeft)||(o=r.to==null||(f.inclusiveRight?r.to>=t:r.to>t),(e||(e=[])).push(new ao(f,r.from,o?null:r.to)))}return e}function od(n,t,i){var u,e,o;if(n)for(u=0;u<n.length;++u){var r=n[u],f=r.marker,s=r.to==null||(f.inclusiveRight?r.to>=t:r.to>t);(s||r.from==t&&f.type=="bookmark"&&(!i||r.marker.insertLeft))&&(o=r.from==null||(f.inclusiveLeft?r.from<=t:r.from<t),(e||(e=[])).push(new ao(f,o?null:r.from-t,r.to==null?null:r.to-t)))}return e}function dh(n,t){var v,y,e,s,a,w,b,u;if(t.full||(v=cu(n,t.from.line)&&r(n,t.from.line).markedSpans,y=cu(n,t.to.line)&&r(n,t.to.line).markedSpans,!v&&!y))return null;var p=t.from.ch,d=t.to.ch,k=f(t.from,t.to)==0,i=ed(v,p,k),o=od(y,d,k),c=t.text.length==1,l=h(t.text).length+(c?p:0);if(i)for(u=0;u<i.length;++u)e=i[u],e.to==null&&(s=of(o,e.marker),s?c&&(e.to=s.to==null?null:s.to+l):e.to=p);if(o)for(u=0;u<o.length;++u)e=o[u],e.to!=null&&(e.to+=l),e.from==null?(s=of(i,e.marker),s||(e.from=l,c&&(i||(i=[])).push(e))):(e.from+=l,c&&(i||(i=[])).push(e));if(i&&(i=ny(i)),o&&o!=i&&(o=ny(o)),a=[i],!c){if(w=t.text.length-2,w>0&&i)for(u=0;u<i.length;++u)i[u].to==null&&(b||(b=[])).push(new ao(i[u].marker,null,null));for(u=0;u<w;++u)a.push(b);a.push(o)}return a}function ny(n){for(var i,t=0;t<n.length;++t)i=n[t],i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&n.splice(t--,1);return n.length?n:null}function ty(n,t){var i=tg(n,t),s=dh(n,t),r,f,u,e,h,o;if(!i)return s;if(!s)return i;for(r=0;r<i.length;++r)if(f=i[r],u=s[r],f&&u)n:for(e=0;e<u.length;++e){for(h=u[e],o=0;o<f.length;++o)if(f[o].marker==h.marker)continue n;f.push(h)}else u&&(i[r]=u);return i}function sd(n,t,i){var r=null,o,h,c,u,s,e;if(n.iter(t.line,i.line+1,function(n){var t,i;if(n.markedSpans)for(t=0;t<n.markedSpans.length;++t)i=n.markedSpans[t].marker,i.readOnly&&(!r||g(r,i)==-1)&&(r||(r=[])).push(i)}),!r)return null;for(o=[{from:t,to:i}],h=0;h<r.length;++h)for(c=r[h],u=c.find(0),s=0;s<o.length;++s)if(e=o[s],!(f(e.to,u.from)<0)&&!(f(e.from,u.to)>0)){var l=[s,1],a=f(e.from,u.from),v=f(e.to,u.to);(a<0||!c.inclusiveLeft&&!a)&&l.push({from:e.from,to:u.from});(v>0||!c.inclusiveRight&&!v)&&l.push({from:u.to,to:e.to});o.splice.apply(o,l);s+=l.length-1}return o}function iy(n){var i=n.markedSpans,t;if(i){for(t=0;t<i.length;++t)i[t].marker.detachLine(n);n.markedSpans=null}}function ry(n,t){if(t){for(var i=0;i<t.length;++i)t[i].marker.attachLine(n);n.markedSpans=t}}function vo(n){return n.inclusiveLeft?-1:0}function yo(n){return n.inclusiveRight?1:0}function uy(n,t){var r=n.lines.length-t.lines.length,i;if(r!=0)return r;var u=n.find(),e=t.find(),o=f(u.from,e.from)||vo(n)-vo(t);return o?-o:(i=f(u.to,e.to)||yo(n)-yo(t),i)?i:t.id-n.id}function fy(n,t){var f=si&&n.markedSpans,r,i,u;if(f)for(u=0;u<f.length;++u)i=f[u],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||uy(r,i.marker)<0)&&(r=i.marker);return r}function ey(n){return fy(n,!0)}function sf(n){return fy(n,!1)}function oy(n,t,i,u,e){var v=r(n,t),l=si&&v.markedSpans,s,o;if(l)for(s=0;s<l.length;++s)if(o=l[s],o.marker.collapsed){var h=o.marker.find(0),c=f(h.from,i)||vo(o.marker)-vo(e),a=f(h.to,u)||yo(o.marker)-yo(e);if((!(c>=0)||!(a<=0))&&(!(c<=0)||!(a>=0))&&(c<=0&&(f(h.to,i)>0||o.marker.inclusiveRight&&e.inclusiveLeft)||c>=0&&(f(h.from,u)<0||o.marker.inclusiveLeft&&e.inclusiveRight)))return!0}}function pt(n){for(var t;t=ey(n);)n=t.find(-1,!0).line;return n}function hd(n){for(var i,t;i=sf(n);)n=i.find(1,!0).line,(t||(t=[])).push(n);return t}function gh(n,t){var i=r(n,t),u=pt(i);return i==u?t:c(u)}function sy(n,t){if(t>n.lastLine())return t;var i=r(n,t),u;if(!ir(n,i))return t;while(u=sf(i))i=u.find(1,!0).line;return c(i)+1}function ir(n,t){var u=si&&t.markedSpans,i,r;if(u)for(r=0;r<u.length;++r)if(i=u[r],i.marker.collapsed){if(i.from==null)return!0;if(!i.marker.widgetNode&&i.from==0&&i.marker.inclusiveLeft&&nc(n,t,i))return!0}}function nc(n,t,i){var f,r,u;if(i.to==null)return f=i.marker.find(1,!0),nc(n,f.line,of(f.line.markedSpans,i.marker));if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(u=0;u<t.markedSpans.length;++u)if(r=t.markedSpans[u],r.marker.collapsed&&!r.marker.widgetNode&&r.from==i.to&&(r.to==null||r.to!=i.from)&&(r.marker.inclusiveLeft||i.marker.inclusiveRight)&&nc(n,t,r))return!0}function hy(n,t,i){ei(t)<(n.curOp&&n.curOp.scrollTop||n.doc.scrollTop)&&ph(n,null,i)}function cf(n){var t,r;return n.height!=null?n.height:(t=n.doc.cm,!t)?0:(go(document.body,n.node)||(r="position: relative;",n.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),n.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),st(t.display.measure,i("div",[n.node],null,r))),n.height=n.node.offsetHeight)}function cd(n,t,i,r){var u=new hf(n,i,r),f=n.cm;return f&&u.noHScroll&&(f.display.alignWidgets=!0),so(n,t,"widget",function(t){var i=t.widgets||(t.widgets=[]),r;return u.insertAt==null?i.push(u):i.splice(Math.min(i.length-1,Math.max(0,u.insertAt)),0,u),u.line=t,f&&!ir(n,t)&&(r=ei(t)<n.scrollTop,wt(t,t.height+cf(u)),r&&ph(f,null,u.height),f.curOp.forceUpdate=!0),!0}),u}function ld(n,t,i,r){n.text=t;n.stateAfter&&(n.stateAfter=null);n.styles&&(n.styles=null);n.order!=null&&(n.order=null);iy(n);ry(n,i);var u=r?r(n):1;u!=n.height&&wt(n,u)}function ad(n){n.parent=null;iy(n)}function cy(n,t){var i,r;if(n)for(;;){if(i=n.match(/(?:^|\s+)line-(background-)?(\S+)/),!i)break;n=n.slice(0,i.index)+n.slice(i.index+i[0].length);r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|s)"+i[2]+"(?:$|s)").test(t[r])||(t[r]+=" "+i[2])}return n}function ly(n,i){if(n.blankLine)return n.blankLine(i);if(n.innerMode){var r=t.innerMode(n,i);if(r.mode.blankLine)return r.mode.blankLine(r.state)}}function tc(n,i,r,u){for(var e,f=0;f<10;f++)if(u&&(u[0]=t.innerMode(n,r).mode),e=n.token(i,r),i.pos>i.start)return e;throw new Error("Mode "+n.name+" failed to advance stream.");}function ay(n,t,i,u){function c(n){return{start:f.start,end:f.pos,string:f.current(),type:l||null,state:n?tr(o.mode,s):s}}var o=n.doc,a=o.mode,l;t=e(o,t);var v=r(o,t.line),s=yu(n,t.line,i),f=new ff(v.text,n.options.tabSize),h;for(u&&(h=[]);(u||f.pos<t.ch)&&!f.eol();)f.start=f.pos,l=tc(a,f,s),u&&h.push(c(!0));return u?h:c()}function vy(n,t,i,r,u,f,e){var c=i.flattenSpans,a,y;c==null&&(c=n.options.flattenSpans);var s=0,l=null,o=new ff(t,n.options.tabSize),h,v=n.options.addModeClass&&[null];for(t==""&&cy(ly(i,r),f);!o.eol();){if(o.pos>n.options.maxHighlightLength?(c=!1,e&&ic(n,t,r,o.pos),o.pos=t.length,h=null):h=cy(tc(i,o,r,v),f),v&&(a=v[0].name,a&&(h="m-"+(h?a+" "+h:a))),!c||l!=h){while(s<o.start)s=Math.min(o.start,s+5e4),u(s,l);l=h}o.start=o.pos}while(s<o.pos)y=Math.min(o.pos,s+5e4),u(y,l),s=y}function yy(n,t,i,r){var u=[n.state.modeGen],e={},o;for(vy(n,t.text,n.doc.mode,i,function(n,t){u.push(n,t)},e,r),o=0;o<n.state.overlays.length;++o){var s=n.state.overlays[o],f=1,h=0;vy(n,t.text,s.mode,!0,function(n,t){for(var i=f,r,e;h<n;)r=u[f],r>n&&u.splice(f,1,n,u[f+1],r),f+=2,h=Math.min(n,r);if(t)if(s.opaque)u.splice(i,f-i,n,"cm-overlay "+t),f=i+2;else for(;i<f;i+=2)e=u[i+1],u[i+1]=(e?e+" ":"")+"cm-overlay "+t},e)}return{styles:u,classes:e.bgClass||e.textClass?e:null}}function py(n,t,i){if(!t.styles||t.styles[0]!=n.state.modeGen){var r=yy(n,t,t.stateAfter=yu(n,c(t)));t.styles=r.styles;r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null);i===n.doc.frontier&&n.doc.frontier++}return t.styles}function ic(n,t,i,r){var f=n.doc.mode,u=new ff(t,n.options.tabSize);for(u.start=u.pos=r||0,t==""&&ly(f,i);!u.eol()&&u.pos<=n.options.maxHighlightLength;)tc(f,u,i),u.start=u.pos}function ky(n,t){if(!n||/^\s*$/.test(n))return null;var i=t.addModeClass?by:wy;return i[n]||(i[n]=n.replace(/\S+/g,"cm-$&"))}function dy(n,t){var e=i("span",null,null,p?"padding-right: .1px":null),r={pre:i("pre",[e]),content:e,col:0,pos:0,cm:n,splitSpaces:(s||p)&&n.getOption("lineWrapping")},f,u,o,h;for(t.measure={},f=0;f<=(t.rest?t.rest.length:0);f++)u=f?t.rest[f-1]:t.line,r.pos=0,r.addToken=yd,eg(n.display.measure)&&(o=at(u))&&(r.addToken=wd(r.addToken,o)),r.map=[],h=t!=n.display.externalMeasured&&c(u),bd(u,r,py(n,u,h)),u.styleClasses&&(u.styleClasses.bgClass&&(r.bgClass=hc(u.styleClasses.bgClass,r.bgClass||"")),u.styleClasses.textClass&&(r.textClass=hc(u.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(fg(n.display.measure))),f==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}));return p&&/\bcm-tab\b/.test(r.content.lastChild.className)&&(r.content.className="cm-tab-wrap-hack"),y(n,"renderLine",n,t.line,r.pre),r.pre.className&&(r.textClass=hc(r.pre.className,r.textClass||"")),r}function vd(n){var t=i("span","•","cm-invalidchar");return t.title="\\u"+n.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function yd(n,t,r,u,f,e,o){var c,l,v,y,h,p,b;if(t){var k=n.splitSpaces?t.replace(/ {3,}/g,pd):t,w=n.cm.state.specialChars,d=!1;if(w.test(t))for(c=document.createDocumentFragment(),l=0;;){if(w.lastIndex=l,v=w.exec(t),y=v?v.index-l:t.length-l,y&&(h=document.createTextNode(k.slice(l,l+y)),s&&a<9?c.appendChild(i("span",[h])):c.appendChild(h),n.map.push(n.pos,n.pos+y,h),n.col+=y,n.pos+=y),!v)break;if(l+=y+1,v[0]=="\t"){var g=n.cm.options.tabSize,nt=g-n.col%g,h=c.appendChild(i("span",wp(nt),"cm-tab"));h.setAttribute("role","presentation");h.setAttribute("cm-text","\t");n.col+=nt}else h=n.cm.options.specialCharPlaceholder(v[0]),h.setAttribute("cm-text",v[0]),s&&a<9?c.appendChild(i("span",[h])):c.appendChild(h),n.col+=1;n.map.push(n.pos,n.pos+1,h);n.pos++}else n.col+=t.length,c=document.createTextNode(k),n.map.push(n.pos,n.pos+t.length,c),s&&a<9&&(d=!0),n.pos+=t.length;if(r||u||f||d||o)return p=r||"",u&&(p+=u),f&&(p+=f),b=i("span",[c],p,o),e&&(b.title=e),n.content.appendChild(b);n.content.appendChild(c)}}function pd(n){for(var i=" ",t=0;t<n.length-2;++t)i+=t%2?" ":" ";return i+" "}function wd(n,t){return function(i,r,u,f,e,o,s){var h,a,l,c;for(u=u?u+" cm-force-border":"cm-force-border",h=i.pos,a=h+r.length;;){for(l=0;l<t.length;l++)if(c=t[l],c.to>h&&c.from<=h)break;if(c.to>=a)return n(i,r,u,f,e,o,s);n(i,r.slice(0,c.to-h),u,f,null,o,s);f=null;r=r.slice(c.to-h);h=c.to}}}function gy(n,t,i,r){var u=!r&&i.widgetNode;u&&n.map.push(n.pos,n.pos+t,u);!r&&n.cm.display.input.needsContentAttribute&&(u||(u=n.content.appendChild(document.createElement("span"))),u.setAttribute("cm-marker",i.id));u&&(n.cm.display.input.setUneditable(u),n.content.appendChild(u));n.pos+=t}function bd(n,t,i){var d=n.markedSpans,g=n.text,v=0,h,a,u,f,s,l,k,rt;if(!d){for(h=1;h<i.length;h+=2)t.addToken(t,g.slice(v,v=i[h]),ky(i[h+1],t.cm.options));return}for(var nt=g.length,r=0,h=1,c="",tt,it,o=0,y,p,w,b,e;;){if(o==r){for(y=p=w=b=it="",e=null,o=Infinity,a=[],s=0;s<d.length;++s)u=d[s],f=u.marker,f.type=="bookmark"&&u.from==r&&f.widgetNode?a.push(f):u.from<=r&&(u.to==null||u.to>r||f.collapsed&&u.to==r&&u.from==r)?(u.to!=null&&u.to!=r&&o>u.to&&(o=u.to,p=""),f.className&&(y+=" "+f.className),f.css&&(it=f.css),f.startStyle&&u.from==r&&(w+=" "+f.startStyle),f.endStyle&&u.to==o&&(p+=" "+f.endStyle),f.title&&!b&&(b=f.title),f.collapsed&&(!e||uy(e.marker,f)<0)&&(e=u)):u.from>r&&o>u.from&&(o=u.from);if(e&&(e.from||0)==r){if(gy(t,(e.to==null?nt+1:e.to)-r,e.marker,e.from==null),e.to==null)return;e.to==r&&(e=!1)}if(!e&&a.length)for(s=0;s<a.length;++s)gy(t,0,a[s])}if(r>=nt)break;for(l=Math.min(nt,o);;){if(c){if(k=r+c.length,e||(rt=k>l?c.slice(0,l-r):c,t.addToken(t,rt,tt?tt+y:y,w,r+rt.length==o?p:"",b,it)),k>=l){c=c.slice(l-r);r=l;break}r=k;w=""}c=g.slice(v,v=i[h++]);tt=ky(i[h++],t.cm.options)}}}function np(n,t){return t.from.ch==0&&t.to.ch==0&&h(t.text)==""&&(!n.cm||n.cm.options.wholeLineUpdateBefore)}function rc(n,t,i,u){function v(n){return i?i[n]:null}function c(n,i,r){ld(n,i,r,u);tt(n,"change",n,t)}function p(n,t){for(var i=n,r=[];i<t;++i)r.push(new tu(f[i],v(i),u));return r}var e=t.from,l=t.to,f=t.text,o=r(n,e.line),a=r(n,l.line),b=h(f),w=v(f.length-1),y=l.line-e.line,s;t.full?(n.insert(0,p(0,f.length)),n.remove(f.length,n.size-f.length)):np(n,t)?(s=p(0,f.length-1),c(a,a.text,w),y&&n.remove(e.line,y),s.length&&n.insert(e.line,s)):o==a?f.length==1?c(o,o.text.slice(0,e.ch)+b+o.text.slice(l.ch),w):(s=p(1,f.length-1),s.push(new tu(b+o.text.slice(l.ch),w,u)),c(o,o.text.slice(0,e.ch)+f[0],v(0)),n.insert(e.line+1,s)):f.length==1?(c(o,o.text.slice(0,e.ch)+f[0]+a.text.slice(l.ch),v(0)),n.remove(e.line+1,y)):(c(o,o.text.slice(0,e.ch)+f[0],v(0)),c(a,b+a.text.slice(l.ch),w),s=p(1,f.length-1),y>1&&n.remove(e.line+1,y-1),n.insert(e.line+1,s));tt(n,"change",n,t)}function lf(n){this.lines=n;this.parent=null;for(var t=0,i=0;t<n.length;++t)n[t].parent=this,i+=n[t].height;this.height=i}function af(n){var r,u,t,i;for(this.children=n,r=0,u=0,t=0;t<n.length;++t)i=n[t],r+=i.chunkSize(),u+=i.height,i.parent=this;this.size=r;this.height=u;this.parent=null}function rr(n,t,i){function r(n,u,f){var o,e,s;if(n.linked)for(o=0;o<n.linked.length;++o)(e=n.linked[o],e.doc!=u)&&(s=f&&e.sharedHist,!i||s)&&(t(e.doc,s),r(e.doc,n,s))}r(n,null,!0)}function rp(n,t){if(t.cm)throw new Error("This document is already in use.");n.doc=t;t.cm=n;fs(n);us(n);n.options.lineWrapping||os(n);n.options.mode=t.modeOption;it(n)}function r(n,t){var i,r,u,f;if(t-=n.first,t<0||t>=n.size)throw new Error("There is no line "+(t+n.first)+" in the document.");for(i=n;!i.lines;)for(r=0;;++r){if(u=i.children[r],f=u.chunkSize(),t<f){i=u;break}t-=f}return i.lines[t]}function ur(n,t,i){var u=[],r=t.line;return n.iter(t.line,i.line+1,function(n){var f=n.text;r==i.line&&(f=f.slice(0,i.ch));r==t.line&&(f=f.slice(t.ch));u.push(f);++r}),u}function uc(n,t,i){var r=[];return n.iter(t,i,function(n){r.push(n.text)}),r}function wt(n,t){var r=t-n.height,i;if(r)for(i=n;i;i=i.parent)i.height+=r}function c(n){var i,u,t,r;if(n.parent==null)return null;for(i=n.parent,u=g(i.lines,n),t=i.parent;t;i=t,t=t.parent)for(r=0;;++r){if(t.children[r]==i)break;u+=t.children[r].chunkSize()}return u+i.first}function fr(n,t){var u=n.first,r,f,i,o,e;n:do{for(i=0;i<n.children.length;++i){if(r=n.children[i],f=r.height,t<f){n=r;continue n}t-=f;u+=r.chunkSize()}return u}while(!n.lines);for(i=0;i<n.lines.length;++i){if(o=n.lines[i],e=o.height,t<e)break;t-=e}return u+i}function ei(n){var u,i,f,r,t,e;for(n=pt(n),u=0,i=n.parent,t=0;t<i.lines.length;++t)if(f=i.lines[t],f==n)break;else u+=f.height;for(r=i.parent;r;i=r,r=i.parent)for(t=0;t<r.children.length;++t)if(e=r.children[t],e==i)break;else u+=e.height;return u}function at(n){var t=n.order;return t==null&&(t=n.order=ew(n.text)),t}function po(n){this.done=[];this.undone=[];this.undoDepth=Infinity;this.lastModTime=this.lastSelTime=0;this.lastOp=this.lastSelOp=null;this.lastOrigin=this.lastSelOrigin=null;this.generation=this.maxGeneration=n||1}function fc(n,t){var i={from:gs(t.from),to:li(t),text:ur(n,t.from,t.to)};return ep(n,i,t.from.line,t.to.line+1),rr(n,function(n){ep(n,i,t.from.line,t.to.line+1)},!0),i}function up(n){while(n.length){var t=h(n);if(t.ranges)n.pop();else break}}function kd(n,t){return t?(up(n.done),h(n.done)):n.done.length&&!h(n.done).ranges?h(n.done):n.done.length>1&&!n.done[n.done.length-2].ranges?(n.done.pop(),h(n.done)):void 0}function fp(n,t,i,r){var u=n.history,s,e,o,c;if(u.undone.length=0,s=+new Date,(u.lastOp==r||u.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.cm&&u.lastModTime>s-n.cm.options.historyEventDelay||t.origin.charAt(0)=="*"))&&(e=kd(u,u.lastOp==r)))o=h(e.changes),f(t.from,t.to)==0&&f(t.from,o.to)==0?o.to=li(t):e.changes.push(fc(n,t));else for(c=h(u.done),c&&c.ranges||wo(n.sel,u.done),e={changes:[fc(n,t)],generation:u.generation},u.done.push(e);u.done.length>u.undoDepth;)u.done.shift(),u.done[0].ranges||u.done.shift();u.done.push(i);u.generation=++u.maxGeneration;u.lastModTime=u.lastSelTime=s;u.lastOp=u.lastSelOp=r;u.lastOrigin=u.lastSelOrigin=t.origin;o||y(n,"historyAdded")}function dd(n,t,i,r){var u=t.charAt(0);return u=="*"||u=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-n.history.lastSelTime<=(n.cm?n.cm.options.historyEventDelay:500)}function gd(n,t,i,r){var u=n.history,f=r&&r.origin;i==u.lastSelOp||f&&u.lastSelOrigin==f&&(u.lastModTime==u.lastSelTime&&u.lastOrigin==f||dd(n,f,h(u.done),t))?u.done[u.done.length-1]=t:wo(t,u.done);u.lastSelTime=+new Date;u.lastSelOrigin=f;u.lastSelOp=i;r&&r.clearRedo!==!1&&up(u.undone)}function wo(n,t){var i=h(t);i&&i.ranges&&i.equals(n)||t.push(n)}function ep(n,t,i,r){var u=t["spans_"+n.id],f=0;n.iter(Math.max(n.first,i),Math.min(n.first+n.size,r),function(i){i.markedSpans&&((u||(u=t["spans_"+n.id]={}))[f]=i.markedSpans);++f})}function ng(n){if(!n)return null;for(var i=0,t;i<n.length;++i)n[i].marker.explicitlyCleared?t||(t=n.slice(0,i)):t&&t.push(n[i]);return t?t.length?t:null:n}function tg(n,t){var u=t["spans_"+n.id],i,r;if(!u)return null;for(i=0,r=[];i<t.text.length;++i)r.push(ng(u[i]));return r}function iu(n,t,i){for(var u,l,s,c,r,a,f,e=0,o=[];e<n.length;++e){if(u=n[e],u.ranges){o.push(i?ni.prototype.deepCopy.call(u):u);continue}for(l=u.changes,s=[],o.push({changes:s}),c=0;c<l.length;++c)if(r=l[c],s.push({from:r.from,to:r.to,text:r.text}),t)for(f in r)(a=f.match(/^spans_(\d+)$/))&&g(t,Number(a[1]))>-1&&(h(s)[f]=r[f],delete r[f])}return o}function op(n,t,i,r){i<n.line?n.line+=r:t<n.line&&(n.line=t,n.ch=0)}function sp(t,i,r,u){for(var f,h,e,o,s=0;s<t.length;++s){if(f=t[s],h=!0,f.ranges){for(f.copied||(f=t[s]=f.deepCopy(),f.copied=!0),e=0;e<f.ranges.length;e++)op(f.ranges[e].anchor,i,r,u),op(f.ranges[e].head,i,r,u);continue}for(e=0;e<f.changes.length;++e)if(o=f.changes[e],r<o.from.line)o.from=n(o.from.line+u,o.from.ch),o.to=n(o.to.line+u,o.to.ch);else if(i<=o.to.line){h=!1;break}h||(t.splice(0,s+1),s=0)}}function hp(n,t){var i=t.from.line,r=t.to.line,u=t.text.length-(r-i)-1;sp(n.done,i,r,u);sp(n.undone,i,r,u)}function ec(n){return n.defaultPrevented!=null?n.defaultPrevented:n.returnValue==!1}function yf(n){return n.target||n.srcElement}function lp(n){var t=n.which;return t==null&&(n.button&1?t=1:n.button&2?t=3:n.button&4&&(t=2)),ct&&n.ctrlKey&&t==1&&(t=3),t}function tt(n,t){function e(n){return function(){n.apply(null,f)}}var u=n._handlers&&n._handlers[t],f,i,r;if(u)for(f=Array.prototype.slice.call(arguments,2),ki?i=ki.delayedCallbacks:pf?i=pf:(i=pf=[],setTimeout(ig,0)),r=0;r<u.length;++r)i.push(e(u[r]))}function ig(){var t=pf,n;for(pf=null,n=0;n<t.length;++n)t[n]()}function kt(n,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),y(n,i||t.type,n,t),ec(t)||t.codemirrorIgnore}function ap(n){var i=n._handlers&&n._handlers.cursorActivity,r,t;if(i)for(r=n.curOp.cursorActivityHandlers||(n.curOp.cursorActivityHandlers=[]),t=0;t<i.length;++t)g(r,i[t])==-1&&r.push(i[t])}function et(n,t){var i=n._handlers&&n._handlers[t];return i&&i.length>0}function ru(n){n.prototype.on=function(n,t){u(this,n,t)};n.prototype.off=function(n,t){bt(this,n,t)}}function bf(){this.id=null}function pp(n,t,i){for(var f,e,r=0,u=0;;){if(f=n.indexOf("\t",r),f==-1&&(f=n.length),e=f-r,f==n.length||u+e>=t)return r+Math.min(e,t-u);if(u+=f-r,u+=i-u%i,r=f+1,u>=t)return r}}function wp(n){while(kf.length<=n)kf.push(h(kf)+" ");return kf[n]}function h(n){return n[n.length-1]}function g(n,t){for(var i=0;i<n.length;++i)if(n[i]==t)return i;return-1}function df(n,t){for(var r=[],i=0;i<n.length;i++)r[i]=t(n[i],i);return r}function gf(){}function bp(n,t){var i;return Object.create?i=Object.create(n):(gf.prototype=n,i=new gf),t&&vt(t,i),i}function vt(n,t,i){t||(t={});for(var r in n)n.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=n[r]);return t}function ne(n){var t=Array.prototype.slice.call(arguments,1);return function(){return n.apply(null,t)}}function ko(n,t){return t?t.source.indexOf("\\w")>-1&&sc(n)?!0:t.test(n):sc(n)}function dp(n){for(var t in n)if(n.hasOwnProperty(t)&&n[t])return!1;return!0}function te(n){return n.charCodeAt(0)>=768&&gp.test(n)}function i(n,t,i,r){var u=document.createElement(n),f;if(i&&(u.className=i),r&&(u.style.cssText=r),typeof t=="string")u.appendChild(document.createTextNode(t));else if(t)for(f=0;f<t.length;++f)u.appendChild(t[f]);return u}function sr(n){for(var t=n.childNodes.length;t>0;--t)n.removeChild(n.firstChild);return n}function st(n,t){return sr(n).appendChild(t)}function gt(){return document.activeElement}function ie(n){return new RegExp("(^|\\s)"+n+"(?:$|\\s)\\s*")}function hc(n,t){for(var r=n.split(" "),i=0;i<r.length;i++)r[i]&&!ie(r[i]).test(t)&&(t+=" "+r[i]);return t}function nw(n){var i,t,r;if(document.body.getElementsByClassName)for(i=document.body.getElementsByClassName("CodeMirror"),t=0;t<i.length;t++)r=i[t].CodeMirror,r&&n(r)}function rg(){cc||(ug(),cc=!0)}function ug(){var n;u(window,"resize",function(){n==null&&(n=setTimeout(function(){n=null;nw(rk)},100))});u(window,"blur",function(){nw(du)})}function fg(n){var t,r;return lc==null&&(t=i("span","​"),st(n,i("span",[t,document.createTextNode("x")])),n.firstChild.offsetHeight!=0&&(lc=t.offsetWidth<=1&&t.offsetHeight>2&&!(s&&a<8))),r=lc?i("span","​"):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px"),r.setAttribute("cm-text",""),r}function eg(n){var i,t,r;return ac!=null?ac:(i=st(n,document.createTextNode("AخA")),t=or(i,0,1).getBoundingClientRect(),!t||t.left==t.right)?!1:(r=or(i,1,2).getBoundingClientRect(),ac=r.right-t.right<3)}function sg(n){if(vc!=null)return vc;var t=st(n,i("span","x")),r=t.getBoundingClientRect(),u=or(t,0,1).getBoundingClientRect();return vc=Math.abs(r.left-u.left)>1}function hg(n,t,i,r){var e,f,u;if(!n)return r(t,i,"ltr");for(e=!1,f=0;f<n.length;++f)u=n[f],(u.from<i&&u.to>t||t==i&&u.to==t)&&(r(Math.max(u.from,t),Math.min(u.to,i),u.level==1?"rtl":"ltr"),e=!0);e||r(t,i,"ltr")}function yc(n){return n.level%2?n.to:n.from}function pc(n){return n.level%2?n.from:n.to}function ns(n){var t=at(n);return t?yc(t[0]):0}function ts(n){var t=at(n);return t?pc(h(t)):n.text.length}function rw(t,i){var e=r(t.doc,i),u=pt(e),f,o;return u!=e&&(i=c(u)),f=at(u),o=f?f[0].level%2?ts(u):ns(u):0,n(i,o)}function cg(t,i){for(var e,u=r(t.doc,i),f,o;e=sf(u);)u=e.find(1,!0).line,i=null;return f=at(u),o=f?f[0].level%2?ns(u):ts(u):u.text.length,n(i==null?c(u):i,o)}function uw(t,i){var u=rw(t,i.line),e=r(t.doc,u.line),o=at(e),f,s;return!o||o[0].level==0?(f=Math.max(0,e.text.search(/\S/)),s=i.line==u.line&&i.ch<=f&&i.ch,n(u.line,s?0:f)):u}function lg(n,t,i){var r=n[0].level;return t==r?!0:i==r?!1:t<i}function is(n,t){var r,u,i;for(re=null,r=0;r<n.length;++r){if(i=n[r],i.from<t&&i.to>t)return r;if(i.from==t||i.to==t)if(u==null)u=r;else return lg(n,i.level,n[u].level)?(i.from!=i.to&&(re=u),r):(i.from!=i.to&&(re=r),u)}return u}function wc(n,t,i,r){if(!r)return t+i;do t+=i;while(t>0&&te(n.text.charAt(t)));return t}function bc(n,t,i,r){var e=at(n);if(!e)return fw(n,t,i,r);for(var o=is(e,t),u=e[o],f=wc(n,t,u.level%2?-i:i,r);;){if(f>u.from&&f<u.to)return f;if(f==u.from||f==u.to)return is(e,f)==o?f:(u=e[o+=i],i>0==u.level%2?u.to:u.from);if(u=e[o+=i],!u)return null;f=i>0==u.level%2?wc(n,u.to,-1,r):wc(n,u.from,1,r)}}function fw(n,t,i,r){var u=t+i;if(r)while(u>0&&te(n.text.charAt(u)))u+=i;return u<0||u>n.text.length?null:u}var yi=/gecko\/\d/i.test(navigator.userAgent),kc=/MSIE \d/.test(navigator.userAgent),dc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),s=kc||dc,a=s&&(kc?document.documentMode||6:dc[1]),p=/WebKit\//.test(navigator.userAgent),ow=p&&/Qt\/\d+\.\d+/.test(navigator.userAgent),sw=/Chrome\//.test(navigator.userAgent),ht=/Opera\//.test(navigator.userAgent),gc=/Apple Computer/.test(navigator.vendor),hw=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),cw=/PhantomJS/.test(navigator.userAgent),hr=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),eu=hr||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),ct=hr||/Mac/.test(navigator.platform),lw=/win/i.test(navigator.platform),pi=ht&&navigator.userAgent.match(/Version\/(\d*\.\d*)/),n,f,ft,be,wi,ki,ga,no,to,lh,ku,rt,ah,ev,uo,li,kv,gi,bh,kh,dr,gr,ho,nr,tr,dv,rf,fi,ff,ai,lo,ef,hf,tu,wy,by,tp,nt,ip,vf,k,cp,bo,ot,kf,er,kp,sc,gp,or,go,uu,fu,cc,tw,lc,ac,oi,re,ew;pi&&(pi=Number(pi[1]));pi&&pi>=15&&(ht=!1,p=!0);var nl=ct&&(ow||ht&&(pi==null||pi<12.11)),rs=yi||s&&a>=9,tl=!1,si=!1;hs.prototype=vt({update:function(n){var i=n.scrollWidth>n.clientWidth+1,r=n.scrollHeight>n.clientHeight+1,t=n.nativeBarWidth,u,f;return r?(this.vert.style.display="block",this.vert.style.bottom=i?t+"px":"0",u=n.viewHeight-(i?t:0),this.vert.firstChild.style.height=Math.max(0,n.scrollHeight-n.clientHeight+u)+"px"):(this.vert.style.display="",this.vert.firstChild.style.height="0"),i?(this.horiz.style.display="block",this.horiz.style.right=r?t+"px":"0",this.horiz.style.left=n.barLeft+"px",f=n.viewWidth-n.barLeft-(r?t:0),this.horiz.firstChild.style.width=n.scrollWidth-n.clientWidth+f+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0"),!this.checkedOverlay&&n.clientHeight>0&&(t==0&&this.overlayHack(),this.checkedOverlay=!0),{right:r?t:0,bottom:i?t:0}},setScrollLeft:function(n){this.horiz.scrollLeft!=n&&(this.horiz.scrollLeft=n)},setScrollTop:function(n){this.vert.scrollTop!=n&&(this.vert.scrollTop=n)},overlayHack:function(){var i=ct&&!hw?"12px":"18px",n,t;this.horiz.style.minHeight=this.vert.style.minWidth=i;n=this;t=function(t){yf(t)!=n.vert&&yf(t)!=n.horiz&&v(n.cm,iv)(t)};u(this.vert,"mousedown",t);u(this.horiz,"mousedown",t)},clear:function(){var n=this.horiz.parentNode;n.removeChild(this.horiz);n.removeChild(this.vert)}},hs.prototype);cs.prototype=vt({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},cs.prototype);t.scrollbarModel={"native":hs,"null":cs};fe.prototype.signal=function(n,t){et(n,t)&&this.events.push(arguments)};fe.prototype.finish=function(){for(var n=0;n<this.events.length;n++)y.apply(null,this.events[n])};n=t.Pos=function(t,i){if(!(this instanceof n))return new n(t,i);this.line=t;this.ch=i};f=t.cmpPos=function(n,t){return n.line-t.line||n.ch-t.ch};ft=null;nh.prototype=vt({init:function(n){function e(n){if(i.somethingSelected())ft=i.getSelections(),t.inaccurateSelection&&(t.prevInput="",t.inaccurateSelection=!1,r.value=ft.join("\n"),er(r));else if(i.options.lineWiseCopyCut){var u=kl(i);ft=u.text;n.type=="cut"?i.setSelections(u.ranges,null,dt):(t.prevInput="",r.value=u.text.join("\n"),er(r))}else return;n.type=="cut"&&(i.state.cutIncoming=!0)}var t=this,i=this.cm,f=this.wrapper=gl(),r=this.textarea=f.firstChild;n.wrapper.insertBefore(f,n.wrapper.firstChild);hr&&(r.style.width="0px");u(r,"input",function(){s&&a>=9&&t.hasSelection&&(t.hasSelection=null);t.poll()});u(r,"paste",function(n){if(wl(n,i))return!0;i.state.pasteIncoming=!0;t.fastPoll()});u(r,"cut",e);u(r,"copy",e);u(n.scroller,"paste",function(r){ui(n,r)||(i.state.pasteIncoming=!0,t.focus())});u(n.lineSpace,"selectstart",function(t){ui(n,t)||k(t)});u(r,"compositionstart",function(){var n=i.getCursor("from");t.composing={start:n,range:i.markText(n,i.getCursor("to"),{className:"CodeMirror-composing"})}});u(r,"compositionend",function(){t.composing&&(t.poll(),t.composing.range.clear(),t.composing=null)})},prepareSelection:function(){var n=this.cm,t=n.display,e=n.doc,i=sa(n);if(n.options.moveInputWithCursor){var r=ii(n,e.sel.primary().head,"div"),u=t.wrapper.getBoundingClientRect(),f=t.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,r.top+f.top-u.top));i.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,r.left+f.left-u.left))}return i},showSelection:function(n){var i=this.cm,t=i.display;st(t.cursorDiv,n.cursors);st(t.selectionDiv,n.selection);n.teTop!=null&&(this.wrapper.style.top=n.teTop+"px",this.wrapper.style.left=n.teLeft+"px")},reset:function(n){var i,f,t,e,r,u;this.contextMenuPending||(t=this.cm,e=t.doc,t.somethingSelected()?(this.prevInput="",r=e.sel.primary(),i=iw&&(r.to().line-r.from().line>100||(f=t.getSelection()).length>1e3),u=i?"-":f||t.getSelection(),this.textarea.value=u,t.state.focused&&er(this.textarea),s&&a>=9&&(this.hasSelection=u)):n||(this.prevInput=this.textarea.value="",s&&a>=9&&(this.hasSelection=null)),this.inaccurateSelection=i)},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if(this.cm.options.readOnly!="nocursor"&&(!eu||gt()!=this.textarea))try{this.textarea.focus()}catch(n){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var n=this;n.pollingFast||n.polling.set(this.cm.options.pollInterval,function(){n.poll();n.cm.state.focused&&n.slowPoll()})},fastPoll:function(){function i(){var r=n.poll();r||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,i))}var t=!1,n=this;n.pollingFast=!0;n.polling.set(20,i)},poll:function(){var n=this.cm,f=this.textarea,r=this.prevInput,t,e,u,o,i;if(this.contextMenuPending||!n.state.focused||og(f)&&!r||ce(n)||n.options.disableInput||n.state.keySeq||(t=f.value,t==r&&!n.somethingSelected()))return!1;if(s&&a>=9&&this.hasSelection===t||ct&&/[\uf700-\uf7ff]/.test(t))return n.display.input.reset(),!1;if(n.doc.sel==n.display.selForContextMenu&&(e=t.charCodeAt(0),e!=8203||r||(r="​"),e==8666))return this.reset(),this.cm.execCommand("undo");for(u=0,o=Math.min(r.length,t.length);u<o&&r.charCodeAt(u)==t.charCodeAt(u);)++u;return i=this,ut(n,function(){le(n,t.slice(u),r.length-u,null,i.composing?"*compose":null);t.length>1e3||t.indexOf("\n")>-1?f.value=i.prevInput="":i.prevInput=t;i.composing&&(i.composing.range.clear(),i.composing.range=n.markText(i.composing.start,n.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){s&&a>=9&&(this.hasSelection=null);this.fastPoll()},onContextMenu:function(n){function y(){if(i.selectionStart!=null){var n=t.somethingSelected(),u="​"+(n?i.value:"");i.value="⇚";i.value=u;f.prevInput=n?"":"​";i.selectionStart=1;i.selectionEnd=u.length;r.selForContextMenu=t.doc.sel}}function b(){if(f.contextMenuPending=!1,f.wrapper.style.position="relative",i.style.cssText=c,s&&a<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=k),i.selectionStart!=null){(!s||s&&a<9)&&y();var u=0,n=function(){r.selForContextMenu==t.doc.sel&&i.selectionStart==0&&i.selectionEnd>0&&f.prevInput=="​"?v(t,rf.selectAll)(t):u++<10?r.detectingSelectAll=setTimeout(n,500):r.input.reset()};r.detectingSelectAll=setTimeout(n,200)}}var f=this,t=f.cm,r=t.display,i=f.textarea,e=yr(t,n),k=r.scroller.scrollTop,h,c,l,o;e&&!ht&&(h=t.options.resetSelectionOnContextMenu,h&&t.doc.sel.contains(e)==-1&&v(t,w)(t.doc,ti(e),dt),c=i.style.cssText,f.wrapper.style.position="absolute",i.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(n.clientY-5)+"px; left: "+(n.clientX-5)+"px; z-index: 1000; background: "+(s?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",p&&(l=window.scrollY),r.input.focus(),p&&window.scrollTo(null,l),r.input.reset(),t.somethingSelected()||(i.value=f.prevInput=" "),f.contextMenuPending=!0,r.selForContextMenu=t.doc.sel,clearTimeout(r.detectingSelectAll),s&&a>=9&&y(),rs?(bo(n),o=function(){bt(window,"mouseup",o);setTimeout(b,20)},u(window,"mouseup",o)):setTimeout(b,50))},setUneditable:gf,needsContentAttribute:!1},nh.prototype);th.prototype=vt({init:function(t){function e(n){var r,t,u,f;if(i.somethingSelected())ft=i.getSelections(),n.type=="cut"&&i.replaceSelection("",null,"cut");else if(i.options.lineWiseCopyCut)r=kl(i),ft=r.text,n.type=="cut"&&i.operation(function(){i.setSelections(r.ranges,0,dt);i.replaceSelection("",null,"cut")});else return;n.clipboardData&&!hr?(n.preventDefault(),n.clipboardData.clearData(),n.clipboardData.setData("text/plain",ft.join("\n"))):(t=gl(),u=t.firstChild,i.display.lineSpace.insertBefore(t,i.display.lineSpace.firstChild),u.value=ft.join("\n"),f=document.activeElement,er(u),setTimeout(function(){i.display.lineSpace.removeChild(t);f.focus()},50))}var r=this,i=r.cm,f=r.div=t.lineDiv;f.contentEditable="true";dl(f);u(f,"paste",function(n){wl(n,i)});u(f,"compositionstart",function(t){var u=t.data;if(r.composing={sel:i.doc.sel,data:u,startData:u},u){var f=i.doc.sel.primary(),o=i.getLine(f.head.line),e=o.indexOf(u,Math.max(0,f.head.ch-u.length));e>-1&&e<=f.head.ch&&(r.composing.sel=ti(n(f.head.line,e),n(f.head.line,e+u.length)))}});u(f,"compositionupdate",function(n){r.composing.data=n.data});u(f,"compositionend",function(n){var t=r.composing;t&&(n.data==t.startData||/\u200b/.test(n.data)||(t.data=n.data),setTimeout(function(){t.handled||r.applyComposition(t);r.composing==t&&(r.composing=null)},50))});u(f,"touchstart",function(){r.forceCompositionEnd()});u(f,"input",function(){r.composing||r.pollContent()||ut(r.cm,function(){it(i)})});u(f,"copy",e);u(f,"cut",e)},prepareSelection:function(){var n=sa(this.cm,!1);return n.focus=this.cm.state.focused,n},showSelection:function(n){n&&this.cm.display.view.length&&(n.focus&&this.showPrimarySelection(),this.showMultipleSelections(n))},showPrimarySelection:function(){var n=window.getSelection(),e=this.cm.doc.sel.primary(),o=ae(this.cm,n.anchorNode,n.anchorOffset),s=ae(this.cm,n.focusNode,n.focusOffset),i,r,h,c,u,t,l;if((!o||o.bad||!s||s.bad||f(he(o,s),e.from())!=0||f(se(o,s),e.to())!=0)&&(i=na(this.cm,e.from()),r=na(this.cm,e.to()),i||r)){h=this.cm.display.view;c=n.rangeCount&&n.getRangeAt(0);i?r||(u=h[h.length-1].measure,t=u.maps?u.maps[u.maps.length-1]:u.map,r={node:t[t.length-1],offset:t[t.length-2]-t[t.length-3]}):i={node:h[0].measure.map[2],offset:0};try{l=or(i.node,i.offset,r.offset,r.node)}catch(a){}l&&(n.removeAllRanges(),n.addRange(l),c&&n.anchorNode==null?n.addRange(c):yi&&this.startGracePeriod());this.rememberSelection()}},startGracePeriod:function(){var n=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){n.gracePeriod=!1;n.selectionChanged()&&n.cm.operation(function(){n.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(n){st(this.cm.display.cursorDiv,n.cursors);st(this.cm.display.selectionDiv,n.selection)},rememberSelection:function(){var n=window.getSelection();this.lastAnchorNode=n.anchorNode;this.lastAnchorOffset=n.anchorOffset;this.lastFocusNode=n.focusNode;this.lastFocusOffset=n.focusOffset},selectionInEditor:function(){var n=window.getSelection(),t;return n.rangeCount?(t=n.getRangeAt(0).commonAncestorContainer,go(this.div,t)):!1},focus:function(){this.cm.options.readOnly!="nocursor"&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function t(){n.cm.state.focused&&(n.pollSelection(),n.polling.set(n.cm.options.pollInterval,t))}var n=this;this.selectionInEditor()?this.pollSelection():ut(this.cm,function(){n.cm.curOp.selectionChanged=!0});this.polling.set(this.cm.options.pollInterval,t)},selectionChanged:function(){var n=window.getSelection();return n.anchorNode!=this.lastAnchorNode||n.anchorOffset!=this.lastAnchorOffset||n.focusNode!=this.lastFocusNode||n.focusOffset!=this.lastFocusOffset},pollSelection:function(){var t,n,i,r;this.composing||this.gracePeriod||!this.selectionChanged()||(t=window.getSelection(),n=this.cm,this.rememberSelection(),i=ae(n,t.anchorNode,t.anchorOffset),r=ae(n,t.focusNode,t.focusOffset),i&&r&&ut(n,function(){w(n.doc,ti(i,r),dt);(i.bad||r.bad)&&(n.curOp.selectionChanged=!0)}))},pollContent:function(){var e=this.cm,i=e.display,tt=e.doc.sel.primary(),p=tt.from(),it=tt.to(),w,l,b,y,s,k,t,u,g,nt;if(p.line<i.viewFrom||it.line>i.viewTo-1)return!1;for(p.line==i.viewFrom||(w=di(e,p.line))==0?(l=c(i.view[0].line),b=i.view[0].node):(l=c(i.view[w].line),b=i.view[w-1].node.nextSibling),y=di(e,it.line),y==i.view.length-1?(s=i.viewTo-1,k=i.lineDiv.lastChild):(s=c(i.view[y+1].line)-1,k=i.view[y+1].node.previousSibling),t=vi(tb(e,b,k,l,s)),u=ur(e.doc,n(l,0),n(s,r(e.doc,s).text.length));t.length>1&&u.length>1;)if(h(t)==h(u))t.pop(),u.pop(),s--;else if(t[0]==u[0])t.shift(),u.shift(),l++;else break;for(var o=0,a=0,rt=t[0],ut=u[0],ft=Math.min(rt.length,ut.length);o<ft&&rt.charCodeAt(o)==ut.charCodeAt(o);)++o;for(var v=h(t),d=h(u),et=Math.min(v.length-(t.length==1?o:0),d.length-(u.length==1?o:0));a<et&&v.charCodeAt(v.length-a-1)==d.charCodeAt(d.length-a-1);)++a;return t[t.length-1]=v.slice(0,v.length-a),t[0]=t[0].slice(o),g=n(l,o),nt=n(s,u.length?h(u).length-a:0),t.length>1||t[0]||f(g,nt)?(nf(e.doc,t,g,nt,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(n){n.data&&n.data!=n.startData&&v(this.cm,le)(this.cm,n.data,0,n.sel)},setUneditable:function(n){n.setAttribute("contenteditable","false")},onKeyPress:function(n){n.preventDefault();v(this.cm,le)(this.cm,String.fromCharCode(n.charCode==null?n.keyCode:n.charCode),0)},onContextMenu:gf,resetPosition:gf,needsContentAttribute:!0},th.prototype);t.inputStyles={textarea:nh,contenteditable:th};ni.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(n){var t,i,r;if(n==this)return!0;if(n.primIndex!=this.primIndex||n.ranges.length!=this.ranges.length)return!1;for(t=0;t<this.ranges.length;t++)if(i=this.ranges[t],r=n.ranges[t],f(i.anchor,r.anchor)!=0||f(i.head,r.head)!=0)return!1;return!0},deepCopy:function(){for(var t=[],n=0;n<this.ranges.length;n++)t[n]=new l(gs(this.ranges[n].anchor),gs(this.ranges[n].head));return new ni(t,this.primIndex)},somethingSelected:function(){for(var n=0;n<this.ranges.length;n++)if(!this.ranges[n].empty())return!0;return!1},contains:function(n,t){var i,r;for(t||(t=n),i=0;i<this.ranges.length;i++)if(r=this.ranges[i],f(t,r.from())>=0&&f(n,r.to())<=0)return i;return-1}};l.prototype={from:function(){return he(this.anchor,this.head)},to:function(){return se(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};be={left:0,right:0,top:0,bottom:0};ki=null;ga=0;lh=0;ku=0;rt=null;s?rt=-.53:yi?rt=15:sw?rt=-.7:gc&&(rt=-1/3);ah=function(n){var i=n.wheelDeltaX,t=n.wheelDeltaY;return i==null&&n.detail&&n.axis==n.HORIZONTAL_AXIS&&(i=n.detail),t==null&&n.detail&&n.axis==n.VERTICAL_AXIS?t=n.detail:t==null&&(t=n.wheelDelta),{x:i,y:t}};t.wheelEventPixels=function(n){var t=ah(n);return t.x*=rt,t.y*=rt,t};ev=new bf;uo=null;li=t.changeEnd=function(t){return t.text?n(t.from.line+t.text.length-1,h(t.text).length+(t.text.length==1?t.from.ch:0)):t.to};t.prototype={constructor:t,focus:function(){window.focus();this.display.input.focus()},setOption:function(n,t){var i=this.options,r=i[n];(i[n]!=t||n=="mode")&&(i[n]=t,gi.hasOwnProperty(n)&&v(this,gi[n])(this,t,r))},getOption:function(n){return this.options[n]},getDoc:function(){return this.doc},addKeyMap:function(n,t){this.state.keyMaps[t?"push":"unshift"](co(n))},removeKeyMap:function(n){for(var i=this.state.keyMaps,t=0;t<i.length;++t)if(i[t]==n||i[t].name==n)return i.splice(t,1),!0},addOverlay:b(function(n,i){var r=n.token?n:t.getMode(this.options,n);if(r.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:r,modeSpec:n,opaque:i&&i.opaque});this.state.modeGen++;it(this)}),removeOverlay:b(function(n){for(var r,i=this.state.overlays,t=0;t<i.length;++t)if(r=i[t].modeSpec,r==n||typeof n=="string"&&r.name==n){i.splice(t,1);this.state.modeGen++;it(this);return}}),indentLine:b(function(n,t,i){typeof t!="string"&&typeof t!="number"&&(t=t==null?this.options.smartIndent?"smart":"prev":t?"add":"subtract");cu(this.doc,n)&&tf(this,n,t,i)}),indentSelection:b(function(n){for(var i,u,f,e=this.doc.sel.ranges,r=-1,t=0;t<e.length;t++)if(i=e[t],i.empty())i.head.line>r&&(tf(this,i.head.line,n,!0),r=i.head.line,t==this.doc.sel.primIndex&&br(this));else{var o=i.from(),s=i.to(),h=Math.max(r,o.line);for(r=Math.min(this.lastLine(),s.line-(s.ch?0:1))+1,u=h;u<r;++u)tf(this,u,n);f=this.doc.sel.ranges;o.ch==0&&e.length==f.length&&f[t].from().ch>0&&ih(this.doc,t,new l(o,f[t].to()),dt)}}),getTokenAt:function(n,t){return ay(this,n,t)},getLineTokens:function(t,i){return ay(this,n(t),i,!0)},getTokenTypeAt:function(n){var t,f;n=e(this.doc,n);var u=py(this,r(this.doc,n.line)),s=0,h=(u.length-1)/2,o=n.ch,i;if(o==0)i=u[2];else for(;;)if(t=s+h>>1,(t?u[t*2-1]:0)>=o)h=t;else if(u[t*2+1]<o)s=t+1;else{i=u[t*2+2];break}return f=i?i.indexOf("cm-overlay "):-1,f<0?i:f==0?null:i.slice(0,f-1)},getModeAt:function(n){var i=this.doc.mode;return i.innerMode?t.innerMode(i,this.getTokenAt(n).state).mode:i},getHelper:function(n,t){return this.getHelpers(n,t)[0]},getHelpers:function(n,t){var u=[],r,i,o,f,e;if(!nr.hasOwnProperty(t))return u;if(r=nr[t],i=this.getModeAt(n),typeof i[t]=="string")r[i[t]]&&u.push(r[i[t]]);else if(i[t])for(f=0;f<i[t].length;f++)o=r[i[t][f]],o&&u.push(o);else i.helperType&&r[i.helperType]?u.push(r[i.helperType]):r[i.name]&&u.push(r[i.name]);for(f=0;f<r._global.length;f++)e=r._global[f],e.pred(i,this)&&g(u,e.val)==-1&&u.push(e.val);return u},getStateAfter:function(n,t){var i=this.doc;return n=ta(i,n==null?i.first+i.size-1:n),yu(this,n+1,t)},cursorCoords:function(n,t){var r,i=this.doc.sel.primary();return r=n==null?i.head:typeof n=="object"?e(this.doc,n):n?i.from():i.to(),ii(this,r,t||"page")},charCoords:function(n,t){return hh(this,e(this.doc,n),t||"page")},coordsChar:function(n,t){return n=ka(this,n,t||"page"),ch(this,n.left,n.top)},lineAtHeight:function(n,t){return n=ka(this,{top:n,left:0},t||"page").top,fr(this.doc,n+this.display.viewOffset)},heightAtLine:function(n,t){var f=!1,i,u;return typeof n=="number"?(u=this.doc.first+this.doc.size-1,n<this.doc.first?n=this.doc.first:n>u&&(n=u,f=!0),i=r(this.doc,n)):i=n,sh(this,i,{top:0,left:0},t||"page").top+(f?this.doc.height-ei(i):0)},defaultTextHeight:function(){return bi(this.display)},defaultCharWidth:function(){return wu(this.display)},setGutterMarker:b(function(n,t,i){return so(this.doc,n,"gutter",function(n){var r=n.gutterMarkers||(n.gutterMarkers={});return r[t]=i,!i&&dp(r)&&(n.gutterMarkers=null),!0})}),clearGutter:b(function(n){var t=this,i=t.doc,r=i.first;i.iter(function(i){i.gutterMarkers&&i.gutterMarkers[n]&&(i.gutterMarkers[n]=null,ri(t,r,"gutter"),dp(i.gutterMarkers)&&(i.gutterMarkers=null));++r})}),lineInfo:function(n){var t;if(typeof n=="number"){if(!cu(this.doc,n)||(t=n,n=r(this.doc,n),!n))return null}else if(t=c(n),t==null)return null;return{line:t,handle:n,text:n.text,gutterMarkers:n.gutterMarkers,textClass:n.textClass,bgClass:n.bgClass,wrapClass:n.wrapClass,widgets:n.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(n,t,i,r,u){var s=this.display,o,f,h,c;n=ii(this,e(this.doc,n));o=n.bottom;f=n.left;t.style.position="absolute";t.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(t);s.sizer.appendChild(t);r=="over"?o=n.top:(r=="above"||r=="near")&&(h=Math.max(s.wrapper.clientHeight,this.doc.height),c=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth),(r=="above"||n.bottom+t.offsetHeight>h)&&n.top>t.offsetHeight?o=n.top-t.offsetHeight:n.bottom+t.offsetHeight<=h&&(o=n.bottom),f+t.offsetWidth>c&&(f=c-t.offsetWidth));t.style.top=o+"px";t.style.left=t.style.right="";u=="right"?(f=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(u=="left"?f=0:u=="middle"&&(f=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=f+"px");i&&kk(this,f,o,f+t.offsetWidth,o+t.offsetHeight)},triggerOnKeyDown:b(sv),triggerOnKeyPress:b(cv),triggerOnKeyUp:hv,execCommand:function(n){if(rf.hasOwnProperty(n))return rf[n](this)},triggerElectric:b(function(n){bl(this,n)}),findPosH:function(n,t,i,r){var o=1,f,u;for(t<0&&(o=-1,t=-t),f=0,u=e(this.doc,n);f<t;++f)if(u=wh(this.doc,u,o,i,r),u.hitSide)break;return u},moveH:b(function(n,t){var i=this;i.extendSelectionsBy(function(r){return i.display.shift||i.doc.extend||r.empty()?wh(i.doc,r.head,n,t,i.options.rtlMoveVisually):n<0?r.from():r.to()},wf)}),deleteH:b(function(n,t){var r=this.doc.sel,i=this.doc;r.somethingSelected()?i.replaceSelection("",null,"+delete"):kr(this,function(r){var u=wh(i,r.head,n,t,!1);return n<0?{from:u,to:r.head}:{from:r.head,to:u}})}),findPosV:function(n,t,i,r){var h=1,o=r,s,u,f;for(t<0&&(h=-1,t=-t),s=0,u=e(this.doc,n);s<t;++s)if(f=ii(this,u,"div"),o==null?o=f.left:f.left=o,u=bv(this,f,h,i),u.hitSide)break;return u},moveV:b(function(n,t){var r=this,i=this.doc,f=[],e=!r.display.shift&&!i.extend&&i.sel.somethingSelected(),u;if(i.extendSelectionsBy(function(u){var o,s;return e?n<0?u.from():u.to():(o=ii(r,u.head,"div"),u.goalColumn!=null&&(o.left=u.goalColumn),f.push(o.left),s=bv(r,o,n,t),t=="page"&&u==i.sel.primary()&&ph(r,null,hh(r,s,"div").top-o.top),s)},wf),f.length)for(u=0;u<i.sel.ranges.length;u++)i.sel.ranges[u].goalColumn=f[u]}),findWordAt:function(t){var h=this.doc,u=r(h,t.line).text,i=t.ch,f=t.ch,e,o,s;if(u){for(e=this.getHelper(t,"wordChars"),(t.xRel<0||f==u.length)&&i?--i:++f,o=u.charAt(i),s=ko(o,e)?function(n){return ko(n,e)}:/\s/.test(o)?function(n){return/\s/.test(n)}:function(n){return!/\s/.test(n)&&!ko(n)};i>0&&s(u.charAt(i-1));)--i;while(f<u.length&&s(u.charAt(f)))++f}return new l(n(t.line,i),n(t.line,f))},toggleOverwrite:function(n){(n==null||n!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?fu(this.display.cursorDiv,"CodeMirror-overwrite"):uu(this.display.cursorDiv,"CodeMirror-overwrite"),y(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==gt()},scrollTo:b(function(n,t){(n!=null||t!=null)&&oo(this);n!=null&&(this.curOp.scrollLeft=n);t!=null&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var n=this.display.scroller;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight-yt(this)-this.display.barHeight,width:n.scrollWidth-yt(this)-this.display.barWidth,clientHeight:fh(this),clientWidth:hi(this)}},scrollIntoView:b(function(t,i){if(t==null?(t={from:this.doc.sel.primary().head,to:null},i==null&&(i=this.options.cursorScrollMargin)):typeof t=="number"?t={from:n(t,0),to:null}:t.from==null&&(t={from:t,to:null}),t.to||(t.to=t.from),t.margin=i||0,t.from.line!=null)oo(this),this.curOp.scrollToPos=t;else{var r=eo(this,Math.min(t.from.left,t.to.left),Math.min(t.from.top,t.to.top)-t.margin,Math.max(t.from.right,t.to.right),Math.max(t.from.bottom,t.to.bottom)+t.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:b(function(n,t){function u(n){return typeof n=="number"||/^\d+$/.test(String(n))?n+"px":n}var i=this,r;n!=null&&(i.display.wrapper.style.width=u(n));t!=null&&(i.display.wrapper.style.height=u(t));i.options.lineWrapping&&pa(this);r=i.display.viewFrom;i.doc.iter(r,i.display.viewTo,function(n){if(n.widgets)for(var t=0;t<n.widgets.length;t++)if(n.widgets[t].noHScroll){ri(i,r,"widget");break}++r});i.curOp.forceUpdate=!0;y(i,"refresh",this)}),operation:function(n){return ut(this,n)},refresh:b(function(){var n=this.display.cachedTextHeight;it(this);this.curOp.forceUpdate=!0;pu(this);this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop);es(this);(n==null||Math.abs(n-bi(this.display))>.5)&&fs(this);y(this,"refresh",this)}),swapDoc:b(function(n){var t=this.doc;return t.cm=null,rp(this,n),pu(this),this.display.input.reset(),this.scrollTo(n.scrollLeft,n.scrollTop),this.curOp.forceScroll=!0,tt(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};ru(t);kv=t.defaults={};gi=t.optionHandlers={};bh=t.Init={toString:function(){return"CodeMirror.Init"}};o("value","",function(n,t){n.setValue(t)},!0);o("mode",null,function(n,t){n.doc.modeOption=t;us(n)},!0);o("indentUnit",2,us,!0);o("indentWithTabs",!1);o("smartIndent",!0);o("tabSize",4,function(n){ou(n);pu(n);it(n)},!0);o("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(n,i,r){n.state.specialChars=new RegExp(i.source+(i.test("\t")?"":"|\t"),"g");r!=t.Init&&n.refresh()});o("specialCharPlaceholder",vd,function(n){n.refresh()},!0);o("electricChars",!0);o("inputStyle",eu?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor");},!0);o("rtlMoveVisually",!lw);o("wholeLineUpdateBefore",!0);o("theme","default",function(n){rl(n);su(n)},!0);o("keyMap","default",function(n,i,r){var f=co(i),u=r!=t.Init&&co(r);u&&u.detach&&u.detach(n,f);f.attach&&f.attach(n,u||null)});o("extraKeys",null);o("lineWrapping",!1,vw,!0);o("gutters",[],function(n){ss(n.options);su(n)},!0);o("fixedGutter",!0,function(n,t){n.display.gutters.style.left=t?ys(n.display)+"px":"0";n.refresh()},!0);o("coverGutterNextToScrollbar",!1,function(n){cr(n)},!0);o("scrollbarStyle","native",function(n){fl(n);cr(n);n.display.scrollbars.setScrollTop(n.doc.scrollTop);n.display.scrollbars.setScrollLeft(n.doc.scrollLeft)},!0);o("lineNumbers",!1,function(n){ss(n.options);su(n)},!0);o("firstLineNumber",1,su,!0);o("lineNumberFormatter",function(n){return n},su,!0);o("showCursorWhenSelecting",!1,au,!0);o("resetSelectionOnContextMenu",!0);o("lineWiseCopyCut",!0);o("readOnly",!1,function(n,t){t=="nocursor"?(du(n),n.display.input.blur(),n.display.disabled=!0):(n.display.disabled=!1,t||n.display.input.reset())});o("disableInput",!1,function(n,t){t||n.display.input.reset()},!0);o("dragDrop",!0,ik);o("cursorBlinkRate",530);o("cursorScrollMargin",0);o("cursorHeight",1,au,!0);o("singleCursorHeightPerLine",!0,au,!0);o("workTime",100);o("workDelay",100);o("flattenSpans",!0,ou,!0);o("addModeClass",!1,ou,!0);o("pollInterval",100);o("undoDepth",200,function(n,t){n.doc.history.undoDepth=t});o("historyEventDelay",1250);o("viewportMargin",10,function(n){n.refresh()},!0);o("maxHighlightLength",1e4,ou,!0);o("moveInputWithCursor",!0,function(n,t){t||n.display.input.resetPosition()});o("tabindex",null,function(n,t){n.display.input.getField().tabIndex=t||""});o("autofocus",null);kh=t.modes={};dr=t.mimeModes={};t.defineMode=function(n,i){t.defaults.mode||n=="null"||(t.defaults.mode=n);arguments.length>2&&(i.dependencies=Array.prototype.slice.call(arguments,2));kh[n]=i};t.defineMIME=function(n,t){dr[n]=t};t.resolveMode=function(n){if(typeof n=="string"&&dr.hasOwnProperty(n))n=dr[n];else if(n&&typeof n.name=="string"&&dr.hasOwnProperty(n.name)){var i=dr[n.name];typeof i=="string"&&(i={name:i});n=bp(i,n);n.name=i.name}else if(typeof n=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(n))return t.resolveMode("application/xml");return typeof n=="string"?{name:n}:n||{name:"null"}};t.getMode=function(n,i){var i=t.resolveMode(i),e=kh[i.name],u,f,r;if(!e)return t.getMode(n,"text/plain");if(u=e(n,i),gr.hasOwnProperty(i.name)){f=gr[i.name];for(r in f)f.hasOwnProperty(r)&&(u.hasOwnProperty(r)&&(u["_"+r]=u[r]),u[r]=f[r])}if(u.name=i.name,i.helperType&&(u.helperType=i.helperType),i.modeProps)for(r in i.modeProps)u[r]=i.modeProps[r];return u};t.defineMode("null",function(){return{token:function(n){n.skipToEnd()}}});t.defineMIME("text/plain","null");gr=t.modeExtensions={};t.extendMode=function(n,t){var i=gr.hasOwnProperty(n)?gr[n]:gr[n]={};vt(t,i)};t.defineExtension=function(n,i){t.prototype[n]=i};t.defineDocExtension=function(n,t){nt.prototype[n]=t};t.defineOption=o;ho=[];t.defineInitHook=function(n){ho.push(n)};nr=t.helpers={};t.registerHelper=function(n,i,r){nr.hasOwnProperty(n)||(nr[n]=t[n]={_global:[]});nr[n][i]=r};t.registerGlobalHelper=function(n,i,r,u){t.registerHelper(n,i,u);nr[n]._global.push({pred:r,val:u})};tr=t.copyState=function(n,t){var r,u,i;if(t===!0)return t;if(n.copyState)return n.copyState(t);r={};for(u in t)i=t[u],i instanceof Array&&(i=i.concat([])),r[u]=i;return r};dv=t.startState=function(n,t,i){return n.startState?n.startState(t,i):!0};t.innerMode=function(n,t){while(n.innerMode){var i=n.innerMode(t);if(!i||i.mode==n)break;t=i.state;n=i.mode}return i||{mode:n,state:t}};rf=t.commands={selectAll:function(t){t.setSelection(n(t.firstLine(),0),n(t.lastLine()),dt)},singleSelection:function(n){n.setSelection(n.getCursor("anchor"),n.getCursor("head"),dt)},killLine:function(t){kr(t,function(i){if(i.empty()){var u=r(t.doc,i.head.line).text.length;return i.head.ch==u&&i.head.line<t.lastLine()?{from:i.head,to:n(i.head.line+1,0)}:{from:i.head,to:n(i.head.line,u)}}return{from:i.from(),to:i.to()}})},deleteLine:function(t){kr(t,function(i){return{from:n(i.from().line,0),to:e(t.doc,n(i.to().line+1,0))}})},delLineLeft:function(t){kr(t,function(t){return{from:n(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(n){kr(n,function(t){var i=n.charCoords(t.head,"div").top+5,r=n.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(n){kr(n,function(t){var i=n.charCoords(t.head,"div").top+5,r=n.coordsChar({left:n.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})},undo:function(n){n.undo()},redo:function(n){n.redo()},undoSelection:function(n){n.undoSelection()},redoSelection:function(n){n.redoSelection()},goDocStart:function(t){t.extendSelection(n(t.firstLine(),0))},goDocEnd:function(t){t.extendSelection(n(t.lastLine()))},goLineStart:function(n){n.extendSelectionsBy(function(t){return rw(n,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(n){n.extendSelectionsBy(function(t){return uw(n,t.head)},{origin:"+move",bias:1})},goLineEnd:function(n){n.extendSelectionsBy(function(t){return cg(n,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(n){n.extendSelectionsBy(function(t){var i=n.charCoords(t.head,"div").top+5;return n.coordsChar({left:n.display.lineDiv.offsetWidth+100,top:i},"div")},wf)},goLineLeft:function(n){n.extendSelectionsBy(function(t){var i=n.charCoords(t.head,"div").top+5;return n.coordsChar({left:0,top:i},"div")},wf)},goLineLeftSmart:function(n){n.extendSelectionsBy(function(t){var r=n.charCoords(t.head,"div").top+5,i=n.coordsChar({left:0,top:r},"div");return i.ch<n.getLine(i.line).search(/\S/)?uw(n,t.head):i},wf)},goLineUp:function(n){n.moveV(-1,"line")},goLineDown:function(n){n.moveV(1,"line")},goPageUp:function(n){n.moveV(-1,"page")},goPageDown:function(n){n.moveV(1,"page")},goCharLeft:function(n){n.moveH(-1,"char")},goCharRight:function(n){n.moveH(1,"char")},goColumnLeft:function(n){n.moveH(-1,"column")},goColumnRight:function(n){n.moveH(1,"column")},goWordLeft:function(n){n.moveH(-1,"word")},goGroupRight:function(n){n.moveH(1,"group")},goGroupLeft:function(n){n.moveH(-1,"group")},goWordRight:function(n){n.moveH(1,"word")},delCharBefore:function(n){n.deleteH(-1,"char")},delCharAfter:function(n){n.deleteH(1,"char")},delWordBefore:function(n){n.deleteH(-1,"word")},delWordAfter:function(n){n.deleteH(1,"word")},delGroupBefore:function(n){n.deleteH(-1,"group")},delGroupAfter:function(n){n.deleteH(1,"group")},indentAuto:function(n){n.indentSelection("smart")},indentMore:function(n){n.indentSelection("add")},indentLess:function(n){n.indentSelection("subtract")},insertTab:function(n){n.replaceSelection("\t")},insertSoftTab:function(n){for(var r,e,u=[],f=n.listSelections(),t=n.options.tabSize,i=0;i<f.length;i++)r=f[i].from(),e=ot(n.getLine(r.line),r.ch,t),u.push(new Array(t-e%t+1).join(" "));n.replaceSelections(u)},defaultTab:function(n){n.somethingSelected()?n.indentSelection("add"):n.execCommand("insertTab")},transposeChars:function(t){ut(t,function(){for(var i,u,f,o=t.listSelections(),s=[],e=0;e<o.length;e++)i=o[e].head,u=r(t.doc,i.line).text,u&&(i.ch==u.length&&(i=new n(i.line,i.ch-1)),i.ch>0?(i=new n(i.line,i.ch+1),t.replaceRange(u.charAt(i.ch-1)+u.charAt(i.ch-2),n(i.line,i.ch-2),i,"+transpose")):i.line>t.doc.first&&(f=r(t.doc,i.line-1).text,f&&t.replaceRange(u.charAt(0)+"\n"+f.charAt(f.length-1),n(i.line-1,f.length-1),n(i.line,1),"+transpose"))),s.push(new l(i,i));t.setSelections(s)})},newlineAndIndent:function(n){ut(n,function(){for(var t,r=n.listSelections().length,i=0;i<r;i++)t=n.listSelections()[i],n.replaceRange("\n",t.anchor,t.head,"+input"),n.indentLine(t.from().line+1,null,!0),br(n)})},toggleOverwrite:function(n){n.toggleOverwrite()}};fi=t.keyMap={};fi.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};fi.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};fi.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};fi.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]};fi["default"]=ct?fi.macDefault:fi.pcDefault;t.normalizeKeyMap=function(n){var f={},t,o,i,r,e,u,s,h;for(t in n)if(n.hasOwnProperty(t)){if(o=n[t],/^(name|fallthrough|(de|at)tach)$/.test(t))continue;if(o=="..."){delete n[t];continue}for(i=df(t.split(" "),dk),r=0;r<i.length;r++)if(r==i.length-1?(u=i.join(" "),e=o):(u=i.slice(0,r+1).join(" "),e="..."),s=f[u],s){if(s!=e)throw new Error("Inconsistent bindings for "+u);}else f[u]=e;delete n[t]}for(h in f)n[h]=f[h];return n};var uf=t.lookupKey=function(n,t,i,r){var u,f,e;if(t=co(t),u=t.call?t.call(n,r):t[n],u===!1)return"nothing";if(u==="...")return"multi";if(u!=null&&i(u))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return uf(n,t.fallthrough,i,r);for(f=0;f<t.fallthrough.length;f++)if(e=uf(n,t.fallthrough[f],i,r),e)return e}},gk=t.isModifierKey=function(n){var t=typeof n=="string"?n:oi[n.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"},nd=t.keyName=function(n,t){if(ht&&n.keyCode==34&&n.char)return!1;var r=oi[n.keyCode],i=r;return i==null||n.altGraphKey?!1:(n.altKey&&r!="Alt"&&(i="Alt-"+i),(nl?n.metaKey:n.ctrlKey)&&r!="Ctrl"&&(i="Ctrl-"+i),(nl?n.ctrlKey:n.metaKey)&&r!="Cmd"&&(i="Cmd-"+i),!t&&n.shiftKey&&r!="Shift"&&(i="Shift-"+i),i)};t.fromTextArea=function(n,i){function f(){n.value=h.getValue()}var e,r,o,s,h;if(i=i?vt(i):{},i.value=n.value,!i.tabindex&&n.tabIndex&&(i.tabindex=n.tabIndex),!i.placeholder&&n.placeholder&&(i.placeholder=n.placeholder),i.autofocus==null&&(e=gt(),i.autofocus=e==n||n.getAttribute("autofocus")!=null&&e==document.body),n.form&&(u(n.form,"submit",f),!i.leaveSubmitMethodAlone)){r=n.form;o=r.submit;try{s=r.submit=function(){f();r.submit=o;r.submit();r.submit=s}}catch(c){}}return i.finishInit=function(t){t.save=f;t.getTextArea=function(){return n};t.toTextArea=function(){t.toTextArea=isNaN;f();n.parentNode.removeChild(t.getWrapperElement());n.style.display="";n.form&&(bt(n.form,"submit",f),typeof n.form.submit=="function"&&(n.form.submit=o))}},n.style.display="none",h=t(function(t){n.parentNode.insertBefore(t,n.nextSibling)},i)};ff=t.StringStream=function(n,t){this.pos=this.start=0;this.string=n;this.tabSize=t||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0};ff.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(n){var t=this.string.charAt(this.pos),i;return i=typeof n=="string"?t==n:t&&(n.test?n.test(t):n(t)),i?(++this.pos,t):void 0},eatWhile:function(n){for(var t=this.pos;this.eat(n););return this.pos>t},eatSpace:function(){for(var n=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>n},skipToEnd:function(){this.pos=this.string.length},skipTo:function(n){var t=this.string.indexOf(n,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(n){this.pos-=n},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ot(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ot(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return ot(this.string,null,this.tabSize)-(this.lineStart?ot(this.string,this.lineStart,this.tabSize):0)},match:function(n,t,i){var u,f,r;if(typeof n=="string"){if(u=function(n){return i?n.toLowerCase():n},f=this.string.substr(this.pos,n.length),u(f)==u(n))return t!==!1&&(this.pos+=n.length),!0}else return(r=this.string.slice(this.pos).match(n),r&&r.index>0)?null:(r&&t!==!1&&(this.pos+=r[0].length),r)},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(n,t){this.lineStart+=n;try{return t()}finally{this.lineStart-=n}}};lo=0;ai=t.TextMarker=function(n,t){this.lines=[];this.type=t;this.doc=n;this.id=++lo};ru(ai);ai.prototype.clear=function(){var n,e,u,f,o,t,r,i,s,h;if(!this.explicitlyCleared){for(n=this.doc.cm,e=n&&!n.curOp,e&&ar(n),et(this,"clear")&&(u=this.find(),u&&tt(this,"clear",u.from,u.to)),f=null,o=null,i=0;i<this.lines.length;++i)t=this.lines[i],r=of(t.markedSpans,this),n&&!this.collapsed?ri(n,c(t),"text"):n&&(r.to!=null&&(o=c(t)),r.from!=null&&(f=c(t))),t.markedSpans=ud(t.markedSpans,r),r.from==null&&this.collapsed&&!ir(this.doc,t)&&n&&wt(t,bi(n.display));if(n&&this.collapsed&&!n.options.lineWrapping)for(i=0;i<this.lines.length;++i)s=pt(this.lines[i]),h=ue(s),h>n.display.maxLineLength&&(n.display.maxLine=s,n.display.maxLineLength=h,n.display.maxLineChanged=!0);f!=null&&n&&this.collapsed&&it(n,f,o+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,n&&ea(n.doc));n&&tt(n,"markerCleared",n,this);e&&vr(n);this.parent&&this.parent.clear()}};ai.prototype.find=function(t,i){var f,o,e,r,u;for(t==null&&this.type=="bookmark"&&(t=1),e=0;e<this.lines.length;++e){if(r=this.lines[e],u=of(r.markedSpans,this),u.from!=null&&(f=n(i?r:c(r),u.from),t==-1))return f;if(u.to!=null&&(o=n(i?r:c(r),u.to),t==1))return o}return f&&{from:f,to:o}};ai.prototype.changed=function(){var i=this.find(-1,!0),t=this,n=this.doc.cm;i&&n&&ut(n,function(){var r=i.line,o=c(i.line),f=eh(n,o),e,u;f&&(ya(f),n.curOp.selectionChanged=n.curOp.forceUpdate=!0);n.curOp.updateMaxLine=!0;ir(t.doc,r)||t.height==null||(e=t.height,t.height=null,u=cf(t)-e,u&&wt(r,r.height+u))})};ai.prototype.attachLine=function(n){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&g(t.maybeHiddenMarkers,this)!=-1||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(n)};ai.prototype.detachLine=function(n){if(this.lines.splice(g(this.lines,n),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};lo=0;ef=t.SharedTextMarker=function(n,t){this.markers=n;this.primary=t;for(var i=0;i<n.length;++i)n[i].parent=this};ru(ef);ef.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var n=0;n<this.markers.length;++n)this.markers[n].clear();tt(this,"clear")}};ef.prototype.find=function(n,t){return this.primary.find(n,t)};hf=t.LineWidget=function(n,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=n;this.node=t};ru(hf);hf.prototype.clear=function(){var r=this.doc.cm,n=this.line.widgets,t=this.line,f=c(t),i,u;if(f!=null&&n){for(i=0;i<n.length;++i)n[i]==this&&n.splice(i--,1);n.length||(t.widgets=null);u=cf(this);wt(t,Math.max(0,t.height-u));r&&ut(r,function(){hy(r,t,-u);ri(r,f,"widget")})}};hf.prototype.changed=function(){var r=this.height,n=this.doc.cm,i=this.line,t;(this.height=null,t=cf(this)-r,t)&&(wt(i,i.height+t),n&&ut(n,function(){n.curOp.forceUpdate=!0;hy(n,i,t)}))};tu=t.Line=function(n,t,i){this.text=n;ry(this,t);this.height=i?i(this):1};ru(tu);tu.prototype.lineNo=function(){return c(this)};wy={};by={};lf.prototype={chunkSize:function(){return this.lines.length},removeInner:function(n,t){for(var r,i=n,u=n+t;i<u;++i)r=this.lines[i],this.height-=r.height,ad(r),tt(r,"delete");this.lines.splice(n,t)},collapse:function(n){n.push.apply(n,this.lines)},insertInner:function(n,t,i){this.height+=i;this.lines=this.lines.slice(0,n).concat(t).concat(this.lines.slice(n));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(n,t,i){for(var r=n+t;n<r;++n)if(i(this.lines[n]))return!0}};af.prototype={chunkSize:function(){return this.size},removeInner:function(n,t){var r,i,u,f,o,e;for(this.size-=t,r=0;r<this.children.length;++r)if(i=this.children[r],u=i.chunkSize(),n<u){if(f=Math.min(t,u-n),o=i.height,i.removeInner(n,f),this.height-=o-i.height,u==f&&(this.children.splice(r--,1),i.parent=null),(t-=f)==0)break;n=0}else n-=u;this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof lf))&&(e=[],this.collapse(e),this.children=[new lf(e)],this.children[0].parent=this)},collapse:function(n){for(var t=0;t<this.children.length;++t)this.children[t].collapse(n)},insertInner:function(n,t,i){var u,r,e,o,f;for(this.size+=t.length,this.height+=i,u=0;u<this.children.length;++u){if(r=this.children[u],e=r.chunkSize(),n<=e){if(r.insertInner(n,t,i),r.lines&&r.lines.length>50){while(r.lines.length>50)o=r.lines.splice(r.lines.length-25,25),f=new lf(o),r.height-=f.height,this.children.splice(u+1,0,f),f.parent=this;this.maybeSpill()}break}n-=e}},maybeSpill:function(){var n,r,t,i,u;if(!(this.children.length<=10)){n=this;do r=n.children.splice(n.children.length-5,5),t=new af(r),n.parent?(n.size-=t.size,n.height-=t.height,u=g(n.parent.children,n),n.parent.children.splice(u+1,0,t)):(i=new af(n.children),i.parent=n,n.children=[i,t],n=i),t.parent=n.parent;while(n.children.length>10);n.parent.maybeSpill()}},iterN:function(n,t,i){for(var f,u,e,r=0;r<this.children.length;++r)if(f=this.children[r],u=f.chunkSize(),n<u){if(e=Math.min(t,u-n),f.iterN(n,e,i))return!0;if((t-=e)==0)break;n=0}else n-=u}};tp=0;nt=t.Doc=function(t,i,r){if(!(this instanceof nt))return new nt(t,i,r);r==null&&(r=0);af.call(this,[new lf([new tu("",null)])]);this.first=r;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.frontier=r;var u=n(r,0);this.sel=ti(u);this.history=new po(null);this.id=++tp;this.modeOption=i;typeof t=="string"&&(t=vi(t));rc(this,{from:u,to:u,text:t});w(this,ti(u),dt)};nt.prototype=bp(af.prototype,{constructor:nt,iter:function(n,t,i){i?this.iterN(n-this.first,t-n,i):this.iterN(this.first,this.first+this.size,n)},insert:function(n,t){for(var r=0,i=0;i<t.length;++i)r+=t[i].height;this.insertInner(n-this.first,t,r)},remove:function(n,t){this.removeInner(n-this.first,t)},getValue:function(n){var t=uc(this,this.first,this.first+this.size);return n===!1?t:t.join(n||"\n")},setValue:d(function(t){var i=n(this.first,0),u=this.first+this.size-1;wr(this,{from:i,to:n(u,r(this,u).text.length),text:vi(t),origin:"setValue",full:!0},!0);w(this,ti(i))}),replaceRange:function(n,t,i,r){t=e(this,t);i=i?e(this,i):t;nf(this,n,t,i,r)},getRange:function(n,t,i){var r=ur(this,e(this,n),e(this,t));return i===!1?r:r.join(i||"\n")},getLine:function(n){var t=this.getLineHandle(n);return t&&t.text},getLineHandle:function(n){if(cu(this,n))return r(this,n)},getLineNumber:function(n){return c(n)},getLineHandleVisualStart:function(n){return typeof n=="number"&&(n=r(this,n)),pt(n)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(n){return e(this,n)},getCursor:function(n){var t=this.sel.primary();return n==null||n=="head"?t.head:n=="anchor"?t.anchor:n=="end"||n=="to"||n===!1?t.to():t.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:d(function(t,i,r){ra(this,e(this,typeof t=="number"?n(t,i||0):t),null,r)}),setSelection:d(function(n,t,i){ra(this,e(this,n),e(this,t||n),i)}),extendSelection:d(function(n,t,i){ve(this,e(this,n),t&&e(this,t),i)}),extendSelections:d(function(n,t){ia(this,rb(this,n,t))}),extendSelectionsBy:d(function(n,t){ia(this,df(this.sel.ranges,n),t)}),setSelections:d(function(n,t,i){if(n.length){for(var r=0,u=[];r<n.length;r++)u[r]=new l(e(this,n[r].anchor),e(this,n[r].head));t==null&&(t=Math.min(n.length-1,this.sel.primIndex));w(this,lt(u,t),i)}}),addSelection:d(function(n,t,i){var r=this.sel.ranges.slice(0);r.push(new l(e(this,n),e(this,t||n)));w(this,lt(r,r.length-1),i)}),getSelection:function(n){for(var u,r=this.sel.ranges,t,i=0;i<r.length;i++)u=ur(this,r[i].from(),r[i].to()),t=t?t.concat(u):u;return n===!1?t:t.join(n||"\n")},getSelections:function(n){for(var i,u=[],r=this.sel.ranges,t=0;t<r.length;t++)i=ur(this,r[t].from(),r[t].to()),n!==!1&&(i=i.join(n||"\n")),u[t]=i;return u},replaceSelection:function(n,t,i){for(var u=[],r=0;r<this.sel.ranges.length;r++)u[r]=n;this.replaceSelections(u,t,i||"+input")},replaceSelections:d(function(n,t,i){for(var f,e,u=[],o=this.sel,r=0;r<o.ranges.length;r++)f=o.ranges[r],u[r]={from:f.from(),to:f.to(),text:vi(n[r]),origin:i};for(e=t&&t!="end"&&yk(this,u,t),r=u.length-1;r>=0;r--)wr(this,u[r]);e?ua(this,e):this.cm&&br(this.cm)}),undo:d(function(){fo(this,"undo")}),redo:d(function(){fo(this,"redo")}),undoSelection:d(function(){fo(this,"undo",!0)}),redoSelection:d(function(){fo(this,"redo",!0)}),setExtending:function(n){this.extend=n},getExtending:function(){return this.extend},historySize:function(){for(var t=this.history,i=0,r=0,n=0;n<t.done.length;n++)t.done[n].ranges||++i;for(n=0;n<t.undone.length;n++)t.undone[n].ranges||++r;return{undo:i,redo:r}},clearHistory:function(){this.history=new po(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(n){return n&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(n){return this.history.generation==(n||this.cleanGeneration)},getHistory:function(){return{done:iu(this.history.done),undone:iu(this.history.undone)}},setHistory:function(n){var t=this.history=new po(this.history.maxGeneration);t.done=iu(n.done.slice(0),null,!0);t.undone=iu(n.undone.slice(0),null,!0)},addLineClass:d(function(n,t,i){return so(this,n,t=="gutter"?"gutter":"class",function(n){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(n[r]){if(ie(i).test(n[r]))return!1;n[r]+=" "+i}else n[r]=i;return!0})}),removeLineClass:d(function(n,t,i){return so(this,n,t=="gutter"?"gutter":"class",function(n){var f=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",u=n[f],r,e;if(u)if(i==null)n[f]=null;else{if(r=u.match(ie(i)),!r)return!1;e=r.index+r[0].length;n[f]=u.slice(0,r.index)+(!r.index||e==u.length?"":" ")+u.slice(e)||null}else return!1;return!0})}),addLineWidget:d(function(n,t,i){return cd(this,n,t,i)}),removeLineWidget:function(n){n.clear()},markText:function(n,t,i){return nu(this,e(this,n),e(this,t),i,"range")},setBookmark:function(n,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return n=e(this,n),nu(this,n,n,i,"bookmark")},findMarksAt:function(n){var f,i,u,t;if(n=e(this,n),f=[],i=r(this,n.line).markedSpans,i)for(u=0;u<i.length;++u)t=i[u],(t.from==null||t.from<=n.ch)&&(t.to==null||t.to>=n.ch)&&f.push(t.marker.parent||t.marker);return f},findMarks:function(n,t,i){n=e(this,n);t=e(this,t);var u=[],r=n.line;return this.iter(n.line,t.line+1,function(f){var s=f.markedSpans,o,e;if(s)for(o=0;o<s.length;o++)e=s[o],r==n.line&&n.ch>e.to||e.from==null&&r!=n.line||r==t.line&&e.from>t.ch||i&&!i(e.marker)||u.push(e.marker.parent||e.marker);++r}),u},getAllMarks:function(){var n=[];return this.iter(function(t){var r=t.markedSpans,i;if(r)for(i=0;i<r.length;++i)r[i].from!=null&&n.push(r[i].marker)}),n},posFromIndex:function(t){var i,r=this.first;return this.iter(function(n){var u=n.text.length+1;if(u>t)return i=t,!0;t-=u;++r}),e(this,n(r,i))},indexFromPos:function(n){n=e(this,n);var t=n.ch;return n.line<this.first||n.ch<0?0:(this.iter(this.first,n.line,function(n){t+=n.text.length+1}),t)},copy:function(n){var t=new nt(uc(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,n&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(n){var i,r,t;return n||(n={}),i=this.first,r=this.first+this.size,n.from!=null&&n.from>i&&(i=n.from),n.to!=null&&n.to<r&&(r=n.to),t=new nt(uc(this,i,r),n.mode||this.modeOption,i),n.sharedHist&&(t.history=this.history),(this.linked||(this.linked=[])).push({doc:t,sharedHist:n.sharedHist}),t.linked=[{doc:this,isParent:!0,sharedHist:n.sharedHist}],id(t,gv(this)),t},unlinkDoc:function(n){var i,u,r;if(n instanceof t&&(n=n.doc),this.linked)for(i=0;i<this.linked.length;++i)if(u=this.linked[i],u.doc==n){this.linked.splice(i,1);n.unlinkDoc(this);rd(gv(this));break}n.history==this.history&&(r=[n.id],rr(n,function(n){r.push(n.id)},!0),n.history=new po(null),n.history.done=iu(this.history.done,r),n.history.undone=iu(this.history.undone,r))},iterLinkedDocs:function(n){rr(this,n)},getMode:function(){return this.mode},getEditor:function(){return this.cm}});nt.prototype.eachLine=nt.prototype.iter;ip="iter insert remove copy getEditor constructor".split(" ");for(vf in nt.prototype)nt.prototype.hasOwnProperty(vf)&&g(ip,vf)<0&&(t.prototype[vf]=function(n){return function(){return n.apply(this.doc,arguments)}}(nt.prototype[vf]));ru(nt);k=t.e_preventDefault=function(n){n.preventDefault?n.preventDefault():n.returnValue=!1};cp=t.e_stopPropagation=function(n){n.stopPropagation?n.stopPropagation():n.cancelBubble=!0};bo=t.e_stop=function(n){k(n);cp(n)};var u=t.on=function(n,t,i){if(n.addEventListener)n.addEventListener(t,i,!1);else if(n.attachEvent)n.attachEvent("on"+t,i);else{var r=n._handlers||(n._handlers={}),u=r[t]||(r[t]=[]);u.push(i)}},bt=t.off=function(n,t,i){var r,u;if(n.removeEventListener)n.removeEventListener(t,i,!1);else if(n.detachEvent)n.detachEvent("on"+t,i);else{if(r=n._handlers&&n._handlers[t],!r)return;for(u=0;u<r.length;++u)if(r[u]==i){r.splice(u,1);break}}},y=t.signal=function(n,t){var r=n._handlers&&n._handlers[t],u,i;if(r)for(u=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,u)},pf=null;var vp=30,yp=t.Pass={toString:function(){return"CodeMirror.Pass"}},dt={scroll:!1},oc={origin:"*mouse"},wf={origin:"+move"};bf.prototype.set=function(n,t){clearTimeout(this.id);this.id=setTimeout(t,n)};ot=t.countColumn=function(n,t,i,r,u){var f,e,o;for(t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length)),f=r||0,e=u||0;;){if(o=n.indexOf("\t",f),o<0||o>=t)return e+(t-f);e+=o-f;e+=i-e%i;f=o+1}};kf=[""];er=function(n){n.select()};hr?er=function(n){n.selectionStart=0;n.selectionEnd=n.value.length}:s&&(er=function(n){try{n.select()}catch(t){}});kp=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;sc=t.isWordChar=function(n){return/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||kp.test(n))};gp=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;or=document.createRange?function(n,t,i,r){var u=document.createRange();return u.setEnd(r||n,i),u.setStart(n,t),u}:function(n,t,i){var r=document.body.createTextRange();try{r.moveToElementText(n.parentNode)}catch(u){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};go=t.contains=function(n,t){if(t.nodeType==3&&(t=t.parentNode),n.contains)return n.contains(t);do if(t.nodeType==11&&(t=t.host),t==n)return!0;while(t=t.parentNode)};s&&a<11&&(gt=function(){try{return document.activeElement}catch(n){return document.body}});uu=t.rmClass=function(n,t){var r=n.className,i=ie(t).exec(r),u;i&&(u=r.slice(i.index+i[0].length),n.className=r.slice(0,i.index)+(u?i[1]+u:""))};fu=t.addClass=function(n,t){var i=n.className;ie(t).test(i)||(n.className+=(i?" ":"")+t)};cc=!1;tw=function(){if(s&&a<9)return!1;var n=i("div");return"draggable"in n||"dragDrop"in n}();var vi=t.splitLines="\n\nb".split(/\n/).length!=3?function(n){for(var i=0,f=[],e=n.length,t,r,u;i<=e;)t=n.indexOf("\n",i),t==-1&&(t=n.length),r=n.slice(i,n.charAt(t-1)=="\r"?t-1:t),u=r.indexOf("\r"),u!=-1?(f.push(r.slice(0,u)),i+=u+1):(f.push(r),i=t+1);return f}:function(n){return n.split(/\r\n?|\n/)},og=window.getSelection?function(n){try{return n.selectionStart!=n.selectionEnd}catch(t){return!1}}:function(n){try{var t=n.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=n?!1:t.compareEndPoints("StartToEnd",t)!=0},iw=function(){var n=i("div");return"oncopy"in n?!0:(n.setAttribute("oncopy","return;"),typeof n.oncopy=="function")}(),vc=null;return oi={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},t.keyNames=oi,function(){for(var n=0;n<10;n++)oi[n+48]=oi[n+96]=String(n);for(n=65;n<=90;n++)oi[n]=String.fromCharCode(n);for(n=1;n<=12;n++)oi[n+111]=oi[n+63235]="F"+n}(),ew=function(){function s(n){return n<=247?e.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1773?o.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":n==8204?"b":"L"}function n(n,t,i){this.level=n;this.from=t;this.to=i}var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",o="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",c=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,r=/[LRr]/,u=/[Lb1n]/,f=/[1n]/,t="L";return function(e){var p,l,b,tt,d,y,w,v,g,o,it,k,nt,a,rt;if(!c.test(e))return!1;for(p=e.length,l=[],o=0;o<p;++o)l.push(y=s(e.charCodeAt(o)));for(o=0,b=t;o<p;++o)y=l[o],y=="m"?l[o]=b:b=y;for(o=0,d=t;o<p;++o)y=l[o],y=="1"&&d=="r"?l[o]="n":r.test(y)&&(d=y,y=="r"&&(l[o]="R"));for(o=1,b=l[0];o<p-1;++o)y=l[o],y=="+"&&b=="1"&&l[o+1]=="1"?l[o]="1":y==","&&b==l[o+1]&&(b=="1"||b=="n")&&(l[o]=b),b=y;for(o=0;o<p;++o)if(y=l[o],y==",")l[o]="N";else if(y=="%"){for(w=o+1;w<p&&l[w]=="%";++w);for(tt=o&&l[o-1]=="!"||w<p&&l[w]=="1"?"1":"N",a=o;a<w;++a)l[a]=tt;o=w-1}for(o=0,d=t;o<p;++o)y=l[o],d=="L"&&y=="1"?l[o]="L":r.test(y)&&(d=y);for(o=0;o<p;++o)if(i.test(l[o])){for(w=o+1;w<p&&i.test(l[w]);++w);var ut=(o?l[o-1]:t)=="L",ft=(w<p?l[w]:t)=="L",tt=ut||ft?"L":"R";for(a=o;a<w;++a)l[a]=tt;o=w-1}for(v=[],o=0;o<p;)if(u.test(l[o])){for(it=o,++o;o<p&&u.test(l[o]);++o);v.push(new n(0,it,o))}else{for(k=o,nt=v.length,++o;o<p&&l[o]!="L";++o);for(a=k;a<o;)if(f.test(l[a])){for(k<a&&v.splice(nt,0,new n(1,k,a)),rt=a,++a;a<o&&f.test(l[a]);++a);v.splice(nt,0,new n(2,rt,a));k=a}else++a;k<o&&v.splice(nt,0,new n(1,k,o))}return v[0].level==1&&(g=e.match(/^\s+/))&&(v[0].from=g[0].length,v.unshift(new n(0,0,g[0].length))),h(v).level==1&&(g=e.match(/\s+$/))&&(h(v).to-=g[0].length,v.push(new n(0,p-g[0].length,p))),v[0].level==2&&v.unshift(new n(1,v[0].to,v[0].to)),v[0].level!=h(v).level&&v.push(new n(v[0].level,p,p)),v}}(),t.version="5.3.1",t}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function i(n,i,u,f){var h,o,e,s;this.atOccurrence=!1;this.doc=n;f==null&&typeof i=="string"&&(f=!1);u=u?n.clipPos(u):t(0,0);this.pos={from:u,to:u};typeof i!="string"?(i.global||(i=new RegExp(i.source,i.ignoreCase?"ig":"g")),this.matches=function(r,u){var o,h,f,s,c,e;if(r){for(i.lastIndex=0,o=n.getLine(u.line).slice(0,u.ch),h=0;;){if(i.lastIndex=h,c=i.exec(o),!c)break;if(f=c,s=f.index,h=f.index+(f[0].length||1),h==o.length)break}e=f&&f[0].length||0;e||(s==0&&o.length==0?f=undefined:s!=n.getLine(u.line).length&&e++)}else{i.lastIndex=u.ch;var o=n.getLine(u.line),f=i.exec(o),e=f&&f[0].length||0,s=f&&f.index;s+e==o.length||e||(e=1)}if(f&&e)return{from:t(u.line,s),to:t(u.line,s+e),match:f}}):(h=i,f&&(i=i.toLowerCase()),o=f?function(n){return n.toLowerCase()}:function(n){return n},e=i.split("\n"),e.length==1?this.matches=i.length?function(u,f){if(u){var s=n.getLine(f.line).slice(0,f.ch),c=o(s),e=c.lastIndexOf(i);if(e>-1)return e=r(s,c,e),{from:t(f.line,e),to:t(f.line,e+h.length)}}else{var s=n.getLine(f.line).slice(f.ch),c=o(s),e=c.indexOf(i);if(e>-1)return e=r(s,c,e)+f.ch,{from:t(f.line,e),to:t(f.line,e+h.length)}}}:function(){}:(s=h.split("\n"),this.matches=function(i,r){var h=e.length-1,a,c,l,v,u,f;if(i){if(r.line-(e.length-1)<n.firstLine())return;if(o(n.getLine(r.line).slice(0,s[h].length))!=e[e.length-1])return;for(a=t(r.line,s[h].length),u=r.line-1,f=h-1;f>=1;--f,--u)if(e[f]!=o(n.getLine(u)))return;return(c=n.getLine(u),l=c.length-s[0].length,o(c.slice(l))!=e[0])?void 0:{from:t(u,l),to:a}}if(!(r.line+(e.length-1)>n.lastLine())&&(c=n.getLine(r.line),l=c.length-s[0].length,o(c.slice(l))==e[0])){for(v=t(r.line,l),u=r.line+1,f=1;f<h;++f,++u)if(e[f]!=o(n.getLine(u)))return;if(o(n.getLine(u).slice(0,s[h].length))==e[h])return{from:v,to:t(u,s[h].length)}}}))}function r(n,t,i){var r,u;if(n.length==t.length)return i;for(r=Math.min(i,n.length);;)if(u=n.slice(0,r).toLowerCase().length,u<i)++r;else if(u>i)--r;else return r}var t=n.Pos;i.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(n){function f(n){var i=t(n,0);return u.pos={from:i,to:i},u.atOccurrence=!1,!1}for(var u=this,i=this.doc.clipPos(n?this.pos.from:this.pos.to),r;;){if(this.pos=this.matches(n,i))return this.atOccurrence=!0,this.pos.match||!0;if(n){if(!i.line)return f(0);i=t(i.line-1,this.doc.getLine(i.line-1).length)}else{if(r=this.doc.lineCount(),i.line==r-1)return f(r);i=t(i.line+1,0)}}},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(i,r){if(this.atOccurrence){var u=n.splitLines(i);this.doc.replaceRange(u,this.pos.from,this.pos.to,r);this.pos.to=t(this.pos.from.line+u.length-1,u[u.length-1].length+(u.length==1?this.pos.from.ch:0))}}};n.defineExtension("getSearchCursor",function(n,t,r){return new i(this.doc,n,t,r)});n.defineDocExtension("getSearchCursor",function(n,t,r){return new i(this,n,t,r)});n.defineExtension("selectMatches",function(t,i){for(var u=[],r=this.getSearchCursor(t,this.getCursor("from"),i);r.findNext();){if(n.cmpPos(r.to(),this.getCursor("to"))>0)break;u.push({anchor:r.from(),head:r.to()})}u.length&&this.setSelections(u,0)})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):typeof define=="function"&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],n):n(CodeMirror)}(function(n){"use strict";function c(n,t){return typeof n=="string"?n=new RegExp(n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):n.global||(n=new RegExp(n.source,n.ignoreCase?"gi":"g")),{token:function(t){n.lastIndex=t.pos;var i=n.exec(t.string);if(i&&i.index==t.pos)return t.pos+=i[0].length,"searching";i?t.pos=i.index:t.skipToEnd()}}}function l(){this.posFrom=this.posTo=this.lastQuery=this.query=null;this.overlay=null}function i(n){return n.state.search||(n.state.search=new l)}function r(n){return typeof n=="string"&&n==n.toLowerCase()}function t(n,t,i){return n.getSearchCursor(t,i,r(t))}function u(n,t,i,r,u){n.openDialog?n.openDialog(t,u,{value:r,selectValueOnOpen:!0}):u(prompt(i,r))}function a(n,t,i,r){n.openConfirm?n.openConfirm(t,r):confirm(i)&&r[0]()}function o(n){var t=n.match(/^\/(.*)\/([a-z]*)$/);if(t)try{n=new RegExp(t[1],t[2].indexOf("i")==-1?"":"i")}catch(i){}return(typeof n=="string"?n=="":n.test(""))&&(n=/x^/),n}function f(n,t){var f=i(n),e;if(f.query)return s(n,t);e=n.getSelection()||f.lastQuery;u(n,v,"Search for:",e,function(i){n.operation(function(){i&&!f.query&&(f.query=o(i),n.removeOverlay(f.overlay,r(f.query)),f.overlay=c(f.query,r(f.query)),n.addOverlay(f.overlay),n.showMatchesOnScrollbar&&(f.annotate&&(f.annotate.clear(),f.annotate=null),f.annotate=n.showMatchesOnScrollbar(f.query,r(f.query))),f.posFrom=f.posTo=n.getCursor(),s(n,t))})})}function s(r,u){r.operation(function(){var e=i(r),f=t(r,e.query,u?e.posFrom:e.posTo);(f.find(u)||(f=t(r,e.query,u?n.Pos(r.lastLine()):n.Pos(r.firstLine(),0)),f.find(u)))&&(r.setSelection(f.from(),f.to()),r.scrollIntoView({from:f.from(),to:f.to()}),e.posFrom=f.from(),e.posTo=f.to())})}function e(n){n.operation(function(){var t=i(n);(t.lastQuery=t.query,t.query)&&(t.query=null,n.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))})}function h(n,r){if(!n.getOption("readOnly")){var f=n.getSelection()||i(n).lastQuery;u(n,y,"Replace:",f,function(i){i&&(i=o(i),u(n,p,"Replace with:","",function(u){if(r)n.operation(function(){for(var f,r=t(n,i);r.findNext();)typeof i!="string"?(f=n.getRange(r.from(),r.to()).match(i),r.replace(u.replace(/\$(\d)/g,function(n,t){return f[t]}))):r.replace(u)});else{e(n);var f=t(n,i,n.getCursor()),o=function(){var r=f.from(),u;((u=f.findNext())||(f=t(n,i),(u=f.findNext())&&(!r||f.from().line!=r.line||f.from().ch!=r.ch)))&&(n.setSelection(f.from(),f.to()),n.scrollIntoView({from:f.from(),to:f.to()}),a(n,w,"Replace?",[function(){s(u)},o]))},s=function(n){f.replace(typeof i=="string"?u:u.replace(/\$(\d)/g,function(t,i){return n[i]}));o()};o()}}))})}}var v='Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/><span style="color: #888" class="CodeMirror-search-hint">(Press Enter key to initiate search, Esc to cancel)<\/span>',y='Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/><span style="color: #888" class="CodeMirror-search-hint">(Press Enter key to initiate search, Esc to cancel)<\/span>',p='With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>',w="Replace? <button>Yes<\/button> <button>No<\/button> <button>Stop<\/button>";n.commands.find=function(n){e(n);f(n)};n.commands.findNext=f;n.commands.findPrev=function(n){f(n,!0)};n.commands.clearSearch=e;n.commands.replace=h;n.commands.replaceAll=function(n){h(n,!0)}}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function s(n){typeof n=="object"&&(this.minChars=n.minChars,this.style=n.style,this.showToken=n.showToken,this.delay=n.delay,this.wordsOnly=n.wordsOnly);this.style==null&&(this.style=f);this.minChars==null&&(this.minChars=u);this.delay==null&&(this.delay=e);this.wordsOnly==null&&(this.wordsOnly=o);this.overlay=this.timeout=null}function t(n){var t=n.state.matchHighlighter;clearTimeout(t.timeout);t.timeout=setTimeout(function(){i(n)},t.delay)}function i(n){n.operation(function(){var t=n.state.matchHighlighter,e,o,c;if(t.overlay&&(n.removeOverlay(t.overlay),t.overlay=null),!n.somethingSelected()&&t.showToken){for(var s=t.showToken===!0?/[\w$]/:t.showToken,l=n.getCursor(),f=n.getLine(l.line),i=l.ch,u=i;i&&s.test(f.charAt(i-1));)--i;while(u<f.length&&s.test(f.charAt(u)))++u;i<u&&n.addOverlay(t.overlay=r(f.slice(i,u),s,t.style));return}(e=n.getCursor("from"),o=n.getCursor("to"),e.line==o.line)&&(!t.wordsOnly||h(n,e,o))&&(c=n.getRange(e,o).replace(/^\s+|\s+$/g,""),c.length>=t.minChars&&n.addOverlay(t.overlay=r(c,!1,t.style)))})}function h(n,t,i){var f=n.getRange(t,i),r,u;return f.match(/^\w+$/)!==null?t.ch>0&&(r={line:t.line,ch:t.ch-1},u=n.getRange(r,t),u.match(/\W/)===null)?!1:i.ch<n.getLine(t.line).length&&(r={line:i.line,ch:i.ch+1},u=n.getRange(i,r),u.match(/\W/)===null)?!1:!0:!1}function c(n,t){return(!n.start||!t.test(n.string.charAt(n.start-1)))&&(n.pos==n.string.length||!t.test(n.string.charAt(n.pos)))}function r(n,t,i){return{token:function(r){if(r.match(n)&&(!t||c(r,t)))return i;r.next();r.skipTo(n.charAt(0))||r.skipToEnd()}}}var u=2,f="matchhighlight",e=100,o=!1;n.defineOption("highlightSelectionMatches",!1,function(r,u,f){if(f&&f!=n.Init){var e=r.state.matchHighlighter.overlay;e&&r.removeOverlay(e);clearTimeout(r.state.matchHighlighter.timeout);r.state.matchHighlighter=null;r.off("cursorActivity",t)}if(u){r.state.matchHighlighter=new s(u);i(r);r.on("cursorActivity",t)}})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){function t(n,t,i){var u=n.getWrapperElement(),r;return r=u.appendChild(document.createElement("div")),r.className=i?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top",typeof t=="string"?r.innerHTML=t:r.appendChild(t),r}function i(n,t){n.state.currentNotificationClose&&n.state.currentNotificationClose();n.state.currentNotificationClose=t}n.defineExtension("openDialog",function(r,u,f){function o(n){if(typeof n=="string")e.value=n;else{if(c)return;if(c=!0,s.parentNode.removeChild(s),l.focus(),f.onClose)f.onClose(s)}}var e,h;f||(f={});i(this,null);var s=t(this,r,f.bottom),c=!1,l=this;if(e=s.getElementsByTagName("input")[0],e){if(f.value&&(e.value=f.value,f.selectValueOnOpen!==!1&&e.select()),f.onInput)n.on(e,"input",function(n){f.onInput(n,e.value,o)});if(f.onKeyUp)n.on(e,"keyup",function(n){f.onKeyUp(n,e.value,o)});n.on(e,"keydown",function(t){f&&f.onKeyDown&&f.onKeyDown(t,e.value,o)||((t.keyCode==27||f.closeOnEnter!==!1&&t.keyCode==13)&&(e.blur(),n.e_stop(t),o()),t.keyCode==13&&u(e.value,t))});if(f.closeOnBlur!==!1)n.on(e,"blur",o);e.focus()}else if(h=s.getElementsByTagName("button")[0]){n.on(h,"click",function(){o();l.focus()});if(f.closeOnBlur!==!1)n.on(h,"blur",o);h.focus()}return o});n.defineExtension("openConfirm",function(r,u,f){function v(){l||(l=!0,s.parentNode.removeChild(s),a.focus())}var e,o;i(this,null);var s=t(this,r,f&&f.bottom),h=s.getElementsByTagName("button"),l=!1,a=this,c=1;for(h[0].focus(),e=0;e<h.length;++e){o=h[e],function(t){n.on(o,"click",function(i){n.e_preventDefault(i);v();t&&t(a)})}(u[e]);n.on(o,"blur",function(){--c;setTimeout(function(){c<=0&&v()},200)});n.on(o,"focus",function(){++c})}});n.defineExtension("openNotification",function(r,u){function f(){o||(o=!0,clearTimeout(s),e.parentNode.removeChild(e))}i(this,f);var e=t(this,r,u&&u.bottom),o=!1,s,h=u&&typeof u.duration!="undefined"?u.duration:5e3;n.on(e,"click",function(t){n.e_preventDefault(t);f()});return h&&(s=setTimeout(f,h)),f})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";n.defineMode("vhdlams",function(t,i){function c(n){for(var i={},r=n.split(" "),t=0;t<r.length;++t)i[r[t]]=!0;return i}function s(n,t){var i=n.peek(),f,e;if(/[\.]/.test(i))return r=n.next(),null;if(ut.test(i))return r=n.next(),"bracket";if(i=="`")return n.next(),n.eatWhile(/[\w\$_]/)?"def":null;if(i=="$")return n.next(),n.eatWhile(/[\w\$_]/)?"meta":null;if(i=="#")return n.next(),n.eatWhile(/[\d_.]/),"def";if(i=='"')return n.next(),t.tokenize=vt(i),t.tokenize(n,t);if(i=="-"){if(n.next(),n.eat("-"))return n.skipToEnd(),"comment";n.backUp(1)}if(n.match(w)||n.match(et)||n.match(ot)||n.match(st)||n.match(ht)||n.match(ft)||n.match(w))return"number";if(n.eatWhile(rt))return a=!0,"meta";for(f=0;f<l.length;f++)if((n.match(/\s+/+l[f],!0,!0)||n.match(l[f],!0,!0)&&a)&&(n.match(/\(/)||n.match(/\s+\(/)))return a=!1,"meta";return n.eatWhile(/[\w\$_]/)?(e=n.current().toLowerCase(),it[e])?(u[e]&&(r="newblock"),k[e]&&(r="newstatement"),o=e,"keyword"):"variable":(n.next(),null)}function vt(n){return function(t,i){for(var r=!1,u,f=!1;(u=t.next())!=null;){if(u==n&&!r){f=!0;break}r=!r&&u=="\\"}return!f&&(r||tt)||(i.tokenize=s),"string"}}function d(n,t,i,r,u){this.indented=n;this.column=t;this.type=i;this.align=r;this.prev=u}function e(n,t,i){var r=n.indented,u=new d(r,t,i,null,n.context);return n.context=u}function v(n){var t=n.context.type;return(t==")"||t=="]"||t=="}")&&(n.indented=n.context.indented),n.context=n.context.prev}function g(n,t){var i,r;if(n==t)return!0;i=t.split(";");for(r in i)if(n==i[r])return!0;return!1}function yt(){var i=[],n,t,r;for(n in u)if(u[n]){t=u[n].split(";");for(r in t)i.push(t[r])}return new RegExp("[{}()\\[\\]]|("+i.join("|")+")$")}var h=t.indentUnit,y=i.statementIndentUnit||h,nt=i.dontAlignCalls,p=i.noIndentKeywords||[],tt=i.multiLineStrings,it=c("access across after alias all and architecture array assert attribute begin block body break buffer bus case component configuration constant disconnect downto else elsif end entity exit file for function generate generic group guarded if impure in inertial inout is label library limit linkage literal loop map mod nand nature new next noise nor not null of on open or others out package port postponed procedural procedure process pure quantity range record reference register reject rem report return rol ror select severity shared signal sls sll spectrum sra srl subnature subtype terminal then through to tolerance transport type unaffected units until use variable wait when while with xnor xor"),l=["sign","ceil","floor","round","trunc","sqrt","cbrt","exp","log","log2","log10","realmax","realmin","mod","sin","cos","tan","arcsin","arccos","arctan","sinh","cosh","tanh","arcsinh","arccosh","arctanh","abs"],rt=/[\<\>\'\"\,\:\;\+\-\*\/!~&|^%=?:]/,ut=/[\[\]{}()]/,ft=/\d[0-9_]*/,et=/\d*\s*'s?d\s*\d[0-9_]*/i,ot=/\d*\s*'s?b\s*[xz01][xz01_]*/i,st=/\d*\s*'s?o\s*[xz0-7][xz0-7_]*/i,ht=/\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i,w=/(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i,ct=/^((\w+)|[)}\]])/,lt=/[)}\]]/,r,o,a=!1,at=c("entity"),u={},b,f,k;for(f in at)u[f]="end"+f;u.begin="end";u.casex="endcase";u.casez="endcase";u["do"]="while";u.fork="join;join_any;join_none";for(b in p)f=p[b],u[f]&&(u[f]=undefined);return k=c("always always_comb always_ff always_latch assert assign assume else for foreach forever if initial repeat while"),{electricInput:yt(),startState:function(n){return{tokenize:null,context:new d((n||0)-h,0,"top",!1),indented:0,startOfLine:!0}},token:function(n,t){var i=t.context,f,h;if(n.sol()&&(i.align==null&&(i.align=!1),t.indented=n.indentation(),t.startOfLine=!0),n.eatSpace())return null;if(r=null,o=null,f=(t.tokenize||s)(n,t),f=="comment"||f=="meta"||f=="variable")return f;if(i.align==null&&(i.align=!0),r==i.type)v(t);else if(r==";"&&i.type=="statement"||i.type&&g(o,i.type))for(i=v(t);i&&i.type=="statement";)i=v(t);else r=="{"?e(t,n.column(),"}"):r=="["?e(t,n.column(),"]"):r=="("?e(t,n.column(),")"):i&&i.type=="endcase"&&r==":"?e(t,n.column(),"statement"):r=="newstatement"?e(t,n.column(),"statement"):r=="newblock"&&(h=u[o],e(t,n.column(),h));return t.startOfLine=!1,f},indent:function(t,i){var r,f,u,e;return t.tokenize!=s&&t.tokenize!=null?n.Pass:(r=t.context,f=i&&i.charAt(0),r.type=="statement"&&f=="}"&&(r=r.prev),u=!1,e=i.match(ct),e&&(u=g(e[0],r.type)),r.type=="statement"?r.indented+(f=="{"?0:y):lt.test(r.type)&&r.align&&!nt?r.column+(u?0:1):r.type!=")"||u?r.indented+(u?0:h):r.indented+y)},blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:"//"}});n.defineMIME("text/x-vhdlams",{name:"vhdlams"});n.defineMIME("text/x-systemverilog",{name:"systemverilog"})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";n.defineMode("spice",function(t,i){function l(n){for(var i={},r=n.split(" "),t=0;t<r.length;++t)i[r[t]]=!0;return i}function h(n,t){var i=n.peek(),f,e;if(/[\.]/.test(i))return r=n.next(),null;if(st.test(i))return r=n.next(),"bracket";if(i=="`")return n.next(),n.eatWhile(/[\w\$_]/)?"def":null;if(i=="$")return n.next(),n.eatWhile(/[\w\$_]/)?"meta":null;if(i=="#")return n.next(),n.eatWhile(/[\d_.]/),"def";if(i=='"')return n.next(),t.tokenize=bt(i),t.tokenize(n,t);if(i=="*"&&n.sol()||i=="!")return n.next(),n.skipToEnd(),"comment";if(d!=n.string&&(d=n.string,et.test(i)))return s=i,n.next(),"keyword";for(f=0;f<b.length;f++)if(n.match(b[f]+"(",!0,!0))return n.backUp(1),"keyword";if(n.match(k)||n.match(ct)||n.match(lt)||n.match(at)||n.match(vt)||n.match(ht)||n.match(k))return"number";if(n.eatWhile(ot))return v=!0,"meta";for(f=0;f<a.length;f++)if((n.match(/\s+/+a[f],!0,!0)||n.match(a[f],!0,!0)&&v)&&(n.match(/\(/)||n.match(/\s+\(/)))return v=!1,"meta";return n.eatWhile(/[\w\$_]/)?(e=n.current().toLowerCase(),s&&(e=s.toLowerCase()+e,s=""),ft[e])?(u[e]&&(r="newblock"),nt[e]&&(r="newstatement"),o=e,"keyword"):"variable":(n.next(),null)}function bt(n){return function(t,i){for(var r=!1,u,f=!1;(u=t.next())!=null;){if(u==n&&!r){f=!0;break}r=!r&&u=="\\"}return!f&&(r||ut)||(i.tokenize=h),"string"}}function tt(n,t,i,r,u){this.indented=n;this.column=t;this.type=i;this.align=r;this.prev=u}function e(n,t,i){var r=n.indented,u=new tt(r,t,i,null,n.context);return n.context=u}function y(n){var t=n.context.type;return(t==")"||t=="]"||t=="}")&&(n.indented=n.context.indented),n.context=n.context.prev}function it(n,t){var i,r;if(n==t)return!0;i=t.split(";");for(r in i)if(n==i[r])return!0;return!1}function kt(){var i=[],n,t,r;for(n in u)if(u[n]){t=u[n].split(";");for(r in t)i.push(t[r])}return new RegExp("[{}()\\[\\]]|("+i.join("|")+")$")}var c=t.indentUnit,p=i.statementIndentUnit||c,rt=i.dontAlignCalls,w=i.noIndentKeywords||[],ut=i.multiLineStrings,ft=l("subckt model ends param lib func include r l c d nmos pmos npn pnp njf pjf value"),b=["R","L","C","D","NMOS","PMOS","NPN","PNP","LPNP","NJF","PJF","AND","OR","NAND","NOR","XOR","INV","DELAY"],et=/[rRlLcCdDkKpPtTyYwWuUqQjJmMxXeEiIgGhHvVfF]/,a=["SQRT","LOG","LOG10","DB","EXP","COS","SIN","TAN","ACOS","ASIN","ATAN","COSH","SINH","TANH","SGN","SIGN","PWR","POW","ABS","INT","TRUNC","ROUND","CEIL","FLOOR","MIN","DMIN","MAX","DMAX","DERIV","REAL","IMAG","MAGNITUDE","CONJ","COMPLEX","STOSMITH","YTOSMITH","ZTOSMITH","DDT","IDT","LIMIT","BITOF","PWL","TABLE"],ot=/[\<\>\'\"\,\:\;\+\-\*\/!~&|^%=?:]/,st=/[\[\]{}()]/,ht=/\d[0-9_]*/,ct=/\d*\s*'s?d\s*\d[0-9_]*/i,lt=/\d*\s*'s?b\s*[xz01][xz01_]*/i,at=/\d*\s*'s?o\s*[xz0-7][xz0-7_]*/i,vt=/\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i,k=/(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i,yt=/^((\w+)|[)}\]])/,pt=/[)}\]]/,r,o,d="",s="",v=!1,wt=l("entity"),u={},g,f,nt;for(f in wt)u[f]="end"+f;u.begin="end";u.casex="endcase";u.casez="endcase";u["do"]="while";u.fork="join;join_any;join_none";for(g in w)f=w[g],u[f]&&(u[f]=undefined);return nt=l("always always_comb always_ff always_latch assert assign assume else for foreach forever if initial repeat while"),{electricInput:kt(),startState:function(n){return{tokenize:null,context:new tt((n||0)-c,0,"top",!1),indented:0,startOfLine:!0}},token:function(n,t){var i=t.context,f,s;if(n.sol()&&(i.align==null&&(i.align=!1),t.indented=n.indentation(),t.startOfLine=!0),n.eatSpace())return null;if(r=null,o=null,f=(t.tokenize||h)(n,t),f=="comment"||f=="meta"||f=="variable")return f;if(i.align==null&&(i.align=!0),r==i.type)y(t);else if(r==";"&&i.type=="statement"||i.type&&it(o,i.type))for(i=y(t);i&&i.type=="statement";)i=y(t);else r=="{"?e(t,n.column(),"}"):r=="["?e(t,n.column(),"]"):r=="("?e(t,n.column(),")"):i&&i.type=="endcase"&&r==":"?e(t,n.column(),"statement"):r=="newstatement"?e(t,n.column(),"statement"):r=="newblock"&&(s=u[o],e(t,n.column(),s));return t.startOfLine=!1,f},indent:function(t,i){var r,f,u,e;return t.tokenize!=h&&t.tokenize!=null?n.Pass:(r=t.context,f=i&&i.charAt(0),r.type=="statement"&&f=="}"&&(r=r.prev),u=!1,e=i.match(yt),e&&(u=it(e[0],r.type)),r.type=="statement"?r.indented+(f=="{"?0:p):pt.test(r.type)&&r.align&&!rt?r.column+(u?0:1):r.type!=")"||u?r.indented+(u?0:c):r.indented+p)},blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:"//"}});n.defineMIME("text/x-spice",{name:"spice"})});!function(n,t){"use strict";function ho(n,t){for(var r,u=[],i=0;i<n.length;++i){if(r=ut[n[i]]||co(n[i]),!r)throw"module definition dependecy not found: "+n[i];u.push(r)}t.apply(null,u)}function i(n,i,r){if("string"!=typeof n)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(r===t)throw"invalid module definition, definition function must be specified";ho(i,function(){ut[n]=r.apply(null,arguments)})}function co(t){for(var i=n,u=t.split(/[.\/]/),r=0;r<u.length;++r){if(!i[u[r]])return;i=i[u[r]]}return i}function lo(i){for(var f,e,u,s,o,r=0;r<i.length;r++){for(f=n,e=i[r],u=e.split(/[.\/]/),o=0;o<u.length-1;++o)f[u[o]]===t&&(f[u[o]]={}),f=f[u[o]];f[u[u.length-1]]=ut[e]}if(n.AMDLC_TESTS){s=n.privateModules||{};for(e in ut)s[e]=ut[e];for(r=0;r<i.length;r++)delete s[i[r]];n.privateModules=s}}var ut={},vu="tinymce/geom/Rect",k="tinymce/util/Promise",f="tinymce/util/Delay",u="tinymce/Env",ft="tinymce/dom/EventUtils",ni="tinymce/dom/Sizzle",c="tinymce/util/Arr",r="tinymce/util/Tools",s="tinymce/dom/DomQuery",pi="tinymce/html/Styles",p="tinymce/dom/TreeWalker",yu="tinymce/dom/Range",d="tinymce/html/Entities",pu="tinymce/dom/StyleSheetLoader",h="tinymce/dom/DOMUtils",vt="tinymce/dom/ScriptLoader",ti="tinymce/AddOnManager",e="tinymce/dom/NodeType",ii="tinymce/text/Zwsp",w="tinymce/caret/CaretContainer",y="tinymce/dom/RangeUtils",wu="tinymce/NodeChange",et="tinymce/html/Node",g="tinymce/html/Schema",ri="tinymce/html/SaxParser",ui="tinymce/html/DomParser",wi="tinymce/html/Writer",yt="tinymce/html/Serializer",bi="tinymce/dom/Serializer",bu="tinymce/dom/TridentSelection",ot="tinymce/util/VK",ki="tinymce/dom/ControlSelection",a="tinymce/util/Fun",st="tinymce/caret/CaretCandidate",nt="tinymce/geom/ClientRect",ku="tinymce/text/ExtendingChar",v="tinymce/caret/CaretPosition",du="tinymce/caret/CaretBookmark",pt="tinymce/dom/BookmarkManager",di="tinymce/dom/Selection",gi="tinymce/dom/ElementUtils",gu="tinymce/fmt/Preview",nf="tinymce/fmt/Hooks",nr="tinymce/Formatter",tr="tinymce/UndoManager",tf="tinymce/EnterKey",rf="tinymce/ForceBlocks",wt="tinymce/caret/CaretUtils",ht="tinymce/caret/CaretWalker",uf="tinymce/InsertList",ff="tinymce/InsertContent",ir="tinymce/EditorCommands",fi="tinymce/util/URI",tt="tinymce/util/Class",ei="tinymce/util/EventDispatcher",ef="tinymce/data/Binding",ct="tinymce/util/Observable",of="tinymce/data/ObservableObject",oi="tinymce/ui/Selector",si="tinymce/ui/Collection",l="tinymce/ui/DomUtils",rr="tinymce/ui/BoxUtils",ur="tinymce/ui/ClassList",hi="tinymce/ui/ReflowQueue",b="tinymce/ui/Control",lt="tinymce/ui/Factory",fr="tinymce/ui/KeyboardNavigation",it="tinymce/ui/Container",rt="tinymce/ui/DragHelper",er="tinymce/ui/Scrollable",bt="tinymce/ui/Panel",kt="tinymce/ui/Movable",or="tinymce/ui/Resizable",at="tinymce/ui/FloatPanel",ci="tinymce/ui/Window",sr="tinymce/ui/MessageBox",hr="tinymce/WindowManager",cr="tinymce/ui/Tooltip",o="tinymce/ui/Widget",lr="tinymce/ui/Progress",ar="tinymce/ui/Notification",vr="tinymce/NotificationManager",sf="tinymce/dom/NodePath",hf="tinymce/util/Quirks",yr="tinymce/EditorObservable",cf="tinymce/Mode",pr="tinymce/Shortcuts",lf="tinymce/file/Uploader",af="tinymce/file/Conversions",vf="tinymce/file/ImageScanner",yf="tinymce/file/BlobCache",pf="tinymce/file/UploadStatus",wf="tinymce/EditorUpload",bf="tinymce/caret/FakeCaret",wr="tinymce/dom/Dimensions",kf="tinymce/caret/LineWalker",df="tinymce/caret/LineUtils",gf="tinymce/DragDropOverrides",ne="tinymce/SelectionOverrides",te="tinymce/util/Uuid",br="tinymce/Editor",kr="tinymce/util/I18n",dr="tinymce/FocusManager",dt="tinymce/EditorManager",gr="tinymce/util/XHR",nu="tinymce/util/JSON",ie="tinymce/util/JSONRequest",re="tinymce/util/JSONP",ue="tinymce/util/LocalStorage",fe="tinymce/Compat",li="tinymce/ui/Layout",gt="tinymce/ui/AbsoluteLayout",ai="tinymce/ui/Button",ee="tinymce/ui/ButtonGroup",tu="tinymce/ui/Checkbox",vi="tinymce/ui/ComboBox",oe="tinymce/ui/ColorBox",iu="tinymce/ui/PanelButton",se="tinymce/ui/ColorButton",ru="tinymce/util/Color",he="tinymce/ui/ColorPicker",uu="tinymce/ui/Path",ce="tinymce/ui/ElementPath",fu="tinymce/ui/FormItem",eu="tinymce/ui/Form",le="tinymce/ui/FieldSet",ae="tinymce/ui/FilePicker",ve="tinymce/ui/FitLayout",ye="tinymce/ui/FlexLayout",ou="tinymce/ui/FlowLayout",pe="tinymce/ui/FormatControls",we="tinymce/ui/GridLayout",be="tinymce/ui/Iframe",ke="tinymce/ui/InfoBox",de="tinymce/ui/Label",su="tinymce/ui/Toolbar",hu="tinymce/ui/MenuBar",yi="tinymce/ui/MenuButton",cu="tinymce/ui/MenuItem",lu="tinymce/ui/Throbber",au="tinymce/ui/Menu",ge="tinymce/ui/ListBox",no="tinymce/ui/Radio",to="tinymce/ui/ResizeHandle",io="tinymce/ui/SelectBox",ro="tinymce/ui/Slider",uo="tinymce/ui/Spacer",fo="tinymce/ui/SplitButton",eo="tinymce/ui/StackLayout",oo="tinymce/ui/TabPanel",so="tinymce/ui/TextBox";i(vu,[],function(){function r(t,r,u){var f,e,o,s,h,c;return f=r.x,e=r.y,o=t.w,s=t.h,h=r.w,c=r.h,u=(u||"").split(""),"b"===u[0]&&(e+=c),"r"===u[1]&&(f+=h),"c"===u[0]&&(e+=i(c/2)),"c"===u[1]&&(f+=i(h/2)),"b"===u[3]&&(e-=s),"r"===u[4]&&(f-=o),"c"===u[3]&&(e-=i(s/2)),"c"===u[4]&&(f-=i(o/2)),n(f,e,o,s)}function f(n,t,i,u){for(var f,e=0;e<u.length;e++)if(f=r(n,t,u[e]),f.x>=i.x&&f.x+f.w<=i.w+i.x&&f.y>=i.y&&f.y+f.h<=i.h+i.y)return u[e];return null}function e(t,i,r){return n(t.x-i,t.y-r,t.w+2*i,t.h+2*r)}function o(i,r){var f,e,o,s;return f=t(i.x,r.x),e=t(i.y,r.y),o=u(i.x+i.w,r.x+r.w),s=u(i.y+i.h,r.y+r.h),0>o-f||0>s-e?null:n(f,e,o-f,s-e)}function s(i,r,u){var h,c,l,a,f,e,o,s,v,y;return f=i.x,e=i.y,o=i.x+i.w,s=i.y+i.h,v=r.x+r.w,y=r.y+r.h,h=t(0,r.x-f),c=t(0,r.y-e),l=t(0,o-v),a=t(0,s-y),f+=h,e+=c,u&&(o+=h,s+=c,f-=l,e-=a),o-=l,s-=a,n(f,e,o-f,s-e)}function n(n,t,i,r){return{x:n,y:t,w:i,h:r}}function h(t){return n(t.left,t.top,t.width,t.height)}var u=Math.min,t=Math.max,i=Math.round;return{inflate:e,relativePosition:r,findBestRelativePosition:f,intersect:o,clamp:s,create:n,fromClientRect:h}});i(k,[],function(){function t(n,t){return function(){n.apply(t,arguments)}}function n(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null;this._value=null;this._deferreds=[];e(n,t(u,this),t(i,this))}function r(n){var t=this;return null===this._state?void this._deferreds.push(n):void s(function(){var i=t._state?n.onFulfilled:n.onRejected,r;if(null===i)return void(t._state?n.resolve:n.reject)(t._value);try{r=i(t._value)}catch(u){return void n.reject(u)}n.resolve(r)})}function u(n){try{if(n===this)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var r=n.then;if("function"==typeof r)return void e(t(r,n),t(u,this),t(i,this))}this._state=!0;this._value=n;f.call(this)}catch(o){i.call(this,o)}}function i(n){this._state=!1;this._value=n;f.call(this)}function f(){for(var n=0,t=this._deferreds.length;t>n;n++)r.call(this,this._deferreds[n]);this._deferreds=null}function o(n,t,i,r){this.onFulfilled="function"==typeof n?n:null;this.onRejected="function"==typeof t?t:null;this.resolve=i;this.reject=r}function e(n,t,i){var r=!1;try{n(function(n){r||(r=!0,t(n))},function(n){r||(r=!0,i(n))})}catch(u){if(r)return;r=!0;i(u)}}if(window.Promise)return window.Promise;var s=n.immediateFn||"function"==typeof setImmediate&&setImmediate||function(n){setTimeout(n,1)},h=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};return n.prototype["catch"]=function(n){return this.then(null,n)},n.prototype.then=function(t,i){var u=this;return new n(function(n,f){r.call(u,new o(t,i,n,f))})},n.all=function(){var t=Array.prototype.slice.call(1===arguments.length&&h(arguments[0])?arguments[0]:arguments);return new n(function(n,i){function u(r,e){try{if(e&&("object"==typeof e||"function"==typeof e)){var o=e.then;if("function"==typeof o)return void o.call(e,function(n){u(r,n)},i)}t[r]=e;0==--f&&n(t)}catch(s){i(s)}}if(0===t.length)return n([]);for(var f=t.length,r=0;r<t.length;r++)u(r,t[r])})},n.resolve=function(t){return t&&"object"==typeof t&&t.constructor===n?t:new n(function(n){n(t)})},n.reject=function(t){return new n(function(n,i){i(t)})},n.race=function(t){return new n(function(n,i){for(var r=0,u=t.length;u>r;r++)t[r].then(n,i)})},n});i(f,[k],function(n){function u(n,t){function f(n){window.setTimeout(n,0)}for(var i=window.requestAnimationFrame,u=["ms","moz","webkit"],r=0;r<u.length&&!i;r++)i=window[u[r]+"RequestAnimationFrame"];i||(i=f);i(n,t)}function t(n,t){return"number"!=typeof t&&(t=0),setTimeout(n,t)}function r(n,t){return"number"!=typeof t&&(t=0),setInterval(n,t)}function f(n){return clearTimeout(n)}function e(n){return clearInterval(n)}var i;return{requestAnimationFrame:function(t,r){return i?void i.then(t):void(i=new n(function(n){r||(r=document.body);u(n,r)}).then(t))},setTimeout:t,setInterval:r,setEditorTimeout:function(n,i,r){return t(function(){n.removed||i()},r)},setEditorInterval:function(n,t,i){var u;return u=r(function(){n.removed?clearInterval(u):t()},i)},throttle:function(n,i){var r,u;return u=function(){var u=arguments;clearTimeout(r);r=t(function(){n.apply(this,u)},i)},u.stop=function(){clearTimeout(r)},u},clearInterval:e,clearTimeout:f}});i(u,[],function(){function c(n){return"matchMedia"in window?matchMedia(n).matches:!1}var o=navigator,n=o.userAgent,s,i,t,u,f,l,a,r,e,h,v,y,p,w;return s=window.opera&&window.opera.buildNumber,e=/Android/.test(n),i=/WebKit/.test(n),t=!i&&!s&&/MSIE/gi.test(n)&&/Explorer/gi.test(o.appName),t=t&&/MSIE (\w+)\./.exec(n)[1],u=-1==n.indexOf("Trident/")||-1==n.indexOf("rv:")&&-1==o.appName.indexOf("Netscape")?!1:11,f=-1==n.indexOf("Edge/")||t||u?!1:12,t=t||u||f,l=!i&&!u&&/Gecko/.test(n),a=-1!=n.indexOf("Mac"),r=/(iPad|iPhone)/.test(n),h="FormData"in window&&"FileReader"in window&&"URL"in window&&!!URL.createObjectURL,v=c("only screen and (max-device-width: 480px)")&&(e||r),y=c("only screen and (min-width: 800px)")&&(e||r),p=-1!=n.indexOf("Windows Phone"),f&&(i=!1),w=!r||h||n.match(/AppleWebKit\/(\d*)/)[1]>=534,{opera:s,webkit:i,ie:t,gecko:l,mac:a,iOS:r,android:e,contentEditable:w,transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",caretAfter:8!=t,range:window.getSelection&&"Range"in window,documentMode:t&&!f?document.documentMode||7:10,fileApi:h,ceFalse:t===!1||t>8,desktop:!v&&!y,windowsPhone:p}});i(ft,[f,u],function(n,t){function r(n,t,i,r){n.addEventListener?n.addEventListener(t,i,r||!1):n.attachEvent&&n.attachEvent("on"+t,i)}function f(n,t,i,r){n.removeEventListener?n.removeEventListener(t,i,r||!1):n.detachEvent&&n.detachEvent("on"+t,i)}function e(n,t){var i,r=t;return i=n.path,i&&i.length>0&&(r=i[0]),n.deepPath&&(i=n.deepPath(),i&&i.length>0&&(r=i[0])),r}function i(n,i){function s(){return!1}function l(){return!0}var o,r=i||{},a;for(o in n)c[o]||(r[o]=n[o]);if(r.target||(r.target=r.srcElement||document),t.experimentalShadowDom&&(r.target=e(n,r.target)),n&&h.test(n.type)&&n.pageX===a&&n.clientX!==a){var v=r.target.ownerDocument||document,u=v.documentElement,f=v.body;r.pageX=n.clientX+(u&&u.scrollLeft||f&&f.scrollLeft||0)-(u&&u.clientLeft||f&&f.clientLeft||0);r.pageY=n.clientY+(u&&u.scrollTop||f&&f.scrollTop||0)-(u&&u.clientTop||f&&f.clientTop||0)}return r.preventDefault=function(){r.isDefaultPrevented=l;n&&(n.preventDefault?n.preventDefault():n.returnValue=!1)},r.stopPropagation=function(){r.isPropagationStopped=l;n&&(n.stopPropagation?n.stopPropagation():n.cancelBubble=!0)},r.stopImmediatePropagation=function(){r.isImmediatePropagationStopped=l;r.stopPropagation()},r.isDefaultPrevented||(r.isDefaultPrevented=s,r.isPropagationStopped=s,r.isImmediatePropagationStopped=s),"undefined"==typeof r.metaKey&&(r.metaKey=!1),r}function o(t,i,u){function o(){u.domLoaded||(u.domLoaded=!0,i(c))}function s(){("complete"===e.readyState||"interactive"===e.readyState&&e.body)&&(f(e,"readystatechange",s),o())}function h(){try{e.documentElement.doScroll("left")}catch(t){return void n.setTimeout(h)}o()}var e=t.document,c={type:"ready"};return u.domLoaded?void i(c):(e.addEventListener?"complete"===e.readyState?o():r(t,"DOMContentLoaded",o):(r(e,"readystatechange",s),e.documentElement.doScroll&&t.self===t.top&&h()),void r(t,"load",o))}function u(){function e(n,t){var f,i,e,r,o=u[t];if(f=o&&o[n.type])for(i=0,e=f.length;e>i;i++)if(r=f[i],r&&r.func.call(r.scope,n)===!1&&n.preventDefault(),n.isImmediatePropagationStopped())return}var n=this,u={},h,t,c,l,a;t=s+(+new Date).toString(32);l="onmouseenter"in document.documentElement;c="onfocusin"in document.documentElement;a={mouseenter:"mouseover",mouseleave:"mouseout"};h=1;n.domLoaded=!1;n.events=u;n.bind=function(f,s,v,y){function it(n){e(i(n||tt.event),w)}var w,b,nt,p,k,d,g,tt=window;if(f&&3!==f.nodeType&&8!==f.nodeType){for(f[t]?w=f[t]:(w=h++,f[t]=w,u[w]={}),y=y||f,s=s.split(" "),nt=s.length;nt--;)p=s[nt],d=it,k=g=!1,"DOMContentLoaded"===p&&(p="ready"),n.domLoaded&&"ready"===p&&"complete"==f.readyState?v.call(y,i({type:p})):(l||(k=a[p],k&&(d=function(n){var r,t;if(r=n.currentTarget,t=n.relatedTarget,t&&r.contains)t=r.contains(t);else for(;t&&t!==r;)t=t.parentNode;t||(n=i(n||tt.event),n.type="mouseout"===n.type?"mouseleave":"mouseenter",n.target=r,e(n,w))})),c||"focusin"!==p&&"focusout"!==p||(g=!0,k="focusin"===p?"focus":"blur",d=function(n){n=i(n||tt.event);n.type="focus"===n.type?"focusin":"focusout";e(n,w)}),b=u[w][p],b?"ready"===p&&n.domLoaded?v({type:p}):b.push({func:v,scope:y}):(u[w][p]=b=[{func:v,scope:y}],b.fakeName=k,b.capture=g,b.nativeHandler=d,"ready"===p?o(f,d,n):r(f,k||p,d,g)));return f=b=0,v}};n.unbind=function(i,r,e){var l,o,a,c,s,h;if(!i||3===i.nodeType||8===i.nodeType)return n;if(l=i[t]){if(h=u[l],r){for(r=r.split(" "),a=r.length;a--;)if(s=r[a],o=h[s]){if(e)for(c=o.length;c--;)if(o[c].func===e){var v=o.nativeHandler,y=o.fakeName,p=o.capture;o=o.slice(0,c).concat(o.slice(c+1));o.nativeHandler=v;o.fakeName=y;o.capture=p;h[s]=o}e&&0!==o.length||(delete h[s],f(i,o.fakeName||s,o.nativeHandler,o.capture))}}else{for(s in h)o=h[s],f(i,o.fakeName||s,o.nativeHandler,o.capture);h={}}for(s in h)return n;delete u[l];try{delete i[t]}catch(w){i[t]=null}}return n};n.fire=function(r,u,f){var o;if(!r||3===r.nodeType||8===r.nodeType)return n;f=i(null,f);f.type=u;f.target=r;do o=r[t],o&&e(f,o),r=r.parentNode||r.ownerDocument||r.defaultView||r.parentWindow;while(r&&!f.isPropagationStopped());return n};n.clean=function(i){var r,u,f=n.unbind;if(!i||3===i.nodeType||8===i.nodeType)return n;if(i[t]&&f(i),i.getElementsByTagName||(i=i.document),i&&i.getElementsByTagName)for(f(i),u=i.getElementsByTagName("*"),r=u.length;r--;)i=u[r],i[t]&&f(i);return n};n.destroy=function(){u={}};n.cancel=function(n){return n&&(n.preventDefault(),n.stopImmediatePropagation()),!1}}var s="mce-data-",h=/^(?:mouse|contextmenu)|click/,c={keyLocation:1,layerX:1,layerY:1,returnValue:1,webkitMovementX:1,webkitMovementY:1,keyIdentifier:1};return u.Event=new u,u.Event.bind(window,"ready",function(){}),u});i(ni,[],function(){function r(n,t,i,r){var p,s,c,v,w,y,k,l,nt,g;if((t?t.ownerDocument||t:h)!==e&&b(t),t=t||e,i=i||[],!n||"string"!=typeof n)return i;if(1!==(v=t.nodeType)&&9!==v)return[];if(a&&!r){if(p=lr.exec(n))if(c=p[1]){if(9===v){if(s=t.getElementById(c),!s||!s.parentNode)return i;if(s.id===c)return i.push(s),i}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(c))&&et(t,s)&&s.id===c)return i.push(s),i}else{if(p[2])return d.apply(i,t.getElementsByTagName(n)),i;if((c=p[3])&&u.getElementsByClassName)return d.apply(i,t.getElementsByClassName(c)),i}if(u.qsa&&(!o||!o.test(n))){if(l=k=f,nt=t,g=9===v&&n,1===v&&"object"!==t.nodeName.toLowerCase()){for(y=ft(n),(k=t.getAttribute("id"))?l=k.replace(ar,"\\$&"):t.setAttribute("id",l),l="[id='"+l+"'] ",w=y.length;w--;)y[w]=l+ht(y[w]);nt=ei.test(n)&&kt(t.parentNode)||t;g=y.join(",")}if(g)try{return d.apply(i,nt.querySelectorAll(g)),i}catch(tt){}finally{k||t.removeAttribute("id")}}}return ci(n.replace(yt,"$1"),t,i,r)}function wt(){function t(r,u){return i.push(r+" ")>n.cacheLength&&delete t[i.shift()],t[r+" "]=u}var i=[];return t}function s(n){return n[f]=!0,n}function c(n){var t=e.createElement("div");try{return!!n(t)}catch(i){return!1}finally{t.parentNode&&t.parentNode.removeChild(t);t=null}}function bt(t,i){for(var u=t.split("|"),r=t.length;r--;)n.attrHandle[u[r]]=i}function oi(n,t){var i=t&&n,r=i&&1===n.nodeType&&1===t.nodeType&&(~t.sourceIndex||yi)-(~n.sourceIndex||yi);if(r)return r;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return n?1:-1}function bi(n){return function(t){var i=t.nodeName.toLowerCase();return"input"===i&&t.type===n}}function ki(n){return function(t){var i=t.nodeName.toLowerCase();return("input"===i||"button"===i)&&t.type===n}}function g(n){return s(function(t){return t=+t,s(function(i,r){for(var u,f=n([],i.length,t),e=f.length;e--;)i[u=f[e]]&&(i[u]=!(r[u]=i[u]))})})}function kt(n){return n&&typeof n.getElementsByTagName!==ot&&n}function si(){}function ht(n){for(var t=0,r=n.length,i="";r>t;t++)i+=n[t].value;return i}function dt(n,t,i){var r=t.dir,u=i&&"parentNode"===r,e=nr++;return t.first?function(t,i,f){for(;t=t[r];)if(1===t.nodeType||u)return n(t,i,f)}:function(t,i,o){var s,h,c=[v,e];if(o){for(;t=t[r];)if((1===t.nodeType||u)&&n(t,i,o))return!0}else for(;t=t[r];)if(1===t.nodeType||u){if(h=t[f]||(t[f]={}),(s=h[r])&&s[0]===v&&s[1]===e)return c[2]=s[2];if(h[r]=c,c[2]=n(t,i,o))return!0}}}function gt(n){return n.length>1?function(t,i,r){for(var u=n.length;u--;)if(!n[u](t,i,r))return!1;return!0}:n[0]}function di(n,t,i){for(var u=0,f=t.length;f>u;u++)r(n,t[u],i);return i}function ct(n,t,i,r,u){for(var e,o=[],f=0,s=n.length,h=null!=t;s>f;f++)(e=n[f])&&(i&&!i(e,r,u)||(o.push(e),h&&t.push(f)));return o}function ni(n,t,i,r,u,e){return r&&!r[f]&&(r=ni(r)),u&&!u[f]&&(u=ni(u,e)),s(function(f,e,o,s){var l,c,a,p=[],y=[],w=e.length,b=f||di(t||"*",o.nodeType?[o]:o,[]),v=!n||!f&&t?b:ct(b,p,n,o,s),h=i?u||(f?n:w||r)?[]:e:v;if(i&&i(v,h,o,s),r)for(l=ct(h,y),r(l,[],o,s),c=l.length;c--;)(a=l[c])&&(h[y[c]]=!(v[y[c]]=a));if(f){if(u||n){if(u){for(l=[],c=h.length;c--;)(a=h[c])&&l.push(v[c]=a);u(null,h=[],l,s)}for(c=h.length;c--;)(a=h[c])&&(l=u?tt.call(f,a):p[c])>-1&&(f[l]=!(e[l]=a))}}else h=ct(h===e?h.splice(w,h.length):h),u?u(null,e,h,s):d.apply(e,h)})}function ti(t){for(var s,u,r,o=t.length,h=n.relative[t[0].type],c=h||n.relative[" "],i=h?1:0,l=dt(function(n){return n===s},c,!0),a=dt(function(n){return tt.call(s,n)>-1},c,!0),e=[function(n,t,i){return!h&&(i||t!==at)||((s=t).nodeType?l(n,t,i):a(n,t,i))}];o>i;i++)if(u=n.relative[t[i].type])e=[dt(gt(e),u)];else{if(u=n.filter[t[i].type].apply(null,t[i].matches),u[f]){for(r=++i;o>r&&!n.relative[t[r].type];r++);return ni(i>1&&gt(e),i>1&&ht(t.slice(0,i-1).concat({value:" "===t[i-2].type?"*":""})).replace(yt,"$1"),u,r>i&&ti(t.slice(i,r)),o>r&&ti(t=t.slice(r)),o>r&&ht(t))}e.push(u)}return gt(e)}function gi(t,i){var u=i.length>0,f=t.length>0,o=function(o,s,h,c,l){var y,k,w,b=0,a="0",g=o&&[],p=[],nt=at,tt=o||f&&n.find.TAG("*",l),it=v+=null==nt?1:Math.random()||.1,rt=tt.length;for(l&&(at=s!==e&&s);a!==rt&&null!=(y=tt[a]);a++){if(f&&y){for(k=0;w=t[k++];)if(w(y,s,h)){c.push(y);break}l&&(v=it)}u&&((y=!w&&y)&&b--,o&&g.push(y))}if(b+=a,u&&a!==b){for(k=0;w=i[k++];)w(g,p,s,h);if(o){if(b>0)for(;a--;)g[a]||p[a]||(p[a]=ir.call(c));p=ct(p)}d.apply(c,p);l&&!o&&p.length>0&&b+i.length>1&&r.uniqueSort(c)}return l&&(v=it,at=nt),g};return u?s(o):o}var rt,u,n,lt,hi,ft,ii,ci,at,w,ut,b,e,l,a,o,nt,vt,et,f="sizzle"+-new Date,h=window.document,v=0,nr=0,li=wt(),ai=wt(),vi=wt(),ri=function(n,t){return n===t&&(ut=!0),0},ot=typeof t,yi=-2147483648,tr={}.hasOwnProperty,k=[],ir=k.pop,rr=k.push,d=k.push,pi=k.slice,tt=k.indexOf||function(n){for(var t=0,i=this.length;i>t;t++)if(this[t]===n)return t;return-1},ui="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",i="[\\x20\\t\\r\\n\\f]",it="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",wi="\\["+i+"*("+it+")(?:"+i+"*([*^$|!~]?=)"+i+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+it+"))|)"+i+"*\\]",fi=":("+it+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+wi+")*)|.*)\\)|)",yt=new RegExp("^"+i+"+|((?:^|[^\\\\])(?:\\\\.)*)"+i+"+$","g"),ur=new RegExp("^"+i+"*,"+i+"*"),fr=new RegExp("^"+i+"*([>+~]|"+i+")"+i+"*"),er=new RegExp("="+i+"*([^\\]'\"]*?)"+i+"*\\]","g"),or=new RegExp(fi),sr=new RegExp("^"+it+"$"),pt={ID:new RegExp("^#("+it+")"),CLASS:new RegExp("^\\.("+it+")"),TAG:new RegExp("^("+it+"|[*])"),ATTR:new RegExp("^"+wi),PSEUDO:new RegExp("^"+fi),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+i+"*(even|odd|(([+-]|)(\\d*)n|)"+i+"*(?:([+-]|)"+i+"*(\\d+)|))"+i+"*\\)|)","i"),bool:new RegExp("^(?:"+ui+")$","i"),needsContext:new RegExp("^"+i+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+i+"*((?:-\\d)?\\d*)"+i+"*\\)|)(?=[^-]|$)","i")},hr=/^(?:input|select|textarea|button)$/i,cr=/^h\d$/i,st=/^[^{]+\{\s*\[native \w/,lr=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ei=/[+~]/,ar=/'|\\/g,y=new RegExp("\\\\([\\da-f]{1,6}"+i+"?|("+i+")|.)","ig"),p=function(n,t,i){var r="0x"+t-65536;return r!==r||i?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)};try{d.apply(k=pi.call(h.childNodes),h.childNodes);k[h.childNodes.length].nodeType}catch(vr){d={apply:k.length?function(n,t){rr.apply(n,pi.call(t))}:function(n,t){for(var i=n.length,r=0;n[i++]=t[r++];);n.length=i-1}}}u=r.support={};hi=r.isXML=function(n){var t=n&&(n.ownerDocument||n).documentElement;return t?"HTML"!==t.nodeName:!1};b=r.setDocument=function(t){function k(n){try{return n.top}catch(t){}return null}var v,r=t?t.ownerDocument||t:h,s=r.defaultView;return r!==e&&9===r.nodeType&&r.documentElement?(e=r,l=r.documentElement,a=!hi(r),s&&s!==k(s)&&(s.addEventListener?s.addEventListener("unload",function(){b()},!1):s.attachEvent&&s.attachEvent("onunload",function(){b()})),u.attributes=c(function(n){return n.className="i",!n.getAttribute("className")}),u.getElementsByTagName=c(function(n){return n.appendChild(r.createComment("")),!n.getElementsByTagName("*").length}),u.getElementsByClassName=st.test(r.getElementsByClassName),u.getById=c(function(n){return l.appendChild(n).id=f,!r.getElementsByName||!r.getElementsByName(f).length}),u.getById?(n.find.ID=function(n,t){if(typeof t.getElementById!==ot&&a){var i=t.getElementById(n);return i&&i.parentNode?[i]:[]}},n.filter.ID=function(n){var t=n.replace(y,p);return function(n){return n.getAttribute("id")===t}}):(delete n.find.ID,n.filter.ID=function(n){var t=n.replace(y,p);return function(n){var i=typeof n.getAttributeNode!==ot&&n.getAttributeNode("id");return i&&i.value===t}}),n.find.TAG=u.getElementsByTagName?function(n,t){if(typeof t.getElementsByTagName!==ot)return t.getElementsByTagName(n)}:function(n,t){var i,r=[],f=0,u=t.getElementsByTagName(n);if("*"===n){for(;i=u[f++];)1===i.nodeType&&r.push(i);return r}return u},n.find.CLASS=u.getElementsByClassName&&function(n,t){if(a)return t.getElementsByClassName(n)},nt=[],o=[],(u.qsa=st.test(r.querySelectorAll))&&(c(function(n){n.innerHTML="<select msallowcapture=''><option selected=''><\/option><\/select>";n.querySelectorAll("[msallowcapture^='']").length&&o.push("[*^$]="+i+"*(?:''|\"\")");n.querySelectorAll("[selected]").length||o.push("\\["+i+"*(?:value|"+ui+")");n.querySelectorAll(":checked").length||o.push(":checked")}),c(function(n){var t=r.createElement("input");t.setAttribute("type","hidden");n.appendChild(t).setAttribute("name","D");n.querySelectorAll("[name=d]").length&&o.push("name"+i+"*[*^$|!~]?=");n.querySelectorAll(":enabled").length||o.push(":enabled",":disabled");n.querySelectorAll("*,:x");o.push(",.*:")})),(u.matchesSelector=st.test(vt=l.matches||l.webkitMatchesSelector||l.mozMatchesSelector||l.oMatchesSelector||l.msMatchesSelector))&&c(function(n){u.disconnectedMatch=vt.call(n,"div");vt.call(n,"[s!='']:x");nt.push("!=",fi)}),o=o.length&&new RegExp(o.join("|")),nt=nt.length&&new RegExp(nt.join("|")),v=st.test(l.compareDocumentPosition),et=v||st.test(l.contains)?function(n,t){var r=9===n.nodeType?n.documentElement:n,i=t&&t.parentNode;return n===i||!(!i||1!==i.nodeType||!(r.contains?r.contains(i):n.compareDocumentPosition&&16&n.compareDocumentPosition(i)))}:function(n,t){if(t)for(;t=t.parentNode;)if(t===n)return!0;return!1},ri=v?function(n,t){if(n===t)return ut=!0,0;var i=!n.compareDocumentPosition-!t.compareDocumentPosition;return i?i:(i=(n.ownerDocument||n)===(t.ownerDocument||t)?n.compareDocumentPosition(t):1,1&i||!u.sortDetached&&t.compareDocumentPosition(n)===i?n===r||n.ownerDocument===h&&et(h,n)?-1:t===r||t.ownerDocument===h&&et(h,t)?1:w?tt.call(w,n)-tt.call(w,t):0:4&i?-1:1)}:function(n,t){if(n===t)return ut=!0,0;var i,u=0,o=n.parentNode,s=t.parentNode,f=[n],e=[t];if(!o||!s)return n===r?-1:t===r?1:o?-1:s?1:w?tt.call(w,n)-tt.call(w,t):0;if(o===s)return oi(n,t);for(i=n;i=i.parentNode;)f.unshift(i);for(i=t;i=i.parentNode;)e.unshift(i);for(;f[u]===e[u];)u++;return u?oi(f[u],e[u]):f[u]===h?-1:e[u]===h?1:0},r):e};r.matches=function(n,t){return r(n,null,null,t)};r.matchesSelector=function(n,t){if((n.ownerDocument||n)!==e&&b(n),t=t.replace(er,"='$1']"),u.matchesSelector&&a&&(!nt||!nt.test(t))&&(!o||!o.test(t)))try{var i=vt.call(n,t);if(i||u.disconnectedMatch||n.document&&11!==n.document.nodeType)return i}catch(f){}return r(t,e,null,[n]).length>0};r.contains=function(n,t){return(n.ownerDocument||n)!==e&&b(n),et(n,t)};r.attr=function(i,r){(i.ownerDocument||i)!==e&&b(i);var o=n.attrHandle[r.toLowerCase()],f=o&&tr.call(n.attrHandle,r.toLowerCase())?o(i,r,!a):t;return f!==t?f:u.attributes||!a?i.getAttribute(r):(f=i.getAttributeNode(r))&&f.specified?f.value:null};r.error=function(n){throw new Error("Syntax error, unrecognized expression: "+n);};r.uniqueSort=function(n){var r,f=[],t=0,i=0;if(ut=!u.detectDuplicates,w=!u.sortStable&&n.slice(0),n.sort(ri),ut){for(;r=n[i++];)r===n[i]&&(t=f.push(i));for(;t--;)n.splice(f[t],1)}return w=null,n};lt=r.getText=function(n){var r,i="",u=0,t=n.nodeType;if(t){if(1===t||9===t||11===t){if("string"==typeof n.textContent)return n.textContent;for(n=n.firstChild;n;n=n.nextSibling)i+=lt(n)}else if(3===t||4===t)return n.nodeValue}else for(;r=n[u++];)i+=lt(r);return i};n=r.selectors={cacheLength:50,createPseudo:s,match:pt,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(n){return n[1]=n[1].replace(y,p),n[3]=(n[3]||n[4]||n[5]||"").replace(y,p),"~="===n[2]&&(n[3]=" "+n[3]+" "),n.slice(0,4)},CHILD:function(n){return n[1]=n[1].toLowerCase(),"nth"===n[1].slice(0,3)?(n[3]||r.error(n[0]),n[4]=+(n[4]?n[5]+(n[6]||1):2*("even"===n[3]||"odd"===n[3])),n[5]=+(n[7]+n[8]||"odd"===n[3])):n[3]&&r.error(n[0]),n},PSEUDO:function(n){var i,t=!n[6]&&n[2];return pt.CHILD.test(n[0])?null:(n[3]?n[2]=n[4]||n[5]||"":t&&or.test(t)&&(i=ft(t,!0))&&(i=t.indexOf(")",t.length-i)-t.length)&&(n[0]=n[0].slice(0,i),n[2]=t.slice(0,i)),n.slice(0,3))}},filter:{TAG:function(n){var t=n.replace(y,p).toLowerCase();return"*"===n?function(){return!0}:function(n){return n.nodeName&&n.nodeName.toLowerCase()===t}},CLASS:function(n){var t=li[n+" "];return t||(t=new RegExp("(^|"+i+")"+n+"("+i+"|$)"))&&li(n,function(n){return t.test("string"==typeof n.className&&n.className||typeof n.getAttribute!==ot&&n.getAttribute("class")||"")})},ATTR:function(n,t,i){return function(u){var f=r.attr(u,n);return null==f?"!="===t:t?(f+="","="===t?f===i:"!="===t?f!==i:"^="===t?i&&0===f.indexOf(i):"*="===t?i&&f.indexOf(i)>-1:"$="===t?i&&f.slice(-i.length)===i:"~="===t?(" "+f+" ").indexOf(i)>-1:"|="===t?f===i||f.slice(0,i.length+1)===i+"-":!1):!0}},CHILD:function(n,t,i,r,u){var s="nth"!==n.slice(0,3),o="last"!==n.slice(-4),e="of-type"===t;return 1===r&&0===u?function(n){return!!n.parentNode}:function(t,i,h){var a,k,c,l,y,w,b=s!==o?"nextSibling":"previousSibling",p=t.parentNode,g=e&&t.nodeName.toLowerCase(),d=!h&&!e;if(p){if(s){for(;b;){for(c=t;c=c[b];)if(e?c.nodeName.toLowerCase()===g:1===c.nodeType)return!1;w=b="only"===n&&!w&&"nextSibling"}return!0}if(w=[o?p.firstChild:p.lastChild],o&&d){for(k=p[f]||(p[f]={}),a=k[n]||[],y=a[0]===v&&a[1],l=a[0]===v&&a[2],c=y&&p.childNodes[y];c=++y&&c&&c[b]||(l=y=0)||w.pop();)if(1===c.nodeType&&++l&&c===t){k[n]=[v,y,l];break}}else if(d&&(a=(t[f]||(t[f]={}))[n])&&a[0]===v)l=a[1];else for(;(c=++y&&c&&c[b]||(l=y=0)||w.pop())&&((e?c.nodeName.toLowerCase()!==g:1!==c.nodeType)||!++l||(d&&((c[f]||(c[f]={}))[n]=[v,l]),c!==t)););return l-=u,l===r||l%r==0&&l/r>=0}}},PSEUDO:function(t,i){var e,u=n.pseudos[t]||n.setFilters[t.toLowerCase()]||r.error("unsupported pseudo: "+t);return u[f]?u(i):u.length>1?(e=[t,t,"",i],n.setFilters.hasOwnProperty(t.toLowerCase())?s(function(n,t){for(var r,f=u(n,i),e=f.length;e--;)r=tt.call(n,f[e]),n[r]=!(t[r]=f[e])}):function(n){return u(n,0,e)}):u}},pseudos:{not:s(function(n){var i=[],r=[],t=ii(n.replace(yt,"$1"));return t[f]?s(function(n,i,r,u){for(var e,o=t(n,null,u,[]),f=n.length;f--;)(e=o[f])&&(n[f]=!(i[f]=e))}):function(n,u,f){return i[0]=n,t(i,null,f,r),!r.pop()}}),has:s(function(n){return function(t){return r(n,t).length>0}}),contains:s(function(n){return n=n.replace(y,p),function(t){return(t.textContent||t.innerText||lt(t)).indexOf(n)>-1}}),lang:s(function(n){return sr.test(n||"")||r.error("unsupported lang: "+n),n=n.replace(y,p).toLowerCase(),function(t){var i;do if(i=a?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return i=i.toLowerCase(),i===n||0===i.indexOf(n+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(n){var t=window.location&&window.location.hash;return t&&t.slice(1)===n.id},root:function(n){return n===l},focus:function(n){return n===e.activeElement&&(!e.hasFocus||e.hasFocus())&&!!(n.type||n.href||~n.tabIndex)},enabled:function(n){return n.disabled===!1},disabled:function(n){return n.disabled===!0},checked:function(n){var t=n.nodeName.toLowerCase();return"input"===t&&!!n.checked||"option"===t&&!!n.selected},selected:function(n){return n.parentNode&&n.parentNode.selectedIndex,n.selected===!0},empty:function(n){for(n=n.firstChild;n;n=n.nextSibling)if(n.nodeType<6)return!1;return!0},parent:function(t){return!n.pseudos.empty(t)},header:function(n){return cr.test(n.nodeName)},input:function(n){return hr.test(n.nodeName)},button:function(n){var t=n.nodeName.toLowerCase();return"input"===t&&"button"===n.type||"button"===t},text:function(n){var t;return"input"===n.nodeName.toLowerCase()&&"text"===n.type&&(null==(t=n.getAttribute("type"))||"text"===t.toLowerCase())},first:g(function(){return[0]}),last:g(function(n,t){return[t-1]}),eq:g(function(n,t,i){return[0>i?i+t:i]}),even:g(function(n,t){for(var i=0;t>i;i+=2)n.push(i);return n}),odd:g(function(n,t){for(var i=1;t>i;i+=2)n.push(i);return n}),lt:g(function(n,t,i){for(var r=0>i?i+t:i;--r>=0;)n.push(r);return n}),gt:g(function(n,t,i){for(var r=0>i?i+t:i;++r<t;)n.push(r);return n})}};n.pseudos.nth=n.pseudos.eq;for(rt in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})n.pseudos[rt]=bi(rt);for(rt in{submit:!0,reset:!0})n.pseudos[rt]=ki(rt);return si.prototype=n.filters=n.pseudos,n.setFilters=new si,ft=r.tokenize=function(t,i){var e,f,s,o,u,h,c,l=ai[t+" "];if(l)return i?0:l.slice(0);for(u=t,h=[],c=n.preFilter;u;){(!e||(f=ur.exec(u)))&&(f&&(u=u.slice(f[0].length)||u),h.push(s=[]));e=!1;(f=fr.exec(u))&&(e=f.shift(),s.push({value:e,type:f[0].replace(yt," ")}),u=u.slice(e.length));for(o in n.filter)(f=pt[o].exec(u))&&(!c[o]||(f=c[o](f)))&&(e=f.shift(),s.push({value:e,type:o,matches:f}),u=u.slice(e.length));if(!e)break}return i?u.length:u?r.error(t):ai(t,h).slice(0)},ii=r.compile=function(n,t){var r,u=[],e=[],i=vi[n+" "];if(!i){for(t||(t=ft(n)),r=t.length;r--;)i=ti(t[r]),i[f]?u.push(i):e.push(i);i=vi(n,gi(e,u));i.selector=n}return i},ci=r.select=function(t,i,r,f){var s,e,o,l,v,c="function"==typeof t&&t,h=!f&&ft(t=c.selector||t);if(r=r||[],1===h.length){if(e=h[0]=h[0].slice(0),e.length>2&&"ID"===(o=e[0]).type&&u.getById&&9===i.nodeType&&a&&n.relative[e[1].type]){if(i=(n.find.ID(o.matches[0].replace(y,p),i)||[])[0],!i)return r;c&&(i=i.parentNode);t=t.slice(e.shift().value.length)}for(s=pt.needsContext.test(t)?0:e.length;s--&&(o=e[s],!n.relative[l=o.type]);)if((v=n.find[l])&&(f=v(o.matches[0].replace(y,p),ei.test(e[0].type)&&kt(i.parentNode)||i))){if(e.splice(s,1),t=f.length&&ht(e),!t)return d.apply(r,f),r;break}}return(c||ii(t,h))(f,i,!a,r,ei.test(t)&&kt(i.parentNode)||i),r},u.sortStable=f.split("").sort(ri).join("")===f,u.detectDuplicates=!!ut,b(),u.sortDetached=c(function(n){return 1&n.compareDocumentPosition(e.createElement("div"))}),c(function(n){return n.innerHTML="<a href='#'><\/a>","#"===n.firstChild.getAttribute("href")})||bt("type|href|height|width",function(n,t,i){if(!i)return n.getAttribute(t,"type"===t.toLowerCase()?1:2)}),u.attributes&&c(function(n){return n.innerHTML="<input/>",n.firstChild.setAttribute("value",""),""===n.firstChild.getAttribute("value")})||bt("value",function(n,t,i){if(!i&&"input"===n.nodeName.toLowerCase())return n.defaultValue}),c(function(n){return null==n.getAttribute("disabled")})||bt(ui,function(n,t,i){var r;if(!i)return n[t]===!0?t.toLowerCase():(r=n.getAttributeNode(t))&&r.specified?r.value:null}),r});i(c,[],function(){function u(n){var i=n,t,u;if(!r(n))for(i=[],t=0,u=n.length;u>t;t++)i[t]=n[t];return i}function n(n,i,r){var u,f;if(!n)return 0;if(r=r||n,n.length!==t){for(u=0,f=n.length;f>u;u++)if(i.call(r,n[u],u,n)===!1)return 0}else for(u in n)if(n.hasOwnProperty(u)&&i.call(r,n[u],u,n)===!1)return 0;return 1}function f(t,i){var r=[];return n(t,function(n,u){r.push(i(n,u,t))}),r}function e(t,i){var r=[];return n(t,function(n,u){i&&!i(n,u,t)||r.push(n)}),r}function o(n,t){var i,r;if(n)for(i=0,r=n.length;r>i;i++)if(n[i]===t)return i;return-1}function s(n,t,i,r){var u=0;for(arguments.length<3&&(i=n[0]);u<n.length;u++)i=t.call(r,i,n[u],u);return i}function i(n,t,i){for(var r=0,u=n.length;u>r;r++)if(t.call(i,n[r],r,n))return r;return-1}function h(n,r,u){var f=i(n,r,u);return-1!==f?n[f]:t}function c(n){return n[n.length-1]}var r=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};return{isArray:r,toArray:u,each:n,map:f,filter:e,indexOf:o,reduce:s,findIndex:i,find:h,last:c}});i(r,[u,c],function(n,i){function r(n){return null===n||n===t?"":(""+n).replace(v,"")}function u(n,r){return r?"array"==r&&i.isArray(n)?!0:typeof n==r:n!==t}function e(n,t,i){var r;for(n=n||[],t=t||",","string"==typeof n&&(n=n.split(t)),i=i||{},r=n.length;r--;)i[n[r]]={};return i}function o(n,t,i){var e=this,f,u,r,o,s,h=0;if(n=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(n),r=n[3].match(/(^|\.)(\w+)$/i)[2],u=e.createNS(n[3].replace(/\.\w+$/,""),i),!u[r]){if("static"==n[2])return u[r]=t,void(this.onCreate&&this.onCreate(n[2],n[3],u[r]));t[r]||(t[r]=function(){},h=1);u[r]=t[r];e.extend(u[r].prototype,t);n[5]&&(f=e.resolve(n[5]).prototype,o=n[5].match(/\.(\w+)$/i)[1],s=u[r],u[r]=h?function(){return f[o].apply(this,arguments)}:function(){return this.parent=f[o],s.apply(this,arguments)},u[r].prototype[r]=u[r],e.each(f,function(n,t){u[r].prototype[t]=f[t]}),e.each(t,function(n,t){f[t]?u[r].prototype[t]=function(){return this.parent=f[t],n.apply(this,arguments)}:t!=r&&(u[r].prototype[t]=n)}));e.each(t["static"],function(n,t){u[r][t]=n})}}function s(n,i){for(var u,o=arguments,f,r=1,e=o.length;e>r;r++){i=o[r];for(u in i)i.hasOwnProperty(u)&&(f=i[u],f!==t&&(n[u]=f))}return n}function f(n,t,r,u){u=u||this;n&&(r&&(n=n[r]),i.each(n,function(n,i){return t.call(u,n,i,r)===!1?!1:void f(n,t,r,u)}))}function h(n,t){var i,r;for(t=t||window,n=n.split("."),i=0;i<n.length;i++)r=n[i],t[r]||(t[r]={}),t=t[r];return t}function c(n,t){var i,r;for(t=t||window,n=n.split("."),i=0,r=n.length;r>i&&(t=t[n[i]],t);i++);return t}function l(n,t){return!n||u(n,"array")?n:i.map(n.split(t||","),r)}function a(t){var i=n.cacheSuffix;return i&&(t+=(-1===t.indexOf("?")?"?":"&")+i),t}var v=/^\s*|\s*$/g;return{trim:r,isArray:i.isArray,is:u,toArray:i.toArray,makeMap:e,each:i.each,map:i.map,grep:i.filter,inArray:i.indexOf,extend:s,create:o,walk:f,createNS:h,resolve:c,explode:l,_addCacheSuffix:a}});i(s,[ft,ni,r,u],function(n,i,r,u){function h(n){return"undefined"!=typeof n}function v(n){return"string"==typeof n}function et(n){return n&&n==n.window}function k(n,t){var i,u,r;for(t=t||ut,r=t.createElement("div"),i=t.createDocumentFragment(),r.innerHTML=n;u=r.firstChild;)i.appendChild(u);return i}function s(n,t,i,r){var u;if(v(t))t=k(t,y(n[0]));else if(t.length&&!t.nodeType){if(t=f.makeArray(t),r)for(u=t.length-1;u>=0;u--)s(n,t[u],i,r);else for(u=0;u<t.length;u++)s(n,t[u],i,r);return n}if(t.nodeType)for(u=n.length;u--;)i.call(n[u],t);return n}function d(n,t){return n&&t&&-1!==(" "+n.className+" ").indexOf(" "+t+" ")}function g(n,t,i){var u,r;return t=f(t)[0],n.each(function(){var n=this;i&&u==n.parentNode?r.appendChild(n):(u=n.parentNode,r=t.cloneNode(!1),n.parentNode.insertBefore(r,n),r.appendChild(n))}),n}function f(n,t){return new f.fn.init(n,t)}function ot(n,t){var i;if(t.indexOf)return t.indexOf(n);for(i=t.length;i--;)if(t[i]===n)return i;return-1}function nt(n){return null===n||n===o?"":(""+n).replace(yt,"")}function e(n,t){var f,u,r,e,i;if(n)if(f=n.length,f===e){for(u in n)if(n.hasOwnProperty(u)&&(i=n[u],t.call(i,u,i)===!1))break}else for(r=0;f>r&&(i=n[r],t.call(i,r,i)!==!1);r++);return n}function tt(n,t){var i=[];return e(n,function(n,r){t(r,n)&&i.push(r)}),i}function y(n){return n?9==n.nodeType?n:n.ownerDocument:ut}function it(n,i,r){var e=[],u=n[i];for("string"!=typeof r&&r instanceof f&&(r=r[0]);u&&9!==u.nodeType;){if(r!==t){if(u===r)break;if("string"==typeof r&&f(u).is(r))break}1===u.nodeType&&e.push(u);u=u[i]}return e}function p(n,i,r,u){var e=[];for(u instanceof f&&(u=u[0]);n;n=n[i])if(!r||n.nodeType===r){if(u!==t){if(n===u)break;if("string"==typeof u&&f(n).is(u))break}e.push(n)}return e}function rt(n,t,i){for(n=n[t];n;n=n[t])if(n.nodeType==i)return n;return null}function w(n,t,i){e(i,function(i,r){n[i]=n[i]||{};n[i][t]=r})}var ut=document,b=Array.prototype.push,st=Array.prototype.slice,ht=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,c=n.Event,o,ct=r.makeMap("children,contents,next,prev"),lt=r.makeMap("fillOpacity fontWeight lineHeight opacity orphans widows zIndex zoom"," "),at=r.makeMap("checked compact declare defer disabled ismap multiple nohref noshade nowrap readonly selected"," "),vt={"for":"htmlFor","class":"className",readonly:"readOnly"},ft={float:"cssFloat"},l={},a={},yt=/^\s*|\s*$/g;return f.fn=f.prototype={constructor:f,selector:"",context:null,length:0,init:function(n,t){var i=this,u,r;if(!n)return i;if(n.nodeType)return i.context=i[0]=n,i.length=1,i;if(t&&t.nodeType)i.context=t;else{if(t)return f(n).attr(t);i.context=t=document}if(v(n)){if(i.selector=n,u="<"===n.charAt(0)&&">"===n.charAt(n.length-1)&&n.length>=3?[null,n,null]:ht.exec(n),!u)return f(t).find(n);if(u[1])for(r=k(n,y(t)).firstChild;r;)b.call(i,r),r=r.nextSibling;else{if(r=y(t).getElementById(u[2]),!r)return i;if(r.id!==u[2])return i.find(n);i.length=1;i[0]=r}}else this.add(n,!1);return i},toArray:function(){return r.toArray(this)},add:function(n,t){var i=this,u,r;if(v(n))return i.add(f(n));if(t!==!1)for(u=f.unique(i.toArray().concat(f.makeArray(n))),i.length=u.length,r=0;r<u.length;r++)i[r]=u[r];else b.apply(i,f.makeArray(n));return i},attr:function(n,t){var i=this,r;if("object"==typeof n)e(n,function(n,t){i.attr(n,t)});else{if(!h(t)){if(i[0]&&1===i[0].nodeType){if(r=l[n],r&&r.get)return r.get(i[0],n);if(at[n])return i.prop(n)?n:o;t=i[0].getAttribute(n,2);null===t&&(t=o)}return t}this.each(function(){var i;if(1===this.nodeType){if(i=l[n],i&&i.set)return void i.set(this,t);null===t?this.removeAttribute(n,2):this.setAttribute(n,t,2)}})}return i},removeAttr:function(n){return this.attr(n,null)},prop:function(n,t){var i=this;if(n=vt[n]||n,"object"==typeof n)e(n,function(n,t){i.prop(n,t)});else{if(!h(t))return i[0]&&i[0].nodeType&&n in i[0]?i[0][n]:t;this.each(function(){1==this.nodeType&&(this[n]=t)})}return i},css:function(n,t){function f(n){return n.replace(/-(\D)/g,function(n,t){return t.toUpperCase()})}function s(n){return n.replace(/[A-Z]/g,function(n){return"-"+n})}var u=this,r,i;if("object"==typeof n)e(n,function(n,t){u.css(n,t)});else if(h(t))n=f(n),"number"!=typeof t||lt[n]||(t+="px"),u.each(function(){var r=this.style;if(i=a[n],i&&i.set)return void i.set(this,t);try{this.style[ft[n]||n]=t}catch(u){}null!==t&&""!==t||(r.removeProperty?r.removeProperty(s(n)):r.removeAttribute(n))});else{if(r=u[0],i=a[n],i&&i.get)return i.get(r);if(r.ownerDocument.defaultView)try{return r.ownerDocument.defaultView.getComputedStyle(r,null).getPropertyValue(s(n))}catch(c){return o}else if(r.currentStyle)return r.currentStyle[f(n)]}return u},remove:function(){for(var i=this,n,t=this.length;t--;)n=i[t],c.clean(n),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){for(var i=this,n,t=this.length;t--;)for(n=i[t];n.firstChild;)n.removeChild(n.firstChild);return this},html:function(n){var t=this,i;if(h(n)){i=t.length;try{for(;i--;)t[i].innerHTML=n}catch(r){f(t[i]).empty().append(n)}return t}return t[0]?t[0].innerHTML:""},text:function(n){var t=this,i;if(h(n)){for(i=t.length;i--;)"innerText"in t[i]?t[i].innerText=n:t[0].textContent=n;return t}return t[0]?t[0].innerText||t[0].textContent:""},append:function(){return s(this,arguments,function(n){(1===this.nodeType||this.host&&1===this.host.nodeType)&&this.appendChild(n)})},prepend:function(){return s(this,arguments,function(n){(1===this.nodeType||this.host&&1===this.host.nodeType)&&this.insertBefore(n,this.firstChild)},!0)},before:function(){var n=this;return n[0]&&n[0].parentNode?s(n,arguments,function(n){this.parentNode.insertBefore(n,this)}):n},after:function(){var n=this;return n[0]&&n[0].parentNode?s(n,arguments,function(n){this.parentNode.insertBefore(n,this.nextSibling)},!0):n},appendTo:function(n){return f(n).append(this),this},prependTo:function(n){return f(n).prepend(this),this},replaceWith:function(n){return this.before(n).remove()},wrap:function(n){return g(this,n)},wrapAll:function(n){return g(this,n,!0)},wrapInner:function(n){return this.each(function(){f(this).contents().wrapAll(n)}),this},unwrap:function(){return this.parent().each(function(){f(this).replaceWith(this.childNodes)})},clone:function(){var n=[];return this.each(function(){n.push(this.cloneNode(!0))}),f(n)},addClass:function(n){return this.toggleClass(n,!0)},removeClass:function(n){return this.toggleClass(n,!1)},toggleClass:function(n,t){var i=this;return"string"!=typeof n?i:(-1!==n.indexOf(" ")?e(n.split(" "),function(){i.toggleClass(this,t)}):i.each(function(i,r){var u,f;f=d(r,n);f!==t&&(u=r.className,f?r.className=nt((" "+u+" ").replace(" "+n+" "," ")):r.className+=u?" "+n:n)}),i)},hasClass:function(n){return d(this[0],n)},each:function(n){return e(this,n)},on:function(n,t){return this.each(function(){c.bind(this,n,t)})},off:function(n,t){return this.each(function(){c.unbind(this,n,t)})},trigger:function(n){return this.each(function(){"object"==typeof n?c.fire(this,n.type,n):c.fire(this,n)})},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},slice:function(){return new f(st.apply(this,arguments))},eq:function(n){return-1===n?this.slice(n):this.slice(n,+n+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},find:function(n){for(var r=[],t=0,i=this.length;i>t;t++)f.find(n,this[t],r);return f(r)},filter:function(n){return f("function"==typeof n?tt(this.toArray(),function(t,i){return n(i,t)}):f.filter(n,this.toArray()))},closest:function(n){var t=[];return n instanceof f&&(n=n[0]),this.each(function(i,r){for(;r;){if("string"==typeof n&&f(r).is(n)){t.push(r);break}if(r==n){t.push(r);break}r=r.parentNode}}),f(t)},offset:function(n){var t,r,i,f=0,e=0,u;return n?this.css(n):(t=this[0],t&&(r=t.ownerDocument,i=r.documentElement,t.getBoundingClientRect&&(u=t.getBoundingClientRect(),f=u.left+(i.scrollLeft||r.body.scrollLeft)-i.clientLeft,e=u.top+(i.scrollTop||r.body.scrollTop)-i.clientTop)),{left:f,top:e})},push:b,sort:[].sort,splice:[].splice},r.extend(f,{extend:r.extend,makeArray:function(n){return et(n)||n.nodeType?[n]:r.toArray(n)},inArray:ot,isArray:r.isArray,each:e,trim:nt,grep:tt,find:i,expr:i.selectors,unique:i.uniqueSort,text:i.getText,contains:i.contains,filter:function(n,t,i){var r=t.length;for(i&&(n=":not("+n+")");r--;)1!=t[r].nodeType&&t.splice(r,1);return 1===t.length?f.find.matchesSelector(t[0],n)?[t[0]]:[]:f.find.matches(n,t)}}),e({parent:function(n){var t=n.parentNode;return t&&11!==t.nodeType?t:null},parents:function(n){return it(n,"parentNode")},next:function(n){return rt(n,"nextSibling",1)},prev:function(n){return rt(n,"previousSibling",1)},children:function(n){return p(n.firstChild,"nextSibling",1)},contents:function(n){return r.toArray(("iframe"===n.nodeName?n.contentDocument||n.contentWindow.document:n).childNodes)}},function(n,t){f.fn[n]=function(i){var u=this,r=[];return u.each(function(){var n=t.call(r,this,i,r);n&&(f.isArray(n)?r.push.apply(r,n):r.push(n))}),this.length>1&&(ct[n]||(r=f.unique(r)),0===n.indexOf("parents")&&(r=r.reverse())),r=f(r),i?r.filter(i):r}}),e({parentsUntil:function(n,t){return it(n,"parentNode",t)},nextUntil:function(n,t){return p(n,"nextSibling",1,t).slice(1)},prevUntil:function(n,t){return p(n,"previousSibling",1,t).slice(1)}},function(n,t){f.fn[n]=function(i,r){var e=this,u=[];return e.each(function(){var n=t.call(u,this,i,u);n&&(f.isArray(n)?u.push.apply(u,n):u.push(n))}),this.length>1&&(u=f.unique(u),0!==n.indexOf("parents")&&"prevUntil"!==n||(u=u.reverse())),u=f(u),r?u.filter(r):u}}),f.fn.is=function(n){return!!n&&this.filter(n).length>0},f.fn.init.prototype=f.fn,f.overrideDefaults=function(n){function i(r,u){return t=t||n(),0===arguments.length&&(r=t.element),u||(u=t.context),new i.fn.init(r,u)}var t;return f.extend(i,this),i},u.ie&&u.ie<8&&(w(l,"get",{maxlength:function(n){var t=n.maxLength;return 2147483647===t?o:t},size:function(n){var t=n.size;return 20===t?o:t},"class":function(n){return n.className},style:function(n){var t=n.style.cssText;return 0===t.length?o:t}}),w(l,"set",{"class":function(n,t){n.className=t},style:function(n,t){n.style.cssText=t}})),u.ie&&u.ie<9&&(ft.float="styleFloat",w(a,"set",{opacity:function(n,t){var i=n.style;null===t||""===t?i.removeAttribute("filter"):(i.zoom=1,i.filter="alpha(opacity="+100*t+")")}})),f.attrHooks=l,f.cssHooks=a,f});i(pi,[],function(){return function(n,t){function s(n,t,i,r){function u(n){return n=parseInt(n,10).toString(16),n.length>1?n:"0"+n}return"#"+u(t)+u(i)+u(r)}var h=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,v=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,c=/\s*([^:]+):\s*([^;]+);?/g,l=/\s+$/,a,i,r={},u,e,f,o="﻿";for(n=n||{},t&&(e=t.getValidStyles(),f=t.getInvalidStyles()),u=("\\\" \\' \\; \\: ; : "+o).split(" "),i=0;i<u.length;i++)r[u[i]]=o+i,r[o+i]=u[i];return{toHex:function(n){return n.replace(h,s)},parse:function(t){function o(n,t,r){var e,o,s,h,f;if(e=u[n+"-top"+t],e&&(o=u[n+"-right"+t],o&&(s=u[n+"-bottom"+t],s&&(h=u[n+"-left"+t])))){for(f=[e,o,s,h],i=f.length-1;i--&&f[i]===f[i+1];);i>-1&&r||(u[n+t]=-1==i?f[0]:f.join(" "),delete u[n+"-top"+t],delete u[n+"-right"+t],delete u[n+"-bottom"+t],delete u[n+"-left"+t])}}function y(n){var t=u[n],i;if(t){for(t=t.split(" "),i=t.length;i--;)if(t[i]!==t[0])return!1;return u[n]=t[0],!0}}function d(n,t,i,r){y(t)&&y(i)&&y(r)&&(u[n]=u[t]+" "+u[i]+" "+u[r],delete u[t],delete u[i],delete u[r])}function b(n){return w=!0,r[n]}function p(n,t){return w&&(n=n.replace(/\uFEFF[0-9]/g,function(n){return r[n]})),t||(n=n.replace(/\\([\'\";:])/g,"$1")),n}function g(t,i,r,u,f,e){if(f=f||e)return f=p(f),"'"+f.replace(/\'/g,"\\'")+"'";if(i=p(i||r||u),!n.allow_script_urls){var o=i.replace(/[\s\r\n]+/,"");if(/(java|vb)script:/i.test(o)||!n.allow_svg_data_urls&&/^data:image\/svg/i.test(o))return""}return k&&(i=k.call(nt,i,"style")),"url('"+i.replace(/\'/g,"\\'")+"')"}var u={},a,e,f,w,k=n.url_converter,nt=n.url_converter_scope||this;if(t){for(t=t.replace(/[\u0000-\u001F]/g,""),t=t.replace(/\\[\"\';:\uFEFF]/g,b).replace(/\"[^\"]+\"|\'[^\']+\'/g,function(n){return n.replace(/[;:]/g,b)});a=c.exec(t);){if(e=a[1].replace(l,"").toLowerCase(),f=a[2].replace(l,""),f=f.replace(/\\[0-9a-f]+/g,function(n){return String.fromCharCode(parseInt(n.substr(1),16))}),e&&f.length>0){if(!n.allow_script_urls&&("behavior"==e||/expression\s*\(|\/\*|\*\//.test(f)))continue;"font-weight"===e&&"700"===f?f="bold":"color"!==e&&"background-color"!==e||(f=f.toLowerCase());f=f.replace(h,s);f=f.replace(v,g);u[e]=w?p(f,!0):f}c.lastIndex=a.index+a[0].length}o("border","",!0);o("border","-width");o("border","-color");o("border","-style");o("padding","");o("margin","");d("border","border-width","border-style","border-color");"medium none"===u.border&&delete u.border;"none"===u["border-image"]&&delete u["border-image"]}return u},serialize:function(n,t){function o(t){var f,r,o,u;if(f=e[t])for(r=0,o=f.length;o>r;r++)t=f[r],u=n[t],u!==a&&u.length>0&&(i+=(i.length>0?" ":"")+t+": "+u+";")}function s(n,t){var i;return i=f["*"],i&&i[n]?!1:(i=f[t],!i||!i[n])}var i="",r,u;if(t&&e)o("*"),o(t);else for(r in n)u=n[r],u!==a&&u.length>0&&(f&&!s(r,t)||(i+=(i.length>0?" ":"")+r+": "+u+";"));return i}}}});i(p,[],function(){return function(n,t){function r(n,i,r,u){var e,f;if(n){if(!u&&n[i])return n[i];if(n!=t){if(e=n[r])return e;for(f=n.parentNode;f&&f!=t;f=f.parentNode)if(e=f[r])return e}}}function u(n,i,r,u){var e,o,f;if(n){if(e=n[r],t&&e===t)return;if(e){if(!u)for(f=e[i];f;f=f[i])if(!f[i])return f;return e}if(o=n.parentNode,o&&o!==t)return o}}var i=n;this.current=function(){return i};this.next=function(n){return i=r(i,"firstChild","nextSibling",n)};this.prev=function(n){return i=r(i,"lastChild","previousSibling",n)};this.prev2=function(n){return i=u(i,"lastChild","previousSibling",n)}}});i(yu,[r],function(n){function t(i){function b(){return w.createDocumentFragment()}function k(n,t){ut(o,n,t)}function d(n,t){ut(c,n,t)}function tt(n){k(n.parentNode,v(n))}function st(n){k(n.parentNode,v(n)+1)}function ht(n){d(n.parentNode,v(n))}function it(n){d(n.parentNode,v(n)+1)}function ct(n){n?(r[e]=r[u],r[s]=r[f]):(r[u]=r[e],r[f]=r[s]);r.collapsed=o}function lt(n){tt(n);it(n)}function at(n){k(n,0);d(n,1===n.nodeType?n.childNodes.length:n.nodeValue.length)}function vt(n,t){var i=r[u],o=r[f],h=r[e],c=r[s],l=t.startContainer,a=t.startOffset,v=t.endContainer,p=t.endOffset;return 0===n?y(i,o,l,a):1===n?y(h,c,l,a):2===n?y(h,c,v,p):3===n?y(i,o,v,p):void 0}function yt(){nt(h)}function pt(){return nt(ui)}function rt(){return nt(l)}function wt(n){var t=this[u],r=this[f],o,e;3!==t.nodeType&&4!==t.nodeType||!t.nodeValue?(t.childNodes.length>0&&(e=t.childNodes[r]),e?t.insertBefore(n,e):3==t.nodeType?i.insertAfter(n,t):t.appendChild(n)):r?r>=t.nodeValue.length?i.insertAfter(n,t):(o=t.splitText(r),t.parentNode.insertBefore(n,o)):t.parentNode.insertBefore(n,t)}function bt(n){var t=r.extractContents();r.insertNode(n);n.appendChild(t);r.selectNode(n)}function kt(){return ot(new t(i),{startContainer:r[u],startOffset:r[f],endContainer:r[e],endOffset:r[s],collapsed:r.collapsed,commonAncestorContainer:r.commonAncestorContainer})}function g(n,t){var i;if(3==n.nodeType||0>t)return n;for(i=n.firstChild;i&&t>0;)--t,i=i.nextSibling;return i?i:n}function dt(){return r[u]==r[e]&&r[f]==r[s]}function y(n,t,r,u){var f,h,e,c,o,s;if(n==r)return t==u?0:u>t?-1:1;for(f=r;f&&f.parentNode!=n;)f=f.parentNode;if(f){for(h=0,e=n.firstChild;e!=f&&t>h;)h++,e=e.nextSibling;return h>=t?-1:1}for(f=n;f&&f.parentNode!=r;)f=f.parentNode;if(f){for(h=0,e=r.firstChild;e!=f&&u>h;)h++,e=e.nextSibling;return u>h?-1:1}for(c=i.findCommonAncestor(n,r),o=n;o&&o.parentNode!=c;)o=o.parentNode;for(o||(o=c),s=r;s&&s.parentNode!=c;)s=s.parentNode;if(s||(s=c),o==s)return 0;for(e=c.firstChild;e;){if(e==o)return-1;if(e==s)return 1;e=e.nextSibling}}function ut(n,t,o){var h,c;for(n?(r[u]=t,r[f]=o):(r[e]=t,r[s]=o),h=r[e];h.parentNode;)h=h.parentNode;for(c=r[u];c.parentNode;)c=c.parentNode;c==h?y(r[u],r[f],r[e],r[s])>0&&r.collapse(n):r.collapse(n);r.collapsed=dt();r.commonAncestorContainer=i.findCommonAncestor(r[u],r[e])}function nt(n){var i,l=0,a=0,t,s,f,o,h,c;if(r[u]==r[e])return gt(n);for(i=r[e],t=i.parentNode;t;i=t,t=t.parentNode){if(t==r[u])return ni(i,n);++l}for(i=r[u],t=i.parentNode;t;i=t,t=t.parentNode){if(t==r[e])return ti(i,n);++a}for(s=a-l,f=r[u];s>0;)f=f.parentNode,s--;for(o=r[e];0>s;)o=o.parentNode,s++;for(h=f.parentNode,c=o.parentNode;h!=c;h=h.parentNode,c=c.parentNode)f=h,o=c;return ii(f,o,n)}function gt(n){var i,y,e,t,c,k,d,a,v;if(n!=h&&(i=b()),r[f]==r[s])return i;if(3==r[u].nodeType)return(y=r[u].nodeValue,e=y.substring(r[f],r[s]),n!=l&&(t=r[u],a=r[f],v=r[s]-r[f],0===a&&v>=t.nodeValue.length-1?t.parentNode.removeChild(t):t.deleteData(a,v),r.collapse(o)),n==h)?void 0:(e.length>0&&i.appendChild(w.createTextNode(e)),i);for(t=g(r[u],r[f]),c=r[s]-r[f];t&&c>0;)k=t.nextSibling,d=p(t,n),i&&i.appendChild(d),--c,t=k;return n!=l&&r.collapse(o),i}function ni(n,t){var i,u,o,e,s,a;if(t!=h&&(i=b()),u=ft(n,t),i&&i.appendChild(u),o=v(n),e=o-r[f],0>=e)return t!=l&&(r.setEndBefore(n),r.collapse(c)),i;for(u=n.previousSibling;e>0;)s=u.previousSibling,a=p(u,t),i&&i.insertBefore(a,i.firstChild),--e,u=s;return t!=l&&(r.setEndBefore(n),r.collapse(c)),i}function ti(n,t){var u,f,i,e,c,a;for(t!=h&&(u=b()),i=et(n,t),u&&u.appendChild(i),f=v(n),++f,e=r[s]-f,i=n.nextSibling;i&&e>0;)c=i.nextSibling,a=p(i,t),u&&u.appendChild(a),--e,i=c;return t!=l&&(r.setStartAfter(n),r.collapse(o)),u}function ii(n,t,i){var f,u,s,a,c,e,y;for(i!=h&&(u=b()),f=et(n,i),u&&u.appendChild(f),s=v(n),a=v(t),++s,c=a-s,e=n.nextSibling;c>0;)y=e.nextSibling,f=p(e,i),u&&u.appendChild(f),e=y,--c;return f=ft(t,i),u&&u.appendChild(f),i!=l&&(r.setStartAfter(n),r.collapse(o)),u}function ft(n,t){var i=g(r[e],r[s]-1),u,f,y,p,l,v=i!=r[e];if(i==n)return a(i,v,c,t);for(u=i.parentNode,f=a(u,c,c,t);u;){for(;i;)y=i.previousSibling,p=a(i,v,c,t),t!=h&&f.insertBefore(p,f.firstChild),v=o,i=y;if(u==n)return f;i=u.previousSibling;u=u.parentNode;l=a(u,c,c,t);t!=h&&l.appendChild(f);f=l}}function et(n,t){var i=g(r[u],r[f]),l=i!=r[u],e,s,y,p,v;if(i==n)return a(i,l,o,t);for(e=i.parentNode,s=a(e,c,o,t);e;){for(;i;)y=i.nextSibling,p=a(i,l,o,t),t!=h&&s.appendChild(p),l=o,i=y;if(e==n)return s;i=e.nextSibling;e=e.parentNode;v=a(e,c,o,t);t!=h&&v.appendChild(s);s=v}}function a(n,t,u,e){var a,v,y,o,w;return t?p(n,e):3==n.nodeType?(a=n.nodeValue,u?(o=r[f],v=a.substring(o),y=a.substring(0,o)):(o=r[s],v=a.substring(0,o),y=a.substring(o)),e!=l&&(n.nodeValue=y),e==h)?void 0:(w=i.clone(n,c),w.nodeValue=v,w):e!=h?i.clone(n,c):void 0}function p(n,t){return t!=h?t==l?i.clone(n,o):n:void n.parentNode.removeChild(n)}function ri(){return i.create("body",null,rt()).outerText}var r=this,w=i.doc,ui=0,l=1,h=2,o=!0,c=!1,f="startOffset",u="startContainer",e="endContainer",s="endOffset",ot=n.extend,v=i.nodeIndex;return ot(r,{startContainer:w,startOffset:0,endContainer:w,endOffset:0,collapsed:o,commonAncestorContainer:w,START_TO_START:0,START_TO_END:1,END_TO_END:2,END_TO_START:3,setStart:k,setEnd:d,setStartBefore:tt,setStartAfter:st,setEndBefore:ht,setEndAfter:it,collapse:ct,selectNode:lt,selectNodeContents:at,compareBoundaryPoints:vt,deleteContents:yt,extractContents:pt,cloneContents:rt,insertNode:wt,surroundContents:bt,cloneRange:kt,toStringIE:ri}),r}return t.prototype.toString=function(){return this.toStringIE()},t});i(d,[r],function(n){function s(n){var t;return t=document.createElement("div"),t.innerHTML=n,t.textContent||t.innerText||n}function e(n,i){var r,u,f,e={};if(n){for(n=n.split(","),i=i||10,r=0;r<n.length;r+=2)u=String.fromCharCode(parseInt(n[r],i)),t[u]||(f="&"+n[r+1]+";",e[u]=f,e[f]=u);return e}}var h=n.makeMap,r,t,o,u=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,f=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,c=/[<>&\"\']/g,l=/&#([a-z0-9]+);?|&([a-z0-9]+);/gi,a={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"},i;return t={'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;","&":"&amp;","`":"&#96;"},o={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&apos;":"'"},r=e("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),i={encodeRaw:function(n,i){return n.replace(i?u:f,function(n){return t[n]||n})},encodeAllRaw:function(n){return(""+n).replace(c,function(n){return t[n]||n})},encodeNumeric:function(n,i){return n.replace(i?u:f,function(n){return n.length>1?"&#"+(1024*(n.charCodeAt(0)-55296)+(n.charCodeAt(1)-56320)+65536)+";":t[n]||"&#"+n.charCodeAt(0)+";"})},encodeNamed:function(n,i,e){return e=e||r,n.replace(i?u:f,function(n){return t[n]||e[n]||n})},getEncodeFunc:function(n,o){function s(n,i){return n.replace(i?u:f,function(n){return t[n]||o[n]||"&#"+n.charCodeAt(0)+";"||n})}function c(n,t){return i.encodeNamed(n,t,o)}return o=e(o)||r,n=h(n.replace(/\+/g,",")),n.named&&n.numeric?s:n.named?o?c:i.encodeNamed:n.numeric?i.encodeNumeric:i.encodeRaw},decode:function(n){return n.replace(l,function(n,t){return t?(t="x"===t.charAt(0).toLowerCase()?parseInt(t.substr(1),16):parseInt(t,10),t>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):a[t]||String.fromCharCode(t)):o[n]||r[n]||s(n)})}}});i(pu,[r,f],function(n,t){return function(i,r){function f(n){i.getElementsByTagName("head")[0].appendChild(n)}function o(r,o,h){function v(){for(var n=c.passed,t=n.length;t--;)n[t]();c.status=2;c.passed=[];c.failed=[]}function y(){for(var n=c.failed,t=n.length;t--;)n[t]();c.status=3;c.passed=[];c.failed=[]}function d(){var n=navigator.userAgent.match(/WebKit\/(\d*)/);return!!(n&&n[1]<536)}function w(n,i){n()||((new Date).getTime()-k<e?t.setTimeout(i):y())}function p(){w(function(){for(var r=i.styleSheets,n,u=r.length,t;u--;)if(n=r[u],t=n.ownerNode?n.ownerNode:n.owningElement,t&&t.id===l.id)return v(),!0},p)}function b(){w(function(){try{var n=a.sheet.cssRules;return v(),!!n}catch(t){}},b)}var l,a,k,c;if(r=n._addCacheSuffix(r),u[r]?c=u[r]:(c={passed:[],failed:[]},u[r]=c),o&&c.passed.push(o),h&&c.failed.push(h),1!=c.status){if(2==c.status)return void v();if(3==c.status)return void y();if(c.status=1,l=i.createElement("link"),l.rel="stylesheet",l.type="text/css",l.id="u"+s++,l.async=!1,l.defer=!1,k=(new Date).getTime(),"onload"in l&&!d())l.onload=p,l.onerror=y;else{if(navigator.userAgent.indexOf("Firefox")>0)return a=i.createElement("style"),a.textContent='@import "'+r+'"',b(),void f(a);p()}f(l);l.href=r}}var s=0,u={},e;r=r||{};e=r.maxLoadTime||5e3;this.load=o}});i(h,[ni,s,pi,ft,p,yu,d,u,r,pu],function(n,i,r,u,f,e,o,s,h,c){function b(n,t){var i={},r=t.keep_values,u;return u={set:function(i,r,u){t.url_converter&&(r=t.url_converter.call(t.url_converter_scope||n,r,u,i[0]));i.attr("data-mce-"+u,r).attr(u,r)},get:function(n,t){return n.attr("data-mce-"+t)||n.attr(t)}},i={style:{set:function(n,t){return null!==t&&"object"==typeof t?void n.css(t):(r&&n.attr("data-mce-style",t),void n.attr("style",t))},get:function(t){var i=t.attr("data-mce-style")||t.attr("style");return n.serializeStyle(n.parseStyle(i),t[0].nodeName)}}},r&&(i.href=i.src=u),i}function p(n,t){var i=t.attr("style");i=n.serializeStyle(n.parseStyle(i),t[0].nodeName);i||(i=null);t.attr("data-mce-style",i)}function w(n,t){var u=0,r,i;if(n)for(r=n.nodeType,n=n.previousSibling;n;n=n.previousSibling)i=n.nodeType,(!t||3!=i||i!=r&&n.nodeValue.length)&&(u++,r=i);return u}function l(n,t){var f=this,e;f.doc=n;f.win=window;f.files={};f.counter=0;f.stdMode=!a||n.documentMode>=8;f.boxModel=!a||"CSS1Compat"==n.compatMode||f.stdMode;f.styleSheetLoader=new c(n);f.boundEvents=[];f.settings=t=t||{};f.schema=t.schema;f.styles=new r({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope},t.schema);f.fixDoc(n);f.events=t.ownEvents?new u(t.proxy):u.Event;f.attrHooks=b(f,t);e=t.schema?t.schema.getBlockElements():{};f.$=i.overrideDefaults(function(){return{context:n,element:f.getRoot()}});f.isBlock=function(n){if(!n)return!1;var t=n.nodeType;return t?!(1!==t||!e[n.nodeName]):!!e[n]}}var v=h.each,y=h.is,k=h.grep,d=h.trim,a=s.ie,g=/^([a-z0-9],?)+$/i,nt=/^[ \t\r\n]*$/;return l.prototype={$$:function(n){return"string"==typeof n&&(n=this.get(n)),this.$(n)},root:null,fixDoc:function(n){var t=this.settings,i;if(a&&t.schema){"abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video".replace(/\w+/g,function(t){n.createElement(t)});for(i in t.schema.getCustomElements())n.createElement(i)}},clone:function(n,t){var i=this,r,u;return!a||1!==n.nodeType||t?n.cloneNode(t):(u=i.doc,t?r.firstChild:(r=u.createElement(n.nodeName),v(i.getAttribs(n),function(t){i.setAttrib(r,t.nodeName,i.getAttrib(n,t.nodeName))}),r))},getRoot:function(){var n=this;return n.settings.root_element||n.doc.body},getViewPort:function(n){var i,t;return n=n?n:this.win,i=n.document,t=this.boxModel?i.documentElement:i.body,{x:n.pageXOffset||t.scrollLeft,y:n.pageYOffset||t.scrollTop,w:n.innerWidth||t.clientWidth,h:n.innerHeight||t.clientHeight}},getRect:function(n){var t=this,i,r;return n=t.get(n),i=t.getPos(n),r=t.getSize(n),{x:i.x,y:i.y,w:r.w,h:r.h}},getSize:function(n){var r=this,t,i;return n=r.get(n),t=r.getStyle(n,"width"),i=r.getStyle(n,"height"),-1===t.indexOf("px")&&(t=0),-1===i.indexOf("px")&&(i=0),{w:parseInt(t,10)||n.offsetWidth||n.clientWidth,h:parseInt(i,10)||n.offsetHeight||n.clientHeight}},getParent:function(n,t,i){return this.getParents(n,t,i,!1)},getParents:function(n,i,r,u){var f=this,e,o=[];for(n=f.get(n),u=u===t,r=r||("BODY"!=f.getRoot().nodeName?f.getRoot().parentNode:null),y(i,"string")&&(e=i,i="*"===i?function(n){return 1==n.nodeType}:function(n){return f.is(n,e)});n&&n!=r&&n.nodeType&&9!==n.nodeType;){if(!i||i(n)){if(!u)return n;o.push(n)}n=n.parentNode}return u?o:null},get:function(n){var t;return n&&this.doc&&"string"==typeof n&&(t=n,n=this.doc.getElementById(n),n&&n.id!==t)?this.doc.getElementsByName(t)[1]:n},getNext:function(n,t){return this._findSib(n,t,"nextSibling")},getPrev:function(n,t){return this._findSib(n,t,"previousSibling")},select:function(t,i){var r=this;return n(t,r.get(i)||r.settings.root_element||r.doc,[])},is:function(i,r){var u,f;if(i.length===t){if("*"===r)return 1==i.nodeType;if(g.test(r)){for(r=r.toLowerCase().split(/,/),i=i.nodeName.toLowerCase(),u=r.length-1;u>=0;u--)if(r[u]==i)return!0;return!1}}return i.nodeType&&1!=i.nodeType?!1:(f=i.nodeType?[i]:i,n(r,f[0].ownerDocument||f[0],null,f).length>0)},add:function(n,t,i,r,u){var f=this;return this.run(n,function(n){var e;return e=y(t,"string")?f.doc.createElement(t):t,f.setAttribs(e,i),r&&(r.nodeType?e.appendChild(r):f.setHTML(e,r)),u?e:n.appendChild(e)})},create:function(n,t,i){return this.add(this.doc.createElement(n),n,t,i,1)},createHTML:function(n,t,i){var u="",r;u+="<"+n;for(r in t)t.hasOwnProperty(r)&&null!==t[r]&&"undefined"!=typeof t[r]&&(u+=" "+r+'="'+this.encode(t[r])+'"');return"undefined"!=typeof i?u+">"+i+"<\/"+n+">":u+" />"},createFragment:function(n){var t,r,u=this.doc,i;for(i=u.createElement("div"),t=u.createDocumentFragment(),n&&(i.innerHTML=n);r=i.firstChild;)t.appendChild(r);return t},remove:function(n,t){return n=this.$$(n),t?n.each(function(){for(var n;n=this.firstChild;)3==n.nodeType&&0===n.data.length?this.removeChild(n):this.parentNode.insertBefore(n,this)}).remove():n.remove(),n.length>1?n.toArray():n[0]},setStyle:function(n,t,i){n=this.$$(n).css(t,i);this.settings.update_styles&&p(this,n)},getStyle:function(n,i,r){return n=this.$$(n),r?n.css(i):(i=i.replace(/-(\D)/g,function(n,t){return t.toUpperCase()}),"float"==i&&(i=s.ie&&s.ie<12?"styleFloat":"cssFloat"),n[0]&&n[0].style?n[0].style[i]:t)},setStyles:function(n,t){n=this.$$(n).css(t);this.settings.update_styles&&p(this,n)},removeAllAttribs:function(n){return this.run(n,function(n){for(var i=n.attributes,t=i.length-1;t>=0;t--)n.removeAttributeNode(i.item(t))})},setAttrib:function(n,t,i){var u=this,f,r,e=u.settings;""===i&&(i=null);n=u.$$(n);f=n.attr(t);n.length&&(r=u.attrHooks[t],r&&r.set?r.set(n,i,t):n.attr(t,i),f!=i&&e.onSetAttrib&&e.onSetAttrib({attrElm:n,attrName:t,attrValue:i}))},setAttribs:function(n,t){var i=this;i.$$(n).each(function(n,r){v(t,function(n,t){i.setAttrib(r,t,n)})})},getAttrib:function(n,t,i){var f=this,r,u;return n=f.$$(n),n.length&&(r=f.attrHooks[t],u=r&&r.get?r.get(n,t):n.attr(t)),"undefined"==typeof u&&(u=i||""),u},getPos:function(n,t){var s=this,f=0,e=0,r,o=s.doc,u=o.body,h;if(n=s.get(n),t=t||u,n){if(t===u&&n.getBoundingClientRect&&"static"===i(u).css("position"))return h=n.getBoundingClientRect(),t=s.boxModel?o.documentElement:u,f=h.left+(o.documentElement.scrollLeft||u.scrollLeft)-t.clientLeft,e=h.top+(o.documentElement.scrollTop||u.scrollTop)-t.clientTop,{x:f,y:e};for(r=n;r&&r!=t&&r.nodeType;)f+=r.offsetLeft||0,e+=r.offsetTop||0,r=r.offsetParent;for(r=n.parentNode;r&&r!=t&&r.nodeType;)f-=r.scrollLeft||0,e-=r.scrollTop||0,r=r.parentNode}return{x:f,y:e}},parseStyle:function(n){return this.styles.parse(n)},serializeStyle:function(n,t){return this.styles.serialize(n,t)},addStyle:function(n){var f=this,r=f.doc,u,t,i;if(f!==l.DOM&&r===document){if(i=l.DOM.addedStyles,i=i||[],i[n])return;i[n]=!0;l.DOM.addedStyles=i}t=r.getElementById("mceDefaultStyles");t||(t=r.createElement("style"),t.id="mceDefaultStyles",t.type="text/css",u=r.getElementsByTagName("head")[0],u.firstChild?u.insertBefore(t,u.firstChild):u.appendChild(t));t.styleSheet?t.styleSheet.cssText+=n:t.appendChild(r.createTextNode(n))},loadCSS:function(n){var i=this,t=i.doc,r;return i!==l.DOM&&t===document?void l.DOM.loadCSS(n):(n||(n=""),r=t.getElementsByTagName("head")[0],void v(n.split(","),function(n){var u;n=h._addCacheSuffix(n);i.files[n]||(i.files[n]=!0,u=i.create("link",{rel:"stylesheet",href:n}),a&&t.documentMode&&t.recalc&&(u.onload=function(){t.recalc&&t.recalc();u.onload=null}),r.appendChild(u))}))},addClass:function(n,t){this.$$(n).addClass(t)},removeClass:function(n,t){this.toggleClass(n,t,!1)},hasClass:function(n,t){return this.$$(n).hasClass(t)},toggleClass:function(n,t,r){this.$$(n).toggleClass(t,r).each(function(){""===this.className&&i(this).attr("class",null)})},show:function(n){this.$$(n).show()},hide:function(n){this.$$(n).hide()},isHidden:function(n){return"none"==this.$$(n).css("display")},uniqueId:function(n){return(n?n:"mce_")+this.counter++},setHTML:function(n,t){n=this.$$(n);a?n.each(function(n,r){if(r.canHaveHTML!==!1){for(;r.firstChild;)r.removeChild(r.firstChild);try{r.innerHTML="<br>"+t;r.removeChild(r.firstChild)}catch(u){i("<div>").html("<br>"+t).contents().slice(1).appendTo(r)}return t}}):n.html(t)},getOuterHTML:function(n){return n=this.get(n),1==n.nodeType&&"outerHTML"in n?n.outerHTML:i("<div>").append(i(n).clone()).html()},setOuterHTML:function(n,t){var r=this;r.$$(n).each(function(){try{if("outerHTML"in this)return void(this.outerHTML=t)}catch(n){}r.remove(i(this).html(t),!0)})},decode:o.decode,encode:o.encodeAllRaw,insertAfter:function(n,t){return t=this.get(t),this.run(n,function(n){var i,r;return i=t.parentNode,r=t.nextSibling,r?i.insertBefore(n,r):i.appendChild(n),n})},replace:function(n,t,i){var r=this;return r.run(t,function(t){return y(t,"array")&&(n=n.cloneNode(!0)),i&&v(k(t.childNodes),function(t){n.appendChild(t)}),t.parentNode.replaceChild(n,t)})},rename:function(n,t){var i=this,r;return n.nodeName!=t.toUpperCase()&&(r=i.create(t),v(i.getAttribs(n),function(t){i.setAttrib(r,t.nodeName,i.getAttrib(n,t.nodeName))}),i.replace(r,n,1)),r||n},findCommonAncestor:function(n,t){for(var i=n,r;i;){for(r=t;r&&i!=r;)r=r.parentNode;if(i==r)break;i=i.parentNode}return!i&&n.ownerDocument?n.ownerDocument.documentElement:i},toHex:function(n){return this.styles.toHex(h.trim(n))},run:function(n,t,i){var u=this,r;return"string"==typeof n&&(n=u.get(n)),n?(i=i||this,n.nodeType||!n.length&&0!==n.length?t.call(i,n):(r=[],v(n,function(n,f){n&&("string"==typeof n&&(n=u.get(n)),r.push(t.call(i,n,f)))}),r)):!1},getAttribs:function(n){var t,i;return(n=this.get(n),!n)?[]:a?(t=[],"OBJECT"==n.nodeName)?n.attributes:("OPTION"===n.nodeName&&this.getAttrib(n,"selected")&&t.push({specified:1,nodeName:"selected"}),i=/<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi,n.cloneNode(!1).outerHTML.replace(i,"").replace(/[\w:\-]+/gi,function(n){t.push({specified:1,nodeName:n})}),t):n.attributes},isEmpty:function(n,t){var u=this,e,o,r,s,i,h=0;if(n=n.firstChild){s=new f(n,n.parentNode);t=t||(u.schema?u.schema.getNonEmptyElements():null);do{if(r=n.nodeType,1===r){if(n.getAttribute("data-mce-bogus"))continue;if(i=n.nodeName.toLowerCase(),t&&t[i]){if("br"===i){h++;continue}return!1}for(o=u.getAttribs(n),e=o.length;e--;)if(i=o[e].nodeName,"name"===i||"data-mce-bookmark"===i)return!1}if(8==r||3===r&&!nt.test(n.nodeValue))return!1}while(n=s.next())}return 1>=h},createRng:function(){var n=this.doc;return n.createRange?n.createRange():new e(this)},nodeIndex:w,split:function(n,t,i){function e(n){function o(n){var t=n.previousSibling&&"SPAN"==n.previousSibling.nodeName,i=n.nextSibling&&"SPAN"==n.nextSibling.nodeName;return t&&i}var i,t=n.childNodes,u=n.nodeType,f;if(1!=u||"bookmark"!=n.getAttribute("data-mce-type")){for(i=t.length-1;i>=0;i--)e(t[i]);if(9!=u){if(3==u&&n.nodeValue.length>0){if(f=d(n.nodeValue).length,!r.isBlock(n.parentNode)||f>0||0===f&&o(n))return}else if(1==u&&(t=n.childNodes,1==t.length&&t[0]&&1==t[0].nodeType&&"bookmark"==t[0].getAttribute("data-mce-type")&&n.parentNode.insertBefore(t[0],n),t.length||/^(br|hr|input|img)$/i.test(n.nodeName)))return;r.remove(n)}return n}}var r=this,u=r.createRng(),o,s,f;if(n&&t)return(u.setStart(n.parentNode,r.nodeIndex(n)),u.setEnd(t.parentNode,r.nodeIndex(t)),o=u.extractContents(),u=r.createRng(),u.setStart(t.parentNode,r.nodeIndex(t)+1),u.setEnd(n.parentNode,r.nodeIndex(n)+1),s=u.extractContents(),f=n.parentNode,f.insertBefore(e(o),n),i?f.insertBefore(i,n):f.insertBefore(t,n),f.insertBefore(e(s),n),r.remove(n),i||t)},bind:function(n,t,i,r){var u=this,f;if(h.isArray(n)){for(f=n.length;f--;)n[f]=u.bind(n[f],t,i,r);return n}return!u.settings.collect||n!==u.doc&&n!==u.win||u.boundEvents.push([n,t,i,r]),u.events.bind(n,t,i,r||u)},unbind:function(n,t,i){var f=this,r,u;if(h.isArray(n)){for(r=n.length;r--;)n[r]=f.unbind(n[r],t,i);return n}if(f.boundEvents&&(n===f.doc||n===f.win))for(r=f.boundEvents.length;r--;)u=f.boundEvents[r],n!=u[0]||t&&t!=u[1]||i&&i!=u[2]||this.events.unbind(u[0],u[1],u[2]);return this.events.unbind(n,t,i)},fire:function(n,t,i){return this.events.fire(n,t,i)},getContentEditable:function(n){var t;return n&&1==n.nodeType?(t=n.getAttribute("data-mce-contenteditable"),t&&"inherit"!==t?t:"inherit"!==n.contentEditable?n.contentEditable:null):null},getContentEditableParent:function(n){for(var i=this.getRoot(),t=null;n&&n!==i&&(t=this.getContentEditable(n),null===t);n=n.parentNode);return t},destroy:function(){var t=this,r,i;if(t.boundEvents){for(r=t.boundEvents.length;r--;)i=t.boundEvents[r],this.events.unbind(i[0],i[1],i[2]);t.boundEvents=null}n.setDocument&&n.setDocument();t.win=t.doc=t.root=t.events=t.frag=null},isChildOf:function(n,t){for(;n;){if(t===n)return!0;n=n.parentNode}return!1},dumpRng:function(n){return"startContainer: "+n.startContainer.nodeName+", startOffset: "+n.startOffset+", endContainer: "+n.endContainer.nodeName+", endOffset: "+n.endOffset},_findSib:function(n,t,i){var u=this,r=t;if(n)for("string"==typeof r&&(r=function(n){return u.is(n,t)}),n=n[i];n;n=n[i])if(r(n))return n;return null}},l.DOM=new l(document),l.nodeIndex=w,l});i(vt,[h,r],function(n,t){function i(){function a(n,i){function e(){o.remove(f);r&&(r.onreadystatechange=r.onload=r=null);i()}function s(){"undefined"!=typeof console&&console.log&&console.log("Failed to load: "+n)}var o=u,r,f;f=o.uniqueId();r=document.createElement("script");r.id=f;r.type="text/javascript";r.src=t._addCacheSuffix(n);"onreadystatechange"in r?r.onreadystatechange=function(){/loaded|complete/.test(r.readyState)&&e()}:r.onload=e;r.onerror=s;(document.getElementsByTagName("head")[0]||document.body).appendChild(r)}var v=0,h=1,e=2,n={},c=[],i={},o=[],s=0,l;this.isDone=function(t){return n[t]==e};this.markDone=function(t){n[t]=e};this.add=this.load=function(t,r,u){var f=n[t];f==l&&(c.push(t),n[t]=v);r&&(i[t]||(i[t]=[]),i[t].push({func:r,scope:u||this}))};this.remove=function(t){delete n[t];delete i[t]};this.loadQueue=function(n,t){this.loadScripts(c,n,t)};this.loadScripts=function(t,u,c){function v(n){r(i[n],function(n){n.func.call(n.scope)});i[n]=l}var y;o.push({func:u,scope:c||this});(y=function(){var i=f(t);t.length=0;r(i,function(t){return n[t]==e?void v(t):void(n[t]!=h&&(n[t]=h,s++,a(t,function(){n[t]=e;s--;v(t);y()})))});s||(r(o,function(n){n.func.call(n.scope)}),o.length=0)})()}}var u=n.DOM,r=t.each,f=t.grep;return i.ScriptLoader=new i,i});i(ti,[vt,r],function(n,i){function r(){var n=this;n.items=[];n.urls={};n.lookup={}}var u=i.each;return r.prototype={get:function(n){return this.lookup[n]?this.lookup[n].instance:t},dependencies:function(n){var t;return this.lookup[n]&&(t=this.lookup[n].dependencies),t||[]},requireLangPack:function(t,i){var u=r.language;if(u&&r.languageLoad!==!1){if(i)if(i=","+i+",",-1!=i.indexOf(","+u.substr(0,2)+","))u=u.substr(0,2);else if(-1==i.indexOf(","+u+","))return;n.ScriptLoader.add(this.urls[t]+"/langs/"+u+".js")}},add:function(n,t,i){return this.items.push(t),this.lookup[n]={instance:t,dependencies:i},t},remove:function(n){delete this.urls[n];delete this.lookup[n]},createUrl:function(n,t){return"object"==typeof t?t:{prefix:n.prefix,resource:t,suffix:n.suffix}},addComponents:function(t,i){var r=this.urls[t];u(i,function(t){n.ScriptLoader.add(r+"/"+t)})},load:function(i,f,e,o){function c(){var r=h.dependencies(i);u(r,function(n){var i=h.createUrl(f,n);h.load(i.resource,i,t,t)});e&&(o?e.call(o):e.call(n))}var h=this,s=f;h.urls[i]||("object"==typeof f&&(s=f.prefix+f.resource+f.suffix),0!==s.indexOf("/")&&-1==s.indexOf("://")&&(s=r.baseURL+"/"+s),h.urls[i]=s.substring(0,s.lastIndexOf("/")),h.lookup[i]?c():n.ScriptLoader.add(s,c,o))}},r.PluginManager=new r,r.ThemeManager=new r,r});i(e,[],function(){function t(n){return function(t){return!!t&&t.nodeType==n}}function i(n){return n=n.toLowerCase().split(" "),function(t){var i,r;if(t&&t.nodeType)for(r=t.nodeName.toLowerCase(),i=0;i<n.length;i++)if(r===n[i])return!0;return!1}}function u(t,i){return i=i.toLowerCase().split(" "),function(r){var u,f;if(n(r))for(u=0;u<i.length;u++)if(f=getComputedStyle(r,null).getPropertyValue(t),f===i[u])return!0;return!1}}function f(t,i){return function(r){return n(r)&&r[t]===i}}function e(t,i){return function(r){return n(r)&&r.getAttribute(t)===i}}function o(t){return n(t)&&t.hasAttribute("data-mce-bogus")}function r(t){return function(i){return n(i)&&(i.contentEditable===t||i.getAttribute("data-mce-contenteditable")===t)?!0:!1}}var n=t(1);return{isText:t(3),isElement:n,isComment:t(8),isBr:i("br"),isContentEditableTrue:r("true"),isContentEditableFalse:r("false"),matchNodeNames:i,hasPropValue:f,hasAttributeValue:e,matchStyleValues:u,isBogus:o}});i(ii,[],function(){function t(t){return t==n}function i(t){return t.replace(new RegExp(n,"g"),"")}var n="​";return{isZwsp:t,ZWSP:n,trim:i}});i(w,[e,ii],function(n,t){function u(n){return i(n)&&(n=n.parentNode),s(n)&&n.hasAttribute("data-mce-caret")}function f(n){return i(n)&&t.isZwsp(n.data)}function r(n){return u(n)||f(n)}function h(n,u){var c,f,s,h;if(c=n.ownerDocument,s=c.createTextNode(t.ZWSP),h=n.parentNode,u){if(f=n.previousSibling,i(f)){if(r(f))return f;if(o(f))return f.splitText(f.data.length-1)}h.insertBefore(s,n)}else{if(f=n.nextSibling,i(f)){if(r(f))return f;if(e(f))return f.splitText(1),f}n.nextSibling?h.insertBefore(s,n.nextSibling):h.appendChild(s)}return s}function c(n,t,i){var f,r,u;return f=t.ownerDocument,r=f.createElement(n),r.setAttribute("data-mce-caret",i?"before":"after"),r.setAttribute("data-mce-bogus","all"),r.appendChild(f.createTextNode(" ")),u=t.parentNode,i?u.insertBefore(r,t):t.nextSibling?u.insertBefore(r,t.nextSibling):u.appendChild(r),r}function l(n){var u;s(n)&&r(n)&&("&nbsp;"!=n.innerHTML?n.removeAttribute("data-mce-caret"):n.parentNode&&n.parentNode.removeChild(n));i(n)&&(u=t.trim(n.data),0===u.length&&n.parentNode&&n.parentNode.removeChild(n),n.nodeValue=u)}function e(n){return i(n)&&n.data[0]==t.ZWSP}function o(n){return i(n)&&n.data[n.data.length-1]==t.ZWSP}var s=n.isElement,i=n.isText;return{isCaretContainer:r,isCaretContainerBlock:u,isCaretContainerInline:f,insertInline:h,insertBlock:c,remove:l,startsWithCaretContainer:e,endsWithCaretContainer:o}});i(y,[r,p,e,w],function(n,t,i,r){function o(n,t){var i=n.childNodes;return t--,t>i.length-1?t=i.length-1:0>t&&(t=0),i[t]||n}function u(n){this.walk=function(t,i){function v(n){var t;return t=n[0],3===t.nodeType&&t===u&&k>=t.nodeValue.length&&n.splice(0,1),t=n[n.length-1],0===d&&n.length>0&&t===f&&3===t.nodeType&&n.splice(n.length-1,1),n}function w(n,t,i){for(var r=[];n&&n!=i;n=n[t])r.push(n);return r}function b(n,t){do{if(n.parentNode==t)return n;n=n.parentNode}while(n)}function a(n,t,u){var f=u?"nextSibling":"previousSibling";for(r=n,y=r.parentNode;r&&r!=t;r=y)y=r.parentNode,s=w(r==n?r:r[f],f),s.length&&(u||s.reverse(),i(v(s)))}var u=t.startContainer,k=t.startOffset,f=t.endContainer,d=t.endOffset,e,c,l,r,y,s,p;if(p=n.select("td[data-mce-selected],th[data-mce-selected]"),p.length>0)return void h(p,function(n){i([n])});if(1==u.nodeType&&u.hasChildNodes()&&(u=u.childNodes[k]),1==f.nodeType&&f.hasChildNodes()&&(f=o(f,d)),u==f)return i(v([u]));for(e=n.findCommonAncestor(u,f),r=u;r;r=r.parentNode){if(r===f)return a(u,e,!0);if(r===e)break}for(r=f;r;r=r.parentNode){if(r===u)return a(f,e);if(r===e)break}c=b(u,e)||u;l=b(f,e)||f;a(u,c,!0);s=w(c==u?c:c.nextSibling,"nextSibling",l==f?l.nextSibling:l);s.length&&i(v(s));a(f,l)};this.split=function(n){function f(n,t){return n.splitText(t)}var i=n.startContainer,r=n.startOffset,t=n.endContainer,u=n.endOffset;return i==t&&3==i.nodeType?r>0&&r<i.nodeValue.length&&(t=f(i,r),i=t.previousSibling,u>r?(u-=r,i=t=f(t,u).previousSibling,u=t.nodeValue.length,r=0):u=0):(3==i.nodeType&&r>0&&r<i.nodeValue.length&&(i=f(i,r),r=0),3==t.nodeType&&u>0&&u<t.nodeValue.length&&(t=f(t,u).previousSibling,u=t.nodeValue.length)),{startContainer:i,startOffset:r,endContainer:t,endOffset:u}};this.normalize=function(i){function o(o){function k(n){return n&&/^(TD|TH|CAPTION)$/.test(n.nodeName)}function w(i,r){for(var u=new t(i,n.getParent(i.parentNode,n.isBlock)||a);i=u[r?"prev":"next"]();)if("BR"===i.nodeName)return!0}function d(n){for(;n&&n!=a;){if(e(n))return!0;n=n.parentNode}return!1}function g(n,t){return n.previousSibling&&n.previousSibling.nodeName==t}function y(i,e){var y,o,l;if(e=e||h,l=n.getParent(e.parentNode,n.isBlock)||a,i&&"BR"==e.nodeName&&b&&n.isEmpty(l))return h=e.parentNode,c=n.nodeIndex(e),void(r=!0);for(y=new t(e,l);s=y[i?"prev":"next"]();){if("false"===n.getContentEditableParent(s)||f(s))return;if(3===s.nodeType&&s.nodeValue.length>0)return h=s,c=i?s.nodeValue.length:0,void(r=!0);if(n.isBlock(s)||v[s.nodeName.toLowerCase()])return;o=s}u&&o&&(h=o,r=!0,c=0)}var h,c,p,a=n.getRoot(),s,v,l,b;if(h=i[(o?"start":"end")+"Container"],c=i[(o?"start":"end")+"Offset"],b=1==h.nodeType&&c===h.childNodes.length,v=n.schema.getNonEmptyElements(),l=o,!f(h)){if(1==h.nodeType&&c>h.childNodes.length-1&&(l=!1),9===h.nodeType&&(h=n.getRoot(),c=0),h===a){if(l&&(s=h.childNodes[c>0?c-1:0])){if(f(s))return;if(v[s.nodeName]||"TABLE"==s.nodeName)return}if(h.hasChildNodes()){if(c=Math.min(!l&&c>0?c-1:c,h.childNodes.length-1),h=h.childNodes[c],c=0,!u&&h===a.lastChild&&"TABLE"===h.nodeName)return;if(d(h)||f(h))return;if(h.hasChildNodes()&&!/TABLE/.test(h.nodeName)){s=h;p=new t(h,a);do{if(e(s)||f(s)){r=!1;break}if(3===s.nodeType&&s.nodeValue.length>0){c=l?0:s.nodeValue.length;h=s;r=!0;break}if(v[s.nodeName.toLowerCase()]&&!k(s)){c=n.nodeIndex(s);h=s.parentNode;"IMG"!=s.nodeName||l||c++;r=!0;break}}while(s=l?p.next():p.prev())}}}u&&(3===h.nodeType&&0===c&&y(!0),1===h.nodeType&&(s=h.childNodes[c],s||(s=h.childNodes[c-1]),!s||"BR"!==s.nodeName||g(s,"A")||w(s)||w(s,!0)||y(!0,s)));l&&!u&&3===h.nodeType&&c===h.nodeValue.length&&y(!1);r&&i["set"+(o?"Start":"End")](h,c)}}var r,u;return u=i.collapsed,o(!0),u||o(),r&&u&&i.collapse(!0),r}}function s(t,i,r){var e,u,f;if(e=r.elementFromPoint(t,i),u=r.body.createTextRange(),e&&"HTML"!=e.tagName||(e=r.body),u.moveToElementText(e),f=n.toArray(u.getClientRects()),f=f.sort(function(n,t){return n=Math.abs(Math.max(n.top-i,n.bottom-i)),t=Math.abs(Math.max(t.top-i,t.bottom-i)),n-t}),f.length>0){i=(f[0].bottom+f[0].top)/2;try{return u.moveToPoint(t,i),u.collapse(!0),u}catch(o){}}return null}var h=n.each,e=i.isContentEditableFalse,f=r.isCaretContainer;return u.compareRanges=function(n,t){if(n&&t){if(!n.item&&!n.duplicate)return n.startContainer==t.startContainer&&n.startOffset==t.startOffset;if(n.item&&t.item&&n.item(0)===t.item(0)||n.isEqual&&t.isEqual&&t.isEqual(n))return!0}return!1},u.getCaretRangeFromPoint=function(n,t,i){var r,u;if(i.caretPositionFromPoint)u=i.caretPositionFromPoint(n,t),r=i.createRange(),r.setStart(u.offsetNode,u.offset),r.collapse(!0);else if(i.caretRangeFromPoint)r=i.caretRangeFromPoint(n,t);else if(i.body.createTextRange){r=i.body.createTextRange();try{r.moveToPoint(n,t);r.collapse(!0)}catch(f){r=s(n,t,i)}}return r},u.getSelectedNode=function(n){var t=n.startContainer,i=n.startOffset;return t.hasChildNodes()&&n.endOffset==i+1?t.childNodes[i]:null},u.getNode=function(n,t){return 1==n.nodeType&&n.hasChildNodes()&&(t>=n.childNodes.length&&(t=n.childNodes.length-1),n=n.childNodes[t]),n},u});i(wu,[y,u,f],function(n,t,i){return function(r){function e(n){var t,i;if(i=r.$(n).parentsUntil(r.getBody()).add(n),i.length===u.length){for(t=i.length;t>=0&&i[t]===u[t];t--);if(-1===t)return u=i,!0}return u=i,!1}var f,u=[];"onselectionchange"in r.getDoc()||r.on("NodeChange Click MouseUp KeyUp Focus",function(t){var i,u;i=r.selection.getRng();u={startContainer:i.startContainer,startOffset:i.startOffset,endContainer:i.endContainer,endOffset:i.endOffset};"nodechange"!=t.type&&n.compareRanges(u,f)||r.fire("SelectionChange");f=u});r.on("contextmenu",function(){r.fire("SelectionChange")});r.on("SelectionChange",function(){var n=r.selection.getStart(!0);!t.range&&r.selection.isCollapsed()||!e(n)&&r.dom.isChildOf(n,r.getBody())&&r.nodeChanged({selectionChange:!0})});r.on("MouseUp",function(n){n.isDefaultPrevented()||("IMG"==r.selection.getNode().nodeName?i.setEditorTimeout(r,function(){r.nodeChanged()}):r.nodeChanged())});this.nodeChanged=function(n){var u=r.selection,t,f,i;r.initialized&&u&&!r.settings.disable_nodechange&&!r.readonly&&(i=r.getBody(),t=u.getStart()||i,t.ownerDocument==r.getDoc()&&r.dom.isChildOf(t,i)||(t=i),"IMG"==t.nodeName&&u.isCollapsed()&&(t=t.parentNode),f=[],r.dom.getParent(t,function(n){return n===i?!0:void f.push(n)}),n=n||{},n.element=t,n.parents=f,r.fire("NodeChange",n))}}});i(et,[],function(){function t(n,t,i){var u,r,f=i?"lastChild":"firstChild",e=i?"prev":"next";if(n[f])return n[f];if(n!==t){if(u=n[e])return u;for(r=n.parent;r&&r!==t;r=r.parent)if(u=r[e])return u}}function n(n,t){this.name=n;this.type=t;1===t&&(this.attributes=[],this.attributes.map={})}var i=/^[ \t\r\n]*$/,r={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11};return n.prototype={replace:function(n){var t=this;return n.parent&&n.remove(),t.insert(n,t),t.remove(),t},attr:function(n,t){var u=this,i,r,f;if("string"!=typeof n){for(r in n)u.attr(r,n[r]);return u}if(i=u.attributes){if(t!==f){if(null===t){if(n in i.map)for(delete i.map[n],r=i.length;r--;)if(i[r].name===n)return i=i.splice(r,1),u;return u}if(n in i.map){for(r=i.length;r--;)if(i[r].name===n){i[r].value=t;break}}else i.push({name:n,value:t});return i.map[n]=t,u}return i.map[n]}},clone:function(){var r=this,u=new n(r.name,r.type),f,o,e,t,i;if(e=r.attributes){for(i=[],i.map={},f=0,o=e.length;o>f;f++)t=e[f],"id"!==t.name&&(i[i.length]={name:t.name,value:t.value},i.map[t.name]=t.value);u.attributes=i}return u.value=r.value,u.shortEnded=r.shortEnded,u},wrap:function(n){var t=this;return t.parent.insert(n,t),n.append(t),t},unwrap:function(){for(var t=this,i,n=t.firstChild;n;)i=n.next,t.insert(n,t,!0),n=i;t.remove()},remove:function(){var n=this,t=n.parent,i=n.next,r=n.prev;return t&&(t.firstChild===n?(t.firstChild=i,i&&(i.prev=null)):r.next=i,t.lastChild===n?(t.lastChild=r,r&&(r.next=null)):i.prev=r,n.parent=n.next=n.prev=null),n},append:function(n){var t=this,i;return n.parent&&n.remove(),i=t.lastChild,i?(i.next=n,n.prev=i,t.lastChild=n):t.lastChild=t.firstChild=n,n.parent=t,n},insert:function(n,t,i){var r;return n.parent&&n.remove(),r=t.parent||this,i?(t===r.firstChild?r.firstChild=n:t.prev.next=n,n.prev=t.prev,n.next=t,t.prev=n):(t===r.lastChild?r.lastChild=n:t.next.prev=n,n.next=t.next,n.prev=t,t.next=n),n.parent=r,n},getAll:function(n){for(var r=this,u=[],i=r.firstChild;i;i=t(i,r))i.name===n&&u.push(i);return u},empty:function(){var i=this,r,u,n;if(i.firstChild){for(r=[],n=i.firstChild;n;n=t(n,i))r.push(n);for(u=r.length;u--;)n=r[u],n.parent=n.firstChild=n.lastChild=n.next=n.prev=null}return i.firstChild=i.lastChild=null,i},isEmpty:function(n){var e=this,r=e.firstChild,u,f;if(r)do{if(1===r.type){if(r.attributes.map["data-mce-bogus"])continue;if(n[r.name])return!1;for(u=r.attributes.length;u--;)if(f=r.attributes[u].name,"name"===f||0===f.indexOf("data-mce-bookmark"))return!1}if(8===r.type||3===r.type&&!i.test(r.value))return!1}while(r=t(r,e));return!0},walk:function(n){return t(this,null,n)}},n.create=function(t,i){var u,f;if(u=new n(t,r[t]||1),i)for(f in i)u.attr(f,i[f]);return u},n});i(g,[r],function(n){function t(n,t){return n?n.split(t||" "):[]}function s(n){function u(n,i,r){function c(n,t){for(var r={},i=0,u=n.length;u>i;i++)r[n[i]]=t||{};return r}var e,u,o,f=arguments;for(r=r||[],i=i||"","string"==typeof r&&(r=t(r)),u=3;u<f.length;u++)"string"==typeof f[u]&&(f[u]=t(f[u])),r.push.apply(r,f[u]);for(n=t(n),e=n.length;e--;)o=[].concat(l,t(i)),s[n[e]]={attributes:c(o),attributesOrder:o,children:c(r,h)}}function f(n,i){var u,f,r,e;for(n=t(n),u=n.length,i=t(i);u--;)for(f=s[n[u]],r=0,e=i.length;e>r;r++)f.attributes[i[r]]={},f.attributesOrder.push(i[r])}var s={},l,c,o,e,a,v;return r[n]?r[n]:(l=t("id accesskey class dir lang style tabindex title"),c=t("address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul"),o=t("a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment"),"html4"!=n&&(l.push.apply(l,t("contenteditable contextmenu draggable dropzone hidden spellcheck translate")),c.push.apply(c,t("article aside details dialog figure header footer hgroup section nav")),o.push.apply(o,t("audio canvas command datalist mark meter output picture progress time wbr video ruby bdi keygen"))),"html5-strict"!=n&&(l.push("xml:lang"),v=t("acronym applet basefont big font strike tt"),o.push.apply(o,v),i(v,function(n){u(n,"",o)}),a=t("center dir isindex noframes"),c.push.apply(c,a),e=[].concat(c,o),i(a,function(n){u(n,"",e)})),e=e||[].concat(c,o),u("html","manifest","head body"),u("head","","base command link meta noscript script style title"),u("title hr noscript br"),u("base","href target"),u("link","href rel media hreflang type sizes hreflang"),u("meta","name http-equiv content charset"),u("style","media type scoped"),u("script","src async defer type charset"),u("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",e),u("address dt dd div caption","",e),u("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",o),u("blockquote","cite",e),u("ol","reversed start type","li"),u("ul","","li"),u("li","value",e),u("dl","","dt dd"),u("a","href target rel media hreflang type",o),u("q","cite",o),u("ins del","cite datetime",e),u("img","src sizes srcset alt usemap ismap width height"),u("iframe","src name width height",e),u("embed","src type width height"),u("object","data type typemustmatch name usemap form width height",e,"param"),u("param","name value"),u("map","name",e,"area"),u("area","alt coords shape href target rel media hreflang type"),u("table","border","caption colgroup thead tfoot tbody tr"+("html4"==n?" col":"")),u("colgroup","span","col"),u("col","span"),u("tbody thead tfoot","","tr"),u("tr","","td th"),u("td","colspan rowspan headers",e),u("th","colspan rowspan headers scope abbr",e),u("form","accept-charset action autocomplete enctype method name novalidate target",e),u("fieldset","disabled form name",e,"legend"),u("label","form for",o),u("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),u("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"==n?e:o),u("select","disabled form multiple name required size","option optgroup"),u("optgroup","disabled label","option"),u("option","disabled label selected value"),u("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),u("menu","type label",e,"li"),u("noscript","",e),"html4"!=n&&(u("wbr"),u("ruby","",o,"rt rp"),u("figcaption","",e),u("mark rt rp summary bdi","",o),u("canvas","width height",e),u("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",e,"track source"),u("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",e,"track source"),u("picture","","img source"),u("source","src srcset type media sizes"),u("track","kind src srclang label default"),u("datalist","",o,"option"),u("article section nav aside header footer","",e),u("hgroup","","h1 h2 h3 h4 h5 h6"),u("figure","",e,"figcaption"),u("time","datetime",o),u("dialog","open",e),u("command","type label icon disabled checked radiogroup command"),u("output","for form name",o),u("progress","value max",o),u("meter","value min max low high optimum",o),u("details","open",e,"summary"),u("keygen","autofocus challenge disabled form keytype name")),"html5-strict"!=n&&(f("script","language xml:space"),f("style","xml:space"),f("object","declare classid code codebase codetype archive standby align border hspace vspace"),f("embed","align name hspace vspace"),f("param","valuetype type"),f("a","charset name rev shape coords"),f("br","clear"),f("applet","codebase archive code object alt name width height align hspace vspace"),f("img","name longdesc align border hspace vspace"),f("iframe","longdesc frameborder marginwidth marginheight scrolling align"),f("font basefont","size color face"),f("input","usemap align"),f("select","onchange"),f("textarea"),f("h1 h2 h3 h4 h5 h6 div p legend caption","align"),f("ul","type compact"),f("li","type"),f("ol dl menu dir","compact"),f("pre","width xml:space"),f("hr","align noshade size width"),f("isindex","prompt"),f("table","summary width frame rules cellspacing cellpadding align bgcolor"),f("col","width align char charoff valign"),f("colgroup","width align char charoff valign"),f("thead","align char charoff valign"),f("tr","align char charoff valign bgcolor"),f("th","axis align char charoff valign nowrap bgcolor width height"),f("form","accept"),f("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),f("tfoot","align char charoff valign"),f("tbody","align char charoff valign"),f("area","nohref"),f("body","background bgcolor text link vlink alink")),"html4"!=n&&(f("input button select textarea","autofocus"),f("input textarea","placeholder"),f("a","download"),f("link script img","crossorigin"),f("iframe","sandbox seamless allowfullscreen")),i(t("a form meter progress dfn"),function(n){s[n]&&delete s[n].children[n]}),delete s.caption.children.table,delete s.script,r[n]=s,s)}function f(n,t){var r;return n&&(r={},"string"==typeof n&&(n={"*":n}),i(n,function(n,i){r[i]=r[i.toUpperCase()]="map"==t?u(n,/[, ]/):o(n,/[, ]/)})),r}var r={},h={},u=n.makeMap,i=n.each,e=n.extend,o=n.explode,c=n.inArray;return function(n){function v(t,i,f){var o=n[t];return o?o=u(o,/[, ]/,u(o.toUpperCase(),/[, ]/)):(o=r[t],o||(o=u(i," ",u(i.toUpperCase()," ")),o=e(o,f),r[t]=o)),o}function it(n){return new RegExp("^"+n.replace(/([?+*])/g,".$1")+"$")}function y(n){var b,rt,k,ut,r,i,e,a,v,f,d,h,o,s,g,y,nt,tt,w,ft=/[*?+]/;if(n)for(n=t(n,","),l["@"]&&(y=l["@"].attributes,nt=l["@"].attributesOrder),b=0,rt=n.length;rt>b;b++)if(r=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)\])?$/.exec(n[b])){if(s=r[1],v=r[2],g=r[3],a=r[5],h={},o=[],i={attributes:h,attributesOrder:o},"#"===s&&(i.paddEmpty=!0),"-"===s&&(i.removeEmpty=!0),"!"===r[4]&&(i.removeEmptyAttrs=!0),y){for(tt in y)h[tt]=y[tt];o.push.apply(o,nt)}if(a)for(a=t(a,"|"),k=0,ut=a.length;ut>k;k++)if(r=/^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/.exec(a[k])){if(e={},d=r[1],f=r[2].replace(/::/g,":"),s=r[3],w=r[4],"!"===d&&(i.attributesRequired=i.attributesRequired||[],i.attributesRequired.push(f),e.required=!0),"-"===d){delete h[f];o.splice(c(o,f),1);continue}s&&("="===s&&(i.attributesDefault=i.attributesDefault||[],i.attributesDefault.push({name:f,value:w}),e.defaultValue=w),":"===s&&(i.attributesForced=i.attributesForced||[],i.attributesForced.push({name:f,value:w}),e.forcedValue=w),"<"===s&&(e.validValues=u(w,"?")));ft.test(f)?(i.attributePatterns=i.attributePatterns||[],e.pattern=it(f),i.attributePatterns.push(e)):(h[f]||o.push(f),h[f]=e)}y||"@"!=v||(y=h,nt=o);g&&(i.outputName=v,l[g]=i);ft.test(v)?(i.pattern=it(v),p.push(i)):l[v]=i}}function rt(n){l={};p=[];y(n);i(d,function(n,t){a[t]=n.children})}function ut(n){var u=/^(~)?(.+)$/;n&&(r.text_block_elements=r.block_elements=null,i(t(n,","),function(n){var o=u.exec(n),s="~"===o[1],f=s?"span":"div",t=o[2],r;(a[t]=a[f],vt[t]=f,s||(w[t.toUpperCase()]={},w[t]={}),l[t])||(r=l[f],r=e({},r),delete r.removeEmptyAttrs,delete r.removeEmpty,l[t]=r);i(a,function(n,i){n[f]&&(a[i]=n=e({},a[i]),n[t]=n[f])})}))}function b(u){var f=/^([+\-]?)(\w+)\[([^\]]+)\]$/;r[n.schema]=null;u&&i(t(u,","),function(n){var r=f.exec(n),u,e;r&&(e=r[1],u=e?a[r[2]]:a[r[2]]={"#comment":{}},u=a[r[2]],i(t(r[3],"|"),function(n){"-"===e?delete u[n]:u[n]={}}))})}function k(n){var t=l[n],i;if(t)return t;for(i=p.length;i--;)if(t=p[i],t.pattern.test(n))return t}var h=this,l={},a={},p=[],ft,et,d,ot,st,g,ht,ct,w,nt,lt,tt,at,vt={},yt={};n=n||{};d=s(n.schema);n.verify_html===!1&&(n.valid_elements="*[*]");ft=f(n.valid_styles);et=f(n.invalid_styles,"map");ct=f(n.valid_classes,"map");ot=v("whitespace_elements","pre script noscript style textarea video audio iframe object");st=v("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr");g=v("short_ended_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track");ht=v("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls");nt=v("non_empty_elements","td th iframe video audio object script",g);lt=v("move_caret_before_on_enter_elements","table",nt);tt=v("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside nav figure");w=v("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup figcaption",tt);at=v("text_inline_elements","span strong b em i font strike u var cite dfn code mark q sup sub samp");i((n.special||"script noscript style textarea").split(" "),function(n){yt[n]=new RegExp("<\/"+n+"[^>]*>","gi")});n.valid_elements?rt(n.valid_elements):(i(d,function(n,t){l[t]={attributes:n.attributes,attributesOrder:n.attributesOrder};a[t]=n.children}),"html5"!=n.schema&&i(t("strong/b em/i"),function(n){n=t(n,"/");l[n[1]].outputName=n[0]}),i(t("ol ul sub sup blockquote span font a table tbody tr strong em b i"),function(n){l[n]&&(l[n].removeEmpty=!0)}),i(t("p h1 h2 h3 h4 h5 h6 th td pre div address caption"),function(n){l[n].paddEmpty=!0}),i(t("span"),function(n){l[n].removeEmptyAttrs=!0}));ut(n.custom_elements);b(n.valid_children);y(n.extended_valid_elements);b("+ol[ul|ol],+ul[ul|ol]");n.invalid_elements&&i(o(n.invalid_elements),function(n){l[n]&&delete l[n]});k("span")||y("span[!data-mce-type|*]");h.children=a;h.getValidStyles=function(){return ft};h.getInvalidStyles=function(){return et};h.getValidClasses=function(){return ct};h.getBoolAttrs=function(){return ht};h.getBlockElements=function(){return w};h.getTextBlockElements=function(){return tt};h.getTextInlineElements=function(){return at};h.getShortEndedElements=function(){return g};h.getSelfClosingElements=function(){return st};h.getNonEmptyElements=function(){return nt};h.getMoveCaretBeforeOnEnterElements=function(){return lt};h.getWhiteSpaceElements=function(){return ot};h.getSpecialElements=function(){return yt};h.isValidChild=function(n,t){var i=a[n];return!(!i||!i[t])};h.isValid=function(n,t){var i,r,u=k(n);if(u){if(!t||u.attributes[t])return!0;if(i=u.attributePatterns)for(r=i.length;r--;)if(i[r].pattern.test(n))return!0}return!1};h.getElementRule=k;h.getCustomElements=function(){return vt};h.addValidElements=y;h.setValidElements=rt;h.addCustomElements=ut;h.addValidChildren=b;h.elements=l}});i(ri,[g,d,r],function(n,t,i){function r(n,t,i){var f=1,e,r,u,o;for(o=n.getShortEndedElements(),u=/<([!?\/])?([A-Za-z0-9\-_\:\.]+)((?:\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\/|\s+)>/g,u.lastIndex=e=i;r=u.exec(t);){if(e=u.lastIndex,"/"===r[1])f--;else if(!r[1]){if(r[2]in o)continue;f++}if(0===f)break}return e}function u(u,e){function s(){}var o=this;u=u||{};o.schema=e=e||new n;u.fix_self_closing!==!1&&(u.fix_self_closing=!0);f("comment cdata text start end pi doctype".split(" "),function(n){n&&(o[n]=u[n]||s)});o.parse=function(n){function ht(n){for(var i,t=a.length;t--&&a[t].name!==n;);if(t>=0){for(i=a.length-1;i>=t;i--)n=a[i],n.valid&&l.end(n.name);a.length=t}}function gt(n,t,i,r,f){var e,s,o;if(t=t.toLowerCase(),i=t in at?t:st(i||r||f||""),d&&!tt&&0!==t.indexOf("data-")){if(e=vt[t],!e&&it){for(s=it.length;s--&&(e=it[s],!e.pattern.test(t)););-1===s&&(e=null)}if(!e)return;if(e.validValues&&!(i in e.validValues))return}if(ni[t]&&!u.allow_script_urls){o=i.replace(/[\s\u0000-\u001F]+/g,"");try{o=decodeURIComponent(o)}catch(c){o=unescape(o)}if(ti.test(o))return;if(!u.allow_html_data_urls&&ii.test(o)&&!/^data:image\//i.test(o))return}h.map[t]=i;h.push({name:t,value:i})}var l=this,o,s=0,f,et,a=[],h,c,nt,w,tt,ct,lt,at,ot,d,b,v,p,k,vt,it,rt,ut,ft,yt,pt,g,wt,bt,y,kt=0,st=t.decode,dt,ni=i.makeMap("src,href,data,background,formaction,poster"),ti=/((java|vb)script|mhtml):/i,ii=/^data:/i;for(g=new RegExp("<(?:(?:!--([\\w\\W]*?)-->)|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|(?:!DOCTYPE([\\w\\W]*?)>)|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|(?:\\/([^>]+)>)|(?:([A-Za-z0-9\\-_\\:\\.]+)((?:\\s+[^\"'>]+(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>]*))*|\\/|\\s+)>))","g"),wt=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g,lt=e.getShortEndedElements(),pt=u.self_closing_elements||e.getSelfClosingElements(),at=e.getBoolAttrs(),d=u.validate,ct=u.remove_internals,dt=u.fix_self_closing,bt=e.getSpecialElements();o=g.exec(n);){if(s<o.index&&l.text(st(n.substr(s,o.index-s))),f=o[6])f=f.toLowerCase(),":"===f.charAt(0)&&(f=f.substr(1)),ht(f);else if(f=o[7]){if(f=f.toLowerCase(),":"===f.charAt(0)&&(f=f.substr(1)),ot=f in lt,dt&&pt[f]&&a.length>0&&a[a.length-1].name===f&&ht(f),!d||(b=e.getElementRule(f))){if(v=!0,d&&(vt=b.attributes,it=b.attributePatterns),(k=o[8])?(tt=-1!==k.indexOf("data-mce-type"),tt&&ct&&(v=!1),h=[],h.map={},k.replace(wt,gt)):(h=[],h.map={}),d&&!tt){if(rt=b.attributesRequired,ut=b.attributesDefault,ft=b.attributesForced,yt=b.removeEmptyAttrs,yt&&!h.length&&(v=!1),ft)for(c=ft.length;c--;)p=ft[c],w=p.name,y=p.value,"{$uid}"===y&&(y="mce_"+kt++),h.map[w]=y,h.push({name:w,value:y});if(ut)for(c=ut.length;c--;)p=ut[c],w=p.name,w in h.map||(y=p.value,"{$uid}"===y&&(y="mce_"+kt++),h.map[w]=y,h.push({name:w,value:y}));if(rt){for(c=rt.length;c--&&!(rt[c]in h.map););-1===c&&(v=!1)}if(p=h.map["data-mce-bogus"]){if("all"===p){s=r(e,n,g.lastIndex);g.lastIndex=s;continue}v=!1}}v&&l.start(f,h,ot)}else v=!1;if(et=bt[f]){et.lastIndex=s=o.index+o[0].length;(o=et.exec(n))?(v&&(nt=n.substr(s,o.index-s)),s=o.index+o[0].length):(nt=n.substr(s),s=n.length);v&&(nt.length>0&&l.text(nt,!0),l.end(f));g.lastIndex=s;continue}ot||(k&&k.indexOf("/")==k.length-1?v&&l.end(f):a.push({name:f,valid:v}))}else(f=o[1])?(">"===f.charAt(0)&&(f=" "+f),u.allow_conditional_comments||"[if"!==f.substr(0,3)||(f=" "+f),l.comment(f)):(f=o[2])?l.cdata(f):(f=o[3])?l.doctype(f):(f=o[4])&&l.pi(f,o[5]);s=o.index+o[0].length}for(s<n.length&&l.text(st(n.substr(s))),c=a.length-1;c>=0;c--)f=a[c],f.valid&&l.end(f.name)}}var f=i.each;return u.findEndTag=r,u});i(ui,[et,g,ri,r],function(n,t,i,r){var u=r.makeMap,f=r.each,e=r.explode,o=r.extend;return function(r,s){function y(t){var v,i,f,e,y,l,a,c,o,p,b,w,k,r,d;for(b=u("tr,td,th,tbody,thead,tfoot,table"),p=s.getNonEmptyElements(),w=s.getTextBlockElements(),k=s.getSpecialElements(),v=0;v<t.length;v++)if(i=t[v],i.parent&&!i.fixed)if(w[i.name]&&"li"==i.parent.name){for(r=i.next;r&&w[r.name];)r.name="li",r.fixed=!0,i.parent.insert(r,i.parent),r=r.next;i.unwrap(i)}else{for(e=[i],f=i.parent;f&&!s.isValidChild(f.name,i.name)&&!b[f.name];f=f.parent)e.push(f);if(f&&e.length>1){for(e.reverse(),y=l=h.filterNode(e[0].clone()),o=0;o<e.length-1;o++){for(s.isValidChild(l.name,e[o].name)?(a=h.filterNode(e[o].clone()),l.append(a)):a=l,c=e[o].firstChild;c&&c!=e[o+1];)d=c.next,a.append(c),c=d;l=a}y.isEmpty(p)?f.insert(i,e[0],!0):(f.insert(y,e[0],!0),f.insert(i,y));f=e[0];(f.isEmpty(p)||f.firstChild===f.lastChild&&"br"===f.firstChild.name)&&f.empty().remove()}else if(i.parent){if("li"===i.name){if(r=i.prev,r&&("ul"===r.name||"ul"===r.name)){r.append(i);continue}if(r=i.next,r&&("ul"===r.name||"ul"===r.name)){r.insert(i,r.firstChild,!0);continue}i.wrap(h.filterNode(new n("ul",1)));continue}s.isValidChild(i.parent.name,"div")&&s.isValidChild("div",i.name)?i.wrap(h.filterNode(new n("div",1))):k[i.name]?i.empty().remove():i.unwrap()}}}var h=this,v={},c=[],l={},a={};r=r||{};r.validate="validate"in r?r.validate:!0;r.root_name=r.root_name||"body";h.schema=s=s||new t;h.filterNode=function(n){var r,t,i;for((t in v)&&(i=l[t],i?i.push(n):l[t]=[n]),r=c.length;r--;)t=c[r].name,t in n.attributes.map&&(i=a[t],i?i.push(n):a[t]=[n]);return n};h.addNodeFilter=function(n,t){f(e(n),function(n){var i=v[n];i||(v[n]=i=[]);i.push(t)})};h.addAttributeFilter=function(n,t){f(e(n),function(n){for(var i=0;i<c.length;i++)if(c[i].name===n)return void c[i].callbacks.push(t);c.push({name:n,callbacks:[t]})})};h.parse=function(t,f){function wt(){function i(t){t&&(n=t.firstChild,n&&3==n.type&&(n.value=n.value.replace(ut,"")),n=t.lastChild,n&&3==n.type&&(n.value=n.value.replace(ft,"")))}var n=d.firstChild,u,t;if(s.isValidChild(d.name,et.toLowerCase())){for(;n;)u=n.next,3==n.type||1==n.type&&"p"!==n.name&&!g[n.name]&&!n.attr("data-mce-type")?t?t.append(n):(t=k(et,1),t.attr(r.forced_root_block_attrs),d.insert(t,n),t.append(n)):(i(t),t=null),n=u;i(t)}}function k(t,i){var r=new n(t,i),u;return t in v&&(u=l[t],u?u.push(r):l[t]=[r]),r}function ot(n){for(var i,r,u,f=s.getBlockElements(),t=n.prev;t&&3===t.type;){if(r=t.value.replace(ft,""),r.length>0)return void(t.value=r);if(i=t.next){if(3==i.type&&i.value.length){t=t.prev;continue}if(!f[i.name]&&"script"!=i.name&&"style"!=i.name){t=t.prev;continue}}u=t.prev;t.remove();t=u}}function bt(n){var t,i={};for(t in n)"li"!==t&&"p"!=t&&(i[t]=n[t]);return i}var at,d,e,w,b,it,h,vt,p,rt,tt,g,ut,st=[],nt,ft,yt,ht,ct,lt,pt,et;if(f=f||{},l={},a={},g=o(u("script,style,head,html,body,title,meta,param"),s.getBlockElements()),pt=s.getNonEmptyElements(),lt=s.children,tt=r.validate,et="forced_root_block"in f?f.forced_root_block:r.forced_root_block,ct=s.getWhiteSpaceElements(),ut=/^[ \t\r\n]+/,ft=/[ \t\r\n]+$/,yt=/[ \t\r\n]+/g,ht=/^[ \t\r\n]+$/,at=new i({validate:tt,allow_script_urls:r.allow_script_urls,allow_conditional_comments:r.allow_conditional_comments,self_closing_elements:bt(s.getSelfClosingElements()),cdata:function(n){e.append(k("#cdata",4)).value=n},text:function(n,t){var i;nt||(n=n.replace(yt," "),e.lastChild&&g[e.lastChild.name]&&(n=n.replace(ut,"")));0!==n.length&&(i=k("#text",3),i.raw=!!t,e.append(i).value=n)},comment:function(n){e.append(k("#comment",8)).value=n},pi:function(n,t){e.append(k(n,7)).value=t;ot(e)},doctype:function(n){var t;t=e.append(k("#doctype",10));t.value=n;ot(e)},start:function(n,t,i){var r,f,h,u,o;if(h=tt?s.getElementRule(n):{}){for(r=k(h.outputName||n,1),r.attributes=t,r.shortEnded=i,e.append(r),o=lt[e.name],o&&lt[r.name]&&!o[r.name]&&st.push(r),f=c.length;f--;)u=c[f].name,u in t.map&&(p=a[u],p?p.push(r):a[u]=[r]);g[n]&&ot(r);i||(e=r);!nt&&ct[n]&&(nt=!0)}},end:function(t){var i,f,r,u,o;if(f=tt?s.getElementRule(t):{}){if(g[t]&&!nt){if(i=e.firstChild,i&&3===i.type)if(r=i.value.replace(ut,""),r.length>0)i.value=r,i=i.next;else for(u=i.next,i.remove(),i=u;i&&3===i.type;)r=i.value,u=i.next,(0===r.length||ht.test(r))&&(i.remove(),i=u),i=u;if(i=e.lastChild,i&&3===i.type)if(r=i.value.replace(ft,""),r.length>0)i.value=r,i=i.prev;else for(u=i.prev,i.remove(),i=u;i&&3===i.type;)r=i.value,u=i.prev,(0===r.length||ht.test(r))&&(i.remove(),i=u),i=u}if(nt&&ct[t]&&(nt=!1),(f.removeEmpty||f.paddEmpty)&&e.isEmpty(pt))if(f.paddEmpty)e.empty().append(new n("#text","3")).value=" ";else if(!e.attributes.map.name&&!e.attributes.map.id)return o=e.parent,g[e.name]?e.empty().remove():e.unwrap(),void(e=o);e=e.parent}}},s),d=e=new n(f.context||r.root_name,11),at.parse(t),tt&&st.length&&(f.context?f.invalid=!0:y(st)),et&&("body"==d.name||f.isRootContent)&&wt(),!f.invalid){for(rt in l){for(p=v[rt],w=l[rt],h=w.length;h--;)w[h].parent||w.splice(h,1);for(b=0,it=p.length;it>b;b++)p[b](w,rt,f)}for(b=0,it=c.length;it>b;b++)if(p=c[b],p.name in a){for(w=a[p.name],h=w.length;h--;)w[h].parent||w.splice(h,1);for(h=0,vt=p.callbacks.length;vt>h;h++)p.callbacks[h](w,p.name,f)}}return d};r.remove_trailing_brs&&h.addNodeFilter("br",function(t){var e,v=t.length,r,l=o({},s.getBlockElements()),y=s.getNonEmptyElements(),i,f,u,h,c,a;for(l.body=1,e=0;v>e;e++)if(r=t[e],i=r.parent,l[r.parent.name]&&r===i.lastChild){for(u=r.prev;u;){if(h=u.name,"span"!==h||"bookmark"!==u.attr("data-mce-type")){if("br"!==h)break;if("br"===h){r=null;break}}u=u.prev}r&&(r.remove(),i.isEmpty(y)&&(c=s.getElementRule(i.name),c&&(c.removeEmpty?i.remove():c.paddEmpty&&(i.empty().append(new n("#text",3)).value=" "))))}else{for(f=r;i&&i.firstChild===f&&i.lastChild===f&&(f=i,!l[i.name]);)i=i.parent;f===i&&(a=new n("#text",3),a.value=" ",r.replace(a))}});r.allow_html_in_named_anchor||h.addAttributeFilter("id,name",function(n){for(var r=n.length,i,u,f,t;r--;)if(t=n[r],"a"===t.name&&t.firstChild&&!t.attr("href")){f=t.parent;i=t.lastChild;do u=i.prev,f.insert(i,t),i=u;while(i)}});r.validate&&s.getValidClasses()&&h.addAttributeFilter("class",function(n){for(var h=n.length,u,o,f,e,t,c=s.getValidClasses(),i,r;h--;){for(u=n[h],o=u.attr("class").split(" "),t="",f=0;f<o.length;f++)e=o[f],r=!1,i=c["*"],i&&i[e]&&(r=!0),i=c[u.name],!r&&i&&i[e]&&(r=!0),r&&(t&&(t+=" "),t+=e);t.length||(t=null);u.attr("class",t)}})}});i(wi,[d,r],function(n,t){var i=t.makeMap;return function(t){var r=[],u,o,e,f,s;return t=t||{},u=t.indent,o=i(t.indent_before||""),e=i(t.indent_after||""),f=n.getEncodeFunc(t.entity_encoding||"raw",t.entities),s="html"==t.element_format,{start:function(n,t,i){var c,a,l,h;if(u&&o[n]&&r.length>0&&(h=r[r.length-1],h.length>0&&"\n"!==h&&r.push("\n")),r.push("<",n),t)for(c=0,a=t.length;a>c;c++)l=t[c],r.push(" ",l.name,'="',f(l.value,!0),'"');r[r.length]=!i||s?">":" />";i&&u&&e[n]&&r.length>0&&(h=r[r.length-1],h.length>0&&"\n"!==h&&r.push("\n"))},end:function(n){var t;r.push("<\/",n,">");u&&e[n]&&r.length>0&&(t=r[r.length-1],t.length>0&&"\n"!==t&&r.push("\n"))},text:function(n,t){n.length>0&&(r[r.length]=t?n:f(n))},cdata:function(n){r.push("<![CDATA[",n,"]\]>")},comment:function(n){r.push("<!--",n,"-->")},pi:function(n,t){t?r.push("<?",n," ",f(t),"?>"):r.push("<?",n,"?>");u&&r.push("\n")},doctype:function(n){r.push("<!DOCTYPE",n,">",u?"\n":"")},reset:function(){r.length=0},getContent:function(){return r.join("").replace(/\n$/,"")}}}});i(yt,[wi,g],function(n,t){return function(i,r){var f=this,u=new n(i);i=i||{};i.validate="validate"in i?i.validate:!0;f.schema=r=r||new t;f.writer=u;f.serialize=function(n){function t(n){var y=f[n.type],p,a,i,o,c,s,h,l,v;if(y)y(n);else{if(p=n.name,a=n.shortEnded,i=n.attributes,e&&i&&i.length>1&&(s=[],s.map={},v=r.getElementRule(n.name))){for(h=0,l=v.attributesOrder.length;l>h;h++)o=v.attributesOrder[h],o in i.map&&(c=i.map[o],s.map[o]=c,s.push({name:o,value:c}));for(h=0,l=i.length;l>h;h++)o=i[h].name,o in s.map||(c=i.map[o],s.map[o]=c,s.push({name:o,value:c}));i=s}if(u.start(n.name,i,a),!a){if(n=n.firstChild)do t(n);while(n=n.next);u.end(p)}}}var f,e;return e=i.validate,f={3:function(n){u.text(n.value,n.raw)},8:function(n){u.comment(n.value)},7:function(n){u.pi(n.name,n.value)},10:function(n){u.doctype(n.value)},4:function(n){u.cdata(n.value)},11:function(n){if(n=n.firstChild)do t(n);while(n=n.next)}},u.reset(),1!=n.type||i.inner?f[11](n):t(n),u.getContent()}}});i(bi,[h,ui,ri,d,yt,et,g,u,r,ii],function(n,t,i,r,u,f,e,o,s,h){function a(n){function r(n){return n&&"br"===n.name}var t,i;t=n.lastChild;r(t)&&(i=t.prev,r(i)&&(t.remove(),i.remove()))}var v=s.each,l=s.trim,y=n.DOM,c=["data-mce-selected"];return function(n,f){function k(n){var t=new RegExp(["<span[^>]+data-mce-bogus[^>]+>[​﻿]+<\\/span>","\\s?("+c.join("|")+')="[^"]+"'].join("|"),"gi");return h.trim(n.replace(t,""))}function d(){for(var n=f.getBody().innerHTML,r=/<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g,o,t,u,e,h=f.schema,n=k(n),s=h.getShortEndedElements();e=r.exec(n);)t=r.lastIndex,u=e[0].length,o=s[e[1]]?t:i.findEndTag(h,n,t),n=n.substring(0,t-u)+n.substring(o),r.lastIndex=t-u;return l(n)}function g(n){-1===s.inArray(c,n)&&(p.addAttributeFilter(n,function(n,t){for(var i=n.length;i--;)n[i].attr(t,null)}),c.push(n))}var w,b,p;return f&&(w=f.dom,b=f.schema),w=w||y,b=b||new e(n),n.entity_encoding=n.entity_encoding||"named",n.remove_trailing_brs="remove_trailing_brs"in n?n.remove_trailing_brs:!0,p=new t(n,b),p.addAttributeFilter("data-mce-tabindex",function(n,t){for(var r=n.length,i;r--;)i=n[r],i.attr("tabindex",i.attributes.map["data-mce-tabindex"]),i.attr(t,null)}),p.addAttributeFilter("src,href,style",function(t,i){for(var f=t.length,u,r,e="data-mce-"+i,o=n.url_converter,s=n.url_converter_scope,h;f--;)u=t[f],r=u.attributes.map[e],r!==h?(u.attr(i,r.length>0?r:null),u.attr(e,null)):(r=u.attributes.map[i],"style"===i?r=w.serializeStyle(w.parseStyle(r),u.name):o&&(r=o.call(s,r,i,u.name)),u.attr(i,r.length>0?r:null))}),p.addAttributeFilter("class",function(n){for(var r=n.length,i,t;r--;)i=n[r],t=i.attr("class"),t&&(t=i.attr("class").replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),i.attr("class",t.length>0?t:null))}),p.addAttributeFilter("data-mce-type",function(n,t,i){for(var u=n.length,r;u--;)r=n[u],"bookmark"!==r.attributes.map["data-mce-type"]||i.cleanup||r.remove()}),p.addNodeFilter("noscript",function(n){for(var i=n.length,t;i--;)t=n[i].firstChild,t&&(t.value=r.decode(t.value))}),p.addNodeFilter("script,style",function(n,t){function f(n){return n.replace(/(<!--\[CDATA\[|\]\]-->)/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi,"").replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")}for(var e=n.length,i,r,u;e--;)i=n[e],r=i.firstChild?i.firstChild.value:"","script"===t?(u=i.attr("type"),u&&i.attr("type","mce-no/type"==u?null:u.replace(/^mce\-/,"")),r.length>0&&(i.firstChild.value="// <![CDATA[\n"+f(r)+"\n// ]\]>")):r.length>0&&(i.firstChild.value="<!--\n"+f(r)+"\n-->")}),p.addNodeFilter("#comment",function(n){for(var i=n.length,t;i--;)t=n[i],0===t.value.indexOf("[CDATA[")?(t.name="#cdata",t.type=4,t.value=t.value.replace(/^\[CDATA\[|\]\]$/g,"")):0===t.value.indexOf("mce:protected ")&&(t.name="#text",t.type=3,t.raw=!0,t.value=unescape(t.value).substr(14))}),p.addNodeFilter("xml:namespace,input",function(n,t){for(var r=n.length,i;r--;)i=n[r],7===i.type?i.remove():1===i.type&&("input"!==t||"type"in i.attributes.map||i.attr("type","text"))}),n.fix_list_elements&&p.addNodeFilter("ul,ol",function(n){for(var r=n.length,t,i;r--;)t=n[r],i=t.parent,"ul"!==i.name&&"ol"!==i.name||t.prev&&"li"===t.prev.name&&t.prev.append(t)}),p.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-type,data-mce-resize",function(n,t){for(var i=n.length;i--;)n[i].attr(t,null)}),{schema:b,addNodeFilter:p.addNodeFilter,addAttributeFilter:p.addAttributeFilter,serialize:function(t,i){var c=this,f,r,e,y,k,s;return o.ie&&w.select("script,style,select,map").length>0?(k=t.innerHTML,t=t.cloneNode(!1),w.setHTML(t,k)):t=t.cloneNode(!0),f=t.ownerDocument.implementation,f.createHTMLDocument&&(r=f.createHTMLDocument(""),v("BODY"==t.nodeName?t.childNodes:[t],function(n){r.body.appendChild(r.importNode(n,!0))}),t="BODY"!=t.nodeName?r.body.firstChild:r.body,e=w.doc,w.doc=r),i=i||{},i.format=i.format||"html",i.selection&&(i.forced_root_block=""),i.no_events||(i.node=t,c.onPreProcess(i)),s=p.parse(l(i.getInner?t.innerHTML:w.getOuterHTML(t)),i),a(s),y=new u(n,b),i.content=y.serialize(s),i.cleanup||(i.content=h.trim(i.content),i.content=i.content.replace(/\uFEFF/g,"")),i.no_events||c.onPostProcess(i),e&&(w.doc=e),i.node=null,i.content},addRules:function(n){b.addValidElements(n)},setRules:function(n){b.setValidElements(n)},onPreProcess:function(n){f&&f.fire("PreProcess",n)},onPostProcess:function(n){f&&f.fire("PostProcess",n)},addTempAttr:g,trimHtml:k,getTrimmedContent:d}}});i(bu,[],function(){function n(n){function i(t,i){var r,c=0,s,a,l,f,e,h,o=-1,u;if(r=t.duplicate(),r.collapse(i),u=r.parentElement(),u.ownerDocument===n.dom.doc){for(;"false"===u.contentEditable;)u=u.parentNode;if(!u.hasChildNodes())return{node:u,inside:1};for(l=u.children,s=l.length-1;s>=c;)if(h=Math.floor((c+s)/2),f=l[h],r.moveToElementText(f),o=r.compareEndPoints(i?"StartToStart":"EndToEnd",t),o>0)s=h-1;else{if(!(0>o))return{node:f};c=h+1}if(0>o)for(f?r.collapse(!1):(r.moveToElementText(u),r.collapse(!0),f=u,a=!0),e=0;0!==r.compareEndPoints(i?"StartToStart":"StartToEnd",t)&&0!==r.move("character",1)&&u==r.parentElement();)e++;else for(r.collapse(!0),e=0;0!==r.compareEndPoints(i?"StartToStart":"StartToEnd",t)&&0!==r.move("character",-1)&&u==r.parentElement();)e++;return{node:f,position:o,offset:e,inside:a}}}function u(){function s(n){var s=i(f,n),r,o,e=0,t,c,h;if(r=s.node,o=s.offset,s.inside&&!r.hasChildNodes())return void u[n?"setStart":"setEnd"](r,0);if(o===c)return void u[n?"setStartBefore":"setEndAfter"](r);if(s.position<0){if(t=s.inside?r.firstChild:r.nextSibling,!t)return void u[n?"setStartAfter":"setEndAfter"](r);if(!o)return void(3==t.nodeType?u[n?"setStart":"setEnd"](t,0):u[n?"setStartBefore":"setEndBefore"](t));for(;t;){if(3==t.nodeType&&(h=t.nodeValue,e+=h.length,e>=o)){r=t;e-=o;e=h.length-e;break}t=t.nextSibling}}else{if(t=r.previousSibling,!t)return u[n?"setStartBefore":"setEndBefore"](r);if(!o)return void(3==r.nodeType?u[n?"setStart":"setEnd"](t,r.nodeValue.length):u[n?"setStartAfter":"setEndAfter"](t));for(;t;){if(3==t.nodeType&&(e+=t.nodeValue.length,e>=o)){r=t;e-=o;break}t=t.previousSibling}}u[n?"setStart":"setEnd"](r,e)}var f=n.getRng(),u=t.createRng(),e,h,o,c,l;if(e=f.item?f.item(0):f.parentElement(),e.ownerDocument!=t.doc)return u;if(h=n.isCollapsed(),f.item)return u.setStart(e.parentNode,t.nodeIndex(e)),u.setEnd(u.startContainer,u.startOffset+1),u;try{s(!0);h||s()}catch(a){if(-2147024809!=a.number)throw a;l=r.getBookmark(2);o=f.duplicate();o.collapse(!0);e=o.parentElement();h||(o=f.duplicate(),o.collapse(!1),c=o.parentElement(),c.innerHTML=c.innerHTML);e.innerHTML=e.innerHTML;r.moveToBookmark(l);f=n.getRng();s(!0);h||s()}return u}var r=this,t=n.dom,f=!1;this.getBookmark=function(r){function e(n){for(var u,r,e=[],i=n.parentNode,f=t.getRoot().parentNode;i!=f&&9!==i.nodeType;){for(u=i.children,r=u.length;r--;)if(n===u[r]){e.push(r);break}n=i;i=i.parentNode}return e}function o(n){var t;return t=i(f,n),t?{position:t.position,offset:t.offset,indexes:e(t.node),inside:t.inside}:void 0}var f=n.getRng(),u={};return 2===r&&(f.item?u.start={ctrl:!0,indexes:e(f.item(0))}:(u.start=o(!0),n.isCollapsed()||(u.end=o()))),u};this.moveToBookmark=function(n){function u(n){for(var u,f,i=t.getRoot(),r=n.length-1;r>=0;r--)f=i.children,u=n[r],u<=f.length-1&&(i=f[u]);return i}function f(t){var e=n[t?"start":"end"],s,f,h,o;e&&(s=e.position>0,f=r.createTextRange(),f.moveToElementText(u(e.indexes)),o=e.offset,o!==h?(f.collapse(e.inside||s),f.moveStart("character",s?-o:o)):f.collapse(t),i.setEndPoint(t?"StartToStart":"EndToStart",f),t&&i.collapse(!0))}var i,r=t.doc.body;n.start&&(n.start.ctrl?(i=r.createControlRange(),i.addElement(u(n.start.indexes)),i.select()):(i=r.createTextRange(),f(!0),f(),i.select()))};this.addRange=function(i){function p(n){var i,y,u,h,v;u=t.create("a");i=n?r:c;y=n?o:s;h=e.duplicate();i!=l&&i!=l.documentElement||(i=a,y=0);3==i.nodeType?(i.parentNode.insertBefore(u,i),h.moveToElementText(u),h.moveStart("character",y),t.remove(u),e.setEndPoint(n?"StartToStart":"EndToEnd",h)):(v=i.childNodes,v.length?(y>=v.length?t.insertAfter(u,v[v.length-1]):i.insertBefore(u,v[y]),h.moveToElementText(u)):i.canHaveHTML&&(i.innerHTML="<span>&#xFEFF;<\/span>",u=i.firstChild,h.moveToElementText(u),h.collapse(f)),e.setEndPoint(n?"StartToStart":"EndToEnd",h),t.remove(u))}var e,h,r,o,c,s,u,l=n.dom.doc,a=l.body,v,y;if(r=i.startContainer,o=i.startOffset,c=i.endContainer,s=i.endOffset,e=a.createTextRange(),r==c&&1==r.nodeType){if(o==s&&!r.hasChildNodes()){if(r.canHaveHTML)return u=r.previousSibling,u&&!u.hasChildNodes()&&t.isBlock(u)?u.innerHTML="&#xFEFF;":u=null,r.innerHTML="<span>&#xFEFF;<\/span><span>&#xFEFF;<\/span>",e.moveToElementText(r.lastChild),e.select(),t.doc.selection.clear(),r.innerHTML="",void(u&&(u.innerHTML=""));o=t.nodeIndex(r);r=r.parentNode}if(o==s-1)try{if(y=r.childNodes[o],h=a.createControlRange(),h.addElement(y),h.select(),v=n.getRng(),v.item&&y===v.item(0))return}catch(w){}}p(!0);p();e.select()};this.getRangeAt=u}return n});i(ot,[u],function(n){return{BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,modifierPressed:function(n){return n.shiftKey||n.ctrlKey||n.altKey||this.metaKeyPressed(n)},metaKeyPressed:function(t){return n.mac?t.metaKey:t.ctrlKey&&!t.altKey}}});i(ki,[ot,r,f,u,e],function(n,t,i,r,u){var f=u.isContentEditableFalse;return function(u,e){function yt(n){var t=e.settings.object_resizing;return t===!1||r.iOS?!1:("string"!=typeof t&&(t="table,img,div"),"false"===n.getAttribute("data-mce-resize")?!1:n==e.getBody()?!1:e.dom.is(n,t))}function et(t){var i,r,y,u,f;i=t.screenX-ii;r=t.screenY-ri;c=i*v[2]+k;l=r*v[3]+d;c=5>c?5:c;l=5>l?5:l;y="IMG"==s.nodeName&&e.settings.resize_img_proportional!==!1?!n.modifierPressed(t):n.modifierPressed(t)||"IMG"==s.nodeName&&v[2]*v[3]!=0;y&&(ct(i)>ct(r)?(l=lt(c*ft),c=lt(l/ft)):(c=lt(l/ft),l=lt(c*ft)));o.setStyles(h,{width:c,height:l});u=v.startPos.x+i;f=v.startPos.y+r;u=u>0?u:0;f=f>0?f:0;o.setStyles(it,{left:u,top:f,display:"block"});it.innerHTML=c+" &times; "+l;v[2]<0&&h.clientWidth<=c&&o.setStyle(h,"left",rt+(k-c));v[3]<0&&h.clientHeight<=l&&o.setStyle(h,"top",ut+(d-l));i=a.scrollWidth-ui;r=a.scrollHeight-fi;i+r!==0&&o.setStyles(it,{left:u-i,top:f-r});g||(e.fire("ObjectResizeStart",{target:s,width:k,height:d}),g=!0)}function ot(){function n(n,t){t&&(s.style[n]||!e.schema.isValid(s.nodeName.toLowerCase(),n)?o.setStyle(s,n,t):o.setAttrib(s,n,t))}g=!1;n("width",c);n("height",l);o.unbind(w,"mousemove",et);o.unbind(w,"mouseup",ot);nt!=w&&(o.unbind(nt,"mousemove",et),o.unbind(nt,"mouseup",ot));o.remove(h);o.remove(it);tt&&"TABLE"!=s.nodeName||st(s);e.fire("ObjectResized",{target:s,width:c,height:l});o.setAttrib(s,"style",o.getAttrib(s,"style"));e.nodeChanged()}function st(n,t,i){var f,b,g,tt,u;y();vt();f=o.getPos(n,a);rt=f.x;ut=f.y;u=n.getBoundingClientRect();b=u.width||u.right-u.left;g=u.height||u.bottom-u.top;s!=n&&(at(),s=n,c=l=0);tt=e.fire("ObjectSelected",{target:n});yt(n)&&!tt.isDefaultPrevented()?ti(p,function(n,u){function e(t){ii=t.screenX;ri=t.screenY;k=s.clientWidth;d=s.clientHeight;ft=d/k;v=n;n.startPos={x:b*n[0]+rt,y:g*n[1]+ut};ui=a.scrollWidth;fi=a.scrollHeight;h=s.cloneNode(!0);o.addClass(h,"mce-clonedresizable");o.setAttrib(h,"data-mce-bogus","all");h.contentEditable=!1;h.unSelectabe=!0;o.setStyles(h,{left:rt,top:ut,margin:0});h.removeAttribute("data-mce-selected");a.appendChild(h);o.bind(w,"mousemove",et);o.bind(w,"mouseup",ot);nt!=w&&(o.bind(nt,"mousemove",et),o.bind(nt,"mouseup",ot));it=o.add(a,"div",{"class":"mce-resize-helper","data-mce-bogus":"all"},k+" &times; "+d)}var f;return t?void(u==t&&e(i)):(f=o.get("mceResizeHandle"+u),f&&o.remove(f),f=o.add(a,"div",{id:"mceResizeHandle"+u,"data-mce-bogus":"all","class":"mce-resizehandle",unselectable:!0,style:"cursor:"+u+"-resize; margin:0; padding:0"}),r.ie&&(f.contentEditable=!1),o.bind(f,"mousedown",function(n){n.stopImmediatePropagation();n.preventDefault();e(n)}),n.elm=f,void o.setStyles(f,{left:b*n[0]+rt-f.offsetWidth/2,top:g*n[1]+ut-f.offsetHeight/2}))}):y();s.setAttribute("data-mce-selected","1")}function y(){var t,n;vt();s&&s.removeAttribute("data-mce-selected");for(t in p)n=o.get("mceResizeHandle"+t),n&&(o.unbind(n),o.remove(n))}function pt(n){function r(n,t){if(n)do if(n===t)return!0;while(n=n.parentNode)}var i,t;if(!g&&!e.removed)return ti(o.select("img[data-mce-selected],hr[data-mce-selected]"),function(n){n.removeAttribute("data-mce-selected")}),t="mousedown"==n.type?n.target:u.getNode(),t=o.$(t).closest(tt?"table":"table,img,hr")[0],r(t,a)&&(gt(),i=u.getStart(!0),r(i,t)&&r(u.getEnd(!0),t)&&(!tt||t!=i&&"IMG"!==i.nodeName))?void st(t):void y()}function wt(n,t,i){n&&n.attachEvent&&n.attachEvent("on"+t,i)}function bt(n,t,i){n&&n.detachEvent&&n.detachEvent("on"+t,i)}function kt(n){var t=n.srcElement,r,u,i,f,o,h,c;r=t.getBoundingClientRect();h=ht.clientX-r.left;c=ht.clientY-r.top;for(u in p)if(i=p[u],f=t.offsetWidth*i[0],o=t.offsetHeight*i[1],ct(f-h)<8&&ct(o-c)<8){v=i;break}g=!0;e.fire("ObjectResizeStart",{target:s,width:s.clientWidth,height:s.clientHeight});e.getDoc().selection.empty();st(t,u,ht)}function ei(n){n.preventDefault?n.preventDefault():n.returnValue=!1}function dt(n){var t=n.srcElement;if(f(t))return void ei(n);if(t!=s){if(e.fire("ObjectSelected",{target:t}),at(),0===t.id.indexOf("mceResizeHandle"))return void(n.returnValue=!1);"IMG"!=t.nodeName&&"TABLE"!=t.nodeName||(y(),s=t,wt(t,"resizestart",kt))}}function at(){bt(s,"resizestart",kt)}function vt(){var t,n;for(t in p)n=p[t],n.elm&&(o.unbind(n.elm),delete n.elm)}function gt(){try{e.getDoc().execCommand("enableObjectResizing",!1,!1)}catch(n){}}function ni(n){var t;if(tt){t=w.body.createControlRange();try{return t.addElement(n),t.select(),!0}catch(i){}}}function oi(){s=h=null;tt&&(at(),bt(a,"controlselect",dt))}var o=e.dom,ti=t.each,s,h,it,p,v,ht,ii,ri,rt,ut,k,d,ft,g,c,l,w=e.getDoc(),nt=document,tt=r.ie&&r.ie<11,ct=Math.abs,lt=Math.round,a=e.getBody(),ui,fi,b;return p={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]},b=".mce-content-body",e.contentStyles.push(b+" div.mce-resizehandle {position: absolute;border: 1px solid black;box-sizing: box-sizing;background: #FFF;width: 7px;height: 7px;z-index: 10000}"+b+" .mce-resizehandle:hover {background: #000}"+b+" img[data-mce-selected],"+b+" hr[data-mce-selected] {outline: 1px solid black;resize: none}"+b+" .mce-clonedresizable {position: absolute;"+(r.gecko?"":"outline: 1px dashed black;")+"opacity: .5;filter: alpha(opacity=50);z-index: 10000}"+b+" .mce-resize-helper {background: #555;background: rgba(0,0,0,0.75);border-radius: 3px;border: 1px;color: white;display: none;font-family: sans-serif;font-size: 12px;white-space: nowrap;line-height: 14px;margin: 5px 10px;padding: 5px;position: absolute;z-index: 10001}"),e.on("init",function(){tt?(e.on("ObjectResized",function(n){"TABLE"!=n.target.nodeName&&(y(),ni(n.target))}),wt(a,"controlselect",dt),e.on("mousedown",function(n){ht=n})):(gt(),r.ie>=11&&(e.on("mousedown click",function(n){var t=n.target.nodeName;!g&&/^(TABLE|IMG|HR)$/.test(t)&&(e.selection.select(n.target,"TABLE"==t),"mousedown"==n.type&&e.nodeChanged())}),e.dom.bind(a,"mscontrolselect",function(n){function t(n){i.setEditorTimeout(e,function(){e.selection.select(n)})}return f(n.target)?(n.preventDefault(),void t(n.target)):void(/^(TABLE|IMG|HR)$/.test(n.target.nodeName)&&(n.preventDefault(),"IMG"==n.target.tagName&&t(n.target)))})));var n=i.throttle(function(n){e.composing||pt(n)});e.on("nodechange ResizeEditor ResizeWindow drop",n);e.on("keyup compositionend",function(t){s&&"TABLE"==s.nodeName&&n(t)});e.on("hide blur",y)}),e.on("remove",vt),{isResizable:yt,showResizeRect:st,hideResizeRect:y,updateResizeRect:pt,controlSelect:ni,destroy:oi}}});i(a,[],function(){function i(n){return function(){return n}}function r(n){return function(t){return!n(t)}}function u(n,t){return function(i){return n(t(i))}}function f(){var t=n.call(arguments);return function(n){for(var i=0;i<t.length;i++)if(t[i](n))return!0;return!1}}function e(){var t=n.call(arguments);return function(n){for(var i=0;i<t.length;i++)if(!t[i](n))return!1;return!0}}function t(i){var r=n.call(arguments);return r.length-1>=i.length?i.apply(this,r.slice(1)):function(){var n=r.concat([].slice.call(arguments));return t.apply(this,n)}}var n=[].slice;return{constant:i,negate:r,and:e,or:f,curry:t,compose:u}});i(st,[e,c,w],function(n,t,i){function u(n){return p(n)?!1:a(n)?!v(n.parentNode):o(n)||l(n)||y(n)||r(n)}function f(n,t){for(n=n.parentNode;n&&n!=t;n=n.parentNode){if(r(n))return!1;if(e(n))return!0}return!0}function s(n){return r(n)?t.reduce(n.getElementsByTagName("*"),function(n,t){return n||e(t)},!1)!==!0:!1}function h(n){return o(n)||s(n)}function c(n,t){return u(n)&&f(n,t)}var e=n.isContentEditableTrue,r=n.isContentEditableFalse,l=n.isBr,a=n.isText,v=n.matchNodeNames("script style textarea"),o=n.matchNodeNames("img input textarea hr iframe video audio object"),y=n.matchNodeNames("table"),p=i.isCaretContainer;return{isCaretCandidate:u,isInEditable:f,isAtomic:h,isEditableCaretCandidate:c}});i(nt,[],function(){function t(t){return t?{left:n(t.left),top:n(t.top),bottom:n(t.bottom),right:n(t.right),width:n(t.width),height:n(t.height)}:{left:0,top:0,bottom:0,right:0,width:0,height:0}}function o(n,i){return n=t(n),i?n.right=n.left:(n.left=n.left+n.width,n.right=n.left),n.width=0,n}function s(n,t){return n.left===t.left&&n.top===t.top&&n.bottom===t.bottom&&n.right===t.right}function i(n,t,i){return n>=0&&n<=Math.min(t.height,i.height)/2}function r(n,t){return n.bottom<t.top?!0:n.top>t.bottom?!1:i(t.top-n.bottom,n,t)}function u(n,t){return n.top>t.bottom?!0:n.bottom<t.top?!1:i(t.bottom-n.top,n,t)}function f(n,t){return n.left<t.left}function e(n,t){return n.right>t.right}function h(n,t){return r(n,t)?-1:u(n,t)?1:f(n,t)?-1:e(n,t)?1:0}function c(n,t,i){return t>=n.left&&t<=n.right&&i>=n.top&&i<=n.bottom}var n=Math.round;return{clone:t,collapse:o,isEqual:s,isAbove:r,isBelow:u,isLeft:f,isRight:e,compare:h,containsXY:c}});i(ku,[],function(){function n(n){return"string"==typeof n&&n.charCodeAt(0)>=768&&t.test(n)}var t=new RegExp("[̀-ͯ҃-҇҈-҉֑-ֽֿׁ-ׂׄ-ׇׅؐ-ًؚ-ٰٟۖ-ۜ۟-ۤۧ-۪ۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣣ-ंऺ़ु-ै्॑-ॗॢ-ॣঁ়াু-ৄ্ৗৢ-ৣਁ-ਂ਼ੁ-ੂੇ-ੈੋ-੍ੑੰ-ੱੵઁ-ં઼ુ-ૅે-ૈ્ૢ-ૣଁ଼ାିୁ-ୄ୍ୖୗୢ-ୣஂாீ்ௗఀా-ీె-ైొ-్ౕ-ౖౢ-ౣಁ಼ಿೂೆೌ-್ೕ-ೖೢ-ೣഁാു-ൄ്ൗൢ-ൣ්ාි-ුූෟัิ-ฺ็-๎ັິ-ູົ-ຼ່-ໍ༘-ཱ༹༙༵༷-ཾྀ-྄྆-྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္-်ွ-ှၘ-ၙၞ-ၠၱ-ၴႂႅ-ႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒ-ᝓᝲ-ᝳ឴-឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧ-ᤨᤲ᤹-᤻ᨗ-ᨘᨛᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼᪰-᪽᪾ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀ-ᮁᮢ-ᮥᮨ-ᮩ᮫-ᮭ᯦ᯨ-ᯩᯭᯯ-ᯱᰬ-ᰳᰶ-᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᳸-᳹᷀-᷵᷼-᷿‌-‍⃐-⃜⃝-⃠⃡⃢-⃤⃥-⃰⳯-⵿⳱ⷠ-〪ⷿ-〭〮-゙〯-゚꙯꙰-꙲ꙴ-꙽ꚞ-ꚟ꛰-꛱ꠂ꠆ꠋꠥ-ꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꧥꨩ-ꨮꨱ-ꨲꨵ-ꨶꩃꩌꩼꪰꪲ-ꪴꪷ-ꪸꪾ-꪿꫁ꫬ-ꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-︯ﾞ-ﾟ]");return{isExtendingChar:n}});i(v,[a,e,h,y,st,nt,ku],function(n,t,i,r,u,f,e){function l(n){return n&&/[\r\n\t ]/.test(n)}function a(n){var i=n.startContainer,r=n.startOffset,t;return!!(l(n.toString())&&g(i.parentNode)&&(t=i.data,l(t[r-1])||l(t[r+1])))}function b(n){function b(n){var r=n.ownerDocument,i=r.createRange(),t=r.createTextNode(" "),u=n.parentNode,e;return u.insertBefore(t,n),i.setStart(t,0),i.setEnd(t,1),e=f.clone(i.getBoundingClientRect()),u.removeChild(t),e}function r(n){var t,i;return i=n.getClientRects(),t=i.length>0?f.clone(i[0]):f.clone(n.getBoundingClientRect()),v(n)&&0===t.left?b(n):t}function u(n,t){return n=f.collapse(n,t),n.width=1,n.right=n.left+1,n}function o(n){0!==n.height&&(i.length>0&&f.isEqual(n,i[i.length-1])||i.push(n))}function w(n,t){var f=n.ownerDocument.createRange();if(t<n.data.length){if(e.isExtendingChar(n.data[t]))return i;if(e.isExtendingChar(n.data[t-1])&&(f.setStart(n,t),f.setEnd(n,t+1),!a(f)))return o(u(r(f),!1)),i}t>0&&(f.setStart(n,t-1),f.setEnd(n,t),a(f)||o(u(r(f),!1)));t<n.data.length&&(f.setStart(n,t),f.setEnd(n,t+1),a(f)||o(u(r(f),!0)))}var i=[],l,t;if(h(n.container()))return w(n.container(),n.offset()),i;if(y(n.container()))if(n.isAtEnd())t=c(n.container(),n.offset()),h(t)&&w(t,t.data.length),s(t)&&!v(t)&&o(u(r(t),!1));else{if(t=c(n.container(),n.offset()),h(t)&&w(t,0),s(t)&&n.isAtEnd())return o(u(r(t),!1)),i;l=c(n.container(),n.offset()-1);s(l)&&!v(l)&&(p(l)||p(t)||!s(t))&&o(u(r(l),!1));s(t)&&o(u(r(t),!0))}return i}function o(t,i,r){function f(){return h(t)?0===i:0===i}function e(){return h(t)?i>=t.data.length:i>=t.childNodes.length}function s(){var n;return n=t.ownerDocument.createRange(),n.setStart(t,i),n.setEnd(t,i),n}function u(){return r||(r=b(new o(t,i))),r}function l(){return u().length>0}function a(n){return n&&t===n.container()&&i===n.offset()}function v(n){return c(t,n?i-1:i)}return{container:n.constant(t),offset:n.constant(i),toRange:s,getClientRects:u,isVisible:l,isAtStart:f,isAtEnd:e,isEqual:a,getNode:v}}var y=t.isElement,k=u.isCaretCandidate,p=t.matchStyleValues("display","block table"),d=t.matchStyleValues("float","left right"),s=n.and(y,k,n.negate(d)),g=n.negate(t.matchStyleValues("white-space","pre pre-line pre-wrap")),h=t.isText,v=t.isBr,w=i.nodeIndex,c=r.getNode;return o.fromRangeStart=function(n){return new o(n.startContainer,n.startOffset)},o.fromRangeEnd=function(n){return new o(n.endContainer,n.endOffset)},o.after=function(n){return new o(n.parentNode,w(n)+1)},o.before=function(n){return new o(n.parentNode,w(n))},o});i(du,[e,h,a,c,v],function(n,t,i,r,u){function o(n){var t=n.parentNode;return c(t)?o(t):t}function e(n){return n?r.reduce(n.childNodes,function(n,t){return c(t)&&"BR"!=t.nodeName?n=n.concat(e(t)):n.push(t),n},[]):[]}function a(n,t){for(;(n=n.previousSibling)&&f(n);)t+=n.data.length;return t}function s(n){return function(t){return n===t}}function v(t){var i,u,h;return i=e(o(t)),u=r.findIndex(i,s(t),t),i=i.slice(0,u+1),h=r.reduce(i,function(n,t,r){return f(t)&&f(i[r-1])&&n++,n},0),i=r.filter(i,n.matchNodeNames(t.nodeName)),u=r.findIndex(i,s(t),t),u-h}function h(n){var t;return t=f(n)?"text()":n.nodeName.toLowerCase(),t+"["+v(n)+"]"}function y(n,t,i){var r=[];for(t=t.parentNode;t!=n&&(!i||!i(t));t=t.parentNode)r.push(t);return r}function p(t,u){var e,o,s=[],c,l,v;return e=u.container(),o=u.offset(),f(e)?c=a(e,o):(l=e.childNodes,o>=l.length?(c="after",o=l.length-1):c="before",e=l[o]),s.push(h(e)),v=y(t,e),v=r.filter(v,i.negate(n.isBogus)),s=s.concat(r.map(v,function(n){return h(n)})),s.reverse().join("/")+","+c}function w(t,i,u){var o=e(t);return o=r.filter(o,function(n,t){return!f(n)||!f(o[t-1])}),o=r.filter(o,n.matchNodeNames(i)),o[u]}function b(n,t){for(var i=n,r=0,e;f(i);){if(e=i.data.length,t>=r&&r+e>=t){n=i;t-=r;break}if(!f(i.nextSibling)){n=i;t=e;break}r+=e;i=i.nextSibling}return t>n.data.length&&(t=n.data.length),new u(n,t)}function k(n,t){var o,i,e;return t?(o=t.split(","),t=o[0].split("/"),e=o.length>1?o[1]:"before",i=r.reduce(t,function(n,t){return(t=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(t))?("text()"===t[1]&&(t[1]="#text"),w(n,t[1],parseInt(t[2],10))):null},n),i?f(i)?b(i,parseInt(e,10)):(e="after"===e?l(i)+1:l(i),new u(i.parentNode,e)):null):null}var f=n.isText,c=n.isBogus,l=t.nodeIndex;return{create:p,resolve:k}});i(pt,[u,r,w,du,v,e],function(n,t,i,r,u,f){function o(o){var s=o.dom;this.getBookmark=function(n,h){function w(n,i){var r=0;return t.each(s.select(n),function(n){if("all"!==n.getAttribute("data-mce-bogus"))return n==i?!1:void r++}),r}function d(n){function t(t){var i,r,u,f=t?"start":"end";i=n[f+"Container"];r=n[f+"Offset"];1==i.nodeType&&"TR"==i.nodeName&&(u=i.childNodes,i=u[Math.min(t?r:r-1,u.length-1)],i&&(r=t?0:i.childNodes.length,n["set"+(t?"Start":"End")](i,r)))}return t(!0),t(),n}function g(n){function i(n,t){var i=n[t?"startContainer":"endContainer"],f=n[t?"startOffset":"endOffset"],o=[],u,e,c=0;if(3==i.nodeType){if(h)for(u=i.previousSibling;u&&3==u.nodeType;u=u.previousSibling)f+=u.nodeValue.length;o.push(f)}else e=i.childNodes,f>=e.length&&e.length&&(c=1,f=Math.max(0,e.length-1)),o.push(s.nodeIndex(e[f],h)+c);for(;i&&i!=r;i=i.parentNode)o.push(s.nodeIndex(i,h));return o}var r=s.getRoot(),t={};return t.start=i(n,!0),o.isCollapsed()||(t.end=i(n)),t}function nt(n){function t(n){var t;if(i.isCaretContainer(n)&&((f.isText(n)&&i.isCaretContainerBlock(n)&&(n=n.parentNode),t=n.previousSibling,e(t))||(t=n.nextSibling,e(t))))return t}return t(n.startContainer)||t(n.endContainer)}var c,v,y,k,a,l,b="&#xFEFF;",p;if(2==n)return l=o.getNode(),a=l?l.nodeName:null,c=o.getRng(),e(l)||"IMG"==a?{name:a,index:w(a,l)}:o.tridentSel?o.tridentSel.getBookmark(n):(l=nt(c),l?(a=l.tagName,{name:a,index:w(a,l)}):g(c));if(3==n)return c=o.getRng(),{start:r.create(s.getRoot(),u.fromRangeStart(c)),end:r.create(s.getRoot(),u.fromRangeEnd(c))};if(n)return{rng:o.getRng()};if(c=o.getRng(),y=s.uniqueId(),k=o.isCollapsed(),p="overflow:hidden;line-height:0px",c.duplicate||c.item){if(c.item)return l=c.item(0),a=l.nodeName,{name:a,index:w(a,l)};v=c.duplicate();try{c.collapse();c.pasteHTML('<span data-mce-type="bookmark" id="'+y+'_start" style="'+p+'">'+b+"<\/span>");k||(v.collapse(!1),c.moveToElementText(v.parentElement()),0===c.compareEndPoints("StartToEnd",v)&&v.move("character",-1),v.pasteHTML('<span data-mce-type="bookmark" id="'+y+'_end" style="'+p+'">'+b+"<\/span>"))}catch(tt){return null}}else{if(l=o.getNode(),a=l.nodeName,"IMG"==a)return{name:a,index:w(a,l)};v=d(c.cloneRange());k||(v.collapse(!1),v.insertNode(s.create("span",{"data-mce-type":"bookmark",id:y+"_end",style:p},b)));c=d(c);c.collapse(!0);c.insertNode(s.create("span",{"data-mce-type":"bookmark",id:y+"_start",style:p},b))}return o.moveToBookmark({id:y,keep:1}),{id:y}};this.moveToBookmark=function(i){function l(n){var r=i[n?"start":"end"],f,t,e,o;if(r){for(e=r[0],t=y,f=r.length-1;f>=1;f--){if(o=t.childNodes,r[f]>o.length-1)return;t=o[r[f]]}3===t.nodeType&&(e=Math.min(r[0],t.nodeValue.length));1===t.nodeType&&(e=Math.min(r[0],t.childNodes.length));n?u.setStart(t,e):u.setEnd(t,e)}return!0}function a(r){var u=s.get(i.id+"_"+r),a,o,v,l,y=i.keep;if(u&&(a=u.parentNode,"start"==r?(y?(a=u.firstChild,o=1):o=s.nodeIndex(u),h=f=a,c=e=o):(y?(a=u.firstChild,o=1):o=s.nodeIndex(u),f=a,e=o),!y)){for(l=u.previousSibling,v=u.nextSibling,t.each(t.grep(u.childNodes),function(n){3==n.nodeType&&(n.nodeValue=n.nodeValue.replace(/\uFEFF/g,""))});u=s.get(i.id+"_"+r);)s.remove(u,1);l&&v&&l.nodeType==v.nodeType&&3==l.nodeType&&!n.opera&&(o=l.nodeValue.length,l.appendData(v.nodeValue),s.remove(v),"start"==r?(h=f=l,c=e=o):(f=l,e=o))}}function v(t){return!s.isBlock(t)||t.innerHTML||n.ie||(t.innerHTML='<br data-mce-bogus="1" />'),t}function p(){var t,n;return t=s.createRng(),n=r.resolve(s.getRoot(),i.start),t.setStart(n.container(),n.offset()),n=r.resolve(s.getRoot(),i.end),t.setEnd(n.container(),n.offset()),t}var u,y,h,f,c,e;if(i)if(t.isArray(i.start)){if(u=s.createRng(),y=s.getRoot(),o.tridentSel)return o.tridentSel.moveToBookmark(i);l(!0)&&l()&&o.setRng(u)}else"string"==typeof i.start?o.setRng(p(i)):i.id?(a("start"),a("end"),h&&(u=s.createRng(),u.setStart(v(h),c),u.setEnd(v(f),e),o.setRng(u))):i.name?o.select(s.select(i.name)[i.index]):i.rng&&o.setRng(i.rng)}}var e=f.isContentEditableFalse;return o.isBookmarkNode=function(n){return n&&"SPAN"===n.tagName&&"bookmark"===n.getAttribute("data-mce-type")},o});i(di,[p,bu,ki,y,pt,e,u,r,v],function(n,i,r,u,f,e,o,s,h){function l(n,t,u,e){var o=this;o.dom=n;o.win=t;o.serializer=u;o.editor=e;o.bookmarkManager=new f(o);o.controlSelection=new r(o,e);o.win.getSelection||(o.tridentSel=new i(o))}var c=s.each,a=s.trim,v=o.ie;return l.prototype={setCursorLocation:function(n,t){var i=this,r=i.dom.createRng();n?(r.setStart(n,t),r.setEnd(n,t),i.setRng(r),i.collapse(!1)):(i._moveEndPoint(r,i.editor.getBody(),!0),i.setRng(r))},getContent:function(n){var r=this,i=r.getRng(),u=r.dom.create("body"),s=r.getSel(),f,e,o;return n=n||{},f=e="",n.get=!0,n.format=n.format||"html",n.selection=!0,r.editor.fire("BeforeGetContent",n),"text"==n.format?r.isCollapsed()?"":i.text||(s.toString?s.toString():""):(i.cloneContents?(o=i.cloneContents(),o&&u.appendChild(o)):i.item!==t||i.htmlText!==t?(u.innerHTML="<br>"+(i.item?i.item(0).outerHTML:i.htmlText),u.removeChild(u.firstChild)):u.innerHTML=i.toString(),/^\s/.test(u.innerHTML)&&(f=" "),/\s+$/.test(u.innerHTML)&&(e=" "),n.getInner=!0,n.content=r.isCollapsed()?"":f+r.serializer.serialize(u,n)+e,r.editor.fire("GetContent",n),n.content)},setContent:function(n,t){var r=this,i=r.getRng(),f,u=r.win.document,e,o;if(t=t||{format:"html"},t.set=!0,t.selection=!0,t.content=n,t.no_events||r.editor.fire("BeforeSetContent",t),n=t.content,i.insertNode){n+='<span id="__caret">_<\/span>';i.startContainer==u&&i.endContainer==u?u.body.innerHTML=n:(i.deleteContents(),0===u.body.childNodes.length?u.body.innerHTML=n:i.createContextualFragment?i.insertNode(i.createContextualFragment(n)):(e=u.createDocumentFragment(),o=u.createElement("div"),e.appendChild(o),o.outerHTML=n,i.insertNode(e)));f=r.dom.get("__caret");i=u.createRange();i.setStartBefore(f);i.setEndBefore(f);r.setRng(i);r.dom.remove("__caret");try{r.setRng(i)}catch(s){}}else i.item&&(u.execCommand("Delete",!1,null),i=r.getRng()),/^\s+/.test(n)?(i.pasteHTML('<span id="__mce_tmp">_<\/span>'+n),r.dom.remove("__mce_tmp")):i.pasteHTML(n);t.no_events||r.editor.fire("SetContent",t)},getStart:function(n){var u=this,i=u.getRng(),t,e,f,r;if(i.duplicate||i.item){if(i.item)return i.item(0);for(f=i.duplicate(),f.collapse(1),t=f.parentElement(),t.ownerDocument!==u.dom.doc&&(t=u.dom.getRoot()),e=r=i.parentElement();r=r.parentNode;)if(r==t){t=e;break}return t}return t=i.startContainer,1==t.nodeType&&t.hasChildNodes()&&(n&&i.collapsed||(t=t.childNodes[Math.min(t.childNodes.length-1,i.startOffset)])),t&&3==t.nodeType?t.parentNode:t},getEnd:function(n){var u=this,i=u.getRng(),t,r;return i.duplicate||i.item?i.item?i.item(0):(i=i.duplicate(),i.collapse(0),t=i.parentElement(),t.ownerDocument!==u.dom.doc&&(t=u.dom.getRoot()),t&&"BODY"==t.nodeName?t.lastChild||t:t):(t=i.endContainer,r=i.endOffset,1==t.nodeType&&t.hasChildNodes()&&(n&&i.collapsed||(t=t.childNodes[r>0?r-1:r])),t&&3==t.nodeType?t.parentNode:t)},getBookmark:function(n,t){return this.bookmarkManager.getBookmark(n,t)},moveToBookmark:function(n){return this.bookmarkManager.moveToBookmark(n)},select:function(n,t){var i=this,f=i.dom,r=f.createRng(),u;if(i.lastFocusBookmark=null,n){if(!t&&i.controlSelection.controlSelect(n))return;u=f.nodeIndex(n);r.setStart(n.parentNode,u);r.setEnd(n.parentNode,u+1);t&&(i._moveEndPoint(r,n,!0),i._moveEndPoint(r,n));i.setRng(r)}return n},isCollapsed:function(){var t=this,n=t.getRng(),i=t.getSel();return!n||n.item?!1:n.compareEndPoints?0===n.compareEndPoints("StartToEnd",n):!i||n.collapsed},collapse:function(n){var i=this,t=i.getRng(),r;t.item&&(r=t.item(0),t=i.win.document.body.createTextRange(),t.moveToElementText(r));t.collapse(!!n);i.setRng(t)},getSel:function(){var n=this.win;return n.getSelection?n.getSelection():n.document.selection},getRng:function(n){function h(n,t,i){try{return t.compareBoundaryPoints(n,i)}catch(r){return-1}}var i=this,e,t,f,r,o,s,u;if(!i.win)return null;if(r=i.win.document,!n&&i.lastFocusBookmark)return u=i.lastFocusBookmark,u.startContainer?(t=r.createRange(),t.setStart(u.startContainer,u.startOffset),t.setEnd(u.endContainer,u.endOffset)):t=u,t;if(n&&i.tridentSel)return i.tridentSel.getRangeAt(0);try{(e=i.getSel())&&(t=e.rangeCount>0?e.getRangeAt(0):e.createRange?e.createRange():r.createRange())}catch(c){}if(s=i.editor.fire("GetSelectionRange",{range:t}),s.range!==t)return s.range;if(v&&t&&t.setStart&&r.selection){try{o=r.selection.createRange()}catch(c){}o&&o.item&&(f=o.item(0),t=r.createRange(),t.setStartBefore(f),t.setEndAfter(f))}return t||(t=r.createRange?r.createRange():r.body.createTextRange()),t.setStart&&9===t.startContainer.nodeType&&t.collapsed&&(f=i.dom.getRoot(),t.setStart(f,0),t.setEnd(f,0)),i.selectedRange&&i.explicitRange&&(0===h(t.START_TO_START,t,i.selectedRange)&&0===h(t.END_TO_END,t,i.selectedRange)?t=i.explicitRange:(i.selectedRange=null,i.explicitRange=null)),t},setRng:function(n,t){var r=this,i,u,f;if(n)if(n.select){r.explicitRange=null;try{n.select()}catch(e){}}else if(r.tridentSel){if(n.cloneRange)try{r.tridentSel.addRange(n)}catch(e){}}else{if(i=r.getSel(),f=r.editor.fire("SetSelectionRange",{range:n}),n=f.range,i){r.explicitRange=n;try{i.removeAllRanges();i.addRange(n)}catch(e){}t===!1&&i.extend&&(i.collapse(n.endContainer,n.endOffset),i.extend(n.startContainer,n.startOffset));r.selectedRange=i.rangeCount>0?i.getRangeAt(0):null}n.collapsed||n.startContainer!=n.endContainer||!i.setBaseAndExtent||o.ie||n.endOffset-n.startOffset<2&&n.startContainer.hasChildNodes()&&(u=n.startContainer.childNodes[n.startOffset],u&&"IMG"==u.tagName&&r.getSel().setBaseAndExtent(u,0,u,1))}},setNode:function(n){var t=this;return t.setContent(t.dom.getOuterHTML(n)),n},getNode:function(){function o(n,t){for(var i=n;n&&3===n.nodeType&&0===n.length;)n=t?n.nextSibling:n.previousSibling;return n||i}var f=this,t=f.getRng(),i,n,r,u,e,s=f.dom.getRoot();return t?(n=t.startContainer,r=t.endContainer,u=t.startOffset,e=t.endOffset,t.setStart?(i=t.commonAncestorContainer,!t.collapsed&&(n==r&&2>e-u&&n.hasChildNodes()&&(i=n.childNodes[u]),3===n.nodeType&&3===r.nodeType&&(n=n.length===u?o(n.nextSibling,!0):n.parentNode,r=0===e?o(r.previousSibling,!1):r.parentNode,n&&n===r))?n:i&&3==i.nodeType?i.parentNode:i):(i=t.item?t.item(0):t.parentElement(),i.ownerDocument!==f.win.document&&(i=s),i)):s},getSelectedBlocks:function(t,i){var o=this,r=o.dom,u,f,e=[],s;if(f=r.getRoot(),t=r.getParent(t||o.getStart(),r.isBlock),i=r.getParent(i||o.getEnd(),r.isBlock),t&&t!=f&&e.push(t),t&&i&&t!=i)for(u=t,s=new n(t,f);(u=s.next())&&u!=i;)r.isBlock(u)&&e.push(u);return i&&t!=i&&i!=f&&e.push(i),e},isForward:function(){var r=this.dom,n=this.getSel(),t,i;return n&&n.anchorNode&&n.focusNode?(t=r.createRng(),t.setStart(n.anchorNode,n.anchorOffset),t.collapse(!0),i=r.createRng(),i.setStart(n.focusNode,n.focusOffset),i.collapse(!0),t.compareBoundaryPoints(t.START_TO_START,i)<=0):!0},normalize:function(){var n=this,t=n.getRng();return o.range&&new u(n.dom).normalize(t)&&n.setRng(t,n.isForward()),t},selectorChanged:function(n,t){var i=this,r;return i.selectorChangedData||(i.selectorChangedData={},r={},i.editor.on("NodeChange",function(n){var f=n.element,t=i.dom,u=t.getParents(f,null,t.getRoot()),e={};c(i.selectorChangedData,function(n,i){c(u,function(f){if(t.is(f,i))return(r[i]||(c(n,function(n){n(!0,{node:f,selector:i,parents:u})}),r[i]=n),e[i]=n,!1)})});c(r,function(n,t){e[t]||(delete r[t],c(n,function(n){n(!1,{node:f,selector:t,parents:u})}))})})),i.selectorChangedData[n]||(i.selectorChangedData[n]=[]),i.selectorChangedData[n].push(t),i},getScrollContainer:function(){for(var t,n=this.dom.getRoot();n&&"BODY"!=n.nodeName;){if(n.scrollHeight>n.clientHeight){t=n;break}n=n.parentNode}return t},scrollIntoView:function(n,t){function l(n){for(var i=0,r=0,t=n;t&&t.nodeType;)i+=t.offsetLeft||0,r+=t.offsetTop||0,t=t.offsetParent;return{x:i,y:r}}var i,o,s=this,h=s.dom,a=h.getRoot(),r,u,c=0,f;if(e.isElement(n)){if((t===!1&&(c=n.offsetHeight),"BODY"!=a.nodeName)&&(f=s.getScrollContainer(),f))return i=l(n).y-l(f).y+c,u=f.clientHeight,r=f.scrollTop,void((r>i||i+25>r+u)&&(f.scrollTop=r>i?i:i-u+25));o=h.getViewPort(s.editor.getWin());i=h.getPos(n).y+c;r=o.y;u=o.h;(i<o.y||i+25>r+u)&&s.editor.getWin().scrollTo(0,r>i?i:i-u+25)}},placeCaretAt:function(n,t){this.setRng(u.getCaretRangeFromPoint(n,t,this.editor.getDoc()))},_moveEndPoint:function(t,i,r){var u=i,f=new n(i,u),e=this.dom.schema.getNonEmptyElements();do{if(3==i.nodeType&&0!==a(i.nodeValue).length)return void(r?t.setStart(i,0):t.setEnd(i,i.nodeValue.length));if(e[i.nodeName]&&!/^(TD|TH)$/.test(i.nodeName))return void(r?t.setStartBefore(i):"BR"==i.nodeName?t.setEndBefore(i):t.setEndAfter(i));if(o.ie&&o.ie<11&&this.dom.isBlock(i)&&this.dom.isEmpty(i))return void(r?t.setStart(i,0):t.setEnd(i,0))}while(i=r?f.next():f.prev());"BODY"==u.nodeName&&(r?t.setStart(u,0):t.setEnd(u,u.childNodes.length))},getBoundingClientRect:function(){var n=this.getRng();return n.collapsed?h.fromRangeStart(n).getClientRects()[0]:n.getBoundingClientRect()},destroy:function(){this.win=null;this.controlSelection.destroy()}},l});i(gi,[pt,r],function(n,t){function i(t){this.compare=function(i,u){function f(n){var i={};return r(t.getAttribs(n),function(r){var u=r.nodeName.toLowerCase();0!==u.indexOf("_")&&"style"!==u&&"data-mce-style"!==u&&"data-mce-fragment"!=u&&(i[u]=t.getAttrib(n,u))}),i}function e(n,t){var r;for(var i in n)if(n.hasOwnProperty(i)){if((r=t[i],"undefined"==typeof r)||n[i]!=r)return!1;delete t[i]}for(i in t)if(t.hasOwnProperty(i))return!1;return!0}return i.nodeName!=u.nodeName?!1:e(f(i),f(u))&&e(t.parseStyle(t.getAttrib(i,"style")),t.parseStyle(t.getAttrib(u,"style")))?!n.isBookmarkNode(i)&&!n.isBookmarkNode(u):!1}}var r=t.each;return i});i(gu,[r],function(n){function i(n,i){function o(n){return n.replace(/%(\w+)/g,"")}var h,u,r=n.dom,s="",f,e;if(e=n.settings.preview_styles,e===!1)return"";if(e||(e="font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow"),"string"==typeof i){if(i=n.formatter.get(i),!i)return;i=i[0]}return h=i.block||i.inline||"span",u=r.create(h),t(i.styles,function(n,t){n=o(n);n&&r.setStyle(u,t,n)}),t(i.attributes,function(n,t){n=o(n);n&&r.setAttrib(u,t,n)}),t(i.classes,function(n){n=o(n);r.hasClass(u,n)||r.addClass(u,n)}),n.fire("PreviewFormats"),r.setStyles(u,{position:"absolute",left:-65535}),n.getBody().appendChild(u),f=r.getStyle(n.getBody(),"fontSize",!0),f=/px$/.test(f)?parseInt(f,10):0,t(e.split(" "),function(t){var i=r.getStyle(u,t,!0);if(!("background-color"==t&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(i)&&(i=r.getStyle(n.getBody(),t,!0),"#ffffff"==r.toHex(i).toLowerCase())||"color"==t&&"#000000"==r.toHex(i).toLowerCase())){if("font-size"==t&&/em|%$/.test(i)){if(0===f)return;i=parseFloat(i,10)/(/%$/.test(i)?100:1);i=i*f+"px"}"border"==t&&i&&(s+="padding:0 2px;");s+=t+":"+i+";"}}),n.fire("AfterPreviewFormats"),r.remove(u),s}var t=n.each;return{getCssText:i}});i(nf,[c,e,s],function(n,t,i){function e(n,t){var i=r[n];i||(r[n]=i=[]);r[n].push(t)}function o(n,t){f(r[n],function(n){n(t)})}var r=[],u=n.filter,f=n.each;return e("pre",function(r){function s(t){return e(t.previousSibling)&&-1!=n.indexOf(o,t.previousSibling)}function h(n,t){i(t).remove();i(n).append("<br><br>").append(t.childNodes)}var c=r.selection.getRng(),e,o;e=t.matchNodeNames("pre");c.collapsed||(o=r.selection.getSelectedBlocks(),f(u(u(o,e),s),function(n){h(n.previousSibling,n)}))}),{postProcess:o}});i(nr,[p,y,pt,gi,r,gu,nf],function(n,t,i,r,u,f,e){return function(o){function pt(n){return n.nodeType&&(n=n.nodeName),!!o.schema.getTextBlockElements()[n.toLowerCase()]}function wt(n){return/^(TH|TD)$/.test(n.nodeName)}function vi(n){return n&&/^(IMG)$/.test(n.nodeName)}function rt(n,t){return s.getParents(n,t,s.getRoot())}function bt(n){return 1===n.nodeType&&"_mce_caret"===n.id}function yi(){ut({valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}],alignleft:[{selector:"figure.image",collapsed:!1,classes:"align-left",ceFalseOverride:!0},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"left"},inherit:!1,defaultBlock:"div"},{selector:"img,table",collapsed:!1,styles:{float:"left"}}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"center"},inherit:!1,defaultBlock:"div"},{selector:"figure.image",collapsed:!1,classes:"align-center",ceFalseOverride:!0},{selector:"img",collapsed:!1,styles:{display:"block",marginLeft:"auto",marginRight:"auto"}},{selector:"table",collapsed:!1,styles:{marginLeft:"auto",marginRight:"auto"}}],alignright:[{selector:"figure.image",collapsed:!1,classes:"align-right",ceFalseOverride:!0},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"right"},inherit:!1,defaultBlock:"div"},{selector:"img,table",collapsed:!1,styles:{float:"right"}}],alignjustify:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"justify"},inherit:!1,defaultBlock:"div"}],bold:[{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b",remove:"all"}],italic:[{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i",remove:"all"}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:!0},{inline:"u",remove:"all"}],strikethrough:[{inline:"span",styles:{textDecoration:"line-through"},exact:!0},{inline:"strike",remove:"all"}],forecolor:{inline:"span",styles:{color:"%value"},links:!0,remove_similar:!0},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},links:!0,remove_similar:!0},fontname:{inline:"span",styles:{fontFamily:"%value"}},fontsize:{inline:"span",styles:{fontSize:"%value"}},fontsize_class:{inline:"span",attributes:{"class":"%value"}},blockquote:{block:"blockquote",wrapper:1,remove:"all"},subscript:{inline:"sub"},superscript:{inline:"sup"},code:{inline:"code"},link:{inline:"a",selector:"a",remove:"all",split:!0,deep:!0,onmatch:function(){return!0},onformat:function(n,t,i){c(i,function(t,i){s.setAttrib(n,i,t)})}},removeformat:[{selector:"b,strong,em,i,font,u,strike,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins",remove:"all",split:!0,expand:!1,block_expand:!0,deep:!0},{selector:"span",attributes:["style","class"],remove:"empty",split:!0,expand:!1,deep:!0},{selector:"*",attributes:["style","class"],split:!1,expand:!1,deep:!0}]});c("p h1 h2 h3 h4 h5 h6 div address pre div dt dd samp".split(/\s/),function(n){ut(n,{block:n,remove:"all"})});ut(o.settings.formats)}function pi(){o.addShortcut("meta+b","bold_desc","Bold");o.addShortcut("meta+i","italic_desc","Italic");o.addShortcut("meta+u","underline_desc","Underline");for(var n=1;6>=n;n++)o.addShortcut("access+"+n,"",["FormatBlock",!1,"h"+n]);o.addShortcut("access+7","",["FormatBlock",!1,"p"]);o.addShortcut("access+8","",["FormatBlock",!1,"div"]);o.addShortcut("access+9","",["FormatBlock",!1,"address"])}function w(n){return n?it[n]:it}function ut(n,t){n&&("string"!=typeof n?c(n,function(n,t){ut(t,n)}):(t=t.length?t:[t],c(t,function(n){n.deep===ht&&(n.deep=!n.selector);n.split===ht&&(n.split=!n.selector||n.inline);n.remove===ht&&n.selector&&!n.inline&&(n.remove="none");n.selector&&n.inline&&(n.mixed=!0,n.block_expand=!0);"string"==typeof n.classes&&(n.classes=n.classes.split(/\s+/))}),it[n]=t))}function wi(n){return n&&it[n]&&delete it[n],it}function fi(n,t){var r=w(t),i;if(r)for(i=0;i<r.length;i++)if(r[i].inherit===!1&&s.is(n,r[i].selector))return!0;return!1}function ei(n){var t;return o.dom.getParent(n,function(n){return t=o.dom.getStyle(n,"text-decoration"),t&&"none"!==t}),t}function oi(n){var t;1===n.nodeType&&n.parentNode&&1===n.parentNode.nodeType&&(t=ei(n.parentNode),o.dom.getStyle(n,"color")&&t?o.dom.setStyle(n,"text-decoration",t):o.dom.getStyle(n,"text-decoration")===t&&o.dom.setStyle(n,"text-decoration",null))}function tt(t,i,r){function g(n,t){if(t=t||u,n){if(t.onformat&&t.onformat(n,t,i,r),c(t.styles,function(t,r){s.setStyle(n,r,d(t,i))}),t.styles){var f=s.getAttrib(n,"style");f&&n.setAttribute("data-mce-style",f)}c(t.attributes,function(t,r){s.setAttrib(n,r,d(t,i))});c(t.classes,function(t){t=d(t,i);s.hasClass(n,t)||s.addClass(n,t)})}}function wt(){function s(t,i){var u=new n(i);for(r=u.prev2();r;r=u.prev2())if(3==r.nodeType&&r.data.length>0||r.childNodes.length>1||r==t||"BR"==r.tagName)return r}var t=o.selection.getRng(),u=t.startContainer,f=t.endContainer,i,e;return u!=f&&0===t.endOffset&&(i=s(u,f),e=3==i.nodeType?i.data.length:i.childNodes.length,t.setEnd(i,e)),t}function ut(n,r,e){var w=[],o,d,h=!0;o=u.inline||u.block;d=s.create(o);g(d);at.walk(n,function(n){function l(n){var v,tt,rt,nt,it;return it=h,v=n.nodeName.toLowerCase(),tt=n.parentNode.nodeName.toLowerCase(),1===n.nodeType&&k(n)&&(it=h,h="true"===k(n),nt=!0),b(v,"br")?(r=0,void(u.block&&s.remove(n))):u.wrapper&&p(n,t,i)?void(r=0):h&&!nt&&u.block&&!u.wrapper&&pt(v)&&vt(tt,o)?(n=s.rename(n,o),g(n),w.push(n),void(r=0)):u.selector&&(c(f,function(t){if(!("collapsed"in t)||t.collapsed===ht)return s.is(n,t.selector)&&!bt(n)?(g(n,t),rt=!0,!1):void 0}),!u.inline||rt)?void(r=0):void(!h||nt||!vt(o,v)||!vt(tt,o)||!e&&3===n.nodeType&&1===n.nodeValue.length&&65279===n.nodeValue.charCodeAt(0)||bt(n)||u.inline&&a(n)?(r=0,c(ct(n.childNodes),l),nt&&(h=it),r=0):(r||(r=s.clone(d,y),n.parentNode.insertBefore(r,n),w.push(r)),r.appendChild(n)))}var r;c(n,l)});u.links===!0&&c(w,function(n){function t(n){"A"===n.nodeName&&g(n,u);c(ct(n.childNodes),t)}t(n)});c(w,function(n){function e(n){var t=0;return c(n.childNodes,function(n){ft(n)||v(n)||t++}),t}function o(n){var t,i;return c(n.childNodes,function(n){if(1==n.nodeType&&!v(n)&&!bt(n))return(t=n,y)}),t&&!v(t)&&gt(t,u)&&(i=s.clone(t,y),g(i),s.replace(i,n,l),s.remove(t,1)),i||n}var r;if(r=e(n),(w.length>1||!a(n))&&0===r)return void s.remove(n,1);if(u.inline||u.wrapper){if(u.exact||1!==r||(n=o(n)),c(f,function(t){c(s.select(t.inline,n),function(n){v(n)||ot(t,i,n,t.exact?n:null)})}),p(n.parentNode,t,i))return s.remove(n,1),n=0,l;u.merge_with_parents&&s.getParent(n.parentNode,function(r){if(p(r,t,i))return(s.remove(n,1),n=0,l)});n&&u.merge_siblings!==!1&&(n=si(ii(n),n),n=si(n,ii(n,l)))}})}var f=w(t),u=f[0],st,it,ht=!r&&h.isCollapsed(),rt,nt,lt;if("false"!==k(h.getNode()))u&&(r?r.nodeType?(it=s.createRng(),it.setStartBefore(r),it.setEndAfter(r),ut(et(it,f),null,!0)):ut(r,null,!0):ht&&u.inline&&!s.select("td[data-mce-selected],th[data-mce-selected]").length?ci("apply",t,i):(rt=o.selection.getNode(),yt||!f[0].defaultBlock||s.getParent(rt,s.isBlock)||tt(f[0].defaultBlock),o.selection.setRng(wt()),st=h.getBookmark(),ut(et(h.getRng(l),f),st),u.styles&&(u.styles.color||u.styles.textDecoration)&&(ai(rt,oi,"childNodes"),oi(rt)),h.moveToBookmark(st),li(h.getRng(l)),o.nodeChanged()),e.postProcess(t,o));else for(r=h.getNode(),nt=0,lt=f.length;lt>nt;nt++)if(f[nt].ceFalseOverride&&s.is(r,f[nt].selector))return void g(r,f[nt])}function kt(n,t,i,r){function it(n){var r,i,e,s,o;if(1===n.nodeType&&k(n)&&(s=g,g="true"===k(n),o=!0),r=ct(n.childNodes),g&&!o)for(i=0,e=u.length;e>i&&!ot(u[i],t,n,n);i++);if(f.deep&&r.length){for(i=0,e=r.length;e>i;i++)it(r[i]);o&&(g=s)}}function ht(i){var u;return c(rt(i.parentNode).reverse(),function(i){var f;u||"_start"==i.id||"_end"==i.id||(f=p(i,n,t,r),f&&f.split!==!1&&(u=i))}),u}function vt(n,i,r,e){var h,o,c,v,l,p;if(n){for(p=n.parentNode,h=i.parentNode;h&&h!=p;h=h.parentNode){for(o=s.clone(h,y),l=0;l<u.length;l++)if(ot(u[l],t,o,o)){o=0;break}o&&(c&&o.appendChild(c),v||(v=o),c=o)}!e||f.mixed&&a(n)||(i=s.split(n,i));c&&(r.parentNode.insertBefore(c,r),v.appendChild(r))}return i}function b(n){return vt(ht(n),n,n,!0)}function nt(n){var i=s.get(n?"_start":"_end"),t=i[n?"firstChild":"lastChild"];return v(t)&&(t=t[n?"firstChild":"lastChild"]),3==t.nodeType&&0===t.data.length&&(t=n?i.previousSibling||i.nextSibling:i.nextSibling||i.previousSibling),s.remove(i,!0),t}function tt(n){var t,i,r=n.commonAncestorContainer;if(n=et(n,u,l),f.split){if(t=hi(n,l),i=hi(n),t!=i){if(/^(TR|TH|TD)$/.test(t.nodeName)&&t.firstChild&&(t="TR"==t.nodeName?t.firstChild.firstChild||t:t.firstChild||t),r&&/^T(HEAD|BODY|FOOT|R)$/.test(r.nodeName)&&wt(i)&&i.firstChild&&(i=i.firstChild||i),s.isChildOf(t,i)&&!a(i)&&!wt(t)&&!wt(i))return t=lt(t,"span",{id:"_start","data-mce-type":"bookmark"}),b(t),void(t=nt(l));t=lt(t,"span",{id:"_start","data-mce-type":"bookmark"});i=lt(i,"span",{id:"_end","data-mce-type":"bookmark"});b(t);b(i);t=nt(l);i=nt()}else t=i=b(t);n.startContainer=t.parentNode?t.parentNode:t;n.startOffset=st(t);n.endContainer=i.parentNode?i.parentNode:i;n.endOffset=st(i)+1}at.walk(n,function(n){c(n,function(n){it(n);1===n.nodeType&&"underline"===o.dom.getStyle(n,"text-decoration")&&n.parentNode&&"underline"===ei(n.parentNode)&&ot({deep:!1,exact:!0,inline:"span",styles:{textDecoration:"underline"}},null,n)})})}var u=w(n),f=u[0],ut,d,g=!0,e,ft;if(i)return void(i.nodeType?(d=s.createRng(),d.setStartBefore(i),d.setEndAfter(i),tt(d)):tt(i));if("false"!==k(h.getNode()))h.isCollapsed()&&f.inline&&!s.select("td[data-mce-selected],th[data-mce-selected]").length?ci("remove",n,t,r):(ut=h.getBookmark(),tt(h.getRng(l)),h.moveToBookmark(ut),f.inline&&dt(n,t,h.getStart())&&li(h.getRng(!0)),o.nodeChanged());else for(i=h.getNode(),e=0,ft=u.length;ft>e&&(!u[e].ceFalseOverride||!ot(u[e],t,i,i));e++);}function bi(n,t,i){var r=w(n);!dt(n,t,i)||"toggle"in r[0]&&!r[0].toggle?tt(n,t,i):kt(n,t,i)}function p(n,t,i,r){function h(n,t,u){var e,h,f=t[u],o;if(t.onmatch)return t.onmatch(n,t,u);if(f)if(f.length===ht){for(e in f)if(f.hasOwnProperty(e)){if(h="attributes"===u?s.getAttrib(n,e):ni(n,e),r&&!h&&!t.exact)return;if((!r||t.exact)&&!b(h,ti(d(f[e],i),e)))return}}else for(o=0;o<f.length;o++)if("attributes"===u?s.getAttrib(n,f[o]):ni(n,f[o]))return t;return t}var e=w(t),f,u,o;if(e&&n)for(u=0;u<e.length;u++)if(f=e[u],gt(n,f)&&h(n,f,"attributes")&&h(n,f,"styles")){if(o=f.classes)for(u=0;u<o.length;u++)if(!s.hasClass(n,o[u]))return;return f}}function dt(n,t,i){function r(i){var r=s.getRoot();return i===r?!1:(i=s.getParent(i,function(i){return fi(i,n)?!0:i.parentNode===r||!!p(i,n,t,!0)}),p(i,n,t))}var u;return i?r(i):(i=h.getNode(),r(i)?l:(u=h.getStart(),u!=i&&r(u)?l:y))}function ki(n,t){var i,r=[],u={};return i=h.getStart(),s.getParent(i,function(i){for(var f,e=0;e<n.length;e++)f=n[e],!u[f]&&p(i,f,t)&&(u[f]=!0,r.push(f))},s.getRoot()),r}function di(n){var i=w(n),e,u,r,t,f;if(i)for(e=h.getStart(),u=rt(e),t=i.length-1;t>=0;t--){if(f=i[t].selector,!f||i[t].defaultBlock)return l;for(r=u.length-1;r>=0;r--)if(s.is(u[r],f))return l}return y}function gi(n,t,i){var r;return nt||(nt={},r={},o.on("NodeChange",function(n){var t=rt(n.element),i={};t=u.grep(t,function(n){return 1==n.nodeType&&!n.getAttribute("data-mce-bogus")});c(nt,function(n,u){c(t,function(f){return p(f,u,{},n.similar)?(r[u]||(c(n,function(n){n(!0,{node:f,format:u,parents:t})}),r[u]=n),i[u]=n,!1):fi(f,u)?!1:void 0})});c(r,function(u,f){i[f]||(delete r[f],c(u,function(i){i(!1,{node:n.element,format:f,parents:t})}))})})),c(n.split(","),function(n){nt[n]||(nt[n]=[],nt[n].similar=i);nt[n].push(t)}),this}function nr(n){return f.getCssText(o,n)}function gt(n,t){return b(n,t.inline)?l:b(n,t.block)?l:t.selector?1==n.nodeType&&s.is(n,t.selector):void 0}function b(n,t){return n=n||"",t=t||"",n=""+(n.nodeName||n),t=""+(t.nodeName||t),n.toLowerCase()==t.toLowerCase()}function ni(n,t){return ti(s.getStyle(n,t),t)}function ti(n,t){return"color"!=t&&"backgroundColor"!=t||(n=s.toHex(n)),"fontWeight"==t&&700==n&&(n="bold"),"fontFamily"==t&&(n=n.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),""+n}function d(n,t){return"string"!=typeof n?n=n(t):t&&(n=n.replace(/%(\w+)/g,function(n,i){return t[i]||n})),n}function ft(n){return n&&3===n.nodeType&&/^([\t \r\n]+|)$/.test(n.nodeValue)}function lt(n,t,i){var r=s.create(t,i);return n.parentNode.insertBefore(r,n),r.appendChild(n),r}function et(t,i,r){function w(n){function y(n){return"BR"==n.nodeName&&n.getAttribute("data-mce-bogus")&&!n.nextSibling}var r,t,e,o,l;if(r=t=n?f:u,o=n?"previousSibling":"nextSibling",l=s.getRoot(),3==r.nodeType&&!ft(r)&&(n?c>0:h<r.nodeValue.length))return r;for(;;){if(!i[0].block_expand&&a(t))return t;for(e=t[o];e;e=e[o])if(!v(e)&&!ft(e)&&!y(e))return t;if(t==l||t.parentNode==l){r=t;break}t=t.parentNode}return r}function d(n,t){for(t===ht&&(t=3===n.nodeType?n.length:n.childNodes.length);n&&n.hasChildNodes();)n=n.childNodes[t],n&&(t=3===n.nodeType?n.length:n.childNodes.length);return{node:n,offset:t}}function g(n){for(var t=n;t;){if(1===t.nodeType&&k(t))return"false"===k(t)?t:n;t=t.parentNode}return n}function nt(t,i,u){function c(n,t){var i,f,e=n.nodeValue;return"undefined"==typeof t&&(t=u?e.length:0),u?(i=e.lastIndexOf(" ",t),f=e.lastIndexOf(" ",t),i=i>f?i:f,-1===i||r||i++):(i=e.indexOf(" ",t),f=e.indexOf(" ",t),i=-1!==i&&(-1===f||f>i)?i:f),i}var l,f,e,h;if(3===t.nodeType){if(e=c(t,i),-1!==e)return{container:t,offset:e};h=t}for(l=new n(t,s.getParent(t,a)||o.getBody());f=l[u?"prev":"next"]();)if(3===f.nodeType){if(h=f,e=c(f),-1!==e)return{container:f,offset:e}}else if(a(f))break;if(h)return(i=u?0:h.length,{container:h,offset:i})}function tt(n,r){var f,u,e,o;for(3==n.nodeType&&0===n.nodeValue.length&&n[r]&&(n=n[r]),f=rt(n),u=0;u<f.length;u++)for(e=0;e<i.length;e++)if(o=i[e],!("collapsed"in o&&o.collapsed!==t.collapsed)&&s.is(f[u],o.selector))return f[u];return n}function it(n,t){var r,u=s.getRoot();if(i[0].wrapper||(r=s.getParent(n,i[0].block,u)),r||(r=s.getParent(3==n.nodeType?n.parentNode:n,function(n){return n!=u&&pt(n)})),r&&i[0].wrapper&&(r=rt(r,"ul,ol").reverse()[0]||r),!r)for(r=n;r[t]&&!a(r[t])&&(r=r[t],!b(r,"br")););return r||n}var p,e,l,f=t.startContainer,c=t.startOffset,u=t.endContainer,h=t.endOffset;if(1==f.nodeType&&f.hasChildNodes()&&(p=f.childNodes.length-1,f=f.childNodes[c>p?p:c],3==f.nodeType&&(c=0)),1==u.nodeType&&u.hasChildNodes()&&(p=u.childNodes.length-1,u=u.childNodes[h>p?p:h-1],3==u.nodeType&&(h=u.nodeValue.length)),f=g(f),u=g(u),(v(f.parentNode)||v(f))&&(f=v(f)?f:f.parentNode,f=f.nextSibling||f,3==f.nodeType&&(c=0)),(v(u.parentNode)||v(u))&&(u=v(u)?u:u.parentNode,u=u.previousSibling||u,3==u.nodeType&&(h=u.length)),i[0].inline&&(t.collapsed&&(l=nt(f,c,!0),l&&(f=l.container,c=l.offset),l=nt(u,h),l&&(u=l.container,h=l.offset)),e=d(u,h),e.node)){for(;e.node&&0===e.offset&&e.node.previousSibling;)e=d(e.node.previousSibling);e.node&&e.offset>0&&3===e.node.nodeType&&" "===e.node.nodeValue.charAt(e.offset-1)&&e.offset>1&&(u=e.node,u.splitText(e.offset-1))}return(i[0].inline||i[0].block_expand)&&(i[0].inline&&3==f.nodeType&&0!==c||(f=w(!0)),i[0].inline&&3==u.nodeType&&h!==u.nodeValue.length||(u=w())),i[0].selector&&i[0].expand!==y&&!i[0].inline&&(f=tt(f,"previousSibling"),u=tt(u,"nextSibling")),(i[0].block||i[0].selector)&&(f=it(f,"previousSibling"),u=it(u,"nextSibling"),i[0].block&&(a(f)||(f=w(!0)),a(u)||(u=w()))),1==f.nodeType&&(c=st(f),f=f.parentNode),1==u.nodeType&&(h=st(u)+1,u=u.parentNode),{startContainer:f,startOffset:c,endContainer:u,endOffset:h}}function tr(n,t){return t.links&&"A"==n.tagName}function ot(n,t,i,r){var u,f,e;if(!gt(i,n)&&!tr(i,n))return y;if("all"!=n.remove)for(c(n.styles,function(u,f){u=ti(d(u,t),f);"number"==typeof f&&(f=u,r=0);(n.remove_similar||!r||b(ni(r,f),u))&&s.setStyle(i,f,"");e=1}),e&&""===s.getAttrib(i,"style")&&(i.removeAttribute("style"),i.removeAttribute("data-mce-style")),c(n.attributes,function(n,u){var f;if(n=d(n,t),"number"==typeof u&&(u=n,r=0),!r||b(s.getAttrib(r,u),n)){if("class"==u&&(n=s.getAttrib(i,u),n&&(f="",c(n.split(/\s+/),function(n){/mce\-\w+/.test(n)&&(f+=(f?" ":"")+n)}),f)))return void s.setAttrib(i,u,f);"class"==u&&i.removeAttribute("className");rr.test(u)&&i.removeAttribute("data-mce-"+u);i.removeAttribute(u)}}),c(n.classes,function(n){n=d(n,t);r&&!s.hasClass(r,n)||s.removeClass(i,n)}),f=s.getAttribs(i),u=0;u<f.length;u++)if(0!==f[u].nodeName.indexOf("_"))return y;if("none"!=n.remove)return(ir(i,n),l)}function ir(n,t){function r(n,t,i){return n=ii(n,t,i),!n||"BR"==n.nodeName||a(n)}var u=n.parentNode,i;t.block&&(yt?u==s.getRoot()&&(t.list_block&&b(n,t.list_block)||c(ct(n.childNodes),function(n){vt(yt,n.nodeName.toLowerCase())?i?i.appendChild(n):(i=lt(n,yt),s.setAttribs(i,o.settings.forced_root_block_attrs)):i=0})):a(n)&&!a(u)&&(r(n,y)||r(n.firstChild,l,1)||n.insertBefore(s.create("br"),n.firstChild),r(n,l)||r(n.lastChild,y,1)||n.appendChild(s.create("br"))));t.selector&&t.inline&&!b(t.inline,n)||s.remove(n,1)}function ii(n,t,i){if(n)for(t=t?"nextSibling":"previousSibling",n=i?n:n[t];n;n=n[t])if(1==n.nodeType||!ft(n))return n}function si(n,t){function u(n,t){for(i=n;i;i=i[t]){if(3==i.nodeType&&0!==i.nodeValue.length)return n;if(1==i.nodeType&&!v(i))return i}return n}var i,f,e=new r(s);if(n&&t&&(n=u(n,"previousSibling"),t=u(t,"nextSibling"),e.compare(n,t))){for(i=n.nextSibling;i&&i!=t;)f=i,i=i.nextSibling,n.appendChild(f);return s.remove(t),c(ct(t.childNodes),function(t){n.appendChild(t)}),n}return t}function hi(t,i){var r,u,f;return r=t[i?"startContainer":"endContainer"],u=t[i?"startOffset":"endOffset"],1==r.nodeType&&(f=r.childNodes.length-1,!i&&u&&u--,r=r.childNodes[u>f?f:u]),3===r.nodeType&&i&&u>=r.nodeValue.length&&(r=new n(r,o.getBody()).next()||r),3!==r.nodeType||i||0!==u||(r=new n(r,o.getBody()).prev()||r),r}function ci(t,i,r,u){function l(n){var t=s.create("span",{id:c,"data-mce-bogus":!0,style:d?"color:red":""});return n&&t.appendChild(o.getDoc().createTextNode(g)),t}function a(n,t){for(;n;){if(3===n.nodeType&&n.nodeValue!==g||n.childNodes.length>1)return!1;t&&1===n.nodeType&&t.push(n);n=n.firstChild}return!0}function f(n){for(;n;){if(n.id===c)return n;n=n.parentNode}}function v(t){var i;if(t)for(i=new n(t,t),t=i.current();t;t=i.next())if(3===t.nodeType)return t}function e(n,t){var r,i;if(n)i=h.getRng(!0),a(n)?(t!==!1&&(i.setStartBefore(n),i.setEndBefore(n)),s.remove(n)):(r=v(n),r.nodeValue.charAt(0)===g&&(r.deleteData(0,1),i.startContainer==r&&i.startOffset>0&&i.setStart(r,i.startOffset-1),i.endContainer==r&&i.endOffset>0&&i.setEnd(r,i.endOffset-1)),s.remove(n,1)),h.setRng(i);else if(n=f(h.getStart()),!n)for(;n=s.get(c);)e(n,!1)}function b(){var n,t,o,u,s,c,e;n=h.getRng(!0);u=n.startOffset;c=n.startContainer;e=c.nodeValue;t=f(h.getStart());t&&(o=v(t));e&&u>0&&u<e.length&&/\w/.test(e.charAt(u))&&/\w/.test(e.charAt(u-1))?(s=h.getBookmark(),n.collapse(!0),n=et(n,w(i)),n=at.split(n),tt(i,r,n),h.moveToBookmark(s)):(t&&o.nodeValue===g?tt(i,r,t):(t=l(!0),o=t.firstChild,n.insertNode(t),u=1,tt(i,r,t)),h.setCursorLocation(o,u))}function k(){var t=h.getRng(!0),e,b,k,a,n,f,v=[],o,c,y;for(e=t.startContainer,b=t.startOffset,n=e,3==e.nodeType&&(b!=e.nodeValue.length&&(a=!0),n=n.parentNode);n;){if(p(n,i,r,u)){f=n;break}n.nextSibling&&(a=!0);v.push(n);n=n.parentNode}if(f)if(a)k=h.getBookmark(),t.collapse(!0),t=et(t,w(i),!0),t=at.split(t),kt(i,r,t),h.moveToBookmark(k);else{for(c=l(),n=c,o=v.length-1;o>=0;o--)n.appendChild(s.clone(v[o],!1)),n=n.firstChild;n.appendChild(s.doc.createTextNode(g));n=n.firstChild;y=s.getParent(f,pt);y&&s.isEmpty(y)?f.parentNode.replaceChild(c,f):s.insertAfter(c,f);h.setCursorLocation(n,1);s.isEmpty(f)&&s.remove(f)}}function y(){var n;n=f(h.getStart());n&&!s.isEmpty(n)&&ai(n,function(n){1!=n.nodeType||n.id===c||s.isEmpty(n)||s.setAttrib(n,"data-mce-bogus",null)},"childNodes")}var c="_mce_caret",d=o.settings.caret_debug;o._hasCaretEvents||(ui=function(){var n=[],t;if(a(f(h.getStart()),n))for(t=n.length;t--;)s.setAttrib(n[t],"data-mce-bogus","1")},ri=function(n){var t=n.keyCode;e();8==t&&h.isCollapsed()&&h.getStart().innerHTML==g&&e(f(h.getStart()));37!=t&&39!=t||e(f(h.getStart()));y()},o.on("SetContent",function(n){n.selection&&y()}),o._hasCaretEvents=!0);"apply"==t?b():k()}function li(t){var i=t.startContainer,u=t.startOffset,c,f,r,e,o;if((t.startContainer!=t.endContainer||!vi(t.startContainer.childNodes[t.startOffset]))&&(3==i.nodeType&&u>=i.nodeValue.length&&(u=st(i),i=i.parentNode,c=!0),1==i.nodeType))for(e=i.childNodes,i=e[Math.min(u,e.length-1)],f=new n(i,s.getParent(i,s.isBlock)),(u>e.length-1||c)&&f.next(),r=f.current();r;r=f.next())if(3==r.nodeType&&!ft(r))return o=s.create("a",{"data-mce-bogus":"all"},g),r.parentNode.insertBefore(o,r),t.setStart(r,0),h.setRng(t),void s.remove(o)}var it={},s=o.dom,h=o.selection,at=new t(s),vt=o.schema.isValidChild,a=s.isBlock,yt=o.settings.forced_root_block,st=s.nodeIndex,g="﻿",rr=/^(src|href|style)$/,y=!1,l=!0,nt,ht,k=s.getContentEditable,ri,ui,v=i.isBookmarkNode,c=u.each,ct=u.grep,ai=u.walk,ur=u.extend;ur(this,{get:w,register:ut,unregister:wi,apply:tt,remove:kt,toggle:bi,match:dt,matchAll:ki,matchNode:p,canApply:di,formatChanged:gi,getCssText:nr});yi();pi();o.on("BeforeGetContent",function(n){ui&&"raw"!=n.format&&ui()});o.on("mouseup keydown",function(n){ri&&ri(n)})}});i(tr,[ot,u],function(n,t){return function(n){function s(){return n.serializer.getTrimmedContent()}function e(t){n.setDirty(t)}function f(n){r.typing=!1;r.add({},n)}var r=this,u=0,i=[],c,h,o=0;return n.on("init",function(){r.add()}),n.on("BeforeExecCommand",function(n){var t=n.command;"Undo"!=t&&"Redo"!=t&&"mceRepaint"!=t&&r.beforeChange()}),n.on("ExecCommand",function(n){var t=n.command;"Undo"!=t&&"Redo"!=t&&"mceRepaint"!=t&&f(n)}),n.on("ObjectResizeStart Cut",function(){r.beforeChange()}),n.on("SaveContent ObjectResized blur",f),n.on("DragEnd",f),n.on("KeyUp",function(u){var o=u.keyCode;u.isDefaultPrevented()||((o>=33&&36>=o||o>=37&&40>=o||45==o||13==o||u.ctrlKey)&&(f(),n.nodeChanged()),(46==o||8==o||t.mac&&(91==o||93==o))&&n.nodeChanged(),h&&r.typing&&(n.isDirty()||(e(i[0]&&s()!=i[0].content),n.isDirty()&&n.fire("change",{level:i[0],lastLevel:null})),n.fire("TypingUndo"),h=!1,n.nodeChanged()))}),n.on("KeyDown",function(n){var t=n.keyCode,i;if(!n.isDefaultPrevented()){if(t>=33&&36>=t||t>=37&&40>=t||45==t)return void(r.typing&&f(n));i=n.ctrlKey&&!n.altKey||n.metaKey;(16>t||t>20)&&224!=t&&91!=t&&!r.typing&&!i&&(r.beforeChange(),r.typing=!0,r.add({},n),h=!0)}}),n.on("MouseDown",function(n){r.typing&&f(n)}),n.addShortcut("meta+z","","Undo"),n.addShortcut("meta+y,meta+shift+z","","Redo"),n.on("AddUndo Undo Redo ClearUndos",function(t){t.isDefaultPrevented()||n.nodeChanged()}),r={data:i,typing:!1,beforeChange:function(){o||(c=n.selection.getBookmark(2,!0))},add:function(t,r){var f,a=n.settings,h,l;if((t=t||{},t.content=s(),o||n.removed)||(h=i[u],n.fire("BeforeAddUndo",{level:t,lastLevel:h,originalEvent:r}).isDefaultPrevented())||h&&h.content==t.content)return null;if(i[u]&&(i[u].beforeBookmark=c),a.custom_undo_redo_levels&&i.length>a.custom_undo_redo_levels){for(f=0;f<i.length-1;f++)i[f]=i[f+1];i.length--;u=i.length}return t.bookmark=n.selection.getBookmark(2,!0),u<i.length-1&&(i.length=u+1),i.push(t),u=i.length-1,l={level:t,lastLevel:h,originalEvent:r},n.fire("AddUndo",l),u>0&&(e(!0),n.fire("change",l)),t},undo:function(){var t;return r.typing&&(r.add(),r.typing=!1),u>0&&(t=i[--u],n.setContent(t.content,{format:"raw"}),n.selection.moveToBookmark(t.beforeBookmark),e(!0),n.fire("undo",{level:t})),t},redo:function(){var t;return u<i.length-1&&(t=i[++u],n.setContent(t.content,{format:"raw"}),n.selection.moveToBookmark(t.bookmark),e(!0),n.fire("redo",{level:t})),t},clear:function(){i=[];u=0;r.typing=!1;r.data=i;n.fire("ClearUndos")},hasUndo:function(){return u>0||r.typing&&i[0]&&s()!=i[0].content},hasRedo:function(){return u<i.length-1&&!this.typing},transact:function(n){r.beforeChange();try{o++;n()}finally{o--}return r.add()},extra:function(t,f){var e,o;r.transact(t)&&(o=i[u].bookmark,e=i[u-1],n.setContent(e.content,{format:"raw"}),n.selection.moveToBookmark(e.beforeBookmark),r.transact(f)&&(i[u-1].beforeBookmark=o))}}}});i(tf,[p,y,u],function(n,t,i){var r=i.ie&&i.ie<11;return function(u){function l(l){function lt(n){return n&&f.isBlock(n)&&!/^(TD|TH|CAPTION|FORM)$/.test(n.nodeName)&&!/^(fixed|absolute)/i.test(n.style.position)&&"true"!==f.getContentEditable(n)}function pt(n){return n&&/^(TD|TH|CAPTION)$/.test(n.nodeName)}function at(n){var t;f.isBlock(n)&&(t=o.getRng(),n.appendChild(f.create("span",null," ")),o.select(n),n.lastChild.outerHTML="",o.setRng(t))}function wt(n){var t=n,i=[],r;if(t){for(;t=t.firstChild;){if(f.isBlock(t))return;1!=t.nodeType||c[t.nodeName.toLowerCase()]||i.push(t)}for(r=i.length;r--;)t=i[r],!t.hasChildNodes()||t.firstChild==t.lastChild&&""===t.firstChild.nodeValue?f.remove(t):"A"==t.nodeName&&" "===(t.innerText||t.textContent)&&f.remove(t)}}function ft(t){function l(n){for(;n;){if(1==n.nodeType||3==n.nodeType&&n.data&&/[\r\n\s]/.test(n.data))return n;n=n.nextSibling}}var e,u,r,s=t,h,c;if(t){if((i.ie&&i.ie<9&&v&&v.firstChild&&v.firstChild==v.lastChild&&"BR"==v.firstChild.tagName&&f.remove(v.firstChild),/^(LI|DT|DD)$/.test(t.nodeName))&&(c=l(t.firstChild),c&&/^(UL|OL|DL)$/.test(c.nodeName)&&t.insertBefore(f.doc.createTextNode(" "),t.firstChild)),r=f.createRng(),i.ie||t.normalize(),t.hasChildNodes()){for(e=new n(t,t);u=e.current();){if(3==u.nodeType){r.setStart(u,0);r.setEnd(u,0);break}if(a[u.nodeName.toLowerCase()]){r.setStartBefore(u);r.setEndBefore(u);break}s=u;u=e.next()}u||(r.setStart(s,0),r.setEnd(s,0))}else"BR"==t.nodeName?t.nextSibling&&f.isBlock(t.nextSibling)?((!ct||9>ct)&&(h=f.create("br"),t.parentNode.insertBefore(h,t)),r.setStartBefore(t),r.setEndBefore(t)):(r.setStartAfter(t),r.setEndAfter(t)):(r.setStart(t,0),r.setEnd(t,0));o.setRng(r);f.remove(h);o.scrollIntoView(t)}}function ht(n){var t=e.forced_root_block;t&&t.toLowerCase()===n.tagName.toLowerCase()&&f.setAttribs(n,e.forced_root_block_attrs)}function bt(n){n.innerHTML=r?"":'<br data-mce-bogus="1">'}function et(n){var i=y,t,u,o,h=s.getTextInlineElements();if(n||"TABLE"==it?(t=f.create(n||b),ht(t)):t=v.cloneNode(!1),o=t,e.keep_styles!==!1)do if(h[i.nodeName]){if("_mce_caret"==i.id)continue;u=i.cloneNode(!1);f.setAttrib(u,"id","");t.hasChildNodes()?(u.appendChild(t.firstChild),t.appendChild(u)):(o=u,t.appendChild(u))}while((i=i.parentNode)&&i!=rt);return r||(o.innerHTML='<br data-mce-bogus="1">'),t}function vt(t){var i,r,u;if(3==y.nodeType&&(t?d>0:d<y.nodeValue.length))return!1;if(y.parentNode==v&&ut&&!t||t&&1==y.nodeType&&y==v.firstChild)return!0;if("TABLE"===y.nodeName||y.previousSibling&&"TABLE"==y.previousSibling.nodeName)return ut&&!t||!ut&&t;for(i=new n(y,v),3==y.nodeType&&(t&&0===d?i.prev():t||d!=y.nodeValue.length||i.next());r=i.current();){if(1===r.nodeType){if(!r.getAttribute("data-mce-bogus")&&(u=r.nodeName.toLowerCase(),c[u]&&"br"!==u))return!1}else if(3===r.nodeType&&!/^[ \t\r\n]*$/.test(r.nodeValue))return!1;t?i.prev():i.next()}return!0}function kt(n,t){var e,r,o,i,c,l,h=b||"P";if(r=f.getParent(n,f.isBlock),!r||!lt(r)){if(r=r||rt,l=r==u.getBody()||pt(r)?r.nodeName.toLowerCase():r.parentNode.nodeName.toLowerCase(),!r.hasChildNodes())return e=f.create(h),ht(e),r.appendChild(e),k.setStart(e,0),k.setEnd(e,0),e;for(i=n;i.parentNode!=r;)i=i.parentNode;for(;i&&!f.isBlock(i);)o=i,i=i.previousSibling;if(o&&s.isValidChild(l,h.toLowerCase())){for(e=f.create(h),ht(e),o.parentNode.insertBefore(e,o),i=o;i&&!f.isBlock(i);)c=i.nextSibling,e.appendChild(i),i=c;k.setStart(n,t);k.setEnd(n,t)}}return n}function dt(){function n(n){for(var t=w[n?"firstChild":"lastChild"];t&&1!=t.nodeType;)t=t[n?"nextSibling":"previousSibling"];return t===v}function t(){var n=w.parentNode;return/^(LI|DT|DD)$/.test(n.nodeName)?n:w}if(w!=u.getBody()){var i=w.parentNode.nodeName;/^(OL|UL|LI)$/.test(i)&&(b="LI");p=b?et(b):f.create("BR");n(!0)&&n()?"LI"==i?f.insertAfter(p,t()):f.replace(p,w):n(!0)?"LI"==i?(f.insertAfter(p,t()),p.appendChild(f.doc.createTextNode(" ")),p.appendChild(w)):w.parentNode.insertBefore(p,w):n()?(f.insertAfter(p,t()),at(p)):(w=t(),tt=k.cloneRange(),tt.setStartAfter(v),tt.setEndAfter(w),g=tt.extractContents(),"LI"==b&&"LI"==g.firstChild.nodeName?(p=g.firstChild,f.insertAfter(g,w)):(f.insertAfter(g,w),f.insertAfter(p,w)));f.remove(v);ft(p);h.add()}}function ot(){u.execCommand("InsertLineBreak",!1,l)}function gt(n){do 3===n.nodeType&&(n.nodeValue=n.nodeValue.replace(/^[\r\n]+/,"")),n=n.firstChild;while(n)}function ni(n){for(var i=f.getRoot(),r,t=n;t!==i&&"false"!==f.getContentEditable(t);)"true"===f.getContentEditable(t)&&(r=t),t=t.parentNode;return t!==i?r:i}function ti(n){var t;r||(n.normalize(),t=n.lastChild,t&&!/^(left|right)$/gi.test(f.getStyle(t,"float",!0))||f.add(n,"br"))}function yt(){p=/^(H[1-6]|PRE|FIGURE)$/.test(it)&&"HGROUP"!=st?et(b):et();e.end_container_on_empty_block&&lt(w)&&f.isEmpty(v)?p=f.split(w,v):f.insertAfter(p,v);ft(p)}var k,tt,rt,y,d,v,ct,nt,p,g,w,it,st,b,ut;if(k=o.getRng(!0),!l.isDefaultPrevented()){if(!k.collapsed)return void u.execCommand("Delete");if(new t(f).normalize(k),y=k.startContainer,d=k.startOffset,b=(e.force_p_newlines?"p":"")||e.forced_root_block,b=b?b.toUpperCase():"",ct=f.doc.documentMode,nt=l.shiftKey,1==y.nodeType&&y.hasChildNodes()&&(ut=d>y.childNodes.length-1,y=y.childNodes[Math.min(d,y.childNodes.length-1)]||y,d=ut&&3==y.nodeType?y.nodeValue.length:0),rt=ni(y)){if(h.beforeChange(),!f.isBlock(rt)&&rt!=f.getRoot())return void(b&&!nt||ot());if((b&&!nt||!b&&nt)&&(y=kt(y,d)),v=f.getParent(y,f.isBlock),w=v?f.getParent(v.parentNode,f.isBlock):null,it=v?v.nodeName.toUpperCase():"",st=w?w.nodeName.toUpperCase():"","LI"!=st||l.ctrlKey||(v=w,it=st),/^(LI|DT|DD)$/.test(it)){if(!b&&nt)return void ot();if(f.isEmpty(v))return void dt()}if("PRE"==it&&e.br_in_pre!==!1){if(!nt)return void ot()}else if(!b&&!nt&&"LI"!=it||b&&nt)return void ot();b&&v===u.getBody()||(b=b||"P",vt()?yt():vt(!0)?(p=v.parentNode.insertBefore(et(),v),at(p),ft(v)):(tt=k.cloneRange(),tt.setEndAfter(v),g=tt.extractContents(),gt(g),p=g.firstChild,f.insertAfter(g,v),wt(p),ti(v),f.isEmpty(v)&&bt(v),p.normalize(),f.isEmpty(p)?(f.remove(p),yt()):ft(p)),f.setAttrib(p,"id",""),u.fire("NewBlock",{newBlock:p}),h.add())}}}var f=u.dom,o=u.selection,e=u.settings,h=u.undoManager,s=u.schema,c=s.getNonEmptyElements(),a=s.getMoveCaretBeforeOnEnterElements();u.on("keydown",function(n){13==n.keyCode&&l(n)!==!1&&n.preventDefault()})}});i(rf,[],function(){return function(n){function e(){var e=t.getStart(),h=n.getBody(),o,w,c,b,l,a,v,k=-16777215,d,p,s,g,y;if(y=i.forced_root_block,e&&1===e.nodeType&&y){for(;e&&e!=h;){if(f[e.nodeName])return;e=e.parentNode}if(o=t.getRng(),o.setStart){w=o.startContainer;c=o.startOffset;b=o.endContainer;l=o.endOffset;try{p=n.getDoc().activeElement===h}catch(nt){}}else o.item&&(e=o.item(0),o=n.getDoc().body.createTextRange(),o.moveToElementText(e)),p=o.parentElement().ownerDocument===n.getDoc(),s=o.duplicate(),s.collapse(!0),c=-1*s.move("character",k),s.collapsed||(s=o.duplicate(),s.collapse(!1),l=-1*s.move("character",k)-c);for(e=h.firstChild,g=h.nodeName.toLowerCase();e;)if((3===e.nodeType||1==e.nodeType&&!f[e.nodeName])&&u.isValidChild(g,y.toLowerCase())){if(3===e.nodeType&&0===e.nodeValue.length){v=e;e=e.nextSibling;r.remove(v);continue}a||(a=r.create(y,n.settings.forced_root_block_attrs),e.parentNode.insertBefore(a,e),d=!0);v=e;e=e.nextSibling;a.appendChild(v)}else a=null,e=e.nextSibling;if(d&&p){if(o.setStart)o.setStart(w,c),o.setEnd(b,l),t.setRng(o);else try{o=n.getDoc().body.createTextRange();o.moveToElementText(h);o.collapse(!0);o.moveStart("character",c);l>0&&o.moveEnd("character",l);o.select()}catch(nt){}n.nodeChanged()}}}var i=n.settings,r=n.dom,t=n.selection,u=n.schema,f=u.getBlockElements();i.forced_root_block&&n.on("NodeChange",e)}});i(wt,[a,p,e,v,w,st],function(n,t,i,r,u,f){function a(n){return n>0}function v(n){return 0>n}function d(n,i,r,u,f){var o=new t(n,u);if(v(i)){if(e(n)&&(n=o.prev(!0),r(n)))return n;for(;n=o.prev(f);)if(r(n))return n}if(a(i)){if(e(n)&&(n=o.next(!0),r(n)))return n;for(;n=o.next(f);)if(r(n))return n}return null}function l(n,t){for(n=n.parentNode;n&&n!=t;n=n.parentNode)if(ut(n))return n;return t}function s(n,t){for(;n&&n!=t;){if(ft(n))return n;n=n.parentNode}return null}function g(n,t,i){return s(n.container(),i)==s(t.container(),i)}function nt(n,t,i){return l(n.container(),i)==l(t.container(),i)}function tt(n,t){var i,r;return t?(i=t.container(),r=t.offset(),k(i)?i.childNodes[r+n]:null):null}function y(n,t){var i=t.ownerDocument.createRange();return n?(i.setStartBefore(t),i.setEndBefore(t)):(i.setStartAfter(t),i.setEndAfter(t)),i}function it(n,t,i){return s(t,n)==s(i,n)}function p(n,t,i){for(var r,u=n?"previousSibling":"nextSibling";i&&i!=t;){if(r=i[u],b(r)&&(r=r[u]),e(r)){if(it(t,r,i))return r;break}if(et(r))break;i=i.parentNode}return null}function rt(n,t,r){var f,s,l,y,a=o(p,!0,t),v=o(p,!1,t);if(s=r.startContainer,l=r.startOffset,u.isCaretContainerBlock(s)){if(k(s)||(s=s.parentNode),y=s.getAttribute("data-mce-caret"),"before"==y&&(f=s.nextSibling,e(f)))return h(f);if("after"==y&&(f=s.previousSibling,e(f)))return c(f)}if(!r.collapsed)return r;if(i.isText(s)){if(b(s)){if(1===n){if(f=v(s))return h(f);if(f=a(s))return c(f)}if(-1===n){if(f=a(s))return c(f);if(f=v(s))return h(f)}return r}if(u.endsWithCaretContainer(s)&&l>=s.data.length-1)return 1===n&&(f=v(s))?h(f):r;if(u.startsWithCaretContainer(s)&&1>=l)return-1===n&&(f=a(s))?c(f):r;if(l===s.data.length)return f=v(s),f?h(f):r;if(0===l)return f=a(s),f?c(f):r}return r}function w(n,t){return e(tt(n,t))}var ut=i.isContentEditableTrue,e=i.isContentEditableFalse,ft=i.matchStyleValues("display","block table table-cell table-caption"),b=u.isCaretContainer,o=n.curry,k=i.isElement,et=f.isCaretCandidate,h=o(y,!0),c=o(y,!1);return{isForwards:a,isBackwards:v,findNode:d,getEditingHost:l,getParentBlock:s,isInSameBlock:g,isInSameEditingHost:nt,isBeforeContentEditableFalse:o(w,0),isAfterContentEditableFalse:o(w,-1),normalizeRange:rt}});i(ht,[e,st,v,wt,c,a],function(n,t,i,r,u,f){function p(n,t){for(var i=[];n&&n!=t;)i.push(n),n=n.parentNode;return i}function a(n,t){return n.hasChildNodes()&&t<n.childNodes.length?n.childNodes[t]:null}function v(n,t){if(o(n)){if(c(t.previousSibling)&&!e(t.previousSibling))return i.before(t);if(e(t))return i(t,0)}if(s(n)){if(c(t.nextSibling)&&!e(t.nextSibling))return i.after(t);if(e(t))return i(t,t.data.length)}return s(n)?d(t)?i.before(t):i.after(t):i.before(t)}function w(t,u){var f;return n.isBr(t)?(f=h(1,i.after(t),u),f?!r.isInSameBlock(i.before(t),i.before(f),u):!1):!1}function h(n,t,d){var nt,tt,rt,g,it,ft,ut;if(!k(d)||!t)return null;if(ut=t,nt=ut.container(),tt=ut.offset(),e(nt)){if(s(n)&&tt>0)return i(nt,--tt);if(o(n)&&tt<nt.length)return i(nt,++tt);rt=nt}else{if(s(n)&&tt>0&&(g=a(nt,tt-1),c(g)))return!y(g)&&(it=r.findNode(g,n,l,g))?e(it)?i(it,it.data.length):i.after(it):e(g)?i(g,g.data.length):i.before(g);if(o(n)&&tt<nt.childNodes.length&&(g=a(nt,tt),c(g)))return w(g,d)?h(n,i.after(g),d):!y(g)&&(it=r.findNode(g,n,l,g))?e(it)?i(it,0):i.before(it):e(g)?i(g,0):i.after(g);rt=ut.getNode()}return(o(n)&&ut.isAtEnd()||s(n)&&ut.isAtStart())&&(rt=r.findNode(rt,n,f.constant(!0),d,!0),l(rt))?v(n,rt):(g=r.findNode(rt,n,l,d),ft=u.last(u.filter(p(nt,d),b)),!ft||g&&ft.contains(g)?g?v(n,g):null:ut=o(n)?i.after(ft):i.before(ft))}var b=n.isContentEditableFalse,e=n.isText,k=n.isElement,d=n.isBr,o=r.isForwards,s=r.isBackwards,c=t.isCaretCandidate,y=t.isAtomic,l=t.isEditableCaretCandidate;return function(n){return{next:function(t){return h(1,t,n)},prev:function(t){return h(-1,t,n)}}}});i(uf,[r,ht,v],function(n,t,i){var o=function(n){var t=n.firstChild,i=n.lastChild;return t&&"meta"===t.name&&(t=t.next),i&&"mce_marker"===i.attr("id")&&(i=i.prev),t&&t===i?"ul"===t.name||"ol"===t.name:!1},s=function(n){var t=n.firstChild,i=n.lastChild;return t&&"META"===t.nodeName&&t.parentNode.removeChild(t),i&&"mce_marker"===i.id&&i.parentNode.removeChild(i),n},h=function(n,t,i){var r=t.serialize(i),u=n.createFragment(r);return s(u)},u=function(t){return n.grep(t.childNodes,function(n){return"LI"===n.nodeName})},c=function(n){return!n.firstChild},f=function(n){return n.length>0&&c(n[n.length-1])?n.slice(0,-1):n},r=function(n,t){var i=n.getParent(t,n.isBlock);return i&&"LI"===i.nodeName?i:null},l=function(n,t){return!!r(n,t)},a=function(n,t){var i=t.cloneRange(),r=t.cloneRange();return i.setStartBefore(n),r.setEndAfter(n),[i.cloneContents(),r.cloneContents()]},v=function(n,r){var f=i.before(n),e=new t(r),u=e.next(f);return u?u.toRange():null},e=function(n,r){var f=i.after(n),e=new t(r),u=e.prev(f);return u?u.toRange():null},y=function(t,i,r,u){var o=a(t,u),f=t.parentNode;return f.insertBefore(o[0],t),n.each(i,function(n){f.insertBefore(n,t)}),f.insertBefore(o[1],t),f.removeChild(t),e(i[i.length-1],r)},p=function(t,i,r){var u=t.parentNode;return n.each(i,function(n){u.insertBefore(n,t)}),v(t,r)},w=function(n,t,i,r){return r.insertAfter(t.reverse(),n),e(t[0],i)},b=function(n,e,o,s){var k=h(e,n,s),c=r(e,o.startContainer),l=f(u(k.firstChild)),v=1,a=e.getRoot(),b=function(n){var u=i.fromRangeStart(o),f=new t(e.getRoot()),s=n===v?f.prev(u):f.next(u);return s?r(e,s.getNode())!==c:!0};return b(v)?p(c,l,a):b(2)?w(c,l,a,e):y(c,l,a,o)};return{isListFragment:o,insertAtCaret:b,isParentBlockLi:l,trimListItems:f,listItems:u}});i(ff,[u,r,yt,ht,v,gi,e,uf],function(n,t,i,r,u,f,e,o){var s=e.matchNodeNames("td th"),h=function(e,h,c){function ot(n){function u(n){return t[n]&&3==t[n].nodeType}var i,t,r;return i=p.getRng(!0),t=i.startContainer,r=i.startOffset,3==t.nodeType&&(r>0?n=n.replace(/^&nbsp;/," "):u("previousSibling")||(n=n.replace(/^ /,"&nbsp;")),r<t.length?n=n.replace(/&nbsp;(<br>|)$/," "):u("nextSibling")||(n=n.replace(/(&nbsp;| )(<br>|)$/,"&nbsp;"))),n}function st(){var i,n,t;i=p.getRng(!0);n=i.startContainer;t=i.startOffset;3==n.nodeType&&i.collapsed&&(" "===n.data[t]?(n.deleteData(t,1),/[\u00a0| ]$/.test(h)||(h+=" ")):" "===n.data[t-1]&&(n.deleteData(t-1,1),/[\u00a0| ]$/.test(h)||(h=" "+h)))}function ht(){if(ft){var n=e.getBody(),i=new f(a);t.each(a.select("*[data-mce-fragment]"),function(t){for(var r=t.parentNode;r&&r!=n;r=r.parentNode)pt[t.nodeName.toLowerCase()]&&i.compare(r,t)&&a.remove(t,!0)})}}function ct(n){for(var t=n;t=t.walk();)1===t.type&&t.attr("data-mce-fragment","1")}function lt(n){t.each(n.getElementsByTagName("*"),function(n){n.removeAttribute("data-mce-fragment")})}function at(n){return!!n.getAttribute("data-mce-fragment")}function vt(n){return n&&!e.schema.getShortEndedElements()[n.nodeName]}function yt(t){function h(n){for(var t=e.getBody();n&&n!==t;n=n.parentNode)if("false"===e.dom.getContentEditable(n))return n;return null}function c(n){var t=u.fromRangeStart(n),i=new r(e.getBody());return t=i.next(t),t?t.toRange():void 0}var f,i,o;if(t){if(p.scrollIntoView(t),f=h(t))return a.remove(t),void p.select(f);v=a.createRng();l=t.previousSibling;l&&3==l.nodeType?(v.setStart(l,l.nodeValue.length),n.ie||(w=t.nextSibling,w&&3==w.nodeType&&(l.appendData(w.data),w.parentNode.removeChild(w)))):(v.setStartBefore(t),v.setEndBefore(t));i=a.getParent(t,a.isBlock);a.remove(t);i&&a.isEmpty(i)&&(e.$(i).empty(),v.setStart(i,0),v.setEnd(i,0),s(i)||at(i)||!(o=c(v))?a.add(i,a.create("br",{"data-mce-bogus":"1"})):(v=o,a.remove(i)));p.setRng(v)}}var tt,g,y,b,k,nt,ut,v,l,w,it,ft,pt=e.schema.getTextInlineElements(),p=e.selection,a=e.dom,et,d,rt;if(/^ | $/.test(h)&&(h=ot(h)),tt=e.parser,ft=c.merge,g=new i({validate:e.settings.validate},e.schema),it='<span id="mce_marker" data-mce-type="bookmark">&#xFEFF;&#x200B;<\/span>',nt={content:h,format:"html",selection:!0},e.fire("BeforeSetContent",nt),h=nt.content,-1==h.indexOf("{$caret}")&&(h+="{$caret}"),h=h.replace(/\{\$caret\}/,it),v=p.getRng(),et=v.startContainer||(v.parentElement?v.parentElement():null),d=e.getBody(),et===d&&p.isCollapsed()&&a.isBlock(d.firstChild)&&vt(d.firstChild)&&a.isEmpty(d.firstChild)&&(v=a.createRng(),v.setStart(d.firstChild,0),v.setEnd(d.firstChild,0),p.setRng(v)),p.isCollapsed()||(e.selection.setRng(e.selection.getRng()),e.getDoc().execCommand("Delete",!1,null),st()),y=p.getNode(),rt={context:y.nodeName.toLowerCase(),data:c.data},k=tt.parse(h,rt),o.isListFragment(k)&&o.isParentBlockLi(a,y))return v=o.insertAtCaret(g,a,e.selection.getRng(),k),e.selection.setRng(v),void e.fire("SetContent",nt);if(ct(k),l=k.lastChild,"mce_marker"==l.attr("id"))for(ut=l,l=l.prev;l;l=l.walk(!0))if(3==l.type||!a.isBlock(l.name)){e.schema.isValidChild(l.parent.name,"span")&&l.parent.insert(ut,l,"br"===l.name);break}if(e._selectionOverrides.showBlockCaretContainer(y),rt.invalid){for(p.setContent(it),y=p.getNode(),b=e.getBody(),9==y.nodeType?y=l=b:l=y;l!==b;)y=l,l=l.parentNode;h=y==b?b.innerHTML:a.getOuterHTML(y);h=g.serialize(tt.parse(h.replace(/<span (id="mce_marker"|id=mce_marker).+?<\/span>/i,function(){return g.serialize(k)})));y==b?a.setHTML(b,h):a.setOuterHTML(y,h)}else h=g.serialize(k),l=y.firstChild,w=y.lastChild,!l||l===w&&"BR"===l.nodeName?a.setHTML(y,h):p.setContent(h);ht();yt(a.get("mce_marker"));lt(e.getBody());e.fire("SetContent",nt);e.addVisual()},c=function(n){var i;return"string"!=typeof n?(i=t.extend({paste:n.paste,data:{paste:n.paste}},n),{content:n.content,details:i}):{content:n,details:{}}},l=function(n,t){var i=c(t);h(n,i.content,i.details)};return{insertAtCaret:l}});i(ir,[u,r,y,p,ff],function(n,i,r,u,f){var o=i.each,l=i.extend,a=i.map,v=i.inArray,s=i.explode,h=n.ie&&n.ie<11,e=!0,c=!1;return function(i){function et(n,t,r,u){var s,e,f=0;if(/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(n)||u&&u.skip_focus||i.focus(),u=i.fire("BeforeExecCommand",{command:n,ui:t,value:r}),u.isDefaultPrevented())return!1;if(e=n.toLowerCase(),s=b.exec[e])return s(e,t,r),i.fire("ExecCommand",{command:n,ui:t,value:r}),!0;if(o(i.plugins,function(u){if(u.execCommand&&u.execCommand(n,t,r))return(i.fire("ExecCommand",{command:n,ui:t,value:r}),f=!0,!1)}),f)return f;if(i.theme&&i.theme.execCommand&&i.theme.execCommand(n,t,r))return i.fire("ExecCommand",{command:n,ui:t,value:r}),!0;try{f=i.getDoc().execCommand(n,t,r)}catch(h){}return f?(i.fire("ExecCommand",{command:n,ui:t,value:r}),!0):!1}function g(n){var t;if(!i.quirks.isHidden()){if(n=n.toLowerCase(),t=b.state[n])return t(n);try{return i.getDoc().queryCommandState(n)}catch(r){}return!1}}function ot(n){var t;if(!i.quirks.isHidden()){if(n=n.toLowerCase(),t=b.value[n])return t(n);try{return i.getDoc().queryCommandValue(n)}catch(r){}}}function nt(n,t){t=t||"exec";o(n,function(n,i){o(i.toLowerCase().split(","),function(i){b[t][i]=n})})}function st(n,t,r){n=n.toLowerCase();b.exec[n]=function(n,u,f,e){return t.call(r||i,u,f,e)}}function ht(n){if(n=n.toLowerCase(),b.exec[n])return!0;try{return i.getDoc().queryCommandSupported(n)}catch(t){}return!1}function ct(n,t,r){n=n.toLowerCase();b.state[n]=function(){return t.call(r||i)}}function lt(n,t,r){n=n.toLowerCase();b.value[n]=function(){return t.call(r||i)}}function at(n){return n=n.toLowerCase(),!!b.exec[n]}function tt(n,r,u){return r===t&&(r=c),u===t&&(u=null),i.getDoc().execCommand(n,r,u)}function it(n){return w.match(n)}function k(n,r){w.toggle(n,r?{value:r}:t);i.nodeChanged()}function rt(n){ft=p.getBookmark(n)}function ut(){p.moveToBookmark(ft)}var y,p,w,b={state:{},exec:{},value:{}},d=i.settings,ft;i.on("PreInit",function(){y=i.dom;p=i.selection;d=i.settings;w=i.formatter});l(this,{execCommand:et,queryCommandState:g,queryCommandValue:ot,queryCommandSupported:ht,addCommands:nt,addCommand:st,addQueryStateHandler:ct,addQueryValueHandler:lt,hasCustomCommand:at});nt({"mceResetDesignMode,mceBeginUndoLevel":function(){},"mceEndUndoLevel,mceAddUndoLevel":function(){i.undoManager.add()},"Cut,Copy,Paste":function(t){var f=i.getDoc(),u,r;try{tt(t)}catch(o){u=e}("paste"!==t||f.queryCommandEnabled(t)||(u=!0),u||!f.queryCommandSupported(t))&&(r=i.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead."),n.mac&&(r=r.replace(/Ctrl\+/g,"⌘+")),i.notificationManager.open({text:r,type:"error"}))},unlink:function(){if(p.isCollapsed()){var n=p.getNode();return void("A"==n.tagName&&i.dom.remove(n,!0))}w.remove("link")},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull,JustifyNone":function(n){var t=n.substring(7);"full"==t&&(t="justify");o("left,center,right,justify".split(","),function(n){t!=n&&w.remove("align"+n)});"none"!=t&&k("align"+t)},"InsertUnorderedList,InsertOrderedList":function(n){var t,i;tt(n);t=y.getParent(p.getNode(),"ol,ul");t&&(i=t.parentNode,/^(H[1-6]|P|ADDRESS|PRE)$/.test(i.nodeName)&&(rt(),y.split(i,t),ut()))},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(n){k(n)},"ForeColor,HiliteColor,FontName":function(n,t,i){k(n,i)},FontSize:function(n,t,i){var r,u;i>=1&&7>=i&&(u=s(d.font_size_style_values),r=s(d.font_size_classes),i=r?r[i-1]||i:u[i-1]||i);k(n,i)},RemoveFormat:function(n){w.remove(n)},mceBlockQuote:function(){k("blockquote")},FormatBlock:function(n,t,i){return k(i||"p")},mceCleanup:function(){var n=p.getBookmark();i.setContent(i.getContent({cleanup:e}),{cleanup:e});p.moveToBookmark(n)},mceRemoveNode:function(n,t,r){var u=r||p.getNode();u!=i.getBody()&&(rt(),i.dom.remove(u,e),ut())},mceSelectNodeDepth:function(n,t,r){var u=0;y.getParent(p.getNode(),function(n){if(1==n.nodeType&&u++==r)return(p.select(n),c)},i.getBody())},mceSelectNode:function(n,t,i){p.select(i)},mceInsertContent:function(n,t,r){f.insertAtCaret(i,r)},mceInsertRawHTML:function(n,t,r){p.setContent("tiny_mce_marker");i.setContent(i.getContent().replace(/tiny_mce_marker/g,function(){return r}))},mceToggleFormat:function(n,t,i){k(i)},mceSetContent:function(n,t,r){i.setContent(r)},"Indent,Outdent":function(n){var t,u,r;t=d.indentation;u=/[a-z%]+$/i.exec(t);t=parseInt(t,10);g("InsertUnorderedList")||g("InsertOrderedList")?tt(n):(d.forced_root_block||y.getParent(p.getNode(),y.isBlock)||w.apply("div"),o(p.getSelectedBlocks(),function(f){if("false"!==y.getContentEditable(f)&&"LI"!=f.nodeName){var e=i.getParam("indent_use_margin",!1)?"margin":"padding";e+="rtl"==y.getStyle(f,"direction",!0)?"Right":"Left";"outdent"==n?(r=Math.max(0,parseInt(f.style[e]||0,10)-t),y.setStyle(f,e,r?r+u:"")):(r=parseInt(f.style[e]||0,10)+t+u,y.setStyle(f,e,r))}}))},mceRepaint:function(){},InsertHorizontalRule:function(){i.execCommand("mceInsertContent",!1,"<hr />")},mceToggleVisualAid:function(){i.hasVisual=!i.hasVisual;i.addVisual()},mceReplaceContent:function(n,t,r){i.execCommand("mceInsertContent",!1,r.replace(/\{\$selection\}/g,p.getContent({format:"text"})))},mceInsertLink:function(n,t,i){var r;"string"==typeof i&&(i={href:i});r=y.getParent(p.getNode(),"a");i.href=i.href.replace(" ","%20");r&&i.href||w.remove("link");i.href&&w.apply("link",i,r)},selectAll:function(){var t=y.getRoot(),n;p.getRng().setStart?(n=y.createRng(),n.setStart(t,0),n.setEnd(t,t.childNodes.length),p.setRng(n)):(n=p.getRng(),n.item||(n.moveToElementText(t),n.select()))},"delete":function(){tt("Delete");var n=i.getBody();y.isEmpty(n)&&(i.setContent(""),n.firstChild&&y.isBlock(n.firstChild)?i.selection.setCursorLocation(n.firstChild,0):i.selection.setCursorLocation(n,0))},mceNewDocument:function(){i.setContent("")},InsertLineBreak:function(n,t,f){function it(){for(var t=new u(o,l),n,r=i.schema.getNonEmptyElements();n=t.next();)if(r[n.nodeName.toLowerCase()]||n.length>0)return!0}var k=f,s,d,v,c=p.getRng(!0),a,o,g,b;new r(y).normalize(c);a=c.startOffset;o=c.startContainer;1==o.nodeType&&o.hasChildNodes()&&(g=a>o.childNodes.length-1,o=o.childNodes[Math.min(a,o.childNodes.length-1)]||o,a=g&&3==o.nodeType?o.nodeValue.length:0);var l=y.getParent(o,y.isBlock),nt=l?l.nodeName.toUpperCase():"",w=l?y.getParent(l.parentNode,y.isBlock):null,tt=w?w.nodeName.toUpperCase():"",rt=k&&k.ctrlKey;return"LI"!=tt||rt||(l=w,nt=tt),o&&3==o.nodeType&&a>=o.nodeValue.length&&(h||it()||(s=y.create("br"),c.insertNode(s),c.setStartAfter(s),c.setEndAfter(s),d=!0)),s=y.create("br"),c.insertNode(s),b=y.doc.documentMode,h&&"PRE"==nt&&(!b||8>b)&&s.parentNode.insertBefore(y.doc.createTextNode("\r"),s),v=y.create("span",{},"&nbsp;"),s.parentNode.insertBefore(v,s),p.scrollIntoView(v),y.remove(v),d?(c.setStartBefore(s),c.setEndBefore(s)):(c.setStartAfter(s),c.setEndAfter(s)),p.setRng(c),i.undoManager.add(),e}});nt({"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(n){var t="align"+n.substring(7),i=p.isCollapsed()?[y.getParent(p.getNode(),y.isBlock)]:p.getSelectedBlocks(),r=a(i,function(n){return!!w.matchNode(n,t)});return-1!==v(r,e)},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(n){return it(n)},mceBlockQuote:function(){return it("blockquote")},Outdent:function(){var n;return d.inline_styles&&((n=y.getParent(p.getStart(),y.isBlock))&&parseInt(n.style.paddingLeft,10)>0||(n=y.getParent(p.getEnd(),y.isBlock))&&parseInt(n.style.paddingLeft,10)>0)?e:g("InsertUnorderedList")||g("InsertOrderedList")||!d.inline_styles&&!!y.getParent(p.getNode(),"BLOCKQUOTE")},"InsertUnorderedList,InsertOrderedList":function(n){var t=y.getParent(p.getNode(),"ul,ol");return t&&("insertunorderedlist"===n&&"UL"===t.tagName||"insertorderedlist"===n&&"OL"===t.tagName)}},"state");nt({"FontSize,FontName":function(n){var i=0,t;return(t=y.getParent(p.getNode(),"span"))&&(i="fontsize"==n?t.style.fontSize:t.style.fontFamily.replace(/, /g,",").replace(/[\'\"]/g,"").toLowerCase()),i}},"value");nt({Undo:function(){i.undoManager.undo()},Redo:function(){i.undoManager.redo()}})}});i(fi,[r],function(n){function t(n,f){var e=this,o,s,h;if(n=r(n),f=e.settings=f||{},o=f.base_uri,/^([\w\-]+):([^\/]{2})/i.test(n)||/^\s*#/.test(n))return void(e.source=n);h=0===n.indexOf("//");0!==n.indexOf("/")||h||(n=(o?o.protocol||"http":"http")+"://mce_host"+n);/^[\w\-]*:?\/\//.test(n)||(s=f.base_uri?f.base_uri.path:new t(location.href).directory,""===f.base_uri.protocol?n="//mce_host"+e.toAbsPath(s,n):(n=/([^#?]*)([#?]?.*)/.exec(n),n=(o&&o.protocol||"http")+"://mce_host"+e.toAbsPath(s,n[1])+n[2]));n=n.replace(/@@/g,"(mce_at)");n=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(n);i(u,function(t,i){var r=n[i];r&&(r=r.replace(/\(mce_at\)/g,"@@"));e[t]=r});o&&(e.protocol||(e.protocol=o.protocol),e.userInfo||(e.userInfo=o.userInfo),e.port||"mce_host"!==e.host||(e.port=o.port),e.host&&"mce_host"!==e.host||(e.host=o.host),e.source="");h&&(e.protocol="")}var i=n.each,r=n.trim,u="source protocol authority userInfo user password host port relative path directory file query anchor".split(" "),f={ftp:21,http:80,https:443,mailto:25};return t.prototype={setPath:function(n){var t=this;n=/^(.*?)\/?(\w+)?$/.exec(n);t.path=n[0];t.directory=n[1];t.file=n[2];t.source="";t.getURI()},toRelative:function(n){var i=this,u,r,f;return"./"===n?n:(n=new t(n,{base_uri:i}),"mce_host"!=n.host&&i.host!=n.host&&n.host||i.port!=n.port||i.protocol!=n.protocol&&""!==n.protocol)?n.getURI():(r=i.getURI(),f=n.getURI(),r==f||"/"==r.charAt(r.length-1)&&r.substr(0,r.length-1)==f?r:(u=i.toRelPath(i.path,n.path),n.query&&(u+="?"+n.query),n.anchor&&(u+="#"+n.anchor),u))},toAbsolute:function(n,i){return n=new t(n,{base_uri:this}),n.getURI(i&&this.isSameOrigin(n))},isSameOrigin:function(n){if(this.host==n.host&&this.protocol==n.protocol){if(this.port==n.port)return!0;var t=f[this.protocol];if(t&&(this.port||t)==(n.port||t))return!0}return!1},toRelPath:function(n,t){var r,f=0,e="",i,u;if(n=n.substring(0,n.lastIndexOf("/")),n=n.split("/"),r=t.split("/"),n.length>=r.length)for(i=0,u=n.length;u>i;i++)if(i>=r.length||n[i]!=r[i]){f=i+1;break}if(n.length<r.length)for(i=0,u=r.length;u>i;i++)if(i>=n.length||n[i]!=r[i]){f=i+1;break}if(1===f)return t;for(i=0,u=n.length-(f-1);u>i;i++)e+="../";for(i=f-1,u=r.length;u>i;i++)e+=i!=f-1?"/"+r[i]:r[i];return e},toAbsPath:function(n,t){var r,e=0,f=[],o,u;for(o=/\/$/.test(t)?"/":"",n=n.split("/"),t=t.split("/"),i(n,function(n){n&&f.push(n)}),n=f,r=t.length-1,f=[];r>=0;r--)0!==t[r].length&&"."!==t[r]&&(".."!==t[r]?e>0?e--:f.push(t[r]):e++);return r=n.length-e,u=0>=r?f.reverse().join("/"):n.slice(0,r).join("/")+"/"+f.reverse().join("/"),0!==u.indexOf("/")&&(u="/"+u),o&&u.lastIndexOf("/")!==u.length-1&&(u+=o),u},getURI:function(n){var i,t=this;return t.source&&!n||(i="",n||(i+=t.protocol?t.protocol+"://":"//",t.userInfo&&(i+=t.userInfo+"@"),t.host&&(i+=t.host),t.port&&(i+=":"+t.port)),t.path&&(i+=t.path),t.query&&(i+="?"+t.query),t.anchor&&(i+="#"+t.anchor),t.source=i),t.source}},t.parseDataUri=function(n){var i,t;return n=decodeURIComponent(n).split(","),t=/data:([^;]+)/.exec(n[0]),t&&(i=t[1]),{type:i,data:n[1]}},t.getDocumentBaseUrl=function(n){var t;return t=0!==n.protocol.indexOf("http")&&"file:"!==n.protocol?n.href:n.protocol+"//"+n.host+n.pathname,/^[^:]+:\/\/\/?[^\/]+\//.test(t)&&(t=t.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(t)||(t+="/")),t},t});i(tt,[r],function(n){function r(){}var t=n.each,f=n.extend,u,i;return r.extend=u=function(n){function r(){var t,r,u,n=this;if(!i&&(n.init&&n.init.apply(n,arguments),r=n.Mixins))for(t=r.length;t--;)u=r[t],u.init&&u.init.apply(n,arguments)}function l(){return this}function a(n,t){return function(){var i=this,u=i._super,r;return i._super=e[n],r=t.apply(i,arguments),i._super=u,r}}var c=this,e=c.prototype,h,o,s;i=!0;h=new c;i=!1;n.Mixins&&(t(n.Mixins,function(t){for(var i in t)"init"!==i&&(n[i]=t[i])}),e.Mixins&&(n.Mixins=e.Mixins.concat(n.Mixins)));n.Methods&&t(n.Methods.split(","),function(t){n[t]=l});n.Properties&&t(n.Properties.split(","),function(t){var i="_"+t;n[t]=function(n){var t=this,r;return n!==r?(t[i]=n,t):t[i]}});n.Statics&&t(n.Statics,function(n,t){r[t]=n});n.Defaults&&e.Defaults&&(n.Defaults=f({},e.Defaults,n.Defaults));for(o in n)s=n[o],h[o]="function"==typeof s&&e[o]?a(o,s):s;return r.prototype=h,r.constructor=r,r.extend=u,r},r});i(ei,[r],function(n){function t(t){function u(){return!1}function e(){return!0}function c(n,r){var c,f,l,s;if(n=n.toLowerCase(),r=r||{},r.type=n,r.target||(r.target=o),r.preventDefault||(r.preventDefault=function(){r.isDefaultPrevented=e},r.stopPropagation=function(){r.isPropagationStopped=e},r.stopImmediatePropagation=function(){r.isImmediatePropagationStopped=e},r.isDefaultPrevented=u,r.isPropagationStopped=u,r.isImmediatePropagationStopped=u),t.beforeFire&&t.beforeFire(r),c=i[n])for(f=0,l=c.length;l>f;f++){if(s=c[f],s.once&&h(n,s.func),r.isImmediatePropagationStopped())return r.stopPropagation(),r;if(s.func.call(o,r)===!1)return r.preventDefault(),r}return r}function s(t,e,o,s){var h,c,l;if(e===!1&&(e=u),e)for(e={func:e},s&&n.extend(e,s),c=t.toLowerCase().split(" "),l=c.length;l--;)t=c[l],h=i[t],h||(h=i[t]=[],f(t,!0)),o?h.unshift(e):h.push(e);return r}function h(n,t){var o,u,s,h,e;if(n)for(h=n.toLowerCase().split(" "),o=h.length;o--;){if(n=h[o],u=i[n],!n){for(s in i)f(s,!1),delete i[s];return r}if(u){if(t)for(e=u.length;e--;)u[e].func===t&&(u=u.slice(0,e).concat(u.slice(e+1)),i[n]=u);else u.length=0;u.length||(f(n,!1),delete i[n])}}else{for(n in i)f(n,!1);i={}}return r}function l(n,t,i){return s(n,t,i,{once:!0})}function a(n){return n=n.toLowerCase(),!(!i[n]||0===i[n].length)}var r=this,o,i={},f;t=t||{};o=t.scope||r;f=t.toggleEvent||u;r.fire=c;r.on=s;r.off=h;r.once=l;r.has=a}var i=n.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchend"," ");return t.isNative=function(n){return!!i[n.toLowerCase()]},t});i(ef,[],function(){function n(n){this.create=n.create}return n.create=function(t,i){return new n({create:function(n,r){function f(t){n.set(r,t.value)}function e(n){t.set(i,n.value)}var u;return n.on("change:"+r,e),t.on("change:"+i,f),u=n._bindings,u||(u=n._bindings=[],n.on("destroy",function(){for(var n=u.length;n--;)u[n]()})),u.push(function(){t.off("change:"+i,f)}),t.get(i)}})},n});i(ct,[ei],function(n){function t(t){return t._eventDispatcher||(t._eventDispatcher=new n({scope:t,toggleEvent:function(i,r){n.isNative(i)&&t.toggleNativeEvent&&t.toggleNativeEvent(i,r)}})),t._eventDispatcher}return{fire:function(n,i,r){var f=this,u;if(f.removed&&"remove"!==n)return i;if(i=t(f).fire(n,i,r),r!==!1&&f.parent)for(u=f.parent();u&&!i.isPropagationStopped();)u.fire(n,i,!1),u=u.parent();return i},on:function(n,i,r){return t(this).on(n,i,r)},off:function(n,i){return t(this).off(n,i)},once:function(n,i){return t(this).once(n,i)},hasEventListeners:function(n){return t(this).has(n)}}});i(of,[ef,ct,tt,r],function(n,t,i,r){function f(n){return n.nodeType>0}function u(n,t){var i,e;if(n===t)return!0;if(null===n||null===t||"object"!=typeof n||"object"!=typeof t)return n===t;if(r.isArray(t)){if(n.length!==t.length)return!1;for(i=n.length;i--;)if(!u(n[i],t[i]))return!1}if(f(n)||f(t))return n===t;e={};for(i in t){if(!u(n[i],t[i]))return!1;e[i]=!0}for(i in n)if(!e[i]&&!u(n[i],t[i]))return!1;return!0}return i.extend({Mixins:[t],init:function(t){var i,r;t=t||{};for(i in t)r=t[i],r instanceof n&&(t[i]=r.create(this,i));this.data=t},set:function(t,i){var r,f,e=this.data[t];if(i instanceof n&&(i=i.create(this,t)),"object"==typeof t){for(r in t)this.set(r,t[r]);return this}return u(e,i)||(this.data[t]=i,f={target:this,name:t,value:i,oldValue:e},this.fire("change:"+t,f),this.fire("change",f)),this},get:function(n){return this.data[n]},has:function(n){return n in this.data},bind:function(t){return n.create(this,t)},destroy:function(){this.fire("destroy")}})});i(oi,[tt],function(n){function u(n){for(var i=[],t=n.length,r;t--;)r=n[t],r.__checked||(i.push(r),r.__checked=1);for(t=i.length;t--;)delete i[t].__checked;return i}var f=/^([\w\\*]+)?(?:#([\w\-\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i,i=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=/^\s*|\s*$/g,t,r=n.extend({init:function(n){function r(n){if(n)return(n=n.toLowerCase(),function(t){return"*"===n||t.type===n})}function u(n){if(n)return function(t){return t._name===n}}function o(n){if(n)return(n=n.split("."),function(t){for(var i=n.length;i--;)if(!t.classes.contains(n[i]))return!1;return!0})}function s(n,t,i){if(n)return function(r){var u=r[n]?r[n]():"";return t?"="===t?u===i:"*="===t?u.indexOf(i)>=0:"~="===t?(" "+u+" ").indexOf(" "+i+" ")>=0:"!="===t?u!=i:"^="===t?0===u.indexOf(i):"$="===t?u.substr(u.length-i.length)===i:!1:!!i}}function h(n){var i;if(n)return(n=/(?:not\((.+)\))|(.+)/i.exec(n),n[1]?(i=t(n[1],[]),function(n){return!l(n,i)}):(n=n[2],function(t,i,r){return"first"===n?0===i:"last"===n?i===r-1:"even"===n?i%2==0:"odd"===n?i%2==1:t[n]?t[n]():!1}))}function c(n,t,i){function l(n){n&&t.push(n)}var c;return c=f.exec(n.replace(e,"")),l(r(c[1])),l(u(c[2])),l(o(c[3])),l(s(c[4],c[5],c[6])),l(h(c[7])),t.pseudo=!!c[7],t.direct=i,t}function t(n,r){var e=[],o,u,f;do if(i.exec(""),u=i.exec(n),u&&(n=u[3],e.push(u[1]),u[2])){o=u[3];break}while(u);for(o&&t(o,r),n=[],f=0;f<e.length;f++)">"!=e[f]&&n.push(c(e[f],[],">"===e[f-1]));return r.push(n),r}var l=this.match;this._selectors=t(n,[])},match:function(n,t){var f,v,u,e,c,r,o,s,h,y,l,a,i;for(t=t||this._selectors,f=0,v=t.length;v>f;f++){for(c=t[f],e=c.length,i=n,a=0,u=e-1;u>=0;u--)for(s=c[u];i;){if(s.pseudo)for(l=i.parent().items(),h=y=l.length;h--&&l[h]!==i;);for(r=0,o=s.length;o>r;r++)if(!s[r](i,h,y)){r=o+1;break}if(r===o){a++;break}if(u===e-1)break;i=i.parent()}if(a===e)return!0}return!1},find:function(n){function e(n,t,r){for(var f,s,u,c=t[r],o=0,h=n.length;h>o;o++){for(u=n[o],f=0,s=c.length;s>f;f++)if(!c[f](u,o,h)){f=s+1;break}if(f===s)r==t.length-1?i.push(u):u.items&&e(u.items(),t,r+1);else if(c.direct)return;u.items&&e(u.items(),t,r)}}var i=[],f,o,s=this._selectors;if(n.items){for(f=0,o=s.length;o>f;f++)e(n.items(),s[f],0);o>1&&(i=u(i))}return t||(t=r.Collection),new t(i)}});return r});i(si,[r,oi,tt],function(n,t,i){var r,u,f=Array.prototype.push,e=Array.prototype.slice;return u={length:0,init:function(n){n&&this.add(n)},add:function(t){var i=this;return n.isArray(t)?f.apply(i,t):t instanceof r?i.add(t.toArray()):f.call(i,t),i},set:function(n){var t=this,r=t.length,i;for(t.length=0,t.add(n),i=t.length;r>i;i++)delete t[i];return t},filter:function(n){var e=this,i,o,s=[],u,f;for("string"==typeof n?(n=new t(n),f=function(t){return n.match(t)}):f=n,i=0,o=e.length;o>i;i++)u=e[i],f(u)&&s.push(u);return new r(s)},slice:function(){return new r(e.apply(this,arguments))},eq:function(n){return-1===n?this.slice(n):this.slice(n,+n+1)},each:function(t){return n.each(this,t),this},toArray:function(){return n.toArray(this)},indexOf:function(n){for(var i=this,t=i.length;t--&&i[t]!==n;);return t},reverse:function(){return new r(n.toArray(this).reverse())},hasClass:function(n){return this[0]?this[0].classes.contains(n):!1},prop:function(n,t){var r=this,u,i;return t!==u?(r.each(function(i){i[n]&&i[n](t)}),r):(i=r[0],i&&i[n]?i[n]():void 0)},exec:function(t){var i=this,r=n.toArray(arguments).slice(1);return i.each(function(n){n[t]&&n[t].apply(n,r)}),i},remove:function(){for(var n=this.length;n--;)this[n].remove();return this},addClass:function(n){return this.each(function(t){t.classes.add(n)})},removeClass:function(n){return this.each(function(t){t.classes.remove(n)})}},n.each("fire on off show hide append prepend before after reflow".split(" "),function(t){u[t]=function(){var i=n.toArray(arguments);return this.each(function(n){t in n&&n[t].apply(n,i)}),this}}),n.each("text name disabled active selected checked visible parent value data".split(" "),function(n){u[n]=function(t){return this.prop(n,t)}}),r=i.extend(u),t.Collection=r,r});i(l,[r,h],function(n,t){var i=0;return{id:function(){return"mceu_"+i++},create:function(i,r,u){var f=document.createElement(i);return t.DOM.setAttribs(f,r),"string"==typeof u?f.innerHTML=u:n.each(u,function(n){n.nodeType&&f.appendChild(n)}),f},createFragment:function(n){return t.DOM.createFragment(n)},getWindowSize:function(){return t.DOM.getViewPort()},getSize:function(n){var i,r,t;return n.getBoundingClientRect?(t=n.getBoundingClientRect(),i=Math.max(t.width||t.right-t.left,n.offsetWidth),r=Math.max(t.height||t.bottom-t.bottom,n.offsetHeight)):(i=n.offsetWidth,r=n.offsetHeight),{width:i,height:r}},getPos:function(n,i){return t.DOM.getPos(n,i)},getViewPort:function(n){return t.DOM.getViewPort(n)},get:function(n){return document.getElementById(n)},addClass:function(n,i){return t.DOM.addClass(n,i)},removeClass:function(n,i){return t.DOM.removeClass(n,i)},hasClass:function(n,i){return t.DOM.hasClass(n,i)},toggleClass:function(n,i,r){return t.DOM.toggleClass(n,i,r)},css:function(n,i,r){return t.DOM.setStyle(n,i,r)},getRuntimeStyle:function(n,i){return t.DOM.getStyle(n,i,!0)},on:function(n,i,r,u){return t.DOM.bind(n,i,r,u)},off:function(n,i,r){return t.DOM.unbind(n,i,r)},fire:function(n,i,r){return t.DOM.fire(n,i,r)},innerHtml:function(n,i){t.DOM.setHTML(n,i)}}});i(rr,[],function(){return{parseBox:function(n){var t,i=10;if(n)return"number"==typeof n?(n=n||0,{top:n,left:n,bottom:n,right:n}):(n=n.split(" "),t=n.length,1===t?n[1]=n[2]=n[3]=n[0]:2===t?(n[2]=n[0],n[3]=n[1]):3===t&&(n[3]=n[1]),{top:parseInt(n[0],i)||0,right:parseInt(n[1],i)||0,bottom:parseInt(n[2],i)||0,left:parseInt(n[3],i)||0})},measureBox:function(n,t){function r(t){var i=document.defaultView;return i?(t=t.replace(/[A-Z]/g,function(n){return"-"+n}),i.getComputedStyle(n,null).getPropertyValue(t)):n.currentStyle[t]}function i(n){var t=parseFloat(r(n),10);return isNaN(t)?0:t}return{top:i(t+"TopWidth"),right:i(t+"RightWidth"),bottom:i(t+"BottomWidth"),left:i(t+"LeftWidth")}}}});i(ur,[r],function(n){function i(){}function t(n){this.cls=[];this.cls._map={};this.onchange=n||i;this.prefix=""}return n.extend(t.prototype,{add:function(n){return n&&!this.contains(n)&&(this.cls._map[n]=!0,this.cls.push(n),this._change()),this},remove:function(n){if(this.contains(n)){for(var t=0;t<this.cls.length&&this.cls[t]!==n;t++);this.cls.splice(t,1);delete this.cls._map[n];this._change()}return this},toggle:function(n,t){var i=this.contains(n);return i!==t&&(i?this.remove(n):this.add(n),this._change()),this},contains:function(n){return!!this.cls._map[n]},_change:function(){delete this.clsValue;this.onchange.call(this)}}),t.prototype.toString=function(){var t,n;if(this.clsValue)return this.clsValue;for(t="",n=0;n<this.cls.length;n++)n>0&&(t+=" "),t+=this.prefix+this.cls[n];return t},t});i(hi,[f],function(n){var t={},i;return{add:function(r){var u=r.parent();if(u){if(!u._layout||u._layout.isNative())return;t[u._id]||(t[u._id]=u);i||(i=!0,n.requestAnimationFrame(function(){var r,n;i=!1;for(r in t)n=t[r],n.state.get("rendered")&&n.reflow();t={}},document.body))}},remove:function(n){t[n._id]&&delete t[n._id]}}});i(b,[tt,r,ei,of,si,l,s,rr,ur,hi],function(n,t,i,r,u,f,e,o,s,h){function l(n){return n._eventDispatcher||(n._eventDispatcher=new i({scope:n,toggleEvent:function(t,r){r&&i.isNative(t)&&(n._nativeEvents||(n._nativeEvents={}),n._nativeEvents[t]=!0,n.state.get("rendered")&&a(n))}})),n._eventDispatcher}function a(n){function c(t){var i=n.getParentCtrl(t.target);i&&i.fire(t.type,t)}function l(){var n=t._lastHoverCtrl;n&&(n.fire("mouseleave",{target:n.getEl()}),n.parents().each(function(n){n.fire("mouseleave",{target:n.getEl()})}),t._lastHoverCtrl=null)}function a(i){var u=n.getParentCtrl(i.target),f=t._lastHoverCtrl,e=0,r,s,o;if(u!==f){if(t._lastHoverCtrl=u,s=u.parents().toArray().reverse(),s.push(u),f){for(o=f.parents().toArray().reverse(),o.push(f),e=0;e<o.length&&s[e]===o[e];e++);for(r=o.length-1;r>=e;r--)f=o[r],f.fire("mouseleave",{target:f.getEl()})}for(r=e;r<s.length;r++)u=s[r],u.fire("mouseenter",{target:u.getEl()})}}function h(t){t.preventDefault();"mousewheel"==t.type?(t.deltaY=-1/40*t.wheelDelta,t.wheelDeltaX&&(t.deltaX=-1/40*t.wheelDeltaX)):(t.deltaX=0,t.deltaY=t.detail);t=n.fire("wheel",t)}var i,o,u,t,s,r,f;if(s=n._nativeEvents){for(u=n.parents().toArray(),u.unshift(n),i=0,o=u.length;!t&&o>i;i++)t=u[i]._eventsRoot;for(t||(t=u[u.length-1]||n),n._eventsRoot=t,o=i,i=0;o>i;i++)u[i]._eventsRoot=t;f=t._delegates;f||(f=t._delegates={});for(r in s){if(!s)return!1;"wheel"!==r||w?("mouseenter"===r||"mouseleave"===r?t._hasMouseEnter||(e(t.getEl()).on("mouseleave",l).on("mouseover",a),t._hasMouseEnter=1):f[r]||(e(t.getEl()).on(r,c),f[r]=!0),s[r]=!1):p?e(n.getEl()).on("mousewheel",h):e(n.getEl()).on("DOMMouseScroll",h)}}}var p="onmousewheel"in document,w=!1,v="mce-",c,b=0,y={Statics:{classPrefix:v},isRtl:function(){return c.rtl},classPrefix:v,init:function(n){function h(n){var t;for(n=n.split(" "),t=0;t<n.length;t++)i.classes.add(n[t])}var i=this,u,f;i.settings=n=t.extend({},i.Defaults,n);i._id=n.id||"mceu_"+b++;i._aria={role:n.role};i._elmCache={};i.$=e;i.state=new r({visible:!0,active:!1,disabled:!1,value:""});i.data=new r(n.data);i.classes=new s(function(){i.state.get("rendered")&&(i.getEl().className=this.toString())});i.classes.prefix=i.classPrefix;u=n.classes;u&&(i.Defaults&&(f=i.Defaults.classes,f&&u!=f&&h(f)),h(u));t.each("title text name visible disabled active value".split(" "),function(t){t in n&&i[t](n[t])});i.on("click",function(){if(i.disabled())return!1});i.settings=n;i.borderBox=o.parseBox(n.border);i.paddingBox=o.parseBox(n.padding);i.marginBox=o.parseBox(n.margin);n.hidden&&i.hide()},Properties:"parent,name",getContainerElm:function(){return document.body},getParentCtrl:function(n){for(var t,i=this.getRoot().controlIdLookup;n&&i&&!(t=i[n.id]);)n=n.parentNode;return t},initLayoutRect:function(){var n=this,t=n.settings,u,w,s=n.getEl(),i,r,h,c,e,l,a,v;u=n.borderBox=n.borderBox||o.measureBox(s,"border");n.paddingBox=n.paddingBox||o.measureBox(s,"padding");n.marginBox=n.marginBox||o.measureBox(s,"margin");v=f.getSize(s);l=t.minWidth;a=t.minHeight;h=l||v.width;c=a||v.height;i=t.width;r=t.height;e=t.autoResize;e="undefined"!=typeof e?e:!i&&!r;i=i||h;r=r||c;var y=u.left+u.right,p=u.top+u.bottom,b=t.maxWidth||65535,k=t.maxHeight||65535;return n._layoutRect=w={x:t.x||0,y:t.y||0,w:i,h:r,deltaW:y,deltaH:p,contentW:i-y,contentH:r-p,innerW:i-y,innerH:r-p,startMinWidth:l||0,startMinHeight:a||0,minW:Math.min(h,b),minH:Math.min(c,k),maxW:b,maxH:k,autoResize:e,scrollW:0},n._lastLayoutRect={},w},layoutRect:function(n){var f=this,t=f._layoutRect,u,i,e,o,r,s;return t||(t=f.initLayoutRect()),n?(e=t.deltaW,o=t.deltaH,n.x!==r&&(t.x=n.x),n.y!==r&&(t.y=n.y),n.minW!==r&&(t.minW=n.minW),n.minH!==r&&(t.minH=n.minH),i=n.w,i!==r&&(i=i<t.minW?t.minW:i,i=i>t.maxW?t.maxW:i,t.w=i,t.innerW=i-e),i=n.h,i!==r&&(i=i<t.minH?t.minH:i,i=i>t.maxH?t.maxH:i,t.h=i,t.innerH=i-o),i=n.innerW,i!==r&&(i=i<t.minW-e?t.minW-e:i,i=i>t.maxW-e?t.maxW-e:i,t.innerW=i,t.w=i+e),i=n.innerH,i!==r&&(i=i<t.minH-o?t.minH-o:i,i=i>t.maxH-o?t.maxH-o:i,t.innerH=i,t.h=i+o),n.contentW!==r&&(t.contentW=n.contentW),n.contentH!==r&&(t.contentH=n.contentH),u=f._lastLayoutRect,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(s=c.repaintControls,s&&s.map&&!s.map[f._id]&&(s.push(f),s.map[f._id]=!0),u.x=t.x,u.y=t.y,u.w=t.w,u.h=t.h),f):t},repaint:function(){var r=this,e,o,u,n,s,h,c,t,f,i;f=document.createRange?function(n){return n}:Math.round;e=r.getEl().style;n=r._layoutRect;t=r._lastRepaintRect||{};s=r.borderBox;h=s.left+s.right;c=s.top+s.bottom;n.x!==t.x&&(e.left=f(n.x)+"px",t.x=n.x);n.y!==t.y&&(e.top=f(n.y)+"px",t.y=n.y);n.w!==t.w&&(i=f(n.w-h),e.width=(i>=0?i:0)+"px",t.w=n.w);n.h!==t.h&&(i=f(n.h-c),e.height=(i>=0?i:0)+"px",t.h=n.h);r._hasBody&&n.innerW!==t.innerW&&(i=f(n.innerW),u=r.getEl("body"),u&&(o=u.style,o.width=(i>=0?i:0)+"px"),t.innerW=n.innerW);r._hasBody&&n.innerH!==t.innerH&&(i=f(n.innerH),u=u||r.getEl("body"),u&&(o=o||u.style,o.height=(i>=0?i:0)+"px"),t.innerH=n.innerH);r._lastRepaintRect=t;r.fire("repaint",{},!1)},updateLayoutRect:function(){var n=this;n.parent()._lastRect=null;f.css(n.getEl(),{width:"",height:""});n._layoutRect=n._lastRepaintRect=n._lastLayoutRect=null;n.initLayoutRect()},on:function(n,t){function r(n){var t,r;return"string"!=typeof n?n:function(u){return t||i.parentsAndSelf().each(function(i){var u=i.settings.callbacks;if(u&&(t=u[n]))return(r=i,!1)}),t?t.call(r,u):(u.action=n,void this.fire("execute",u))}}var i=this;return l(i).on(n,r(t)),i},off:function(n,t){return l(this).off(n,t),this},fire:function(n,t,i){var u=this,r;if(t=t||{},t.control||(t.control=u),t=l(u).fire(n,t),i!==!1&&u.parent)for(r=u.parent();r&&!t.isPropagationStopped();)r.fire(n,t,!1),r=r.parent();return t},hasEventListeners:function(n){return l(this).has(n)},parents:function(n){for(var r=this,i=new u,t=r.parent();t;t=t.parent())i.add(t);return n&&(i=i.filter(n)),i},parentsAndSelf:function(n){return new u(this).add(this.parents(n))},next:function(){var n=this.parent().items();return n[n.indexOf(this)+1]},prev:function(){var n=this.parent().items();return n[n.indexOf(this)-1]},innerHtml:function(n){return this.$el.html(n),this},getEl:function(n){var t=n?this._id+"-"+n:this._id;return this._elmCache[t]||(this._elmCache[t]=e("#"+t)[0]),this._elmCache[t]},show:function(){return this.visible(!0)},hide:function(){return this.visible(!1)},focus:function(){try{this.getEl().focus()}catch(n){}return this},blur:function(){return this.getEl().blur(),this},aria:function(n,t){var i=this,r=i.getEl(i.ariaTarget);return"undefined"==typeof t?i._aria[n]:(i._aria[n]=t,i.state.get("rendered")&&r.setAttribute("role"==n?n:"aria-"+n,t),i)},encode:function(n,t){return t!==!1&&(n=this.translate(n)),(n||"").replace(/[&<>"]/g,function(n){return"&#"+n.charCodeAt(0)+";"})},translate:function(n){return c.translate?c.translate(n):n},before:function(n){var t=this,i=t.parent();return i&&i.insert(n,i.items().indexOf(t),!0),t},after:function(n){var t=this,i=t.parent();return i&&i.insert(n,i.items().indexOf(t)),t},remove:function(){var n=this,t=n.getEl(),i=n.parent(),r,u,f,o;if(n.items)for(f=n.items().toArray(),u=f.length;u--;)f[u].remove();return i&&i.items&&(r=[],i.items().each(function(t){t!==n&&r.push(t)}),i.items().set(r),i._lastRect=null),n._eventsRoot&&n._eventsRoot==n&&e(t).off(),o=n.getRoot().controlIdLookup,o&&delete o[n._id],t&&t.parentNode&&t.parentNode.removeChild(t),n.state.set("rendered",!1),n.state.destroy(),n.fire("remove"),n},renderBefore:function(n){return e(n).before(this.renderHtml()),this.postRender(),this},renderTo:function(n){return e(n||this.getContainerElm()).append(this.renderHtml()),this.postRender(),this},preRender:function(){},render:function(){},renderHtml:function(){return'<div id="'+this._id+'" class="'+this.classes+'"><\/div>'},postRender:function(){var n=this,i=n.settings,f,r,u,t,o,s,c;n.$el=e(n.getEl());n.state.set("rendered",!0);for(t in i)0===t.indexOf("on")&&n.on(t.substr(2),i[t]);if(n._eventsRoot){for(u=n.parent();!o&&u;u=u.parent())o=u._eventsRoot;if(o)for(t in o._nativeEvents)n._nativeEvents[t]=!0}a(n);i.style&&(f=n.getEl(),f&&(f.setAttribute("style",i.style),f.style.cssText=i.style));n.settings.border&&(r=n.borderBox,n.$el.css({"border-top-width":r.top,"border-right-width":r.right,"border-bottom-width":r.bottom,"border-left-width":r.left}));s=n.getRoot();s.controlIdLookup||(s.controlIdLookup={});s.controlIdLookup[n._id]=n;for(c in n._aria)n.aria(c,n._aria[c]);n.state.get("visible")===!1&&(n.getEl().style.display="none");n.bindStates();n.state.on("change:visible",function(t){var r=t.value,i;n.state.get("rendered")&&(n.getEl().style.display=r===!1?"none":"",n.getEl().getBoundingClientRect());i=n.parent();i&&(i._lastRect=null);n.fire(r?"show":"hide");h.add(n)});n.fire("postrender",{},!1)},bindStates:function(){},scrollIntoView:function(n){function c(n,t){for(var u,i=n,r=u=0;i&&i!=t&&i.nodeType;)r+=i.offsetLeft||0,u+=i.offsetTop||0,i=i.offsetParent;return{x:r,y:u}}var i=this.getEl(),t=i.parentNode,r,u,f,e,o,s,h=c(i,t);return r=h.x,u=h.y,f=i.offsetWidth,e=i.offsetHeight,o=t.clientWidth,s=t.clientHeight,"end"==n?(r-=o-f,u-=s-e):"center"==n&&(r-=o/2-f/2,u-=s/2-e/2),t.scrollLeft=r,t.scrollTop=u,this},getRoot:function(){for(var t,r,n=this,i=[];n;){if(n.rootControl){t=n.rootControl;break}i.push(n);t=n;n=n.parent()}for(t||(t=this),r=i.length;r--;)i[r].rootControl=t;return t},reflow:function(){h.remove(this);var n=this.parent();return n._layout&&!n._layout.isNative()&&n.reflow(),this}};return t.each("text title visible disabled active value".split(" "),function(n){y[n]=function(t){return 0===arguments.length?this.state.get(n):("undefined"!=typeof t&&this.state.set(n,t),this)}}),c=n.extend(y)});i(lt,[],function(){var n={},t;return{add:function(t,i){n[t.toLowerCase()]=i},has:function(t){return!!n[t.toLowerCase()]},create:function(i,r){var u,f,e;if(!t){e=tinymce.ui;for(f in e)n[f.toLowerCase()]=e[f];t=!0}if("string"==typeof i?(r=r||{},r.type=i):(r=i,i=r.type),i=i.toLowerCase(),u=n[i],!u)throw new Error("Could not find control by type: "+i);return u=new u(r),u.type=i,u}}});i(fr,[],function(){return function(n){function c(n){return n&&1===n.nodeType}function u(n){return n=n||t,c(n)?n.getAttribute("role"):null}function e(n){for(var r,i=n||t;i=i.parentNode;)if(r=u(i))return r}function l(n){var i=t;if(c(i))return i.getAttribute("aria-"+n)}function a(n){var t=n.tagName.toUpperCase();return"INPUT"==t||"TEXTAREA"==t||"SELECT"==t}function p(n){return a(n)&&!n.hidden?!0:!!/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell|slider)$/.test(u(n))}function f(n){function t(n){if(1==n.nodeType&&"none"!=n.style.display){p(n)&&i.push(n);for(var r=0;r<n.childNodes.length;r++)t(n.childNodes[r])}}var i=[];return t(n||s.getEl()),i}function v(n){var u,t,i;for(n=n||r,t=n.parents().toArray(),t.unshift(n),i=0;i<t.length&&(u=t[i],!u.settings.ariaRoot);i++);return u}function w(n){var t=v(n),i=f(t.getEl());t.settings.ariaRemember&&"lastAriaIndex"in t?h(t.lastAriaIndex,i):h(0,i)}function h(n,t){return 0>n?n=t.length-1:n>=t.length&&(n=0),t[n]&&t[n].focus(),n}function i(n,i){var u=-1,e=v(),r;for(i=i||f(e.getEl()),r=0;r<i.length;r++)i[r]===t&&(u=r);u+=n;e.lastAriaIndex=h(u,i)}function b(){var n=e();"tablist"==n?i(-1,f(t.parentNode)):r.parent().submenu?y():i(-1)}function k(){var r=u(),n=e();"tablist"==n?i(1,f(t.parentNode)):"menuitem"==r&&"menu"==n&&l("haspopup")?o():i(1)}function d(){i(-1)}function g(){var n=u(),t=e();"menuitem"==n&&"menubar"==t?o():"button"==n&&l("haspopup")?o({key:"down"}):i(1)}function nt(n){var u=e(),t;"tablist"==u?(t=f(r.getEl("body"))[0],t&&t.focus()):i(n.shiftKey?-1:1)}function y(){r.fire("cancel")}function o(n){n=n||{};r.fire("click",{target:t,aria:n})}var s=n.root,t,r;try{t=document.activeElement}catch(tt){t=document.body}return r=s.getParentCtrl(t),s.on("keydown",function(n){function i(n,i){a(t)||"slider"!==u(t)&&i(n)!==!1&&n.preventDefault()}if(!n.isDefaultPrevented())switch(n.keyCode){case 37:i(n,b);break;case 39:i(n,k);break;case 38:i(n,d);break;case 40:i(n,g);break;case 27:y();break;case 14:case 13:case 32:i(n,o);break;case 9:nt(n)!==!1&&n.preventDefault()}}),s.on("focusin",function(n){t=n.target;r=n.control}),{focusFirst:w}}});i(it,[b,si,oi,lt,fr,r,s,ur,hi],function(n,t,i,r,u,f,e,o,s){var h={};return n.extend({init:function(n){var i=this;i._super(n);n=i.settings;n.fixed&&i.state.set("fixed",!0);i._items=new t;i.isRtl()&&i.classes.add("rtl");i.bodyClasses=new o(function(){i.state.get("rendered")&&(i.getEl("body").className=this.toString())});i.bodyClasses.prefix=i.classPrefix;i.classes.add("container");i.bodyClasses.add("container-body");n.containerCls&&i.classes.add(n.containerCls);i._layout=r.create((n.layout||"")+"layout");i.settings.items?i.add(i.settings.items):i.add(i.render());i._hasBody=!0},items:function(){return this._items},find:function(n){return n=h[n]=h[n]||new i(n),n.find(this)},add:function(n){var t=this;return t.items().add(t.create(n)).parent(t),t},focus:function(n){var t=this,i,u,r;return n&&(u=t.keyboardNav||t.parents().eq(-1)[0].keyboardNav)?void u.focusFirst(t):(r=t.find("*"),t.statusbar&&r.add(t.statusbar.items()),r.each(function(n){return n.settings.autofocus?(i=null,!1):void(n.canFocus&&(i=i||n))}),i&&i.focus(),t)},replace:function(n,t){for(var i,u=this.items(),r=u.length;r--;)if(u[r]===n){u[r]=t;break}r>=0&&(i=t.getEl(),i&&i.parentNode.removeChild(i),i=n.getEl(),i&&i.parentNode.removeChild(i));t.parent(this)},create:function(t){var u=this,i,e=[];return f.isArray(t)||(t=[t]),f.each(t,function(t){t&&(t instanceof n||("string"==typeof t&&(t={type:t}),i=f.extend({},u.settings.defaults,t),t.type=i.type=i.type||t.type||u.settings.defaultType||(i.defaults?i.defaults.type:null),t=r.create(i)),e.push(t))}),e},renderNew:function(){var n=this;return n.items().each(function(t,i){var r;t.parent(n);t.state.get("rendered")||(r=n.getEl("body"),r.hasChildNodes()&&i<=r.childNodes.length-1?e(r.childNodes[i]).before(t.renderHtml()):e(r).append(t.renderHtml()),t.postRender(),s.add(t))}),n._layout.applyClasses(n.items().filter(":visible")),n._lastRect=null,n},append:function(n){return this.add(n).renderNew()},prepend:function(n){var t=this;return t.items().set(t.create(n).concat(t.items().toArray())),t.renderNew()},insert:function(n,t,i){var u=this,r,f,e;return n=u.create(n),r=u.items(),!i&&t<r.length-1&&(t+=1),t>=0&&t<r.length&&(f=r.slice(0,t).toArray(),e=r.slice(t).toArray(),r.set(f.concat(n,e))),u.renderNew()},fromJSON:function(n){var t=this;for(var i in n)t.find("#"+i).value(n[i]);return t},toJSON:function(){var t=this,n={};return t.find("*").each(function(t){var i=t.name(),r=t.value();i&&"undefined"!=typeof r&&(n[i]=r)}),n},renderHtml:function(){var n=this,t=n._layout,i=this.settings.role;return n.preRender(),t.preRender(n),'<div id="'+n._id+'" class="'+n.classes+'"'+(i?' role="'+this.settings.role+'"':"")+'><div id="'+n._id+'-body" class="'+n.bodyClasses+'">'+(n.settings.html||"")+t.renderHtml(n)+"<\/div><\/div>"},postRender:function(){var n=this,t;return n.items().exec("postRender"),n._super(),n._layout.postRender(n),n.state.set("rendered",!0),n.settings.style&&n.$el.css(n.settings.style),n.settings.border&&(t=n.borderBox,n.$el.css({"border-top-width":t.top,"border-right-width":t.right,"border-bottom-width":t.bottom,"border-left-width":t.left})),n.parent()||(n.keyboardNav=new u({root:n})),n},initLayoutRect:function(){var n=this,t=n._super();return n._layout.recalc(n),t},recalc:function(){var t=this,n=t._layoutRect,i=t._lastRect;if(!i||i.w!=n.w||i.h!=n.h)return(t._layout.recalc(t),n=t.layoutRect(),t._lastRect={x:n.x,y:n.y,w:n.w,h:n.h},!0)},reflow:function(){var t;if(s.remove(this),this.visible()){for(n.repaintControls=[],n.repaintControls.map={},this.recalc(),t=n.repaintControls.length;t--;)n.repaintControls[t].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint();n.repaintControls=[]}return this}})});i(rt,[s],function(n){function i(n){var t,i,u,e,o,f,s,h,r=Math.max;return t=n.documentElement,i=n.body,u=r(t.scrollWidth,i.scrollWidth),e=r(t.clientWidth,i.clientWidth),o=r(t.offsetWidth,i.offsetWidth),f=r(t.scrollHeight,i.scrollHeight),s=r(t.clientHeight,i.clientHeight),h=r(t.offsetHeight,i.offsetHeight),{width:o>u?e:u,height:h>f?s:f}}function t(n){var i,t;if(n.changedTouches)for(i="screenX screenY pageX pageY clientX clientY".split(" "),t=0;t<i.length;t++)n[i[t]]=n.changedTouches[0][i[t]]}return function(r,u){function o(){return f.getElementById(u.handle||r)}var h,f=u.document||document,c,l,e,s,a,v;u=u||{};l=function(r){var y=i(f),l,p;t(r);r.preventDefault();c=r.button;l=o();a=r.screenX;v=r.screenY;p=window.getComputedStyle?window.getComputedStyle(l,null).getPropertyValue("cursor"):l.runtimeStyle.cursor;h=n("<div>").css({position:"absolute",top:0,left:0,width:y.width,height:y.height,zIndex:2147483647,opacity:.0001,cursor:p}).appendTo(f.body);n(f).on("mousemove touchmove",s).on("mouseup touchend",e);u.start(r)};s=function(n){return t(n),n.button!==c?e(n):(n.deltaX=n.screenX-a,n.deltaY=n.screenY-v,n.preventDefault(),void u.drag(n))};e=function(i){t(i);n(f).off("mousemove touchmove",s).off("mouseup touchend",e);h.remove();u.stop&&u.stop(i)};this.destroy=function(){n(o()).off()};n(o()).on("mousedown touchstart",l)}});i(er,[s,rt],function(n,t){return{init:function(){var n=this;n.on("repaint",n.renderScroll)},renderScroll:function(){function r(){function e(t,e,o,s,h,c){var a,v,k,y,d,w,l,p,b;if(v=i.getEl("scroll"+t)){if(p=e.toLowerCase(),b=o.toLowerCase(),n(i.getEl("absend")).css(p,i.layoutRect()[s]-1),!h)return void n(v).css("display","none");n(v).css("display","block");a=i.getEl("body");k=i.getEl("scroll"+t+"t");y=a["client"+o]-2*u;y-=r&&f?v["client"+c]:0;d=a["scroll"+o];w=y/d;l={};l[p]=a["offset"+e]+u;l[b]=y;n(v).css(l);l={};l[p]=a["scroll"+e]*w;l[b]=y*w;n(k).css(l)}}var r,f,t;t=i.getEl("body");r=t.scrollWidth>t.clientWidth;f=t.scrollHeight>t.clientHeight;e("h","Left","Width","contentW",r,"Height");e("v","Top","Height","contentH",f,"Width")}function f(){function r(r,f,e,o,s){var l,h=i._id+"-scroll"+r,c=i.classPrefix;n(i.getEl()).append('<div id="'+h+'" class="'+c+"scrollbar "+c+"scrollbar-"+r+'"><div id="'+h+'t" class="'+c+'scrollbar-thumb"><\/div><\/div>');i.draghelper=new t(h+"t",{start:function(){l=i.getEl("body")["scroll"+f];n("#"+h).addClass(c+"active")},drag:function(n){var c,a,v,h,t=i.layoutRect();a=t.contentW>t.innerW;v=t.contentH>t.innerH;h=i.getEl("body")["client"+e]-2*u;h-=a&&v?i.getEl("scroll"+r)["client"+s]:0;c=h/i.getEl("body")["scroll"+e];i.getEl("body")["scroll"+f]=l+n["delta"+o]/c},stop:function(){n("#"+h).removeClass(c+"active")}})}i.classes.add("scroll");r("v","Top","Height","Y","Width");r("h","Left","Width","X","Height")}var i=this,u=2;i.settings.autoScroll&&(i._hasScroll||(i._hasScroll=!0,f(),i.on("wheel",function(n){var t=i.getEl("body");t.scrollLeft+=10*(n.deltaX||0);t.scrollTop+=10*n.deltaY;r()}),n(i.getEl("body")).on("scroll",r)),r())}}});i(bt,[it,er],function(n,t){return n.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[t],renderHtml:function(){var n=this,i=n._layout,t=n.settings.html;return n.preRender(),i.preRender(n),"undefined"==typeof t?t='<div id="'+n._id+'-body" class="'+n.bodyClasses+'">'+i.renderHtml(n)+"<\/div>":("function"==typeof t&&(t=t.call(n)),n._hasBody=!1),'<div id="'+n._id+'" class="'+n.classes+'" hidefocus="1" tabindex="-1" role="group">'+(n._preBodyHtml||"")+t+"<\/div>"}})});i(kt,[l],function(n){function t(t,i,r){var v,h,u,f,o,s,c,l,a,e;return a=n.getViewPort(),h=n.getPos(i),u=h.x,f=h.y,t.state.get("fixed")&&"static"==n.getRuntimeStyle(document.body,"position")&&(u-=a.x,f-=a.y),v=t.getEl(),e=n.getSize(v),o=e.width,s=e.height,e=n.getSize(i),c=e.width,l=e.height,r=(r||"").split(""),"b"===r[0]&&(f+=l),"r"===r[1]&&(u+=c),"c"===r[0]&&(f+=Math.round(l/2)),"c"===r[1]&&(u+=Math.round(c/2)),"b"===r[3]&&(f-=s),"r"===r[4]&&(u-=o),"c"===r[3]&&(f-=Math.round(s/2)),"c"===r[4]&&(u-=Math.round(o/2)),{x:u,y:f,w:o,h:s}}return{testMoveRel:function(i,r){for(var u,f=n.getViewPort(),e=0;e<r.length;e++)if(u=t(this,i,r[e]),this.state.get("fixed")){if(u.x>0&&u.x+u.w<f.w&&u.y>0&&u.y+u.h<f.h)return r[e]}else if(u.x>f.x&&u.x+u.w<f.w+f.x&&u.y>f.y&&u.y+u.h<f.h+f.y)return r[e];return r[0]},moveRel:function(n,i){"string"!=typeof i&&(i=this.testMoveRel(n,i));var r=t(this,n,i);return this.moveTo(r.x,r.y)},moveBy:function(n,t){var i=this,r=i.layoutRect();return i.moveTo(r.x+n,r.y+t),i},moveTo:function(t,i){function e(n,t,i){return 0>n?0:n+i>t?(n=t-i,0>n?0:n):n}var r=this,u,f;return r.settings.constrainToViewport&&(u=n.getViewPort(window),f=r.layoutRect(),t=e(t,u.w+u.x,f.w),i=e(i,u.h+u.y,f.h)),r.state.get("rendered")?r.layoutRect({x:t,y:i}).repaint():(r.settings.x=t,r.settings.y=i),r.fire("move",{x:t,y:i}),r}}});i(or,[l],function(n){return{resizeToContent:function(){this._layoutRect.autoResize=!0;this._lastRect=null;this.reflow()},resizeTo:function(t,i){if(1>=t||1>=i){var r=n.getWindowSize();t=1>=t?t*r.w:t;i=1>=i?i*r.h:i}return this._layoutRect.autoResize=!1,this.layoutRect({minW:t,minH:i,w:t,h:i}).reflow()},resizeBy:function(n,t){var i=this,r=i.layoutRect();return i.resizeTo(r.w+n,r.h+t)}}});i(at,[bt,kt,or,l,s,f],function(n,t,i,r,u,f){function w(n,t){for(;n;){if(n==t)return!0;n=n.parent()}}function b(n){for(var t,i,r=e.length;r--;)if(t=e[r],i=t.getParentCtrl(n.target),t.settings.autohide){if(i&&(w(i,t)||t.parent()===i))continue;n=t.fire("autohide",{target:n.target});n.isDefaultPrevented()||t.hide()}}function k(){c||(c=function(n){2!=n.button&&b(n)},u(document).on("click touchstart",c))}function d(){l||(l=function(){for(var n=e.length;n--;)y(e[n])},u(window).on("scroll",l))}function g(){if(!a){var n=document.documentElement,t=n.clientWidth,i=n.clientHeight;a=function(){document.all&&t==n.clientWidth&&i==n.clientHeight||(t=n.clientWidth,i=n.clientHeight,s.hideAll())};u(window).on("resize",a)}}function y(n){function i(t,i){for(var r,u=0;u<e.length;u++)if(e[u]!=n)for(r=e[u].parent();r&&(r=r.parent());)r==n&&e[u].fixed(t).moveBy(0,i).repaint()}var t=r.getViewPort().y;n.settings.autofix&&(n.state.get("fixed")?n._autoFixY>t&&(n.fixed(!1).layoutRect({y:n._autoFixY}).repaint(),i(!1,n._autoFixY-t)):(n._autoFixY=n.layoutRect().y,n._autoFixY<t&&(n.fixed(!0).layoutRect({y:0}).repaint(),i(!0,t-n._autoFixY))))}function h(n,t){var i,r=s.zIndex||65535,e,f;if(n)o.push(t);else for(i=o.length;i--;)o[i]===t&&o.splice(i,1);if(o.length)for(i=0;i<o.length;i++)o[i].modal&&(r++,e=o[i]),o[i].getEl().style.zIndex=r,o[i].zIndex=r,r++;f=u("#"+t.classPrefix+"modal-block",t.getContainerElm())[0];e?u(f).css("z-index",e.zIndex-1):f&&(f.parentNode.removeChild(f),v=!1);s.currentZIndex=r}function p(n){for(var t=e.length;t--;)e[t]===n&&e.splice(t,1);for(t=o.length;t--;)o[t]===n&&o.splice(t,1)}var c,l,a,e=[],o=[],v,s=n.extend({Mixins:[t,i],init:function(n){var t=this;t._super(n);t._eventsRoot=t;t.classes.add("floatpanel");n.autohide&&(k(),g(),e.push(t));n.autofix&&(d(),t.on("move",function(){y(this)}));t.on("postrender show",function(n){if(n.control==t){var r,i=t.classPrefix;t.modal&&!v&&(r=u("#"+i+"modal-block",t.getContainerElm()),r[0]||(r=u('<div id="'+i+'modal-block" class="'+i+"reset "+i+'fade"><\/div>').appendTo(t.getContainerElm())),f.setTimeout(function(){r.addClass(i+"in");u(t.getEl()).addClass(i+"in")}),v=!0);h(!0,t)}});t.on("show",function(){t.parents().each(function(n){if(n.state.get("fixed"))return(t.fixed(!0),!1)})});n.popover&&(t._preBodyHtml='<div class="'+t.classPrefix+'arrow"><\/div>',t.classes.add("popover").add("bottom").add(t.isRtl()?"end":"start"));t.aria("label",n.ariaLabel);t.aria("labelledby",t._id);t.aria("describedby",t.describedBy||t._id+"-none")},fixed:function(n){var t=this,i;return t.state.get("fixed")!=n&&(t.state.get("rendered")&&(i=r.getViewPort(),n?t.layoutRect().y-=i.y:t.layoutRect().y+=i.y),t.classes.toggle("fixed",n),t.state.set("fixed",n)),t},show:function(){for(var t=this,i=t._super(),n=e.length;n--&&e[n]!==t;);return-1===n&&e.push(t),i},hide:function(){return p(this),h(!1,this),this._super()},hideAll:function(){s.hideAll()},close:function(){var n=this;return n.fire("close").isDefaultPrevented()||(n.remove(),h(!1,n)),n},remove:function(){p(this);this._super()},postRender:function(){var n=this;return n.settings.bodyRole&&this.getEl("body").setAttribute("role",n.settings.bodyRole),n._super()}});return s.hideAll=function(){for(var t,n=e.length;n--;)t=e[n],t&&t.settings.autohide&&(t.hide(),e.splice(n,1))},s});i(ci,[at,bt,l,s,rt,rr,u,f],function(n,t,i,r,u,f,e,o){function c(n){var t=r("meta[name=viewport]")[0],i;e.overrideViewPort!==!1&&(t||(t=document.createElement("meta"),t.setAttribute("name","viewport"),document.getElementsByTagName("head")[0].appendChild(t)),i=t.getAttribute("content"),i&&"undefined"!=typeof h&&(h=i),t.setAttribute("content",n?"width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0":h))}function l(n){for(var t=0;t<s.length;t++)if(s[t]._fullscreen)return;r([document.documentElement,document.body]).removeClass(n+"fullscreen")}function a(){function t(){for(var r=i.getWindowSize(),t,n=0;n<s.length;n++)t=s[n].layoutRect(),s[n].moveTo(s[n].settings.x||Math.max(0,r.w/2-t.w/2),s[n].settings.y||Math.max(0,r.h/2-t.h/2))}if(!e.desktop){var n={w:window.innerWidth,h:window.innerHeight};o.setInterval(function(){var t=window.innerWidth,i=window.innerHeight;n.w==t&&n.h==i||(n={w:t,h:i},r(window).trigger("resize"))},100)}r(window).on("resize",t)}var s=[],h="",v=n.extend({modal:!0,Defaults:{border:1,layout:"flex",containerCls:"panel",role:"dialog",callbacks:{submit:function(){this.fire("submit",{data:this.toJSON()})},close:function(){this.close()}}},init:function(n){var r=this;r._super(n);r.isRtl()&&r.classes.add("rtl");r.classes.add("window");r.bodyClasses.add("window-body");r.state.set("fixed",!0);n.buttons&&(r.statusbar=new t({layout:"flex",border:"1 0 0 0",spacing:3,padding:10,align:"center",pack:r.isRtl()?"start":"end",defaults:{type:"button"},items:n.buttons}),r.statusbar.classes.add("foot"),r.statusbar.parent(r));r.on("click",function(n){var t=r.classPrefix+"close";(i.hasClass(n.target,t)||i.hasClass(n.target.parentNode,t))&&r.close()});r.on("cancel",function(){r.close()});r.aria("describedby",r.describedBy||r._id+"-none");r.aria("label",n.title);r._fullscreen=!1},recalc:function(){var n=this,f=n.statusbar,t,r,u,e;n._fullscreen&&(n.layoutRect(i.getWindowSize()),n.layoutRect().contentH=n.layoutRect().innerH);n._super();t=n.layoutRect();n.settings.title&&!n._fullscreen&&(r=t.headerW,r>t.w&&(u=t.x-Math.max(0,r/2),n.layoutRect({w:r,x:u}),e=!0));f&&(f.layoutRect({w:n.layoutRect().innerW}).recalc(),r=f.layoutRect().minW+t.deltaW,r>t.w&&(u=t.x-Math.max(0,r-t.w),n.layoutRect({w:r,x:u}),e=!0));e&&n.recalc()},initLayoutRect:function(){var t=this,n=t._super(),r=0,e,u,f;return t.settings.title&&!t._fullscreen&&(e=t.getEl("head"),u=i.getSize(e),n.headerW=u.width,n.headerH=u.height,r+=n.headerH),t.statusbar&&(r+=t.statusbar.layoutRect().h),n.deltaH+=r,n.minH+=r,n.h+=r,f=i.getWindowSize(),n.x=t.settings.x||Math.max(0,f.w/2-n.w/2),n.y=t.settings.y||Math.max(0,f.h/2-n.h/2),n},renderHtml:function(){var n=this,f=n._layout,t=n._id,r=n.classPrefix,i=n.settings,e="",o="",u=i.html;return n.preRender(),f.preRender(n),i.title&&(e='<div id="'+t+'-head" class="'+r+'window-head"><div id="'+t+'-title" class="'+r+'title">'+n.encode(i.title)+'<\/div><div id="'+t+'-dragh" class="'+r+'dragh"><\/div><button type="button" class="'+r+'close" aria-hidden="true"><i class="mce-ico mce-i-remove"><\/i><\/button><\/div>'),i.url&&(u='<iframe src="'+i.url+'" tabindex="-1"><\/iframe>'),"undefined"==typeof u&&(u=f.renderHtml(n)),n.statusbar&&(o=n.statusbar.renderHtml()),'<div id="'+t+'" class="'+n.classes+'" hidefocus="1"><div class="'+n.classPrefix+'reset" role="application">'+e+'<div id="'+t+'-body" class="'+n.bodyClasses+'">'+u+"<\/div>"+o+"<\/div><\/div>"},fullscreen:function(n){var t=this,s=document.documentElement,h,c=t.classPrefix,u,e;return n!=t._fullscreen&&((r(window).on("resize",function(){var r,n;t._fullscreen&&(h?t._timer||(t._timer=o.setTimeout(function(){var n=i.getWindowSize();t.moveTo(0,0).resizeTo(n.w,n.h);t._timer=0},50)):(r=(new Date).getTime(),n=i.getWindowSize(),t.moveTo(0,0).resizeTo(n.w,n.h),(new Date).getTime()-r>50&&(h=!0)))}),u=t.layoutRect(),t._fullscreen=n,n)?(t._initial={x:u.x,y:u.y,w:u.w,h:u.h},t.borderBox=f.parseBox("0"),t.getEl("head").style.display="none",u.deltaH-=u.headerH+2,r([s,document.body]).addClass(c+"fullscreen"),t.classes.add("fullscreen"),e=i.getWindowSize(),t.moveTo(0,0).resizeTo(e.w,e.h)):(t.borderBox=f.parseBox(t.settings.border),t.getEl("head").style.display="",u.deltaH+=u.headerH,r([s,document.body]).removeClass(c+"fullscreen"),t.classes.remove("fullscreen"),t.moveTo(t._initial.x,t._initial.y).resizeTo(t._initial.w,t._initial.h))),t.reflow()},postRender:function(){var n=this,t;setTimeout(function(){n.classes.add("in");n.fire("open")},0);n._super();n.statusbar&&n.statusbar.postRender();n.focus();this.dragHelper=new u(n._id+"-dragh",{start:function(){t={x:n.layoutRect().x,y:n.layoutRect().y}},drag:function(i){n.moveTo(t.x+i.deltaX,t.y+i.deltaY)}});n.on("submit",function(t){t.isDefaultPrevented()||n.close()});s.push(n);c(!0)},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var n=this,t;for(n.dragHelper.destroy(),n._super(),n.statusbar&&this.statusbar.remove(),t=s.length;t--;)s[t]===n&&s.splice(t,1);c(s.length>0);l(n.classPrefix)},getContentWindow:function(){var n=this.getEl().getElementsByTagName("iframe")[0];return n?n.contentWindow:null}});return a(),v});i(sr,[ci],function(n){var t=n.extend({init:function(n){n={border:1,padding:20,layout:"flex",pack:"center",align:"center",containerCls:"panel",autoScroll:!0,buttons:{type:"button",text:"Ok",action:"ok"},items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200}};this._super(n)},Statics:{OK:1,OK_CANCEL:2,YES_NO:3,YES_NO_CANCEL:4,msgBox:function(i){function r(n,t,i){return{type:"button",text:n,subtype:i?"primary":"",onClick:function(n){n.control.parents()[1].close();f(t)}}}var u,f=i.callback||function(){};switch(i.buttons){case t.OK_CANCEL:u=[r("Ok",!0,!0),r("Cancel",!1)];break;case t.YES_NO:case t.YES_NO_CANCEL:u=[r("Yes",1,!0),r("No",0)];i.buttons==t.YES_NO_CANCEL&&u.push(r("Cancel",-1));break;default:u=[r("Ok",!0,!0)]}return new n({padding:20,x:i.x,y:i.y,minWidth:300,minHeight:100,layout:"flex",pack:"center",align:"center",buttons:u,title:i.title,role:"alertdialog",items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200,text:i.text},onPostRender:function(){this.aria("describedby",this.items()[0]._id)},onClose:i.onClose,onCancel:function(){f(!1)}}).renderTo(document.body).reflow()},alert:function(n,i){return"string"==typeof n&&(n={text:n}),n.callback=i,t.msgBox(n)},confirm:function(n,i){return"string"==typeof n&&(n={text:n}),n.callback=i,n.buttons=t.OK_CANCEL,t.msgBox(n)}}});return t});i(hr,[ci,sr],function(n,t){return function(i){function f(){if(r.length)return r[r.length-1]}function e(n){i.fire("OpenWindow",{win:n})}function o(n){i.fire("CloseWindow",{win:n})}var u=this,r=[];u.windows=r;i.on("remove",function(){for(var n=r.length;n--;)r[n].close()});u.open=function(t,u){var f;return i.editorManager.setActive(i),t.title=t.title||" ",t.url=t.url||t.file,t.url&&(t.width=parseInt(t.width||320,10),t.height=parseInt(t.height||240,10)),t.body&&(t.items={defaults:t.defaults,type:t.bodyType||"form",items:t.body,data:t.data,callbacks:t.commands}),t.url||t.buttons||(t.buttons=[{text:"Ok",subtype:"primary",onclick:function(){f.find("form")[0].submit()}},{text:"Cancel",onclick:function(){f.close()}}]),f=new n(t),r.push(f),f.on("close",function(){for(var n=r.length;n--;)r[n]===f&&r.splice(n,1);r.length||i.focus();o(f)}),t.data&&f.on("postRender",function(){this.find("*").each(function(n){var i=n.name();i in t.data&&n.value(t.data[i])})}),f.features=t||{},f.params=u||{},1===r.length&&i.nodeChanged(),f=f.renderTo().reflow(),e(f),f};u.alert=function(n,r,u){var f;f=t.alert(n,function(){r?r.call(u||this):i.focus()});f.on("close",function(){o(f)});e(f)};u.confirm=function(n,i,r){var u;u=t.confirm(n,function(n){i.call(r||this,n)});u.on("close",function(){o(u)});e(u)};u.close=function(){f()&&f().close()};u.getParams=function(){return f()?f().params:null};u.setParams=function(n){f()&&(f().params=n)};u.getWindows=function(){return r}}});i(cr,[b,kt],function(n,t){return n.extend({Mixins:[t],Defaults:{classes:"widget tooltip tooltip-n"},renderHtml:function(){var n=this,t=n.classPrefix;return'<div id="'+n._id+'" class="'+n.classes+'" role="presentation"><div class="'+t+'tooltip-arrow"><\/div><div class="'+t+'tooltip-inner">'+n.encode(n.state.get("text"))+"<\/div><\/div>"},bindStates:function(){var n=this;return n.state.on("change:text",function(t){n.getEl().lastChild.innerHTML=n.encode(t.value)}),n._super()},repaint:function(){var i=this,n,t;n=i.getEl().style;t=i._layoutRect;n.left=t.x+"px";n.top=t.y+"px";n.zIndex=131070}})});i(o,[b,cr],function(n,t){var i,r=n.extend({init:function(n){var t=this;t._super(n);n=t.settings;t.canFocus=!0;n.tooltip&&r.tooltips!==!1&&(t.on("mouseenter",function(i){var r=t.tooltip().moveTo(-65535),u;i.control==t?(u=r.text(n.tooltip).show().testMoveRel(t.getEl(),["bc-tc","bc-tl","bc-tr"]),r.classes.toggle("tooltip-n","bc-tc"==u),r.classes.toggle("tooltip-nw","bc-tl"==u),r.classes.toggle("tooltip-ne","bc-tr"==u),r.moveRel(t.getEl(),u)):r.hide()}),t.on("mouseleave mousedown click",function(){t.tooltip().hide()}));t.aria("label",n.ariaLabel||n.tooltip)},tooltip:function(){return i||(i=new t({type:"tooltip"}),i.renderTo()),i},postRender:function(){var n=this,t=n.settings;n._super();n.parent()||!t.width&&!t.height||(n.initLayoutRect(),n.repaint());t.autofocus&&n.focus()},bindStates:function(){function t(t){n.aria("disabled",t);n.classes.toggle("disabled",t)}function i(t){n.aria("pressed",t);n.classes.toggle("active",t)}var n=this;return n.state.on("change:disabled",function(n){t(n.value)}),n.state.on("change:active",function(n){i(n.value)}),n.state.get("disabled")&&t(!0),n.state.get("active")&&i(!0),n._super()},remove:function(){this._super();i&&(i.remove(),i=null)}});return r});i(lr,[o],function(n){return n.extend({Defaults:{value:0},init:function(n){var t=this;t._super(n);t.classes.add("progress");t.settings.filter||(t.settings.filter=function(n){return Math.round(n)})},renderHtml:function(){var t=this,i=t._id,n=this.classPrefix;return'<div id="'+i+'" class="'+t.classes+'"><div class="'+n+'bar-container"><div class="'+n+'bar"><\/div><\/div><div class="'+n+'text">0%<\/div><\/div>'},postRender:function(){var n=this;return n._super(),n.value(n.settings.value),n},bindStates:function(){function t(t){t=n.settings.filter(t);n.getEl().lastChild.innerHTML=t+"%";n.getEl().firstChild.firstChild.style.width=t+"%"}var n=this;return n.state.on("change:value",function(n){t(n.value)}),t(n.state.get("value")),n._super()}})});i(ar,[b,kt,lr,f],function(n,t,i,r){return n.extend({Mixins:[t],Defaults:{classes:"widget notification"},init:function(n){var t=this;t._super(n);n.text&&t.text(n.text);n.icon&&(t.icon=n.icon);n.color&&(t.color=n.color);n.type&&t.classes.add("notification-"+n.type);n.timeout&&(n.timeout<0||n.timeout>0)&&!n.closeButton?t.closeButton=!1:(t.classes.add("has-close"),t.closeButton=!0);n.progressBar&&(t.progressBar=new i);t.on("click",function(n){-1!=n.target.className.indexOf(t.classPrefix+"close")&&t.close()})},renderHtml:function(){var n=this,t=n.classPrefix,i="",r="",u="",f="";return n.icon&&(i='<i class="'+t+"ico "+t+"i-"+n.icon+'"><\/i>'),n.color&&(f=' style="background-color: '+n.color+'"'),n.closeButton&&(r='<button type="button" class="'+t+'close" aria-hidden="true">×<\/button>'),n.progressBar&&(u=n.progressBar.renderHtml()),'<div id="'+n._id+'" class="'+n.classes+'"'+f+' role="presentation">'+i+'<div class="'+t+'notification-inner">'+n.state.get("text")+"<\/div>"+u+r+"<\/div>"},postRender:function(){var n=this;return r.setTimeout(function(){n.$el.addClass(n.classPrefix+"in")}),n._super()},bindStates:function(){var n=this;return n.state.on("change:text",function(t){n.getEl().childNodes[1].innerHTML=t.value}),n.progressBar&&n.progressBar.bindStates(),n._super()},close:function(){var n=this;return n.fire("close").isDefaultPrevented()||n.remove(),n},repaint:function(){var i=this,n,t;n=i.getEl().style;t=i._layoutRect;n.left=t.x+"px";n.top=t.y+"px";n.zIndex=131070}})});i(vr,[ar,f],function(n,t){return function(i){function e(){if(r.length)return r[r.length-1]}function o(){t.requestAnimationFrame(function(){s();u()})}function s(){for(var n=0;n<r.length;n++)r[n].moveTo(0,0)}function u(){var t,u,n;if(r.length>0&&(t=r.slice(0,1)[0],u=i.inline?i.getElement():i.getContentAreaContainer(),t.moveRel(u,"tc-tc"),r.length>1))for(n=1;n<r.length;n++)r[n].moveRel(r[n-1].getEl(),"bc-tc")}var f=this,r=[];f.notifications=r;i.on("remove",function(){for(var n=r.length;n--;)r[n].close()});i.on("ResizeEditor",u);i.on("ResizeWindow",o);f.open=function(t){var f;return i.editorManager.setActive(i),f=new n(t),r.push(f),t.timeout>0&&(f.timer=setTimeout(function(){f.close()},t.timeout)),f.on("close",function(){var n=r.length;for(f.timer&&i.getWin().clearTimeout(f.timer);n--;)r[n]===f&&r.splice(n,1);u()}),f.renderTo(),u(),f};f.close=function(){e()&&e().close()};f.getNotifications=function(){return r};i.on("SkinLoaded",function(){var n=i.settings.service_message;n&&i.notificationManager.open({text:n,type:"warning",timeout:0,icon:""})})}});i(sf,[h],function(n){function t(t,i,r){for(var u=[];i&&i!=t;i=i.parentNode)u.push(n.nodeIndex(i,r));return u}function i(n,t){for(var u,r=n,i=t.length-1;i>=0;i--){if(u=r.childNodes,t[i]>u.length-1)return null;r=u[t[i]]}return r}return{create:t,resolve:i}});i(hf,[ot,y,p,sf,et,d,u,r,f,w,v,ht],function(n,t,i,r,u,f,e,o,s,h,c,l){return function(a){function b(n,t){try{a.getDoc().execCommand(n,!1,t)}catch(i){}}function g(){var n=a.getDoc().documentMode;return n?n:6}function p(n){return n.isDefaultPrevented()}function ft(n){var t,i;n.dataTransfer&&(a.selection.isCollapsed()&&"IMG"==n.target.tagName&&y.select(n.target),t=a.selection.getContent(),t.length>0&&(i=ut+escape(a.id)+","+escape(t),n.dataTransfer.setData(bt,i)))}function et(n){var t;return n.dataTransfer&&(t=n.dataTransfer.getData(bt),t&&t.indexOf(ut)>=0)?(t=t.substr(ut.length).split(","),{id:unescape(t[0]),html:unescape(t[1])}):null}function ot(n){a.queryCommandSupported("mceInsertClipboardContent")?a.execCommand("mceInsertClipboardContent",!1,{content:n}):a.execCommand("mceInsertContent",!1,n)}function kt(){function b(n){var t=u.schema.getBlockElements(),i=a.getBody();if("BR"!=n.nodeName)return!1;for(;n!=i&&!t[n.nodeName];n=n.parentNode)if(n.nextSibling)return!1;return!0}function v(n,t){for(var i=n.nextSibling;i&&i!=t;i=i.nextSibling)if((3!=i.nodeType||0!==w.trim(i.data).length)&&i!==t)return!1;return i===t}function c(n,t,r){for(var f,o=u.schema.getNonEmptyElements(),e=new i(r||n,n);f=e[t?"next":"prev"]();)if(o[f.nodeName]&&!b(f)||3==f.nodeType&&f.data.length>0)return f}function d(n){var o,r,i,f,s;if(!n.collapsed&&(o=u.getParent(t.getNode(n.startContainer,n.startOffset),u.isBlock),r=u.getParent(t.getNode(n.endContainer,n.endOffset),u.isBlock),s=a.schema.getTextBlockElements(),o!=r&&s[o.nodeName]&&s[r.nodeName]&&"false"!==u.getContentEditable(o)&&"false"!==u.getContentEditable(r)))return n.deleteContents(),i=c(o,!1),f=c(r,!0),u.isEmpty(r)||w(o).append(r.childNodes),w(r).remove(),i?1==i.nodeType?"BR"==i.nodeName?(n.setStartBefore(i),n.setEndBefore(i)):(n.setStartAfter(i),n.setEndAfter(i)):(n.setStart(i,i.data.length),n.setEnd(i,i.data.length)):f&&(1==f.nodeType?(n.setStartBefore(f),n.setEndBefore(f)):(n.setStart(f,0),n.setEnd(f,0))),e.setRng(n),!0}function g(n,i){var r,f,o,e,s,h;if(!n.collapsed)return n;if(s=n.startContainer,h=n.startOffset,3==s.nodeType)if(i){if(h<s.data.length)return n}else if(h>0)return n;if(r=t.getNode(n.startContainer,n.startOffset),o=u.getParent(r,u.isBlock),f=c(a.getBody(),i,r),e=u.getParent(f,u.isBlock),!r||!f)return n;if(e&&o!=e)if(i){if(!v(o,e))return n;1==r.nodeType?"BR"==r.nodeName?n.setStartBefore(r):n.setStartAfter(r):n.setStart(r,r.data.length);1==f.nodeType?n.setEnd(f,0):n.setEndBefore(f)}else{if(!v(e,o))return n;1==f.nodeType?"BR"==f.nodeName?n.setStartBefore(f):n.setStartAfter(f):n.setStart(f,f.data.length);1==r.nodeType?n.setEnd(r,0):n.setEndBefore(r)}return n}function nt(n){var t=e.getRng();return t=g(t,n),d(t)?!0:void 0}function tt(n,t){function y(n,i){return c=w(i).parents().filter(function(n,t){return!!a.schema.getTextInlineElements()[t.nodeName]}),e=n.cloneNode(!1),c=o.map(c,function(n){return n=n.cloneNode(!1),e.hasChildNodes()?(n.appendChild(e.firstChild),e.appendChild(n)):e.appendChild(n),e.appendChild(n),n}),c.length?(h=u.create("br"),c[0].appendChild(h),u.replace(e,n),t.setStartBefore(h),t.setEndBefore(h),a.selection.setRng(t),h):null}function p(n){return n&&a.schema.getTextBlockElements()[n.tagName]}var b,f,e,v,l,i,s,h,c;if(t.collapsed&&(i=t.startContainer,s=t.startOffset,f=u.getParent(i,u.isBlock),p(f)))if(1==i.nodeType){if(i=i.childNodes[s],i&&"BR"!=i.tagName)return;if(l=n?f.nextSibling:f.previousSibling,u.isEmpty(f)&&p(l)&&u.isEmpty(l)&&y(f,i))return u.remove(l),!0}else if(3==i.nodeType){if(b=r.create(f,i),v=f.cloneNode(!0),i=r.resolve(v,b),n){if(s>=i.data.length)return;i.deleteData(s,1)}else{if(0>=s)return;i.deleteData(s-1,1)}if(u.isEmpty(v))return y(f,i)}}function f(n){var i,t,r;nt(n)||(o.each(a.getBody().getElementsByTagName("*"),function(n){"SPAN"==n.tagName&&n.setAttribute("mce-data-marked",1);!n.hasAttribute("data-mce-style")&&n.hasAttribute("style")&&a.dom.setAttrib(n,"style",a.dom.getAttrib(n,"style"))}),i=new l(function(){}),i.observe(a.getDoc(),{childList:!0,attributes:!0,subtree:!0,attributeFilter:["style"]}),a.getDoc().execCommand(n?"ForwardDelete":"Delete",!1,null),t=a.selection.getRng(),r=t.startContainer.parentNode,o.each(i.takeRecords(),function(n){if(u.isChildOf(n.target,a.getBody())){if("style"==n.attributeName){var i=n.target.getAttribute("data-mce-style");i?n.target.setAttribute("style",i):n.target.removeAttribute("style")}o.each(n.addedNodes,function(n){if("SPAN"==n.nodeName&&!n.getAttribute("mce-data-marked")){var f,i;n==r&&(f=t.startOffset,i=n.firstChild);u.remove(n,!0);i&&(t.setStart(i,f),t.setEnd(i,f),a.selection.setRng(t))}})}}),i.disconnect(),o.each(a.dom.select("span[mce-data-marked]"),function(n){n.removeAttribute("mce-data-marked")}))}var rt=a.getDoc(),u=a.dom,e=a.selection,l=window.MutationObserver,y,h;l||(y=!0,l=function(){function t(n){var t=n.relatedNode||n.target;i.push({target:t,addedNodes:[t]})}function r(n){var t=n.relatedNode||n.target;i.push({target:t,attributeName:n.attrName})}var i=[],n;this.observe=function(i){n=i;n.addEventListener("DOMSubtreeModified",t,!1);n.addEventListener("DOMNodeInsertedIntoDocument",t,!1);n.addEventListener("DOMNodeInserted",t,!1);n.addEventListener("DOMAttrModified",r,!1)};this.disconnect=function(){n.removeEventListener("DOMSubtreeModified",t,!1);n.removeEventListener("DOMNodeInsertedIntoDocument",t,!1);n.removeEventListener("DOMNodeInserted",t,!1);n.removeEventListener("DOMAttrModified",r,!1)};this.takeRecords=function(){return i}});a.on("keydown",function(n){var t=n.keyCode==it,r=n.ctrlKey||n.metaKey;if(!p(n)&&(t||n.keyCode==k)){var i=a.selection.getRng(),u=i.startContainer,e=i.startOffset;if(t&&n.shiftKey)return;if(tt(t,i))return void n.preventDefault();if(!r&&i.collapsed&&3==u.nodeType&&(t?e<u.data.length:e>0))return;n.preventDefault();r&&a.selection.getSel().modify("extend",t?"forward":"backward",n.metaKey?"lineboundary":"word");f(t)}});a.on("keypress",function(t){if(!p(t)&&!e.isCollapsed()&&t.charCode>31&&!n.metaKeyPressed(t)){var r,o,i,h,s,c;r=a.selection.getRng();c=String.fromCharCode(t.charCode);t.preventDefault();o=w(r.startContainer).parents().filter(function(n,t){return!!a.schema.getTextInlineElements()[t.nodeName]});f(!0);o=o.filter(function(n,t){return!w.contains(a.getBody(),t)});o.length?(i=u.createFragment(),o.each(function(n,t){t=t.cloneNode(!1);i.hasChildNodes()?(t.appendChild(i.firstChild),i.appendChild(t)):(s=t,i.appendChild(t));i.appendChild(t)}),s.appendChild(a.getDoc().createTextNode(c)),h=u.getParent(r.startContainer,u.isBlock),u.isEmpty(h)?w(h).empty().append(i):r.insertNode(i),r.setStart(s.firstChild,1),r.setEnd(s.firstChild,1),a.selection.setRng(r)):a.selection.setContent(c)}});a.addCommand("Delete",function(){f()});a.addCommand("ForwardDelete",function(){f(!0)});y||(a.on("dragstart",function(n){h=e.getRng();ft(n)}),a.on("drop",function(n){if(!p(n)){var i=et(n);i&&(n.preventDefault(),s.setEditorTimeout(a,function(){var r=t.getCaretRangeFromPoint(n.x,n.y,rt);h&&(e.setRng(h),h=null);f();e.setRng(r);ot(i.html)}))}}),a.on("cut",function(n){p(n)||!n.clipboardData||a.selection.isCollapsed()||(n.preventDefault(),n.clipboardData.clearData(),n.clipboardData.setData("text/html",a.selection.getContent()),n.clipboardData.setData("text/plain",a.selection.getContent({format:"text"})),s.setEditorTimeout(a,function(){f(!0)}))}))}function dt(){function n(n){var t=v.create("body"),i=n.cloneContents();return t.appendChild(i),y.serializer.serialize(t,{format:"html"})}function i(i){var r,f,u,e;return i.setStart?(f=n(i),u=v.createRng(),u.selectNode(a.getBody()),e=n(u),f===e):i.item?!1:(r=i.duplicate(),r.moveToElementText(a.getBody()),t.compareRanges(i,r))}a.on("keydown",function(n){var u=n.keyCode,r,t;if(!p(n)&&(u==it||u==k)){if(r=a.selection.isCollapsed(),t=a.getBody(),r&&!v.isEmpty(t))return;if(!r&&!i(a.selection.getRng()))return;n.preventDefault();a.setContent("");t.firstChild&&v.isBlock(t.firstChild)?a.selection.setCursorLocation(t.firstChild,0):a.selection.setCursorLocation(t,0);a.nodeChanged()}})}function st(){a.shortcuts.add("meta+a",null,"SelectAll")}function gt(){a.settings.content_editable||v.bind(a.getDoc(),"mousedown mouseup",function(n){var t;if(n.target==a.getDoc().documentElement)if(t=y.getRng(),a.getBody().focus(),"mousedown"==n.type){if(h.isCaretContainer(t.startContainer))return;y.placeCaretAt(n.clientX,n.clientY)}else y.setRng(t)})}function ht(){a.on("keydown",function(n){if(!p(n)&&n.keyCode===k){if(!a.getBody().getElementsByTagName("hr").length)return;if(y.isCollapsed()&&0===y.getRng(!0).startOffset){var i=y.getNode(),t=i.previousSibling;if("HR"==i.nodeName)return v.remove(i),void n.preventDefault();t&&t.nodeName&&"hr"===t.nodeName.toLowerCase()&&(v.remove(t),n.preventDefault())}}})}function ni(){window.Range.prototype.getClientRects||a.on("mousedown",function(n){if(!p(n)&&"HTML"===n.target.nodeName){var t=a.getBody();t.blur();s.setEditorTimeout(a,function(){t.focus()})}})}function ti(){a.on("click",function(n){var t=n.target;/^(IMG|HR)$/.test(t.nodeName)&&"false"!==v.getContentEditableParent(t)&&(n.preventDefault(),y.getSel().setBaseAndExtent(t,0,t,1),a.nodeChanged());"A"==t.nodeName&&v.hasClass(t,"mce-item-anchor")&&(n.preventDefault(),y.select(t))})}function ii(){function n(){var n=v.getAttribs(y.getStart().cloneNode(!1));return function(){var t=y.getStart();t!==a.getBody()&&(v.setAttrib(t,"style",null),tt(n,function(n){t.setAttributeNode(n.cloneNode(!0))}))}}function t(){return!y.isCollapsed()&&v.getParent(y.getStart(),v.isBlock)!=v.getParent(y.getEnd(),v.isBlock)}a.on("keypress",function(i){var r;if(!p(i)&&(8==i.keyCode||46==i.keyCode)&&t())return(r=n(),a.getDoc().execCommand("delete",!1,null),r(),i.preventDefault(),!1)});v.bind(a.getDoc(),"cut",function(i){var r;!p(i)&&t()&&(r=n(),s.setEditorTimeout(a,function(){r()}))})}function ri(){document.body.setAttribute("role","application")}function nt(){a.on("keydown",function(n){if(!p(n)&&n.keyCode===k&&y.isCollapsed()&&0===y.getRng(!0).startOffset){var t=y.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return n.preventDefault(),!1}})}function ui(){g()>7||(b("RespectVisibilityInDesign",!0),a.contentStyles.push(".mceHideBrInPre pre br {display: none}"),v.addClass(a.getBody(),"mceHideBrInPre"),rt.addNodeFilter("pre",function(n){for(var e=n.length,r,f,i,t;e--;)for(r=n[e].getAll("br"),f=r.length;f--;)i=r[f],t=i.prev,t&&3===t.type&&"\n"!=t.value.charAt(t.value-1)?t.value+="\n":i.parent.insert(new u("#text",3),i,!0).value="\n"}),yt.addNodeFilter("pre",function(n){for(var u=n.length,i,r,f,t;u--;)for(i=n[u].getAll("br"),r=i.length;r--;)f=i[r],t=f.prev,t&&3==t.type&&(t.value=t.value.replace(/\r?\n$/,""))}))}function fi(){v.bind(a.getBody(),"mouseup",function(){var t,n=y.getNode();"IMG"==n.nodeName&&((t=v.getStyle(n,"width"))&&(v.setAttrib(n,"width",t.replace(/[^0-9%]+/g,"")),v.setStyle(n,"width","")),(t=v.getStyle(n,"height"))&&(v.setAttrib(n,"height",t.replace(/[^0-9%]+/g,"")),v.setStyle(n,"height","")))})}function ei(){a.on("keydown",function(t){var r,u,f,e,i;if(!p(t)&&t.keyCode==n.BACKSPACE&&(r=y.getRng(),u=r.startContainer,f=r.startOffset,e=v.getRoot(),i=u,r.collapsed&&0===f)){for(;i&&i.parentNode&&i.parentNode.firstChild==i&&i.parentNode!=e;)i=i.parentNode;"BLOCKQUOTE"===i.tagName&&(a.formatter.toggle("blockquote",null,i),r=v.createRng(),r.setStart(u,0),r.setEnd(u,0),y.setRng(r))}})}function oi(){function n(){lt();b("StyleWithCSS",!1);b("enableInlineTableEditing",!1);d.object_resizing||b("enableObjectResizing",!1)}d.readonly||a.on("BeforeExecCommand MouseDown",n)}function si(){function n(){tt(v.select("a"),function(n){var t=n.parentNode,i=v.getRoot();if(t.lastChild===n){for(;t&&!v.isBlock(t);){if(t.parentNode.lastChild!==t||t===i)return;t=t.parentNode}v.add(t,"br",{"data-mce-bogus":1})}})}a.on("SetContent ExecCommand",function(t){"setcontent"!=t.type&&"mceInsertLink"!==t.command||n()})}function hi(){d.forced_root_block&&a.on("init",function(){b("DefaultParagraphSeparator",d.forced_root_block)})}function ci(){a.on("keydown",function(n){var t;p(n)||n.keyCode!=k||(t=a.getDoc().selection.createRange(),t&&t.item&&(n.preventDefault(),a.undoManager.beforeChange(),v.remove(t.item(0)),a.undoManager.add()))})}function li(){var n;g()>=10&&(n="",tt("p div h1 h2 h3 h4 h5 h6".split(" "),function(t,i){n+=(i>0?",":"")+t+":empty"}),a.contentStyles.push(n+"{padding-right: 1px !important}"))}function ai(){g()<9&&(rt.addNodeFilter("noscript",function(n){for(var r=n.length,t,i;r--;)t=n[r],i=t.firstChild,i&&t.attr("data-mce-innertext",i.value)}),yt.addNodeFilter("noscript",function(n){for(var r=n.length,i,t,e;r--;)i=n[r],t=n[r].firstChild,t?t.value=f.decode(t.value):(e=i.attributes.map["data-mce-innertext"],e&&(i.attr("data-mce-innertext",null),t=new u("#text",3),t.value=e,t.raw=!0,i.append(t)))}))}function vi(){function f(n,t){var i=o.createTextRange();try{i.moveToPoint(n,t)}catch(r){i=null}return i}function e(n){var r;n.button?(r=f(n.x,n.y),r&&(r.compareEndPoints("StartToStart",t)>0?r.setEndPoint("StartToStart",t):r.setEndPoint("EndToEnd",t),r.select())):i()}function i(){var u=n.selection.createRange();t&&!u.item&&0===u.compareEndPoints("StartToEnd",u)&&t.select();v.unbind(n,"mouseup",i);v.unbind(n,"mousemove",e);t=r=0}var n=v.doc,o=n.body,r,t,u;n.documentElement.unselectable=!0;v.bind(n,"mousedown contextmenu",function(o){if("HTML"===o.target.nodeName){if(r&&i(),u=n.documentElement,u.scrollHeight>u.clientHeight)return;r=1;t=f(o.x,o.y);t&&(v.bind(n,"mouseup",i),v.bind(n,"mousemove",e),v.getRoot().focus(),t.select())}})}function yi(){a.on("keyup focusin mouseup",function(t){65==t.keyCode&&n.metaKeyPressed(t)||y.normalize()},!0)}function pi(){a.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function wi(){a.inline||a.on("keydown",function(){document.activeElement==document.body&&a.getWin().focus()})}function ct(){a.inline||(a.contentStyles.push("body {min-height: 150px}"),a.on("click",function(n){var t;if("HTML"==n.target.nodeName){if(e.ie>11)return void a.getBody().focus();t=a.selection.getRng();a.getBody().focus();a.selection.setRng(t);a.selection.normalize();a.nodeChanged()}}))}function bi(){e.mac&&a.on("keydown",function(t){!n.metaKeyPressed(t)||t.shiftKey||37!=t.keyCode&&39!=t.keyCode||(t.preventDefault(),a.selection.getSel().modify("move",37==t.keyCode?"backward":"forward","lineboundary"))})}function ki(){b("AutoUrlDetect",!1)}function di(){a.on("click",function(n){var t=n.target;do if("A"===t.tagName)return void n.preventDefault();while(t=t.parentNode)});a.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function gi(){a.on("init",function(){a.dom.bind(a.getBody(),"submit",function(n){n.preventDefault()})})}function nr(){rt.addNodeFilter("br",function(n){for(var t=n.length;t--;)"Apple-interchange-newline"==n[t].attr("class")&&n[t].remove()})}function tr(){a.on("dragstart",function(n){ft(n)});a.on("drop",function(n){var i,r;p(n)||(i=et(n),i&&i.id!=a.id&&(n.preventDefault(),r=t.getCaretRangeFromPoint(n.x,n.y,a.getDoc()),y.setRng(r),ot(i.html)))})}function lt(){var n,t;at()&&(n=a.getBody(),t=n.parentNode,t.removeChild(n),t.appendChild(n),n.focus())}function at(){var n;return pt?(n=a.selection.getSel(),!n||!n.rangeCount||0===n.rangeCount):0}function vt(){function t(n){var t=new l(n.getBody()),i=n.selection.getRng(),r=c.fromRangeStart(i),u=c.fromRangeEnd(i);return!n.selection.isCollapsed()&&!t.prev(r)&&!t.next(u)}a.on("keypress",function(i){!p(i)&&!y.isCollapsed()&&i.charCode>31&&!n.metaKeyPressed(i)&&t(a)&&(i.preventDefault(),a.setContent(String.fromCharCode(i.charCode)),a.selection.select(a.getBody(),!0),a.selection.collapse(!1),a.nodeChanged())});a.on("keydown",function(n){var i=n.keyCode;p(n)||i!=it&&i!=k||t(a)&&(n.preventDefault(),a.setContent(""),a.nodeChanged())})}var tt=o.each,w=a.$,k=n.BACKSPACE,it=n.DELETE,v=a.dom,y=a.selection,d=a.settings,rt=a.parser,yt=a.serializer,pt=e.gecko,wt=e.ie,ir=e.webkit,ut="data:text/mce-internal,",bt=wt?"Text":"URL";return ei(),dt(),e.windowsPhone||yi(),ir&&(vt(),kt(),gt(),ti(),hi(),gi(),nt(),nr(),e.iOS?(wi(),ct(),di()):st()),wt&&e.ie<11&&(ht(),ri(),ui(),fi(),ci(),li(),ai(),vi()),e.ie>=11&&(ct(),nt()),e.ie&&(st(),ki(),tr()),pt&&(vt(),ht(),ni(),ii(),oi(),si(),pi(),bi(),nt()),{refreshContentEditable:lt,isHidden:at}}});i(yr,[ct,h,r],function(n,t,i){function u(n,t){return"selectionchange"==t?n.getDoc():!n.inline&&/^mouse|click|contextmenu|drop|dragover|dragend/.test(t)?n.getDoc().documentElement:n.settings.event_root?(n.eventRoot||(n.eventRoot=f.select(n.settings.event_root)[0]),n.eventRoot):n.getBody()}function e(n,t){function e(n){return!n.hidden&&!n.readonly}var o=u(n,t),i;if(n.delegates||(n.delegates={}),!n.delegates[t])if(n.settings.event_root){if(r||(r={},n.editorManager.on("removeEditor",function(){var t;if(!n.editorManager.activeEditor&&r){for(t in r)n.dom.unbind(u(n,t));r=null}})),r[t])return;i=function(i){for(var o,s=i.target,r=n.editorManager.editors,u=r.length;u--;)o=r[u].getBody(),(o===s||f.isChildOf(s,o))&&e(r[u])&&r[u].fire(t,i)};r[t]=i;f.bind(o,t,i)}else i=function(i){e(n)&&n.fire(t,i)},f.bind(o,t,i),n.delegates[t]=i}var f=t.DOM,r,o={bindPendingEventDelegates:function(){var n=this;i.each(n._pendingNativeEvents,function(t){e(n,t)})},toggleNativeEvent:function(n,t){var i=this;"focus"!=n&&"blur"!=n&&(t?i.initialized?e(i,n):i._pendingNativeEvents?i._pendingNativeEvents.push(n):i._pendingNativeEvents=[n]:i.initialized&&(i.dom.unbind(u(i,n),n,i.delegates[n]),delete i.delegates[n]))},unbindAllNativeEvents:function(){var n=this,t;if(n.delegates){for(t in n.delegates)n.dom.unbind(u(n,t),t,n.delegates[t]);delete n.delegates}n.inline||(n.getBody().onload=null,n.dom.unbind(n.getWin()),n.dom.unbind(n.getDoc()));n.dom.unbind(n.getBody());n.dom.unbind(n.getContainer())}};return i.extend({},n,o)});i(cf,[],function(){function n(n,t,i){try{n.getDoc().execCommand(t,!1,i)}catch(r){}}function i(n){var t,i;return t=n.getBody(),i=function(t){n.dom.getParents(t.target,"a").length>0&&t.preventDefault()},n.dom.bind(t,"click",i),{unbind:function(){n.dom.unbind(t,"click",i)}}}function t(t,r){t._clickBlocker&&(t._clickBlocker.unbind(),t._clickBlocker=null);r?(t._clickBlocker=i(t),t.selection.controlSelection.hideResizeRect(),t.readonly=!0,t.getBody().contentEditable=!1):(t.readonly=!1,t.getBody().contentEditable=!0,n(t,"StyleWithCSS",!1),n(t,"enableInlineTableEditing",!1),n(t,"enableObjectResizing",!1),t.focus(),t.nodeChanged())}function r(n,i){var r=n.readonly?"readonly":"design";i!=r&&(n.initialized?t(n,"readonly"==i):n.on("init",function(){t(n,"readonly"==i)}),n.fire("SwitchMode",{mode:i}))}return{setMode:r}});i(pr,[r,u],function(n,t){var i=n.each,r=n.explode,f={f9:120,f10:121,f11:122},u=n.makeMap("alt,ctrl,shift,meta,access");return function(e){function v(n){var s,o,e={};i(r(n,"+"),function(n){n in u?e[n]=!0:/^[0-9]{2,}$/.test(n)?e.keyCode=parseInt(n,10):(e.charCode=n.charCodeAt(0),e.keyCode=f[n]||n.toUpperCase().charCodeAt(0))});s=[e.keyCode];for(o in u)e[o]?s.push(o):e[o]=!1;return e.id=s.join(","),e.access&&(e.alt=!0,t.mac?e.ctrl=!0:e.shift=!0),e.meta&&(t.mac?e.meta=!0:(e.ctrl=!0,e.meta=!1)),e}function h(t,i,u,f){var o;return o=n.map(r(t,">"),v),o[o.length-1]=n.extend(o[o.length-1],{func:u,scope:f||e}),n.extend(o[0],{desc:e.translate(i),subpatterns:o.slice(1)})}function y(n){return n.altKey||n.ctrlKey||n.metaKey}function p(n){return n.keyCode>=112&&n.keyCode<=123}function c(n,t){return t?t.ctrl!=n.ctrlKey||t.meta!=n.metaKey?!1:t.alt!=n.altKey||t.shift!=n.shiftKey?!1:n.keyCode==t.keyCode||n.charCode&&n.charCode==t.charCode?(n.preventDefault(),!0):!1:!1}function l(n){return n.func?n.func.call(n.scope):null}var a=this,s={},o=[];e.on("keyup keypress keydown",function(n){(y(n)||p(n))&&!n.isDefaultPrevented()&&(i(s,function(t){if(c(n,t))return(o=t.subpatterns.slice(0),"keydown"==n.type&&l(t),!0)}),c(n,o[0])&&(1===o.length&&"keydown"==n.type&&l(o[0]),o.shift()))});a.add=function(t,u,f,o){var c;return c=f,"string"==typeof f?f=function(){e.execCommand(c,!1,null)}:n.isArray(c)&&(f=function(){e.execCommand(c[0],c[1],c[2])}),i(r(n.trim(t.toLowerCase())),function(n){var t=h(n,u,f,o);s[t.id]=t}),!0};a.remove=function(n){var t=h(n);return s[t.id]?(delete s[t.id],!0):!1}}});i(lf,[k,r,a],function(n,t,i){return function(r,u){function o(n){var t,i;return i={"image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/png":"png"},t=i[n.blob().type.toLowerCase()]||"dat",n.id()+"."+t}function l(n,t){return n?n.replace(/\/$/,"")+"/"+t.replace(/^\//,""):t}function a(n){return{id:n.id,blob:n.blob,base64:n.base64,filename:i.constant(o(n))}}function s(n,t,i,r){var f,e;f=new XMLHttpRequest;f.open("POST",u.url);f.withCredentials=u.credentials;f.upload.onprogress=function(n){r(n.loaded/n.total*100)};f.onerror=function(){i("Image upload failed due to a XHR Transport error. Code: "+f.status)};f.onload=function(){var n;return 200!=f.status?void i("HTTP Error: "+f.status):(n=JSON.parse(f.responseText),n&&"string"==typeof n.location?void t(l(u.basePath,n.location)):void i("Invalid JSON: "+f.responseText))};e=new FormData;e.append("file",n.blob(),o(n));f.send(e)}function v(){return new n(function(n){n([])})}function h(n,t){return{url:t,blobInfo:n,status:!0}}function e(n,t){return{url:"",blobInfo:n,status:!1,error:t}}function c(n,i){t.each(f[n],function(n){n(i)});delete f[n]}function y(t,i,u){return r.markPending(t.blobUri()),new n(function(n){var f,o,v=function(){};try{var l=function(){f&&(f.close(),o=v)},y=function(i){l();r.markUploaded(t.blobUri(),i);c(t.blobUri(),h(t,i));n(h(t,i))},s=function(){l();r.removeFailed(t.blobUri());c(t.blobUri(),e(t,s));n(e(t,s))};o=function(n){0>n||n>100||(f||(f=u()),f.progressBar.value(n))};i(a(t),y,s,o)}catch(p){n(e(t,p.message))}})}function p(n){return n===s}function w(t){var i=t.blobUri();return new n(function(n){f[i]=f[i]||[];f[i].push(n)})}function b(i,f){return i=t.grep(i,function(n){return!r.isUploaded(n.blobUri())}),n.all(t.map(i,function(n){return r.isPending(n.blobUri())?w(n):y(n,u.handler,f)}))}function k(n,t){return!u.url&&p(u.handler)?v():b(n,t)}var f={};return u=t.extend({credentials:!1,handler:s},u),{upload:k}}});i(af,[k],function(n){function i(t){return new n(function(n){var i=new XMLHttpRequest;i.open("GET",t,!0);i.responseType="blob";i.onload=function(){200==this.status&&n(this.response)};i.send()})}function t(n){var i,t;return n=decodeURIComponent(n).split(","),t=/data:([^;]+)/.exec(n[0]),t&&(i=t[1]),{type:i,data:n[1]}}function r(i){return new n(function(n){var f,u,r;i=t(i);try{f=atob(i.data)}catch(e){return void n(new Blob([]))}for(u=new Uint8Array(f.length),r=0;r<u.length;r++)u[r]=f.charCodeAt(r);n(new Blob([u],{type:i.type}))})}function u(n){return 0===n.indexOf("blob:")?i(n):0===n.indexOf("data:")?r(n):null}function f(t){return new n(function(n){var i=new FileReader;i.onloadend=function(){n(i.result)};i.readAsDataURL(t)})}return{uriToBlob:u,blobToDataUri:f,parseDataUri:t}});i(vf,[k,c,a,af,u],function(n,t,i,r,u){var f=0;return function(e,o){function h(h,c){function v(n,t){var u,i;return 0===n.src.indexOf("blob:")?(i=o.getByUri(n.src),void(i&&t({image:n,blobInfo:i}))):(u=r.parseDataUri(n.src).data,i=o.findFirst(function(n){return n.base64()===u}),void(i?t({image:n,blobInfo:i}):r.uriToBlob(n.src).then(function(i){var e="blobid"+f++,r=o.create(e,i,u);o.add(r);t({image:n,blobInfo:r})})))}var l,a;return c||(c=i.constant(!0)),l=t.filter(h.getElementsByTagName("img"),function(n){var t=n.src;return u.fileApi?n.hasAttribute("data-mce-bogus")?!1:n.hasAttribute("data-mce-placeholder")?!1:t&&t!=u.transparentSrc?0===t.indexOf("blob:")?!e.isUploaded(t):0===t.indexOf("data:")?c(n):!1:!1:!1}),a=t.map(l,function(t){var i;return s[t.src]?new n(function(n){s[t.src].then(function(i){n({image:t,blobInfo:i.blobInfo})})}):(i=new n(function(n){v(t,n)}).then(function(n){return delete s[n.image.src],n})["catch"](function(n){return delete s[t.src],n}),s[t.src]=i,i)}),n.all(a)}var s={};return{findAll:h}}});i(yf,[c,a],function(n,t){return function(){function e(n,t,i){return{id:r(n),blob:r(t),base64:r(i),blobUri:r(URL.createObjectURL(t))}}function o(n){f(n.id())||i.push(n)}function f(n){return u(function(t){return t.id()===n})}function u(t){return n.filter(i,t)[0]}function s(n){return u(function(t){return t.blobUri()==n})}function h(t){i=n.filter(i,function(n){return n.blobUri()===t?(URL.revokeObjectURL(n.blobUri()),!1):!0})}function c(){n.each(i,function(n){URL.revokeObjectURL(n.blobUri())});i=[]}var i=[],r=t.constant;return{create:e,add:o,get:f,getByUri:s,findFirst:u,removeByUri:h,destroy:c}}});i(pf,[],function(){return function(){function i(n,t){return{status:n,resultUri:t}}function t(t){return t in n}function f(t){var i=n[t];return i?i.resultUri:null}function e(i){return t(i)?n[i].status===r:!1}function o(i){return t(i)?n[i].status===u:!1}function s(t){n[t]=i(r,null)}function h(t,r){n[t]=i(u,r)}function c(t){delete n[t]}function l(){n={}}var r=1,u=2,n={};return{hasBlobUri:t,getResultUri:f,isPending:e,isUploaded:o,markPending:s,markUploaded:h,removeFailed:c,destroy:l}}});i(wf,[c,lf,vf,yf,pf],function(n,t,i,r,u){return function(f){function l(n){return function(t){return f.selection?n(t):[]}}function v(n,t,i){var r=0;do r=n.indexOf(t,r),-1!==r&&(n=n.substring(0,r)+i+n.substr(r+t.length),r+=i.length-t.length+1);while(-1!==r);return n}function k(n,t,i){return n=v(n,'src="'+t+'"','src="'+i+'"'),n=v(n,'data-mce-src="'+t+'"','data-mce-src="'+i+'"')}function y(t,i){n.each(f.undoManager.data,function(n){n.content=k(n.content,t,i)})}function d(){return f.notificationManager.open({text:f.translate("Image uploading..."),type:"info",timeout:-1,progressBar:!0})}function g(n,t){o.removeByUri(n.src);y(n.src,t);f.$(n).attr({src:t,"data-mce-src":f.convertURL(t,"src")})}function p(i){return h||(h=new t(s,{url:e.images_upload_url,basePath:e.images_upload_base_path,credentials:e.images_upload_credentials,handler:e.images_upload_handler})),a().then(l(function(t){var r;return r=n.map(t,function(n){return n.blobInfo}),h.upload(r,d).then(l(function(r){return r=n.map(r,function(n,i){var r=t[i].image;return n.status&&f.settings.images_replace_blob_uris!==!1&&g(r,n.url),{element:r,status:n.status}}),i&&i(r),r}))}))}function w(n){if(e.automatic_uploads!==!1)return p(n)}function nt(n){return e.images_dataimg_filter?e.images_dataimg_filter(n):!0}function a(){return c||(c=new i(s,o)),c.findAll(f.getBody(),nt).then(l(function(t){return n.each(t,function(n){y(n.image.src,n.blobInfo.blobUri());n.image.src=n.blobInfo.blobUri();n.image.removeAttribute("data-mce-src")}),t}))}function tt(){o.destroy();s.destroy();c=h=null}function b(t){return t.replace(/src="(blob:[^"]+)"/g,function(t,i){var u=s.getResultUri(i),r;return u?'src="'+u+'"':(r=o.getByUri(i),r||(r=n.reduce(f.editorManager.editors,function(n,t){return n||t.editorUpload.blobCache.getByUri(i)},null)),r?'src="data:'+r.blob().type+";base64,"+r.base64()+'"':t)})}var o=new r,h,c,e=f.settings,s=new u;return f.on("setContent",function(){f.settings.automatic_uploads!==!1?w():a()}),f.on("RawSaveContent",function(n){n.content=b(n.content)}),f.on("getContent",function(n){n.source_view||"raw"==n.format||(n.content=b(n.content))}),f.on("PostRender",function(){f.parser.addNodeFilter("img",function(t){n.each(t,function(n){var i=n.attr("src"),t;o.getByUri(i)||(t=s.getResultUri(i),t&&n.attr("src",t))})})}),{blobCache:o,uploadImages:p,uploadImagesAuto:w,scanForImages:a,destroy:tt}}});i(bf,[w,v,e,y,s,nt,f],function(n,t,i,r,u,f,e){var o=i.isContentEditableFalse;return function(t,i){function l(n,i){var r=f.collapse(n.getBoundingClientRect(),i),s,e,o,u,h;return"BODY"==t.tagName?(s=t.ownerDocument.documentElement,e=t.scrollLeft||s.scrollLeft,o=t.scrollTop||s.scrollTop):(h=t.getBoundingClientRect(),e=t.scrollLeft-h.left,o=t.scrollTop-h.top),r.left+=e,r.right+=e,r.top+=o,r.bottom+=o,r.width=1,u=n.offsetWidth-n.clientWidth,u>0&&(i&&(u*=-1),r.left+=u,r.right+=u),r}function a(){for(var o,i,r,e=u("*[contentEditable=false]",t),f=0;f<e.length;f++)o=e[f],i=o.previousSibling,n.endsWithCaretContainer(i)&&(r=i.data,1==r.length?i.parentNode.removeChild(i):i.deleteData(r.length-1,1)),i=o.nextSibling,n.startsWithCaretContainer(i)&&(r=i.data,1==r.length?i.parentNode.removeChild(i):i.deleteData(0,1));return null}function v(f,e){var a,h,v;return c(),i(e)?(r=n.insertBlock("p",e,f),a=l(e,f),u(r).css("top",a.top),s=u('<div class="mce-visual-caret" data-mce-bogus="all"><\/div>').css(a).appendTo(t),f&&s.addClass("mce-visual-caret-before"),y(),h=e.ownerDocument.createRange(),v=r.firstChild,h.setStart(v,0),h.setEnd(v,1),h):(r=n.insertInline(e,f),h=e.ownerDocument.createRange(),o(r.nextSibling)?(h.setStart(r,0),h.setEnd(r,0)):(h.setStart(r,1),h.setEnd(r,1)),h)}function c(){a();r&&(n.remove(r),r=null);s&&(s.remove(),s=null);clearInterval(h)}function y(){h=e.setInterval(function(){u("div.mce-visual-caret",t).toggleClass("mce-visual-caret-hidden")},500)}function p(){e.clearInterval(h)}function w(){return".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}"}var h,s,r;return{show:v,hide:c,getCss:w,destroy:p}}});i(wr,[c,e,nt],function(n,t,i){function r(u){function e(t){return n.map(t,function(n){return n=i.clone(n),n.node=u,n})}if(n.isArray(u))return n.reduce(u,function(n,t){return n.concat(r(t))},[]);if(t.isElement(u))return e(u.getClientRects());if(t.isText(u)){var f=u.ownerDocument.createRange();return f.setStart(u,0),f.setEnd(u,u.data.length),e(f.getClientRects())}}return{getClientRects:r}});i(kf,[a,c,wr,st,wt,ht,v,nt],function(n,t,i,r,u,f,e,o){function c(n,t,i,f){for(;f=u.findNode(f,n,r.isEditableCaretCandidate,t);)if(i(f))return}function h(n,r,u,f,e,o){function l(f){var c,o,h;for(h=i.getClientRects(f),-1==n&&(h=h.reverse()),c=0;c<h.length;c++)if(o=h[c],!u(o,v)){if(s.length>0&&r(o,t.last(s))&&a++,o.line=a,e(o))return!0;s.push(o)}}var a=0,h,s=[],v;return(v=t.last(o.getClientRects()))?(h=o.getNode(),l(h),c(n,f,l,h),s):s}function l(n,t){return t.line>n}function a(n,t){return t.line===n}function v(n,i,r,u){function y(i){return 1==n?t.last(i.getClientRects()):t.last(i.getClientRects())}var p=new f(i),l,a,v,h,c=[],w=0,s,b;1==n?(l=p.next,a=o.isBelow,v=o.isAbove,h=e.after(u)):(l=p.prev,a=o.isAbove,v=o.isBelow,h=e.before(u));b=y(h);do if(h.isVisible()&&(s=y(h),!v(s,b))){if(c.length>0&&a(s,t.last(c))&&w++,s=o.clone(s),s.position=h,s.line=w,r(s))return c;c.push(s)}while(h=l(h));return c}var s=n.curry,y=s(h,-1,o.isAbove,o.isBelow),p=s(h,1,o.isBelow,o.isAbove);return{upUntil:y,downUntil:p,positionsUntil:v,isAboveLine:s(l),isLine:s(a)}});i(df,[a,c,e,wr,nt,wt,st],function(n,t,i,r,u,f,e){function o(n,t){return Math.abs(n.left-t)}function s(n,t){return Math.abs(n.right-t)}function h(n,i){function r(n,t){return n>=t.left&&n<=t.right}return t.reduce(n,function(n,t){var u,f;return u=Math.min(o(n,i),s(n,i)),f=Math.min(o(t,i),s(t,i)),r(i,t)?t:r(i,n)?n:f==u&&c(t.node)?t:u>f?t:n})}function l(n,t,i,r){for(;r=b(r,n,e.isEditableCaretCandidate,t);)if(i(r))return}function a(n,i){function e(n,u){var e;return e=t.filter(r.getClientRects(u),function(t){return!n(t,i)}),f=f.concat(e),0===e.length}var f=[];return f.push(i),l(-1,n,v(e,u.isAbove),i.node),l(1,n,v(e,u.isBelow),i.node),f}function y(n){return t.filter(t.toArray(n.getElementsByTagName("*")),c)}function p(n,t){return{node:n.node,before:o(n,t)<s(n,t)}}function w(n,i,u){var e,f;return e=r.getClientRects(y(n)),e=t.filter(e,function(n){return u>=n.top&&u<=n.bottom}),f=h(e,i),f&&(f=h(a(n,f),i),f&&c(f.node))?p(f,i):null}var c=i.isContentEditableFalse,b=f.findNode,v=n.curry;return{findClosestClientRect:h,findLineNodeRects:a,closestCaret:w}});i(gf,[e,c,a],function(n,t,i){function u(n){function y(n){return r(n)}function l(t){e(n.getBody()).css("cursor",t)}function p(t){return t==u.element||n.dom.isChildOf(t,u.element)?!1:!r(t)}function h(t){var f,o,h,c,v=0,y=0,p,i,r,a;0===t.button&&(f=t.screenX-u.screenX,o=t.screenY-u.screenY,p=Math.max(Math.abs(f),Math.abs(o)),!u.dragging&&p>10&&(u.dragging=!0,l("default"),u.clone=u.element.cloneNode(!0),h=s.getPos(u.element),u.relX=u.clientX-h.x,u.relY=u.clientY-h.y,u.width=u.element.offsetWidth,u.height=u.element.offsetHeight,e(u.clone).css({width:u.width,height:u.height}).removeAttr("data-mce-selected"),u.ghost=e("<div>").css({position:"absolute",opacity:.5,overflow:"hidden",width:u.width,height:u.height}).attr({"data-mce-bogus":"all",unselectable:"on",contenteditable:"false"}).addClass("mce-drag-container mce-reset").append(u.clone).appendTo(n.getBody())[0],c=n.dom.getViewPort(n.getWin()),u.maxX=c.w,u.maxY=c.h),u.dragging&&(n._selectionOverrides.hideFakeCaret(),n.selection.placeCaretAt(t.clientX,t.clientY),i=u.clientX+f-u.relX,r=u.clientY+o+5,i+u.width>u.maxX&&(v=i+u.width-u.maxX),r+u.height>u.maxY&&(y=r+u.height-u.maxY),a="BODY"!=n.getBody().nodeName?n.getBody().getBoundingClientRect():{left:0,top:0},e(u.ghost).css({left:i-a.left,top:r-a.top,width:u.width-v,height:u.height-y})))}function a(t){var r,i;if(u.dragging&&(n.selection.setRng(n.selection.getSel().getRangeAt(0)),p(n.selection.getNode()))){if(i=u.element,r=n.fire("drop",{targetClone:i,clientX:t.clientX,clientY:t.clientY}),r.isDefaultPrevented())return;i=r.targetClone;n.undoManager.transact(function(){n.insertContent(s.getOuterHTML(i));e(u.element).remove()})}c()}function w(e){var l,p;if(c(),0===e.button&&(l=t.find(n.dom.getParents(e.target),i.or(r,f)),y(l))){if(p=n.fire("dragstart",{target:l}),p.isDefaultPrevented())return;n.on("mousemove",h);n.on("mouseup",a);o!=v&&(s.bind(o,"mousemove",h),s.bind(o,"mouseup",a));u={screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY,element:l}}}function c(){e(u.ghost).remove();l(null);n.off("mousemove",h);n.off("mouseup",c);o!=v&&(s.unbind(o,"mousemove",h),s.unbind(o,"mouseup",c));u={}}var e=n.$,o=document,v=n.getDoc(),s=n.dom,u={};n.on("mousedown",w);n.on("drop",function(t){var i="undefined"!=typeof t.clientX?n.getDoc().elementFromPoint(t.clientX,t.clientY):null;(r(i)||r(n.dom.getContentEditableParent(i)))&&t.preventDefault()})}var r=n.isContentEditableFalse,f=n.isContentEditableTrue;return{init:u}});i(ne,[u,ht,v,w,wt,bf,kf,df,e,y,nt,ot,a,c,f,gf,ii],function(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w){function it(n,t){for(;t=n(t);)if(t.isVisible())return t;return t}function rt(h){function vt(n){return h.dom.isBlock(n)}function lt(n){n&&h.selection.setRng(n)}function pt(){return h.selection.getRng()}function gt(n,t){h.selection.scrollIntoView(n,t)}function rt(n,t,i){var r;return r=h.fire("ShowCaret",{target:t,direction:n,before:i}),r.isDefaultPrevented()?null:(gt(t,-1===n),st.show(i,t))}function ni(n){var t;return st.hide(),t=h.fire("BeforeObjectSelected",{target:n}),t.isDefaultPrevented()?null:hi(n)}function hi(n){var t=n.ownerDocument.createRange();return t.selectNode(n),t}function ci(n,t){var i=u.isInSameBlock(n,t);return!i&&s.isBr(n.getNode())?!0:i}function yt(n,t){return t=u.normalizeRange(n,ht,t),-1==n?i.fromRangeStart(t):i.fromRangeEnd(t)}function li(n){return r.isCaretContainerBlock(n.startContainer)}function ai(n,t,i,r){var e,u,f,o;return!r.collapsed&&(e=tt(r),b(e))?rt(n,e,-1==n):(o=li(r),u=yt(n,r),i(u)?ni(u.getNode(-1==n)):(u=t(u))?i(u)?rt(n,u.getNode(-1==n),1==n):(f=t(u),i(f)&&ci(u,f)?rt(n,f.getNode(-1==n),1==n):o?et(u.toRange()):null):o?r:null)}function vi(n,t,i){var u,l,a,r,h,f,y,p,s,c;return(s=tt(i),u=yt(n,i),l=t(ht,e.isAboveLine(1),u),a=v.filter(l,e.isLine(1)),h=v.last(u.getClientRects()),g(u)&&(s=u.getNode()),d(u)&&(s=u.getNode(!0)),!h)?null:(f=h.left,r=o.findClosestClientRect(a,f),r&&b(r.node))?(y=Math.abs(f-r.left),p=Math.abs(f-r.right),rt(n,r.node,p>y)):s&&((c=e.positionsUntil(n,ht,e.isAboveLine(1),s),r=o.findClosestClientRect(v.filter(c,e.isLine(1)),f))||(r=v.last(v.filter(c,e.isLine(0)))))?et(r.position.toRange()):void 0}function ti(t,r){function o(){var t=h.dom.create(h.settings.forced_root_block);return(!n.ie||n.ie>=11)&&(t.innerHTML='<br data-mce-bogus="1">'),t}var u,e,f;if(r.collapsed&&h.settings.forced_root_block){if(u=h.dom.getParent(r.startContainer,"PRE"),!u)return;e=1==t?bt(i.fromRangeStart(r)):kt(i.fromRangeStart(r));e||(f=o(),1==t?h.$(u).after(f):h.$(u).before(f),h.selection.select(f,!0),h.selection.collapse())}}function ii(n,t,i,r){var u;return(u=ai(n,t,i,r))?u:(u=ti(n,r),u?u:null)}function ri(n,t,i){var r;return(r=vi(n,t,i))?r:(r=ti(n,i),r?r:null)}function yi(){return si("*[data-mce-caret]")[0]}function wt(n){n=si(n);n.attr("data-mce-caret")&&(st.hide(),n.removeAttr("data-mce-caret"),n.removeAttr("data-mce-bogus"),n.removeAttr("style"),lt(pt()),gt(n[0]))}function ui(n){var t,r;return n=u.normalizeRange(1,ht,n),t=i.fromRangeStart(n),b(t.getNode())?rt(1,t.getNode(),!t.isAtEnd()):b(t.getNode(!0))?rt(1,t.getNode(!0),!1):(r=h.dom.getParent(t.getNode(),a.or(b,nt)),b(r)?rt(1,r,!1):(st.hide(),null))}function et(n){var t;return n&&n.collapsed?(t=ui(n),t?t:n):n}function at(n){var t,u,f,e;return b(n)?(b(n.previousSibling)&&(f=n.previousSibling),u=kt(i.before(n)),u||(t=bt(i.after(n))),t&&ut(t.getNode())&&(e=t.getNode()),r.remove(n.previousSibling),r.remove(n.nextSibling),h.dom.remove(n),ot(),h.dom.isEmpty(h.getBody())?(h.setContent(""),void h.focus()):f?i.after(f).toRange():e?i.before(e).toRange():u?u.toRange():t?t.toRange():null):null}function fi(n,t,i){var u=h.dom,r,f,o,e;if(-1===n){if(d(i)&&vt(i.getNode(!0)))return at(i.getNode(!0))}else if(g(t)&&vt(t.getNode()))return at(t.getNode());if(e=h.schema.getTextBlockElements(),r=u.getParent(t.getNode(),u.isBlock),f=u.getParent(i.getNode(),u.isBlock),r===f||!e[r.nodeName]||!e[f.nodeName])return null;for(;o=r.firstChild;)f.appendChild(o);return h.dom.remove(r),i.toRange()}function ei(n,t,i,u){var o,f,e,s;return!u.collapsed&&(o=tt(u),b(o))?et(at(o)):(f=yt(n,u),i(f)&&r.isCaretContainerBlock(u.startContainer)?(s=-1==n?ct.prev(f):ct.next(f),s?et(s.toRange()):u):t(f)?et(at(f.getNode(-1==n))):(e=-1==n?ct.prev(f):ct.next(f),t(e)?-1===n?fi(n,f,e):fi(n,e,f):void 0))}function pi(){function n(n,t){var i=t(pt());i&&!n.isDefaultPrevented()&&(n.preventDefault(),lt(i))}function r(n){for(var t=h.getBody();n&&n!=t;){if(nt(n)||b(n))return n;n=n.parentNode}return null}function f(n,t,i){return i.collapsed?!1:v.reduce(i.getClientRects(),function(i,r){return i||c.containsXY(r,n,t)},!1)}function u(){var t,n=r(h.selection.getNode());nt(n)&&vt(n)&&h.dom.isEmpty(n)&&(t=h.dom.create("br",{"data-mce-bogus":"1"}),h.$(n).empty().append(t),h.selection.setRng(i.before(t).toRange()))}function s(n){var t=yi();if(t)return"compositionstart"==n.type?(n.preventDefault(),n.stopPropagation(),void wt(t)):void("&nbsp;"!=t.innerHTML&&wt(t))}function a(n){var t;switch(n.keyCode){case l.DELETE:t=u();break;case l.BACKSPACE:t=u()}t&&n.preventDefault()}var w=k(ii,1,bt,g),tt=k(ii,-1,kt,d),it=k(ei,1,g,d),ut=k(ei,-1,d,g),ct=k(ri,-1,e.upUntil),yt=k(ri,1,e.downUntil);h.on("mouseup",function(){var n=pt();n.collapsed&&lt(ui(n))});h.on("click",function(n){var t;t=r(n.target);t&&b(t)&&n.preventDefault()});var dt=function(n){var f=new t(n),u,r;return n.firstChild?(u=i.before(n.firstChild),r=f.next(u),r&&!g(r)&&!d(r)):!1},gt=function(n,t){var i=h.dom.getParent(n,h.dom.isBlock),r=h.dom.getParent(t,h.dom.isBlock);return i===r},ti=function(n,t){var i=h.dom.getParent(n,h.dom.isBlock),r=h.dom.getParent(t,h.dom.isBlock);return i&&!gt(i,r)&&dt(i)};h.on("mousedown",function(n){var i,t;(i=r(n.target))?b(i)?(n.preventDefault(),oi(ni(i))):(ot(),f(n.clientX,n.clientY,h.selection.getRng())||h.selection.placeCaretAt(n.clientX,n.clientY)):(ot(),st.hide(),t=o.closestCaret(ht,n.clientX,n.clientY),t&&(ti(n.target,t.node)||(n.preventDefault(),h.getBody().focus(),lt(rt(1,t.node,t.before)))))});h.on("keydown",function(t){if(!l.modifierPressed(t))switch(t.keyCode){case l.RIGHT:n(t,w);break;case l.DOWN:n(t,yt);break;case l.LEFT:n(t,tt);break;case l.UP:n(t,ct);break;case l.DELETE:n(t,it);break;case l.BACKSPACE:n(t,ut);break;default:b(h.selection.getNode())&&t.preventDefault()}});h.on("keyup compositionstart",function(n){s(n);a(n)},!0);h.on("cut",function(){var n=h.selection.getNode();b(n)&&y.setEditorTimeout(h,function(){lt(et(at(n)))})});h.on("getSelectionRange",function(n){var t=n.range;if(ft){if(!ft.parentNode)return void(ft=null);t=t.cloneRange();t.selectNode(ft);n.range=t}});h.on("setSelectionRange",function(n){var t;t=oi(n.range);t&&(n.range=t)});h.on("focus",function(){y.setEditorTimeout(h,function(){h.selection.setRng(et(h.selection.getRng()))},0)});p.init(h)}function wi(){var t=h.contentStyles,n=".mce-content-body";t.push(st.getCss());t.push(n+" .mce-offscreen-selection {position: absolute;left: -9999999999px;width: 100px;height: 100px;}"+n+" *[contentEditable=false] {cursor: default;}"+n+" *[contentEditable=true] {cursor: text;}")}function bi(n){return r.isCaretContainer(n.startContainer)||r.isCaretContainer(n.endContainer)}function oi(t){var u,l=h.$,a=h.dom,i,s,r,o,v,c,f,e,y;if(!t)return ot(),null;if(t.collapsed){if(ot(),!bi(t)){if(f=yt(1,t),b(f.getNode()))return rt(1,f.getNode(),!f.isAtEnd());if(b(f.getNode(!0)))return rt(1,f.getNode(!0),!1)}return null}return r=t.startContainer,o=t.startOffset,v=t.endOffset,3==r.nodeType&&0==o&&b(r.parentNode)&&(r=r.parentNode,o=a.nodeIndex(r),r=r.parentNode),1!=r.nodeType?(ot(),null):(v==o+1&&(u=r.childNodes[o]),b(u)?(e=y=u.cloneNode(!0),c=h.fire("ObjectSelected",{target:u,targetClone:e}),c.isDefaultPrevented()?(ot(),null):(e=c.targetClone,i=l("#"+dt),0===i.length&&(i=l('<div data-mce-bogus="all" class="mce-offscreen-selection"><\/div>').attr("id",dt),i.appendTo(h.getBody())),t=h.dom.createRng(),e===y&&n.ie?(i.empty().append(w.ZWSP).append(e).append(w.ZWSP),t.setStart(i[0].firstChild,0),t.setEnd(i[0].lastChild,1)):(i.empty().append(" ").append(e).append(" "),t.setStart(i[0].firstChild,1),t.setEnd(i[0].lastChild,0)),i.css({top:a.getPos(u,h.getBody()).y}),i[0].focus(),s=h.selection.getSel(),s.removeAllRanges(),s.addRange(t),h.$("*[data-mce-selected]").removeAttr("data-mce-selected"),u.setAttribute("data-mce-selected",1),ft=u,t)):(ot(),null))}function ot(){ft&&(ft.removeAttribute("data-mce-selected"),h.$("#"+dt).remove(),ft=null)}function ki(){st.destroy();ft=null}function di(){st.hide()}var ht=h.getBody(),ct=new t(ht),bt=k(it,ct.next),kt=k(it,ct.prev),st=new f(h.getBody(),vt),dt="sel-"+h.dom.uniqueId(),ft,si=h.$;return n.ceFalse&&(pi(),wi()),{showBlockCaretContainer:wt,hideFakeCaret:di,destroy:ki}}var k=a.curry,nt=s.isContentEditableTrue,b=s.isContentEditableFalse,ut=s.isElement,d=u.isAfterContentEditableFalse,g=u.isBeforeContentEditableFalse,tt=h.getSelectedNode;return rt});i(te,[],function(){var n=0,t=function(){var n=function(){return Math.round(4294967295*Math.random()).toString(36)};return"s"+Date.now().toString(36)+n()+n()+n()},i=function(i){return i+n+++t()};return{uuid:i}});i(br,[h,s,ti,wu,et,bi,yt,di,nr,tr,tf,rf,ir,fi,vt,ft,hr,vr,g,ui,hf,u,r,f,yr,cf,pr,wf,ne,te],function(n,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot,st,ht){function bt(n,t,u){var f=this,o,s,e;o=f.documentBaseUrl=u.documentBaseURL;s=u.baseURI;e=u.defaultSettings;t=wt({id:n,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:o,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"<!DOCTYPE html>",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,padd_empty_editor:!0,render_ui:!0,indentation:"30px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",validate:!0,entity_encoding:"named",url_converter:f.convertURL,url_converter_scope:f,ie7_compat:!0},e,t);e&&e.external_plugins&&t.external_plugins&&(t.external_plugins=wt({},e.external_plugins,t.external_plugins));f.settings=t;r.language=t.language||"en";r.languageLoad=t.language_load;r.baseURL=u.baseURL;f.id=t.id=n;f.setDirty(!1);f.plugins={};f.documentBaseURI=new y(t.document_base_url||o,{base_uri:s});f.baseURI=s;f.contentCSS=[];f.contentStyles=[];f.shortcuts=new et(f);f.loadedCSS={};f.editorCommands=new v(f);t.target&&(f.targetElm=t.target);f.suffix=u.suffix;f.editorManager=u;f.inline=t.inline;f.settings.content_editable=f.inline;t.cache_suffix&&(tt.cacheSuffix=t.cache_suffix.replace(/^[\?\&]+/,""));t.override_viewport===!1&&(tt.overrideViewPort=!1);u.fire("SetupEditor",f);f.execCallback("setup",f);f.$=i.overrideDefaults(function(){return{context:f.inline?f.getBody():f.getDoc(),element:f.getBody()}})}var ct=n.DOM,pt=r.ThemeManager,at=r.PluginManager,wt=it.extend,lt=it.each,dt=it.explode,gt=it.inArray,vt=it.trim,kt=it.resolve,ni=w.Event,ti=tt.gecko,yt=tt.ie;return bt.prototype={render:function(){function f(){ct.unbind(window,"ready",f);n.render()}function e(){var r=p.ScriptLoader,i;(t.language&&"en"!=t.language&&!t.language_url&&(t.language_url=n.editorManager.baseURL+"/langs/"+t.language+".js"),t.language_url&&r.add(t.language_url),t.theme&&"function"!=typeof t.theme&&"-"!=t.theme.charAt(0)&&!pt.urls[t.theme])&&(i=t.theme_url,i=i?n.documentBaseURI.toAbsolute(i):"themes/"+t.theme+"/theme"+u+".js",pt.load(t.theme,i));it.isArray(t.plugins)&&(t.plugins=t.plugins.join(" "));lt(t.external_plugins,function(n,i){at.load(i,n);t.plugins+=" "+i});lt(t.plugins.split(/[ ,]/),function(n){if(n=vt(n),n&&!at.urls[n])if("-"==n.charAt(0)){n=n.substr(1,n.length);var t=at.dependencies(n);lt(t,function(n){var t={prefix:"plugins/",resource:n,suffix:"/plugin"+u+".js"};n=at.createUrl(t,n);at.load(n.resource,n)})}else at.load(n,{prefix:"plugins/",resource:n,suffix:"/plugin"+u+".js"})});r.loadQueue(function(){n.removed||n.init()})}var n=this,t=n.settings,r=n.id,u=n.suffix,i;if(!ni.domLoaded)return void ct.bind(window,"ready",f);n.getElement()&&tt.contentEditable&&(t.inline?n.inline=!0:(n.orgVisibility=n.getElement().style.visibility,n.getElement().style.visibility="hidden"),i=n.getElement().form||ct.getParent(r,"form"),i&&(n.formElement=i,t.hidden_input&&!/TEXTAREA|INPUT/i.test(n.getElement().nodeName)&&(ct.insertAfter(ct.create("input",{type:"hidden",name:r}),r),n.hasHiddenInput=!0),n.formEventDelegate=function(t){n.fire(t.type,t)},ct.bind(i,"submit reset",n.formEventDelegate),n.on("reset",function(){n.setContent(n.startContent,{format:"raw"})}),!t.submit_patch||i.submit.nodeType||i.submit.length||i._mceOldSubmit||(i._mceOldSubmit=i.submit,i.submit=function(){return n.editorManager.triggerSave(),n.setDirty(!1),i._mceOldSubmit(i)})),n.windowManager=new b(n),n.notificationManager=new k(n),"xml"==t.encoding&&n.on("GetContent",function(n){n.save&&(n.content=ct.encode(n.content))}),t.add_form_submit_trigger&&n.on("submit",function(){n.initialized&&n.save()}),t.add_unload_trigger&&(n._beforeUnload=function(){!n.initialized||n.destroyed||n.isHidden()||n.save({format:"raw",no_events:!0,set_dirty:!1})},n.editorManager.on("BeforeUnload",n._beforeUnload)),n.editorManager.add(n),e())},init:function(){function w(t){var u=at.get(t),r,i;if(r=at.urls[t]||n.documentBaseUrl.replace(/\/$/,""),t=vt(t),u&&-1===gt(k,t)){if(lt(at.dependencies(t),function(n){w(n)}),n.plugins[t])return;i=new u(n,r,n.$);n.plugins[t]=i;i.init&&(i.init(n,r),k.push(t))}}var n=this,t=n.settings,u=n.getElement(),s,r,h,c,i,b,l,f,e,v,a,k=[],y,p,o;if(this.editorManager.i18n.setCode(t.language),n.rtl=t.rtl_ui||this.editorManager.i18n.rtl,t.aria_label=t.aria_label||ct.getAttrib(u,"aria-label",n.getLang("aria.rich_text_area")),t.theme&&("function"!=typeof t.theme?(t.theme=t.theme.replace(/-/,""),b=pt.get(t.theme),n.theme=new b(n,pt.urls[t.theme]),n.theme.init&&n.theme.init(n,pt.urls[t.theme]||n.documentBaseUrl.replace(/\/$/,""),n.$)):n.theme=t.theme),lt(t.plugins.replace(/\-/g,"").split(/[ ,]/),w),t.render_ui&&n.theme&&(n.orgDisplay=u.style.display,"function"!=typeof t.theme?(s=t.width||u.style.width||u.offsetWidth,r=t.height||u.style.height||u.offsetHeight,h=t.min_height||100,v=/^[0-9\.]+(|px)$/i,v.test(""+s)&&(s=Math.max(parseInt(s,10),100)),v.test(""+r)&&(r=Math.max(parseInt(r,10),h)),i=n.theme.renderUI({targetNode:u,width:s,height:r,deltaWidth:t.delta_width,deltaHeight:t.delta_height}),t.content_editable||(r=(i.iframeHeight||r)+("number"==typeof r?i.deltaHeight||0:""),h>r&&(r=h))):(i=t.theme(n,u),i.editorContainer.nodeType&&(i.editorContainer=i.editorContainer.id=i.editorContainer.id||n.id+"_parent"),i.iframeContainer.nodeType&&(i.iframeContainer=i.iframeContainer.id=i.iframeContainer.id||n.id+"_iframecontainer"),r=i.iframeHeight||u.offsetHeight),n.editorContainer=i.editorContainer),t.content_css&&lt(dt(t.content_css),function(t){n.contentCSS.push(n.documentBaseURI.toAbsolute(t))}),t.content_style&&n.contentStyles.push(t.content_style),t.content_editable)return u=c=i=null,n.initContentBody();if(n.iframeHTML=t.doctype+"<html><head>",t.document_base_url!=n.documentBaseUrl&&(n.iframeHTML+='<base href="'+n.documentBaseURI.getURI()+'" />'),!tt.caretAfter&&t.ie7_compat&&(n.iframeHTML+='<meta http-equiv="X-UA-Compatible" content="IE=7" />'),n.iframeHTML+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />',!/#$/.test(document.location.href))for(a=0;a<n.contentCSS.length;a++)y=n.contentCSS[a],n.iframeHTML+='<link type="text/css" rel="stylesheet" href="'+it._addCacheSuffix(y)+'" />',n.loadedCSS[y]=!0;if(f=t.body_id||"tinymce",-1!=f.indexOf("=")&&(f=n.getParam("body_id","","hash"),f=f[n.id]||f),e=t.body_class||"",-1!=e.indexOf("=")&&(e=n.getParam("body_class","","hash"),e=e[n.id]||""),t.content_security_policy&&(n.iframeHTML+='<meta http-equiv="Content-Security-Policy" content="'+t.content_security_policy+'" />'),n.iframeHTML+='<\/head><body id="'+f+'" class="mce-content-body '+e+'" data-id="'+n.id+'"><br><\/body><\/html>',p='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinymce.get("'+n.id+'");document.write(ed.iframeHTML);document.close();ed.initContentBody(true);})()',document.domain!=location.hostname&&tt.ie&&tt.ie<12&&(l=p),o=ct.create("iframe",{id:n.id+"_ifr",frameBorder:"0",allowTransparency:"true",title:n.editorManager.translate("Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help"),style:{width:"100%",height:r,display:"block"}}),o.onload=function(){o.onload=null;n.fire("load")},ct.setAttrib(o,"src",l||'javascript:""'),n.contentAreaContainer=i.iframeContainer,n.iframeElement=o,c=ct.add(i.iframeContainer,o),yt)try{n.getDoc()}catch(d){c.src=l=p}i.editorContainer&&(ct.get(i.editorContainer).style.display=n.orgDisplay,n.hidden=ct.isHidden(i.editorContainer));n.getElement().style.display="none";ct.setAttrib(n.id,"aria-hidden",!0);l||n.initContentBody();u=c=i=null},initContentBody:function(t){var i=this,r=i.settings,y=i.getElement(),v=i.getDoc(),o,p;r.inline||(i.getElement().style.visibility=i.orgVisibility);t||r.content_editable||(v.open(),v.write(i.iframeHTML),v.close());r.content_editable&&(i.on("remove",function(){var n=this.getBody();ct.removeClass(n,"mce-content-body");ct.removeClass(n,"mce-edit-focus");ct.setAttrib(n,"contentEditable",null)}),ct.addClass(y,"mce-content-body"),i.contentDocument=v=r.content_document||document,i.contentWindow=r.content_window||window,i.bodyElement=y,r.content_document=r.content_window=null,r.root_name=y.nodeName.toLowerCase());o=i.getBody();o.disabled=!0;i.readonly=r.readonly;i.readonly||(i.inline&&"static"==ct.getStyle(o,"position",!0)&&(o.style.position="relative"),o.contentEditable=i.getParam("content_editable_state",!0));o.disabled=!1;i.editorUpload=new ot(i);i.schema=new d(r);i.dom=new n(v,{keep_values:!0,url_converter:i.convertURL,url_converter_scope:i,hex_colors:r.force_hex_style_colors,class_filter:r.class_filter,update_styles:!0,root_element:i.inline?i.getBody():null,collect:r.content_editable,schema:i.schema,onSetAttrib:function(n){i.fire("SetAttrib",n)}});i.parser=new g(r,i.schema);i.parser.addAttributeFilter("src,href,style,tabindex",function(n,t){for(var e=n.length,u,o=i.dom,r,f;e--;)if(u=n[e],r=u.attr(t),f="data-mce-"+t,!u.attributes.map[f]){if(0===r.indexOf("data:")||0===r.indexOf("blob:"))continue;"style"===t?(r=o.serializeStyle(o.parseStyle(r),u.name),r.length||(r=null),u.attr(f,r),u.attr(t,r)):"tabindex"===t?(u.attr(f,r),u.attr(t,null)):u.attr(f,i.convertURL(r,t,u.name))}});i.parser.addNodeFilter("script",function(n){for(var r=n.length,t,i;r--;)t=n[r],i=t.attr("type")||"no/type",0!==i.indexOf("mce-")&&t.attr("type","mce-"+i)});i.parser.addNodeFilter("#cdata",function(n){for(var i=n.length,t;i--;)t=n[i],t.type=8,t.name="#comment",t.value="[CDATA["+t.value+"]]"});i.parser.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(n){for(var r=n.length,t,u=i.schema.getNonEmptyElements();r--;)t=n[r],t.isEmpty(u)&&(t.append(new f("br",1)).shortEnded=!0)});i.serializer=new e(r,i);i.selection=new s(i.dom,i.getWin(),i.serializer,i);i.formatter=new h(i);i.undoManager=new c(i);i.forceBlocks=new a(i);i.enterKey=new l(i);i._nodeChangeDispatcher=new u(i);i._selectionOverrides=new st(i);i.fire("PreInit");r.browser_spellcheck||r.gecko_spellcheck||(v.body.spellcheck=!1,ct.setAttrib(o,"spellcheck","false"));i.quirks=new nt(i);i.fire("PostRender");r.directionality&&(o.dir=r.directionality);r.nowrap&&(o.style.whiteSpace="nowrap");r.protect&&i.on("BeforeSetContent",function(n){lt(r.protect,function(t){n.content=n.content.replace(t,function(n){return"<!--mce:protected "+escape(n)+"-->"})})});i.on("SetContent",function(){i.addVisual(i.getBody())});r.padd_empty_editor&&i.on("PostProcess",function(n){n.content=n.content.replace(/^(<p[^>]*>(&nbsp;|&#160;|\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/,"")});i.load({initial:!0,format:"html"});i.startContent=i.getContent({format:"raw"});i.initialized=!0;i.bindPendingEventDelegates();i.fire("init");i.focus(!0);i.nodeChanged({initial:!0});i.execCallback("init_instance_callback",i);i.on("compositionstart compositionend",function(n){i.composing="compositionstart"===n.type});i.contentStyles.length>0&&(p="",lt(i.contentStyles,function(n){p+=n+"\r\n"}),i.dom.addStyle(p));lt(i.contentCSS,function(n){i.loadedCSS[n]||(i.dom.loadCSS(n),i.loadedCSS[n]=!0)});r.auto_focus&&rt.setEditorTimeout(i,function(){var n;n=r.auto_focus===!0?i:i.editorManager.get(r.auto_focus);n.destroyed||n.focus()},100);y=v=o=null},focus:function(n){function h(n){return t.dom.getParent(n,function(n){return"true"===t.dom.getContentEditable(n)})}var t=this,u=t.selection,e=t.settings.content_editable,i,f,s=t.getDoc(),r=t.getBody(),o;if(!n){if(i=u.getRng(),i.item&&(f=i.item(0)),t.quirks.refreshContentEditable(),o=h(u.getNode()),t.$.contains(r,o))return o.focus(),u.normalize(),void t.editorManager.setActive(t);if(e||(tt.opera||t.getBody().focus(),t.getWin().focus()),ti||e){if(r.setActive)try{r.setActive()}catch(c){r.focus()}else r.focus();e&&u.normalize()}f&&f.ownerDocument==s&&(i=s.body.createControlRange(),i.addElement(f),i.select())}t.editorManager.setActive(t)},execCallback:function(n){var r=this,i=r.settings[n],t;if(i)return r.callbackLookup&&(t=r.callbackLookup[n])&&(i=t.func,t=t.scope),"string"==typeof i&&(t=i.replace(/\.\w+$/,""),t=t?kt(t):0,i=kt(i),r.callbackLookup=r.callbackLookup||{},r.callbackLookup[n]={func:i,scope:t}),i.apply(t||r,Array.prototype.slice.call(arguments,1))},translate:function(n){var t=this.settings.language||"en",i=this.editorManager.i18n;return n?(n=i.data[t+"."+n]||n.replace(/\{\#([^\}]+)\}/g,function(n,r){return i.data[t+"."+r]||"{#"+r+"}"}),this.editorManager.translate(n)):""},getLang:function(n,i){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+n]||(i!==t?i:"{#"+n+"}")},getParam:function(n,t,i){var r=n in this.settings?this.settings[n]:t,u;return"hash"===i?(u={},"string"==typeof r?lt(r.indexOf("=")>0?r.split(/[;,](?![^=;,]*(?:[;,]|$))/):r.split(","),function(n){n=n.split("=");u[vt(n[0])]=n.length>1?vt(n[1]):vt(n)}):u=r,u):r},nodeChanged:function(n){this._nodeChangeDispatcher.nodeChanged(n)},addButton:function(n,t){var i=this;t.cmd&&(t.onclick=function(){i.execCommand(t.cmd)});t.text||t.icon||(t.icon=n);i.buttons=i.buttons||{};t.tooltip=t.tooltip||t.title;i.buttons[n]=t},addMenuItem:function(n,t){var i=this;t.cmd&&(t.onclick=function(){i.execCommand(t.cmd)});i.menuItems=i.menuItems||{};i.menuItems[n]=t},addContextToolbar:function(n,t){var i=this,r;i.contextToolbars=i.contextToolbars||[];"string"==typeof n&&(r=n,n=function(n){return i.dom.is(n,r)});i.contextToolbars.push({id:ht.uuid("mcet"),predicate:n,items:t})},addCommand:function(n,t,i){this.editorCommands.addCommand(n,t,i)},addQueryStateHandler:function(n,t,i){this.editorCommands.addQueryStateHandler(n,t,i)},addQueryValueHandler:function(n,t,i){this.editorCommands.addQueryValueHandler(n,t,i)},addShortcut:function(n,t,i,r){this.shortcuts.add(n,t,i,r)},execCommand:function(n,t,i,r){return this.editorCommands.execCommand(n,t,i,r)},queryCommandState:function(n){return this.editorCommands.queryCommandState(n)},queryCommandValue:function(n){return this.editorCommands.queryCommandValue(n)},queryCommandSupported:function(n){return this.editorCommands.queryCommandSupported(n)},show:function(){var n=this;n.hidden&&(n.hidden=!1,n.inline?n.getBody().contentEditable=!0:(ct.show(n.getContainer()),ct.hide(n.id)),n.load(),n.fire("show"))},hide:function(){var n=this,t=n.getDoc();n.hidden||(yt&&t&&!n.inline&&t.execCommand("SelectAll"),n.save(),n.inline?(n.getBody().contentEditable=!1,n==n.editorManager.focusedEditor&&(n.editorManager.focusedEditor=null)):(ct.hide(n.getContainer()),ct.setStyle(n.id,"display",n.orgDisplay)),n.hidden=!0,n.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(n,t){this.fire("ProgressState",{state:n,time:t})},load:function(n){var r=this,i=r.getElement(),u;if(i)return(n=n||{},n.load=!0,u=r.setContent(i.value!==t?i.value:i.innerHTML,n),n.element=i,n.no_events||r.fire("LoadContent",n),n.element=i=null,u)},save:function(n){var t=this,i=t.getElement(),r,u;if(i&&t.initialized)return n=n||{},n.save=!0,n.element=i,r=n.content=t.getContent(n),n.no_events||t.fire("SaveContent",n),"raw"==n.format&&t.fire("RawSaveContent",n),r=n.content,/TEXTAREA|INPUT/i.test(i.nodeName)?i.value=r:(t.inline||(i.innerHTML=r),(u=ct.getParent(t.id,"form"))&&lt(u.elements,function(n){if(n.name==t.id)return(n.value=r,!1)})),n.element=i=null,n.set_dirty!==!1&&t.setDirty(!1),r},setContent:function(n,t){var i=this,r=i.getBody(),u,f;return t=t||{},t.format=t.format||"html",t.set=!0,t.content=n,t.no_events||i.fire("BeforeSetContent",t),n=t.content,0===n.length||/^\s+$/.test(n)?(f=yt&&11>yt?"":'<br data-mce-bogus="1">',"TABLE"==r.nodeName?n="<tr><td>"+f+"<\/td><\/tr>":/^(UL|OL)$/.test(r.nodeName)&&(n="<li>"+f+"<\/li>"),u=i.settings.forced_root_block,u&&i.schema.isValidChild(r.nodeName.toLowerCase(),u.toLowerCase())?(n=f,n=i.dom.createHTML(u,i.settings.forced_root_block_attrs,n)):yt||n||(n='<br data-mce-bogus="1">'),i.dom.setHTML(r,n),i.fire("SetContent",t)):("raw"!==t.format&&(n=new o({validate:i.validate},i.schema).serialize(i.parser.parse(n,{isRootContent:!0}))),t.content=vt(n),i.dom.setHTML(r,t.content),t.no_events||i.fire("SetContent",t)),t.content},getContent:function(n){var t=this,i,r=t.getBody();return n=n||{},n.format=n.format||"html",n.get=!0,n.getInner=!0,n.no_events||t.fire("BeforeGetContent",n),i="raw"==n.format?t.serializer.getTrimmedContent():"text"==n.format?r.innerText||r.textContent:t.serializer.serialize(r,n),n.content="text"!=n.format?vt(i):i,n.no_events||t.fire("GetContent",n),n.content},insertContent:function(n,t){t&&(n=wt({content:n},t));this.execCommand("mceInsertContent",!1,n)},isDirty:function(){return!this.isNotDirty},setDirty:function(n){var t=!this.isNotDirty;this.isNotDirty=!n;n&&n!=t&&this.fire("dirty")},setMode:function(n){ft.setMode(this,n)},getContainer:function(){var n=this;return n.container||(n.container=ct.get(n.editorContainer||n.id+"_parent")),n.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return this.targetElm||(this.targetElm=ct.get(this.id)),this.targetElm},getWin:function(){var n=this,t;return n.contentWindow||(t=n.iframeElement,t&&(n.contentWindow=t.contentWindow)),n.contentWindow},getDoc:function(){var n=this,t;return n.contentDocument||(t=n.getWin(),t&&(n.contentDocument=t.document)),n.contentDocument},getBody:function(){return this.bodyElement||this.getDoc().body},convertURL:function(n,t,i){var r=this,u=r.settings;return u.urlconverter_callback?r.execCallback("urlconverter_callback",n,i,!0,t):!u.convert_urls||i&&"LINK"==i.nodeName||0===n.indexOf("file:")||0===n.length?n:u.relative_urls?r.documentBaseURI.toRelative(n):n=r.documentBaseURI.toAbsolute(n,u.remove_script_host)},addVisual:function(n){var i=this,f=i.settings,r=i.dom,u;n=n||i.getBody();i.hasVisual===t&&(i.hasVisual=f.visual);lt(r.select("table,a",n),function(n){var t;switch(n.nodeName){case"TABLE":return u=f.visual_table_class||"mce-item-table",t=r.getAttrib(n,"border"),void(t&&"0"!=t||!i.hasVisual?r.removeClass(n,u):r.addClass(n,u));case"A":return void(r.getAttrib(n,"href",!1)||(t=r.getAttrib(n,"name")||n.id,u=f.visual_anchor_class||"mce-item-anchor",t&&i.hasVisual?r.addClass(n,u):r.removeClass(n,u)))}});i.fire("VisualAid",{element:n,hasVisual:i.hasVisual})},remove:function(){var n=this;n.removed||(n.save(),n.removed=1,n.unbindAllNativeEvents(),n.hasHiddenInput&&ct.remove(n.getElement().nextSibling),n.inline||(yt&&10>yt&&n.getDoc().execCommand("SelectAll",!1,null),ct.setStyle(n.id,"display",n.orgDisplay),n.getBody().onload=null),n.fire("remove"),n.editorManager.remove(n),ct.remove(n.getContainer()),n._selectionOverrides.destroy(),n.editorUpload.destroy(),n.destroy())},destroy:function(n){var t=this,i;if(!t.destroyed){if(!n&&!t.removed)return void t.remove();n||(t.editorManager.off("beforeunload",t._beforeUnload),t.theme&&t.theme.destroy&&t.theme.destroy(),t.selection.destroy(),t.dom.destroy());i=t.formElement;i&&(i._mceOldSubmit&&(i.submit=i._mceOldSubmit,i._mceOldSubmit=null),ct.unbind(i,"submit reset",t.formEventDelegate));t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null;t.bodyElement=t.contentDocument=t.contentWindow=null;t.iframeElement=t.targetElm=null;t.selection&&(t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null);t.destroyed=1}},uploadImages:function(n){return this.editorUpload.uploadImages(n)},_scanForImages:function(){return this.editorUpload.scanForImages()}},wt(bt.prototype,ut),bt});i(kr,[],function(){var n={},t="en";return{setCode:function(n){n&&(t=n,this.rtl=this.data[n]?"rtl"===this.data[n]._dir:!1)},getCode:function(){return t},rtl:!1,add:function(t,i){var r=n[t],u;r||(n[t]=r={});for(u in i)r[u]=i[u];this.setCode(t)},translate:function(i){var r,u;return(r=n[t],r||(r={}),"undefined"==typeof i)?i:"string"!=typeof i&&i.raw?i.raw:(i.push&&(u=i.slice(1),i=(r[i[0]]||i[0]).replace(/\{([0-9]+)\}/g,function(n,t){return u[t]})),(r[i]||i).replace(/{context:\w+}$/,""))},data:n}});i(dr,[h,f,u],function(n,t,i){function o(n){function s(){try{return document.activeElement}catch(n){return document.body}}function c(n,t){return t&&t.startContainer?!n.isChildOf(t.startContainer,n.getRoot())||!n.isChildOf(t.endContainer,n.getRoot())?void 0:{startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset}:t}function l(n,t){var i;return t.startContainer?(i=n.getDoc().createRange(),i.setStart(t.startContainer,t.startOffset),i.setEnd(t.endContainer,t.endOffset)):i=t,i}function h(n){return!!r.getParent(n,o.isEditorUIElement)}function a(o){var a=o.editor;a.on("init",function(){(a.inline||i.ie)&&("onbeforedeactivate"in document&&i.ie<9?a.dom.bind(a.getBody(),"beforedeactivate",function(n){if(n.target==a.getBody())try{a.lastRng=a.selection.getRng()}catch(t){}}):a.on("nodechange mouseup keyup",function(n){var t=s();"nodechange"==n.type&&n.selectionChange||(t&&t.id==a.id+"_ifr"&&(t=a.getBody()),a.dom.isChildOf(t,a.getBody())&&(a.lastRng=a.selection.getRng()))}),i.webkit&&!u&&(u=function(){var i=n.activeEditor,t;i&&i.selection&&(t=i.selection.getRng(),t&&!t.collapsed&&(a.lastRng=t))},r.bind(document,"selectionchange",u)))});a.on("setcontent",function(){a.lastRng=null});a.on("mousedown",function(){a.selection.lastFocusBookmark=null});a.on("focusin",function(){var t=n.focusedEditor,i;a.selection.lastFocusBookmark&&(i=l(a,a.selection.lastFocusBookmark),a.selection.lastFocusBookmark=null,a.selection.setRng(i));t!=a&&(t&&t.fire("blur",{focusedEditor:a}),n.setActive(a),n.focusedEditor=a,a.fire("focus",{blurredEditor:t}),a.focus(!0));a.lastRng=null});a.on("focusout",function(){t.setEditorTimeout(a,function(){var t=n.focusedEditor;h(s())||t!=a||(a.fire("blur",{focusedEditor:null}),n.focusedEditor=null,a.selection&&(a.selection.lastFocusBookmark=null))})});f||(f=function(t){var i=n.activeEditor,r;r=t.target;i&&r.ownerDocument==document&&(i.selection&&r!=i.getBody()&&(i.selection.lastFocusBookmark=c(i.dom,i.lastRng)),r==document.body||h(r)||n.focusedEditor!=i||(i.fire("blur",{focusedEditor:null}),n.focusedEditor=null))},r.bind(document,"focusin",f));a.inline&&!e&&(e=function(t){var i=n.activeEditor,u=i.dom,r;i.inline&&u&&!u.isChildOf(t.target,i.getBody())&&(r=i.selection.getRng(),r.collapsed||(i.lastRng=r))},r.bind(document,"mouseup",e))}function v(t){n.focusedEditor==t.editor&&(n.focusedEditor=null);n.activeEditor||(r.unbind(document,"selectionchange",u),r.unbind(document,"focusin",f),r.unbind(document,"mouseup",e),u=f=e=null)}n.on("AddEditor",a);n.on("RemoveEditor",v)}var u,f,e,r=n.DOM;return o.isEditorUIElement=function(n){return-1!==n.className.toString().indexOf("mce-")},o});i(dt,[br,s,h,fi,u,r,k,ct,kr,dr],function(n,t,i,r,u,f,e,o,s,h){function y(n){a(l.editors,function(t){"scroll"===n.type?t.fire("ScrollWindow",n):t.fire("ResizeWindow",n)})}function p(n,i){i!==k&&(i?t(window).on("resize scroll",y):t(window).off("resize scroll",y),k=i)}function w(n){var t=l.editors,r,i;for(delete t[n.id],i=0;i<t.length;i++)if(t[i]==n){t.splice(i,1);r=!0;break}return l.activeEditor==n&&(l.activeEditor=t[0]),l.focusedEditor==n&&(l.focusedEditor=null),r}function d(n){return n&&n.initialized&&!(n.getContainer()||n.getBody()).parentNode&&(w(n),n.unbindAllNativeEvents(),n.destroy(!0),n.removed=!0,n=null),n}var c=i.DOM,g=f.explode,a=f.each,b=f.extend,nt=0,v,l,k=!1;return l={$:t,majorVersion:"4",minorVersion:"4.0",releaseDate:"2016-06-30",editors:[],i18n:s,activeEditor:null,setup:function(){var i=this,u,t,f="",e,n,s,o,c;if(t=r.getDocumentBaseUrl(document.location),/^[^:]+:\/\/\/?[^\/]+\//.test(t)&&(t=t.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(t)||(t+="/")),e=window.tinymce||window.tinyMCEPreInit)u=e.base||e.baseURL,f=e.suffix;else{for(s=document.getElementsByTagName("script"),o=0;o<s.length;o++)if(n=s[o].src,c=n.substring(n.lastIndexOf("/")),/tinymce(\.full|\.jquery|)(\.min|\.dev|)\.js/.test(n)){-1!=c.indexOf(".min")&&(f=".min");u=n.substring(0,n.lastIndexOf("/"));break}!u&&document.currentScript&&(n=document.currentScript.src,-1!=n.indexOf(".min")&&(f=".min"),u=n.substring(0,n.lastIndexOf("/")))}i.baseURL=new r(t).toAbsolute(u);i.documentBaseURL=t;i.baseURI=new r(i.baseURL);i.suffix=f;i.focusManager=new h(i)},overrideDefaults:function(n){var t,i;t=n.base_url;t&&(this.baseURL=new r(this.documentBaseURL).toAbsolute(t.replace(/\/+$/,"")),this.baseURI=new r(this.baseURL));i=n.suffix;n.suffix&&(this.suffix=i);this.defaultSettings=n},init:function(i){function y(n,t){return n.inline&&t.tagName.toLowerCase()in v}function p(n,t){window.console&&!window.test&&window.console.log(n,t)}function s(n){var t=n.id;return t||(t=n.name,t=t&&!c.get(t)?n.name:c.uniqueId(),n.setAttribute("id",t)),t}function w(n){var t=i[n];if(t)return t.apply(r,Array.prototype.slice.call(arguments,2))}function h(n,t){return t.constructor===RegExp?t.test(n.className):c.hasClass(n,t)}function k(n){var i,t=[];if(n.types)return a(n.types,function(n){t=t.concat(c.select(n.selector))}),t;if(n.selector)return c.select(n.selector);if(n.target)return[n.target];switch(n.mode){case"exact":i=n.elements||"";i.length>0&&a(g(i),function(n){var i;(i=c.get(n))?t.push(i):a(document.forms,function(i){a(i.elements,function(i){i.name===n&&(n="mce_editor_"+nt++,c.setAttrib(i,"id",n),t.push(i))})})});break;case"textareas":case"specific_textareas":a(c.select("textarea"),function(i){n.editor_deselector&&h(i,n.editor_deselector)||n.editor_selector&&!h(i,n.editor_selector)||t.push(i)})}return t}function l(){function e(t,i,f){var e=new n(t,i,r);h.push(e);e.on("init",function(){++v===u.length&&o(h)});e.targetElm=e.targetElm||f;e.render()}var v=0,h=[],u;return c.unbind(window,"ready",l),w("onpageload"),u=t.unique(k(i)),i.types?void a(i.types,function(n){f.each(u,function(t){return c.is(t,n.selector)?(e(s(t),b({},i,n),t),!1):!0})}):(f.each(u,function(n){d(r.get(n.id))}),u=f.grep(u,function(n){return!r.get(n.id)}),void a(u,function(n){y(i,n)?p("Could not initialize inline editor on invalid inline target element",n):e(s(n),i,n)}))}var r=this,u,v,o;return v=f.makeMap("area base basefont br col frame hr img input isindex link meta param embed source wbr track colgroup option tbody tfoot thead tr script noscript style textarea video audio iframe object menu"," "),o=function(n){u=n},r.settings=i,c.bind(window,"ready",l),new e(function(n){u?n(u):o=function(t){n(t)}})},get:function(n){return arguments.length?n in this.editors?this.editors[n]:null:this.editors},add:function(n){var t=this,i=t.editors;return i[n.id]=n,i.push(n),p(i,!0),t.activeEditor=n,t.fire("AddEditor",{editor:n}),v||(v=function(){t.fire("BeforeUnload")},c.bind(window,"beforeunload",v)),n},createEditor:function(t,i){return this.add(new n(t,i,this))},remove:function(n){var r=this,u,i=r.editors,t;if(n)return"string"==typeof n?(n=n.selector||n,void a(c.select(n),function(n){t=i[n.id];t&&r.remove(t)})):(t=n,i[t.id]?(w(t)&&r.fire("RemoveEditor",{editor:t}),i.length||c.unbind(window,"beforeunload",v),t.remove(),p(i,i.length>0),t):null);for(u=i.length-1;u>=0;u--)r.remove(i[u])},execCommand:function(t,i,r){var u=this,f=u.get(r);switch(t){case"mceAddEditor":return u.get(r)||new n(r,u.settings,u).render(),!0;case"mceRemoveEditor":return f&&f.remove(),!0;case"mceToggleEditor":return f?(f.isHidden()?f.show():f.hide(),!0):(u.execCommand("mceAddEditor",0,r),!0)}return u.activeEditor?u.activeEditor.execCommand(t,i,r):!1},triggerSave:function(){a(this.editors,function(n){n.save()})},addI18n:function(n,t){s.add(n,t)},translate:function(n){return s.translate(n)},setActive:function(n){var t=this.activeEditor;this.activeEditor!=n&&(t&&t.fire("deactivate",{relatedTarget:n}),n.fire("activate",{relatedTarget:t}));this.activeEditor=n}},b(l,o),l.setup(),window.tinymce=window.tinyMCE=l,l});i("tinymce/LegacyInput",[dt,r],function(n,t){var i=t.each,r=t.explode;n.on("AddEditor",function(n){var t=n.editor;t.on("preInit",function(){function u(t,r){i(r,function(i,r){i&&n.setStyle(t,r,i)});n.rename(t,"span")}function s(r){n=t.dom;f.convert_fonts_to_spans&&i(n.select("font,u,strike",r.node),function(t){e[t.nodeName.toLowerCase()](n,t)})}var e,o,n,f=t.settings;f.inline_styles&&(o=r(f.font_size_legacy_values),e={font:function(n,t){u(t,{backgroundColor:t.style.backgroundColor,color:t.color,fontFamily:t.face,fontSize:o[parseInt(t.size,10)-1]})},u:function(n,i){"html4"===t.settings.schema&&u(i,{textDecoration:"underline"})},strike:function(n,t){u(t,{textDecoration:"line-through"})}},t.on("PreProcess SetContent",s))})})});i(gr,[ct,r],function(n,t){var i={send:function(n){function u(){!n.async||4==r.readyState||f++>1e4?(n.success&&1e4>f&&200==r.status?n.success.call(n.success_scope,""+r.responseText,r,n):n.error&&n.error.call(n.error_scope,f>1e4?"TIMED_OUT":"GENERAL",r,n),r=null):setTimeout(u,10)}var r,f=0;if(n.scope=n.scope||this,n.success_scope=n.success_scope||n.scope,n.error_scope=n.error_scope||n.scope,n.async=n.async!==!1,n.data=n.data||"",i.fire("beforeInitialize",{settings:n}),r=new XMLHttpRequest){if(r.overrideMimeType&&r.overrideMimeType(n.content_type),r.open(n.type||(n.data?"POST":"GET"),n.url,n.async),n.crossDomain&&(r.withCredentials=!0),n.content_type&&r.setRequestHeader("Content-Type",n.content_type),n.requestheaders&&t.each(n.requestheaders,function(n){r.setRequestHeader(n.key,n.value)}),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r=i.fire("beforeSend",{xhr:r,settings:n}).xhr,r.send(n.data),!n.async)return u();setTimeout(u,10)}}};return t.extend(i,n),i});i(nu,[],function(){function n(t,i){var u,r,e,f;if(i=i||'"',null===t)return"null";if(e=typeof t,"string"==e)return r="\bb\tt\nn\ff\rr\"\"''\\\\",i+t.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(n,t){return'"'===i&&"'"===n?n:(u=r.indexOf(t),u+1?"\\"+r.charAt(u+1):(n=t.charCodeAt().toString(16),"\\u"+"0000".substring(n.length)+n))})+i;if("object"==e){if(t.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(t)){for(u=0,r="[";u<t.length;u++)r+=(u>0?",":"")+n(t[u],i);return r+"]"}r="{";for(f in t)t.hasOwnProperty(f)&&(r+="function"!=typeof t[f]?(r.length>1?","+i:i)+f+i+":"+n(t[f],i):"");return r+"}"}return""+t}return{serialize:n,parse:function(n){try{return window[String.fromCharCode(101)+"val"]("("+n+")")}catch(t){}}}});i(ie,[nu,gr,r],function(n,t,i){function r(n){this.settings=u({},n);this.count=0}var u=i.extend;return r.sendRPC=function(n){return(new r).send(n)},r.prototype={send:function(i){var r=i.error,f=i.success;i=u(this.settings,i);i.success=function(t,u){t=n.parse(t);"undefined"==typeof t&&(t={error:"JSON Parse error."});t.error?r.call(i.error_scope||i.scope,t.error,u):f.call(i.success_scope||i.scope,t.result)};i.error=function(n,t){r&&r.call(i.error_scope||i.scope,n,t)};i.data=n.serialize({id:i.id||"c"+this.count++,method:i.method,params:i.params});i.content_type="application/json";t.send(i)}},r});i(re,[h],function(n){return{callbacks:{},count:0,send:function(i){var r=this,u=n.DOM,f=i.count!==t?i.count:r.count,e="tinymce_jsonp_"+f;r.callbacks[f]=function(n){u.remove(e);delete r.callbacks[f];i.callback(n)};u.add(u.doc.body,"script",{id:e,src:i.url,type:"text/javascript"});r.count++}}});i(ue,[],function(){function s(){u=[];for(var t in n)u.push(t);o.length=u.length}function h(){function o(n){var r,i;return i=n!==t?c+n:h.indexOf(",",c),-1===i||i>h.length?null:(r=h.substring(c,i),c=i+1,r)}var e,h,l,c=0,u;if(n={},f){i.load(r);h=i.getAttribute(r)||"";do{if(u=o(),null===u)break;if(e=o(parseInt(u,32)||0),null!==e){if(u=o(),null===u)break;l=o(parseInt(u,32)||0);e&&(n[e]=l)}}while(null!==e);s()}}function e(){var u,e="",t;if(f){for(t in n)u=n[t],e+=(e?",":"")+t.length.toString(32)+","+t+","+u.length.toString(32)+","+u;i.setAttribute(r,e);try{i.save(r)}catch(o){}s()}}var o,i,n,u,r,f;try{if(window.localStorage)return localStorage}catch(c){}return r="tinymce",i=document.documentElement,f=!!i.addBehavior,f&&i.addBehavior("#default#userData"),o={key:function(n){return u[n]},getItem:function(t){return t in n?n[t]:null},setItem:function(t,i){n[t]=""+i;e()},removeItem:function(t){delete n[t];e()},clear:function(){n={};e()}},h(),o});i(fe,[h,ft,vt,ti,r,u],function(n,t,i,r,u,f){var e=window.tinymce;return e.DOM=n.DOM,e.ScriptLoader=i.ScriptLoader,e.PluginManager=r.PluginManager,e.ThemeManager=r.ThemeManager,e.dom=e.dom||{},e.dom.Event=t.Event,u.each(u,function(n,t){e[t]=n}),u.each("isOpera isWebKit isIE isGecko isMac".split(" "),function(n){e[n]=f[n.substr(2).toLowerCase()]}),{}});i(li,[tt,r],function(n,t){return n.extend({Defaults:{firstControlClass:"first",lastControlClass:"last"},init:function(n){this.settings=t.extend({},this.Defaults,n)},preRender:function(n){n.bodyClasses.add(this.settings.containerClass)},applyClasses:function(n){var e=this,i=e.settings,r,u,t,f;r=i.firstControlClass;u=i.lastControlClass;n.each(function(n){n.classes.remove(r).remove(u).add(i.controlClass);n.visible()&&(t||(t=n),f=n)});t&&t.classes.add(r);f&&f.classes.add(u)},renderHtml:function(n){var i=this,t="";return i.applyClasses(n.items()),n.items().each(function(n){t+=n.renderHtml()}),t},recalc:function(){},postRender:function(){},isNative:function(){return!1}})});i(gt,[li],function(n){return n.extend({Defaults:{containerClass:"abs-layout",controlClass:"abs-layout-item"},recalc:function(n){n.items().filter(":visible").each(function(n){var t=n.settings;n.layoutRect({x:t.x,y:t.y,w:t.w,h:t.h});n.recalc&&n.recalc()})},renderHtml:function(n){return'<div id="'+n._id+'-absend" class="'+n.classPrefix+'abs-end"><\/div>'+this._super(n)}})});i(ai,[o],function(n){return n.extend({Defaults:{classes:"widget btn",role:"button"},init:function(n){var t=this,i;t._super(n);n=t.settings;i=t.settings.size;t.on("click mousedown",function(n){n.preventDefault()});t.on("touchstart",function(n){t.fire("click",n);n.preventDefault()});n.subtype&&t.classes.add(n.subtype);i&&t.classes.add("btn-"+i);n.icon&&t.icon(n.icon)},icon:function(n){return arguments.length?(this.state.set("icon",n),this):this.state.get("icon")},repaint:function(){var t=this.getEl().firstChild,n;t&&(n=t.style,n.width=n.height="100%");this._super()},renderHtml:function(){var t=this,u=t._id,r=t.classPrefix,i=t.state.get("icon"),n,f=t.state.get("text"),e="";return n=t.settings.image,n?(i="none","string"!=typeof n&&(n=window.getSelection?n[0]:n[1]),n=" style=\"background-image: url('"+n+"')\""):n="",f&&(t.classes.add("btn-has-text"),e='<span class="'+r+'txt">'+t.encode(f)+"<\/span>"),i=t.settings.icon?r+"ico "+r+"i-"+i:"",'<div id="'+u+'" class="'+t.classes+'" tabindex="-1" aria-labelledby="'+u+'"><button role="presentation" type="button" tabindex="-1">'+(i?'<i class="'+i+'"'+n+"><\/i>":"")+e+"<\/button><\/div>"},bindStates:function(){function r(r){var u=t("span."+i,n.getEl());r?(u[0]||(t("button:first",n.getEl()).append('<span class="'+i+'"><\/span>'),u=t("span."+i,n.getEl())),u.html(n.encode(r))):u.remove();n.classes.toggle("btn-has-text",!!r)}var n=this,t=n.$,i=n.classPrefix+"txt";return n.state.on("change:text",function(n){r(n.value)}),n.state.on("change:icon",function(t){var f=t.value,e=n.classPrefix,u,i;n.settings.icon=f;f=f?e+"ico "+e+"i-"+n.settings.icon:"";u=n.getEl().firstChild;i=u.getElementsByTagName("i")[0];f?(i&&i==u.firstChild||(i=document.createElement("i"),u.insertBefore(i,u.firstChild)),i.className=f):i&&u.removeChild(i);r(n.state.get("text"))}),n._super()}})});i(ee,[it],function(n){return n.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var n=this,t=n._layout;return n.classes.add("btn-group"),n.preRender(),t.preRender(n),'<div id="'+n._id+'" class="'+n.classes+'"><div id="'+n._id+'-body">'+(n.settings.html||"")+t.renderHtml(n)+"<\/div><\/div>"}})});i(tu,[o],function(n){return n.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(n){var t=this;t._super(n);t.on("click mousedown",function(n){n.preventDefault()});t.on("click",function(n){n.preventDefault();t.disabled()||t.checked(!t.checked())});t.checked(t.settings.checked)},checked:function(n){return arguments.length?(this.state.set("checked",n),this):this.state.get("checked")},value:function(n){return arguments.length?this.checked(n):this.checked()},renderHtml:function(){var n=this,t=n._id,i=n.classPrefix;return'<div id="'+t+'" class="'+n.classes+'" unselectable="on" aria-labelledby="'+t+'-al" tabindex="-1"><i class="'+i+"ico "+i+'i-checkbox"><\/i><span id="'+t+'-al" class="'+i+'label">'+n.encode(n.state.get("text"))+"<\/span><\/div>"},bindStates:function(){function t(t){n.classes.toggle("checked",t);n.aria("checked",t)}var n=this;return n.state.on("change:text",function(t){n.getEl("al").firstChild.data=n.translate(t.value)}),n.state.on("change:checked change:value",function(i){n.fire("change");t(i.value)}),n.state.on("change:icon",function(t){var r=t.value,f=n.classPrefix,u,i;if("undefined"==typeof r)return n.settings.icon;n.settings.icon=r;r=r?f+"ico "+f+"i-"+n.settings.icon:"";u=n.getEl().firstChild;i=u.getElementsByTagName("i")[0];r?(i&&i==u.firstChild||(i=document.createElement("i"),u.insertBefore(i,u.firstChild)),i.className=r):i&&u.removeChild(i)}),n.state.get("checked")&&t(!0),n._super()}})});i(vi,[o,lt,l,s],function(n,t,i,r){return n.extend({init:function(n){var t=this;t._super(n);n=t.settings;t.classes.add("combobox");t.subinput=!0;t.ariaTarget="inp";n.menu=n.menu||n.values;n.menu&&(n.icon="caret");t.on("click",function(i){var u=i.target,f=t.getEl();if(r.contains(f,u)||u==f)for(;u&&u!=f;)u.id&&-1!=u.id.indexOf("-open")&&(t.fire("action"),n.menu&&(t.showMenu(),i.aria&&t.menu.items()[0].focus())),u=u.parentNode});t.on("keydown",function(n){"INPUT"==n.target.nodeName&&13==n.keyCode&&t.parents().reverse().each(function(i){var u=t.state.get("value"),r=t.getEl("inp").value;return n.preventDefault(),t.state.set("value",r),u!=r&&t.fire("change"),i.hasEventListeners("submit")&&i.toJSON?(i.fire("submit",{data:i.toJSON()}),!1):void 0})});t.on("keyup",function(n){"INPUT"==n.target.nodeName&&t.state.set("value",n.target.value)})},showMenu:function(){var n=this,r=n.settings,i;n.menu||(i=r.menu||[],i.length?i={type:"menu",items:i}:i.type=i.type||"menu",n.menu=t.create(i).parent(n).renderTo(n.getContainerElm()),n.fire("createmenu"),n.menu.reflow(),n.menu.on("cancel",function(t){t.control===n.menu&&n.focus()}),n.menu.on("show hide",function(t){t.control.items().each(function(t){t.active(t.value()==n.value())})}).fire("show"),n.menu.on("select",function(t){n.value(t.control.value())}),n.on("focusin",function(t){"INPUT"==t.target.tagName.toUpperCase()&&n.menu.hide()}),n.aria("expanded",!0));n.menu.show();n.menu.layoutRect({w:n.layoutRect().w});n.menu.moveRel(n.getEl(),n.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},focus:function(){this.getEl("inp").focus()},repaint:function(){var n=this,s=n.getEl(),u=n.getEl("open"),f=n.layoutRect(),e,o,t;return e=u?f.w-i.getSize(u).width-10:f.w-10,t=document,t.all&&(!t.documentMode||t.documentMode<=8)&&(o=n.layoutRect().h-2+"px"),r(s.firstChild).css({width:e,lineHeight:o}),n._super(),n},postRender:function(){var n=this;return r(this.getEl("inp")).on("change",function(t){n.state.set("value",t.target.value);n.fire("change",t)}),n._super()},renderHtml:function(){var t=this,f=t._id,n=t.settings,r=t.classPrefix,s=t.state.get("value")||"",i,e,o="",u="";return"spellcheck"in n&&(u+=' spellcheck="'+n.spellcheck+'"'),n.maxLength&&(u+=' maxlength="'+n.maxLength+'"'),n.size&&(u+=' size="'+n.size+'"'),n.subtype&&(u+=' type="'+n.subtype+'"'),t.disabled()&&(u+=' disabled="disabled"'),i=n.icon,i&&"caret"!=i&&(i=r+"ico "+r+"i-"+n.icon),e=t.state.get("text"),(i||e)&&(o='<div id="'+f+'-open" class="'+r+"btn "+r+'open" tabIndex="-1" role="button"><button id="'+f+'-action" type="button" hidefocus="1" tabindex="-1">'+("caret"!=i?'<i class="'+i+'"><\/i>':'<i class="'+r+'caret"><\/i>')+(e?(i?" ":"")+e:"")+"<\/button><\/div>",t.classes.add("has-open")),'<div id="'+f+'" class="'+t.classes+'"><input id="'+f+'-inp" class="'+r+'textbox" value="'+t.encode(s,!1)+'" hidefocus="1"'+u+' placeholder="'+t.encode(n.placeholder)+'" />'+o+"<\/div>"},value:function(n){return arguments.length?(this.state.set("value",n),this):(this.state.get("rendered")&&this.state.set("value",this.getEl("inp").value),this.state.get("value"))},bindStates:function(){var n=this;return n.state.on("change:value",function(t){n.getEl("inp").value!=t.value&&(n.getEl("inp").value=t.value)}),n.state.on("change:disabled",function(t){n.getEl("inp").disabled=t.value}),n._super()},remove:function(){r(this.getEl("inp")).off();this._super()}})});i(oe,[vi],function(n){return n.extend({init:function(n){var t=this;n.spellcheck=!1;n.onaction&&(n.icon="none");t._super(n);t.classes.add("colorbox");t.on("change keyup postrender",function(){t.repaintColor(t.value())})},repaintColor:function(n){var t=this.getEl().getElementsByTagName("i")[0];if(t)try{t.style.background=n}catch(i){}},bindStates:function(){var n=this;return n.state.on("change:value",function(t){n.state.get("rendered")&&n.repaintColor(t.value)}),n._super()}})});i(iu,[ai,at],function(n,t){return n.extend({showPanel:function(){var n=this,r=n.settings,i;(n.active(!0),n.panel)?n.panel.show():(i=r.panel,i.type&&(i={layout:"grid",items:i}),i.role=i.role||"dialog",i.popover=!0,i.autohide=!0,i.ariaRoot=!0,n.panel=new t(i).on("hide",function(){n.active(!1)}).on("cancel",function(t){t.stopPropagation();n.focus();n.hidePanel()}).parent(n).renderTo(n.getContainerElm()),n.panel.fire("show"),n.panel.reflow());n.panel.moveRel(n.getEl(),r.popoverAlign||(n.isRtl()?["bc-tr","bc-tc"]:["bc-tl","bc-tc"]))},hidePanel:function(){var n=this;n.panel&&n.panel.hide()},postRender:function(){var n=this;return n.aria("haspopup",!0),n.on("click",function(t){t.control===n&&(n.panel&&n.panel.visible()?n.hidePanel():(n.showPanel(),n.panel.focus(!!t.aria)))}),n._super()},remove:function(){return this.panel&&(this.panel.remove(),this.panel=null),this._super()}})});i(se,[iu,h],function(n,t){var i=t.DOM;return n.extend({init:function(n){this._super(n);this.classes.add("colorbutton")},color:function(n){return n?(this._color=n,this.getEl("preview").style.backgroundColor=n,this):this._color},resetColor:function(){return this._color=null,this.getEl("preview").style.backgroundColor=null,this},renderHtml:function(){var n=this,i=n._id,t=n.classPrefix,r=n.state.get("text"),u=n.settings.icon?t+"ico "+t+"i-"+n.settings.icon:"",e=n.settings.image?" style=\"background-image: url('"+n.settings.image+"')\"":"",f="";return r&&(n.classes.add("btn-has-text"),f='<span class="'+t+'txt">'+n.encode(r)+"<\/span>"),'<div id="'+i+'" class="'+n.classes+'" role="button" tabindex="-1" aria-haspopup="true"><button role="presentation" hidefocus="1" type="button" tabindex="-1">'+(u?'<i class="'+u+'"'+e+"><\/i>":"")+'<span id="'+i+'-preview" class="'+t+'preview"><\/span>'+f+'<\/button><button type="button" class="'+t+'open" hidefocus="1" tabindex="-1"> <i class="'+t+'caret"><\/i><\/button><\/div>'},postRender:function(){var n=this,t=n.settings.onclick;return n.on("click",function(r){r.aria&&"down"==r.aria.key||r.control!=n||i.getParent(r.target,"."+n.classPrefix+"open")||(r.stopImmediatePropagation(),t.call(n,r))}),delete n.settings.onclick,n._super()}})});i(ru,[],function(){function r(r){function h(r,u,f){var s,c,h,l,e,o;return s=0,c=0,h=0,r/=255,u/=255,f/=255,e=t(r,t(u,f)),o=i(r,i(u,f)),e==o?(h=e,{h:0,s:0,v:100*h}):(l=r==e?u-f:f==e?r-u:f-r,s=r==e?3:f==e?1:5,s=60*(s-l/(o-e)),c=(o-e)/o,h=o,{h:n(s),s:n(100*c),v:n(100*h)})}function c(r,o,s){var a,h,c,l;if(r=(parseInt(r,10)||0)%360,o=parseInt(o,10)/100,s=parseInt(s,10)/100,o=i(0,t(o,1)),s=i(0,t(s,1)),0===o)return void(u=f=e=n(255*s));switch(a=r/60,h=s*o,c=h*(1-Math.abs(a%2-1)),l=s-h,Math.floor(a)){case 0:u=h;f=c;e=0;break;case 1:u=c;f=h;e=0;break;case 2:u=0;f=h;e=c;break;case 3:u=0;f=c;e=h;break;case 4:u=c;f=0;e=h;break;case 5:u=h;f=0;e=c;break;default:u=f=e=0}u=n(255*(u+l));f=n(255*(f+l));e=n(255*(e+l))}function l(){function n(n){return n=parseInt(n,10).toString(16),n.length>1?n:"0"+n}return"#"+n(u)+n(f)+n(e)}function a(){return{r:u,g:f,b:e}}function v(){return h(u,f,e)}function s(n){var t;return"object"==typeof n?"r"in n?(u=n.r,f=n.g,e=n.b):"v"in n&&c(n.h,n.s,n.v):(t=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)[^\)]*\)/gi.exec(n))?(u=parseInt(t[1],10),f=parseInt(t[2],10),e=parseInt(t[3],10)):(t=/#([0-F]{2})([0-F]{2})([0-F]{2})/gi.exec(n))?(u=parseInt(t[1],16),f=parseInt(t[2],16),e=parseInt(t[3],16)):(t=/#([0-F])([0-F])([0-F])/gi.exec(n))&&(u=parseInt(t[1]+t[1],16),f=parseInt(t[2]+t[2],16),e=parseInt(t[3]+t[3],16)),u=0>u?0:u>255?255:u,f=0>f?0:f>255?255:f,e=0>e?0:e>255?255:e,o}var o=this,u=0,f=0,e=0;r&&s(r);o.toRgb=a;o.toHsv=v;o.toHex=l;o.parse=s}var t=Math.min,i=Math.max,n=Math.round;return r});i(he,[o,rt,l,ru],function(n,t,i,r){return n.extend({Defaults:{classes:"widget colorpicker"},init:function(n){this._super(n)},postRender:function(){function o(n,t){var f=i.getPos(n),r,u;return r=t.pageX-f.x,u=t.pageY-f.y,r=Math.max(0,Math.min(r/n.clientWidth,1)),u=Math.max(0,Math.min(u/n.clientHeight,1)),{x:r,y:u}}function f(t,u){var f=(360-t.h)/360;i.css(a,{top:100*f+"%"});u||i.css(v,{left:t.s+"%",top:100-t.v+"%"});e.style.background=new r({s:100,v:100,h:t.h}).toHex();n.color().parse({s:t.s,v:t.v,h:t.h})}function s(t){var i;i=o(e,t);u.s=100*i.x;u.v=100*(1-i.y);f(u);n.fire("change")}function h(t){var i;i=o(l,t);u=c.toHsv();u.h=360*(1-i.y);f(u,!0);n.fire("change")}var n=this,c=n.color(),u,l,a,e,v;l=n.getEl("h");a=n.getEl("hp");e=n.getEl("sv");v=n.getEl("svp");n._repaint=function(){u=c.toHsv();f(u)};n._super();n._svdraghelper=new t(n._id+"-sv",{start:s,drag:s});n._hdraghelper=new t(n._id+"-h",{start:h,drag:h});n._repaint()},rgb:function(){return this.color().toRgb()},value:function(n){var t=this;return arguments.length?(t.color().parse(n),void(t._rendered&&t._repaint())):t.color().toHex()},color:function(){return this._color||(this._color=new r),this._color},renderHtml:function(){function f(){var t,u,e="",f,i;for(f="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",i=r.split(","),t=0,u=i.length-1;u>t;t++)e+='<div class="'+n+'colorpicker-h-chunk" style="height:'+100/u+"%;"+f+i[t]+",endColorstr="+i[t+1]+");-ms-"+f+i[t]+",endColorstr="+i[t+1]+')"><\/div>';return e}var i=this,t=i._id,n=i.classPrefix,u,r="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000",e="background: -ms-linear-gradient(top,"+r+");background: linear-gradient(to bottom,"+r+");";return u='<div id="'+t+'-h" class="'+n+'colorpicker-h" style="'+e+'">'+f()+'<div id="'+t+'-hp" class="'+n+'colorpicker-h-marker"><\/div><\/div>','<div id="'+t+'" class="'+i.classes+'"><div id="'+t+'-sv" class="'+n+'colorpicker-sv"><div class="'+n+'colorpicker-overlay1"><div class="'+n+'colorpicker-overlay2"><div id="'+t+'-svp" class="'+n+'colorpicker-selector1"><div class="'+n+'colorpicker-selector2"><\/div><\/div><\/div><\/div><\/div>'+u+"<\/div>"}})});i(uu,[o],function(n){return n.extend({init:function(n){var t=this;n.delimiter||(n.delimiter="»");t._super(n);t.classes.add("path");t.canFocus=!0;t.on("click",function(n){var i,r=n.target;(i=r.getAttribute("data-index"))&&t.fire("select",{value:t.row()[i],index:i})});t.row(t.settings.row)},focus:function(){var n=this;return n.getEl().firstChild.focus(),n},row:function(n){return arguments.length?(this.state.set("row",n),this):this.state.get("row")},renderHtml:function(){var n=this;return'<div id="'+n._id+'" class="'+n.classes+'">'+n._getDataPathHtml(n.state.get("row"))+"<\/div>"},bindStates:function(){var n=this;return n.state.on("change:row",function(t){n.innerHtml(n._getDataPathHtml(t.value))}),n._super()},_getDataPathHtml:function(n){for(var u=this,e=n||[],i="",r=u.classPrefix,t=0,f=e.length;f>t;t++)i+=(t>0?'<div class="'+r+'divider" aria-hidden="true"> '+u.settings.delimiter+" <\/div>":"")+'<div role="button" class="'+r+"path-item"+(t==f-1?" "+r+"last":"")+'" data-index="'+t+'" tabindex="-1" id="'+u._id+"-"+t+'" aria-level="'+t+'">'+e[t].name+"<\/div>";return i||(i='<div class="'+r+'path-item"> <\/div>'),i}})});i(ce,[uu,dt],function(n,t){return n.extend({postRender:function(){function r(n){return 1===n.nodeType&&("BR"==n.nodeName||n.getAttribute("data-mce-bogus")||"bookmark"===n.getAttribute("data-mce-type"))?!0:!1}var i=this,n=t.activeEditor;return n.settings.elementpath!==!1&&(i.on("select",function(t){n.focus();n.selection.select(this.row()[t.index].element);n.nodeChanged()}),n.on("nodeChange",function(t){for(var e,o=[],u=t.parents,f=u.length;f--;)if(1==u[f].nodeType&&!r(u[f])&&(e=n.fire("ResolveName",{name:u[f].nodeName.toLowerCase(),target:u[f]}),e.isDefaultPrevented()||o.push({name:e.name,element:u[f]}),e.isPropagationStopped()))break;i.row(o)})),i._super()}})});i(fu,[it],function(n){return n.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var n=this,t=n._layout,i=n.classPrefix;return n.classes.add("formitem"),t.preRender(n),'<div id="'+n._id+'" class="'+n.classes+'" hidefocus="1" tabindex="-1">'+(n.settings.title?'<div id="'+n._id+'-title" class="'+i+'title">'+n.settings.title+"<\/div>":"")+'<div id="'+n._id+'-body" class="'+n.bodyClasses+'">'+(n.settings.html||"")+t.renderHtml(n)+"<\/div><\/div>"}})});i(eu,[it,fu,r],function(n,t,i){return n.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:20,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var n=this,r=n.items();n.settings.formItemDefaults||(n.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}});r.each(function(r){var u,f=r.settings.label;f&&(u=new t(i.extend({items:{type:"label",id:r._id+"-l",text:f,flex:0,forId:r._id,disabled:r.disabled()}},n.settings.formItemDefaults)),u.type="formitem",r.aria("labelledby",r._id+"-l"),"undefined"==typeof r.settings.flex&&(r.settings.flex=1),n.replace(r,u),u.add(r))})},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){var n=this;n._super();n.fromJSON(n.settings.data)},bindStates:function(){function t(){var t=0,i=[],r,u,f;if(n.settings.labelGapCalc!==!1)for(f="children"==n.settings.labelGapCalc?n.find("formitem"):n.items(),f.filter("formitem").each(function(n){var r=n.items()[0],u=r.getEl().clientWidth;t=u>t?u:t;i.push(r)}),u=n.settings.labelGap||0,r=i.length;r--;)i[r].settings.minWidth=t+u}var n=this;n._super();n.on("show",t);t()}})});i(le,[eu],function(n){return n.extend({Defaults:{containerCls:"fieldset",layout:"flex",direction:"column",align:"stretch",flex:1,padding:"25 15 5 15",labelGap:30,spacing:10,border:1},renderHtml:function(){var n=this,t=n._layout,i=n.classPrefix;return n.preRender(),t.preRender(n),'<fieldset id="'+n._id+'" class="'+n.classes+'" hidefocus="1" tabindex="-1">'+(n.settings.title?'<legend id="'+n._id+'-title" class="'+i+'fieldset-title">'+n.settings.title+"<\/legend>":"")+'<div id="'+n._id+'-body" class="'+n.bodyClasses+'">'+(n.settings.html||"")+t.renderHtml(n)+"<\/div><\/fieldset>"}})});i(ae,[vi,r],function(n,t){return n.extend({init:function(n){var r=this,o=tinymce.activeEditor,f=o.settings,e,u,i;n.spellcheck=!1;i=f.file_picker_types||f.file_browser_callback_types;i&&(i=t.makeMap(i,/[, ]/));i&&!i[n.filetype]||(u=f.file_picker_callback,!u||i&&!i[n.filetype]?(u=f.file_browser_callback,!u||i&&!i[n.filetype]||(e=function(){u(r.getEl("inp").id,r.value(),n.filetype,window)})):e=function(){var i=r.fire("beforecall").meta;i=t.extend({filetype:n.filetype},i);u.call(o,function(n,t){r.value(n).fire("change",{meta:t})},r.value(),i)});e&&(n.icon="browse",n.onaction=e);r._super(n)}})});i(ve,[gt],function(n){return n.extend({recalc:function(n){var i=n.layoutRect(),t=n.paddingBox;n.items().filter(":visible").each(function(n){n.layoutRect({x:t.left,y:t.top,w:i.innerW-t.right-t.left,h:i.innerH-t.top-t.bottom});n.recalc&&n.recalc()})}})});i(ye,[gt],function(n){return n.extend({recalc:function(n){var f,v,s,r,u,y,ut,ft,et,w,e,b,o,i,gt,ot,at=[],h,vt,st,t,l,g,yt,a,pt,nt,c,p,ht,wt,k,tt,it,rt,d,ct,bt,kt,dt=Math.max,ni=Math.min,lt;for(s=n.items().filter(":visible"),r=n.layoutRect(),u=n.paddingBox,y=n.settings,b=n.isRtl()?y.direction||"row-reversed":y.direction,ut=y.align,ft=n.isRtl()?y.pack||"end":y.pack,et=y.spacing||0,"row-reversed"!=b&&"column-reverse"!=b||(s=s.set(s.toArray().reverse()),b=b.split("-")[0]),"column"==b?(pt="y",yt="h",a="minH",nt="maxH",p="innerH",c="top",ht="deltaH",wt="contentH",d="left",it="w",k="x",tt="innerW",rt="minW",ct="right",bt="deltaW",kt="contentW"):(pt="x",yt="w",a="minW",nt="maxW",p="innerW",c="left",ht="deltaW",wt="contentW",d="top",it="h",k="y",tt="innerH",rt="minH",ct="bottom",bt="deltaH",kt="contentH"),e=r[p]-u[c]-u[c],g=w=0,f=0,v=s.length;v>f;f++)o=s[f],i=o.layoutRect(),gt=o.settings,ot=gt.flex,e-=v-1>f?et:0,ot>0&&(w+=ot,i[nt]&&at.push(o),i.flex=ot),e-=i[a],h=u[d]+i[rt]+u[ct],h>g&&(g=h);if(t={},t[a]=0>e?r[a]-e+r[ht]:r[p]-e+r[ht],t[rt]=g+r[bt],t[wt]=r[p]-e,t[kt]=g,t.minW=ni(t.minW,r.maxW),t.minH=ni(t.minH,r.maxH),t.minW=dt(t.minW,r.startMinWidth),t.minH=dt(t.minH,r.startMinHeight),r.autoResize&&(t.minW!=r.minW||t.minH!=r.minH))(t.w=t.minW,t.h=t.minH,n.layoutRect(t),this.recalc(n),null===n._lastRect)&&(lt=n.parent(),lt&&(lt._lastRect=null,lt.recalc()));else{for(st=e/w,f=0,v=at.length;v>f;f++)o=at[f],i=o.layoutRect(),vt=i[nt],h=i[a]+i.flex*st,h>vt?(e-=i[nt]-i[a],w-=i.flex,i.flex=0,i.maxFlexSize=vt):i.maxFlexSize=0;for(st=e/w,l=u[c],t={},0===w&&("end"==ft?l=e+u[c]:"center"==ft?(l=Math.round(r[p]/2-(r[p]-e)/2)+u[c],0>l&&(l=u[c])):"justify"==ft&&(l=u[c],et=Math.floor(e/(s.length-1)))),t[k]=u[d],f=0,v=s.length;v>f;f++)o=s[f],i=o.layoutRect(),h=i.maxFlexSize||i[a],"center"===ut?t[k]=Math.round(r[tt]/2-i[it]/2):"stretch"===ut?(t[it]=dt(i[rt]||0,r[tt]-u[d]-u[ct]),t[k]=u[d]):"end"===ut&&(t[k]=r[tt]-i[it]-u.top),i.flex>0&&(h+=i.flex*st),t[yt]=h,t[pt]=l,o.layoutRect(t),o.recalc&&o.recalc(),l+=h+et}}})});i(ou,[li],function(n){return n.extend({Defaults:{containerClass:"flow-layout",controlClass:"flow-layout-item",endClass:"break"},recalc:function(n){n.items().filter(":visible").each(function(n){n.recalc&&n.recalc()})},isNative:function(){return!0}})});i(pe,[b,o,at,r,dt,u],function(n,t,i,r,u,f){function o(n){function r(t,i){return function(){var r=this;n.on("nodeChange",function(u){var o=n.formatter,f=null;e(u.parents,function(n){return e(t,function(t){return i?o.matchNode(n,i,{value:t.value})&&(f=t.value):o.matchNode(n,t.value)&&(f=t.value),f?!1:void 0}),f?!1:void 0});r.value(f)})}}function o(n){n=n.replace(/;$/,"").split(";");for(var t=n.length;t--;)n[t]=n[t].split("=");return n}function h(){function i(n){var t=[];if(n)return e(n,function(n){var u={text:n.title,icon:n.icon},f;n.items?u.menu=i(n.items):(f=n.format||"custom"+o++,n.format||(n.name=f,r.push(n)),u.format=f,u.cmd=n.cmd);t.push(u)}),t}function f(){return i(n.settings.style_formats_merge?n.settings.style_formats?t.concat(n.settings.style_formats):t:n.settings.style_formats||t)}var o=0,r=[],t=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}];return n.on("init",function(){e(r,function(t){n.formatter.register(t.name,t)})}),{type:"menu",items:f(),onPostRender:function(t){n.fire("renderFormatsMenu",{control:t.control})},itemDefaults:{preview:!0,textStyle:function(){if(this.settings.format)return n.formatter.getCssText(this.settings.format)},onPostRender:function(){var t=this;t.parent().on("show",function(){var i,r;i=t.settings.format;i&&(t.disabled(!n.formatter.canApply(i)),t.active(n.formatter.match(i)));r=t.settings.cmd;r&&t.active(n.queryCommandState(r))})},onclick:function(){this.settings.format&&u(this.settings.format);this.settings.cmd&&n.execCommand(this.settings.cmd)}}}}function s(t){return function(){var i=this;n.formatter?n.formatter.formatChanged(t,function(n){i.active(n)}):n.on("init",function(){n.formatter.formatChanged(t,function(n){i.active(n)})})}}function t(t){return function(){function i(){return n.undoManager?n.undoManager[t]():!1}var r=this;t="redo"==t?"hasRedo":"hasUndo";r.disabled(!i());n.on("Undo Redo AddUndo TypingUndo ClearUndos SwitchMode",function(){r.disabled(n.readonly||!i())})}}function c(){var t=this;n.on("VisualAid",function(n){t.active(n.hasVisual)});t.active(n.hasVisual)}function u(t){t.control&&(t=t.control.value());t&&n.execCommand("mceToggleFormat",!1,t)}var f;f=h();e({bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript"},function(t,i){n.addButton(i,{tooltip:t,onPostRender:s(i),onclick:function(){u(i)}})});e({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,i){n.addButton(i,{tooltip:t[0],cmd:t[1]})});e({blockquote:["Blockquote","mceBlockQuote"],numlist:["Numbered list","InsertOrderedList"],bullist:["Bullet list","InsertUnorderedList"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"],alignnone:["No alignment","JustifyNone"]},function(t,i){n.addButton(i,{tooltip:t[0],cmd:t[1],onPostRender:s(i)})});n.addButton("undo",{tooltip:"Undo",onPostRender:t("undo"),cmd:"undo"});n.addButton("redo",{tooltip:"Redo",onPostRender:t("redo"),cmd:"redo"});n.addMenuItem("newdocument",{text:"New document",icon:"newdocument",cmd:"mceNewDocument"});n.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onPostRender:t("undo"),cmd:"undo"});n.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onPostRender:t("redo"),cmd:"redo"});n.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:c,cmd:"mceToggleVisualAid"});n.addButton("remove",{tooltip:"Remove",icon:"remove",cmd:"Delete"});e({cut:["Cut","Cut","Meta+X"],copy:["Copy","Copy","Meta+C"],paste:["Paste","Paste","Meta+V"],selectall:["Select all","SelectAll","Meta+A"],bold:["Bold","Bold","Meta+B"],italic:["Italic","Italic","Meta+I"],underline:["Underline","Underline"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,i){n.addMenuItem(i,{text:t[0],icon:i,shortcut:t[2],cmd:t[1]})});n.on("mousedown",function(){i.hideAll()});n.addButton("styleselect",{type:"menubutton",text:"Formats",menu:f});n.addButton("formatselect",function(){var t=[],i=o(n.settings.block_formats||"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre");return e(i,function(i){t.push({text:i[0],value:i[1],textStyle:function(){return n.formatter.getCssText(i[1])}})}),{type:"listbox",text:i[0][0],values:t,fixedWidth:!0,onselect:u,onPostRender:r(t)}});n.addButton("fontselect",function(){var t=[],i=o(n.settings.font_formats||"Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats");return e(i,function(n){t.push({text:{raw:n[0]},value:n[1],textStyle:-1==n[1].indexOf("dings")?"font-family:"+n[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:t,fixedWidth:!0,onPostRender:r(t,"fontname"),onselect:function(t){t.control.settings.value&&n.execCommand("FontName",!1,t.control.settings.value)}}});n.addButton("fontsizeselect",function(){var t=[],i=n.settings.fontsize_formats||"8pt 10pt 12pt 14pt 18pt 24pt 36pt";return e(i.split(" "),function(n){var r=n,u=n,i=n.split("=");i.length>1&&(r=i[0],u=i[1]);t.push({text:r,value:u})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:t,fixedWidth:!0,onPostRender:r(t,"fontsize"),onclick:function(t){t.control.settings.value&&n.execCommand("FontSize",!1,t.control.settings.value)}}});n.addMenuItem("formats",{text:"Formats",menu:f})}var e=r.each;u.on("AddEditor",function(t){t.editor.rtl&&(n.rtl=!0);o(t.editor)});n.translate=function(n){return u.translate(n)};t.tooltips=!f.iOS});i(we,[gt],function(n){return n.extend({recalc:function(n){var e,p,o,b,u,k,d,i,f,h,t,r,g,nt,st,s,c,tt,it,l,a,rt,ut,v=[],y=[],ht,ct,lt,ft,vt,yt,pt,et,w,at,ot;for(e=n.settings,b=n.items().filter(":visible"),u=n.layoutRect(),o=e.columns||Math.ceil(Math.sqrt(b.length)),p=Math.ceil(b.length/o),tt=e.spacingH||e.spacing||0,it=e.spacingV||e.spacing||0,l=e.alignH||e.align,a=e.alignV||e.align,s=n.paddingBox,vt=("reverseRows"in e)?e.reverseRows:n.isRtl(),l&&"string"==typeof l&&(l=[l]),a&&"string"==typeof a&&(a=[a]),t=0;o>t;t++)v.push(0);for(r=0;p>r;r++)y.push(0);for(r=0;p>r;r++)for(t=0;o>t&&(h=b[r*o+t],h);t++)f=h.layoutRect(),ht=f.minW,ct=f.minH,v[t]=ht>v[t]?ht:v[t],y[r]=ct>y[r]?ct:y[r];for(lt=u.innerW-s.left-s.right,rt=0,t=0;o>t;t++)rt+=v[t]+(t>0?tt:0),lt-=(t>0?tt:0)+v[t];for(ft=u.innerH-s.top-s.bottom,ut=0,r=0;p>r;r++)ut+=y[r]+(r>0?it:0),ft-=(r>0?it:0)+y[r];if(rt+=s.left+s.right,ut+=s.top+s.bottom,i={},i.minW=rt+(u.w-u.innerW),i.minH=ut+(u.h-u.innerH),i.contentW=i.minW-u.deltaW,i.contentH=i.minH-u.deltaH,i.minW=Math.min(i.minW,u.maxW),i.minH=Math.min(i.minH,u.maxH),i.minW=Math.max(i.minW,u.startMinWidth),i.minH=Math.max(i.minH,u.startMinHeight),u.autoResize&&(i.minW!=u.minW||i.minH!=u.minH))(i.w=i.minW,i.h=i.minH,n.layoutRect(i),this.recalc(n),null===n._lastRect)&&(ot=n.parent(),ot&&(ot._lastRect=null,ot.recalc()));else{if(u.autoResize&&(i=n.layoutRect(i),i.contentW=i.minW-u.deltaW,i.contentH=i.minH-u.deltaH),pt="start"==e.packV?0:ft>0?Math.floor(ft/p):0,et=0,w=e.flexWidths,w)for(t=0;t<w.length;t++)et+=w[t];else et=o;for(at=lt/et,t=0;o>t;t++)v[t]+=w?w[t]*at:at;for(nt=s.top,r=0;p>r;r++){for(g=s.left,d=y[r]+pt,t=0;o>t&&(yt=vt?r*o+o-1-t:r*o+t,h=b[yt],h);t++)st=h.settings,f=h.layoutRect(),k=Math.max(v[t],f.startMinWidth),f.x=g,f.y=nt,c=st.alignH||(l?l[t]||l[0]:null),"center"==c?f.x=g+k/2-f.w/2:"right"==c?f.x=g+k-f.w:"stretch"==c&&(f.w=k),c=st.alignV||(a?a[t]||a[0]:null),"center"==c?f.y=nt+d/2-f.h/2:"bottom"==c?f.y=nt+d-f.h:"stretch"==c&&(f.h=d),h.layoutRect(f),g+=k+tt,h.recalc&&h.recalc();nt+=d+it}}}})});i(be,[o,f],function(n,t){return n.extend({renderHtml:function(){var n=this;return n.classes.add("iframe"),n.canFocus=!1,'<iframe id="'+n._id+'" class="'+n.classes+'" tabindex="-1" src="'+(n.settings.url||"javascript:''")+'" frameborder="0"><\/iframe>'},src:function(n){this.getEl().src=n},html:function(n,i){var u=this,r=this.getEl().contentWindow.document.body;return r?(r.innerHTML=n,i&&i()):t.setTimeout(function(){u.html(n)}),this}})});i(ke,[o],function(n){return n.extend({init:function(n){var t=this;t._super(n);t.classes.add("widget").add("infobox");t.canFocus=!1},severity:function(n){this.classes.remove("error");this.classes.remove("warning");this.classes.remove("success");this.classes.add(n)},help:function(n){this.state.set("help",n)},renderHtml:function(){var n=this,t=n.classPrefix;return'<div id="'+n._id+'" class="'+n.classes+'"><div id="'+n._id+'-body">'+n.encode(n.state.get("text"))+'<button role="button" tabindex="-1"><i class="'+t+"ico "+t+'i-help"><\/i><\/button><\/div><\/div>'},bindStates:function(){var n=this;return n.state.on("change:text",function(t){n.getEl("body").firstChild.data=n.encode(t.value);n.state.get("rendered")&&n.updateLayoutRect()}),n.state.on("change:help",function(t){n.classes.toggle("has-help",t.value);n.state.get("rendered")&&n.updateLayoutRect()}),n._super()}})});i(de,[o,l],function(n,t){return n.extend({init:function(n){var t=this;t._super(n);t.classes.add("widget").add("label");t.canFocus=!1;n.multiline&&t.classes.add("autoscroll");n.strong&&t.classes.add("strong")},initLayoutRect:function(){var i=this,n=i._super(),r;return i.settings.multiline&&(r=t.getSize(i.getEl()),r.width>n.maxW&&(n.minW=n.maxW,i.classes.add("multiline")),i.getEl().style.width=n.minW+"px",n.startMinH=n.h=n.minH=Math.min(n.maxH,t.getSize(i.getEl()).height)),n},repaint:function(){var n=this;return n.settings.multiline||(n.getEl().style.lineHeight=n.layoutRect().h+"px"),n._super()},severity:function(n){this.classes.remove("error");this.classes.remove("warning");this.classes.remove("success");this.classes.add(n)},renderHtml:function(){var n=this,i,r,t=n.settings.forId;return!t&&(r=n.settings.forName)&&(i=n.getRoot().find("#"+r)[0],i&&(t=i._id)),t?'<label id="'+n._id+'" class="'+n.classes+'"'+(t?' for="'+t+'"':"")+">"+n.encode(n.state.get("text"))+"<\/label>":'<span id="'+n._id+'" class="'+n.classes+'">'+n.encode(n.state.get("text"))+"<\/span>"},bindStates:function(){var n=this;return n.state.on("change:text",function(t){n.innerHtml(n.encode(t.value));n.state.get("rendered")&&n.updateLayoutRect()}),n._super()}})});i(su,[it],function(n){return n.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(n){var t=this;t._super(n);t.classes.add("toolbar")},postRender:function(){var n=this;return n.items().each(function(n){n.classes.add("toolbar-item")}),n._super()}})});i(hu,[su],function(n){return n.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}})});i(yi,[ai,lt,hu],function(n,t,i){function u(n,t){for(;n;){if(t===n)return!0;n=n.parentNode}return!1}var r=n.extend({init:function(n){var t=this;t._renderOpen=!0;t._super(n);n=t.settings;t.classes.add("menubtn");n.fixedWidth&&t.classes.add("fixed-width");t.aria("haspopup",!0);t.state.set("menu",n.menu||t.render())},showMenu:function(){var n=this,i;return n.menu&&n.menu.visible()?n.hideMenu():(n.menu||(i=n.state.get("menu")||[],i.length?i={type:"menu",items:i}:i.type=i.type||"menu",n.menu=i.renderTo?i.parent(n).show().renderTo():t.create(i).parent(n).renderTo(),n.fire("createmenu"),n.menu.reflow(),n.menu.on("cancel",function(t){t.control.parent()===n.menu&&(t.stopPropagation(),n.focus(),n.hideMenu())}),n.menu.on("select",function(){n.focus()}),n.menu.on("show hide",function(t){t.control==n.menu&&n.activeMenu("show"==t.type);n.aria("expanded","show"==t.type)}).fire("show")),n.menu.show(),n.menu.layoutRect({w:n.layoutRect().w}),void n.menu.moveRel(n.getEl(),n.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]))},hideMenu:function(){var n=this;n.menu&&(n.menu.items().each(function(n){n.hideMenu&&n.hideMenu()}),n.menu.hide())},activeMenu:function(n){this.classes.toggle("active",n)},renderHtml:function(){var n=this,f=n._id,u=n.classPrefix,r=n.settings.icon,t,e=n.state.get("text"),o="";return t=n.settings.image,t?(r="none","string"!=typeof t&&(t=window.getSelection?t[0]:t[1]),t=" style=\"background-image: url('"+t+"')\""):t="",e&&(n.classes.add("btn-has-text"),o='<span class="'+u+'txt">'+n.encode(e)+"<\/span>"),r=n.settings.icon?u+"ico "+u+"i-"+r:"",n.aria("role",n.parent()instanceof i?"menuitem":"button"),'<div id="'+f+'" class="'+n.classes+'" tabindex="-1" aria-labelledby="'+f+'"><button id="'+f+'-open" role="presentation" type="button" tabindex="-1">'+(r?'<i class="'+r+'"'+t+"><\/i>":"")+o+' <i class="'+u+'caret"><\/i><\/button><\/div>'},postRender:function(){var n=this;return n.on("click",function(t){t.control===n&&u(t.target,n.getEl())&&(n.showMenu(),t.aria&&n.menu.items()[0].focus())}),n.on("mouseenter",function(t){var i=t.control,u=n.parent(),f;i&&u&&i instanceof r&&i.parent()==u&&(u.items().filter("MenuButton").each(function(n){n.hideMenu&&n!=i&&(n.menu&&n.menu.visible()&&(f=!0),n.hideMenu())}),f&&(i.focus(),i.showMenu()))}),n._super()},bindStates:function(){var n=this;return n.state.on("change:menu",function(){n.menu&&n.menu.remove();n.menu=null}),n._super()},remove:function(){this._super();this.menu&&this.menu.remove()}});return r});i(cu,[o,lt,u,f],function(n,t,i,r){return n.extend({Defaults:{border:0,role:"menuitem"},init:function(n){var t=this,i;t._super(n);n=t.settings;t.classes.add("menu-item");n.menu&&t.classes.add("menu-item-expand");n.preview&&t.classes.add("menu-item-preview");i=t.state.get("text");"-"!==i&&"|"!==i||(t.classes.add("menu-item-sep"),t.aria("role","separator"),t.state.set("text","-"));n.selectable&&(t.aria("role","menuitemcheckbox"),t.classes.add("menu-item-checkbox"),n.icon="selected");n.preview||n.selectable||t.classes.add("menu-item-normal");t.on("mousedown",function(n){n.preventDefault()});n.menu&&!n.ariaHideMenu&&t.aria("haspopup",!0)},hasMenus:function(){return!!this.settings.menu},showMenu:function(){var i=this,f=i.settings,n,u=i.parent(),r;(u.items().each(function(n){n!==i&&n.hideMenu()}),f.menu)&&(n=i.menu,n?n.show():(n=f.menu,n.length?n={type:"menu",items:n}:n.type=n.type||"menu",u.settings.itemDefaults&&(n.itemDefaults=u.settings.itemDefaults),n=i.menu=t.create(n).parent(i).renderTo(),n.reflow(),n.on("cancel",function(t){t.stopPropagation();i.focus();n.hide()}),n.on("show hide",function(n){n.control.items().each(function(n){n.active(n.settings.selected)})}).fire("show"),n.on("hide",function(t){t.control===n&&i.classes.remove("selected")}),n.submenu=!0),n._parentMenu=u,n.classes.add("menu-sub"),r=n.testMoveRel(i.getEl(),i.isRtl()?["tl-tr","bl-br","tr-tl","br-bl"]:["tr-tl","br-bl","tl-tr","bl-br"]),n.moveRel(i.getEl(),r),n.rel=r,r="menu-sub-"+r,n.classes.remove(n._lastRel).add(r),n._lastRel=r,i.classes.add("selected"),i.aria("expanded",!0))},hideMenu:function(){var n=this;return n.menu&&(n.menu.items().each(function(n){n.hideMenu&&n.hideMenu()}),n.menu.hide(),n.aria("expanded",!1)),n},renderHtml:function(){function h(n){var t,r,u={};for(u=i.mac?{alt:"&#x2325;",ctrl:"&#x2318;",shift:"&#x21E7;",meta:"&#x2318;"}:{meta:"Ctrl"},n=n.split("+"),t=0;t<n.length;t++)r=u[n[t].toLowerCase()],r&&(n[t]=r);return n.join("+")}var n=this,f=n._id,u=n.settings,t=n.classPrefix,e=n.encode(n.state.get("text")),o=n.settings.icon,s="",r=u.shortcut;return o&&n.parent().classes.add("menu-has-icons"),u.image&&(s=" style=\"background-image: url('"+u.image+"')\""),r&&(r=h(r)),o=t+"ico "+t+"i-"+(n.settings.icon||"none"),'<div id="'+f+'" class="'+n.classes+'" tabindex="-1">'+("-"!==e?'<i class="'+o+'"'+s+"><\/i> ":"")+("-"!==e?'<span id="'+f+'-text" class="'+t+'text">'+e+"<\/span>":"")+(r?'<div id="'+f+'-shortcut" class="'+t+'menu-shortcut">'+r+"<\/div>":"")+(u.menu?'<div class="'+t+'caret"><\/div>':"")+"<\/div>"},postRender:function(){var n=this,u=n.settings,t=u.textStyle,i;return("function"==typeof t&&(t=t.call(this)),t)&&(i=n.getEl("text"),i&&i.setAttribute("style",t)),n.on("mouseenter click",function(t){t.control===n&&(u.menu||"click"!==t.type?(n.showMenu(),t.aria&&n.menu.focus(!0)):(n.fire("select"),r.requestAnimationFrame(function(){n.parent().hideAll()})))}),n._super(),n},hover:function(){var n=this;return n.parent().items().each(function(n){n.classes.remove("selected")}),n.classes.toggle("selected",!0),n},active:function(n){return"undefined"!=typeof n&&this.aria("checked",n),this._super(n)},remove:function(){this._super();this.menu&&this.menu.remove()}})});i(lu,[s,b,f],function(n,t,i){return function(r,u){var f=this,e,o=t.classPrefix,s;f.show=function(t,h){function c(){e&&(n(r).append('<div class="'+o+"throbber"+(u?" "+o+"throbber-inline":"")+'"><\/div>'),h&&h())}return f.hide(),e=!0,t?s=i.setTimeout(c,t):c(),f};f.hide=function(){var n=r.lastChild;return i.clearTimeout(s),n&&-1!=n.className.indexOf("throbber")&&n.parentNode.removeChild(n),e=!1,f}}});i(au,[at,cu,lu,r],function(n,t,i,r){return n.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(n){var u=this,t,i;if(n.autohide=!0,n.constrainToViewport=!0,"function"==typeof n.items&&(n.itemsFactory=n.items,n.items=[]),n.itemDefaults)for(t=n.items,i=t.length;i--;)t[i]=r.extend({},n.itemDefaults,t[i]);u._super(n);u.classes.add("menu")},repaint:function(){return this.classes.toggle("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){var n=this;n.hideAll();n.fire("select")},load:function(){function t(){n.throbber&&(n.throbber.hide(),n.throbber=null)}var n=this,r,u;u=n.settings.itemsFactory;u&&(n.throbber||(n.throbber=new i(n.getEl("body"),!0),0===n.items().length?(n.throbber.show(),n.fire("loading")):n.throbber.show(100,function(){n.items().remove();n.fire("loading")}),n.on("hide close",t)),n.requestTime=r=(new Date).getTime(),n.settings.itemsFactory(function(i){return 0===i.length?void n.hide():void(n.requestTime===r&&(n.getEl().style.width="",n.getEl("body").style.width="",t(),n.items().remove(),n.getEl("body").innerHTML="",n.add(i),n.renderNew(),n.fire("loaded")))}))},hideAll:function(){var n=this;return this.find("menuitem").exec("hideMenu"),n._super()},preRender:function(){var n=this;return n.items().each(function(t){var i=t.settings;if(i.icon||i.image||i.selectable)return(n._hasIcons=!0,!1)}),n.settings.itemsFactory&&n.on("postrender",function(){n.settings.itemsFactory&&n.load()}),n._super()}})});i(ge,[yi,au],function(n,t){return n.extend({init:function(n){function f(i){for(var u=0;u<i.length;u++){if(e=i[u].selected||n.value===i[u].value)return r=r||i[u].text,t.state.set("value",i[u].value),!0;if(i[u].menu&&f(i[u].menu))return!0}}var t=this,i,e,r,u;t._super(n);n=t.settings;t._values=i=n.values;i&&("undefined"!=typeof n.value&&f(i),!e&&i.length>0&&(r=i[0].text,t.state.set("value",i[0].value)),t.state.set("menu",i));t.state.set("text",n.text||r);t.classes.add("listbox");t.on("select",function(i){var r=i.control;u&&(i.lastControl=u);n.multiple?r.active(!r.active()):t.value(i.control.value());u=r})},bindStates:function(){function r(n,i){n instanceof t&&n.items().each(function(n){n.hasMenus()||n.active(n.value()===i)})}function i(n,t){var u,r;if(n)for(r=0;r<n.length;r++){if(n[r].value===t)return n[r];if(n[r].menu&&(u=i(n[r].menu,t)))return u}}var n=this;return n.on("show",function(t){r(t.control,n.value())}),n.state.on("change:value",function(t){var r=i(n.state.get("menu"),t.value);r?n.text(r.text):n.text(n.settings.text)}),n._super()}})});i(no,[tu],function(n){return n.extend({Defaults:{classes:"radio",role:"radio"}})});i(to,[o,rt],function(n,t){return n.extend({renderHtml:function(){var n=this,t=n.classPrefix;return n.classes.add("resizehandle"),"both"==n.settings.direction&&n.classes.add("resizehandle-both"),n.canFocus=!1,'<div id="'+n._id+'" class="'+n.classes+'"><i class="'+t+"ico "+t+'i-resize"><\/i><\/div>'},postRender:function(){var n=this;n._super();n.resizeDragHelper=new t(this._id,{start:function(){n.fire("ResizeStart")},drag:function(t){"both"!=n.settings.direction&&(t.deltaX=0);n.fire("Resize",t)},stop:function(){n.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}})});i(io,[o],function(n){function t(n){var i="",t;if(n)for(t=0;t<n.length;t++)i+='<option value="'+n[t]+'">'+n[t]+"<\/option>";return i}return n.extend({Defaults:{classes:"selectbox",role:"selectbox",options:[]},init:function(n){var t=this;t._super(n);t.settings.size&&(t.size=t.settings.size);t.settings.options&&(t._options=t.settings.options);t.on("keydown",function(n){var i;13==n.keyCode&&(n.preventDefault(),t.parents().reverse().each(function(n){if(n.toJSON)return(i=n,!1)}),t.fire("submit",{data:i.toJSON()}))})},options:function(n){return arguments.length?(this.state.set("options",n),this):this.state.get("options")},renderHtml:function(){var n=this,i,r="";return i=t(n._options),n.size&&(r=' size = "'+n.size+'"'),'<select id="'+n._id+'" class="'+n.classes+'"'+r+">"+i+"<\/select>"},bindStates:function(){var n=this;return n.state.on("change:options",function(i){n.getEl().innerHTML=t(i.value)}),n._super()}})});i(ro,[o,rt,l],function(n,t,i){function u(n,t,i){return t>n&&(n=t),n>i&&(n=i),n}function r(n,t,i){n.setAttribute("aria-"+t,i)}function f(n,t){var s,f,e,o,h,u;"v"==n.settings.orientation?(o="top",e="height",f="h"):(o="left",e="width",f="w");u=n.getEl("handle");s=(n.layoutRect()[f]||100)-i.getSize(u)[e];h=s*((t-n._minValue)/(n._maxValue-n._minValue))+"px";u.style[o]=h;u.style.height=n.layoutRect().h+"px";r(u,"valuenow",t);r(u,"valuetext",""+n.settings.previewFilter(t));r(u,"valuemin",n._minValue);r(u,"valuemax",n._maxValue)}return n.extend({init:function(n){var t=this;n.previewFilter||(n.previewFilter=function(n){return Math.round(100*n)/100});t._super(n);t.classes.add("slider");"v"==n.orientation&&t.classes.add("vertical");t._minValue=n.minValue||0;t._maxValue=n.maxValue||100;t._initValue=t.state.get("value")},renderHtml:function(){var n=this,t=n._id,i=n.classPrefix;return'<div id="'+t+'" class="'+n.classes+'"><div id="'+t+'-handle" class="'+i+'slider-handle" role="slider" tabindex="-1"><\/div><\/div>'},reset:function(){this.value(this._initValue).repaint()},postRender:function(){function c(n,t,i){return(i+n)/(t-n)}function l(n,t,i){return i*(t-n)-n}function a(t,i){function r(r){var f;f=n.value();f=l(t,i,c(t,i,f)+.05*r);f=u(f,t,i);n.value(f);n.fire("dragstart",{value:f});n.fire("drag",{value:f});n.fire("dragend",{value:f})}n.on("keydown",function(n){switch(n.keyCode){case 37:case 38:r(-1);break;case 39:case 40:r(1)}})}function v(e,o,c){var y,p,a,v,l;n._dragHelper=new t(n._id,{handle:n._id+"-handle",start:function(t){y=t[r];p=parseInt(n.getEl("handle").style[f],10);a=(n.layoutRect()[h]||100)-i.getSize(c)[s];n.fire("dragstart",{value:l})},drag:function(t){var i=t[r]-y;v=u(p+i,0,a);c.style[f]=v+"px";l=e+v/a*(o-e);n.value(l);n.tooltip().text(""+n.settings.previewFilter(l)).show().moveRel(c,"bc tc");n.fire("drag",{value:l})},stop:function(){n.tooltip().hide();n.fire("dragend",{value:l})}})}var n=this,e,o,r,f,s,h;e=n._minValue;o=n._maxValue;"v"==n.settings.orientation?(r="screenY",f="top",s="height",h="h"):(r="screenX",f="left",s="width",h="w");n._super();a(e,o,n.getEl("handle"));v(e,o,n.getEl("handle"))},repaint:function(){this._super();f(this,this.value())},bindStates:function(){var n=this;return n.state.on("change:value",function(t){f(n,t.value)}),n._super()}})});i(uo,[o],function(n){return n.extend({renderHtml:function(){var n=this;return n.classes.add("spacer"),n.canFocus=!1,'<div id="'+n._id+'" class="'+n.classes+'"><\/div>'}})});i(fo,[yi,l,s],function(n,t,i){return n.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var n=this,f=n.getEl(),r=n.layoutRect(),e,u;return n._super(),e=f.firstChild,u=f.lastChild,i(e).css({width:r.w-t.getSize(u).width,height:r.h-2}),i(u).css({height:r.h-2}),n},activeMenu:function(n){var t=this;i(t.getEl().lastChild).toggleClass(t.classPrefix+"active",n)},renderHtml:function(){var n=this,e=n._id,r=n.classPrefix,t,i=n.state.get("icon"),u=n.state.get("text"),f="";return t=n.settings.image,t?(i="none","string"!=typeof t&&(t=window.getSelection?t[0]:t[1]),t=" style=\"background-image: url('"+t+"')\""):t="",i=n.settings.icon?r+"ico "+r+"i-"+i:"",u&&(n.classes.add("btn-has-text"),f='<span class="'+r+'txt">'+n.encode(u)+"<\/span>"),'<div id="'+e+'" class="'+n.classes+'" role="button" tabindex="-1"><button type="button" hidefocus="1" tabindex="-1">'+(i?'<i class="'+i+'"'+t+"><\/i>":"")+f+'<\/button><button type="button" class="'+r+'open" hidefocus="1" tabindex="-1">'+(n._menuBtnText?(i?" ":"")+n._menuBtnText:"")+' <i class="'+r+'caret"><\/i><\/button><\/div>'},postRender:function(){var n=this,t=n.settings.onclick;return n.on("click",function(n){var i=n.target;if(n.control==this)for(;i;){if(n.aria&&"down"!=n.aria.key||"BUTTON"==i.nodeName&&-1==i.className.indexOf("open"))return n.stopImmediatePropagation(),void(t&&t.call(this,n));i=i.parentNode}}),delete n.settings.onclick,n._super()}})});i(eo,[ou],function(n){return n.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"},isNative:function(){return!0}})});i(oo,[bt,s,l],function(n,t,i){return n.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(n){var i;this.activeTabId&&(i=this.getEl(this.activeTabId),t(i).removeClass(this.classPrefix+"active"),i.setAttribute("aria-selected","false"));this.activeTabId="t"+n;i=this.getEl("t"+n);i.setAttribute("aria-selected","true");t(i).addClass(this.classPrefix+"active");this.items()[n].show().fire("showtab");this.reflow();this.items().each(function(t,i){n!=i&&t.hide()})},renderHtml:function(){var n=this,t=n._layout,i="",r=n.classPrefix;return n.preRender(),t.preRender(n),n.items().each(function(t,u){var f=n._id+"-t"+u;t.aria("role","tabpanel");t.aria("labelledby",f);i+='<div id="'+f+'" class="'+r+'tab" unselectable="on" role="tab" aria-controls="'+t._id+'" aria-selected="false" tabIndex="-1">'+n.encode(t.settings.title)+"<\/div>"}),'<div id="'+n._id+'" class="'+n.classes+'" hidefocus="1" tabindex="-1"><div id="'+n._id+'-head" class="'+r+'tabs" role="tablist">'+i+'<\/div><div id="'+n._id+'-body" class="'+n.bodyClasses+'">'+t.renderHtml(n)+"<\/div><\/div>"},postRender:function(){var n=this;n._super();n.settings.activeTab=n.settings.activeTab||0;n.activateTab(n.settings.activeTab);this.on("click",function(t){var r=t.target.parentNode,i;if(t.target.parentNode.id==n._id+"-head")for(i=r.childNodes.length;i--;)r.childNodes[i]==t.target&&n.activateTab(i)})},initLayoutRect:function(){var t=this,r,n,u,f;return n=i.getSize(t.getEl("head")).width,n=0>n?0:n,u=0,t.items().each(function(t){n=Math.max(n,t.layoutRect().minW);u=Math.max(u,t.layoutRect().minH)}),t.items().each(function(t){t.settings.x=0;t.settings.y=0;t.settings.w=n;t.settings.h=u;t.layoutRect({x:0,y:0,w:n,h:u})}),f=i.getSize(t.getEl("head")).height,t.settings.minWidth=n,t.settings.minHeight=u+f,r=t._super(),r.deltaH+=f,r.innerH=r.h-r.deltaH,r}})});i(so,[o,r,l],function(n,t,i){return n.extend({init:function(n){var t=this;t._super(n);t.classes.add("textbox");n.multiline?t.classes.add("multiline"):(t.on("keydown",function(n){var i;13==n.keyCode&&(n.preventDefault(),t.parents().reverse().each(function(n){if(n.toJSON)return(i=n,!1)}),t.fire("submit",{data:i.toJSON()}))}),t.on("keyup",function(n){t.state.set("value",n.target.value)}))},repaint:function(){var i=this,r,n,u,o,e=0,t,f;return r=i.getEl().style,n=i._layoutRect,t=i._lastRepaintRect||{},f=document,!i.settings.multiline&&f.all&&(!f.documentMode||f.documentMode<=8)&&(r.lineHeight=n.h-e+"px"),u=i.borderBox,o=u.left+u.right+8,e=u.top+u.bottom+(i.settings.multiline?8:0),n.x!==t.x&&(r.left=n.x+"px",t.x=n.x),n.y!==t.y&&(r.top=n.y+"px",t.y=n.y),n.w!==t.w&&(r.width=n.w-o+"px",t.w=n.w),n.h!==t.h&&(r.height=n.h-e+"px",t.h=n.h),i._lastRepaintRect=t,i.fire("repaint",{},!1),i},renderHtml:function(){var n=this,u=n.settings,r,f;return r={id:n._id,hidefocus:"1"},t.each(["rows","spellcheck","maxLength","size","readonly","min","max","step","list","pattern","placeholder","required","multiple"],function(n){r[n]=u[n]}),n.disabled()&&(r.disabled="disabled"),u.subtype&&(r.type=u.subtype),f=i.create(u.multiline?"textarea":"input",r),f.value=n.state.get("value"),f.className=n.classes,f.outerHTML},value:function(n){return arguments.length?(this.state.set("value",n),this):(this.state.get("rendered")&&this.state.set("value",this.getEl().value),this.state.get("value"))},postRender:function(){var n=this;n.getEl().value=n.state.get("value");n._super();n.$el.on("change",function(t){n.state.set("value",t.target.value);n.fire("change",t)})},bindStates:function(){var n=this;return n.state.on("change:value",function(t){n.getEl().value!=t.value&&(n.getEl().value=t.value)}),n.state.on("change:disabled",function(t){n.getEl().disabled=t.value}),n._super()},remove:function(){this.$el.off();this._super()}})});i("tinymce/Register",[],function(){var n=this||window,t=function(){return n.tinymce};return"function"==typeof n.define&&(n.define.amd||n.define("ephox/tinymce",[],t)),{}});lo([vu,k,f,u,ft,ni,r,s,pi,p,d,h,vt,ti,y,et,g,ri,ui,wi,yt,bi,ot,ki,pt,di,nr,tr,ir,fi,tt,ei,ct,oi,si,hi,b,lt,fr,it,rt,er,bt,kt,or,at,ci,sr,hr,cr,o,lr,ar,vr,yr,pr,br,kr,dr,dt,gr,nu,ie,re,ue,fe,li,gt,ai,ee,tu,vi,oe,iu,se,ru,he,uu,ce,fu,eu,le,ae,ve,ye,ou,pe,we,be,ke,de,su,hu,yi,cu,lu,au,ge,no,to,io,ro,uo,fo,eo,oo,so])}(this);tinymce.ThemeManager.add("modern",function(n){function s(t,i){var r,u=[];if(t)return f(t.split(/[ ,]/),function(t){function o(){function r(n){return function(i,r){for(var u,f=r.parents.length;f--&&(u=r.parents[f].nodeName,"OL"!=u&&"UL"!=u););t.active(i&&u==n)}}var i=n.selection;"bullist"==f&&i.selectorChanged("ul > li",r("UL"));"numlist"==f&&i.selectorChanged("ol > li",r("OL"));t.settings.stateSelector&&i.selectorChanged(t.settings.stateSelector,function(n){t.active(n)},!0);t.settings.disabledStateSelector&&i.selectorChanged(t.settings.disabledStateSelector,function(n){t.disabled(n)})}var f;"|"==t?r=null:e.has(t)?(t={type:t,size:i},u.push(t),r=null):(r||(r={type:"buttongroup",items:[]},u.push(r)),n.buttons[t]&&(f=t,t=n.buttons[f],"function"==typeof t&&(t=t()),t.type=t.type||"button",t.size=i,t=e.create(t),r.items.push(t),n.initialized?o():n.on("init",o)))}),{type:"toolbar",layout:"flow",items:u}}function h(n){function u(t){if(t)return(i.push(s(t,n)),!0)}var i=[],r;if(tinymce.isArray(t.toolbar)){if(0===t.toolbar.length)return;tinymce.each(t.toolbar,function(n,i){t["toolbar"+(i+1)]=n});delete t.toolbar}for(r=1;10>r&&u(t["toolbar"+r]);r++);return i.length||t.toolbar===!1||u(t.toolbar||d),i.length?{type:"panel",layout:"stack",classes:"toolbar-grp",ariaRoot:!0,ariaRemember:!0,items:i}:void 0}function c(){function s(t){var i;return"|"==t?{text:"|"}:i=n.menuItems[t]}function c(i){var o,e,r,h,c,u;if(c=tinymce.makeMap((t.removed_menuitems||"").split(/[ ,]/)),t.menu?(e=t.menu[i],h=!0):e=y[i],e){for(o={text:e.title},r=[],f((e.items||"").split(/[ ,]/),function(n){var t=s(n);t&&!c[n]&&r.push(s(n))}),h||f(n.menuItems,function(n){n.context==i&&("before"==n.separator&&r.push({text:"|"}),n.prependToContext?r.unshift(n):r.push(n),"after"==n.separator&&r.push({text:"|"}))}),u=0;u<r.length;u++)"|"==r[u].text&&(0!==u&&u!=r.length-1||r.splice(u,1));if(o.menu=r,!o.menu.length)return null}return o}var r,h=[],e=[],o,u,i;if(t.menu)for(r in t.menu)e.push(r);else for(r in y)e.push(r);for(o="string"==typeof t.menubar?t.menubar.split(/[ ,]/):e,u=0;u<o.length;u++)i=o[u],i=c(i),i&&h.push(i);return h}function l(t){function i(n){var i=t.find(n)[0];i&&i.focus(!0)}n.shortcuts.add("Alt+F9","",function(){i("menubar")});n.shortcuts.add("Alt+F10","",function(){i("toolbar")});n.shortcuts.add("Alt+F11","",function(){i("elementpath")});t.on("cancel",function(){n.focus()})}function o(i,u){function o(n){return{width:n.clientWidth,height:n.clientHeight}}var e,f,s,h;e=n.getContainer();f=n.getContentAreaContainer().firstChild;s=o(e);h=o(f);null!==i&&(i=Math.max(t.min_width||100,i),i=Math.min(t.max_width||65535,i),r.setStyle(e,"width",i+(s.width-h.width)),r.setStyle(f,"width",i));u=Math.max(t.min_height||100,u);u=Math.min(t.max_height||65535,u);r.setStyle(f,"height",u);n.fire("ResizeEditor")}function p(t,r){var u=n.getContentAreaContainer();i.resizeTo(u.clientWidth+t,u.clientHeight+r)}function a(){function o(){return n.contextToolbars||[]}function p(t){var u,i,r;return u=tinymce.DOM.getPos(n.getContentAreaContainer()),i=n.dom.getRect(t),r=n.dom.getRoot(),"BODY"==r.nodeName&&(i.x-=r.ownerDocument.documentElement.scrollLeft||r.scrollLeft,i.y-=r.ownerDocument.documentElement.scrollTop||r.scrollTop),i.x+=u.x,i.y+=u.y,i}function w(){f(n.contextToolbars,function(n){n.panel&&n.panel.hide()})}function b(n,t,i){t=t?t.substr(0,2):"";f({t:"down",b:"up"},function(r,u){n.classes.toggle("arrow-"+r,i(u,t.substr(0,1)))});f({l:"left",r:"right"},function(r,u){n.classes.toggle("arrow-"+r,i(u,t.substr(1,1)))})}function h(n){return{left:n.x,top:n.y,width:n.w,height:n.h,right:n.x+n.w,bottom:n.y+n.h}}function c(n,i,r,u,f){return f=h({x:n,y:i,w:f.w,h:f.h}),t.inline_toolbar_position_handler&&(f=t.inline_toolbar_position_handler({elementRect:h(r),contentAreaRect:h(u),panelRect:f})),f}function l(n,t){n.moveTo(t.left,t.top)}function a(t){var o,f,i,r,e,s,h,a;if(!n.removed){if(!t||!t.toolbar.panel)return void w();h=["bc-tc","tc-bc","tl-bl","bl-tl","tr-br","br-tr"];e=t.toolbar.panel;e.show();i=p(t.element);f=tinymce.DOM.getRect(e.getEl());r=tinymce.DOM.getRect(n.getContentAreaContainer()||n.getBody());a=25;i.w=t.element.clientWidth;i.h=t.element.clientHeight;n.inline||(r.w=n.getDoc().documentElement.offsetWidth);n.selection.controlSelection.isResizable(t.element)&&i.w<a&&(i=u.inflate(i,0,8));o=u.findBestRelativePosition(f,i,r,h);i=u.clamp(i,r);o?(s=u.relativePosition(f,i,o),l(e,c(s.x,s.y,i,r,f))):(r.h+=f.h,i=u.intersect(r,i),i?(o=u.findBestRelativePosition(f,i,r,["bc-tc","bl-tl","br-tr"]),o?(s=u.relativePosition(f,i,o),l(e,c(s.x,s.y,i,r,f))):l(e,c(i.x,i.y,i,r,f))):e.hide());b(e,o,function(n,t){return n===t})}}function y(){function t(){n.selection&&a(i(n.selection.getNode()))}tinymce.util.Delay.requestAnimationFrame(t)}function k(){r||(r=n.selection.getScrollContainer()||n.getWin(),tinymce.$(r).on("scroll",y),n.on("remove",function(){tinymce.$(r).off("scroll")}))}function d(t){var i;return t.toolbar.panel?(t.toolbar.panel.show(),void a(t)):(k(),i=e.create({type:"floatpanel",role:"dialog",classes:"tinymce tinymce-inline arrow",ariaLabel:"Inline toolbar",layout:"flex",direction:"column",align:"stretch",autohide:!1,autofix:!0,fixed:!0,border:1,items:s(t.toolbar.items),oncancel:function(){n.focus()}}),t.toolbar.panel=i,i.renderTo(document.body).reflow(),void a(t))}function v(){tinymce.each(o(),function(n){n.panel&&n.panel.hide()})}function i(t){for(var r,f=o(),u=n.$(t).parents().add(t),i=u.length-1;i>=0;i--)for(r=f.length-1;r>=0;r--)if(f[r].predicate(u[i]))return{toolbar:f[r],element:u[i]};return null}var r;n.on("click keyup setContent",function(t){("setcontent"!=t.type||t.selection)&&tinymce.util.Delay.setEditorTimeout(n,function(){var t;t=i(n.selection.getNode());t?(v(),d(t)):v()})});n.on("blur hide",v);n.on("ObjectResizeStart",function(){var t=i(n.selection.getNode());t&&t.toolbar.panel&&t.toolbar.panel.hide()});n.on("nodeChange ResizeEditor ResizeWindow",y);n.on("remove",function(){tinymce.each(o(),function(n){n.panel&&n.panel.remove()});n.contextToolbars={}});n.shortcuts.add("ctrl+shift+e > ctrl+shift+p","",function(){var t=i(n.selection.getNode());t&&t.toolbar.panel&&t.toolbar.panel.items()[0].focus()})}function v(n){return function(){n.initialized?n.fire("SkinLoaded"):n.on("init",function(){n.fire("SkinLoaded")})}}function w(u){function p(){var t,i;if(f&&f.moveRel&&f.visible()&&!f._fixed){var u=n.selection.getScrollContainer(),e=n.getBody(),o=0,s=0;u&&(t=r.getPos(e),i=r.getPos(u),o=Math.max(0,i.x-t.x),s=Math.max(0,i.y-t.y));f.fixed(!1).moveRel(e,n.rtl?["tr-br","br-tr"]:["tl-bl","bl-tl","tr-br"]).moveBy(o,s)}}function s(){f&&(f.show(),p(),r.addClass(n.getBody(),"mce-edit-focus"))}function w(){f&&(f.hide(),k.hideAll(),r.removeClass(n.getBody(),"mce-edit-focus"))}function y(){return f?void(f.visible()||s()):(f=i.panel=e.create({type:o?"panel":"floatpanel",role:"application",classes:"tinymce tinymce-inline",layout:"flex",direction:"column",align:"stretch",autohide:!1,autofix:!0,fixed:!!o,border:1,items:[t.menubar===!1?null:{type:"menubar",border:"0 0 1 0",items:c()},h(t.toolbar_items_size)]}),n.fire("BeforeRenderUI"),f.renderTo(o||document.body).reflow(),l(f),s(),a(),n.on("nodeChange",p),n.on("activate",s),n.on("deactivate",w),void n.nodeChanged())}var f,o;return t.fixed_toolbar_container&&(o=r.select(t.fixed_toolbar_container)[0]),t.content_editable=!0,n.on("focus",function(){u.skinUiCss?tinymce.DOM.styleSheetLoader.load(u.skinUiCss,y,y):y()}),n.on("blur hide",w),n.on("remove",function(){f&&(f.remove(),f=null)}),u.skinUiCss&&tinymce.DOM.styleSheetLoader.load(u.skinUiCss,v(n)),{}}function b(r){function y(){return function(n){"readonly"==n.mode?u.find("*").disabled(!0):u.find("*").disabled(!1)}}var u,s,f;return r.skinUiCss&&tinymce.DOM.styleSheetLoader.load(r.skinUiCss,v(n)),u=i.panel=e.create({type:"panel",role:"application",classes:"tinymce",style:"visibility: hidden",layout:"stack",border:1,items:[t.menubar===!1?null:{type:"menubar",border:"0 0 1 0",items:c()},h(t.toolbar_items_size),{type:"panel",name:"iframe",layout:"stack",classes:"edit-area",html:"",border:"1 0 0 0"}]}),t.resize!==!1&&(s={type:"resizehandle",direction:t.resize,onResizeStart:function(){var t=n.getContentAreaContainer().firstChild;f={width:t.clientWidth,height:t.clientHeight}},onResize:function(n){"both"==t.resize?o(f.width+n.deltaX,f.height+n.deltaY):o(null,f.height+n.deltaY)}}),t.statusbar!==!1&&u.add({type:"panel",name:"statusbar",classes:"statusbar",layout:"flow",border:"1 0 0 0",ariaRoot:!0,items:[{type:"elementpath"},s]}),n.fire("BeforeRenderUI"),n.on("SwitchMode",y()),u.renderBefore(r.targetNode).reflow(),t.readonly&&n.setMode("readonly"),t.width&&tinymce.DOM.setStyle(u.getEl(),"width",t.width),n.on("remove",function(){u.remove();u=null}),l(u),a(),{iframeContainer:u.find("#iframe")[0].getEl(),editorContainer:u.getEl()}}var i=this,t=n.settings,e=tinymce.ui.Factory,f=tinymce.each,r=tinymce.DOM,u=tinymce.geom.Rect,k=tinymce.ui.FloatPanel,y={file:{title:"File",items:"newdocument"},edit:{title:"Edit",items:"undo redo | cut copy paste pastetext | selectall"},insert:{title:"Insert",items:"|"},view:{title:"View",items:"visualaid |"},format:{title:"Format",items:"bold italic underline strikethrough superscript subscript | formats | removeformat"},table:{title:"Table"},tools:{title:"Tools"}},d="undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image";i.renderUI=function(r){var f=t.skin!==!1?t.skin||"lightgray":!1,u;return f&&(u=t.skin_url,u=u?n.documentBaseURI.toAbsolute(u):tinymce.baseURL+"/skins/"+f,r.skinUiCss=tinymce.Env.documentMode<=7?u+"/skin.ie7.min.css":u+"/skin.min.css",n.contentCSS.push(u+"/content"+(n.inline?".inline":"")+".min.css")),n.on("ProgressState",function(n){i.throbber=i.throbber||new tinymce.ui.Throbber(i.panel.getEl("body"));n.state?i.throbber.show(n.time):i.throbber.hide()}),t.inline?w(r):b(r)};i.resizeTo=o;i.resizeBy=p});tinymce.PluginManager.add("advlist",function(n){function i(n,t){var i=[];return tinymce.each(t.split(/[ ,]/),function(n){i.push({text:n.replace(/\-/g," ").replace(/\b\w/g,function(n){return n.toUpperCase()}),data:"default"==n?"":n})}),i}function t(t,i){n.undoManager.transact(function(){var r,u=n.dom,f=n.selection,o;(r=u.getParent(f.getNode(),"ol,ul"),r&&r.nodeName==t&&i!==!1)||(o={"list-style-type":i?i:null},n.execCommand("UL"==t?"InsertUnorderedList":"InsertOrderedList",!1,o));i=i===!1?e[t]:i;e[t]=i;r=u.getParent(f.getNode(),"ol,ul");r&&(u.setStyle(r,"listStyleType",i?i:null),r.removeAttribute("data-mce-style"));n.focus()})}function r(t){var i=n.dom.getStyle(n.dom.getParent(n.selection.getNode(),"ol,ul"),"listStyleType")||"";t.control.items().each(function(n){n.active(n.settings.data===i)})}var u,f,e={};u=i("OL",n.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman"));f=i("UL",n.getParam("advlist_bullet_styles","default,circle,disc,square"));n.addButton("numlist",{type:"splitbutton",tooltip:"Numbered list",menu:u,onshow:r,onselect:function(n){t("OL",n.control.settings.data)},onclick:function(){t("OL",!1)}});n.addButton("bullist",{type:"splitbutton",tooltip:"Bullet list",menu:f,onshow:r,onselect:function(n){t("UL",n.control.settings.data)},onclick:function(){t("UL",!1)}})});tinymce.PluginManager.add("code",function(n){function t(){var t=n.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:n.getParam("code_dialog_width",600),minHeight:n.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(t){n.focus();n.undoManager.transact(function(){n.setContent(t.data.code)});n.selection.setCursorLocation();n.nodeChanged()}});t.find("#code").value(n.getContent({source_view:!0}))}n.addCommand("mceCodeEditor",t);n.addButton("code",{icon:"code",tooltip:"Source code",onclick:t});n.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:t})});tinymce.PluginManager.add("colorpicker",function(n){function t(t,i){function u(n){var t=new tinymce.util.Color(n),i=t.toRgb();r.fromJSON({r:i.r,g:i.g,b:i.b,hex:t.toHex().substr(1)});f(t.toHex())}function f(n){r.find("#preview")[0].getEl().style.background=n}var r=n.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:i,onchange:function(){var n=this.rgb();r&&(r.find("#r").value(n.r),r.find("#g").value(n.g),r.find("#b").value(n.b),r.find("#hex").value(this.value().substr(1)),f(this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var t,n,i=r.find("colorpicker")[0];return t=this.name(),n=this.value(),"hex"==t?(n="#"+n,u(n),void i.value(n)):(n={r:r.find("#r").value(),g:r.find("#g").value(),b:r.find("#b").value()},i.value(n),void u(n))}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){t("#"+this.toJSON().hex)}});u(i)}n.settings.color_picker_callback||(n.settings.color_picker_callback=t)});!function(){function n(n){return n&&1==n.nodeType&&"false"===n.contentEditable}function t(t,i,r,u,f){function v(n,t){var i,r;if(t=t||0,!n[0])throw"findAndReplaceDOMText cannot handle zero-length matches";if(i=n.index,t>0){if(r=n[t],!r)throw"Invalid capture group";i+=n[0].indexOf(r);n[0]=r}return[i,i+n[0].length,[n[0]]]}function y(t){var i;if(3===t.nodeType)return t.data;if(l[t.nodeName]&&!o[t.nodeName])return"";if(i="",n(t))return"\n";if((o[t.nodeName]||a[t.nodeName])&&(i+="\n"),t=t.firstChild)do i+=y(t);while(t=t.nextSibling);return i}function w(t,i,r){var s,h,y,c,v=[],f=0,u=t,e=i.shift(),p=0;n:for(;;){if((o[u.nodeName]||a[u.nodeName]||n(u))&&f++,3===u.nodeType&&(!h&&u.length+f>=e[1]?(h=u,c=e[1]-f):s&&v.push(u),!s&&u.length+f>e[0]&&(s=u,y=e[0]-f),f+=u.length),s&&h){if(u=r({startNode:s,startNodeIndex:y,endNode:h,endNodeIndex:c,innerNodes:v,match:e[2],matchIndex:p}),f-=h.length-c,s=null,h=null,v=[],e=i.shift(),p++,!e)break}else if((!l[u.nodeName]||o[u.nodeName])&&u.firstChild){if(!n(u)){u=u.firstChild;continue}}else if(u.nextSibling){u=u.nextSibling;continue}for(;;){if(u.nextSibling){u=u.nextSibling;break}if(u.parentNode===t)break n;u=u.parentNode}}}function b(n){var t,i;return"function"!=typeof n?(i=n.nodeType?n:e.createElement(n),t=function(n,t){var r=i.cloneNode(!1);return r.setAttribute("data-mce-index",t),n&&r.appendChild(e.createTextNode(n)),r}):t=n,function(n){var o,s,i,u=n.startNode,f=n.endNode,h=n.matchIndex,r,l,c,v,y;if(u===f)return r=u,i=r.parentNode,n.startNodeIndex>0&&(o=e.createTextNode(r.data.substring(0,n.startNodeIndex)),i.insertBefore(o,r)),l=t(n.match[0],h),i.insertBefore(l,r),n.endNodeIndex<r.length&&(s=e.createTextNode(r.data.substring(n.endNodeIndex)),i.insertBefore(s,r)),r.parentNode.removeChild(r),l;o=e.createTextNode(u.data.substring(0,n.startNodeIndex));s=e.createTextNode(f.data.substring(n.endNodeIndex));for(var p=t(u.data.substring(n.startNodeIndex),h),w=[],a=0,b=n.innerNodes.length;b>a;++a)c=n.innerNodes[a],v=t(c.data,h),c.parentNode.replaceChild(v,c),w.push(v);return y=t(f.data.substring(0,n.endNodeIndex),h),i=u.parentNode,i.insertBefore(o,u),i.insertBefore(p,u),i.removeChild(u),i=f.parentNode,i.insertBefore(y,f),i.insertBefore(s,f),i.removeChild(f),y}}var h,c,e,o,l,a,s=[],p=0;if(e=i.ownerDocument,o=f.getBlockElements(),l=f.getWhiteSpaceElements(),a=f.getShortEndedElements(),c=y(i)){if(t.global)for(;h=t.exec(c);)s.push(v(h,u));else h=c.match(t),s.push(v(h,u));return s.length&&(p=s.length,w(i,s,b(r))),p}}function i(n){function e(){function e(){t.statusbar.find("#next").disabled(!u(r+1).length);t.statusbar.find("#prev").disabled(!u(r-1).length)}function o(){n.windowManager.alert("Could not find the specified string.",function(){t.find("#find")[0].focus()})}var s,f={},t;s=tinymce.trim(n.selection.getContent({format:"text"}));t=n.windowManager.open({layout:"flex",pack:"center",align:"center",onClose:function(){n.focus();i.done()},onSubmit:function(n){var l,h,s,c;return n.preventDefault(),h=t.find("#case").checked(),c=t.find("#words").checked(),s=t.find("#find").value(),s.length?f.text==s&&f.caseState==h&&f.wholeWord==c?0===u(r+1).length?void o():(i.next(),void e()):(l=i.find(s,h,c),l||o(),t.statusbar.items().slice(1).disabled(0===l),e(),void(f={text:s,caseState:h,wholeWord:c})):(i.done(!1),void t.statusbar.items().slice(1).disabled(!0))},buttons:[{text:"Find",subtype:"primary",onclick:function(){t.submit()}},{text:"Replace",disabled:!0,onclick:function(){i.replace(t.find("#replace").value())||(t.statusbar.items().slice(1).disabled(!0),r=-1,f={})}},{text:"Replace all",disabled:!0,onclick:function(){i.replace(t.find("#replace").value(),!0,!0);t.statusbar.items().slice(1).disabled(!0);f={}}},{type:"spacer",flex:1},{text:"Prev",name:"prev",disabled:!0,onclick:function(){i.prev();e()}},{text:"Next",name:"next",disabled:!0,onclick:function(){i.next();e()}}],title:"Find and replace",items:{type:"form",padding:20,labelGap:30,spacing:10,items:[{type:"textbox",name:"find",size:40,label:"Find",value:s},{type:"textbox",name:"replace",size:40,label:"Replace with"},{type:"checkbox",name:"case",text:"Match case",label:" "},{type:"checkbox",name:"words",text:"Whole words",label:" "}]}})}function f(n){var t=n.getAttribute("data-mce-index");return"number"==typeof t?""+t:t}function c(r){var f,u;return u=n.dom.create("span",{"data-mce-bogus":1}),u.className="mce-match-marker",f=n.getBody(),i.done(!1),t(r,f,u,!1,n.schema)}function s(n){var t=n.parentNode;n.firstChild&&t.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}function u(t){var i,e=[],r,u;if(i=tinymce.toArray(n.getBody().getElementsByTagName("span")),i.length)for(r=0;r<i.length;r++)u=f(i[r]),null!==u&&u.length&&u===t.toString()&&e.push(i[r]);return e}function o(t){var i=r,e=n.dom,f;return t=t!==!1,t?i++:i--,e.removeClass(u(r),"mce-match-marker-selected"),f=u(i),f.length?(e.addClass(u(i),"mce-match-marker-selected"),n.selection.scrollIntoView(f[0]),i):-1}function h(t){var i=n.dom,r=t.parentNode;i.remove(t);i.isEmpty(r)&&i.remove(r)}function l(n){var t=f(n);return null!==t&&t.length>0}var i=this,r=-1;i.init=function(n){n.addMenuItem("searchreplace",{text:"Find and replace",shortcut:"Meta+F",onclick:e,separator:"before",context:"edit"});n.addButton("searchreplace",{tooltip:"Find and replace",shortcut:"Meta+F",onclick:e});n.addCommand("SearchReplace",e);n.shortcuts.add("Meta+F","",e)};i.find=function(n,t,i){n=n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");n=i?"\\b"+n+"\\b":n;var u=c(new RegExp(n,t?"g":"gi"));return u&&(r=-1,r=o(!0)),u};i.next=function(){var n=o(!0);-1!==n&&(r=n)};i.prev=function(){var n=o(!1);-1!==n&&(r=n)};i.replace=function(t,e,o){var c,a,b,v,y,w,p=r,k;for(e=e!==!1,b=n.getBody(),a=tinymce.grep(tinymce.toArray(b.getElementsByTagName("span")),l),c=0;c<a.length;c++)if(k=f(a[c]),v=y=parseInt(k,10),o||v===r){for(t.length?(a[c].firstChild.nodeValue=t,s(a[c])):h(a[c]);a[++c];){if(v=parseInt(f(a[c]),10),v!==y){c--;break}h(a[c])}e&&p--}else y>r&&a[c].setAttribute("data-mce-index",y-1);return n.undoManager.add(),r=p,e?(w=u(p+1).length>0,i.next()):(w=u(p-1).length>0,i.prev()),!o&&w};i.done=function(t){for(var o,h,c,e,u=tinymce.toArray(n.getBody().getElementsByTagName("span")),i=0;i<u.length;i++)c=f(u[i]),null!==c&&c.length&&(c===r.toString()&&(o||(o=u[i].firstChild),h=u[i].firstChild),s(u[i]));if(o&&h)return e=n.dom.createRng(),e.setStart(o,0),e.setEnd(h,h.data.length),t!==!1&&n.selection.setRng(e),e}}tinymce.PluginManager.add("searchreplace",i)}();!function(n,t){"use strict";function u(n,t){for(var u,e=[],r=0;r<n.length;++r){if(u=i[n[r]]||f(n[r]),!u)throw"module definition dependecy not found: "+n[r];e.push(u)}t.apply(null,e)}function r(n,r,f){if("string"!=typeof n)throw"invalid module definition, module id must be defined and be a string";if(r===t)throw"invalid module definition, dependencies must be specified";if(f===t)throw"invalid module definition, definition function must be specified";u(r,function(){i[n]=f.apply(null,arguments)})}function f(t){for(var i=n,u=t.split(/[.\/]/),r=0;r<u.length;++r){if(!i[u[r]])return;i=i[u[r]]}return i}function e(r){for(var e,o,f,h,s,u=0;u<r.length;u++){for(e=n,o=r[u],f=o.split(/[.\/]/),s=0;s<f.length-1;++s)e[f[s]]===t&&(e[f[s]]={}),e=e[f[s]];e[f[f.length-1]]=i[o]}if(n.AMDLC_TESTS){h=n.privateModules||{};for(o in i)h[o]=i[o];for(u=0;u<r.length;u++)delete h[r[u]];n.privateModules=h}}var i={};r("tinymce/spellcheckerplugin/DomTextMatcher",[],function(){function n(n){return n&&1==n.nodeType&&"false"===n.contentEditable}return function(t,i){function w(n,t){if(!n[0])throw"findAndReplaceDOMText cannot handle zero-length matches";return{start:n.index,end:n.index+n[0].length,text:n[0],data:t}}function c(t){var i;if(3===t.nodeType)return t.data;if(s[t.nodeName]&&!f[t.nodeName])return"";if(n(t))return"\n";if(i="",(f[t.nodeName]||h[t.nodeName])&&(i+="\n"),t=t.firstChild)do i+=c(t);while(t=t.nextSibling);return i}function b(t,i,r){var c,l,y,a,e,v=[],o=0,u=t,p=0;i=i.slice(0);i.sort(function(n,t){return n.start-t.start});e=i.shift();n:for(;;){if((f[u.nodeName]||h[u.nodeName]||n(u))&&o++,3===u.nodeType&&(!l&&u.length+o>=e.end?(l=u,a=e.end-o):c&&v.push(u),!c&&u.length+o>e.start&&(c=u,y=e.start-o),o+=u.length),c&&l){if(u=r({startNode:c,startNodeIndex:y,endNode:l,endNodeIndex:a,innerNodes:v,match:e.text,matchIndex:p}),o-=l.length-a,c=null,l=null,v=[],e=i.shift(),p++,!e)break}else if((!s[u.nodeName]||f[u.nodeName])&&u.firstChild){if(!n(u)){u=u.firstChild;continue}}else if(u.nextSibling){u=u.nextSibling;continue}for(;;){if(u.nextSibling){u=u.nextSibling;break}if(u.parentNode===t)break n;u=u.parentNode}}}function k(n){function t(t,i){var u=r[i],f;return u.stencil||(u.stencil=n(u)),f=u.stencil.cloneNode(!1),f.setAttribute("data-mce-index",i),t&&f.appendChild(p.doc.createTextNode(t)),f}return function(n){var e,o,i,u=n.startNode,f=n.endNode,s=n.matchIndex,h=p.doc,r,l,c,v,y;if(u===f)return r=u,i=r.parentNode,n.startNodeIndex>0&&(e=h.createTextNode(r.data.substring(0,n.startNodeIndex)),i.insertBefore(e,r)),l=t(n.match,s),i.insertBefore(l,r),n.endNodeIndex<r.length&&(o=h.createTextNode(r.data.substring(n.endNodeIndex)),i.insertBefore(o,r)),r.parentNode.removeChild(r),l;e=h.createTextNode(u.data.substring(0,n.startNodeIndex));o=h.createTextNode(f.data.substring(n.endNodeIndex));for(var w=t(u.data.substring(n.startNodeIndex),s),b=[],a=0,k=n.innerNodes.length;k>a;++a)c=n.innerNodes[a],v=t(c.data,s),c.parentNode.replaceChild(v,c),b.push(v);return y=t(f.data.substring(0,n.endNodeIndex),s),i=u.parentNode,i.insertBefore(e,u),i.insertBefore(w,u),i.removeChild(u),i=f.parentNode,i.insertBefore(y,f),i.insertBefore(o,f),i.removeChild(f),y}}function d(n){var t=n.parentNode;t.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}function o(n){var f=t.getElementsByTagName("*"),e=[],i,u,r;for(n="number"==typeof n?""+n:null,i=0;i<f.length;i++)u=f[i],r=u.getAttribute("data-mce-index"),null!==r&&r.length&&(r!==n&&null!==n||e.push(u));return e}function e(n){for(var t=r.length;t--;)if(r[t]===n)return t;return-1}function g(n){var t=[];return l(function(i,r){n(i,r)&&t.push(i)}),r=t,this}function l(n){for(var t=0,i=r.length;i>t&&n(r[t],t)!==!1;t++);return this}function nt(n){return r.length&&b(t,r,k(n)),this}function tt(n,t){if(u&&n.global)for(;y=n.exec(u);)r.push(w(y,t));return this}function a(n){for(var i=o(n?e(n):null),t=i.length;t--;)d(i[t]);return this}function it(n){return r[n.getAttribute("data-mce-index")]}function rt(n){return o(e(n))[0]}function ut(n,t,i){return r.push({start:n,end:n+t,text:u.substr(n,t),data:i}),this}function v(n){var t=o(e(n)),r=i.dom.createRng();return r.setStartBefore(t[0]),r.setEndAfter(t[t.length-1]),r}function ft(n,t){var r=v(n);return r.deleteContents(),t.length>0&&r.insertNode(i.dom.doc.createTextNode(t)),r}function et(){return r.splice(0,r.length),a(),this}var y,u,f,s,h,r=[],p=i.dom;return f=i.schema.getBlockElements(),s=i.schema.getWhiteSpaceElements(),h=i.schema.getShortEndedElements(),u=c(t),{text:u,matches:r,each:l,filter:g,reset:et,matchFromElement:it,elementFromMatch:rt,find:tt,add:ut,wrap:nt,unwrap:a,replace:ft,rangeFromMatch:v,indexOf:e}}});r("tinymce/spellcheckerplugin/Plugin",["tinymce/spellcheckerplugin/DomTextMatcher","tinymce/PluginManager","tinymce/util/Tools","tinymce/ui/Menu","tinymce/dom/DOMUtils","tinymce/util/XHR","tinymce/util/URI","tinymce/util/JSON"],function(n,t,i,r,u,f,e,o){t.add("spellchecker",function(t,s){function y(){return v.textMatcher||(v.textMatcher=new n(t.getBody(),t)),v.textMatcher}function ft(n,t){var r=[];return i.each(t,function(n){r.push({selectable:!0,text:n.name,data:n.value})}),r}function et(n){for(var t in n)return!1;return!0}function ot(n,f){var o=[],l=rt[n];i.each(l,function(n){o.push({text:n,onclick:function(){t.insertContent(t.dom.encode(n));t.dom.remove(f);p()}})});o.push({text:"-"});ut&&o.push({text:"Add to Dictionary",onclick:function(){ht(n,f)}});o.push.apply(o,[{text:"Ignore",onclick:function(){nt(n,f)}},{text:"Ignore all",onclick:function(){nt(n,f,!0)}}]);c=new r({items:o,context:"contextmenu",onautohide:function(n){-1!=n.target.className.indexOf("spellchecker")&&n.preventDefault()},onhide:function(){c.remove();c=null}});c.renderTo(document.body);var h=u.DOM.getPos(t.getContentAreaContainer()),s=t.dom.getPos(f[0]),e=t.dom.getRoot();"BODY"==e.nodeName?(s.x-=e.ownerDocument.documentElement.scrollLeft||e.scrollLeft,s.y-=e.ownerDocument.documentElement.scrollTop||e.scrollTop):(s.x-=e.scrollLeft,s.y-=e.scrollTop);h.x+=s.x;h.y+=s.y;c.moveTo(h.x,h.y+f[0].offsetHeight)}function d(){return t.getParam("spellchecker_wordchar_pattern")||new RegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`§©«®±¶·¸»¼½¾¿×÷¤”“„    ]+',"g")}function st(n,r,u,c){var a={method:n,lang:h.spellchecker_language},l="";a["addToDictionary"==n?"word":"text"]=r;i.each(a,function(n,t){l&&(l+="&");l+=t+"="+encodeURIComponent(n)});f.send({url:new e(s).toAbsolute(h.spellchecker_rpc_url),type:"post",content_type:"application/x-www-form-urlencoded",data:l,success:function(n){if(n=o.parse(n))n.error?c(n.error):u(n);else{var i=t.translate("Server response wasn't proper JSON.");c(i)}},error:function(){var n=t.translate("The spelling service was not found: (")+h.spellchecker_rpc_url+t.translate(")");c(n)}})}function g(n,t,i,r){var u=h.spellchecker_callback||st;u.call(v,n,t,i,r)}function w(){function n(n){t.notificationManager.open({text:n,type:"error"});t.setProgressState(!1);b()}b()||(t.setProgressState(!0),g("spellcheck",y().text,it,n),t.focus())}function p(){t.dom.select("span.mce-spellchecker-word").length||b()}function ht(n,i){t.setProgressState(!0);g("addToDictionary",n,function(){t.setProgressState(!1);t.dom.remove(i,!0);p()},function(n){t.notificationManager.open({text:n,type:"error"});t.setProgressState(!1)})}function nt(n,r,u){t.selection.collapse();u?i.each(t.dom.select("span.mce-spellchecker-word"),function(i){i.getAttribute("data-mce-word")==n&&t.dom.remove(i,!0)}):t.dom.remove(r,!0);p()}function b(){return y().reset(),v.textMatcher=null,l?(l=!1,t.fire("SpellcheckEnd"),!0):void 0}function tt(n){var t=n.getAttribute("data-mce-index");return"number"==typeof t?""+t:t}function ct(n){var r,e=[],u,f;if(r=i.toArray(t.getBody().getElementsByTagName("span")),r.length)for(u=0;u<r.length;u++)f=tt(r[u]),null!==f&&f.length&&f===n.toString()&&e.push(r[u]);return e}function lt(n){var t=h.spellchecker_language;n.control.items().each(function(n){n.active(n.settings.data===t)})}function it(n){var i,r;if(n.words?(ut=!!n.dictionary,i=n.words):i=n,t.setProgressState(!1),et(i))return r=t.translate("No misspellings found."),t.notificationManager.open({text:r,type:"info"}),void(l=!1);rt=i;y().find(d()).filter(function(n){return!!i[n.text]}).wrap(function(n){return t.dom.create("span",{"class":"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":n.text})});l=!0;t.fire("SpellcheckStart")}var k,rt,l,c,ut,v=this,h=t.settings,at=h.spellchecker_languages||"English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv",a;k=ft("Language",i.map(at.split(","),function(n){return n=n.split("="),{name:n[0],value:n[1]}}));t.on("click",function(n){var u=n.target,i,r;"mce-spellchecker-word"==u.className&&(n.preventDefault(),i=ct(tt(u)),i.length>0&&(r=t.dom.createRng(),r.setStartBefore(i[0]),r.setEndAfter(i[i.length-1]),t.selection.setRng(r),ot(u.getAttribute("data-mce-word"),i)))});t.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:w,selectable:!0,onPostRender:function(){var n=this;n.active(l);t.on("SpellcheckStart SpellcheckEnd",function(){n.active(l)})}});a={tooltip:"Spellcheck",onclick:w,onPostRender:function(){var n=this;t.on("SpellcheckStart SpellcheckEnd",function(){n.active(l)})}};k.length>1&&(a.type="splitbutton",a.menu=k,a.onshow=lt,a.onselect=function(n){h.spellchecker_language=n.control.settings.data});t.addButton("spellchecker",a);t.addCommand("mceSpellCheck",w);t.on("remove",function(){c&&(c.remove(),c=null)});t.on("change",p);this.getTextMatcher=y;this.getWordCharPattern=d;this.markErrors=it;this.getLanguage=function(){return h.spellchecker_language};h.spellchecker_language=h.spellchecker_language||h.language||"en"})});e(["tinymce/spellcheckerplugin/DomTextMatcher"])}(this);!function(n,t){"use strict";function u(n,t){for(var u,e=[],i=0;i<n.length;++i){if(u=r[n[i]]||f(n[i]),!u)throw"module definition dependecy not found: "+n[i];e.push(u)}t.apply(null,e)}function i(n,i,f){if("string"!=typeof n)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(f===t)throw"invalid module definition, definition function must be specified";u(i,function(){r[n]=f.apply(null,arguments)})}function f(t){for(var i=n,u=t.split(/[.\/]/),r=0;r<u.length;++r){if(!i[u[r]])return;i=i[u[r]]}return i}var r={};i("tinymce/tableplugin/Utils",["tinymce/Env"],function(n){function t(n,t){return parseInt(n.getAttribute(t)||1,10)}function i(t){(!n.ie||n.ie>9)&&(t.hasChildNodes()||(t.innerHTML='<br data-mce-bogus="1" />'))}return{getSpanVal:t,paddCell:i}});i("tinymce/tableplugin/TableGrid",["tinymce/util/Tools","tinymce/Env","tinymce/tableplugin/Utils"],function(n,i,r){var u=n.each,f=r.getSpanVal;return function(e,o,s){function ot(){e.$("td[data-mce-selected],th[data-mce-selected]").removeAttr("data-mce-selected")}function g(n){return n===e.getBody()}function ft(t,i){return t?(i=n.map(i.split(","),function(n){return n.toLowerCase()}),n.grep(t.childNodes,function(t){return-1!==n.inArray(i,t.nodeName.toLowerCase())})):[]}function nt(){var n=0;h=[];w=0;u(["thead","tbody","tfoot"],function(t){var r=ft(o,t)[0],i=ft(r,"tr");u(i,function(i,r){r+=n;u(ft(i,"td,th"),function(n,i){var e,u,o,s;if(h[r])for(;h[r][i];)i++;for(o=f(n,"rowspan"),s=f(n,"colspan"),u=r;r+o>u;u++)for(h[u]||(h[u]=[]),e=i;i+s>e;e++)h[u][e]={part:t,real:u==r&&e==i,elm:n,rowspan:o,colspan:s};w=Math.max(w,i+1)})});n+=i.length})}function st(n){return e.fire("newrow",{node:n}),n}function et(n){return e.fire("newcell",{node:n}),n}function tt(n,t){return n=n.cloneNode(t),n.removeAttribute("id"),n}function d(n,t){var i;return i=h[t],i?i[n]:void 0}function a(n,t,i){n&&(i=parseInt(i,10),1===i?n.removeAttribute(t,1):n.setAttribute(t,i,1))}function b(n){return n&&(!!c.getAttrib(n.elm,"data-mce-selected")||n==s)}function it(){var n=[];return u(o.rows,function(t){u(t.cells,function(i){if(c.getAttrib(i,"data-mce-selected")||s&&i==s.elm)return(n.push(t),!1)})}),n}function lt(){var n=c.createRng();g(o)||(n.setStartAfter(o),n.setEndAfter(o),y.setRng(n),c.remove(o))}function k(t){var f,o={};return e.settings.table_clone_elements!==!1&&(o=n.makeMap((e.settings.table_clone_elements||"strong em b i span font h1 h2 h3 h4 h5 h6 p div").toUpperCase(),/[ ,]/)),n.walk(t,function(n){var r;if(3==n.nodeType)return(u(c.getParents(n.parentNode,null,t).reverse(),function(n){o[n.nodeName]&&(n=tt(n,!1),f?r&&r.appendChild(n):f=r=n,r=n)}),r&&(r.innerHTML=i.ie&&i.ie<10?"&nbsp;":'<br data-mce-bogus="1" />'),!1)},"childNodes"),t=tt(t,!1),et(t),a(t,"rowSpan",1),a(t,"colSpan",1),f?t.appendChild(f):r.paddCell(t),t}function rt(){var n,t=c.createRng();return u(c.select("tr",o),function(n){0===n.cells.length&&c.remove(n)}),0===c.select("tr",o).length?(t.setStartBefore(o),t.setEndBefore(o),y.setRng(t),void c.remove(o)):(u(c.select("thead,tbody,tfoot",o),function(n){0===n.rows.length&&c.remove(n)}),nt(),void(l&&(n=h[Math.min(h.length-1,l.y)],n&&(y.select(n[Math.min(n.length-1,l.x)].elm,!0),y.collapse(!0)))))}function ut(n,t,i,r){for(var e,f,s,u=h[t][n].elm.parentNode,o=1;i>=o;o++)if(u=c.getNext(u,"tr")){for(e=n;e>=0;e--)if(s=h[t+o][e].elm,s.parentNode==u){for(f=1;r>=f;f++)c.insertAfter(k(s),s);break}if(-1==e)for(f=1;r>=f;f++)u.insertBefore(k(u.cells[0]),u.cells[0])}}function ht(){u(h,function(n,t){u(n,function(n,i){var r,u,e;if(b(n)&&(n=n.elm,r=f(n,"colspan"),u=f(n,"rowspan"),r>1||u>1)){for(a(n,"rowSpan",1),a(n,"colSpan",1),e=0;r-1>e;e++)c.insertAfter(k(n),n);ut(i,t,u-1,r)}})})}function at(t,i,r){var ft,e,o,g,tt,it,s,f,et,y,ot,ut,k;if(t?(ft=p(t),e=ft.x,o=ft.y,g=e+(i-1),tt=o+(r-1)):(l=v=null,u(h,function(n,t){u(n,function(n,i){b(n)&&(l||(l={x:i,y:t}),v={x:i,y:t})})}),l&&(e=l.x,o=l.y,g=v.x,tt=v.y)),f=d(e,o),et=d(g,tt),f&&et&&f.part==et.part){for(ht(),nt(),f=d(e,o).elm,ut=g-e+1,k=tt-o+1,ut===w&&k===h.length&&(ut=1,k=1),ut===w&&k>1&&(k=1),a(f,"colSpan",ut),a(f,"rowSpan",k),s=o;tt>=s;s++)for(it=e;g>=it;it++)h[s]&&h[s][it]&&(t=h[s][it].elm,t!=f&&(y=n.grep(t.childNodes),u(y,function(n){f.appendChild(n)}),y.length&&(y=n.grep(f.childNodes),ot=0,u(y,function(n){"BR"==n.nodeName&&ot++<y.length-1&&f.removeChild(n)})),c.remove(t)));rt()}}function vt(n){var i,r,w,e,s,l,v,y,o,p;if(u(h,function(t,r){return u(t,function(t){if(b(t)&&(t=t.elm,s=t.parentNode,l=st(tt(s,!1)),i=r,n))return!1}),n?!i:void 0}),i!==t){for(e=0,p=0;e<h[0].length;e+=p)if(h[i][e]&&(r=h[i][e].elm,p=f(r,"colspan"),r!=w)){if(n){if(i>0&&h[i-1][e]&&(y=h[i-1][e].elm,o=f(y,"rowSpan"),o>1)){a(y,"rowSpan",o+1);continue}}else if(o=f(r,"rowspan"),o>1){a(r,"rowSpan",o+1);continue}v=k(r);a(v,"colSpan",r.colSpan);l.appendChild(v);w=r}l.hasChildNodes()&&(n?s.parentNode.insertBefore(l,s):c.insertAfter(l,s))}}function yt(n){var t,i;u(h,function(i){return u(i,function(i,r){if(b(i)&&(t=r,n))return!1}),n?!t:void 0});u(h,function(r,u){var e,s,o;r[t]&&(e=r[t].elm,e!=i&&(o=f(e,"colspan"),s=f(e,"rowspan"),1==o?n?(e.parentNode.insertBefore(k(e),e),ut(t,u,s-1,o)):(c.insertAfter(k(e),e),ut(t,u,s-1,o)):a(e,"colSpan",e.colSpan+1),i=e))})}function pt(t){return n.grep(ct(t),b)}function ct(n){var t=[];return u(n,function(n){u(n,function(n){t.push(n)})}),t}function wt(){var t=[];if(g(o)){if(1==h[0].length)return;if(pt(h).length==ct(h).length)return}u(h,function(i){u(i,function(i,r){b(i)&&-1===n.inArray(t,r)&&(u(h,function(n){var t,i=n[r].elm;t=f(i,"colSpan");t>1?a(i,"colSpan",t-1):c.remove(i)}),t.push(r))})});rt()}function bt(){function t(n){var t,i;u(n.cells,function(n){var i=f(n,"rowSpan");i>1&&(a(n,"rowSpan",i-1),t=p(n),ut(t.x,t.y,1,1))});t=p(n.cells[0]);u(h[t.y],function(n){var t;n=n.elm;n!=i&&(t=f(n,"rowSpan"),1>=t?c.remove(n):a(n,"rowSpan",t-1),i=n)})}var n;n=it();g(o)&&n.length==o.rows.length||(u(n.reverse(),function(n){t(n)}),rt())}function kt(){var n=it();if(!g(o)||n.length!=o.rows.length)return c.remove(n),rt(),n}function dt(){var n=it();return u(n,function(t,i){n[i]=tt(t,!0)}),n}function gt(t,i){var e,o=it(),r=o[i?0:o.length-1],f=r.cells.length;t&&(e=n.map(t,function(n){return n.cloneNode(!0)}),u(h,function(n){var t;return f=0,u(n,function(n){n.real&&(f+=n.colspan);n.elm.parentNode==r&&(t=1)}),t?!1:void 0}),i||e.reverse(),u(e,function(n){var t,u,e=n.cells.length;for(st(n),t=0;e>t;t++)u=n.cells[t],et(u),a(u,"colSpan",1),a(u,"rowSpan",1);for(t=e;f>t;t++)n.appendChild(et(k(n.cells[e-1])));for(t=f;e>t;t++)c.remove(n.cells[t]);i?r.parentNode.insertBefore(n,r):c.insertAfter(n,r)}),ot())}function p(n){var t;return u(h,function(i,r){return u(i,function(i,u){if(i.elm==n)return(t={x:u,y:r},!1)}),!t}),t}function ni(n){l=p(n)}function ti(){var n,t;return n=t=0,u(h,function(i,r){u(i,function(i,u){var f,e;b(i)&&(i=h[r][u],u>n&&(n=u),r>t&&(t=r),i.real&&(f=i.colspan-1,e=i.rowspan-1,f&&u+f>n&&(n=u+f),e&&r+e>t&&(t=r+e)))})}),{x:n,y:t}}function ii(n){var o,s,a,y,r,u,f,e,t,i;if(v=p(n),l&&v){for(o=Math.min(l.x,v.x),s=Math.min(l.y,v.y),a=Math.max(l.x,v.x),y=Math.max(l.y,v.y),r=a,u=y,i=s;y>=i;i++)for(t=o;a>=t;t++)n=h[i][t],n.real&&(f=n.colspan-1,e=n.rowspan-1,f&&t+f>r&&(r=t+f),e&&i+e>u&&(u=i+e));for(ot(),i=s;u>=i;i++)for(t=o;r>=t;t++)h[i][t]&&c.setAttrib(h[i][t].elm,"data-mce-selected","1")}}function ri(n,t){var u,r,i;u=p(n);r=u.y*w+u.x;do{if(r+=t,i=d(r%w,Math.floor(r/w)),!i)break;if(i.elm!=n)return y.select(i.elm,!0),c.isEmpty(i.elm)&&y.collapse(!0),!0}while(i.elm==n);return!1}var h,w,l,v,y=e.selection,c=y.dom;o=o||c.getParent(y.getStart(!0),"table");nt();s=s||c.getParent(y.getStart(!0),"th,td");s&&(l=p(s),v=ti(),s=d(l.x,l.y));n.extend(this,{deleteTable:lt,split:ht,merge:at,insertRow:vt,insertCol:yt,deleteCols:wt,deleteRows:bt,cutRows:kt,copyRows:dt,pasteRows:gt,getPos:p,setStartCell:ni,setEndCell:ii,moveRelIdx:ri,refresh:nt})}});i("tinymce/tableplugin/Quirks",["tinymce/util/VK","tinymce/util/Delay","tinymce/Env","tinymce/util/Tools","tinymce/tableplugin/Utils"],function(n,t,i,r,u){var e=r.each,f=u.getSpanVal;return function(o){function c(){function i(i){function c(n,t){var f=n?"previousSibling":"nextSibling",r=o.dom.getParent(t,"tr"),e=r[f],u;if(e)return l(o,t,e,n),i.preventDefault(),!0;var s=o.dom.getParent(r,"table"),h=r.parentNode,c=h.nodeName.toLowerCase();return("tbody"===c||c===(n?"tfoot":"thead"))&&(u=a(n,s,h,"tbody"),null!==u)?y(n,u,t):p(n,r,f,s)}function a(n,t,i,r){var u=o.dom.select(">"+r,t),f=u.indexOf(i),e;return n&&0===f||!n&&f===u.length-1?v(n,t):-1===f?(e="thead"===i.tagName.toLowerCase()?0:u.length-1,u[e]):u[f+(n?-1:1)]}function v(n,t){var r=n?"thead":"tfoot",i=o.dom.select(">"+r,t);return 0!==i.length?i[0]:null}function y(n,t,u){var f=r(t,n);return f&&l(o,u,f,n),i.preventDefault(),!0}function p(n,t,f,e){var h=e[f],s,l;return h?(u(h),!0):(s=o.dom.getParent(e,"td,th"),s)?c(n,s,i):(l=r(t,!n),u(l),i.preventDefault(),!1)}function r(n,t){var i=n&&n[t?"lastChild":"firstChild"];return i&&"BR"===i.nodeName?o.dom.getParent(i,"td,th"):i}function u(n){o.selection.setCursorLocation(n,0)}function w(){return s==n.UP||s==n.DOWN}function b(n){var t=n.selection.getNode(),i=n.dom.getParent(t,"tr");return null!==i}function k(n){for(var i=0,t=n;t.previousSibling;)t=t.previousSibling,i+=f(t,"colspan");return i}function d(n,t){var i=0,r=0;return e(n.children,function(n,u){return i+=f(n,"colspan"),r=u,i>t?!1:void 0}),r}function l(n,t,i,f){var s=k(o.dom.getParent(t,"td,th")),h=d(i,s),e=i.childNodes[h],c=r(e,f);u(c||e)}function g(n){var r=o.selection.getNode(),t=o.dom.getParent(r,"td,th"),i=o.dom.getParent(n,"td,th");return t&&t!==i&&nt(t,i)}function nt(n,t){return o.dom.getParent(n,"TABLE")===o.dom.getParent(t,"TABLE")}var s=i.keyCode,h;w()&&b(o)&&(h=o.selection.getNode(),t.setEditorTimeout(o,function(){g(h)&&c(!i.shiftKey&&s===n.UP,h,i)},0))}o.on("KeyDown",function(n){i(n)})}function s(){function n(n,t){var i,u=t.ownerDocument,r=u.createRange();return r.setStartBefore(t),r.setEnd(n.endContainer,n.endOffset),i=u.createElement("body"),i.appendChild(r.cloneContents()),0===i.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}o.on("KeyDown",function(t){var i,r,u=o.dom;37!=t.keyCode&&38!=t.keyCode||(i=o.selection.getRng(),r=u.getParent(i.startContainer,"table"),r&&o.getBody().firstChild==r&&n(i,r)&&(i=u.createRng(),i.setStartBefore(r),i.setEndBefore(r),o.selection.setRng(i),t.preventDefault()))})}function h(){o.on("KeyDown SetContent VisualAid",function(){for(var n=o.getBody().lastChild;n;n=n.previousSibling)if(3==n.nodeType){if(n.nodeValue.length>0)break}else if(1==n.nodeType&&("BR"==n.tagName||!n.getAttribute("data-mce-bogus")))break;n&&"TABLE"==n.nodeName&&(o.settings.forced_root_block?o.dom.add(o.getBody(),o.settings.forced_root_block,o.settings.forced_root_block_attrs,i.ie&&i.ie<10?"&nbsp;":'<br data-mce-bogus="1" />'):o.dom.add(o.getBody(),"br",{"data-mce-bogus":"1"}))});o.on("PreProcess",function(n){var t=n.node.lastChild;t&&("BR"==t.nodeName||1==t.childNodes.length&&("BR"==t.firstChild.nodeName||" "==t.firstChild.nodeValue))&&t.previousSibling&&"TABLE"==t.previousSibling.nodeName&&o.dom.remove(t)})}function l(){function t(n,t,i,r){var u,f,e,o=n.dom.getParent(t.startContainer,"TABLE");return o&&(u=o.parentNode),f=t.startContainer.nodeType==3&&0===t.startOffset&&0===t.endOffset&&r&&("TR"==i.nodeName||i==u),e=("TD"==i.nodeName||"TH"==i.nodeName)&&!r,f||e}function n(){var i=o.selection.getRng(),u=o.selection.getNode(),r=o.dom.getParent(i.startContainer,"TD,TH"),n;if(t(o,i,u,r)){for(r||(r=u),n=r.lastChild;n.lastChild;)n=n.lastChild;3==n.nodeType&&(i.setEnd(n,n.data.length),o.selection.setRng(i))}}o.on("KeyDown",function(){n()});o.on("MouseDown",function(t){2!=t.button&&n()})}function a(){function t(n){o.selection.select(n,!0);o.selection.collapse(!0)}function i(n){o.$(n).empty();u.paddCell(n)}o.on("keydown",function(u){if((u.keyCode==n.DELETE||u.keyCode==n.BACKSPACE)&&!u.isDefaultPrevented()){var h,s,f,e;if(h=o.dom.getParent(o.selection.getStart(),"table")){if(s=o.dom.select("td,th",h),f=r.grep(s,function(n){return!!o.dom.getAttrib(n,"data-mce-selected")}),0===f.length)return e=o.dom.getParent(o.selection.getStart(),"td,th"),void(o.selection.isCollapsed()&&e&&o.dom.isEmpty(e)&&(u.preventDefault(),i(e),t(e)));u.preventDefault();o.undoManager.transact(function(){s.length==f.length?o.execCommand("mceTableDelete"):(r.each(f,i),t(f[0]))})}}})}a();i.webkit&&(c(),l());i.gecko&&(s(),h());i.ie>9&&(s(),h())}});i("tinymce/tableplugin/CellSelection",["tinymce/tableplugin/TableGrid","tinymce/dom/TreeWalker","tinymce/util/Tools"],function(n,t,i){return function(r,u){function c(n){r.getBody().style.webkitUserSelect="";(n||h)&&(r.$("td[data-mce-selected],th[data-mce-selected]").removeAttr("data-mce-selected"),h=!1)}function v(n,t){return n&&t?n===f.getParent(t,"table"):!1}function y(t){var c,i,y=t.target;if(!l&&y!==a&&(a=y,o&&e)){if(i=f.getParent(y,"td,th"),v(o,i)||(i=f.getParent(o,"td,th")),e===i&&!h)return;if(u(!0),v(o,i)){t.preventDefault();s||(s=new n(r,o,e),r.getBody().style.webkitUserSelect="none");s.setEndCell(i);h=!0;c=r.selection.getSel();try{c.removeAllRanges?c.removeAllRanges():c.empty()}catch(p){}}}}var s,e,o,a,l,f=r.dom,h=!0,p=function(){e=s=o=a=null;u(!1)};return r.on("SelectionChange",function(n){h&&n.stopImmediatePropagation()},!0),r.on("MouseDown",function(n){2==n.button||l||(c(),e=f.getParent(n.target,"td,th"),o=f.getParent(e,"table"))}),r.on("mouseover",y),r.on("remove",function(){f.unbind(r.getDoc(),"mouseover",y);c()}),r.on("MouseUp",function(){function h(n,r){var f=new t(n,n);do{if(3==n.nodeType&&0!==i.trim(n.nodeValue).length)return void(r?u.setStart(n,0):u.setEnd(n,n.nodeValue.length));if("BR"==n.nodeName)return void(r?u.setStartBefore(n):u.setEndBefore(n))}while(n=r?f.next():f.prev())}var u,o,c,n,l,a=r.selection;if(e){if(s&&(r.getBody().style.webkitUserSelect=""),o=f.select("td[data-mce-selected],th[data-mce-selected]"),o.length>0){u=f.createRng();n=o[0];u.setStartBefore(n);u.setEndAfter(n);h(n,1);c=new t(n,f.getParent(o[0],"table"));do if("TD"==n.nodeName||"TH"==n.nodeName){if(!f.getAttrib(n,"data-mce-selected"))break;l=n}while(n=c.next());h(l);a.setRng(u)}r.nodeChanged();p()}}),r.on("KeyUp Drop SetContent",function(n){c("setcontent"==n.type);p();l=!1}),r.on("ObjectResizeStart ObjectResized",function(n){l="objectresized"!=n.type}),{clear:c}}});i("tinymce/tableplugin/Dialogs",["tinymce/util/Tools","tinymce/Env"],function(n,t){var i=n.each;return function(r){function a(){var n=r.settings.color_picker_callback;if(n)return function(){var t=this;n.call(r,function(n){t.value(n).fire("change")},t.value())}}function s(n){return{title:"Advanced",type:"form",defaults:{onchange:function(){o(n,this.parents().reverse()[0],"style"==this.name())}},items:[{label:"Style",name:"style",type:"textbox"},{type:"form",padding:0,formItemDefaults:{layout:"grid",alignH:["start","right"]},defaults:{size:7},items:[{label:"Border color",type:"colorbox",name:"borderColor",onaction:a()},{label:"Background color",type:"colorbox",name:"backgroundColor",onaction:a()}]}]}}function u(n){return n?n.replace(/px$/,""):""}function f(n){return/^[0-9]+$/.test(n)&&(n+="px"),n}function h(n){i("left center right".split(" "),function(t){r.formatter.remove("align"+t,{},n)})}function v(n){i("top middle bottom".split(" "),function(t){r.formatter.remove("valign"+t,{},n)})}function c(t,i,r){function u(t,r){return r=r||[],n.each(t,function(n){var t={text:n.text||n.title};n.menu?t.menu=u(n.menu):(t.value=n.value,i&&i(t));r.push(t)}),r}return u(t,r||[])}function o(n,t,i){var u=t.toJSON(),r=n.parseStyle(u.style);i?(t.find("#borderColor").value(r["border-color"]||"")[0].fire("change"),t.find("#backgroundColor").value(r["background-color"]||"")[0].fire("change")):(r["border-color"]=u.borderColor,r["background-color"]=u.backgroundColor);t.find("#style").value(n.serializeStyle(n.parseStyle(n.serializeStyle(r))))}function l(n,t,i){var r=n.parseStyle(n.getAttrib(i,"style"));r["border-color"]&&(t.borderColor=r["border-color"]);r["background-color"]&&(t.backgroundColor=r["background-color"]);t.style=n.serializeStyle(r)}function y(n,t,r){var u=n.parseStyle(n.getAttrib(t,"style"));i(r,function(n){u[n.name]=n.value});n.setAttrib(t,"style",n.serializeStyle(n.parseStyle(n.serializeStyle(u))))}var e=this;e.tableProps=function(){e.table(!0)};e.table=function(e){function g(){function e(n,t,i){if("TD"===n.tagName||"TH"===n.tagName)p.setStyle(n,t,i);else if(n.children)for(var r=0;r<n.children.length;r++)e(n.children[r],t,i)}var i;o(p,this);v=n.extend(v,this.toJSON());v["class"]===!1&&delete v["class"];r.undoManager.transact(function(){if(a||(a=r.plugins.table.insertTable(v.cols||1,v.rows||1)),r.dom.setAttribs(a,{style:v.style,"class":v["class"]}),r.settings.table_style_by_css){if(w=[],w.push({name:"border",value:v.border}),w.push({name:"border-spacing",value:f(v.cellspacing)}),y(p,a,w),p.setAttribs(a,{"data-mce-border-color":v.borderColor,"data-mce-cell-padding":v.cellpadding,"data-mce-border":v.border}),a.children)for(var n=0;n<a.children.length;n++)e(a.children[n],"border",v.border),e(a.children[n],"padding",f(v.cellpadding))}else r.dom.setAttribs(a,{border:v.border,cellpadding:v.cellpadding,cellspacing:v.cellspacing});p.getAttrib(a,"width")&&!r.settings.table_style_by_css?p.setAttrib(a,"width",u(v.width)):p.setStyle(a,"width",f(v.width));p.setStyle(a,"height",f(v.height));i=p.select("caption",a)[0];i&&!v.caption&&p.remove(i);!i&&v.caption&&(i=p.create("caption"),i.innerHTML=t.ie?" ":'<br data-mce-bogus="1"/>',a.insertBefore(i,a.firstChild));h(a);v.align&&r.formatter.apply("align"+v.align,{},a);r.focus();r.addVisual()})}function nt(n,t){function i(n,i){for(var u,r=0;r<i.length;r++)if(u=p.getStyle(i[r],t),"undefined"==typeof n&&(n=u),n!=u)return"";return n}var u,f=r.dom.select("td,th",n);return i(u,f)}var a,b,k,tt,d,w,p=r.dom,v={};e===!0?(a=p.getParent(r.selection.getStart(),"table"),a&&(v={width:u(p.getStyle(a,"width")||p.getAttrib(a,"width")),height:u(p.getStyle(a,"height")||p.getAttrib(a,"height")),cellspacing:u(p.getStyle(a,"border-spacing")||p.getAttrib(a,"cellspacing")),cellpadding:p.getAttrib(a,"data-mce-cell-padding")||p.getAttrib(a,"cellpadding")||nt(a,"padding"),border:p.getAttrib(a,"data-mce-border")||p.getAttrib(a,"border")||nt(a,"border"),borderColor:p.getAttrib(a,"data-mce-border-color"),caption:!!p.select("caption",a)[0],"class":p.getAttrib(a,"class")},i("left center right".split(" "),function(n){r.formatter.matchNode(a,"align"+n)&&(v.align=n)}))):(b={label:"Cols",name:"cols"},k={label:"Rows",name:"rows"});r.settings.table_class_list&&(v["class"]&&(v["class"]=v["class"].replace(/\s*mce\-item\-table\s*/g,"")),tt={name:"class",type:"listbox",label:"Class",values:c(r.settings.table_class_list,function(n){n.value&&(n.textStyle=function(){return r.formatter.getCssText({block:"table",classes:[n.value]})})})});d={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",labelGapCalc:!1,padding:0,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:r.settings.table_appearance_options!==!1?[b,k,{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"}]:[b,k,{label:"Width",name:"width"},{label:"Height",name:"height"}]},{label:"Alignment",name:"align",type:"listbox",text:"None",values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},tt]};r.settings.table_advtab!==!1?(l(p,v,a),r.windowManager.open({title:"Table properties",data:v,bodyType:"tabpanel",body:[{title:"General",type:"form",items:d},s(p)],onsubmit:g})):r.windowManager.open({title:"Table properties",data:v,body:d,onsubmit:g})};e.merge=function(n,t){r.windowManager.open({title:"Merge cells",body:[{label:"Cols",name:"cols",type:"textbox",value:"1",size:10},{label:"Rows",name:"rows",type:"textbox",value:"1",size:10}],onsubmit:function(){var i=this.toJSON();r.undoManager.transact(function(){n.merge(t,i.cols,i.rows)})}})};e.cell=function(){function w(){o(a,this);t=n.extend(t,this.toJSON());r.undoManager.transact(function(){i(y,function(n){r.dom.setAttribs(n,{scope:t.scope,style:t.style,"class":t["class"]});r.dom.setStyles(n,{width:f(t.width),height:f(t.height)});t.type&&n.nodeName.toLowerCase()!=t.type&&(n=a.rename(n,t.type));h(n);t.align&&r.formatter.apply("align"+t.align,{},n);v(n);t.valign&&r.formatter.apply("valign"+t.valign,{},n)});r.focus()})}var e,t,b,a=r.dom,y=[],p;(y=r.dom.select("td[data-mce-selected],th[data-mce-selected]"),e=r.dom.getParent(r.selection.getStart(),"td,th"),!y.length&&e&&y.push(e),e=e||y[0])&&(t={width:u(a.getStyle(e,"width")||a.getAttrib(e,"width")),height:u(a.getStyle(e,"height")||a.getAttrib(e,"height")),scope:a.getAttrib(e,"scope"),"class":a.getAttrib(e,"class")},t.type=e.nodeName.toLowerCase(),i("left center right".split(" "),function(n){r.formatter.matchNode(e,"align"+n)&&(t.align=n)}),i("top middle bottom".split(" "),function(n){r.formatter.matchNode(e,"valign"+n)&&(t.valign=n)}),r.settings.table_cell_class_list&&(b={name:"class",type:"listbox",label:"Class",values:c(r.settings.table_cell_class_list,function(n){n.value&&(n.textStyle=function(){return r.formatter.getCssText({block:"td",classes:[n.value]})})})}),p={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",layout:"grid",columns:2,labelGapCalc:!1,padding:0,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"H Align",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},b]},r.settings.table_cell_advtab!==!1?(l(a,t,e),r.windowManager.open({title:"Cell properties",bodyType:"tabpanel",data:t,body:[{title:"General",type:"form",items:p},s(a)],onsubmit:w})):r.windowManager.open({title:"Cell properties",data:t,body:p,onsubmit:w}))};e.row=function(){function p(){var u,c,s;o(e,this);t=n.extend(t,this.toJSON());r.undoManager.transact(function(){var n=t.type;i(y,function(i){r.dom.setAttribs(i,{scope:t.scope,style:t.style,"class":t["class"]});r.dom.setStyles(i,{height:f(t.height)});n!=i.parentNode.nodeName.toLowerCase()&&(u=e.getParent(i,"table"),c=i.parentNode,s=e.select(n,u)[0],s||(s=e.create(n),u.firstChild?u.insertBefore(s,u.firstChild):u.appendChild(s)),s.appendChild(i),c.hasChildNodes()||e.remove(c));h(i);t.align&&r.formatter.apply("align"+t.align,{},i)});r.focus()})}var w,b,a,k,t,v,e=r.dom,y=[];w=r.dom.getParent(r.selection.getStart(),"table");b=r.dom.getParent(r.selection.getStart(),"td,th");i(w.rows,function(n){i(n.cells,function(t){if(e.getAttrib(t,"data-mce-selected")||t==b)return(y.push(n),!1)})});a=y[0];a&&(t={height:u(e.getStyle(a,"height")||e.getAttrib(a,"height")),scope:e.getAttrib(a,"scope"),"class":e.getAttrib(a,"class")},t.type=a.parentNode.nodeName.toLowerCase(),i("left center right".split(" "),function(n){r.formatter.matchNode(a,"align"+n)&&(t.align=n)}),r.settings.table_row_class_list&&(k={name:"class",type:"listbox",label:"Class",values:c(r.settings.table_row_class_list,function(n){n.value&&(n.textStyle=function(){return r.formatter.getCssText({block:"tr",classes:[n.value]})})})}),v={type:"form",columns:2,padding:0,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"None",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"},k]},r.settings.table_row_advtab!==!1?(l(e,t,a),r.windowManager.open({title:"Row properties",data:t,bodyType:"tabpanel",body:[{title:"General",type:"form",items:v},s(e)],onsubmit:p})):r.windowManager.open({title:"Row properties",data:t,body:v,onsubmit:p}))}}});i("tinymce/tableplugin/ResizeBars",["tinymce/util/Tools","tinymce/util/VK"],function(n,i){var r;return function(u){function d(n,t){return{index:n,y:u.dom.getPos(t).y}}function wi(n,t){return{index:n,y:u.dom.getPos(t).y+t.offsetHeight}}function g(n,t){return{index:n,x:u.dom.getPos(t).x}}function nt(n,t){return{index:n,x:u.dom.getPos(t).x+t.offsetWidth}}function k(){var n=u.getBody().dir;return"rtl"===n}function bi(){return u.inline}function o(){return bi?u.getBody().ownerDocument.body:u.getBody()}function tt(n,t){return k()?nt(n,t):g(n,t)}function ki(n,t){return k()?g(n,t):nt(n,t)}function di(n,t){return e(n,"width")/e(t,"width")*100}function e(n,t){var i=u.dom.getStyle(n,t,!0);return parseInt(i,10)}function it(n){var t=e(n,"width"),i=e(n.parentElement,"width");return t/i*100}function gi(n,t){var i=e(n,"width");return t/i*100}function nr(n,t){var i=e(n.parentElement,"width");return t/i*100}function rt(n,t,i){for(var f,e,u=[],r=1;r<i.length;r++)f=i[r].element,u.push(n(r-1,f));return e=i[i.length-1],u.push(t(i.length-1,e.element)),u}function l(){var t=u.dom.select("."+oi,o());n.each(t,function(n){u.dom.remove(n)})}function ut(n){l();ht(n)}function ft(n,t,i,r,u,f,e,o){var s={"data-mce-bogus":"all","class":oi+" "+n,unselectable:"on","data-mce-resize":!1,style:"cursor: "+t+"; margin: 0; padding: 0; position: absolute; left: "+i+"px; top: "+r+"px; height: "+u+"px; width: "+f+"px; "};return s[e]=o,s}function tr(t,i,r){n.each(t,function(n){var t=r.x,f=n.y-b/2,e=b,s=i;u.dom.add(o(),"div",ft(si,vr,t,f,e,s,hi,n.index))})}function ir(t,i,r){n.each(t,function(n){var t=n.x-b/2,f=r.y,e=i,s=b;u.dom.add(o(),"div",ft(li,yr,t,f,e,s,ai,n.index))})}function y(t){return n.map(t.rows,function(t){var i=n.map(t.cells,function(n){var t=n.hasAttribute("rowspan")?parseInt(n.getAttribute("rowspan"),10):1,i=n.hasAttribute("colspan")?parseInt(n.getAttribute("colspan"),10):1;return{element:n,rowspan:t,colspan:i}});return{element:t,cells:i}})}function p(i){function r(n,t){return n+","+t}function s(n,t){return u[r(n,t)]}function h(){var t=[];return n.each(f,function(n){t=t.concat(n.cells)}),t}function c(){return f}var u={},f=[],e=0,o=0;return n.each(i,function(i,s){var h=[];n.each(i.cells,function(n){for(var l,f,c,a,v,i=0;u[r(s,i)]!==t;)i++;for(l={element:n.element,colspan:n.colspan,rowspan:n.rowspan,rowIndex:s,colIndex:i},f=0;f<n.colspan;f++)for(c=0;c<n.rowspan;c++)a=s+c,v=i+f,u[r(a,v)]=l,e=Math.max(e,a+1),o=Math.max(o,v+1);h.push(l)});f.push({element:i.element,cells:h})}),{grid:{maxRows:e,maxCols:o},getAt:s,getAllCells:h,getAllRows:c}}function w(n,t){for(var r=[],i=n;t>i;i++)r.push(i);return r}function et(n,t,i){for(var u,f=n(),r=0;r<f.length;r++)t(f[r])&&(u=f[r]);return u?u:i()}function ot(t){var r=w(0,t.grid.maxCols),i=w(0,t.grid.maxRows);return n.map(r,function(n){function r(){for(var u,f=[],r=0;r<i.length;r++)u=t.getAt(r,n),u&&u.colIndex===n&&f.push(u);return f}function u(n){return 1===n.colspan}function f(){for(var u,r=0;r<i.length;r++)if(u=t.getAt(r,n))return u;return null}return et(r,u,f)})}function st(t){var i=w(0,t.grid.maxCols),r=w(0,t.grid.maxRows);return n.map(r,function(n){function r(){for(var u,f=[],r=0;r<i.length;r++)u=t.getAt(n,r),u&&u.rowIndex===n&&f.push(u);return f}function u(n){return 1===n.rowspan}function f(){return t.getAt(n,0)}return et(r,u,f)})}function ht(n){var e=y(n),t=p(e),i=st(t),r=ot(t),f=u.dom.getPos(n),o=i.length>0?rt(d,wi,i):[],s=r.length>0?rt(tt,ki,r):[];tr(o,n.offsetWidth,f);ir(s,n.offsetHeight,f)}function ct(n,t,i,r){var u,h,o,f,c,s,a,l;if(0>t||t>=n.length-1)return"";if(u=n[t],u)u={value:u,delta:0};else for(h=n.slice(0,t).reverse(),o=0;o<h.length;o++)h[o]&&(u={value:h[o],delta:o+1});if(f=n[t+1],f)f={value:f,delta:1};else for(c=n.slice(t+1),s=0;s<c.length;s++)c[s]&&(f={value:c[s],delta:s+1});return a=f.delta-u.delta,l=Math.abs(f.value-u.value)/a,i?l/e(r,"width")*100:l}function lt(n,t){var i=u.dom.getStyle(n,t);return i||(i=u.dom.getAttrib(n,t)),i||(i=u.dom.getStyle(n,t,!0)),i}function rr(n,t,i){var u=lt(n,"width"),r=parseInt(u,10),f=t?di(n,i):e(n,"width");return(t&&!a(u)||!t&&!dt(u))&&(r=0),!isNaN(r)&&r>0?r:f}function at(t,i,r){for(var s,e,f=ot(t),h=n.map(f,function(n){return tt(n.colIndex,n.element).x}),o=[],u=0;u<f.length;u++)s=f[u].element.hasAttribute("colspan")?parseInt(f[u].element.getAttribute("colspan"),10):1,e=s>1?ct(h,u):rr(f[u].element,i,r),e=e?e:yi,o.push(e);return o}function ur(n){var i=lt(n,"height"),t=parseInt(i,10);return a(i)&&(t=0),!isNaN(t)&&t>0?t:e(n,"height")}function vt(t){for(var e,u,r=st(t),o=n.map(r,function(n){return d(n.rowIndex,n.element).y}),f=[],i=0;i<r.length;i++)e=r[i].element.hasAttribute("rowspan")?parseInt(r[i].element.getAttribute("rowspan"),10):1,u=e>1?ct(o,i):ur(r[i].element),u=u?u:pr,f.push(u);return f}function yt(t,i,r,u,f){function o(t){return n.map(t,function(){return 0})}function h(){var n,t;return f?n=[100-e[0]]:(t=Math.max(u,e[0]+r),n=[t-e[0]]),n}function s(n,t){var i,s=o(e.slice(0,n)),h=o(e.slice(t+1)),c,f,l;return r>=0?(c=Math.max(u,e[t]-r),i=s.concat([r,c-e[t]]).concat(h)):(f=Math.max(u,e[n]+r),l=e[n]-f,i=s.concat([f-e[n],l]).concat(h)),i}function c(n,t){var i,f=o(e.slice(0,t)),s;return r>=0?i=f.concat([r]):(s=Math.max(u,e[t]+r),i=f.concat([s-e[t]])),i}var e=t.slice(0);return 0===t.length?[]:1===t.length?h():0===i?s(0,1):i>0&&i<t.length-1?s(i,i+1):i===t.length-1?c(i-1,i):[]}function pt(n,t,i){for(var u=0,r=n;t>r;r++)u+=i[r];return u}function wt(t,i){var r=t.getAllCells();return n.map(r,function(n){var t=pt(n.colIndex,n.colIndex+n.colspan,i);return{element:n.element,width:t,colspan:n.colspan}})}function bt(t,i){var r=t.getAllCells();return n.map(r,function(n){var t=pt(n.rowIndex,n.rowIndex+n.rowspan,i);return{element:n.element,height:t,rowspan:n.rowspan}})}function kt(t,i){var r=t.getAllRows();return n.map(r,function(n,t){return{element:n.element,height:i[t]}})}function a(n){return wr.test(n)}function dt(n){return br.test(n)}function gt(t,i,r){function w(t,i){n.each(t,function(n){u.dom.setStyle(n.element,"width",n.width+i);u.dom.setAttrib(n.element,"width",null)})}function b(){return r<o.grid.maxCols-1?it(t):it(t)+nr(t,i)}function k(){return r<o.grid.maxCols-1?e(t,"width"):e(t,"width")+i}function d(n,i,f){r!=o.grid.maxCols-1&&f||(u.dom.setStyle(t,"width",n+i),u.dom.setAttrib(t,"width",null))}for(var g=y(t),o=p(g),f=a(t.width)||a(t.style.width),h=at(o,f,t),nt=f?gi(t,i):i,c=yt(h,r,nt,yi,f,t),l=[],s=0;s<c.length;s++)l.push(c[s]+h[s]);var tt=wt(o,l),v=f?"%":"px",rt=f?b():k();u.undoManager.transact(function(){w(tt,v);d(rt,v,f)})}function ni(t,i,r){for(var c,l,a=y(t),e=p(a),o=vt(e),s=[],h=0,f=0;f<o.length;f++)s.push(f===r?i+o[f]:o[f]),h+=h[f];c=bt(e,s);l=kt(e,s);u.undoManager.transact(function(){n.each(l,function(n){u.dom.setStyle(n.element,"height",n.height+"px");u.dom.setAttrib(n.element,"height",null)});n.each(c,function(n){u.dom.setStyle(n.element,"height",n.height+"px");u.dom.setAttrib(n.element,"height",null)});u.dom.setStyle(t,"height",h+"px");u.dom.setAttrib(t,"height",null)})}function fr(){ei=setTimeout(function(){ti()},200)}function er(){clearTimeout(ei)}function or(){var n=document.createElement("div");return n.setAttribute("style","margin: 0; padding: 0; position: fixed; left: 0px; top: 0px; height: 100%; width: 100%;"),n.setAttribute("data-mce-bogus","all"),n}function sr(n,t){u.dom.bind(n,"mouseup",function(){ti()});u.dom.bind(n,"mousemove",function(n){er();v&&t(n)});u.dom.bind(n,"mouseout",function(){fr()})}function ti(){var n,t,i,e,o,h;(u.dom.remove(s),v)&&(u.dom.removeClass(f,pi),v=!1,ri(f)?(i=parseInt(u.dom.getAttrib(f,vi),10),e=u.dom.getPos(f).x,n=parseInt(u.dom.getAttrib(f,ai),10),t=k()?i-e:e-i,gt(r,t,n)):ui(f)&&(o=parseInt(u.dom.getAttrib(f,ci),10),h=u.dom.getPos(f).y,n=parseInt(u.dom.getAttrib(f,hi),10),t=h-o,ni(r,t,n)),ut(r),u.nodeChanged())}function ii(n,t){s=s?s:or();v=!0;u.dom.addClass(n,pi);f=n;sr(s,t);u.dom.add(o(),s)}function ri(n){return u.dom.hasClass(n,li)}function ui(n){return u.dom.hasClass(n,si)}function hr(n){var i,r;h=h!==t?h:n.clientX;i=n.clientX-h;h=n.clientX;r=u.dom.getPos(f).x;u.dom.setStyle(f,"left",r+i+"px")}function cr(n){var i,r;c=c!==t?c:n.clientY;i=n.clientY-c;c=n.clientY;r=u.dom.getPos(f).y;u.dom.setStyle(f,"top",r+i+"px")}function lr(n){h=t;ii(n,hr)}function ar(n){c=t;ii(n,cr)}function fi(n){var t=n.target,i=u.getBody(),f,e;(u.$.contains(i,r)||r===i)&&(ri(t)?(n.preventDefault(),f=u.dom.getPos(t).x,u.dom.setAttrib(t,vi,f),lr(t)):ui(t)?(n.preventDefault(),e=u.dom.getPos(t).y,u.dom.setAttrib(t,ci,e),ar(t)):l())}var ei,v,s,f,h,c,oi="mce-resize-bar",si="mce-resize-bar-row",vr="row-resize",hi="data-row",ci="data-initial-top",li="mce-resize-bar-col",yr="col-resize",ai="data-col",vi="data-initial-left",b=4,yi=10,pr=10,pi="mce-resize-bar-dragging",wr=new RegExp(/(\d+(\.\d+)?%)/),br=new RegExp(/px|em/);return u.on("init",function(){u.dom.bind(o(),"mousedown",fi)}),u.on("ObjectResized",function(t){var r=t.target,i;"TABLE"===r.nodeName&&(i=[],n.each(r.rows,function(t){n.each(t.cells,function(n){var t=u.dom.getStyle(n,"width",!0);i.push({cell:n,width:t})})}),n.each(i,function(n){u.dom.setStyle(n.cell,"width",n.width);u.dom.setAttrib(n.cell,"width",null)}))}),u.on("mouseover",function(n){if(!v){var t=u.dom.getParent(n.target,"table");("TABLE"===n.target.nodeName||t)&&(r=t,ut(t))}}),u.on("keydown",function(n){switch(n.keyCode){case i.LEFT:case i.RIGHT:case i.UP:case i.DOWN:l()}}),u.on("remove",function(){l();u.dom.unbind(o(),"mousedown",fi)}),{adjustWidth:gt,adjustHeight:ni,clearBars:l,drawBars:ht,determineDeltas:yt,getTableGrid:p,getTableDetails:y,getWidths:at,getPixelHeights:vt,isPercentageBasedSize:a,isPixelBasedSize:dt,recalculateWidths:wt,recalculateCellHeights:bt,recalculateRowHeights:kt}}});i("tinymce/tableplugin/Plugin",["tinymce/tableplugin/TableGrid","tinymce/tableplugin/Quirks","tinymce/tableplugin/CellSelection","tinymce/tableplugin/Dialogs","tinymce/tableplugin/ResizeBars","tinymce/util/Tools","tinymce/dom/TreeWalker","tinymce/Env","tinymce/PluginManager"],function(n,t,i,r,u,f,e,o,s){function c(f){function e(n){return function(){f.execCommand(n)}}function w(n,t){for(var e,r,i='<table id="__mce"><tbody>',u=0;t>u;u++){for(i+="<tr>",e=0;n>e;e++)i+="<td>"+(o.ie&&o.ie<10?"&nbsp;":"<br>")+"<\/td>";i+="<\/tr>"}return i+="<\/tbody><\/table>",f.undoManager.transact(function(){f.insertContent(i);r=f.dom.get("__mce");f.dom.setAttrib(r,"id",null);f.$("tr",r).each(function(n,t){f.fire("newrow",{node:t});f.$("th,td",t).each(function(n,t){f.fire("newcell",{node:t})})});f.dom.setAttribs(r,f.settings.table_default_attributes||{});f.dom.setStyles(r,f.settings.table_default_styles||{})}),r}function p(n,t,i){function r(){var r,u,e,o={},s=0;u=f.dom.select("td[data-mce-selected],th[data-mce-selected]");r=u[0];r||(r=f.selection.getStart());i&&u.length>0?(h(u,function(n){return o[n.parentNode.parentNode.nodeName]=1}),h(o,function(n){s+=n}),e=1!==s):e=!f.dom.getParent(r,t);n.disabled(e);f.selection.selectorChanged(t,function(t){n.disabled(!t)})}f.initialized?r():f.on("init",r)}function b(){p(this,"table")}function s(){p(this,"td,th")}function d(){p(this,"td,th",!0)}function g(){for(var n="",i,n='<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">',t=0;10>t;t++){for(n+="<tr>",i=0;10>i;i++)n+='<td role="gridcell" tabindex="-1"><a id="mcegrid'+(10*t+i)+'" href="#" data-mce-x="'+i+'" data-mce-y="'+t+'"><\/a><\/td>';n+="<\/tr>"}return n+="<\/table>",n+'<div class="mce-text-center" role="presentation">1 x 1<\/div>'}function k(n,t,i){var r,u,s,e,o,h=i.getEl().getElementsByTagName("table")[0],c=i.isRtl()||"tl-tr"==i.parent().rel;for(h.nextSibling.innerHTML=n+1+" x "+(t+1),c&&(n=9-n),u=0;10>u;u++)for(r=0;10>r;r++)e=h.rows[u].childNodes[r].firstChild,o=(c?r>=n:n>=r)&&t>=u,f.dom.toggleClass(e,"mce-active",o),o&&(s=e);return s.parentNode}function nt(){f.addButton("tableprops",{title:"Table properties",onclick:c.tableProps,icon:"table"});f.addButton("tabledelete",{title:"Delete table",onclick:e("mceTableDelete")});f.addButton("tablecellprops",{title:"Cell properties",onclick:e("mceTableCellProps")});f.addButton("tablemergecells",{title:"Merge cells",onclick:e("mceTableMergeCells")});f.addButton("tablesplitcells",{title:"Split cell",onclick:e("mceTableSplitCells")});f.addButton("tableinsertrowbefore",{title:"Insert row before",onclick:e("mceTableInsertRowBefore")});f.addButton("tableinsertrowafter",{title:"Insert row after",onclick:e("mceTableInsertRowAfter")});f.addButton("tabledeleterow",{title:"Delete row",onclick:e("mceTableDeleteRow")});f.addButton("tablerowprops",{title:"Row properties",onclick:e("mceTableRowProps")});f.addButton("tablecutrow",{title:"Cut row",onclick:e("mceTableCutRow")});f.addButton("tablecopyrow",{title:"Copy row",onclick:e("mceTableCopyRow")});f.addButton("tablepasterowbefore",{title:"Paste row before",onclick:e("mceTablePasteRowBefore")});f.addButton("tablepasterowafter",{title:"Paste row after",onclick:e("mceTablePasteRowAfter")});f.addButton("tableinsertcolbefore",{title:"Insert column before",onclick:e("mceTableInsertColBefore")});f.addButton("tableinsertcolafter",{title:"Insert column after",onclick:e("mceTableInsertColAfter")});f.addButton("tabledeletecol",{title:"Delete column",onclick:e("mceTableDeleteCol")})}function tt(n){return f.dom.is(n,"table")&&f.getBody().contains(n)}function it(){var n=f.settings.table_toolbar;""!==n&&n!==!1&&(n||(n="tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"),f.addContextToolbar(tt,n))}function rt(){return a}function ut(n){a=n}var a,v,l=this,c=new r(f),y;f.settings.object_resizing&&f.settings.table_resize_bars!==!1&&(f.settings.object_resizing===!0||"table"===f.settings.object_resizing)&&(v=u(f));f.settings.table_grid===!1?f.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onclick:c.table}):f.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(n){n.aria&&(this.parent().hideAll(),n.stopImmediatePropagation(),c.table())},onshow:function(){k(0,0,this.menu.items()[0])},onhide:function(){var n=this.menu.items()[0].getEl().getElementsByTagName("a");f.dom.removeClass(n,"mce-active");f.dom.addClass(n[0],"mce-active")},menu:[{type:"container",html:g(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(n){var t,i,r=n.target;"A"==r.tagName.toUpperCase()&&(t=parseInt(r.getAttribute("data-mce-x"),10),i=parseInt(r.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"==this.parent().rel)&&(t=9-t),t===this.lastX&&i===this.lastY||(k(t,i,n.control),this.lastX=t,this.lastY=i))},onclick:function(n){var t=this;"A"==n.target.tagName.toUpperCase()&&(n.preventDefault(),n.stopPropagation(),t.parent().cancel(),f.undoManager.transact(function(){w(t.lastX+1,t.lastY+1)}),f.addVisual())}}]});f.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:b,onclick:c.tableProps});f.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:b,cmd:"mceTableDelete"});f.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:e("mceTableCellProps"),onPostRender:s},{text:"Merge cells",onclick:e("mceTableMergeCells"),onPostRender:d},{text:"Split cell",onclick:e("mceTableSplitCells"),onPostRender:s}]});f.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:e("mceTableInsertRowBefore"),onPostRender:s},{text:"Insert row after",onclick:e("mceTableInsertRowAfter"),onPostRender:s},{text:"Delete row",onclick:e("mceTableDeleteRow"),onPostRender:s},{text:"Row properties",onclick:e("mceTableRowProps"),onPostRender:s},{text:"-"},{text:"Cut row",onclick:e("mceTableCutRow"),onPostRender:s},{text:"Copy row",onclick:e("mceTableCopyRow"),onPostRender:s},{text:"Paste row before",onclick:e("mceTablePasteRowBefore"),onPostRender:s},{text:"Paste row after",onclick:e("mceTablePasteRowAfter"),onPostRender:s}]});f.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:e("mceTableInsertColBefore"),onPostRender:s},{text:"Insert column after",onclick:e("mceTableInsertColAfter"),onPostRender:s},{text:"Delete column",onclick:e("mceTableDeleteCol"),onPostRender:s}]});y=[];h("inserttable tableprops deletetable | cell row column".split(" "),function(n){"|"==n?y.push({text:"-"}):y.push(f.menuItems[n])});f.addButton("table",{type:"menubutton",title:"Table",menu:y});o.isIE||f.on("click",function(n){n=n.target;"TABLE"===n.nodeName&&(f.selection.select(n),f.nodeChanged())});l.quirks=new t(f);f.on("Init",function(){l.cellSelection=new i(f,function(n){n&&v.clearBars()});l.resizeBars=v});f.on("PreInit",function(){f.serializer.addAttributeFilter("data-mce-cell-padding,data-mce-border,data-mce-border-color",function(n,t){for(var i=n.length;i--;)n[i].attr(t,null)})});h({mceTableSplitCells:function(n){n.split()},mceTableMergeCells:function(n){var t;t=f.dom.getParent(f.selection.getStart(),"th,td");f.dom.select("td[data-mce-selected],th[data-mce-selected]").length?n.merge():c.merge(n,t)},mceTableInsertRowBefore:function(n){n.insertRow(!0)},mceTableInsertRowAfter:function(n){n.insertRow()},mceTableInsertColBefore:function(n){n.insertCol(!0)},mceTableInsertColAfter:function(n){n.insertCol()},mceTableDeleteCol:function(n){n.deleteCols()},mceTableDeleteRow:function(n){n.deleteRows()},mceTableCutRow:function(n){a=n.cutRows()},mceTableCopyRow:function(n){a=n.copyRows()},mceTablePasteRowBefore:function(n){n.pasteRows(a,!0)},mceTablePasteRowAfter:function(n){n.pasteRows(a)},mceTableDelete:function(n){v&&v.clearBars();n.deleteTable()}},function(t,i){f.addCommand(i,function(){var i=new n(f);i&&(t(i),f.execCommand("mceRepaint"),l.cellSelection.clear())})});h({mceInsertTable:c.table,mceTableProps:function(){c.table(!0)},mceTableRowProps:c.row,mceTableCellProps:c.cell},function(n,t){f.addCommand(t,function(t,i){n(i)})});nt();it();f.settings.table_tab_navigation!==!1&&f.on("keydown",function(t){var r,i,u;9==t.keyCode&&(r=f.dom.getParent(f.selection.getStart(),"th,td"),r&&(t.preventDefault(),i=new n(f),u=t.shiftKey?-1:1,f.undoManager.transact(function(){!i.moveRelIdx(r,u)&&u>0&&(i.insertRow(),i.refresh(),i.moveRelIdx(r,u))})))});l.insertTable=w;l.setClipboardRows=ut;l.getClipboardRows=rt}var h=f.each;s.add("table",c)})}(this),function(n){var i=function(){function n(){}return n}(),t;n.Result=i;t=function(){function t(){}return t.GetResultID=function(t){var i=$.Deferred();return $.ajax({headers:{TOKEN_HEADER:n.Settings.APIKEY,TOKEN:"5",userID:n.Settings.UUID},url:n.Settings.APIURI()+"/results/?revisionID="+t,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){i.resolve(n)}}),i.promise()},t.GetSimulationInfo=function(t){var i=$.Deferred();return $.ajax({headers:{TOKEN_HEADER:n.Settings.APIKEY,TOKEN:"5",userID:n.Settings.UUID},url:n.Settings.APIURI()+"/simulations/?simulationId="+t,dataType:"json",type:"GET",data:null,contentType:"application/json;charset=utf-8",success:function(n){i.resolve(n)}}),i.promise()},t}();n.ResultsInfo=t}(Project||(Project={}));!function(n,t,i){!function(n){"use strict";"function"==typeof define&&define.amd?define(["jquery"],n):jQuery&&!jQuery.fn.qtip&&n(jQuery)}(function(r){"use strict";function ii(n,t,i,f){this.id=i;this.target=n;this.tooltip=s;this.elements={target:n};this._id=o+"-"+i;this.timers={img:{}};this.options=t;this.plugins={};this.cache={event:{},target:r(),disabled:u,attr:f,onTooltip:u,lastClass:""};this.rendered=this.destroyed=this.disabled=this.waiting=this.hiddenDuringWait=this.positioning=this.triggering=u}function ut(n){return n===s||"object"!==r.type(n)}function vi(n){return!(r.isFunction(n)||n&&n.attr||n.length||"object"===r.type(n)&&(n.jquery||n.then))}function pt(n){var t,e,i,o;return ut(n)?u:(ut(n.metadata)&&(n.metadata={type:n.metadata}),"content"in n&&(t=n.content,ut(t)||t.jquery||t.done?t=n.content={text:e=vi(t)?u:t}:e=t.text,"ajax"in t&&(i=t.ajax,o=i&&i.once!==u,delete t.ajax,t.text=function(n,t){var u=e||r(this).attr(t.options.content.attr)||"Loading...",f=r.ajax(r.extend({},i,{context:t})).then(i.success,s,i.error).then(function(n){return n&&o&&t.set("content.text",n),n},function(n,i,r){t.destroyed||0===n.status||t.set("content.text",i+": "+r)});return o?u:(t.set("content.text",u),f)}),"title"in t&&(r.isPlainObject(t.title)&&(t.button=t.title.button,t.title=t.title.text),vi(t.title||u)&&(t.title=u))),"position"in n&&ut(n.position)&&(n.position={my:n.position,at:n.position}),"show"in n&&ut(n.show)&&(n.show=n.show.jquery?{target:n.show}:n.show===f?{ready:f}:{event:n.show}),"hide"in n&&ut(n.hide)&&(n.hide=n.hide.jquery?{target:n.hide}:{event:n.hide}),"style"in n&&ut(n.style)&&(n.style={classes:n.style}),r.each(h,function(){this.sanitize&&this.sanitize(n)}),n)}function yi(n,t){for(var u,f=0,i=n,r=t.split(".");i=i[r[f++]];)f<r.length&&(u=i);return[u||n,r.pop()]}function fr(n,t){var i,r,u;for(i in this.checks)for(r in this.checks[i])(u=new RegExp(r,"i").exec(n))&&(t.push(u),("builtin"===i||this.plugins[i])&&this.checks[i][r].apply(this.plugins[i]||this,t))}function wt(n){return lr.concat("").join(n?"-"+n+" ":" ")}function bt(n,t){return t>0?setTimeout(r.proxy(n,this),t):void n.call(this)}function er(n){this.tooltip.hasClass(a)||(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this.timers.show=bt.call(this,function(){this.toggle(f,n)},this.options.show.delay))}function or(n){if(!this.tooltip.hasClass(a)&&!this.destroyed){var t=r(n.relatedTarget),i=t.closest(it)[0]===this.tooltip[0],f=t[0]===this.options.show.target[0];if(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this!==t[0]&&"mouse"===this.options.position.target&&i||this.options.hide.fixed&&/mouse(out|leave|move)/.test(n.type)&&(i||f))try{n.preventDefault();n.stopImmediatePropagation()}catch(e){}else this.timers.hide=bt.call(this,function(){this.toggle(u,n)},this.options.hide.delay,this)}}function ri(n){!this.tooltip.hasClass(a)&&this.options.hide.inactive&&(clearTimeout(this.timers.inactive),this.timers.inactive=bt.call(this,function(){this.hide(n)},this.options.hide.inactive))}function pi(n){this.rendered&&this.tooltip[0].offsetWidth>0&&this.reposition(n)}function wi(n,i,u){r(t.body).delegate(n,(i.split?i:i.join("."+o+" "))+"."+o,function(){var n=c.api[r.attr(this,dt)];n&&!n.disabled&&u.apply(n,arguments)})}function sr(n,i,e){var y,l,v,h,b,k=r(t.body),p=n[0]===t?k:n,w=n.metadata?n.metadata(e.metadata):s,d="html5"===e.metadata.type&&w?w[e.metadata.name]:s,a=n.data(e.metadata.name||"qtipopts");try{a="string"==typeof a?r.parseJSON(a):a}catch(g){}if(h=r.extend(f,{},c.defaults,e,"object"==typeof a?pt(a):s,pt(d||w)),l=h.position,h.id=i,"boolean"==typeof h.content.text){if(v=n.attr(h.content.attr),h.content.attr===u||!v)return u;h.content.text=v}if(l.container.length||(l.container=k),l.target===u&&(l.target=p),h.show.target===u&&(h.show.target=p),h.show.solo===f&&(h.show.solo=l.container.closest("body")),h.hide.target===u&&(h.hide.target=p),h.position.viewport===f&&(h.position.viewport=l.container),l.container=l.container.eq(0),l.at=new nt(l.at,f),l.my=new nt(l.my),n.data(o))if(h.overwrite)n.qtip("destroy",!0);else if(h.overwrite===u)return u;return n.attr(ei,i),h.suppress&&(b=n.attr("title"))&&n.removeAttr("title").attr(rt,b).attr("title",""),y=new ii(n,h,i,!!v),n.data(o,y),y}function lt(n){return n.charAt(0).toUpperCase()+n.slice(1)}function hr(n,t){var r,u,f=t.charAt(0).toUpperCase()+t.slice(1),e=(t+" "+vr.join(f+" ")+f).split(" "),o=0;if(ci[t])return n.css(ci[t]);for(;r=e[o++];)if((u=n.css(r))!==i)return ci[t]=r,u}function et(n,t){return Math.ceil(parseFloat(hr(n,t)))}function bi(n,t){this._ns="tip";this.options=t;this.offset=t.offset;this.size=[t.width,t.height];this.init(this.qtip=n)}function ki(n,t){this.options=t;this._ns="-modal";this.init(this.qtip=n)}var c,e,nt,ui,kt,f=!0,u=!1,s=null,p="x",v="y",at="width",fi="height",b="top",w="left",tt="bottom",k="right",l="center",cr="flipinvert",ft="shift",h={},o="qtip",ei="data-hasqtip",dt="data-qtip-id",lr=["ui-widget","ui-tooltip"],it="."+o,di="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),gi=o+"-fixed",oi=o+"-default",ot=o+"-focus",ar=o+"-hover",a=o+"-disabled",st="_replacedByqTip",rt="oldtitle",y={ie:function(){for(var n=4,i=t.createElement("div");(i.innerHTML="<!--[if gt IE "+n+"]><i><\/i><![endif]-->")&&i.getElementsByTagName("i")[0];n+=1);return n>4?n:NaN}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||u},nr,tr,vt,li,ai,d,ti,g;e=ii.prototype;e._when=function(n){return r.when.apply(r,n)};e.render=function(n){if(this.rendered||this.destroyed)return this;var w,i=this,t=this.options,s=this.cache,y=this.elements,p=t.content.text,l=t.content.title,b=t.content.button,e=t.position,v=("."+this._id+" ",[]);return r.attr(this.target[0],"aria-describedby",this._id),s.posClass=this._createPosClass((this.position={my:e.my,at:e.at}).my),this.tooltip=y.tooltip=w=r("<div/>",{id:this._id,"class":[o,oi,t.style.classes,s.posClass].join(" "),width:t.style.width||"",height:t.style.height||"",tracking:"mouse"===e.target&&e.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":u,"aria-describedby":this._id+"-content","aria-hidden":f}).toggleClass(a,this.disabled).attr(dt,this.id).data(o,this).appendTo(e.container).append(y.content=r("<div />",{"class":o+"-content",id:this._id+"-content","aria-atomic":f})),this.rendered=-1,this.positioning=f,l&&(this._createTitle(),r.isFunction(l)||v.push(this._updateTitle(l,u))),b&&this._createButton(),r.isFunction(p)||v.push(this._updateContent(p,u)),this.rendered=f,this._setWidget(),r.each(h,function(n){var t;"render"===this.initialize&&(t=this(i))&&(i.plugins[n]=t)}),this._unassignEvents(),this._assignEvents(),this._when(v).then(function(){i._trigger("render");i.positioning=u;i.hiddenDuringWait||!t.show.ready&&!n||i.toggle(f,s.event,u);i.hiddenDuringWait=u}),c.api[this.id]=this,this};e.destroy=function(n){function t(){if(!this.destroyed){this.destroyed=f;var t,n=this.target,i=n.attr(rt);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove();r.each(this.plugins,function(){this.destroy&&this.destroy()});for(t in this.timers)clearTimeout(this.timers[t]);n.removeData(o).removeAttr(dt).removeAttr(ei).removeAttr("aria-describedby");this.options.suppress&&i&&n.attr("title",i).removeAttr(rt);this._unassignEvents();this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=s;delete c.api[this.id]}}return this.destroyed?this.target:(n===f&&"hide"!==this.triggering||!this.rendered?t.call(this):(this.tooltip.one("tooltiphidden",r.proxy(t,this)),!this.triggering&&this.hide()),this.target)};ui=e.checks={builtin:{"^id$":function(n,t,i,e){var s=i===f?c.nextid:i,h=o+"-"+s;s!==u&&s.length>0&&!r("#"+h).length?(this._id=h,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):n[t]=e},"^prerender":function(n,t,i){i&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(n,t,i){this._updateContent(i)},"^content.attr$":function(n,t,i,r){this.options.content.text===this.target.attr(r)&&this._updateContent(this.target.attr(i))},"^content.title$":function(n,t,i){return i?(i&&!this.elements.title&&this._createTitle(),void this._updateTitle(i)):this._removeTitle()},"^content.button$":function(n,t,i){this._updateButton(i)},"^content.title.(text|button)$":function(n,t,i){this.set("content."+t,i)},"^position.(my|at)$":function(n,t,i){"string"==typeof i&&(this.position[t]=n[t]=new nt(i,"at"===t))},"^position.container$":function(n,t,i){this.rendered&&this.tooltip.appendTo(i)},"^show.ready$":function(n,t,i){i&&(!this.rendered&&this.render(f)||this.toggle(f))},"^style.classes$":function(n,t,i,r){this.rendered&&this.tooltip.removeClass(r).addClass(i)},"^style.(width|height)":function(n,t,i){this.rendered&&this.tooltip.css(t,i)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(n,t,i){this.rendered&&this.tooltip.toggleClass(oi,!!i)},"^events.(render|show|move|hide|focus|blur)$":function(n,t,i){this.rendered&&this.tooltip[(r.isFunction(i)?"":"un")+"bind"]("tooltip"+t,i)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(this.rendered){var n=this.options.position;this.tooltip.attr("tracking","mouse"===n.target&&n.adjust.mouse);this._unassignEvents();this._assignEvents()}}}};e.get=function(n){if(this.destroyed)return this;var i=yi(this.options,n.toLowerCase()),t=i[0][i[1]];return t.precedance?t.string():t};nr=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i;tr=/^prerender|show\.ready/i;e.set=function(n,t){if(this.destroyed)return this;var o,h=this.rendered,i=u,e=this.options;return this.checks,"string"==typeof n?(o=n,n={},n[o]=t):n=r.extend({},n),r.each(n,function(t,u){if(h&&tr.test(t))return void delete n[t];var o,f=yi(e,t.toLowerCase());o=f[0][f[1]];f[0][f[1]]=u&&u.nodeType?r(u):u;i=nr.test(t)||i;n[t]=[f[0],f[1],u,o]}),pt(e),this.positioning=f,r.each(n,r.proxy(fr,this)),this.positioning=u,this.rendered&&this.tooltip[0].offsetWidth>0&&i&&this.reposition("mouse"===e.position.target?s:this.cache.event),this};e._update=function(n,t){var i=this,e=this.cache;return this.rendered&&n?(r.isFunction(n)&&(n=n.call(this.elements.target,e.event,this)||""),r.isFunction(n.then)?(e.waiting=f,n.then(function(n){return e.waiting=u,i._update(n,t)},s,function(n){return i._update(n,t)})):n===u||!n&&""!==n?u:(n.jquery&&n.length>0?t.empty().append(n.css({display:"block",visibility:"visible"})):t.html(n),this._waitForContent(t).then(function(n){i.rendered&&i.tooltip[0].offsetWidth>0&&i.reposition(e.event,!n.length)}))):u};e._waitForContent=function(n){var t=this.cache;return t.waiting=f,(r.fn.imagesLoaded?n.imagesLoaded():r.Deferred().resolve([])).done(function(){t.waiting=u}).promise()};e._updateContent=function(n,t){this._update(n,this.elements.content,t)};e._updateTitle=function(n,t){this._update(n,this.elements.title,t)===u&&this._removeTitle(u)};e._createTitle=function(){var n=this.elements,t=this._id+"-title";n.titlebar&&this._removeTitle();n.titlebar=r("<div />",{"class":o+"-titlebar "+(this.options.style.widget?wt("header"):"")}).append(n.title=r("<div />",{id:t,"class":o+"-title","aria-atomic":f})).insertBefore(n.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(n){r(this).toggleClass("ui-state-active ui-state-focus","down"===n.type.substr(-4))}).delegate(".qtip-close","mouseover mouseout",function(n){r(this).toggleClass("ui-state-hover","mouseover"===n.type)});this.options.content.button&&this._createButton()};e._removeTitle=function(n){var t=this.elements;t.title&&(t.titlebar.remove(),t.titlebar=t.title=t.button=s,n!==u&&this.reposition())};e._createPosClass=function(n){return o+"-pos-"+(n||this.options.position.my).abbrev()};e.reposition=function(i,e){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=f;var a,v,ut,at,c=this.cache,d=this.tooltip,p=this.options.position,o=p.target,et=p.my,g=p.at,ot=p.viewport,ht=p.container,ft=p.adjust,vt=ft.method.split(" "),ct=d.outerWidth(u),lt=d.outerHeight(u),nt=0,it=0,yt=d.css("position"),s={left:0,top:0},wt=d[0].offsetWidth>0,bt=i&&"scroll"===i.type,st=r(n),pt=ht[0].ownerDocument,rt=this.mouse;if(r.isArray(o)&&2===o.length)g={x:w,y:b},s={left:o[0],top:o[1]};else if("mouse"===o)g={x:w,y:b},(!ft.mouse||this.options.hide.distance)&&c.origin&&c.origin.pageX?i=c.origin:!i||i&&("resize"===i.type||"scroll"===i.type)?i=c.event:rt&&rt.pageX&&(i=rt),"static"!==yt&&(s=ht.offset()),pt.body.offsetWidth!==(n.innerWidth||pt.documentElement.clientWidth)&&(v=r(t.body).offset()),s={left:i.pageX-s.left+(v&&v.left||0),top:i.pageY-s.top+(v&&v.top||0)},ft.mouse&&bt&&rt&&(s.left-=(rt.scrollX||0)-st.scrollLeft(),s.top-=(rt.scrollY||0)-st.scrollTop());else{if("event"===o?i&&i.target&&"scroll"!==i.type&&"resize"!==i.type?c.target=r(i.target):i.target||(c.target=this.elements.target):"event"!==o&&(c.target=r(o.jquery?o:this.elements.target)),o=c.target,o=r(o).eq(0),0===o.length)return this;o[0]===t||o[0]===n?(nt=y.iOS?n.innerWidth:o.width(),it=y.iOS?n.innerHeight:o.height(),o[0]===n&&(s={top:(ot||o).scrollTop(),left:(ot||o).scrollLeft()})):h.imagemap&&o.is("area")?a=h.imagemap(this,o,g,h.viewport?vt:u):h.svg&&o&&o[0].ownerSVGElement?a=h.svg(this,o,g,h.viewport?vt:u):(nt=o.outerWidth(u),it=o.outerHeight(u),s=o.offset());a&&(nt=a.width,it=a.height,v=a.offset,s=a.position);s=this.reposition.offset(o,s,ht);(y.iOS>3.1&&y.iOS<4.1||y.iOS>=4.3&&y.iOS<4.33||!y.iOS&&"fixed"===yt)&&(s.left-=st.scrollLeft(),s.top-=st.scrollTop());(!a||a&&a.adjustable!==u)&&(s.left+=g.x===k?nt:g.x===l?nt/2:0,s.top+=g.y===tt?it:g.y===l?it/2:0)}return s.left+=ft.x+(et.x===k?-ct:et.x===l?-ct/2:0),s.top+=ft.y+(et.y===tt?-lt:et.y===l?-lt/2:0),h.viewport?(ut=s.adjusted=h.viewport(this,s,p,nt,it,ct,lt),v&&ut.left&&(s.left+=v.left),v&&ut.top&&(s.top+=v.top),ut.my&&(this.position.my=ut.my)):s.adjusted={left:0,top:0},c.posClass!==(at=this._createPosClass(this.position.my))&&d.removeClass(c.posClass).addClass(c.posClass=at),this._trigger("move",[s,ot.elem||ot],i)?(delete s.adjusted,e===u||!wt||isNaN(s.left)||isNaN(s.top)||"mouse"===o||!r.isFunction(p.effect)?d.css(s):r.isFunction(p.effect)&&(p.effect.call(d,this,r.extend({},s)),d.queue(function(n){r(this).css({opacity:"",height:""});y.ie&&this.style.removeAttribute("filter");n()})),this.positioning=u,this):this};e.reposition.offset=function(n,i,u){function s(n,t){i.left+=t*n.scrollLeft();i.top+=t*n.scrollTop()}if(!u[0])return i;var o,h,e,c,l=r(n[0].ownerDocument),a=!!y.ie&&"CSS1Compat"!==t.compatMode,f=u[0];do"static"!==(h=r.css(f,"position"))&&("fixed"===h?(e=f.getBoundingClientRect(),s(l,-1)):(e=r(f).position(),e.left+=parseFloat(r.css(f,"borderLeftWidth"))||0,e.top+=parseFloat(r.css(f,"borderTopWidth"))||0),i.left-=e.left+(parseFloat(r.css(f,"marginLeft"))||0),i.top-=e.top+(parseFloat(r.css(f,"marginTop"))||0),o||"hidden"===(c=r.css(f,"overflow"))||"visible"===c||(o=r(f)));while(f=f.offsetParent);return o&&(o[0]!==l[0]||a)&&s(o,1),i};vt=(nt=e.reposition.Corner=function(n,t){n=(""+n).replace(/([A-Z])/," $1").replace(/middle/gi,l).toLowerCase();this.x=(n.match(/left|right/i)||n.match(/center/)||["inherit"])[0].toLowerCase();this.y=(n.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase();this.forceY=!!t;var i=n.charAt(0);this.precedance="t"===i||"b"===i?v:p}).prototype;vt.invert=function(n,t){this[n]=this[n]===w?k:this[n]===k?w:t||this[n]};vt.string=function(n){var t=this.x,i=this.y,r=t!==i?"center"===t||"center"!==i&&(this.precedance===v||this.forceY)?[i,t]:[t,i]:[t];return n!==!1?r.join(" "):r};vt.abbrev=function(){var n=this.string(!1);return n[0].charAt(0)+(n[1]&&n[1].charAt(0)||"")};vt.clone=function(){return new nt(this.string(),this.forceY)};e.toggle=function(n,i){var c=this.cache,b=this.options,e=this.tooltip;if(i){if(/over|enter/.test(i.type)&&c.event&&/out|leave/.test(c.event.type)&&b.show.target.add(i.target).length===b.show.target.length&&e.has(i.relatedTarget).length)return this;c.event=r.event.fix(i)}if(this.waiting&&!n&&(this.hiddenDuringWait=f),!this.rendered)return n?this.render(1):this;if(this.destroyed||this.disabled)return this;var v,p,l,w=n?"show":"hide",h=this.options[w],k=(this.options[n?"hide":"show"],this.options.position),a=this.options.content,d=this.tooltip.css("width"),g=this.tooltip.is(":visible"),nt=n||1===h.target.length,tt=!i||h.target.length<2||c.target[0]===i.target;return(typeof n).search("boolean|number")&&(n=!g),v=!e.is(":animated")&&g===n&&tt,p=v?s:!!this._trigger(w,[90]),this.destroyed?this:(p!==u&&n&&this.focus(i),!p||v?this:(r.attr(e[0],"aria-hidden",!n),n?(this.mouse&&(c.origin=r.event.fix(this.mouse)),r.isFunction(a.text)&&this._updateContent(a.text,u),r.isFunction(a.title)&&this._updateTitle(a.title,u),!kt&&"mouse"===k.target&&k.adjust.mouse&&(r(t).bind("mousemove."+o,this._storeMouse),kt=f),d||e.css("width",e.outerWidth(u)),this.reposition(i,arguments[2]),d||e.css("width",""),h.solo&&("string"==typeof h.solo?r(h.solo):r(it,h.solo)).not(e).not(h.target).qtip("hide",r.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete c.origin,kt&&!r(it+'[tracking="true"]:visible',h.solo).not(e).length&&(r(t).unbind("mousemove."+o),kt=u),this.blur(i)),l=r.proxy(function(){n?(y.ie&&e[0].style.removeAttribute("filter"),e.css("overflow",""),"string"==typeof h.autofocus&&r(this.options.show.autofocus,e).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):e.css({display:"",visibility:"",opacity:"",left:"",top:""});this._trigger(n?"visible":"hidden")},this),h.effect===u||nt===u?(e[w](),l()):r.isFunction(h.effect)?(e.stop(1,1),h.effect.call(e,this),e.queue("fx",function(n){l();n()})):e.fadeTo(90,n?1:0,l),n&&h.target.trigger("qtip-"+this.id+"-inactive"),this))};e.show=function(n){return this.toggle(f,n)};e.hide=function(n){return this.toggle(u,n)};e.focus=function(n){if(!this.rendered||this.destroyed)return this;var t=r(it),i=this.tooltip,f=parseInt(i[0].style.zIndex,10),u=c.zindex+t.length;return i.hasClass(ot)||this._trigger("focus",[u],n)&&(f!==u&&(t.each(function(){this.style.zIndex>f&&(this.style.zIndex=this.style.zIndex-1)}),t.filter("."+ot).qtip("blur",n)),i.addClass(ot)[0].style.zIndex=u),this};e.blur=function(n){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass(ot),this._trigger("blur",[this.tooltip.css("zIndex")],n),this)};e.disable=function(n){return this.destroyed?this:("toggle"===n?n=!(this.rendered?this.tooltip.hasClass(a):this.disabled):"boolean"!=typeof n&&(n=f),this.rendered&&this.tooltip.toggleClass(a,n).attr("aria-disabled",n),this.disabled=!!n,this)};e.enable=function(){return this.disable(u)};e._createButton=function(){var e=this,n=this.elements,i=n.tooltip,t=this.options.content.button,s="string"==typeof t,f=s?t:"Close tooltip";n.button&&n.button.remove();n.button=t.jquery?t:r("<a />",{"class":"qtip-close "+(this.options.style.widget?"":o+"-icon"),title:f,"aria-label":f}).prepend(r("<span />",{"class":"ui-icon ui-icon-close",html:"&times;"}));n.button.appendTo(n.titlebar||i).attr("role","button").click(function(n){return i.hasClass(a)||e.hide(n),u})};e._updateButton=function(n){if(!this.rendered)return u;var t=this.elements.button;n?this._createButton():t.remove()};e._setWidget=function(){var t=this.options.style.widget,n=this.elements,i=n.tooltip,r=i.hasClass(a);i.removeClass(a);a=t?"ui-state-disabled":"qtip-disabled";i.toggleClass(a,r);i.toggleClass("ui-helper-reset "+wt(),t).toggleClass(oi,this.options.style.def&&!t);n.content&&n.content.toggleClass(wt("content"),t);n.titlebar&&n.titlebar.toggleClass(wt("header"),t);n.button&&n.button.toggleClass(o+"-icon",!t)};e._storeMouse=function(n){return(this.mouse=r.event.fix(n)).type="mousemove",this};e._bind=function(n,t,i,u,f){if(n&&i&&t.length){var e="."+this._id+(u?"-"+u:"");return r(n).bind((t.split?t:t.join(e+" "))+e,r.proxy(i,f||this)),this}};e._unbind=function(n,t){return n&&r(n).unbind("."+this._id+(t?"-"+t:"")),this};e._trigger=function(n,t,i){var f=r.Event("tooltip"+n);return f.originalEvent=i&&r.extend({},i)||this.cache.event||s,this.triggering=n,this.tooltip.trigger(f,[this].concat(t||[])),this.triggering=u,!f.isDefaultPrevented()};e._bindEvents=function(n,t,i,u,f,e){var o=i.filter(u).add(u.filter(i)),s=[];o.length&&(r.each(t,function(t,i){var u=r.inArray(i,n);u>-1&&s.push(n.splice(u,1)[0])}),s.length&&(this._bind(o,s,function(n){var t=this.rendered?this.tooltip[0].offsetWidth>0:!1;(t?e:f).call(this,n)}),i=i.not(o),u=u.not(o)));this._bind(i,n,f);this._bind(u,t,e)};e._assignInitialEvents=function(n){function i(n){return this.disabled||this.destroyed?u:(this.cache.event=n&&r.event.fix(n),this.cache.target=n&&r(n.target),clearTimeout(this.timers.show),void(this.timers.show=bt.call(this,function(){this.render("object"==typeof n||t.show.ready)},t.prerender?0:t.show.delay)))}var t=this.options,e=t.show.target,s=t.hide.target,h=t.show.event?r.trim(""+t.show.event).split(" "):[],o=t.hide.event?r.trim(""+t.hide.event).split(" "):[];this._bind(this.elements.target,["remove","removeqtip"],function(){this.destroy(!0)},"destroy");/mouse(over|enter)/i.test(t.show.event)&&!/mouse(out|leave)/i.test(t.hide.event)&&o.push("mouseleave");this._bind(e,"mousemove",function(n){this._storeMouse(n);this.cache.onTarget=f});this._bindEvents(h,o,e,s,i,function(){return this.timers?void clearTimeout(this.timers.show):u});(t.show.ready||t.prerender)&&i.call(this,n)};e._assignEvents=function(){var y=this,i=this.options,f=i.position,e=this.tooltip,s=i.show.target,o=i.hide.target,p=f.container,h=f.viewport,l=r(t),v=(r(t.body),r(n)),w=i.show.event?r.trim(""+i.show.event).split(" "):[],b=i.hide.event?r.trim(""+i.hide.event).split(" "):[];r.each(i.events,function(n,t){y._bind(e,"toggle"===n?["tooltipshow","tooltiphide"]:["tooltip"+n],t,null,e)});/mouse(out|leave)/i.test(i.hide.event)&&"window"===i.hide.leave&&this._bind(l,["mouseout","blur"],function(n){/select|option/.test(n.target.nodeName)||n.relatedTarget||this.hide(n)});i.hide.fixed?o=o.add(e.addClass(gi)):/mouse(over|enter)/i.test(i.show.event)&&this._bind(o,"mouseleave",function(){clearTimeout(this.timers.show)});(""+i.hide.event).indexOf("unfocus")>-1&&this._bind(p.closest("html"),["mousedown","touchstart"],function(n){var t=r(n.target),i=this.rendered&&!this.tooltip.hasClass(a)&&this.tooltip[0].offsetWidth>0,u=t.parents(it).filter(this.tooltip[0]).length>0;t[0]===this.target[0]||t[0]===this.tooltip[0]||u||this.target.has(t[0]).length||!i||this.hide(n)});"number"==typeof i.hide.inactive&&(this._bind(s,"qtip-"+this.id+"-inactive",ri,"inactive"),this._bind(o.add(e),c.inactiveEvents,ri));this._bindEvents(w,b,s,o,er,or);this._bind(s.add(e),"mousemove",function(n){if("number"==typeof i.hide.distance){var t=this.cache.origin||{},r=this.options.hide.distance,u=Math.abs;(u(n.pageX-t.pageX)>=r||u(n.pageY-t.pageY)>=r)&&this.hide(n)}this._storeMouse(n)});"mouse"===f.target&&f.adjust.mouse&&(i.hide.event&&this._bind(s,["mouseenter","mouseleave"],function(n){return this.cache?void(this.cache.onTarget="mouseenter"===n.type):u}),this._bind(l,"mousemove",function(n){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(a)&&this.tooltip[0].offsetWidth>0&&this.reposition(n)}));(f.adjust.resize||h.length)&&this._bind(r.event.special.resize?h:v,"resize",pi);f.adjust.scroll&&this._bind(v.add(f.container),"scroll",pi)};e._unassignEvents=function(){var u=this.options,f=u.show.target,e=u.hide.target,i=r.grep([this.elements.target[0],this.rendered&&this.tooltip[0],u.position.container[0],u.position.viewport[0],u.position.container.closest("html")[0],n,t],function(n){return"object"==typeof n});f&&f.toArray&&(i=i.concat(f.toArray()));e&&e.toArray&&(i=i.concat(e.toArray()));this._unbind(i)._unbind(i,"destroy")._unbind(i,"inactive")};r(function(){wi(it,["mouseenter","mouseleave"],function(n){var u="mouseenter"===n.type,i=r(n.currentTarget),f=r(n.relatedTarget||n.target),t=this.options;u?(this.focus(n),i.hasClass(gi)&&!i.hasClass(a)&&clearTimeout(this.timers.hide)):"mouse"===t.position.target&&t.position.adjust.mouse&&t.hide.event&&t.show.target&&!f.closest(t.show.target[0]).length&&this.hide(n);i.toggleClass(ar,u)});wi("["+dt+"]",di,ri)});c=r.fn.qtip=function(n,t,e){var a=(""+n).toLowerCase(),y=s,p=r.makeArray(arguments).slice(1),v=p[p.length-1],l=this[0]?r.data(this[0],o):s;return!arguments.length&&l||"api"===a?l:"string"==typeof n?(this.each(function(){var n=r.data(this,o);if(!n)return f;if(v&&v.timeStamp&&(n.cache.event=v),t&&("option"===a||"options"===a)){if(e===i&&!r.isPlainObject(t))return y=n.get(t),u;n.set(t,e)}else n[a]&&n[a].apply(n,p)}),y!==s?y:this):"object"!=typeof n&&arguments.length?void 0:(l=pt(r.extend(f,{},n)),this.each(function(n){var i,t;return t=r.isArray(l.id)?l.id[n]:l.id,t=!t||t===u||t.length<1||c.api[t]?c.nextid++:t,i=sr(r(this),t,l),i===u?f:(c.api[t]=i,r.each(h,function(){"initialize"===this.initialize&&this(i)}),void i._assignInitialEvents(v))}))};r.qtip=ii;c.api={};r.each({attr:function(n,t){if(this.length){var u=this[0],f="title",i=r.data(u,"qtip");if(n===f&&i&&"object"==typeof i&&i.options.suppress)return arguments.length<2?r.attr(u,rt):(i&&i.options.content.attr===f&&i.cache.attr&&i.set("content.text",t),this.attr(rt,t))}return r.fn["attr"+st].apply(this,arguments)},clone:function(n){var t=(r([]),r.fn["clone"+st].apply(this,arguments));return n||t.filter("["+rt+"]").attr("title",function(){return r.attr(this,rt)}).removeAttr(rt),t}},function(n,t){if(!t||r.fn[n+st])return f;var i=r.fn[n+st]=r.fn[n];r.fn[n]=function(){return t.apply(this,arguments)||i.apply(this,arguments)}});r.ui||(r["cleanData"+st]=r.cleanData,r.cleanData=function(n){for(var t,i=0;(t=r(n[i])).length;i++)if(t.attr(ei))try{t.triggerHandler("removeqtip")}catch(u){}r["cleanData"+st].apply(this,arguments)});c.version="2.2.1";c.nextid=0;c.inactiveEvents=di;c.zindex=15e3;c.defaults={prerender:u,id:u,overwrite:f,suppress:f,content:{text:f,attr:"title",title:u,button:u},position:{my:"top left",at:"bottom right",target:u,container:u,viewport:u,adjust:{x:0,y:0,mouse:f,scroll:f,resize:f,method:"flipinvert flipinvert"},effect:function(n,t){r(this).animate(t,{duration:200,queue:u})}},show:{target:u,event:"mouseenter",effect:f,delay:90,solo:u,ready:u,autofocus:u},hide:{target:u,event:"mouseleave",effect:f,delay:0,fixed:u,inactive:u,leave:"window",distance:u},style:{classes:"",widget:u,width:u,height:u,def:f},events:{render:s,move:s,show:s,hide:s,toggle:s,visible:s,hidden:s,focus:s,blur:s}};var si,hi="margin",gt="border",yt="color",ht="background-color",ir="transparent",rr=" !important",ni=!!t.createElement("canvas").getContext,ur=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,ci={},vr=["Webkit","O","Moz","ms"];if(ni)var yr=n.devicePixelRatio||1,pr=function(){var n=t.createElement("canvas").getContext("2d");return n.backingStorePixelRatio||n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||1}(),ct=yr/pr;else li=function(n,t,i){return"<qtipvml:"+n+' xmlns="urn:schemas-microsoft.com:vml" class="qtip-vml" '+(t||"")+' style="behavior: url(#default#VML); '+(i||"")+'" />'};r.extend(bi.prototype,{init:function(n){var t,i;i=this.element=n.elements.tip=r("<div />",{"class":o+"-tip"}).prependTo(n.tooltip);ni?(t=r("<canvas />").appendTo(this.element)[0].getContext("2d"),t.lineJoin="miter",t.miterLimit=1e5,t.save()):(t=li("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(t+t),n._bind(r("*",i).add(i),["click","mousedown"],function(n){n.stopPropagation()},this._ns));n._bind(n.tooltip,"tooltipmove",this.reposition,this._ns,this);this.create()},_swapDimensions:function(){this.size[0]=this.options.height;this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width;this.size[1]=this.options.height},_useTitle:function(n){var t=this.qtip.elements.titlebar;return t&&(n.y===b||n.y===l&&this.element.position().top+this.size[1]/2+this.options.offset<t.outerHeight(f))},_parseCorner:function(n){var t=this.qtip.options.position.my;return n===u||t===u?n=u:n===f?n=new nt(t.string()):n.string||(n=new nt(n),n.fixed=f),n},_parseWidth:function(n,t,i){var r=this.qtip.elements,u=gt+lt(t)+"Width";return(i?et(i,u):et(r.content,u)||et(this._useTitle(n)&&r.titlebar||r.content,u)||et(r.tooltip,u))||0},_parseRadius:function(n){var t=this.qtip.elements,i=gt+lt(n.y)+lt(n.x)+"Radius";return y.ie<9?0:et(this._useTitle(n)&&t.titlebar||t.content,i)||et(t.tooltip,i)||0},_invalidColour:function(n,t,i){var r=n.css(t);return!r||i&&r===n.css(i)||ur.test(r)?u:r},_parseColours:function(n){var i=this.qtip.elements,u=this.element.css("cssText",""),f=gt+lt(n[n.precedance])+lt(yt),o=this._useTitle(n)&&i.titlebar||i.content,t=this._invalidColour,e=[];return e[0]=t(u,ht)||t(o,ht)||t(i.content,ht)||t(i.tooltip,ht)||u.css(ht),e[1]=t(u,f,yt)||t(o,f,yt)||t(i.content,f,yt)||t(i.tooltip,f,yt)||i.tooltip.css(f),r("*",u).add(u).css("cssText",ht+":"+ir+rr+";"+gt+":0"+rr+";"),e},_calculateSize:function(n){var o,f,e,s=n.precedance===v,h=this.options.width,r=this.options.height,c="c"===n.abbrev(),l=(s?h:r)*(c?.5:1),i=Math.pow,a=Math.round,u=Math.sqrt(i(l,2)+i(r,2)),t=[this.border/l*u,this.border/r*u];return t[2]=Math.sqrt(i(t[0],2)-i(this.border,2)),t[3]=Math.sqrt(i(t[1],2)-i(this.border,2)),o=u+t[2]+t[3]+(c?0:t[0]),f=o/u,e=[a(f*h),a(f*r)],s?e:e.reverse()},_calculateTip:function(n,t,i){i=i||1;t=t||this.size;var r=t[0]*i,u=t[1]*i,e=Math.ceil(r/2),o=Math.ceil(u/2),f={br:[0,0,r,u,r,0],bl:[0,0,r,0,0,u],tr:[0,u,r,0,r,u],tl:[0,0,0,u,r,u],tc:[0,u,e,0,r,u],bc:[0,0,r,0,e,u],rc:[0,0,r,o,0,u],lc:[r,0,r,u,0,o]};return f.lt=f.br,f.rt=f.bl,f.lb=f.tr,f.rb=f.tl,f[n.abbrev()]},_drawCoords:function(n,t){n.beginPath();n.moveTo(t[0],t[1]);n.lineTo(t[2],t[3]);n.lineTo(t[4],t[5]);n.closePath()},create:function(){var n=this.corner=(ni||y.ie)&&this._parseCorner(this.options.corner);return(this.enabled=!!this.corner&&"c"!==this.corner.abbrev())&&(this.qtip.cache.corner=n.clone(),this.update()),this.element.toggle(this.enabled),this.corner},update:function(t,i){if(!this.enabled)return this;var a,ft,h,c,et,d,o,s,st=this.qtip.elements,ot=this.element,it=ot.children(),rt=this.options,g=this.size,e=rt.mimic,ut=Math.round;t||(t=this.qtip.cache.corner||this.corner);e===u?e=t:(e=new nt(e),e.precedance=t.precedance,"inherit"===e.x?e.x=t.x:"inherit"===e.y?e.y=t.y:e.x===e.y&&(e[t.precedance]=t[t.precedance]));ft=e.precedance;t.precedance===p?this._swapDimensions():this._resetDimensions();a=this.color=this._parseColours(t);a[1]!==ir?(s=this.border=this._parseWidth(t,t[t.precedance]),rt.border&&1>s&&!ur.test(a[1])&&(a[0]=a[1]),this.border=s=rt.border!==f?rt.border:s):this.border=s=0;o=this.size=this._calculateSize(t);ot.css({width:o[0],height:o[1],lineHeight:o[1]+"px"});d=t.precedance===v?[ut(e.x===w?s:e.x===k?o[0]-g[0]-s:(o[0]-g[0])/2),ut(e.y===b?o[1]-g[1]:0)]:[ut(e.x===w?o[0]-g[0]:0),ut(e.y===b?s:e.y===tt?o[1]-g[1]-s:(o[1]-g[1])/2)];ni?(h=it[0].getContext("2d"),h.restore(),h.save(),h.clearRect(0,0,6e3,6e3),c=this._calculateTip(e,g,ct),et=this._calculateTip(e,this.size,ct),it.attr(at,o[0]*ct).attr(fi,o[1]*ct),it.css(at,o[0]).css(fi,o[1]),this._drawCoords(h,et),h.fillStyle=a[1],h.fill(),h.translate(d[0]*ct,d[1]*ct),this._drawCoords(h,c),h.fillStyle=a[0],h.fill()):(c=this._calculateTip(e),c="m"+c[0]+","+c[1]+" l"+c[2]+","+c[3]+" "+c[4]+","+c[5]+" xe",d[2]=s&&/^(r|b)/i.test(t.string())?8===y.ie?2:1:0,it.css({coordsize:o[0]+s+" "+(o[1]+s),antialias:""+(e.string().indexOf(l)>-1),left:d[0]-d[2]*Number(ft===p),top:d[1]-d[2]*Number(ft===v),width:o[0]+s,height:o[1]+s}).each(function(n){var t=r(this);t[t.prop?"prop":"attr"]({coordsize:o[0]+s+" "+(o[1]+s),path:c,fillcolor:a[0],filled:!!n,stroked:!n}).toggle(!(!s&&!n));n||t.html(li("stroke",'weight="'+2*s+'px" color="'+a[1]+'" miterlimit="1000" joinstyle="miter"'))}));n.opera&&setTimeout(function(){st.tip.css({display:"inline-block",visibility:"visible"})},1);i!==u&&this.calculate(t,o)},calculate:function(n,t){if(!this.enabled)return u;var i,o,e=this,s=this.qtip.elements,c=this.element,h=this.options.offset,f=(s.tooltip.hasClass("ui-widget"),{});return n=n||this.corner,i=n.precedance,t=t||this._calculateSize(n),o=[n.x,n.y],i===p&&o.reverse(),r.each(o,function(r,u){var o,a,c;u===l?(o=i===v?w:b,f[o]="50%",f[hi+"-"+o]=-Math.round(t[i===v?0:1]/2)+h):(o=e._parseWidth(n,u,s.tooltip),a=e._parseWidth(n,u,s.content),c=e._parseRadius(n),f[u]=Math.max(-e.border,r?a:h+(c>o?c:-o)))}),f[n[i]]-=t[i===p?0:1],c.css({margin:"",top:"",bottom:"",left:"",right:""}).css(f),f},reposition:function(n,t,r){function it(n,t,i,r,u){n===ft&&s.precedance===t&&h[r]&&s[i]!==l?s.precedance=s.precedance===p?v:p:n!==ft&&h[r]&&(s[t]=s[t]===l?h[r]>0?r:u:s[t]===r?u:r)}function rt(n,t,f){s[n]===l?nt[hi+"-"+t]=o[n]=e[hi+"-"+t]-h[t]:(a=e[f]!==i?[h[t],-e[t]]:[-h[t],e[t]],(o[n]=Math.max(a[0],a[1]))>a[0]&&(r[t]-=h[t],o[t]=u),nt[e[f]!==i?f:t]=o[n])}if(this.enabled){var e,a,c=t.cache,s=this.corner.clone(),h=r.adjusted,y=t.options.position.adjust.method.split(" "),d=y[0],g=y[1]||y[0],o={left:u,top:u,x:0,y:0},nt={};this.corner.fixed!==f&&(it(d,p,v,w,k),it(g,v,p,b,tt),(s.string()!==c.corner.string()||c.cornerTop!==h.top||c.cornerLeft!==h.left)&&this.update(s,u));e=this.calculate(s);e.right!==i&&(e.left=-e.right);e.bottom!==i&&(e.top=-e.bottom);e.user=this.offset;(o.left=d===ft&&!!h.left)&&rt(p,w,k);(o.top=g===ft&&!!h.top)&&rt(v,b,tt);this.element.css(nt).toggle(!(o.x&&o.y||s.x===l&&o.y||s.y===l&&o.x));r.left-=e.left.charAt?e.user:d!==ft||o.top||!o.left&&!o.top?e.left+this.border:0;r.top-=e.top.charAt?e.user:g!==ft||o.left||!o.left&&!o.top?e.top+this.border:0;c.cornerLeft=h.left;c.cornerTop=h.top;c.corner=s.clone()}},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns);this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}});si=h.tip=function(n){return new bi(n,n.options.style.tip)};si.initialize="render";si.sanitize=function(n){if(n.style&&"tip"in n.style){var t=n.style.tip;"object"!=typeof t&&(t=n.style.tip={corner:t});/string|boolean/i.test(typeof t.corner)||(t.corner=f)}};ui.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create();this.qtip.reposition()},"^style.tip.(height|width)$":function(n){this.size=[n.width,n.height];this.update();this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}};r.extend(f,c.defaults,{style:{tip:{corner:f,mimic:u,width:6,height:6,border:f,offset:0}}});h.viewport=function(i,r,f,e,o,s,h){function lt(n,t,i,u,f,e,o,s,h){var v=r[f],c=y[n],k=bt[n],it=i===ft,nt=c===f?h:c===e?-h:-h/2,rt=k===f?s:k===e?-s:-s/2,tt=ot[f]+g[f]-(vt?0:d[f]),b=tt-v,w=v+h-(o===at?ut:et)-tt,p=nt-(y.precedance===n||c===y[t]?rt:0)-(k===l?s/2:0);return it?(p=(c===f?1:-1)*nt,r[f]+=b>0?b:w>0?-w:0,r[f]=Math.max(-d[f]+g[f],v-p,Math.min(Math.max(-d[f]+g[f]+(o===at?ut:et),v+p),r[f],"center"===c?v-nt:1e9))):(u*=i===cr?2:0,b>0&&(c!==f||w>0)?(r[f]-=p+u,a.invert(n,f)):w>0&&(c!==e||b>0)&&(r[f]-=(c===l?-p:p)+u,a.invert(n,e)),r[f]<ot&&-r[f]>w&&(r[f]=v,a=y.clone())),r[f]-v}var rt,a,d,vt,ut,et,ot,g,yt=f.target,wt=i.elements.tooltip,y=f.my,bt=f.at,nt=f.adjust,st=nt.method.split(" "),ht=st[0],ct=st[1]||st[0],c=f.viewport,pt=f.container,it=(i.cache,{left:0,top:0});return c.jquery&&yt[0]!==n&&yt[0]!==t.body&&"none"!==nt.method?(d=pt.offset()||it,vt="static"===pt.css("position"),rt="fixed"===wt.css("position"),ut=c[0]===n?c.width():c.outerWidth(u),et=c[0]===n?c.height():c.outerHeight(u),ot={left:rt?0:c.scrollLeft(),top:rt?0:c.scrollTop()},g=c.offset()||it,("shift"!==ht||"shift"!==ct)&&(a=y.clone()),it={left:"none"!==ht?lt(p,v,ht,nt.x,w,k,at,e,s):0,top:"none"!==ct?lt(v,p,ct,nt.y,b,tt,fi,o,h):0,my:a}):it};h.polys={polygon:function(n,t){for(var r,h,c,i={width:0,height:0,position:{top:1e10,right:0,bottom:0,left:1e10},adjustable:u},f=0,e=[],o=1,s=1,a=0,v=0,f=n.length;f--;)r=[parseInt(n[--f],10),parseInt(n[f+1],10)],r[0]>i.position.right&&(i.position.right=r[0]),r[0]<i.position.left&&(i.position.left=r[0]),r[1]>i.position.bottom&&(i.position.bottom=r[1]),r[1]<i.position.top&&(i.position.top=r[1]),e.push(r);if(h=i.width=Math.abs(i.position.right-i.position.left),c=i.height=Math.abs(i.position.bottom-i.position.top),"c"===t.abbrev())i.position={left:i.position.left+i.width/2,top:i.position.top+i.height/2};else{for(;h>0&&c>0&&o>0&&s>0;)for(h=Math.floor(h/2),c=Math.floor(c/2),t.x===w?o=h:t.x===k?o=i.width-h:o+=Math.floor(h/2),t.y===b?s=c:t.y===tt?s=i.height-c:s+=Math.floor(c/2),f=e.length;f--&&!(e.length<2);)a=e[f][0]-i.position.left,v=e[f][1]-i.position.top,(t.x===w&&a>=o||t.x===k&&o>=a||t.x===l&&(o>a||a>i.width-o)||t.y===b&&v>=s||t.y===tt&&s>=v||t.y===l&&(s>v||v>i.height-s))&&e.splice(f,1);i.position={left:e[0][0],top:e[0][1]}}return i},rect:function(n,t,i,r){return{width:Math.abs(i-n),height:Math.abs(r-t),position:{left:Math.min(n,i),top:Math.min(t,r)}}},_angles:{tc:1.5,tr:7/4,tl:5/4,bc:.5,br:.25,bl:.75,rc:2,lc:1,c:0},ellipse:function(n,t,i,r,f){var e=h.polys._angles[f.abbrev()],o=0===e?0:i*Math.cos(e*Math.PI),s=r*Math.sin(e*Math.PI);return{width:2*i-Math.abs(o),height:2*r-Math.abs(s),position:{left:n+o,top:t+s},adjustable:u}},circle:function(n,t,i,r){return h.polys.ellipse(n,t,i,i,r)}};h.imagemap=function(n,t,i){t.jquery||(t=r(t));var e,s,c,o,v,l=(t.attr("shape")||"rect").toLowerCase().replace("poly","polygon"),f=r('img[usemap="#'+t.parent("map").attr("name")+'"]'),y=r.trim(t.attr("coords")),a=y.replace(/,$/,"").split(",");if(!f.length)return u;if("polygon"===l)o=h.polys.polygon(a,i);else{if(!h.polys[l])return u;for(c=-1,v=a.length,s=[];++c<v;)s.push(parseInt(a[c],10));o=h.polys[l].apply(this,s.concat(i))}return e=f.offset(),e.left+=Math.ceil((f.outerWidth(u)-f.width())/2),e.top+=Math.ceil((f.outerHeight(u)-f.height())/2),o.position.left+=e.left,o.position.top+=e.top,o};h.svg=function(n,i,f){for(var a,b,p,k,w,v,s,o,c,e=(r(t),i[0]),y=r(e.ownerSVGElement),l=e.ownerDocument,d=(parseInt(i.css("stroke-width"),10)||0)/2;!e.getBBox;)e=e.parentNode;if(!e.getBBox||!e.parentNode)return u;switch(e.nodeName){case"ellipse":case"circle":o=h.polys.ellipse(e.cx.baseVal.value,e.cy.baseVal.value,(e.rx||e.r).baseVal.value+d,(e.ry||e.r).baseVal.value+d,f);break;case"line":case"polygon":case"polyline":for(s=e.points||[{x:e.x1.baseVal.value,y:e.y1.baseVal.value},{x:e.x2.baseVal.value,y:e.y2.baseVal.value}],o=[],v=-1,k=s.numberOfItems||s.length;++v<k;)w=s.getItem?s.getItem(v):s[v],o.push.apply(o,[w.x,w.y]);o=h.polys.polygon(o,f);break;default:o=e.getBBox();o={width:o.width,height:o.height,position:{left:o.x,top:o.y}}}return c=o.position,y=y[0],y.createSVGPoint&&(b=e.getScreenCTM(),s=y.createSVGPoint(),s.x=c.left,s.y=c.top,p=s.matrixTransform(b),c.left=p.x,c.top=p.y),l!==t&&"mouse"!==n.position.target&&(a=r((l.defaultView||l.parentWindow).frameElement).offset(),a&&(c.left+=a.left,c.top+=a.top)),l=r(l),c.left+=l.scrollLeft(),c.top+=l.scrollTop(),o};ti="qtip-modal";g="."+ti;d=function(){function l(n){if(r.expr[":"].focusable)return r.expr[":"].focusable;var t,i,u,e=!isNaN(r.attr(n,"tabindex")),f=n.nodeName&&n.nodeName.toLowerCase();return"area"===f?(t=n.parentNode,i=t.name,n.href&&i&&"map"===t.nodeName.toLowerCase()?(u=r("img[usemap=#"+i+"]")[0],!!u&&u.is(":visible")):!1):/input|select|textarea|button|object/.test(f)?!n.disabled:"a"===f?n.href||e:e}function h(n){o.length<1&&n.length?n.not("body").blur():o.first().focus()}function a(t){if(n.is(":visible")){var e,f=r(t.target),s=i.tooltip,c=f.closest(it);e=c.length<1?u:parseInt(c[0].style.zIndex,10)>parseInt(s[0].style.zIndex,10);e||f.closest(it)[0]===s[0]||h(f);v=t.target===o[o.length-1]}}var i,v,c,n,e=this,o={};r.extend(e,{init:function(){return n=e.elem=r("<div />",{id:"qtip-overlay",html:"<div><\/div>",mousedown:function(){return u}}).hide(),r(t.body).bind("focusin"+g,a),r(t).bind("keydown"+g,function(n){i&&i.options.show.modal.escape&&27===n.keyCode&&i.hide(n)}),n.bind("click"+g,function(n){i&&i.options.show.modal.blur&&i.hide(n)}),e},update:function(n){i=n;o=n.options.show.modal.stealfocus!==u?n.tooltip.find("*").filter(function(){return l(this)}):[]},toggle:function(o,l,a){var p=(r(t.body),o.tooltip),v=o.options.show.modal,y=v.effect,w=l?"show":"hide",b=n.is(":visible"),k=r(g).filter(":visible:not(:animated)").not(p);return e.update(o),l&&v.stealfocus!==u&&h(r(":focus")),n.toggleClass("blurs",v.blur),l&&n.appendTo(t.body),n.is(":animated")&&b===l&&c!==u||!l&&k.length?e:(n.stop(f,u),r.isFunction(y)?y.call(n,l):y===u?n[w]():n.fadeTo(parseInt(a,10)||90,l?1:0,function(){l||n.hide()}),l||n.queue(function(t){n.css({left:"",top:""});r(g).length||n.detach();t()}),c=l,i.destroyed&&(i=s),e)}});e.init()};d=new d;r.extend(ki.prototype,{init:function(n){var t=n.tooltip;return this.options.on?(n.elements.overlay=d.elem,t.addClass(ti).css("z-index",c.modal_zindex+r(g).length),n._bind(t,["tooltipshow","tooltiphide"],function(n,i,u){var f=n.originalEvent;if(n.target===t[0])if(f&&"tooltiphide"===n.type&&/mouse(leave|enter)/.test(f.type)&&r(f.relatedTarget).closest(d.elem[0]).length)try{n.preventDefault()}catch(e){}else(!f||f&&"tooltipsolo"!==f.type)&&this.toggle(n,"tooltipshow"===n.type,u)},this._ns,this),n._bind(t,"tooltipfocus",function(n,i){if(!n.isDefaultPrevented()&&n.target===t[0]){var u=r(g),f=c.modal_zindex+u.length,e=parseInt(t[0].style.zIndex,10);d.elem[0].style.zIndex=f-1;u.each(function(){this.style.zIndex>e&&(this.style.zIndex-=1)});u.filter("."+ot).qtip("blur",n.originalEvent);t.addClass(ot)[0].style.zIndex=f;d.update(i);try{n.preventDefault()}catch(o){}}},this._ns,this),void n._bind(t,"tooltiphide",function(n){n.target===t[0]&&r(g).filter(":visible").not(t).last().qtip("focus",n)},this._ns,this)):this},toggle:function(n,t,i){return n&&n.isDefaultPrevented()?this:void d.toggle(this.qtip,!!t,i)},destroy:function(){this.qtip.tooltip.removeClass(ti);this.qtip._unbind(this.qtip.tooltip,this._ns);d.toggle(this.qtip,u);delete this.qtip.elements.overlay}});ai=h.modal=function(n){return new ki(n,n.options.show.modal)};ai.sanitize=function(n){n.show&&("object"!=typeof n.show.modal?n.show.modal={on:!!n.show.modal}:"undefined"==typeof n.show.modal.on&&(n.show.modal.on=f))};c.modal_zindex=c.zindex-200;ai.initialize="render";ui.modal={"^show.modal.(on|blur)$":function(){this.destroy();this.init();this.qtip.elems.overlay.toggle(this.qtip.tooltip[0].offsetWidth>0)}};r.extend(f,c.defaults,{show:{modal:{on:u,effect:f,blur:f,stealfocus:f,escape:f}}})})}(window,document),function(){var n=function(t){var i=new n.Index;return i.pipeline.add(n.trimmer,n.stopWordFilter,n.stemmer),t&&t.call(i,i),i};n.version="0.5.11";n.utils={};n.utils.warn=function(n){return function(t){n.console&&console.warn&&console.warn(t)}}(this);n.EventEmitter=function(){this.events={}};n.EventEmitter.prototype.addListener=function(){var n=Array.prototype.slice.call(arguments),t=n.pop(),i=n;if(typeof t!="function")throw new TypeError("last argument must be a function");i.forEach(function(n){this.hasHandler(n)||(this.events[n]=[]);this.events[n].push(t)},this)};n.EventEmitter.prototype.removeListener=function(n,t){if(this.hasHandler(n)){var i=this.events[n].indexOf(t);this.events[n].splice(i,1);this.events[n].length||delete this.events[n]}};n.EventEmitter.prototype.emit=function(n){if(this.hasHandler(n)){var t=Array.prototype.slice.call(arguments,1);this.events[n].forEach(function(n){n.apply(undefined,t)})}};n.EventEmitter.prototype.hasHandler=function(n){return n in this.events};n.tokenizer=function(n){return!arguments.length||n==null||n==undefined?[]:Array.isArray(n)?n.map(function(n){return n.toLowerCase()}):n.toString().trim().toLowerCase().split(/[\s\-]+/)};n.Pipeline=function(){this._stack=[]};n.Pipeline.registeredFunctions={};n.Pipeline.registerFunction=function(t,i){i in this.registeredFunctions&&n.utils.warn("Overwriting existing registered function: "+i);t.label=i;n.Pipeline.registeredFunctions[t.label]=t};n.Pipeline.warnIfFunctionNotRegistered=function(t){var i=t.label&&t.label in this.registeredFunctions;i||n.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",t)};n.Pipeline.load=function(t){var i=new n.Pipeline;return t.forEach(function(t){var r=n.Pipeline.registeredFunctions[t];if(r)i.add(r);else throw new Error("Cannot load un-registered function: "+t);}),i};n.Pipeline.prototype.add=function(){var t=Array.prototype.slice.call(arguments);t.forEach(function(t){n.Pipeline.warnIfFunctionNotRegistered(t);this._stack.push(t)},this)};n.Pipeline.prototype.after=function(t,i){n.Pipeline.warnIfFunctionNotRegistered(i);var r=this._stack.indexOf(t);if(r==-1)throw new Error("Cannot find existingFn");r=r+1;this._stack.splice(r,0,i)};n.Pipeline.prototype.before=function(t,i){n.Pipeline.warnIfFunctionNotRegistered(i);var r=this._stack.indexOf(t);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,i)};n.Pipeline.prototype.remove=function(n){var t=this._stack.indexOf(n);t!=-1&&this._stack.splice(t,1)};n.Pipeline.prototype.run=function(n){for(var t,r,u=[],f=n.length,e=this._stack.length,i=0;i<f;i++){for(t=n[i],r=0;r<e;r++)if(t=this._stack[r](t,i,n),t===void 0)break;t!==void 0&&u.push(t)}return u};n.Pipeline.prototype.reset=function(){this._stack=[]};n.Pipeline.prototype.toJSON=function(){return this._stack.map(function(t){return n.Pipeline.warnIfFunctionNotRegistered(t),t.label})};n.Vector=function(){this._magnitude=null;this.list=undefined;this.length=0};n.Vector.Node=function(n,t,i){this.idx=n;this.val=t;this.next=i};n.Vector.prototype.insert=function(t,i){var u,f,r;if((this._magnitude=undefined,u=this.list,!u)||t<u.idx)return this.list=new n.Vector.Node(t,i,u),this.length++;for(f=u,r=u.next;r!=undefined;){if(t<r.idx)return f.next=new n.Vector.Node(t,i,r),this.length++;f=r;r=r.next}return f.next=new n.Vector.Node(t,i,r),this.length++};n.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var n=this.list,i=0,t;n;)t=n.val,i+=t*t,n=n.next;return this._magnitude=Math.sqrt(i)};n.Vector.prototype.dot=function(n){for(var t=this.list,i=n.list,r=0;t&&i;)t.idx<i.idx?t=t.next:t.idx>i.idx?i=i.next:(r+=t.val*i.val,t=t.next,i=i.next);return r};n.Vector.prototype.similarity=function(n){return this.dot(n)/(this.magnitude()*n.magnitude())};n.SortedSet=function(){this.length=0;this.elements=[]};n.SortedSet.load=function(n){var t=new this;return t.elements=n,t.length=n.length,t};n.SortedSet.prototype.add=function(){for(var t,n=0;n<arguments.length;n++)(t=arguments[n],~this.indexOf(t))||this.elements.splice(this.locationFor(t),0,t);this.length=this.elements.length};n.SortedSet.prototype.toArray=function(){return this.elements.slice()};n.SortedSet.prototype.map=function(n,t){return this.elements.map(n,t)};n.SortedSet.prototype.forEach=function(n,t){return this.elements.forEach(n,t)};n.SortedSet.prototype.indexOf=function(n){for(var i=0,f=this.elements.length,u=f-i,t=i+Math.floor(u/2),r=this.elements[t];u>1;){if(r===n)return t;r<n&&(i=t);r>n&&(f=t);u=f-i;t=i+Math.floor(u/2);r=this.elements[t]}return r===n?t:-1};n.SortedSet.prototype.locationFor=function(n){for(var i=0,f=this.elements.length,u=f-i,t=i+Math.floor(u/2),r=this.elements[t];u>1;)r<n&&(i=t),r>n&&(f=t),u=f-i,t=i+Math.floor(u/2),r=this.elements[t];return r>n?t:r<n?t+1:void 0};n.SortedSet.prototype.intersect=function(t){for(var e=new n.SortedSet,i=0,r=0,o=this.length,s=t.length,u=this.elements,f=t.elements;;){if(i>o-1||r>s-1)break;if(u[i]===f[r]){e.add(u[i]);i++;r++;continue}if(u[i]<f[r]){i++;continue}if(u[i]>f[r]){r++;continue}}return e};n.SortedSet.prototype.clone=function(){var t=new n.SortedSet;return t.elements=this.toArray(),t.length=t.elements.length,t};n.SortedSet.prototype.union=function(n){var i,r,t;return this.length>=n.length?(i=this,r=n):(i=n,r=this),t=i.clone(),t.add.apply(t,r.toArray()),t};n.SortedSet.prototype.toJSON=function(){return this.toArray()};n.Index=function(){this._fields=[];this._ref="id";this.pipeline=new n.Pipeline;this.documentStore=new n.Store;this.tokenStore=new n.TokenStore;this.corpusTokens=new n.SortedSet;this.eventEmitter=new n.EventEmitter;this._idfCache={};this.on("add","remove","update",function(){this._idfCache={}}.bind(this))};n.Index.prototype.on=function(){var n=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,n)};n.Index.prototype.off=function(n,t){return this.eventEmitter.removeListener(n,t)};n.Index.load=function(t){t.version!==n.version&&n.utils.warn("version mismatch: current "+n.version+" importing "+t.version);var i=new this;return i._fields=t.fields,i._ref=t.ref,i.documentStore=n.Store.load(t.documentStore),i.tokenStore=n.TokenStore.load(t.tokenStore),i.corpusTokens=n.SortedSet.load(t.corpusTokens),i.pipeline=n.Pipeline.load(t.pipeline),i};n.Index.prototype.field=function(n,t){var t=t||{},i={name:n,boost:t.boost||1};return this._fields.push(i),this};n.Index.prototype.ref=function(n){return this._ref=n,this};n.Index.prototype.add=function(t,i){var f={},r=new n.SortedSet,o=t[this._ref],i=i===undefined?!0:i,u,e,s;for(this._fields.forEach(function(i){var u=this.pipeline.run(n.tokenizer(t[i.name]));f[i.name]=u;t[i.name]&&n.SortedSet.prototype.add.apply(r,u)},this),this.documentStore.set(o,r),n.SortedSet.prototype.add.apply(this.corpusTokens,r.toArray()),u=0;u<r.length;u++)e=r.elements[u],s=this._fields.reduce(function(n,t){var i=f[t.name].length,r;return i?(r=f[t.name].filter(function(n){return n===e}).length,n+r/i*t.boost):n},0),this.tokenStore.add(e,{ref:o,tf:s});i&&this.eventEmitter.emit("add",t,this)};n.Index.prototype.remove=function(n,t){var i=n[this._ref],t=t===undefined?!0:t,r;this.documentStore.has(i)&&(r=this.documentStore.get(i),this.documentStore.remove(i),r.forEach(function(n){this.tokenStore.remove(n,i)},this),t&&this.eventEmitter.emit("remove",n,this))};n.Index.prototype.update=function(n,t){var t=t===undefined?!0:t;this.remove(n,!1);this.add(n,!1);t&&this.eventEmitter.emit("update",n,this)};n.Index.prototype.idf=function(n){var t="@"+n,i,r;return Object.prototype.hasOwnProperty.call(this._idfCache,t)?this._idfCache[t]:(i=this.tokenStore.count(n),r=1,i>0&&(r=1+Math.log(this.documentStore.length/i)),this._idfCache[t]=r)};n.Index.prototype.search=function(t){var i=this.pipeline.run(n.tokenizer(t)),r=new n.Vector,u=[],e=this._fields.reduce(function(n,t){return n+t.boost},0),o=i.some(function(n){return this.tokenStore.has(n)},this),f;return o?(i.forEach(function(t,i,f){var s=1/f.length*this._fields.length*e,o=this,h=this.tokenStore.expand(t).reduce(function(i,u){var f=o.corpusTokens.indexOf(u),l=o.idf(u),e=1,h=new n.SortedSet,c;return u!==t&&(c=Math.max(3,u.length-t.length),e=1/Math.log(c)),f>-1&&r.insert(f,s*l*e),Object.keys(o.tokenStore.get(u)).forEach(function(n){h.add(n)}),i.union(h)},new n.SortedSet);u.push(h)},this),f=u.reduce(function(n,t){return n.intersect(t)}),f.map(function(n){return{ref:n,score:r.similarity(this.documentVector(n))}},this).sort(function(n,t){return t.score-n.score})):[]};n.Index.prototype.documentVector=function(t){for(var u=this.documentStore.get(t),e=u.length,f=new n.Vector,i=0;i<e;i++){var r=u.elements[i],o=this.tokenStore.get(r)[t].tf,s=this.idf(r);f.insert(this.corpusTokens.indexOf(r),o*s)}return f};n.Index.prototype.toJSON=function(){return{version:n.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}};n.Index.prototype.use=function(n){var t=Array.prototype.slice.call(arguments,1);t.unshift(this);n.apply(this,t)};n.Store=function(){this.store={};this.length=0};n.Store.load=function(t){var i=new this;return i.length=t.length,i.store=Object.keys(t.store).reduce(function(i,r){return i[r]=n.SortedSet.load(t.store[r]),i},{}),i};n.Store.prototype.set=function(n,t){this.has(n)||this.length++;this.store[n]=t};n.Store.prototype.get=function(n){return this.store[n]};n.Store.prototype.has=function(n){return n in this.store};n.Store.prototype.remove=function(n){this.has(n)&&(delete this.store[n],this.length--)};n.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}};n.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},o={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},i="[aeiouy]",n="[^aeiou][^aeiouy]*",t=i+"[aeiou]*",s="^("+n+")?"+t+n,h="^("+n+")?"+t+n+"("+t+")?$",c="^("+n+")?"+t+n+t+n,l="^("+n+")?"+i,u=new RegExp(s),r=new RegExp(c),a=new RegExp(h),v=new RegExp(l),y=/^(.+?)(ss|i)es$/,p=/^(.+?)([^s])s$/,w=/^(.+?)eed$/,b=/^(.+?)(ed|ing)$/,f=/.$/,k=/(at|bl|iz)$/,d=new RegExp("([^aeiouylsz])\\1$"),g=new RegExp("^"+n+i+"[^aeiouwxy]$"),nt=/^(.+?[^aeiou])y$/,tt=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,it=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,rt=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,ut=/^(.+?)(s|t)(ion)$/,ft=/^(.+?)e$/,et=/ll$/,ot=new RegExp("^"+n+i+"[^aeiouwxy]$");return function(n){var i,l,c,t,s,st,ht,h;return n.length<3?n:(c=n.substr(0,1),c=="y"&&(n=c.toUpperCase()+n.substr(1)),t=y,s=p,t.test(n)?n=n.replace(t,"$1$2"):s.test(n)&&(n=n.replace(s,"$1$2")),t=w,s=b,t.test(n)?(h=t.exec(n),t=u,t.test(h[1])&&(t=f,n=n.replace(t,""))):s.test(n)&&(h=s.exec(n),i=h[1],s=v,s.test(i)&&(n=i,s=k,st=d,ht=g,s.test(n)?n=n+"e":st.test(n)?(t=f,n=n.replace(t,"")):ht.test(n)&&(n=n+"e"))),t=nt,t.test(n)&&(h=t.exec(n),i=h[1],n=i+"i"),t=tt,t.test(n)&&(h=t.exec(n),i=h[1],l=h[2],t=u,t.test(i)&&(n=i+e[l])),t=it,t.test(n)&&(h=t.exec(n),i=h[1],l=h[2],t=u,t.test(i)&&(n=i+o[l])),t=rt,s=ut,t.test(n)?(h=t.exec(n),i=h[1],t=r,t.test(i)&&(n=i)):s.test(n)&&(h=s.exec(n),i=h[1]+h[2],s=r,s.test(i)&&(n=i)),t=ft,t.test(n)&&(h=t.exec(n),i=h[1],t=r,s=a,st=ot,(t.test(i)||s.test(i)&&!st.test(i))&&(n=i)),t=et,s=r,t.test(n)&&s.test(n)&&(t=f,n=n.replace(t,"")),c=="y"&&(n=c.toLowerCase()+n.substr(1)),n)}}();n.Pipeline.registerFunction(n.stemmer,"stemmer");n.stopWordFilter=function(t){if(n.stopWordFilter.stopWords.indexOf(t)===-1)return t};n.stopWordFilter.stopWords=new n.SortedSet;n.stopWordFilter.stopWords.length=119;n.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"];n.Pipeline.registerFunction(n.stopWordFilter,"stopWordFilter");n.trimmer=function(n){return n.replace(/^\W+/,"").replace(/\W+$/,"")};n.Pipeline.registerFunction(n.trimmer,"trimmer");n.TokenStore=function(){this.root={docs:{}};this.length=0};n.TokenStore.load=function(n){var t=new this;return t.root=n.root,t.length=n.length,t};n.TokenStore.prototype.add=function(n,t,i){var i=i||this.root,r=n[0],u=n.slice(1);if(r in i||(i[r]={docs:{}}),u.length===0){i[r].docs[t.ref]=t;this.length+=1;return}return this.add(u,t,i[r])};n.TokenStore.prototype.has=function(n){var i,t;if(!n)return!1;for(i=this.root,t=0;t<n.length;t++){if(!i[n[t]])return!1;i=i[n[t]]}return!0};n.TokenStore.prototype.getNode=function(n){var t,i;if(!n)return{};for(t=this.root,i=0;i<n.length;i++){if(!t[n[i]])return{};t=t[n[i]]}return t};n.TokenStore.prototype.get=function(n,t){return this.getNode(n,t).docs||{}};n.TokenStore.prototype.count=function(n,t){return Object.keys(this.get(n,t)).length};n.TokenStore.prototype.remove=function(n,t){var i,r;if(n){for(i=this.root,r=0;r<n.length;r++){if(!(n[r]in i))return;i=i[n[r]]}delete i.docs[t]}};n.TokenStore.prototype.expand=function(n,t){var i=this.getNode(n),r=i.docs||{},t=t||[];return Object.keys(r).length&&t.push(n),Object.keys(i).forEach(function(i){i!=="docs"&&t.concat(this.expand(n+i,t))},this),t};n.TokenStore.prototype.toJSON=function(){return{root:this.root,length:this.length}},function(n,t){typeof define=="function"&&define.amd?define(t):typeof exports=="object"?module.exports=t():n.lunr=t()}(this,function(){return n})}()