text: Ext.namespace("gxp");
  gxp.util={_uniqueNames:{},getOGCExceptionText:function(a){var b;a&&a.exceptions?(b=[],Ext.each(a.exceptions,function(a){Ext.each(a.texts,function(a){b.push(a)})}),b=b.join("\n")):b="Unknown error (no exception report).";return b},dispatch:function(a,b,c){function d(){++g;g===f&&b.call(c,h)}function e(b){window.setTimeout(function(){a[b].apply(c,[d,h])})}for(var b=b||Ext.emptyFn,c=c||this,f=a.length,g=0,h={},j=0;j<f;++j)e(j)},uniqueName:function(a,b){var b=b||" ",c=RegExp(b+"[0-9]*$"),d=a.replace(c,
  ""),c=c.exec(a),c=void 0!==this._uniqueNames[d]?this._uniqueNames[d]:c instanceof Array?Number(c[0]):void 0,e=d;void 0!==c&&(c++,e+=b+c);this._uniqueNames[d]=c||0;return e},getAbsoluteUrl:function(a){var b;Ext.isIE6||Ext.isIE7||Ext.isIE8?(b=document.createElement("<a href='"+a+"'/>"),b.style.display="none",document.body.appendChild(b),b.href=b.href,document.body.removeChild(b)):(b=document.createElement("a"),b.href=a);return b.href},md5:function(){function a(a){return String.fromCharCode(a&255)+String.fromCharCode(a>>>
  8&255)+String.fromCharCode(a>>>16&255)+String.fromCharCode(a>>>24&255)}function b(a){for(;0>a;)a+=4294967296;for(;4294967295<a;)a-=4294967296;return a}var c=[0,3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,
  4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],d=[[function(a,b,c){return a&b|~a&c},[[0,7,1],[1,12,2],[2,17,3],[3,22,4],[4,7,5],[5,12,6],[6,17,7],[7,22,8],[8,7,9],[9,12,10],[10,17,11],[11,22,12],[12,7,
  13],[13,12,14],[14,17,15],[15,22,16]]],[function(a,b,c){return a&c|b&~c},[[1,5,17],[6,9,18],[11,14,19],[0,20,20],[5,5,21],[10,9,22],[15,14,23],[4,20,24],[9,5,25],[14,9,26],[3,14,27],[8,20,28],[13,5,29],[2,9,30],[7,14,31],[12,20,32]]],[function(a,b,c){return a^b^c},[[5,4,33],[8,11,34],[11,16,35],[14,23,36],[1,4,37],[4,11,38],[7,16,39],[10,23,40],[13,4,41],[0,11,42],[3,16,43],[6,23,44],[9,4,45],[12,11,46],[15,16,47],[2,23,48]]],[function(a,b,c){return b^(a|~c)},[[0,6,49],[7,10,50],[14,15,51],[5,21,
  52],[12,6,53],[3,10,54],[10,15,55],[1,21,56],[8,6,57],[15,10,58],[6,15,59],[13,21,60],[4,6,61],[11,10,62],[2,15,63],[9,21,64]]]];return function(e){var f,g,h,j,k,l,n,m,o,p,q;f=[1732584193,4023233417,2562383102,271733878];g=e.length;h=g&63;j=56>h?56-h:120-h;if(0<j){e+="\u0080";for(h=0;h<j-1;h++)e+="\x00"}e+=a(8*g);e+=a(0);g+=j+8;j=[0,1,2,3];k=[16];l=[4];for(p=0;p<g;p+=64){h=0;for(o=p;16>h;h++,o+=4)k[h]=e.charCodeAt(o)|e.charCodeAt(o+1)<<8|e.charCodeAt(o+2)<<16|e.charCodeAt(o+3)<<24;for(h=0;4>h;h++)l[h]=
  f[h];for(h=0;4>h;h++){n=d[h][0];m=d[h][1];for(o=0;16>o;o++){q=k;var s=l,t=m[o],v=void 0,w=void 0,u=void 0,y=void 0,r=void 0,x=void 0,z=void 0,u=r=void 0,v=j[0],w=j[1],u=j[2],y=j[3],r=t[0],x=t[1],z=t[2],u=n(s[w],s[u],s[y]),r=s[v]+u+q[r]+c[z],r=b(r),r=r<<x|r>>>32-x,r=r+s[w];s[v]=b(r);q=j[0];j[0]=j[3];j[3]=j[2];j[2]=j[1];j[1]=q}}for(h=0;4>h;h++)f[h]+=l[h],f[h]=b(f[h])}h=a(f[0])+a(f[1])+a(f[2])+a(f[3]);f="";for(e=0;16>e;e++)g=h.charCodeAt(e),f+="0123456789abcdef".charAt(g>>4&15),f+="0123456789abcdef".charAt(g&
  15);return f}}()};Ext.ns("Ext.ux.form");
  Ext.ux.form.FileUploadField=Ext.extend(Ext.form.TextField,{buttonText:"Browse...",buttonOnly:!1,buttonOffset:3,readOnly:!0,autoSize:Ext.emptyFn,initComponent:function(){Ext.ux.form.FileUploadField.superclass.initComponent.call(this);this.addEvents("fileselected")},onRender:function(a,b){Ext.ux.form.FileUploadField.superclass.onRender.call(this,a,b);this.wrap=this.el.wrap({cls:"x-form-field-wrap x-form-file-wrap"});this.el.addClass("x-form-file-text");this.el.dom.removeAttribute("name");this.createFileInput();
  var c=Ext.applyIf(this.buttonCfg||{},{text:this.buttonText});this.button=new Ext.Button(Ext.apply(c,{renderTo:this.wrap,cls:"x-form-file-btn"+(c.iconCls?" x-btn-icon":"")}));this.buttonOnly&&(this.el.hide(),this.wrap.setWidth(this.button.getEl().getWidth()));this.bindListeners();this.resizeEl=this.positionEl=this.wrap},bindListeners:function(){this.fileInput.on({scope:this,mouseenter:function(){this.button.addClass(["x-btn-over","x-btn-focus"])},mouseleave:function(){this.button.removeClass(["x-btn-over",
  "x-btn-focus","x-btn-click"])},mousedown:function(){this.button.addClass("x-btn-click")},mouseup:function(){this.button.removeClass(["x-btn-over","x-btn-focus","x-btn-click"])},change:function(){var a=this.fileInput.dom.value;this.setValue(a);this.fireEvent("fileselected",this,a)}})},createFileInput:function(){this.fileInput=this.wrap.createChild({id:this.getFileInputId(),name:this.name||this.getId(),cls:"x-form-file",tag:"input",type:"file",size:1})},reset:function(){this.fileInput.remove();this.createFileInput();
  this.bindListeners();Ext.ux.form.FileUploadField.superclass.reset.call(this)},getFileInputId:function(){return this.id+"-file"},onResize:function(a,b){Ext.ux.form.FileUploadField.superclass.onResize.call(this,a,b);this.wrap.setWidth(a);this.buttonOnly||(a=this.wrap.getWidth()-this.button.getEl().getWidth()-this.buttonOffset,this.el.setWidth(a))},onDestroy:function(){Ext.ux.form.FileUploadField.superclass.onDestroy.call(this);Ext.destroy(this.fileInput,this.button,this.wrap)},onDisable:function(){Ext.ux.form.FileUploadField.superclass.onDisable.call(this);
  this.doDisable(!0)},onEnable:function(){Ext.ux.form.FileUploadField.superclass.onEnable.call(this);this.doDisable(!1)},doDisable:function(a){this.fileInput.dom.disabled=a;this.button.setDisabled(a)},preFocus:Ext.emptyFn,alignErrorIcon:function(){this.errorIcon.alignTo(this.wrap,"tl-tr",[2,0])}});Ext.reg("fileuploadfield",Ext.ux.form.FileUploadField);Ext.form.FileUploadField=Ext.ux.form.FileUploadField;Ext.namespace("gxp.plugins");
  gxp.plugins.LayerSource=Ext.extend(Ext.util.Observable,{store:null,lazy:!1,title:"",constructor:function(a){this.initialConfig=a;Ext.apply(this,a);this.addEvents("ready","failure");gxp.plugins.LayerSource.superclass.constructor.apply(this,arguments)},init:function(a){this.target=a;this.createStore()},getMapProjection:function(){var a=this.target.mapPanel.map.projection;return this.target.mapPanel.map.getProjectionObject()||a&&new OpenLayers.Projection(a)||new OpenLayers.Projection("EPSG:4326")},getProjection:function(a){var a=
  a.getLayer(),b=this.getMapProjection();return(a.projection?a.projection instanceof OpenLayers.Projection?a.projection:new OpenLayers.Projection(a.projection):b).equals(b)?b:null},createStore:function(){this.fireEvent("ready",this)},createLayerRecord:function(){},getConfigForRecord:function(a){var b=a.getLayer();return{source:a.get("source"),name:a.get("name"),title:a.get("title"),visibility:b.getVisibility(),opacity:b.opacity||void 0,group:a.get("group"),fixed:a.get("fixed"),selected:a.get("selected")}},
  getState:function(){return Ext.apply({},this.initialConfig)}});Ext.namespace("gxp.plugins");
  gxp.plugins.Tool=Ext.extend(Ext.util.Observable,{ptype:"gxp_tool",autoActivate:!0,actionTarget:"map.tbar",output:null,constructor:function(a){this.initialConfig=a||{};this.active=!1;Ext.apply(this,a);this.id||(this.id=Ext.id());this.output=[];this.addEvents("activate","deactivate");gxp.plugins.Tool.superclass.constructor.apply(this,arguments)},init:function(a){a.tools[this.id]=this;this.target=a;this.autoActivate&&this.activate();this.target.on("portalready",this.addActions,this)},activate:function(){if(!1===
  this.active)return this.active=!0,this.fireEvent("activate",this),!0},deactivate:function(){if(!0===this.active)return this.active=!1,this.fireEvent("deactivate",this),!0},addActions:function(a){a=a||this.actions;if(!a||null===this.actionTarget)this.addOutput();else{var b=this.actionTarget instanceof Array?this.actionTarget:[this.actionTarget],a=a instanceof Array?a:[a],c,d,e,f,g,h=null;for(d=b.length-1;0<=d;--d){if(c=b[d]){c instanceof Object&&(h=c.index,c=c.target);c=c.split(".");if(e=c[0])if("map"==
  e)g=this.target.mapPanel;else{if(g=Ext.getCmp(e)||this.target.portal[e],!g)throw Error("Can't find component with id: "+e);}else g=this.target.portal;if(c=1<c.length&&c[1])g=(e={tbar:"getTopToolbar",bbar:"getBottomToolbar",fbar:"getFooterToolbar"}[c])?g[e]():g[c]}e=0;for(f=a.length;e<f;++e){if(!(a[e]instanceof Ext.Action||a[e]instanceof Ext.Component)&&"string"!=typeof a[e])e==this.defaultAction&&(a[e].pressed=!0),a[e]=new Ext.Action(a[e]);c=a[e];e==this.defaultAction&&c instanceof GeoExt.Action&&
  (c.isDisabled()?c.activateOnEnable=!0:c.control.activate());if(g){g instanceof Ext.menu.Menu?c=Ext.apply(new Ext.menu.CheckItem(c),{text:c.initialConfig.menuText,group:c.initialConfig.toggleGroup,groupClass:null}):g instanceof Ext.Toolbar||(c=new Ext.Button(c));var j=null===h?g.add(c):g.insert(h,c);c=c instanceof Ext.Button?c:j;null!==h&&(h+=1);if(null!=this.outputAction&&e==this.outputAction){var k;c.on("click",function(){k?this.outputTarget?k.show():k.ownerCt.ownerCt.show():k=this.addOutput()},
  this)}}}g&&(g.isVisible()?g.doLayout():g instanceof Ext.menu.Menu||g.show())}return this.actions=a}},addOutput:function(a){if(a||this.outputConfig){var a=a||{},b=this.outputTarget;b?(b="map"===b?this.target.mapPanel:Ext.getCmp(b)||this.target.portal[b],a instanceof Ext.Component||Ext.apply(a,this.outputConfig)):(b=this.outputConfig||{},b=(new Ext.Window(Ext.apply({hideBorders:!0,shadow:!1,closeAction:"hide",autoHeight:!b.height,layout:b.height?"fit":void 0,items:[{defaults:Ext.applyIf({autoHeight:!b.height&&
  !(b.defaults&&b.defaults.height)},b.defaults)}]},b))).show().items.get(0));if(b)return a=b.add(a),a.on("removed",function(a){this.output.remove(a)},this,{single:!0}),a instanceof Ext.Window?a.show():b.doLayout(),this.output.push(a),a;a=this.ptype;window.console&&console.error("Failed to create output for plugin with ptype: "+a)}},removeOutput:function(){for(var a,b=this.output.length-1;0<=b;--b)if(a=this.output[b],this.outputTarget)if(a.ownerCt){if(a.ownerCt.remove(a),a.ownerCt instanceof Ext.Window)a.ownerCt[a.ownerCt.closeAction]()}else a.remove();
  else a.findParentBy(function(a){return a instanceof Ext.Window}).close();this.output=[]},getState:function(){return Ext.apply({},this.initialConfig)}});Ext.preg(gxp.plugins.Tool.prototype.ptype,gxp.plugins.Tool);Ext.namespace("gxp.plugins");
  gxp.plugins.ZoomToExtent=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_zoomtoextent",menuText:"Zoom To Max Extent",tooltip:"Zoom To Max Extent",extent:null,closest:!0,iconCls:"gxp-icon-zoomtoextent",closest:!0,constructor:function(a){gxp.plugins.ZoomToExtent.superclass.constructor.apply(this,arguments);this.extent instanceof Array&&(this.extent=OpenLayers.Bounds.fromArray(this.extent))},addActions:function(){return gxp.plugins.ZoomToExtent.superclass.addActions.apply(this,[{text:this.buttonText,menuText:this.menuText,
  iconCls:this.iconCls,tooltip:this.tooltip,handler:function(){var a=this.target.mapPanel.map,b="function"==typeof this.extent?this.extent():this.extent;if(!b)for(var c,d=0,e=a.layers.length;d<e;++d)c=a.layers[d],c.getVisibility()&&(c=c.restrictedExtent||c.maxExtent,b?b.extend(c):c&&(b=c.clone()));b&&((d=a.restrictedExtent||a.maxExtent)&&(b=new OpenLayers.Bounds(Math.max(b.left,d.left),Math.max(b.bottom,d.bottom),Math.min(b.right,d.right),Math.min(b.top,d.top))),a.zoomToExtent(b,this.closest))},scope:this}])}});
  Ext.preg(gxp.plugins.ZoomToExtent.prototype.ptype,gxp.plugins.ZoomToExtent);Ext.namespace("gxp.slider");
  gxp.slider.Tip=Ext.extend(Ext.slider.Tip,{hover:!0,dragging:!1,init:function(a){if(this.hover)a.on("render",this.registerThumbListeners,this);this.slider=a;gxp.slider.Tip.superclass.init.apply(this,arguments)},registerThumbListeners:function(){for(var a=0,b=this.slider.thumbs.length;a<b;++a)this.slider.thumbs[a].el.on({mouseover:this.createHoverListener(a),mouseout:function(){this.dragging||this.hide.apply(this,arguments)},scope:this})},createHoverListener:function(a){return function(){this.onSlide(this.slider,
  {},this.slider.thumbs[a]);this.dragging=!1}.createDelegate(this)},onSlide:function(a,b,c){this.dragging=!0;gxp.slider.Tip.superclass.onSlide.apply(this,arguments)}});Ext.namespace("gxp.slider");
  gxp.slider.RangeSliderTip=Ext.extend(gxp.slider.Tip,{template:"<div>{startDate}/{endDate}</div>",compiledTemplate:null,init:function(a){this.slider=a;this.compiledTemplate=new Ext.Template(this.template);gxp.slider.RangeSliderTip.superclass.init.call(this,a)},getText:function(){return this.compiledTemplate.apply({startDate:this.slider.startDate,endDate:this.slider.endDate})}});Ext.namespace("gxp.plugins");
  gxp.plugins.SelectedFeatureActions=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_selectedfeatureactions",addActions:function(){for(var a=this.target.tools[this.featureManager],b=this.actions.length,c=Array(b),d=this,e=0;e<b;++e)c[e]=Ext.apply({iconCls:"process",disabled:!0,handler:function(){var b=a.featureLayer.selectedFeatures[0],c=new Ext.Template(this.urlTemplate),e=Ext.applyIf(this.outputConfig||{},d.initialConfig.outputConfig);d.outputConfig=Ext.apply(e,{title:this.menuText,bodyCfg:{tag:"iframe",
  src:c.apply(Ext.applyIf({fid:b.fid.split(".").pop(),layer:a.layerRecord.get("name")},b.attributes)),style:{border:"0px none"}}});d.addOutput()}},this.actions[e]);a.featureLayer.events.on({featureselected:function(a){for(var a=1!=a.feature.layer.selectedFeatures.length,b=c.length-1;0<=b;--b)c[b].setDisabled(a)},featureunselected:function(a){if(0==a.feature.layer.selectedFeatures.length)for(a=c.length-1;0<=a;--a)c[a].disable()},scope:this});gxp.plugins.SelectedFeatureActions.superclass.addActions.apply(this,
  [c])}});Ext.preg(gxp.plugins.SelectedFeatureActions.prototype.ptype,gxp.plugins.SelectedFeatureActions);Ext.namespace("gxp.plugins");
  gxp.plugins.MapQuestSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_mapquestsource",title:"MapQuest Layers",osmAttribution:"Tiles Courtesy of <a href='http://open.mapquest.co.uk/' target='_blank'>MapQuest</a> <img src='http://developer.mapquest.com/content/osm/mq_logo.png' border='0'>",osmTitle:"MapQuest OpenStreetMap",naipAttribution:"Tiles Courtesy of <a href='http://open.mapquest.co.uk/' target='_blank'>MapQuest</a> <img src='http://developer.mapquest.com/content/osm/mq_logo.png' border='0'>",naipTitle:"MapQuest Imagery",
  createStore:function(){var a={projection:"EPSG:900913",maxExtent:new OpenLayers.Bounds(-2.00375083392E7,-2.00375083392E7,2.00375083392E7,2.00375083392E7),maxResolution:156543.03390625,numZoomLevels:19,units:"m",buffer:1,transitionEffect:"resize",tileOptions:{crossOriginKeyword:null}},a=[new OpenLayers.Layer.OSM(this.osmTitle,["http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png","http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png","http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
  "http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png"],OpenLayers.Util.applyDefaults({attribution:this.osmAttribution,type:"osm"},a)),new OpenLayers.Layer.OSM(this.naipTitle,["http://oatile1.mqcdn.com/naip/${z}/${x}/${y}.png","http://oatile2.mqcdn.com/naip/${z}/${x}/${y}.png","http://oatile3.mqcdn.com/naip/${z}/${x}/${y}.png","http://oatile4.mqcdn.com/naip/${z}/${x}/${y}.png"],OpenLayers.Util.applyDefaults({attribution:this.naipAttribution,type:"naip"},a))];this.store=new GeoExt.data.LayerStore({layers:a,
  fields:[{name:"source",type:"string"},{name:"name",type:"string",mapping:"type"},{name:"abstract",type:"string",mapping:"attribution"},{name:"group",type:"string",defaultValue:"background"},{name:"fixed",type:"boolean",defaultValue:!0},{name:"selected",type:"boolean"}]});this.store.each(function(a){a.set("group","background")});this.fireEvent("ready",this)},createLayerRecord:function(a){var b,c=this.store.findExact("name",a.name);-1<c&&(b=this.store.getAt(c).copy(Ext.data.Record.id({})),c=b.getLayer().clone(),
  a.title&&(c.setName(a.title),b.set("title",a.title)),"visibility"in a&&(c.visibility=a.visibility),b.set("selected",a.selected||!1),b.set("source",a.source),b.set("name",a.name),"group"in a&&b.set("group",a.group),b.data.layer=c,b.commit());return b}});Ext.preg(gxp.plugins.MapQuestSource.prototype.ptype,gxp.plugins.MapQuestSource);Ext.namespace("gxp");
  gxp.FillSymbolizer=Ext.extend(Ext.FormPanel,{symbolizer:null,colorProperty:"fillColor",opacityProperty:"fillOpacity",colorManager:null,checkboxToggle:!0,defaultColor:null,border:!1,fillText:"Fill",colorText:"Color",opacityText:"Opacity",initComponent:function(){this.symbolizer||(this.symbolizer={});var a;this.colorManager&&(a=[new this.colorManager]);var b=100;this.opacityProperty in this.symbolizer?b=this.symbolizer[this.opacityProperty]:OpenLayers.Renderer.defaultSymbolizer[this.opacityProperty]&&
  (b=100*OpenLayers.Renderer.defaultSymbolizer[this.opacityProperty]);this.items=[{xtype:"fieldset",title:this.fillText,autoHeight:!0,checkboxToggle:this.checkboxToggle,collapsed:!0===this.checkboxToggle&&!1===this.symbolizer.fill,hideMode:"offsets",defaults:{width:100},items:[{xtype:"gxp_colorfield",fieldLabel:this.colorText,name:"color",emptyText:OpenLayers.Renderer.defaultSymbolizer[this.colorProperty],value:this.symbolizer[this.colorProperty],defaultBackground:this.defaultColor||OpenLayers.Renderer.defaultSymbolizer[this.colorProperty],
  plugins:a,listeners:{valid:function(a){var a=a.getValue(),b=this.symbolizer[this.colorProperty]!=a;this.symbolizer[this.colorProperty]=a;b&&this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"slider",fieldLabel:this.opacityText,name:"opacity",values:[b],isFormField:!0,listeners:{changecomplete:function(a,b){this.symbolizer[this.opacityProperty]=b/100;this.fireEvent("change",this.symbolizer)},scope:this},plugins:[new GeoExt.SliderTip({getText:function(a){return a.value+"%"}})]}],listeners:{collapse:function(){if(this.symbolizer.fill!==
  false){this.symbolizer.fill=false;this.fireEvent("change",this.symbolizer)}},expand:function(){this.symbolizer.fill=true;this.fireEvent("change",this.symbolizer)},scope:this}}];this.addEvents("change");gxp.FillSymbolizer.superclass.initComponent.call(this)}});Ext.reg("gxp_fillsymbolizer",gxp.FillSymbolizer);Ext.namespace("gxp");
  gxp.PointSymbolizer=Ext.extend(Ext.Panel,{symbolizer:null,graphicCircleText:"circle",graphicSquareText:"square",graphicTriangleText:"triangle",graphicStarText:"star",graphicCrossText:"cross",graphicXText:"x",graphicExternalText:"external",urlText:"URL",opacityText:"opacity",symbolText:"Symbol",sizeText:"Size",rotationText:"Rotation",pointGraphics:null,colorManager:null,external:null,layout:"form",initComponent:function(){this.symbolizer||(this.symbolizer={});this.pointGraphics||(this.pointGraphics=
  [{display:this.graphicCircleText,value:"circle",mark:!0},{display:this.graphicSquareText,value:"square",mark:!0},{display:this.graphicTriangleText,value:"triangle",mark:!0},{display:this.graphicStarText,value:"star",mark:!0},{display:this.graphicCrossText,value:"cross",mark:!0},{display:this.graphicXText,value:"x",mark:!0},{display:this.graphicExternalText}]);this.external=!!this.symbolizer.externalGraphic;this.markPanel=new Ext.Panel({border:!1,collapsed:this.external,layout:"form",items:[{xtype:"gxp_fillsymbolizer",
  symbolizer:this.symbolizer,labelWidth:this.labelWidth,labelAlign:this.labelAlign,colorManager:this.colorManager,listeners:{change:function(){this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"gxp_strokesymbolizer",symbolizer:this.symbolizer,labelWidth:this.labelWidth,labelAlign:this.labelAlign,colorManager:this.colorManager,listeners:{change:function(){this.fireEvent("change",this.symbolizer)},scope:this}}]});this.urlField=new Ext.form.TextField({name:"url",fieldLabel:this.urlText,value:this.symbolizer.externalGraphic,
  hidden:!0,listeners:{change:function(a,b){this.symbolizer.externalGraphic=b;this.fireEvent("change",this.symbolizer)},scope:this},width:100});this.graphicPanel=new Ext.Panel({border:!1,collapsed:!this.external,layout:"form",items:[this.urlField,{xtype:"slider",name:"opacity",fieldLabel:this.opacityText,value:[null==this.symbolizer.graphicOpacity?100:100*this.symbolizer.graphicOpacity],isFormField:!0,listeners:{changecomplete:function(a,b){this.symbolizer.graphicOpacity=b/100;this.fireEvent("change",
  this.symbolizer)},scope:this},plugins:[new GeoExt.SliderTip({getText:function(a){return a.value+"%"}})],width:100}]});this.items=[{xtype:"combo",name:"mark",fieldLabel:this.symbolText,store:new Ext.data.JsonStore({data:{root:this.pointGraphics},root:"root",fields:["value","display","preview",{name:"mark",type:"boolean"}]}),value:this.external?0:this.symbolizer.graphicName,displayField:"display",valueField:"value",tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item gx-pointsymbolizer-mark-item"><tpl if="preview"><img src="{preview}" alt="{display}"/></tpl><span>{display}</span></div></tpl>'),
  mode:"local",allowBlank:!1,triggerAction:"all",editable:!1,listeners:{select:function(a,b){var c=b.get("mark"),d=b.get("value");if(c){if(this.external){this.external=false;delete this.symbolizer.externalGraphic;this.updateGraphicDisplay()}this.symbolizer.graphicName=d}else{if(d){this.urlField.hide();this.urlField.getEl().up(".x-form-item").setDisplayed(false);this.symbolizer.externalGraphic=d}else{this.urlField.show();this.urlField.getEl().up(".x-form-item").setDisplayed(true)}if(!this.external){this.external=
  true;this.updateGraphicDisplay()}}this.fireEvent("change",this.symbolizer)},scope:this},width:100},{xtype:"textfield",name:"size",fieldLabel:this.sizeText,value:this.symbolizer.pointRadius&&2*this.symbolizer.pointRadius,listeners:{change:function(a,b){this.symbolizer.pointRadius=b/2;this.fireEvent("change",this.symbolizer)},scope:this},width:100},{xtype:"textfield",name:"rotation",fieldLabel:this.rotationText,value:this.symbolizer.rotation,listeners:{change:function(a,b){this.symbolizer.rotation=
  b;this.fireEvent("change",this.symbolizer)},scope:this},width:100},this.markPanel,this.graphicPanel];this.addEvents("change");gxp.PointSymbolizer.superclass.initComponent.call(this)},updateGraphicDisplay:function(){this.external?(this.markPanel.collapse(),this.graphicPanel.expand()):(this.graphicPanel.collapse(),this.markPanel.expand())}});Ext.reg("gxp_pointsymbolizer",gxp.PointSymbolizer);Ext.namespace("gxp.plugins");
  gxp.plugins.Legend=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_legend",menuText:"Legend",tooltip:"Show Legend",actionTarget:null,constructor:function(a){gxp.plugins.Legend.superclass.constructor.apply(this,arguments);this.outputConfig||(this.outputConfig={width:300,height:400});Ext.applyIf(this.outputConfig,{title:this.menuText})},addActions:function(){return gxp.plugins.Legend.superclass.addActions.apply(this,[[{menuText:this.menuText,iconCls:"gxp-icon-legend",tooltip:this.tooltip,handler:function(){this.removeOutput();
  this.addOutput()},scope:this}]])},getLegendPanel:function(){return this.output[0]},addOutput:function(a){return gxp.plugins.Legend.superclass.addOutput.call(this,Ext.apply({xtype:"gx_legendpanel",ascending:!1,border:!1,hideMode:"offsets",layerStore:this.target.mapPanel.layers,defaults:{cls:"gxp-legend-item"}},a))}});Ext.preg(gxp.plugins.Legend.prototype.ptype,gxp.plugins.Legend);Ext.namespace("gxp.plugins");
  gxp.plugins.FeatureEditorForm=Ext.extend(Ext.FormPanel,{ptype:"gxp_editorform",feature:null,schema:null,fieldConfig:null,fields:null,excludeFields:null,propertyNames:null,readOnly:null,monitorValid:!0,initComponent:function(){this.defaults=Ext.apply(this.defaults||{},{readOnly:!0});this.listeners={clientvalidation:function(a,b){b&&this.getForm().isDirty()&&(Ext.apply(this.feature.attributes,this.getForm().getFieldValues()),this.featureEditor.setFeatureState(this.featureEditor.getDirtyState()))},scope:this};
  gxp.plugins.FeatureEditorForm.superclass.initComponent.call(this);this.excludeFields||(this.excludeFields=[]);var a=[],b,c;b=0;for(c=this.excludeFields.length;b<c;++b)a[b]=this.excludeFields[b].toLowerCase();this.excludeFields=a;var d=this.fields?this.fields.join(",").toUpperCase().split(","):[],e={};if(this.schema)this.schema.each(function(a){var b=a.get("name"),c=b.toLowerCase();this.fields&&d.indexOf(b.toUpperCase())==-1&&this.excludeFields.push(c);if(this.excludeFields.indexOf(c)==-1&&!a.get("type").match(/^[^:]*:?((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry))/)){a=
  GeoExt.form.recordToField(a);a.fieldLabel=this.propertyNames?this.propertyNames[b]||a.fieldLabel:a.fieldLabel;this.fieldConfig&&this.fieldConfig[b]&&Ext.apply(a,this.fieldConfig[b]);if(this.feature.attributes[b]!==void 0)a.value=this.feature.attributes[b];if(a.value&&a.xtype=="checkbox")a.checked=Ext.isBoolean(a.value)?a.value:a.value==="true";if(a.value&&a.xtype=="gxp_datefield")a.value=new Date(a.value*1E3);if(a.value&&a.xtype=="datefield"){a.format="Y-m-d";a.value=Date.parseDate(a.value.replace(/Z$/,
  ""),"Y-m-d")}a.xtype==="combo"&&Ext.applyIf(a,{store:new Ext.data.ArrayStore({fields:["id","value"],data:a.comboStoreData}),displayField:"value",valueField:"id",mode:"local",triggerAction:"all"});e[c]=a}},this);else{var e={},f;for(f in this.feature.attributes)a=f.toLowerCase(),this.fields&&-1==d.indexOf(f.toUpperCase())&&this.excludeFields.push(a),-1===this.excludeFields.indexOf(a)&&(e[a]={xtype:"textfield",fieldLabel:this.propertyNames?this.propertyNames[f]||f:f,name:f,value:this.feature.attributes[f]})}this.add(this.reorderFields(e))},
  reorderFields:function(a){var b=[];if(this.fields)for(var c=0,d=this.fields.length;c<d;++c)a[this.fields[c].toLowerCase()]&&b.push(a[this.fields[c].toLowerCase()]);else for(c in a)b.push(a[c]);return b},init:function(a){this.featureEditor=a;this.featureEditor.on("startedit",this.onStartEdit,this);this.featureEditor.on("stopedit",this.onStopEdit,this);this.featureEditor.on("canceledit",this.onCancelEdit,this);this.featureEditor.add(this);this.featureEditor.doLayout()},destroy:function(){this.featureEditor.un("startedit",
  this.onStartEdit,this);this.featureEditor.un("stopedit",this.onStopEdit,this);this.featureEditor.un("canceledit",this.onCancelEdit,this);this.featureEditor=null;gxp.plugins.FeatureEditorForm.superclass.destroy.call(this)},onStartEdit:function(){this.getForm().items.each(function(a){!0!==this.readOnly&&a.setReadOnly(!1)},this)},onStopEdit:function(){this.getForm().items.each(function(a){a.setReadOnly(!0)})},onCancelEdit:function(a,b){if(b){var c=this.getForm(),d;for(d in b.attributes){var e=c.findField(d);
  e&&e.setValue(b.attributes[d])}}}});Ext.preg(gxp.plugins.FeatureEditorForm.prototype.ptype,gxp.plugins.FeatureEditorForm);Ext.namespace("gxp.data");
  gxp.data.WFSProtocolProxy=Ext.extend(GeoExt.data.ProtocolProxy,{setFilter:function(a){this.protocol.filter=a;this.protocol.options.filter=a},constructor:function(a){Ext.applyIf(a,{version:"1.1.0"});this.protocol&&this.protocol instanceof OpenLayers.Protocol||(a.protocol=new OpenLayers.Protocol.WFS(Ext.apply({version:a.version,srsName:a.srsName,url:a.url,featureType:a.featureType,featureNS:a.featureNS,geometryName:a.geometryName,schema:a.schema,filter:a.filter,maxFeatures:a.maxFeatures,multi:a.multi},
  a.protocol)));gxp.data.WFSProtocolProxy.superclass.constructor.apply(this,arguments)},doRequest:function(a,b,c,d,e,f,g){delete c.xaction;if(a===Ext.data.Api.actions.read)this.load(c,d,e,f,g);else{b instanceof Array||(b=[b]);var h=Array(b.length),j;Ext.each(b,function(a,b){h[b]=a.getFeature();j=h[b];j.modified=Ext.apply(j.modified||{},{attributes:Ext.apply(j.modified&&j.modified.attributes||{},a.modified)})},this);var k={action:a,records:b,callback:e,scope:f},a={callback:function(a){this.onProtocolCommit(a,
  k)},scope:this};Ext.applyIf(a,c);this.protocol.commit(h,a)}},onProtocolCommit:function(a,b){if(a.success()){var c=a.reqFeatures,d,e,f=[],g=a.insertIds||[],h,j,k=0;h=0;for(j=c.length;h<j;++h)if(e=c[h],d=e.state)d==OpenLayers.State.DELETE?f.push(e):d==OpenLayers.State.INSERT?(e.fid=g[k],++k):e.modified&&(e.modified={}),e.state=null;h=0;for(j=f.length;h<j;++h)e=f[h],e.layer&&e.layer.destroyFeatures([e]);j=c.length;d=Array(j);for(h=0;h<j;++h){e=c[h];d[h]={id:e.id,feature:e,state:null};var f=b.records[h].fields,
  l;for(l in e.attributes)f.containsKey(l)&&(d[h][l]=e.attributes[l])}b.callback.call(b.scope,d,a.priv,!0)}else c=a.priv,200<=c.status&&300>c.status?this.fireEvent("exception",this,"remote",b.action,b,a.error,b.records):this.fireEvent("exception",this,"response",b.action,b,c),b.callback.call(b.scope,[],c,!1)}});Ext.namespace("gxp.data");
  gxp.data.WFSFeatureStore=Ext.extend(GeoExt.data.FeatureStore,{setOgcFilter:function(a){this.proxy.setFilter(a)},constructor:function(a){a.proxy&&a.proxy instanceof GeoExt.data.ProtocolProxy||(a.proxy=new gxp.data.WFSProtocolProxy(Ext.apply({srsName:a.srsName,url:a.url,featureType:a.featureType,featureNS:a.featureNS,geometryName:a.geometryName,schema:a.schema,filter:a.ogcFilter,maxFeatures:a.maxFeatures,multi:a.multi},a.proxy)));a.writer||(a.writer=new Ext.data.DataWriter({write:Ext.emptyFn}));gxp.data.WFSFeatureStore.superclass.constructor.apply(this,
  arguments);this.reader.extractValues=function(a){return this.readRecords([a.feature]).records[0].data}.createDelegate(this.reader);this.reader.meta.idProperty="id";this.reader.getId=function(a){return a.id}}});Ext.namespace("gxp");
  gxp.GoogleStreetViewPanel=Ext.extend(Ext.Panel,{panorama:null,heading:0,pitch:0,zoom:0,location:null,initComponent:function(){Ext.applyIf(this,{plain:!0,border:!1});return gxp.GoogleStreetViewPanel.superclass.initComponent.call(this)},afterRender:function(){var a=this.ownerCt;a&&(a=a.getSize(),Ext.applyIf(this,a),this.location||GeoExt.Popup&&this.bubble(function(a){if(a instanceof GeoExt.Popup)return this.location=a.location.clone().transform(a.map.getProjectionObject(),new OpenLayers.Projection("EPSG:4326")),
  !1},this));gxp.GoogleStreetViewPanel.superclass.afterRender.call(this);a={position:new google.maps.LatLng(this.location.lat,this.location.lon),pov:{heading:this.heading,pitch:this.pitch,zoom:this.zoom}};this.panorama=new google.maps.StreetViewPanorama(this.body.dom,a)},beforeDestroy:function(){delete this.panorama;gxp.GoogleStreetViewPanel.superclass.beforeDestroy.apply(this,arguments)},onResize:function(a,b){gxp.GoogleStreetViewPanel.superclass.onResize.apply(this,arguments);this.panorama&&"object"==
  typeof this.panorama&&google.maps.event.trigger(this.panorama,"resize")},setSize:function(a,b,c){gxp.GoogleStreetViewPanel.superclass.setSize.apply(this,arguments);this.panorama&&"object"==typeof this.panorama&&google.maps.event.trigger(this.panorama,"resize")}});Ext.reg("gxp_googlestreetviewpanel",gxp.GoogleStreetViewPanel);Ext.ns("gxp.data");
  gxp.data.GroupStyleReader=Ext.extend(GeoExt.data.StyleReader,{onMetaChange:function(){gxp.data.GroupStyleReader.superclass.onMetaChange.apply(this,arguments);var a=this.recordType,b=!1;a.prototype.set=Ext.createInterceptor(this.recordType.prototype.set,function(c,d){if(!b&&"filter"===c){b=!0;var e=this.store,f=this.get("filter");BETWEEN=OpenLayers.Filter.Comparison.BETWEEN;f instanceof OpenLayers.Filter&&"string"===typeof d&&(d=OpenLayers.Format.CQL.prototype.read(d));var g,h=e.indexOf(this);if(h<
  e.getCount()-1&&(g=d.type===BETWEEN?"upperBoundary":"value",d[g]!==f[g])){var j=e.getAt(h+1),k=j.get("filter").clone();k[k.type===BETWEEN?"lowerBoundary":"value"]=d[g];j.set("filter",k)}0<h&&(g=d.type===BETWEEN?"lowerBoundary":"value",d[g]!==f[g]&&(e=e.getAt(h-1),f=e.get("filter").clone(),f[f.type===BETWEEN?"upperBoundary":"value"]=d[g],e.set("filter",f)));a.prototype.set.apply(this,[c,d]);return b=!1}})}});Ext.namespace("gxp.grid");
  gxp.grid.FeatureGrid=Ext.extend(Ext.grid.GridPanel,{map:null,ignoreFields:null,includeFields:null,layer:null,initComponent:function(){this.ignoreFields=["feature","state","fid"].concat(this.ignoreFields);this.store?(this.cm=this.createColumnModel(this.store),this.map&&(this.layer=new OpenLayers.Layer.Vector(this.id+"_layer"),this.map.addLayer(this.layer))):(this.store=new Ext.data.Store,this.cm=new Ext.grid.ColumnModel({columns:[]}));this.layer&&(this.sm=this.sm||new GeoExt.grid.FeatureSelectionModel({layerFromStore:!1,
  layer:this.layer}),this.store instanceof GeoExt.data.FeatureStore&&this.store.bind(this.layer));this.dateFormat||(this.dateFormat=Ext.form.DateField.prototype.format);this.timeFormat||(this.timeFormat=Ext.form.TimeField.prototype.format);gxp.grid.FeatureGrid.superclass.initComponent.call(this)},onDestroy:function(){this.initialConfig&&this.initialConfig.map&&!this.initialConfig.layer&&(this.layer.destroy(),delete this.layer);gxp.grid.FeatureGrid.superclass.onDestroy.apply(this,arguments)},setStore:function(a,
  b){b&&(this.schema=b);a?(this.store instanceof GeoExt.data.FeatureStore&&this.store.unbind(),this.layer&&(this.layer.destroyFeatures(),a.bind(this.layer)),this.reconfigure(a,this.createColumnModel(a))):this.reconfigure(new Ext.data.Store,new Ext.grid.ColumnModel({columns:[]}))},getColumns:function(a){function b(a){return function(b){var c=b;"string"==typeof b&&(c=Date.parseDate(b.replace(/Z$/,""),"c"));return c?c.format(a):b}}var c=[],d=this.customRenderers||{},e,f,g,h,j;(this.schema||a.fields).each(function(a){if(this.schema)switch(e=
  a.get("name"),f=a.get("type").split(":").pop(),h=null,f){case "date":h=this.dateFormat;break;case "datetime":h=h?h:this.dateFormat+" "+this.timeFormat;g=void 0;j=b(h);break;case "boolean":g="booleancolumn";break;case "string":g="gridcolumn";break;default:g="numbercolumn"}else e=a.name;if(-1===this.ignoreFields.indexOf(e)&&(null===this.includeFields||0<=this.includeFields.indexOf(e)))c.push({dataIndex:e,hidden:this.fieldVisibility?!this.fieldVisibility[e]:!1,header:this.propertyNames?this.propertyNames[e]||
  e:e,sortable:!0,xtype:g,format:h,renderer:d[e]||(g?void 0:j)})},this);return c},createColumnModel:function(a){a=this.getColumns(a);return new Ext.grid.ColumnModel(a)}});Ext.reg("gxp_featuregrid",gxp.grid.FeatureGrid);
  (function(){function a(a){var c=this.meta.format;if("string"===typeof a||a.nodeType){var a=c.read(a),d=c.read;c.read=function(){c.read=d;return a}}this.raw=a}Ext.intercept(GeoExt.data.WMSCapabilitiesReader.prototype,"readRecords",a);GeoExt.data.AttributeReader&&Ext.intercept(GeoExt.data.AttributeReader.prototype,"readRecords",a)})();Ext.namespace("gxp.plugins");
  gxp.plugins.WMSSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_wmssource",baseParams:null,format:null,describeLayerStore:null,describedLayers:null,schemaCache:null,ready:!1,requiredProperties:["title","bbox"],constructor:function(a){a&&!0===a.forceLazy&&(a.requiredProperties=[],delete a.forceLazy,window.console&&console.warn("Deprecated config option 'forceLazy: true' for layer source '"+a.id+"'. Use 'requiredProperties: []' instead."));gxp.plugins.WMSSource.superclass.constructor.apply(this,
  arguments);this.format||(this.format=new OpenLayers.Format.WMSCapabilities({keepData:!0}))},init:function(a){gxp.plugins.WMSSource.superclass.init.apply(this,arguments);this.target.on("authorizationchange",this.onAuthorizationChange,this)},onAuthorizationChange:function(){this.store&&"/"===this.store.url.charAt(0)&&this.store.reload()},destroy:function(){this.target.un("authorizationchange",this.onAuthorizationChange,this);gxp.plugins.WMSSource.superclass.destroy.apply(this,arguments)},isLazy:function(){var a=
  !0,b=this.target.initialConfig.map;if(b&&b.layers)for(var c,d=0,e=b.layers.length;d<e&&!(c=b.layers[d],c.source===this.id&&(a=this.layerConfigComplete(c),!1===a));++d);return a},layerConfigComplete:function(a){var b=!0;if(!Ext.isObject(a.capability))for(var c=this.requiredProperties,d=c.length-1;0<=d&&!(b=!!a[c[d]],!1===b);--d);return b},createStore:function(){var a=this.baseParams||{SERVICE:"WMS",REQUEST:"GetCapabilities"};this.version&&(a.VERSION=this.version);var b=this.isLazy();this.store=new GeoExt.data.WMSCapabilitiesStore({url:this.trimUrl(this.url,
  a),baseParams:a,format:this.format,autoLoad:!b,layerParams:{exceptions:null},listeners:{load:function(){if(!this.store.reader.raw||!this.store.reader.raw.service)this.fireEvent("failure",this,"Invalid capabilities document.");else{if(!this.title)this.title=this.store.reader.raw.service.title;if(this.ready)this.lazy=false;else{this.ready=true;this.fireEvent("ready",this)}}delete this.format.data},exception:function(a,b,e,f,g,h){delete this.store;a="";if(b==="response")if(typeof h=="string")b=h;else{b=
  "Invalid response from server.";(a=this.format&&this.format.data)&&a.parseError&&(b=b+("  "+a.parseError.reason+" - line: "+a.parseError.line));g=g.status;a=g>=200&&g<300?gxp.util.getOGCExceptionText(h&&h.arg&&h.arg.exceptionReport):"Status: "+g}else{b="Trouble creating layer store from response.";a="Unable to handle response."}this.fireEvent("failure",this,b,a);delete this.format.data},scope:this}});b&&(this.lazy=!0,Ext.Ajax.request({method:"GET",url:this.url,params:{SERVICE:"WMS"},callback:function(a,
  b,e){a=e.status;if(a>=200&&a<403&&e.responseText){this.ready=true;this.fireEvent("ready",this)}else this.fireEvent("failure",this,"Layer source not available.","Unable to contact WMS service.")},scope:this}))},trimUrl:function(a,b){var c=OpenLayers.Util.getParameters(a),b=OpenLayers.Util.upperCaseObject(b),d=0,e;for(e in c)++d,e.toUpperCase()in b&&(--d,delete c[e]);return a.split("?").shift()+(d?"?"+OpenLayers.Util.getParameterString(c):"")},createLazyLayerRecord:function(a){var a=Ext.apply({},a),
  b=a.srs||this.target.map.projection;a.srs={};a.srs[b]=!0;var c=a.bbox||this.target.map.maxExtent;a.bbox={};a.bbox[b]={bbox:c};c=this.store&&this.store instanceof GeoExt.data.WMSCapabilitiesStore?new this.store.recordType(a):new GeoExt.data.LayerRecord(a);c.setLayer(new OpenLayers.Layer.WMS(a.title||a.name,a.url||this.url,{layers:a.name,transparent:"transparent"in a?a.transparent:!0,format:a.format},{projection:b}));c.json=a;return c},createLayerRecord:function(a){var b,c,d=this.store.findExact("name",
  a.name);-1<d?c=this.store.getAt(d):Ext.isObject(a.capability)?c=this.store.reader.readRecords({capability:{request:{getmap:{href:this.url}},layers:[a.capability]}}).records[0]:this.layerConfigComplete(a)&&(c=this.createLazyLayerRecord(a));if(c){b=c.getLayer().clone();var d=this.getMapProjection(),e=this.getProjection(c),f=(e||d).getCode(),g=c.get("bbox"),h;if(g&&g[f])b.addOptions({projection:e}),h=OpenLayers.Bounds.fromArray(g[f].bbox,b.reverseAxisOrder());else if(e=c.get("llbbox"))d=OpenLayers.Bounds.fromArray(e).transform("EPSG:4326",
  d),0<1/d.getHeight()&&0<1/d.getWidth()&&(h=d);b.mergeNewParams({STYLES:a.styles,FORMAT:a.format,TRANSPARENT:a.transparent});d=!1;"tiled"in a?d=!a.tiled:c.data.dimensions&&c.data.dimensions.time&&(d=!0);b.setName(a.title||b.name);b.addOptions({attribution:b.attribution,maxExtent:h,restrictedExtent:h,singleTile:d,ratio:a.ratio||1,visibility:"visibility"in a?a.visibility:!0,opacity:"opacity"in a?a.opacity:1,buffer:"buffer"in a?a.buffer:1,dimensions:c.data.dimensions,transitionEffect:d?"resize":null});
  h=Ext.applyIf({title:b.name,group:a.group,infoFormat:a.infoFormat,source:a.source,properties:"gxp_wmslayerpanel",fixed:a.fixed,selected:"selected"in a?a.selected:!1,restUrl:this.restUrl,layer:b},c.data);var j=[{name:"source",type:"string"},{name:"group",type:"string"},{name:"properties",type:"string"},{name:"fixed",type:"boolean"},{name:"selected",type:"boolean"},{name:"restUrl",type:"string"},{name:"infoFormat",type:"string"}];c.fields.each(function(a){j.push(a)});b=new (GeoExt.data.LayerRecord.create(j))(h,
  b.id);b.json=a}else window.console&&0<this.store.getCount()&&console.warn("Could not create layer record for layer '"+a.name+"'. Check if the layer is found in the WMS GetCapabilities response.");return b},getProjection:function(a){var b=this.getMapProjection(),c=b,a=a.get("srs");if(!a[b.getCode()]){var c=null,d,e;for(e in a)if((d=new OpenLayers.Projection(e)).equals(b)){c=d;break}}return c},initDescribeLayerStore:function(){var a=this.store.reader.raw;this.lazy&&(a={capability:{request:{describelayer:{href:this.url}}},
  version:this.version||"1.1.1"});var b=a.capability.request.describelayer;b&&(a=a.version,1.1<parseFloat(a)&&(a="1.1.1"),a={SERVICE:"WMS",VERSION:a,REQUEST:"DescribeLayer"},this.describeLayerStore=new GeoExt.data.WMSDescribeLayerStore({url:this.trimUrl(b.href,a),baseParams:a}))},describeLayer:function(a,b,c){function d(a){window.setTimeout(function(){b.call(c,a)},0)}this.describeLayerStore||this.initDescribeLayerStore();if(this.describeLayerStore){this.describedLayers||(this.describedLayers={});var e=
  a.getLayer().params.LAYERS,a=function(){for(var a=Ext.isArray(arguments[1])?arguments[1]:arguments[0],d,g,l=a.length-1;l>=0;l--){d=a[l];g=d.get("layerName");if(g==e){this.describeLayerStore.un("load",arguments.callee,this);this.describedLayers[g]=true;b.call(c,d);return}if(typeof this.describedLayers[g]=="function"){d=this.describedLayers[g];this.describeLayerStore.un("load",d,this);d.apply(this,arguments)}}delete f[e];b.call(c,false)},f=this.describedLayers,g;if(f[e])if(-1==(g=this.describeLayerStore.findExact("layerName",
  e)))this.describeLayerStore.on("load",a,this);else d(this.describeLayerStore.getAt(g));else f[e]=a,this.describeLayerStore.load({params:{LAYERS:e},add:!0,callback:a,scope:this})}else d(!1)},fetchSchema:function(a,b,c,d){var e=this.schemaCache[b];if(e)if(0==e.getCount())e.on("load",function(){c.call(d,e)},this,{single:!0});else c.call(d,e);else e=new GeoExt.data.AttributeStore({url:a,baseParams:{SERVICE:"WFS",VERSION:"1.1.0",REQUEST:"DescribeFeatureType",TYPENAME:b},autoLoad:!0,listeners:{load:function(){c.call(d,
  e)},scope:this}}),this.schemaCache[b]=e},getSchema:function(a,b,c){this.schemaCache||(this.schemaCache={});this.describeLayer(a,function(d){if(d&&d.get("owsType")=="WFS"){var e=d.get("typeName");this.fetchSchema(d.get("owsURL"),e,b,c)}else d?b.call(c,false):this.fetchSchema(this.url,a.get("name"),b,c)},this)},getWFSProtocol:function(a,b,c){this.getSchema(a,function(d){var e=!1;if(d){var f,g=/gml:((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry)).*/;d.each(function(a){g.exec(a.get("type"))&&(f=
  a.get("name"))},this);e=new OpenLayers.Protocol.WFS({version:"1.1.0",srsName:a.getLayer().projection.getCode(),url:d.url,featureType:d.reader.raw.featureTypes[0].typeName,featureNS:d.reader.raw.targetNamespace,geometryName:f})}b.call(c,e,d,a)},this)},getConfigForRecord:function(a){var b=Ext.applyIf(gxp.plugins.WMSSource.superclass.getConfigForRecord.apply(this,arguments),a.json),c=a.getLayer(),d=c.params,e=b.name,f=this.store.reader.raw;if(f)for(var f=f.capability.layers,g=f.length-1;0<=g;--g)if(f[g].name===
  e){b.capability=Ext.apply({},f[g]);e={};e[c.projection.getCode()]=!0;b.capability.srs=e;break}b.capability||(c.maxExtent&&(b.bbox=c.maxExtent.toArray()),b.srs=c.projection.getCode());return Ext.apply(b,{format:d.FORMAT,styles:d.STYLES,transparent:d.TRANSPARENT})},getState:function(){var a=gxp.plugins.WMSSource.superclass.getState.apply(this,arguments);return Ext.applyIf(a,{title:this.title})}});Ext.preg(gxp.plugins.WMSSource.prototype.ptype,gxp.plugins.WMSSource);Ext.namespace("gxp.plugins");
  gxp.plugins.NavigationHistory=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_navigationhistory",previousMenuText:"Zoom To Previous Extent",nextMenuText:"Zoom To Next Extent",previousTooltip:"Zoom To Previous Extent",nextTooltip:"Zoom To Next Extent",constructor:function(a){gxp.plugins.NavigationHistory.superclass.constructor.apply(this,arguments)},addActions:function(){var a=new OpenLayers.Control.NavigationHistory;this.target.mapPanel.map.addControl(a);a=[new GeoExt.Action({menuText:this.previousMenuText,
  iconCls:"gxp-icon-zoom-previous",tooltip:this.previousTooltip,disabled:!0,control:a.previous}),new GeoExt.Action({menuText:this.nextMenuText,iconCls:"gxp-icon-zoom-next",tooltip:this.nextTooltip,disabled:!0,control:a.next})];return gxp.plugins.NavigationHistory.superclass.addActions.apply(this,[a])}});Ext.preg(gxp.plugins.NavigationHistory.prototype.ptype,gxp.plugins.NavigationHistory);Ext.namespace("gxp.form");
  gxp.form.ComparisonComboBox=Ext.extend(Ext.form.ComboBox,{allowedTypes:[[OpenLayers.Filter.Comparison.EQUAL_TO,"="],[OpenLayers.Filter.Comparison.NOT_EQUAL_TO,"<>"],[OpenLayers.Filter.Comparison.LESS_THAN,"<"],[OpenLayers.Filter.Comparison.GREATER_THAN,">"],[OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO,"<="],[OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,">="],[OpenLayers.Filter.Comparison.LIKE,"like"],[OpenLayers.Filter.Comparison.BETWEEN,"between"]],allowBlank:!1,mode:"local",typeAhead:!0,
  forceSelection:!0,triggerAction:"all",width:50,editable:!0,initComponent:function(){var a={displayField:"name",valueField:"value",store:new Ext.data.SimpleStore({data:this.allowedTypes,fields:["value","name"]}),value:void 0===this.value?this.allowedTypes[0][0]:this.value,listeners:{blur:function(){var a=this.store.findExact("value",this.getValue());-1!=a?this.fireEvent("select",this,this.store.getAt(a)):null!=this.startValue&&this.setValue(this.startValue)}}};Ext.applyIf(this,a);gxp.form.ComparisonComboBox.superclass.initComponent.call(this)}});
  Ext.reg("gxp_comparisoncombo",gxp.form.ComparisonComboBox);Ext.namespace("gxp");
  gxp.Histogram=Ext.extend(Ext.BoxComponent,{onRender:function(a,b){if(!this.el){var c=document.createElement("div");c.id=this.getId();this.el=Ext.get(c)}this.el.addClass("gxp-histogram");this.quantities&&this.setQuantities(this.quantities);gxp.Histogram.superclass.onRender.apply(this,arguments)},setQuantities:function(a){for(this.quantities=a;this.el.dom.firstChild;)this.el.dom.removeChild(this.el.dom.firstChild);var b,c=0,d=Number.POSITIVE_INFINITY,e,f=a.length;for(e=0;e<f;++e)b=a[e],b<d&&(d=b),b>
  c&&(c=b);var c=100/c,g,h=100/f;for(e=0;e<f;++e)b=document.createElement("div"),b.className="bar",g=b.style,g.width=h+"%",g.left=e*h+"%",g.top=100-(a[e]-d)*c+"%",this.el.dom.appendChild(b)}});Ext.reg("gxp_histogram",gxp.Histogram);Ext.namespace("gxp.form");
  gxp.form.ColorField=Ext.extend(Ext.form.TextField,{cssColors:{aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"},defaultBackground:"#ffffff",initComponent:function(){this.value&&(this.value=this.hexToColor(this.value));gxp.form.ColorField.superclass.initComponent.call(this);this.on({render:this.colorField,
  valid:this.colorField,scope:this})},isDark:function(a){var b=!1;if(a)var b=parseInt(a.substring(1,3),16)/255,c=parseInt(a.substring(3,5),16)/255,a=parseInt(a.substring(5,7),16)/255,b=0.5>0.299*b+0.587*c+0.144*a;return b},colorField:function(){var a=this.colorToHex(this.getValue())||this.defaultBackground;this.getEl().setStyle({background:a,color:this.isDark(a)?"#ffffff":"#000000"})},getHexValue:function(){return this.colorToHex(gxp.form.ColorField.superclass.getValue.apply(this,arguments))},getValue:function(){var a=
  this.getHexValue(),b=this.initialConfig.value;a===this.hexToColor(b)&&(a=b);return a},setValue:function(a){gxp.form.ColorField.superclass.setValue.apply(this,[this.hexToColor(a)])},colorToHex:function(a){return!a?a:a.match(/^#[0-9a-f]{6}$/i)?a:this.cssColors[a.toLowerCase()]||null},hexToColor:function(a){if(!a)return a;for(var b in this.cssColors)if(this.cssColors[b]==a.toUpperCase()){a=b;break}return a}});Ext.reg("gxp_colorfield",gxp.form.ColorField);Ext.namespace("gxp.plugins");
  gxp.plugins.GoogleEarth=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_googleearth",timeout:7E3,menuText:"3D Viewer",tooltip:"Switch to 3D Viewer",tooltipMap:"Switch back to normal map view",constructor:function(a){gxp.plugins.GoogleEarth.superclass.constructor.apply(this,arguments)},addActions:function(){return gxp.plugins.GoogleEarth.superclass.addActions.apply(this,[[{menuText:this.menuText,enableToggle:!0,iconCls:"gxp-icon-googleearth",tooltip:this.tooltip,toggleHandler:function(a,b){this.actions[0].each(function(a){a.toggle&&
  a.toggle(!1,!0)});this.togglePanelDisplay(b)},scope:this}]])},togglePanelDisplay:function(a){var b=this.target.mapPanel.ownerCt,c=b&&b.getLayout();if(c&&c instanceof Ext.layout.CardLayout)if(!0===a)gxp.plugins.GoogleEarth.loader.onLoad({callback:function(){c.setActiveItem(1);this.actions[0].enable();this.actions[0].items[0].setTooltip(this.tooltipMap);this.actions[0].each(function(a){a.toggle&&a.toggle(!0,!0)})},scope:this});else c.setActiveItem(0),this.actions[0].items[0].setTooltip(this.tooltip)},
  getHost:function(){return window.location.host.split(":").shift()+":"+(window.location.port||"80")}});
  gxp.plugins.GoogleEarth.loader=new (Ext.extend(Ext.util.Observable,{ready:!(!window.google||!window.google.earth),loading:!1,constructor:function(){this.addEvents("ready","failure");return Ext.util.Observable.prototype.constructor.apply(this,arguments)},onScriptLoad:function(){var a=gxp.plugins.GoogleEarth.loader;a.ready||(a.ready=!0,a.loading=!1,a.fireEvent("ready"))},onLoad:function(a){if(this.ready)window.setTimeout(function(){a.callback.call(a.scope)},0);else if(this.loading)this.on({ready:a.callback,
  failure:a.errback||Ext.emptyFn,scope:a.scope});else this.loadScript(a)},loadScript:function(a){function b(){document.getElementsByTagName("head")[0].appendChild(d)}window.google&&delete google.loader;var c={autoload:Ext.encode({modules:[{name:"earth",version:"1",callback:"gxp.plugins.GoogleEarth.loader.onScriptLoad"}]})},d=document.createElement("script");d.src="http://www.google.com/jsapi?"+Ext.urlEncode(c);c=a.timeout||gxp.plugins.GoogleSource.prototype.timeout;window.setTimeout(function(){gxp.plugins.GoogleEarth.loader.ready||
  (this.fireEvent("failure"),this.unload())}.createDelegate(this),c);this.on({ready:a.callback,failure:a.errback||Ext.emptyFn,scope:a.scope});this.loading=!0;if(document.body)b();else Ext.onReady(b);this.script=d},unload:function(){this.purgeListeners();this.script&&(document.getElementsByTagName("head")[0].removeChild(this.script),delete this.script);this.ready=this.loading=!1;delete google.loader;delete google.earth}}));Ext.preg(gxp.plugins.GoogleEarth.prototype.ptype,gxp.plugins.GoogleEarth);Ext.namespace("gxp.plugins");
  gxp.plugins.OSMSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_osmsource",title:"OpenStreetMap Layers",mapnikAttribution:"Data CC-By-SA by <a href='http://openstreetmap.org/' target='_blank'>OpenStreetMap</a>",osmarenderAttribution:"Data CC-By-SA by <a href='http://openstreetmap.org/' target='_blank'>OpenStreetMap</a>",createStore:function(){var a={projection:"EPSG:900913",maxExtent:new OpenLayers.Bounds(-2.00375083392E7,-2.00375083392E7,2.00375083392E7,2.00375083392E7),maxResolution:156543.03390625,
  numZoomLevels:19,units:"m",buffer:1,transitionEffect:"resize"},a=[new OpenLayers.Layer.OSM("OpenStreetMap",["http://a.tile.openstreetmap.org/${z}/${x}/${y}.png","http://b.tile.openstreetmap.org/${z}/${x}/${y}.png","http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"],OpenLayers.Util.applyDefaults({attribution:this.mapnikAttribution,type:"mapnik"},a))];this.store=new GeoExt.data.LayerStore({layers:a,fields:[{name:"source",type:"string"},{name:"name",type:"string",mapping:"type"},{name:"abstract",type:"string",
  mapping:"attribution"},{name:"group",type:"string",defaultValue:"background"},{name:"fixed",type:"boolean",defaultValue:!0},{name:"selected",type:"boolean"}]});this.store.each(function(a){a.set("group","background")});this.fireEvent("ready",this)},createLayerRecord:function(a){var b,c=this.store.findExact("name",a.name);-1<c&&(b=this.store.getAt(c).copy(Ext.data.Record.id({})),c=b.getLayer().clone(),a.title&&(c.setName(a.title),b.set("title",a.title)),"visibility"in a&&(c.visibility=a.visibility),
  b.set("selected",a.selected||!1),b.set("source",a.source),b.set("name",a.name),"group"in a&&b.set("group",a.group),b.data.layer=c,b.commit());return b}});Ext.preg(gxp.plugins.OSMSource.prototype.ptype,gxp.plugins.OSMSource);Ext.namespace("gxp");
  gxp.StrokeSymbolizer=Ext.extend(Ext.FormPanel,{solidStrokeName:"solid",dashStrokeName:"dash",dotStrokeName:"dot",titleText:"Stroke",styleText:"Style",colorText:"Color",widthText:"Width",opacityText:"Opacity",symbolizer:null,colorManager:null,checkboxToggle:!0,defaultColor:null,dashStyles:null,border:!1,initComponent:function(){this.dashStyles=this.dashStyles||[["solid",this.solidStrokeName],["4 4",this.dashStrokeName],["2 4",this.dotStrokeName]];this.symbolizer||(this.symbolizer={});var a;this.colorManager&&
  (a=[new this.colorManager]);this.items=[{xtype:"fieldset",title:this.titleText,autoHeight:!0,checkboxToggle:this.checkboxToggle,collapsed:!0===this.checkboxToggle&&!1===this.symbolizer.stroke,hideMode:"offsets",defaults:{width:100},items:[{xtype:"combo",name:"style",fieldLabel:this.styleText,store:new Ext.data.SimpleStore({data:this.dashStyles,fields:["value","display"]}),displayField:"display",valueField:"value",value:this.getDashArray(this.symbolizer.strokeDashstyle)||OpenLayers.Renderer.defaultSymbolizer.strokeDashstyle,
  mode:"local",allowBlank:!0,triggerAction:"all",editable:!1,listeners:{select:function(a,c){this.symbolizer.strokeDashstyle=c.get("value");this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"gxp_colorfield",name:"color",fieldLabel:this.colorText,emptyText:OpenLayers.Renderer.defaultSymbolizer.strokeColor,value:this.symbolizer.strokeColor,defaultBackground:this.defaultColor||OpenLayers.Renderer.defaultSymbolizer.strokeColor,plugins:a,listeners:{valid:function(a){var a=a.getValue(),c=this.symbolizer.strokeColor!=
  a;this.symbolizer.strokeColor=a;c&&this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"numberfield",name:"width",fieldLabel:this.widthText,allowNegative:!1,emptyText:OpenLayers.Renderer.defaultSymbolizer.strokeWidth,value:this.symbolizer.strokeWidth,listeners:{change:function(a,c){c=parseFloat(c);isNaN(c)?delete this.symbolizer.strokeWidth:this.symbolizer.strokeWidth=c;this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"slider",name:"opacity",fieldLabel:this.opacityText,values:[100*
  ("strokeOpacity"in this.symbolizer?this.symbolizer.strokeOpacity:OpenLayers.Renderer.defaultSymbolizer.strokeOpacity)],isFormField:!0,listeners:{changecomplete:function(a,c){this.symbolizer.strokeOpacity=c/100;this.fireEvent("change",this.symbolizer)},scope:this},plugins:[new GeoExt.SliderTip({getText:function(a){return a.value+"%"}})]}],listeners:{collapse:function(){if(this.symbolizer.stroke!==false){this.symbolizer.stroke=false;this.fireEvent("change",this.symbolizer)}},expand:function(){this.symbolizer.stroke=
  true;this.fireEvent("change",this.symbolizer)},scope:this}}];this.addEvents("change");gxp.StrokeSymbolizer.superclass.initComponent.call(this)},getDashArray:function(a){var b;a&&(a=a.split(/\s+/),a=a[0]/a[1],isNaN(a)||(b=1<=a?"4 4":"2 4"));return b}});Ext.reg("gxp_strokesymbolizer",gxp.StrokeSymbolizer);Ext.ns("gxp.slider");
  gxp.slider.TimeSlider=Ext.extend(Ext.slider.MultiSlider,{ref:"slider",cls:"gx_timeslider",indexMap:null,width:200,animate:!1,timeFormat:"l, F d, Y g:i:s A",timeManager:null,playbackMode:"track",autoPlay:!1,initComponent:function(){this.timeManager||(this.timeManager=new OpenLayers.Control.TimeManager,app.mapPanel.map.addControl(this.timeManager));this.timeManager.timeAgents&&(this.timeManager.units||this.timeManager.guessPlaybackRate(),this.playbackMode&&"track"!=this.playbackMode&&this.timeManager.units&&
  this.timeManager.incrementTime(this.timeManager.rangeInterval,this.timeManager.units));var a=this.buildSliderValues();if(a){this.timeManager.guessPlaybackRate();var b={maxValue:a.maxValue,minValue:a.minValue,increment:a.interval,keyIncrement:a.interval,indexMap:a.map,values:a.values};this.initialConfig.timeFormat||this.setTimeFormat(gxp.PlaybackToolbar.guessTimeFormat(a.interval));Ext.applyIf(this.initialConfig,b);Ext.apply(this,this.initialConfig)}this.timeManager.events.on({rangemodified:this.onRangeModified,
  tick:this.onTimeTick,scope:this});this.plugins=(this.plugins||[]).concat([new Ext.slider.Tip({getText:this.getThumbText})]);this.listeners=Ext.applyIf(this.listeners||{},{changecomplete:this.onSliderChangeComplete,dragstart:function(){if(this.timeManager.timer){this.timeManager.stop();this._restartPlayback=true}},beforechange:function(a,b,e,f){b=true;!this.timeManager.units&&!this.timeManager.snapToIntervals?b=false:this.playbackMode=="cumulative"&&a.indexMap[f.index]=="tail"&&(b=false);return b},
  afterrender:function(a){this.sliderTip=a.plugins[0];this.timeManager.units&&a.thumbs.length>1&&a.setThumbStyles();this.autoPlay&&this.timeManager.play()},scope:this});gxp.slider.TimeSlider.superclass.initComponent.call(this)},setPlaybackMode:function(a){this.playbackMode=a;a=this.buildSliderValues();this.reconfigureSlider(a);"track"!=this.playbackMode&&(this.timeManager.incrementTime(this.timeManager.rangeInterval,this.timeManager.units||OpenLayers.TimeUnit[gxp.PlaybackToolbar.smartIntervalFormat(a.interval).units.toUpperCase()]),
  this.setValue(0,this.timeManager.currentTime.getTime()));this.setThumbStyles()},setTimeFormat:function(a){this.timeFormat=a},onRangeModified:function(){var a=this.timeManager;if(!a.timeAgents||!a.timeAgents.length)a.map.removeControl(this.ctl),a.destroy();else{var b=a.range[0].getTime(),c=a.range[1].getTime();a.guessPlaybackRate();if(a.range[0].getTime()!=b||a.range[1].getTime()!=c||void 0!=a.units||void 0!=a.step)this.reconfigureSlider(this.buildSliderValues()),this.setThumbStyles(),this.fireEvent("rangemodified",
  this,a.range)}},onTimeTick:function(a){var b=a.currentTime;if(b){var c=this.refOwner,d=this.indexMap?this.indexMap.indexOf("tail"):-1,e=-1<d?b.getTime()-this.thumbs[0].value:0;this.setValue(0,a.currentTime.getTime());-1<d&&this.setValue(d,this.thumbs[d].value+e);this.updateTimeDisplay();c.fireEvent("timechange",c,b)}},updateTimeDisplay:function(){this.sliderTip.onSlide(this,null,this.thumbs[0]);this.sliderTip.el.alignTo(this.el,"b-t?",this.offsets)},buildSliderValues:function(){if(!this.timeManager.units&&
  !this.timeManager.snapToIntervals)return!1;var a=["primary"],b=[this.timeManager.currentTime.getTime()],c=this.timeManager.range[0].getTime(),d=this.timeManager.range[1].getTime(),e=new Date(c);if(this.timeManager.units)var f=parseFloat(e["getUTC"+this.timeManager.units]())+parseFloat(this.timeManager.step),e=e["setUTC"+this.timeManager.units](f)-c;else e=!1;this.dynamicRange&&(f=0.1*(c-d),b.push(c-=f,d+=f),a[1]="minTime",a[2]="maxTime");this.playbackMode&&"track"!=this.playbackMode&&(b.push(c),a[a.length]=
  "tail");!e&&this.timeManager.intervals&&2<this.timeManager.intervals.length&&(e=Math.round((d-c)/this.timeManager.intervals.length));return{values:b,map:a,maxValue:d,minValue:c,interval:e}},reconfigureSlider:function(a){this.setMaxValue(a.maxValue);this.setMinValue(a.minValue);Ext.apply(this,{increment:a.interval,keyIncrement:a.interval,indexMap:a.map});for(var b=0;b<a.values.length;b++)this.thumbs[b]?this.setValue(b,a.values[b]):this.addThumb(a.values[b]);!a.interval&&this.timeManager.intervals&&
  2<this.timeManager.intervals.length&&(a.interval=Math.round((a.maxValue-a.minValue)/this.timeManager.intervals.length));this.setTimeFormat(gxp.PlaybackToolbar.guessTimeFormat(a.interval))},setThumbStyles:function(){var a=this.indexMap.indexOf("tail");"min"==this.indexMap[1]&&(this.thumbs[1].el.addClass("x-slider-min-thumb"),this.thumbs[2].el.addClass("x-slider-max-thumb"));if(-1<a){var a=this.thumbs[a],b=this.thumbs[0];a.el.addClass("x-slider-tail-thumb");a.constrain=!1;b.constrain=!1}},getThumbText:function(a){if("tail"!=
  a.slider.indexMap[a.index])return(new Date(a.value)).format(a.slider.timeFormat);a=gxp.PlaybackToolbar.smartIntervalFormat.call(a,a.slider.thumbs[0].value-a.value);return a.value+" "+a.units},onSliderChangeComplete:function(a,b,c,d){var e=new Date(b),f=a.timeManager;switch(a.indexMap[c.index]){case "primary":d=a.indexMap.indexOf("tail");if(-1<d)a.onSliderChangeComplete(a,a.thumbs[d].value,a.thumbs[d],!0);if(!f.snapToIntervals&&f.units)f.setTime(e);else if(f.snapToIntervals&&f.intervals.length){var g=
  0;Ext.each(f.intervals,function(a,c,d){if(a.getTime()==b)return g=c,!1;d=b-d[g].getTime();a=a.getTime()-b;if(d<a)return!1;g=c});f.setTime(f.intervals[g])}break;case "min":b>=f.intialRange[0].getTime()&&f.setStart(new Date(b));break;case "max":b<=f.intialRange[1].getTime()&&f.setEnd(new Date(b));break;case "tail":e=1;switch(f.units){case OpenLayers.TimeUnit.YEARS:e*=12;case OpenLayers.TimeUnit.MONTHS:e*=365/12;case OpenLayers.TimeUnit.DAYS:e*=24;case OpenLayers.TimeUnit.HOURS:e*=60;case OpenLayers.TimeUnit.MINUTES:e*=
  60;case OpenLayers.TimeUnit.SECONDS:e*=1E3}for(var c=0,h=f.timeAgents.length;c<h;c++)"range"==f.timeAgents[c].rangeMode&&(f.timeAgents[c].rangeInterval=(a.thumbs[0].value-b)/e);d||f.setTime(new Date(a.thumbs[0].value))}this._restartPlayback&&(delete this._restartPlayback,f.play())}});Ext.reg("gxp_timeslider",gxp.slider.TimeSlider);Ext.namespace("gxp");
  gxp.PlaybackToolbar=Ext.extend(Ext.Toolbar,{control:null,viewer:null,initialTime:null,timeFormat:"l, F d, Y g:i:s A",toolbarCls:"x-toolbar gx-overlay-playback",ctCls:"gx-playback-wrap",slider:!0,dynamicRange:!1,playbackMode:"track",showIntervals:!1,labelButtons:!1,settingsButton:!0,rateAdjuster:!1,looped:!1,autoPlay:!1,optionsWindow:null,playing:!1,playLabel:"Play",playTooltip:"Play",stopLabel:"Stop",stopTooltip:"Stop",fastforwardLabel:"FFWD",fastforwardTooltip:"Double Speed Playback",nextLabel:"Next",
  nextTooltip:"Advance One Frame",resetLabel:"Reset",resetTooltip:"Reset to the start",loopLabel:"Loop",loopTooltip:"Continously loop the animation",normalTooltip:"Return to normal playback",pauseLabel:"Pause",pauseTooltip:"Pause",initComponent:function(){this.playbackActions||(this.playbackActions="settings,slider,reset,play,fastforward,next,loop".split(","));this.control||(this.control=this.buildTimeManager());this.control.events.on({play:function(){this.playing=true},stop:function(){this.playing=
  false},scope:this});this.availableTools=Ext.applyIf(this.availableTools||{},this.getAvailableTools());Ext.applyIf(this,{defaults:{xtype:"button",flex:1,scale:"small"},items:this.buildPlaybackItems(),border:!1,frame:!1,unstyled:!0,shadow:!1,timeDisplayConfig:{xtype:"tip",format:this.timeFormat,height:"auto",closeable:!1,title:!1,width:210}});this.addEvents("timechange","rangemodified");gxp.PlaybackToolbar.superclass.initComponent.call(this)},destroy:function(){this.control&&!this.initialConfig.control&&
  (this.control.map&&this.control.map.removeControl(this.control),this.control.destroy(),this.control=null);gxp.PlaybackToolbar.superclass.destroy.call(this)},setTime:function(a){var b=a.getTime();if(b<this.slider.minValue||b>this.slider.maxValue)return!1;this.control.setTime(a);return!0},setTimeFormat:function(a){this.timeFormat=a;this.slider.setTimeFormat(a)},setPlaybackMode:function(a){this.playbackMode=a;this.slider.setPlaybackMode(a)},buildPlaybackItems:function(){for(var a=this.playbackActions,
  b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=this.availableTools[e];f?b.push(f):-1<["|"," ","->"].indexOf(e)&&b.push(e)}return b},getAvailableTools:function(){return{slider:{xtype:"gxp_timeslider",ref:"slider",timeManager:this.control,playbackMode:this.playbackMode},reset:{iconCls:"gxp-icon-reset",ref:"btnReset",handler:this.control.reset,scope:this.control,tooltip:this.resetTooltip,menuText:this.resetLabel,text:this.labelButtons?this.resetLabel:!1},pause:{iconCls:"gxp-icon-pause",ref:"btnPause",handler:this.control.stop,
  scope:this.control,tooltip:this.stopTooltip,menuText:this.stopLabel,text:this.labelButtons?this.stopLabel:!1,toggleGroup:"timecontrol",enableToggle:!0,allowDepress:!1},play:{iconCls:"gxp-icon-play",ref:"btnPlay",toggleHandler:this.toggleAnimation,scope:this,toggleGroup:"timecontrol",enableToggle:!0,allowDepress:!0,tooltip:this.playTooltip,menuText:this.playLabel,text:this.labelButtons?this.playLabel:!1},next:{iconCls:"gxp-icon-next",ref:"btnNext",handler:function(){this.stop();this.tick()},scope:this.control,
  tooltip:this.nextTooltip,menuText:this.nextLabel,text:this.labelButtons?this.nextLabel:!1},end:{iconCls:"gxp-icon-last",ref:"btnEnd",handler:this.forwardToEnd,scope:this,tooltip:this.endTooltip,menuText:this.endLabel,text:this.labelButtons?this.endLabel:!1},loop:{iconCls:"gxp-icon-loop",ref:"btnLoop",tooltip:this.loopTooltip,enableToggle:!0,allowDepress:!0,pressed:this.looped,toggleHandler:this.toggleLoopMode,scope:this,menuText:this.loopLabel,text:this.labelButtons?this.loopLabel:!1},fastforward:{iconCls:"gxp-icon-ffwd",
  ref:"btnFastforward",tooltip:this.fastforwardTooltip,enableToggle:!0,toggleGroup:"fastforward",toggleHandler:this.toggleDoubleSpeed,scope:this,disabled:!0,menuText:this.fastforwardLabel,text:this.labelButtons?this.fastforwardLabel:!1},settings:{iconCls:"gxp-icon-settings",ref:"btnSettings",scope:this,handler:this.toggleOptionsWindow,enableToggle:!1,tooltip:this.settingsTooltip,menuText:this.settingsLabel,text:this.labelButtons?this.settingsLabel:!1}}},buildTimeManager:function(){this.controlConfig||
  (this.controlConfig={});if(this.controlConfig.range&&this.controlConfig.range.length)for(var a=0;a<this.controlConfig.range.length;a++){var b=this.controlConfig.range[a];-1<b.indexOf("T")&&-1==b.indexOf("Z")&&(b=b.substring(0,b.indexOf("T")));this.controlConfig.range[a]=b}if(this.controlConfig.timeAgents)for(a=0;a<this.controlConfig.timeAgents.length;a++){var b=this.controlConfig.timeAgents[a],c=b.type,d=[];Ext.each(b.layers,function(a){var b=app.mapPanel.layers.findBy(function(b){return b.json&&
  b.json.source==a.source&&b.json.title==a.title&&b.json.name==a.name&&(b.json.styles==a.styles||!1==!!b.json.styles&&!1==!!a.styles)});-1<b&&d.push(app.mapPanel.layers.getAt(b).getLayer())});b.layers=d;delete b.type;b=c?new OpenLayers.TimeAgent[c](b):new OpenLayers.TimeAgent(b);this.controlConfig.timeAgents[a]=b}else"ranged"==this.playbackMode?Ext.apply(this.controlConfig,{agentOptions:{WMS:{rangeMode:"range",rangeInterval:this.rangedPlayInterval},Vector:{rangeMode:"range",rangeInterval:this.rangedPlayInterval}}}):
  "cumulative"==this.playbackMode&&Ext.apply(this.controlConfig,{agentOptions:{WMS:{rangeMode:"cumulative"},Vector:{rangeMode:"cumulative"}}});a=this.control=new OpenLayers.Control.TimeManager(this.controlConfig);a.loop=this.looped;this.mapPanel.map.addControl(a);a.layers&&this.fireEvent("rangemodified",this,a.range);return a},forwardToEnd:function(){var a=this.control;a.setTime(new Date(a.range[0>a.step?0:1].getTime()))},toggleAnimation:function(a,b){!a.bound&&b&&(this.control.events.on({stop:function(b){a.toggle(!1);
  b.rangeExceeded&&(this._resetOnPlay=!0)},play:function(){a.toggle(!0);this._resetOnPlay&&(this.reset(),delete this._resetOnPlay)}}),a.bound=!0);b?(this.control.timer||this.control.play(),a.btnEl.removeClass("gxp-icon-play"),a.btnEl.addClass("gxp-icon-pause"),a.setTooltip(this.pauseTooltip)):(this.control.timer&&this.control.stop(),a.btnEl.addClass("gxp-icon-play"),a.btnEl.removeClass("gxp-icon-pause"),a.setTooltip(this.playTooltip));a.el.removeClass("x-btn-pressed");a.refOwner.btnFastforward.setDisabled(!b);
  this.labelButtons&&a.text&&a.setText(b?this.pauseLabel:this.playLabel)},toggleLoopMode:function(a,b){this.control.loop=b;a.setTooltip(b?this.normalTooltip:this.loopTooltip);this.labelButtons&&a.text&&a.setText(b?this.normalLabel:this.loopLabel)},toggleDoubleSpeed:function(a,b){this.control.setFrameRate(this.control.frameRate*(b?2:0.5));a.setTooltip(b?this.normalTooltip:this.fastforwardTooltip)},toggleOptionsWindow:function(a,b){b&&this.optionsWindow.hidden?(this.optionsWindow.optionsPanel.timeManager||
  (this.optionsWindow.optionsPanel.timeManager=this.control,this.optionsWindow.optionsPanel.playbackToolbar=this),this.optionsWindow.show()):!b&&!this.optionsWindow.hidden&&this.optionsWindow.hide()}});gxp.PlaybackToolbar.guessTimeFormat=function(a){if(a){var b=this.timeFormat;switch(gxp.PlaybackToolbar.smartIntervalFormat(a).units){case "Minutes":b="l, F d, Y g:i A";break;case "Hours":b="l, F d, Y g A";break;case "Days":b="l, F d, Y";break;case "Months":b="F, Y";break;case "Years":b="Y"}return b}};
  gxp.PlaybackToolbar.smartIntervalFormat=function(a){var b;b=Math.abs(a);5E3>b?(b="Seconds",a=Math.round(a/100)/10):35E5>b?(b="Minutes",a=Math.round(a/600)/10):828E5>b?(b="Hours",a=Math.round(a/36E4)/10):25E8>b?(b="Days",a=Math.round(a/864E4)/10):311E8>b?(b="Months",a=Math.round(a/2628E5)/10):(b="Years",a=Math.round(a/31536E5)/10);return{units:b,value:a}};Ext.reg("gxp_playbacktoolbar",gxp.PlaybackToolbar);Ext.namespace("gxp.plugins");
  gxp.plugins.FeatureManager=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_featuremanager",maxFeatures:100,paging:!0,pagingType:null,autoZoomPage:!1,autoSetLayer:!0,autoLoadFeatures:!1,layerRecord:null,featureStore:null,hitCountProtocol:null,featureLayer:null,schema:null,geometryType:null,toolsShowingLayer:null,style:null,pages:null,page:null,numberOfFeatures:null,numPages:null,pageIndex:null,constructor:function(a){this.addEvents("beforequery","query","beforelayerchange","layerchange","beforesetpage","setpage",
  "beforeclearfeatures","clearfeatures","beforesave","exception");a&&!a.pagingType&&(this.pagingType=gxp.plugins.FeatureManager.QUADTREE_PAGING);a&&a.layer&&(this.autoSetLayer=!1);gxp.plugins.FeatureManager.superclass.constructor.apply(this,arguments)},init:function(a){gxp.plugins.FeatureManager.superclass.init.apply(this,arguments);this.toolsShowingLayer={};this.style={all:new OpenLayers.Style(null,{rules:[new OpenLayers.Rule({symbolizer:this.initialConfig.symbolizer||{Point:{pointRadius:4,graphicName:"square",
  fillColor:"white",fillOpacity:1,strokeWidth:1,strokeOpacity:1,strokeColor:"#333333"},Line:{strokeWidth:4,strokeOpacity:1,strokeColor:"#ff9933"},Polygon:{strokeWidth:2,strokeOpacity:1,strokeColor:"#ff6633",fillColor:"white",fillOpacity:0.3}}})]}),selected:new OpenLayers.Style(null,{rules:[new OpenLayers.Rule({symbolizer:{display:"none"}})]})};this.featureLayer=new OpenLayers.Layer.Vector(this.id,{displayInLayerSwitcher:!1,visibility:!1,styleMap:new OpenLayers.StyleMap({select:OpenLayers.Util.extend({display:""},
  OpenLayers.Feature.Vector.style.select),vertex:this.style.all},{extendDefault:!1})});this.target.on({ready:function(){this.target.mapPanel.map.addLayer(this.featureLayer)},scope:this});this.on({beforedestroy:function(){this.target.mapPanel.map.removeLayer(this.featureLayer)},scope:this})},activate:function(){if(gxp.plugins.FeatureManager.superclass.activate.apply(this,arguments)){if(this.autoSetLayer)this.target.on("beforelayerselectionchange",this.setLayer,this);this.layer&&this.target.createLayerRecord(Ext.apply({},
  this.layer),this.setLayer,this);this.on("layerchange",this.setSchema,this);return!0}},deactivate:function(){if(gxp.plugins.FeatureManager.superclass.deactivate.apply(this,arguments))return this.autoSetLayer&&this.target.un("beforelayerselectionchange",this.setLayer,this),this.un("layerchange",this.setSchema,this),this.setLayer(),!0},getPageExtent:function(){return this.pagingType===gxp.plugins.FeatureManager.QUADTREE_PAGING?this.page.extent:this.featureStore.layer.getDataExtent()},setLayer:function(a){var b=
  this.fireEvent("beforelayerchange",this,a);if(!1!==b&&(a&&(this.featureLayer.projection=a.getLayer().projection),a!==this.layerRecord))this.clearFeatureStore(),(this.layerRecord=a)?!0===this.autoLoadFeatures?this.loadFeatures():this.setFeatureStore():this.fireEvent("layerchange",this,null);return b},setSchema:function(a,b,c){this.schema=c},showLayer:function(a,b){this.toolsShowingLayer[a]=b||"all";this.setLayerDisplay()},hideLayer:function(a){delete this.toolsShowingLayer[a];this.setLayerDisplay()},
  setLayerDisplay:function(){var a=this.visible(),b=this.target.mapPanel.map;a?(a=this.style[a],a!==this.featureLayer.styleMap.styles["default"]&&(this.featureLayer.styleMap.styles["default"]=a,this.featureLayer.redraw()),this.featureLayer.setVisibility(!0),b.events.on({addlayer:this.raiseLayer,scope:this})):this.featureLayer.map&&(this.featureLayer.setVisibility(!1),b.events.un({addlayer:this.raiseLayer,scope:this}))},visible:function(){var a=!1,b;for(b in this.toolsShowingLayer)"all"!=a&&(a=this.toolsShowingLayer[b]);
  return a},raiseLayer:function(){var a=this.featureLayer&&this.featureLayer.map;a&&a.setLayerIndex(this.featureLayer,a.layers.length)},loadFeatures:function(a,b,c){if(!1!==this.fireEvent("beforequery",this,a,b,c)){this.filter=a;this.pages=null;if(b){var d=this;d._activeQuery&&d.un("query",d._activeQuery);this.on("query",d._activeQuery=function(a,f){delete d._activeQuery;this.un("query",arguments.callee,this);f.getCount();0==f.getCount()?b.call(c,[]):this.featureLayer.events.register("featuresadded",
  this,function(a){this.featureLayer.events.unregister("featuresadded",this,arguments.callee);b.call(c,a.features)})},this,{single:!0})}this.featureStore?(this.featureStore.setOgcFilter(a),this.paging?this.setPage():this.featureStore.load()):(this.paging&&this.on("layerchange",function(a,b,c){c&&(this.un("layerchange",arguments.callee,this),this.setPage())},this),this.setFeatureStore(a,!this.paging))}},clearFeatures:function(){var a=this.featureStore;a&&!1!==this.fireEvent("beforeclearfeatures",this)&&
  (a.removeAll(),this.fireEvent("clearfeatures",this),a=a.proxy,a.abortRequest(),a.protocol.response&&a.protocol.response.abort())},getProjection:function(a){var b=this.target.mapPanel.map.getProjectionObject();(a=a.getLayer().projection)&&a.equals(b)&&(b=a);return b},setFeatureStore:function(a,b){var c=this.layerRecord,d=this.target.getSource(c);d&&d instanceof gxp.plugins.WMSSource?d.getSchema(c,function(d){if(!1===d)this.clearFeatureStore();else{var f=[],g,h=/gml:((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry)).*/,
  j={"xsd:boolean":"boolean","xsd:int":"int","xsd:integer":"int","xsd:short":"int","xsd:long":"int","xsd:date":"date","xsd:string":"string","xsd:float":"float","xsd:double":"float"};d.each(function(a){var b=h.exec(a.get("type"));b?(g=a.get("name"),this.geometryType=b[1]):(b=j[a.get("type")],a={name:a.get("name"),type:j[b]},"date"==b&&(a.dateFormat="Y-m-d\\Z"),f.push(a))},this);var k={srsName:this.getProjection(c).getCode(),url:d.url,featureType:d.reader.raw.featureTypes[0].typeName,featureNS:d.reader.raw.targetNamespace,
  geometryName:g};this.hitCountProtocol=new OpenLayers.Protocol.WFS(Ext.apply({version:"1.1.0",readOptions:{output:"object"},resultType:"hits",filter:a},k));this.featureStore=new gxp.data.WFSFeatureStore(Ext.apply({fields:f,proxy:{protocol:{outputFormat:this.format,multi:this.multi}},maxFeatures:this.maxFeatures,layer:this.featureLayer,ogcFilter:a,autoLoad:b,autoSave:!1,listeners:{beforewrite:function(a,b,c,d){this.fireEvent("beforesave",this,a,d.params)},write:function(){this.redrawMatchingLayers(c)},
  load:function(a){this.fireEvent("query",this,a,this.filter)},scope:this}},k))}this.fireEvent("layerchange",this,c,d)},this):(this.clearFeatureStore(),this.fireEvent("layerchange",this,c,!1))},redrawMatchingLayers:function(a){var b=a.get("name"),c=a.get("source");this.target.mapPanel.layers.each(function(a){a.get("source")===c&&a.get("name")===b&&a.getLayer().redraw(!0)})},clearFeatureStore:function(){this.featureStore&&(this.featureStore.removeAll(),this.featureStore.unbind(),this.featureStore.destroy(),
  this.geometryType=this.featureStore=null)},processPage:function(a,b,c,d){var b=b||{},e=b.lonLat?null:b.index,f=b.next,g=this.pages,h=this.pages.indexOf(a);this.setPageFilter(a);var j=f?h==(g.indexOf(f)||g.length)-1:!0,k=b.lonLat?a.extent.containsLonLat(b.lonLat):!0;k&&a.numFeatures&&a.numFeatures<=this.maxFeatures?c.call(this,a):k&&(h==e||j)&&this.hitCountProtocol.read({callback:function(h){var j=e,k=b.lonLat;f&&(j=(g.indexOf(f)||g.length)-1);!j&&k&&a.extent.containsLonLat(k)&&(j=g.indexOf(a));a.numFeatures=
  h.numberOfFeatures;this.page||(a.numFeatures>this.maxFeatures?this.createLeaf(a,Ext.applyIf({index:j,next:f},b),c,d):0==a.numFeatures&&1<g.length?(g.remove(a),!1===b.allowEmpty&&this.setPage({index:e%this.pages.length,allowEmpty:!1})):this.pages.indexOf(a)==j&&c.call(this,a))},scope:this})},createLeaf:function(a,b,c,d){b=b||{};this.layerRecord.getLayer();var e=this.pages.indexOf(a);this.pages.remove(a);for(var f=a.extent,g=f.getCenterLonLat(),a=[f.left,g.lon,f.left,g.lon],h=[g.lat,g.lat,f.bottom,
  f.bottom],j=[g.lon,f.right,g.lon,f.right],f=[f.top,f.top,g.lat,g.lat],k,g=3;0<=g;--g)k={extent:new OpenLayers.Bounds(a[g],h[g],j[g],f[g])},this.pages.splice(e,0,k),this.processPage(k,b,c,d)},getPagingExtent:function(a){var b=this.layerRecord.getLayer(),c=this.getSpatialFilter();if((a=c?c.value:this.target.mapPanel.map[a]())&&b.maxExtent&&a.containsBounds(b.maxExtent))a=b.maxExtent;return a},getSpatialFilter:function(){var a;if(this.filter instanceof OpenLayers.Filter.Spatial&&this.filter.type===OpenLayers.Filter.Spatial.BBOX)a=
  this.filter;else if(this.filter instanceof OpenLayers.Filter.Logical&&this.filter.type===OpenLayers.Filter.Logical.AND)for(var b,c=this.filter.filters.length-1;0<=c;--c)if(b=this.filter.filters[c],b instanceof OpenLayers.Filter.Spatial&&b.type===OpenLayers.Filter.Spatial.BBOX){a=b;break}return a},setPageFilter:function(a){a.extent?(a=new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,property:this.featureStore.geometryName,value:a.extent}),a=this.filter?new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,
  filters:[this.filter,a]}):a):a=this.filter;this.featureStore.setOgcFilter(a);this.hitCountProtocol.filter=a;return this.hitCountProtocol.options.filter=a},nextPage:function(a,b){var c;this.pagingType===gxp.plugins.FeatureManager.QUADTREE_PAGING?(c=this.page,this.page=null,c=(this.pages.indexOf(c)+1)%this.pages.length):c=this.pageIndex+1%this.numPages;this.setPage({index:c,allowEmpty:!1},a,b)},previousPage:function(a){var b;this.pagingType===gxp.plugins.FeatureManager.QUADTREE_PAGING?(b=this.pages.indexOf(this.page)-
  1,0>b&&(b=this.pages.length-1)):(b=this.pageIndex-1,0>b&&(b=this.numPages-1));this.setPage({index:b,allowEmpty:!1,next:this.page},a)},setPage:function(a,b,c){if(this.pagingType===gxp.plugins.FeatureManager.QUADTREE_PAGING)if(this.filter instanceof OpenLayers.Filter.FeatureId)this.featureStore.load({callback:function(){b&&b.call(c)}});else{if(!1!==this.fireEvent("beforesetpage",this,a,b,c)){if(!a){var d=this.getPagingExtent("getExtent"),d=new OpenLayers.LonLat(d.left,d.top),e=this.target.mapPanel.map.getMaxExtent();
  e.containsLonLat(d,!0)||(d=new OpenLayers.LonLat(e.left,e.top));a={lonLat:d,allowEmpty:!1}}a.index=a.index||0;"last"==a.index&&(a.index=this.pages.length-1,a.next=this.pages[0]);this.page=null;if(this.pages){if(a.lonLat)for(d=this.pages.length-1;0<=d;--d)if(this.pages[d].extent.containsLonLat(a.lonLat)){a.index=d;break}}else this.layerRecord.getLayer(),this.pages=[{extent:this.getPagingExtent("getMaxExtent")}],a.index=0;this.processPage(this.pages[a.index],a,function(d){var e=this.target.mapPanel.map;
  this.page=d;this.setPageFilter(d);this.autoZoomPage&&!e.getExtent().containsLonLat(d.extent.getCenterLonLat())&&e.zoomToExtent(d.extent);e=this.pages.indexOf(this.page);this.fireEvent("setpage",this,a,b,c,e,this.pages.length);this.featureStore.load({callback:function(){b&&b.call(c,d)}})},this)}}else!1!==this.fireEvent("beforesetpage",this,a,b,c)&&(a?null!=a.index&&(this.pageIndex="last"===a.index?this.numPages-1:"first"===a.index?0:a.index,d=this.pageIndex*this.maxFeatures,this.fireEvent("setpage",
  this,a,b,c,this.pageIndex,this.numPages),this.featureStore.load({startIndex:d,callback:function(){b&&b.call(c)}})):this.hitCountProtocol.read({filter:this.filter,callback:function(d){this.numberOfFeatures=d.numberOfFeatures;this.numPages=Math.ceil(this.numberOfFeatures/this.maxFeatures);this.pageIndex=0;this.fireEvent("setpage",this,a,b,c,this.pageIndex,this.numPages);this.featureStore.load({output:"object",callback:function(){b&&b.call(c)}})},scope:this}))}});
  gxp.plugins.FeatureManager.QUADTREE_PAGING=0;gxp.plugins.FeatureManager.WFS_PAGING=1;Ext.preg(gxp.plugins.FeatureManager.prototype.ptype,gxp.plugins.FeatureManager);Ext.namespace("gxp.plugins");
  gxp.plugins.ZoomToSelectedFeatures=Ext.extend(gxp.plugins.ZoomToExtent,{ptype:"gxp_zoomtoselectedfeatures",menuText:"Zoom to selected features",tooltip:"Zoom to selected features",closest:!1,iconCls:"gxp-icon-zoom-to",extent:function(){for(var a,b,c=this.target.tools[this.featureManager].featureLayer.selectedFeatures,d=c.length-1;0<=d;--d)if(b=c[d].geometry)b=b.getBounds(),a?a.extend(b):a=b.clone();return a},addActions:function(){var a=gxp.plugins.ZoomToSelectedFeatures.superclass.addActions.apply(this,
  arguments);a[0].disable();var b=this.target.tools[this.featureManager].featureLayer;b.events.on({featureselected:function(b){a[0].isDisabled()&&null!==b.feature.geometry&&a[0].enable()},featureunselected:function(){0===b.selectedFeatures.length&&a[0].disable()}});return a}});Ext.preg(gxp.plugins.ZoomToSelectedFeatures.prototype.ptype,gxp.plugins.ZoomToSelectedFeatures);Ext.namespace("gxp.plugins");
  gxp.plugins.ClickableFeatures=Ext.extend(gxp.plugins.Tool,{featureManager:null,autoLoadFeature:!1,autoLoadedFeature:null,toleranceParameters:["BUFFER","RADIUS"],constructor:function(a){a&&"autoLoadFeatures"in a&&(a.autoLoadFeature=a.autoLoadFeatures,delete a.autoLoadFeatures,window.console&&console.warn("Deprecated config option 'autoLoadFeatures' for ptype: '"+a.ptype+"'. Use 'autoLoadFeature' instead."));gxp.plugins.ClickableFeatures.superclass.constructor.apply(this,[a])},noFeatureClick:function(a){this.selectControl||
  (this.selectControl=new OpenLayers.Control.SelectFeature(this.target.tools[this.featureManager].featureLayer,this.initialConfig.controlOptions));var b=this.target.mapPanel.map.getLonLatFromPixel(a.xy),c=this.target.tools[this.featureManager],d=c.page;if(!("all"==c.visible()&&c.paging&&d&&d.extent.containsLonLat(b))&&(b=c.layerRecord&&c.layerRecord.getLayer())){var e=this.target.mapPanel.map,d=e.getSize(),d=Ext.applyIf({REQUEST:"GetFeatureInfo",BBOX:e.getExtent().toBBOX(),WIDTH:d.w,HEIGHT:d.h,X:parseInt(a.xy.x),
  Y:parseInt(a.xy.y),QUERY_LAYERS:b.params.LAYERS,INFO_FORMAT:"application/vnd.ogc.gml",EXCEPTIONS:"application/vnd.ogc.se_xml",FEATURE_COUNT:1},b.params);if("number"===typeof this.tolerance)for(var f=0,g=this.toleranceParameters.length;f<g;++f)d[this.toleranceParameters[f]]=this.tolerance;e=e.getProjectionObject();(f=b.projection)&&f.equals(e)&&(e=f);1.3<=parseFloat(b.params.VERSION)?d.CRS=e.getCode():d.SRS=e.getCode();new GeoExt.data.FeatureStore({fields:{},proxy:new GeoExt.data.ProtocolProxy({protocol:new OpenLayers.Protocol.HTTP({url:"string"===
  typeof b.url?b.url:b.url[0],params:d,format:new OpenLayers.Format.WMSGetFeatureInfo})}),autoLoad:!0,listeners:{load:function(b,d){if(d.length>0){var e=d[0].get("fid"),f=new OpenLayers.Filter.FeatureId({fids:[e]}),g=function(){c.loadFeatures(f,function(a){if(a.length){this.autoLoadedFeature=a[0];this.select(a[0])}},this)}.createDelegate(this),m=c.featureLayer.getFeatureByFid(e);if(m)this.select(m);else if(c.paging&&c.pagingType===gxp.plugins.FeatureManager.QUADTREE_PAGING){m=this.target.mapPanel.map.getLonLatFromPixel(a.xy);
  c.setPage({lonLat:m},function(){var a=c.featureLayer.getFeatureByFid(e);a?this.select(a):this.autoLoadFeature===true&&g()},this)}else g()}},scope:this}})}},select:function(a){this.selectControl.unselectAll();this.selectControl.select(a)}});Ext.namespace("gxp.plugins");
  gxp.plugins.FeatureGrid=Ext.extend(gxp.plugins.ClickableFeatures,{ptype:"gxp_featuregrid",schema:null,showTotalResults:!1,alwaysDisplayOnMap:!1,displayMode:"all",autoExpand:!1,autoCollapse:!1,selectOnMap:!1,displayFeatureText:"Display on map",firstPageTip:"First page",previousPageTip:"Previous page",zoomPageExtentTip:"Zoom to page extent",nextPageTip:"Next page",lastPageTip:"Last page",totalMsg:"Total: {0} records",displayTotalResults:function(){var a=this.target.tools[this.featureManager];!0===this.showTotalResults&&
  null!==a.numberOfFeatures&&this.displayItem.setText(String.format(this.totalMsg,a.numberOfFeatures))},addOutput:function(a){function b(){var a=c.schema,b=["feature","state","fid"];a&&a.each(function(a){0==a.get("type").indexOf("gml:")&&b.push(a.get("name"))});f.ignoreFields=b;f.setStore(c.featureStore,a)}var c=this.target.tools[this.featureManager],d=this.target.mapPanel.map,e;this.selectControl=new OpenLayers.Control.SelectFeature(c.featureLayer,this.initialConfig.controlOptions);if(this.selectOnMap){if(c.paging)this.selectControl.events.on({activate:function(){d.events.register("click",
  this,this.noFeatureClick)},deactivate:function(){d.events.unregister("click",this,this.noFeatureClick)},scope:this});d.addControl(this.selectControl);e={selectControl:this.selectControl}}else e={selectControl:this.selectControl,singleSelect:!1,autoActivateControl:!1,listeners:{beforerowselect:function(){if(this.selectControl.active||c.featureStore.getModifiedRecords().length)return!1},scope:this}};this.displayItem=new Ext.Toolbar.TextItem({});var a=Ext.apply({xtype:"gxp_featuregrid",sm:new GeoExt.grid.FeatureSelectionModel(e),
  autoScroll:!0,bbar:(c.paging?[{iconCls:"x-tbar-page-first",ref:"../firstPageButton",tooltip:this.firstPageTip,disabled:!0,handler:function(){c.setPage({index:0})}},{iconCls:"x-tbar-page-prev",ref:"../prevPageButton",tooltip:this.previousPageTip,disabled:!0,handler:function(){c.previousPage()}},{iconCls:"gxp-icon-zoom-to",ref:"../zoomToPageButton",tooltip:this.zoomPageExtentTip,disabled:!0,hidden:c.autoZoomPage,handler:function(){var a=c.getPageExtent();null!==a&&d.zoomToExtent(a)}},{iconCls:"x-tbar-page-next",
  ref:"../nextPageButton",tooltip:this.nextPageTip,disabled:!0,handler:function(){c.nextPage()}},{iconCls:"x-tbar-page-last",ref:"../lastPageButton",tooltip:this.lastPageTip,disabled:!0,handler:function(){c.setPage({index:"last"})}},{xtype:"tbspacer",width:10},this.displayItem]:[]).concat(["->"].concat(!this.alwaysDisplayOnMap?[{text:this.displayFeatureText,enableToggle:!0,toggleHandler:function(a,b){this.selectOnMap&&this.selectControl[b?"activate":"deactivate"]();c[b?"showLayer":"hideLayer"](this.id,
  this.displayMode)},scope:this}]:[])),listeners:{added:function(a,b){function d(){this.displayTotalResults();this.selectOnMap&&this.selectControl.deactivate();this.autoCollapse&&"function"==typeof b.collapse&&b.collapse()}c.on({query:function(a,c){c&&c.getCount()?(this.displayTotalResults(),this.selectOnMap&&this.selectControl.activate(),this.autoExpand&&"function"==typeof b.expand&&b.expand()):d.call(this)},layerchange:d,clearfeatures:d,scope:this})},contextmenu:function(a){if(0<f.contextMenu.items.getCount()){var b=
  f.getView().findRowIndex(a.getTarget());!1!==b&&(f.getSelectionModel().selectRow(b),f.contextMenu.showAt(a.getXY()),a.stopEvent())}},scope:this},contextMenu:new Ext.menu.Menu({items:[]})},a||{}),f=gxp.plugins.FeatureGrid.superclass.addOutput.call(this,a);(this.alwaysDisplayOnMap||this.selectOnMap)&&c.showLayer(this.id,this.displayMode);c.paging&&c.on({beforesetpage:function(){f.zoomToPageButton.disable()},setpage:function(a,b,c,d,e,n){a=0<n;f.zoomToPageButton.setDisabled(!a);b=a&&0!==e;f.firstPageButton.setDisabled(!b);
  f.prevPageButton.setDisabled(!b);e=a&&e!==n-1;f.lastPageButton.setDisabled(!e);f.nextPageButton.setDisabled(!e)},scope:this});c.featureStore&&b.call(this);c.on("layerchange",b,this);return f}});Ext.preg(gxp.plugins.FeatureGrid.prototype.ptype,gxp.plugins.FeatureGrid);Ext.namespace("gxp");
  gxp.EmbedMapDialog=Ext.extend(Ext.Container,{url:null,url:null,publishMessage:"Your map is ready to be published to the web! Simply copy the following HTML to embed the map in your website:",heightLabel:"Height",widthLabel:"Width",mapSizeLabel:"Map Size",miniSizeLabel:"Mini",smallSizeLabel:"Small",premiumSizeLabel:"Premium",largeSizeLabel:"Large",snippetArea:null,heightField:null,widthField:null,initComponent:function(){Ext.apply(this,this.getConfig());gxp.EmbedMapDialog.superclass.initComponent.call(this)},
  getIframeHTML:function(){return this.snippetArea.getValue()},updateSnippet:function(){this.snippetArea.setValue('<iframe style="border: none;" height="'+this.heightField.getValue()+'" width="'+this.widthField.getValue()+'" src="'+gxp.util.getAbsoluteUrl(this.url)+'"></iframe>');!0===this.snippetArea.isVisible()&&this.snippetArea.focus(!0,100)},getConfig:function(){this.snippetArea=new Ext.form.TextArea({height:70,selectOnFocus:!0,readOnly:!0});var a={change:this.updateSnippet,specialkey:function(a,
  c){c.getKey()==c.ENTER&&this.updateSnippet()},scope:this};this.heightField=new Ext.form.NumberField({width:50,value:400,listeners:a});this.widthField=new Ext.form.NumberField({width:50,value:600,listeners:a});return{border:!1,defaults:{border:!1,cls:"gxp-export-section",xtype:"container",layout:"fit"},items:[{items:[new Ext.Container({layout:"column",defaults:{border:!1,xtype:"box"},items:[{autoEl:{cls:"gxp-field-label",html:this.mapSizeLabel}},new Ext.form.ComboBox({editable:!1,width:75,store:new Ext.data.SimpleStore({fields:["name",
  "height","width"],data:[[this.miniSizeLabel,100,100],[this.smallSizeLabel,200,300],[this.largeSizeLabel,400,600],[this.premiumSizeLabel,600,800]]}),triggerAction:"all",displayField:"name",value:this.largeSizeLabel,mode:"local",listeners:{select:function(a,c){this.widthField.setValue(c.get("width"));this.heightField.setValue(c.get("height"));this.updateSnippet()},scope:this}}),{autoEl:{cls:"gxp-field-label",html:this.heightLabel}},this.heightField,{autoEl:{cls:"gxp-field-label",html:this.widthLabel}},
  this.widthField]})]},{xtype:"box",autoEl:{tag:"p",html:this.publishMessage}},{items:[this.snippetArea]}],listeners:{afterrender:this.updateSnippet,scope:this}}}});Ext.reg("gxp_embedmapdialog",gxp.EmbedMapDialog);Ext.namespace("gxp.plugins");
  gxp.plugins.LayerManager=Ext.extend(gxp.plugins.LayerTree,{ptype:"gxp_layermanager",baseNodeText:"Base Maps",createOutputConfig:function(){var a=gxp.plugins.LayerManager.superclass.createOutputConfig.apply(this,arguments);Ext.applyIf(a,Ext.apply({cls:"gxp-layermanager-tree",lines:!1,useArrows:!0,plugins:[{ptype:"gx_treenodecomponent"}]},this.treeConfig));return a},configureLayerNode:function(a,b){gxp.plugins.LayerManager.superclass.configureLayerNode.apply(this,arguments);b.layer instanceof OpenLayers.Layer.WMS&&
  (b.expanded=!0,b.allowDrop=!1,b.children=[{nodeType:"node",cls:"legendnode",uiProvider:Ext.extend(Ext.tree.TreeNodeUI,new GeoExt.tree.TreeNodeUIEventMixin),component:{xtype:"gx_wmslegend",baseParams:{format:"image/png",legend_options:"fontAntiAliasing:true;fontSize:11;fontName:Arial"},layerRecord:this.target.mapPanel.layers.getByLayer(b.layer),showTitle:!1,cls:"legend"},listeners:{beforeclick:function(){this.parentNode.select();return!1}}}])}});Ext.preg(gxp.plugins.LayerManager.prototype.ptype,gxp.plugins.LayerManager);
  Ext.namespace("gxp.plugins");
  gxp.plugins.Zoom=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_zoom",zoomInMenuText:"Zoom In",zoomOutMenuText:"Zoom Out",zoomInTooltip:"Zoom In",zoomOutTooltip:"Zoom Out",constructor:function(a){gxp.plugins.Zoom.superclass.constructor.apply(this,arguments)},addActions:function(){return gxp.plugins.Zoom.superclass.addActions.apply(this,[[{menuText:this.zoomInMenuText,iconCls:"gxp-icon-zoom-in",tooltip:this.zoomInTooltip,handler:function(){this.target.mapPanel.map.zoomIn()},scope:this},{menuText:this.zoomOutMenuText,
  iconCls:"gxp-icon-zoom-out",tooltip:this.zoomOutTooltip,handler:function(){this.target.mapPanel.map.zoomOut()},scope:this}]])}});Ext.preg(gxp.plugins.Zoom.prototype.ptype,gxp.plugins.Zoom);Ext.namespace("gxp.form");
  gxp.form.FontComboBox=Ext.extend(Ext.form.ComboBox,{fonts:"Serif,SansSerif,Arial,Courier New,Tahoma,Times New Roman,Verdana".split(","),defaultFont:"Serif",allowBlank:!1,mode:"local",triggerAction:"all",editable:!1,initComponent:function(){var a=this.fonts||gxp.form.FontComboBox.prototype.fonts,b=this.defaultFont;-1===a.indexOf(this.defaultFont)&&(b=a[0]);a={displayField:"field1",valueField:"field1",store:a,value:b,tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-family: {field1};">{field1}</span></div></tpl>')};
  Ext.applyIf(this,a);gxp.form.FontComboBox.superclass.initComponent.call(this)}});Ext.reg("gxp_fontcombo",gxp.form.FontComboBox);Ext.namespace("gxp");
  gxp.WMSLayerPanel=Ext.extend(Ext.TabPanel,{layerRecord:null,source:null,styling:!0,sameOriginStyling:!0,rasterStyling:!1,transparent:null,editableStyles:!1,activeTab:0,border:!1,imageFormats:/png|gif|jpe?g/i,aboutText:"About",titleText:"Title",nameText:"Name",descriptionText:"Description",displayText:"Display",opacityText:"Opacity",formatText:"Format",infoFormatText:"Info format",infoFormatEmptyText:"Select a format",transparentText:"Transparent",cacheText:"Cache",cacheFieldText:"Use cached version",
  stylesText:"Styles",initComponent:function(){this.addEvents("change");this.items=[this.createAboutPanel(),this.createDisplayPanel()];null!=this.layerRecord.get("layer").params.TILED&&this.items.push(this.createCachePanel());if(this.styling&&gxp.WMSStylesDialog&&this.layerRecord.get("styles")){var a=this.layerRecord.get("restUrl");a||(a=(this.source||this.layerRecord.get("layer")).url.split("?").shift().replace(/\/(wms|ows)\/?$/,"/rest"));this.editableStyles=this.sameOriginStyling?"/"===a.charAt(0):
  !0;this.items.push(this.createStylesPanel(a))}gxp.WMSLayerPanel.superclass.initComponent.call(this)},createCachePanel:function(){return{title:this.cacheText,layout:"form",style:"padding: 10px",items:[{xtype:"checkbox",fieldLabel:this.cacheFieldText,checked:!0===this.layerRecord.get("layer").params.TILED,listeners:{check:function(a,b){this.layerRecord.get("layer").mergeNewParams({TILED:b});this.fireEvent("change")},scope:this}}]}},createStylesPanel:function(a){var b=gxp.WMSStylesDialog.createGeoServerStylerConfig(this.layerRecord,
  a);!0===this.rasterStyling&&b.plugins.push({ptype:"gxp_wmsrasterstylesdialog"});return Ext.apply(b,{title:this.stylesText,style:"padding: 10px",editable:!1,listeners:Ext.apply(b.listeners,{beforerender:{fn:function(b){var d=!this.editableStyles;d||("boolean"==typeof this.authorized?(b.editable=this.authorized,b.ownerCt.doLayout()):Ext.Ajax.request({method:"PUT",url:a+"/styles",callback:function(a,d,g){b.editable=405==g.status;b.ownerCt.doLayout()}}));return d},scope:this,single:!0}})})},createAboutPanel:function(){return{title:this.aboutText,
  style:{padding:"10px"},defaults:{border:!1},items:[{layout:"form",labelWidth:70,items:[{xtype:"textfield",fieldLabel:this.titleText,anchor:"99%",value:this.layerRecord.get("title"),listeners:{change:function(a){this.layerRecord.set("title",a.getValue());this.layerRecord.commit();this.fireEvent("change")},scope:this}},{xtype:"textfield",fieldLabel:this.nameText,anchor:"99%",value:this.layerRecord.get("name"),readOnly:!0}]},{layout:"form",labelAlign:"top",items:[{xtype:"textarea",fieldLabel:this.descriptionText,
  grow:!0,growMax:150,anchor:"99%",value:this.layerRecord.get("abstract"),readOnly:!0}]}]}},createDisplayPanel:function(){var a=this.layerRecord,b=a.getLayer(),c=b.opacity;null==c&&(c=1);var d=[],e=b.params.FORMAT.toLowerCase();Ext.each(a.get("formats"),function(a){this.imageFormats.test(a)&&d.push(a.toLowerCase())},this);-1===d.indexOf(e)&&d.push(e);var f=b.params.TRANSPARENT,f="true"===f||!0===f;return{title:this.displayText,style:{padding:"10px"},layout:"form",labelWidth:70,items:[{xtype:"slider",
  name:"opacity",fieldLabel:this.opacityText,value:100*c,values:[100*c],anchor:"99%",isFormField:!0,listeners:{change:function(a,c){b.setOpacity(c/100);this.fireEvent("change")},scope:this}},{xtype:"combo",fieldLabel:this.formatText,store:d,value:e,mode:"local",triggerAction:"all",editable:!1,anchor:"99%",listeners:{select:function(a){a=a.getValue();b.mergeNewParams({format:a});"image/jpeg"==a?(this.transparent=Ext.getCmp("transparent").getValue(),Ext.getCmp("transparent").setValue(!1)):null!==this.transparent&&
  (Ext.getCmp("transparent").setValue(this.transparent),this.transparent=null);Ext.getCmp("transparent").setDisabled("image/jpeg"==a);this.fireEvent("change")},scope:this}},{xtype:"combo",fieldLabel:this.infoFormatText,emptyText:this.infoFormatEmptyText,store:a.get("infoFormats"),value:a.get("infoFormat"),hidden:void 0===a.get("infoFormats"),mode:"local",triggerAction:"all",editable:!1,anchor:"99%",listeners:{select:function(b){b=b.getValue();a.set("infoFormat",b);this.fireEvent("change")}},scope:this},
  {xtype:"checkbox",id:"transparent",fieldLabel:this.transparentText,checked:f,listeners:{check:function(a,c){b.mergeNewParams({transparent:c?"true":"false"});this.fireEvent("change")},scope:this}}]}}});Ext.reg("gxp_wmslayerpanel",gxp.WMSLayerPanel);Ext.namespace("gxp");
  gxp.ScaleLimitPanel=Ext.extend(Ext.Panel,{maxScaleDenominatorLimit:1.577757414193268E9*OpenLayers.DOTS_PER_INCH/256,limitMaxScaleDenominator:!0,maxScaleDenominator:void 0,minScaleDenominatorLimit:1.577757414193268E9*Math.pow(0.5,19)*OpenLayers.DOTS_PER_INCH/256,limitMinScaleDenominator:!0,minScaleDenominator:void 0,scaleLevels:20,scaleSliderTemplate:"{scaleType} Scale 1:{scale}",modifyScaleTipContext:Ext.emptyFn,scaleFactor:null,changing:!1,border:!1,maxScaleLimitText:"Max scale limit",minScaleLimitText:"Min scale limit",
  initComponent:function(){this.layout="column";this.defaults={border:!1,bodyStyle:"margin: 0 5px;"};this.bodyStyle={padding:"5px"};this.scaleSliderTemplate=new Ext.Template(this.scaleSliderTemplate);Ext.applyIf(this,{minScaleDenominator:this.minScaleDenominatorLimit,maxScaleDenominator:this.maxScaleDenominatorLimit});this.scaleFactor=Math.pow(this.maxScaleDenominatorLimit/this.minScaleDenominatorLimit,1/(this.scaleLevels-1));this.scaleSlider=new Ext.Slider({vertical:!0,height:100,values:[0,100],listeners:{changecomplete:function(a){this.updateScaleValues(a)},
  render:function(a){a.thumbs[0].el.setVisible(this.limitMaxScaleDenominator);a.thumbs[1].el.setVisible(this.limitMinScaleDenominator);a.setDisabled(!this.limitMinScaleDenominator&&!this.limitMaxScaleDenominator)},scope:this},plugins:[new gxp.slider.Tip({getText:function(a){var b=a.slider.thumbs.indexOf(a),a={scale:""+this.sliderValuesToScale([a.value])[0],zoom:(a.value*(this.scaleLevels/100)).toFixed(1),type:0===b?"Max":"Min",scaleType:0===b?"Min":"Max"};this.modifyScaleTipContext(this,a);return this.scaleSliderTemplate.apply(a)}.createDelegate(this)})]});
  this.maxScaleDenominatorInput=new Ext.form.NumberField({allowNegative:!1,width:100,fieldLabel:"1",value:Math.round(this.maxScaleDenominator),disabled:!this.limitMaxScaleDenominator,validator:function(a){return!this.limitMinScaleDenominator||a>this.minScaleDenominator}.createDelegate(this),listeners:{valid:function(a){var a=Number(a.getValue()),b=Math.round(this.maxScaleDenominatorLimit);a<b&&a>this.minScaleDenominator&&(this.maxScaleDenominator=a,this.updateSliderValues())},change:function(a){var b=
  Number(a.getValue()),c=Math.round(this.maxScaleDenominatorLimit);b>c?a.setValue(c):b<this.minScaleDenominator?a.setValue(this.minScaleDenominator):(this.maxScaleDenominator=b,this.updateSliderValues())},scope:this}});this.minScaleDenominatorInput=new Ext.form.NumberField({allowNegative:!1,width:100,fieldLabel:"1",value:Math.round(this.minScaleDenominator),disabled:!this.limitMinScaleDenominator,validator:function(a){return!this.limitMaxScaleDenominator||a<this.maxScaleDenominator}.createDelegate(this),
  listeners:{valid:function(a){var a=Number(a.getValue()),b=Math.round(this.minScaleDenominatorLimit);a>b&&a<this.maxScaleDenominator&&(this.minScaleDenominator=a,this.updateSliderValues())},change:function(a){var b=Number(a.getValue()),c=Math.round(this.minScaleDenominatorLimit);b<c?a.setValue(c):b>this.maxScaleDenominator?a.setValue(this.maxScaleDenominator):(this.minScaleDenominator=b,this.updateSliderValues())},scope:this}});this.items=[this.scaleSlider,{xtype:"panel",layout:"form",defaults:{border:!1},
  items:[{labelWidth:90,layout:"form",width:150,items:[{xtype:"checkbox",checked:!!this.limitMinScaleDenominator,fieldLabel:this.maxScaleLimitText,listeners:{check:function(a,b){this.limitMinScaleDenominator=b;var c=this.scaleSlider;c.setValue(1,100);c.thumbs[1].el.setVisible(b);this.minScaleDenominatorInput.setDisabled(!b);this.updateScaleValues(c);c.setDisabled(!this.limitMinScaleDenominator&&!this.limitMaxScaleDenominator)},scope:this}}]},{labelWidth:10,layout:"form",items:[this.minScaleDenominatorInput]},
  {labelWidth:90,layout:"form",items:[{xtype:"checkbox",checked:!!this.limitMaxScaleDenominator,fieldLabel:this.minScaleLimitText,listeners:{check:function(a,b){this.limitMaxScaleDenominator=b;var c=this.scaleSlider;c.setValue(0,0);c.thumbs[0].el.setVisible(b);this.maxScaleDenominatorInput.setDisabled(!b);this.updateScaleValues(c);c.setDisabled(!this.limitMinScaleDenominator&&!this.limitMaxScaleDenominator)},scope:this}}]},{labelWidth:10,layout:"form",items:[this.maxScaleDenominatorInput]}]}];this.addEvents("change");
  gxp.ScaleLimitPanel.superclass.initComponent.call(this)},updateScaleValues:function(a){if(!this.changing){var b=a.getValues(),c=!1;!this.limitMaxScaleDenominator&&0<b[0]&&(b[0]=0,c=!0);!this.limitMinScaleDenominator&&100>b[1]&&(b[1]=100,c=!0);c?(a.setValue(0,b[0]),a.setValue(1,b[1])):(b=this.sliderValuesToScale(b),a=b[0],b=b[1],this.changing=!0,this.minScaleDenominatorInput.setValue(b),this.maxScaleDenominatorInput.setValue(a),this.changing=!1,this.fireEvent("change",this,this.limitMinScaleDenominator?
  b:void 0,this.limitMaxScaleDenominator?a:void 0))}},updateSliderValues:function(){if(!this.changing){var a=this.minScaleDenominator,b=this.maxScaleDenominator,c=this.scaleToSliderValues([b,a]);this.changing=!0;this.scaleSlider.setValue(0,c[0]);this.scaleSlider.setValue(1,c[1]);this.changing=!1;this.fireEvent("change",this,this.limitMinScaleDenominator?a:void 0,this.limitMaxScaleDenominator?b:void 0)}},sliderValuesToScale:function(a){var b=100/(this.scaleLevels-1);return[Math.round(Math.pow(this.scaleFactor,
  (100-a[0])/b)*this.minScaleDenominatorLimit),Math.round(Math.pow(this.scaleFactor,(100-a[1])/b)*this.minScaleDenominatorLimit)]},scaleToSliderValues:function(a){var b=100/(this.scaleLevels-1);return[100-b*Math.log(a[0]/this.minScaleDenominatorLimit)/Math.log(this.scaleFactor),100-b*Math.log(a[1]/this.minScaleDenominatorLimit)/Math.log(this.scaleFactor)]}});Ext.reg("gxp_scalelimitpanel",gxp.ScaleLimitPanel);Ext.namespace("gxp.form");
  gxp.form.GoogleGeocoderComboBox=Ext.extend(Ext.form.ComboBox,{xtype:"gxp_googlegeocodercombo",queryDelay:100,valueField:"viewport",displayField:"address",initComponent:function(){this.disabled=!0;if(window.google&&google.maps)window.setTimeout(function(){this.prepGeocoder()}.createDelegate(this),0);else{if(!gxp.plugins||!gxp.plugins.GoogleSource)throw Error("The gxp.form.GoogleGeocoderComboBox requires the gxp.plugins.GoogleSource or the Google Maps V3 API to be loaded.");gxp.plugins.GoogleSource.loader.onLoad({callback:this.prepGeocoder,
  errback:function(){throw Error("The Google Maps script failed to load within the given timeout.");},scope:this})}this.store=new Ext.data.JsonStore({root:"results",fields:[{name:"address",type:"string"},{name:"location"},{name:"viewport"}],autoLoad:!1});this.on({focus:function(){this.clearValue()},scope:this});return gxp.form.GoogleGeocoderComboBox.superclass.initComponent.apply(this,arguments)},prepGeocoder:function(){var a=new google.maps.Geocoder,b={};b[Ext.data.Api.actions.read]=!0;var b=new Ext.data.DataProxy({api:b}),
  c=this,d=function(){var a=this.bounds;a&&(a instanceof OpenLayers.Bounds&&(a=a.toArray()),a=new google.maps.LatLngBounds(new google.maps.LatLng(a[1],a[0]),new google.maps.LatLng(a[3],a[2])));return a}.createDelegate(this);b.doRequest=function(b,f,g,h,j,k,l){a.geocode({address:g.query,bounds:d()},function(a,d){var f;if(d===google.maps.GeocoderStatus.OK||d===google.maps.GeocoderStatus.ZERO_RESULTS)try{a=c.transformResults(a),f=h.readRecords({results:a})}catch(g){c.fireEvent("exception",c,"response",
  b,l,d,g)}else c.fireEvent("exception",c,"remote",b,l,d,null);f?j.call(k,f,l,!0):j.call(k,null,l,!1)})};this.store.proxy=b;!0!=this.initialConfig.disabled&&this.enable()},transformResults:function(a){var b=a.length,c=Array(b),d,e,f,g;for(i=0;i<b;++i)d=a[i],e=d.geometry.location,f=d.geometry.viewport,g=f.getNorthEast(),f=f.getSouthWest(),c[i]={address:d.formatted_address,location:new OpenLayers.LonLat(e.lng(),e.lat()),viewport:new OpenLayers.Bounds(f.lng(),f.lat(),g.lng(),g.lat())};return c}});
  Ext.reg(gxp.form.GoogleGeocoderComboBox.prototype.xtype,gxp.form.GoogleGeocoderComboBox);Ext.namespace("gxp.plugins");
  gxp.plugins.GoogleGeocoder=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_googlegeocoder",updateField:"viewport",init:function(a){var b=new gxp.form.GoogleGeocoderComboBox(Ext.apply({listeners:{select:this.onComboSelect,scope:this}},this.outputConfig)),c=a.mapPanel.map.restrictedExtent;if(c&&!b.bounds)a.on({ready:function(){b.bounds=c.clone().transform(a.mapPanel.map.getProjectionObject(),new OpenLayers.Projection("EPSG:4326"))}});this.combo=b;return gxp.plugins.GoogleGeocoder.superclass.init.apply(this,
  arguments)},addOutput:function(){return gxp.plugins.GoogleGeocoder.superclass.addOutput.call(this,this.combo)},onComboSelect:function(a,b){if(this.updateField){var c=this.target.mapPanel.map,d=b.get(this.updateField).clone().transform(new OpenLayers.Projection("EPSG:4326"),c.getProjectionObject());d instanceof OpenLayers.Bounds?c.zoomToExtent(d,!0):c.setCenter(d)}}});Ext.preg(gxp.plugins.GoogleGeocoder.prototype.ptype,gxp.plugins.GoogleGeocoder);Ext.namespace("gxp.plugins");
  gxp.plugins.FeatureEditorGrid=Ext.extend(Ext.grid.PropertyGrid,{ptype:"gxp_editorgrid",feature:null,schema:null,fields:null,excludeFields:null,propertyNames:null,readOnly:null,border:!1,initComponent:function(){this.dateFormat||(this.dateFormat=Ext.form.DateField.prototype.format);this.timeFormat||(this.timeFormat=Ext.form.TimeField.prototype.format);var a={},b={},c=this.feature,d;if(this.fields){d={};for(var e=0,f=this.fields.length;e<f;++e)d[this.fields[e]]=c.attributes[this.fields[e]]}else d=c.attributes;
  this.excludeFields||(this.excludeFields=[]);if(this.schema){var g=this.fields?this.fields.join(",").toUpperCase().split(","):[];this.schema.each(function(e){var f=e.get("type");if(!f.match(/^[^:]*:?((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry))/)){var h=e.get("name");this.fields&&g.indexOf(h.toUpperCase())==-1&&this.excludeFields.push(h);var n=c.attributes[h],e=GeoExt.form.recordToField(e),m;if(typeof n=="string"){var o;switch(f.split(":").pop()){case "date":o=this.dateFormat;e.editable=false;
  break;case "dateTime":if(!o){o=this.dateFormat+" "+this.timeFormat;e.editable=true}e.format=o;m={startedit:function(a,b){if(!(b instanceof Date)){var c=Date.parseDate(b.replace(/Z$/,""),"c");c&&this.setValue(c)}}};b[h]=function(){return function(a){var b=a;typeof a=="string"&&(b=Date.parseDate(a.replace(/Z$/,""),"c"));return b?b.format(o):a}}();break;case "boolean":m={startedit:function(a,b){this.setValue(Boolean(b))}}}}a[h]=new Ext.grid.GridEditor({field:Ext.create(e),listeners:m});d[h]=n}},this);
  c.attributes=d}this.source=d;this.customEditors=a;this.customRenderers=b;var h=this.excludeFields.length?this.excludeFields.join(",").toUpperCase().split(","):[];this.viewConfig={forceFit:!0,getRowClass:function(a){if(h.indexOf(a.get("name").toUpperCase())!==-1)return"x-hide-nosize"}};this.listeners={beforeedit:function(){return this.featureEditor.editing},propertychange:function(){this.featureEditor.setFeatureState(this.featureEditor.getDirtyState())},scope:this};e=Ext.data.Store.prototype.sort;
  Ext.data.Store.prototype.sort=function(){};gxp.plugins.FeatureEditorGrid.superclass.initComponent.apply(this,arguments);Ext.data.Store.prototype.sort=e;this.propStore.isEditableValue=function(){return true}},init:function(a){this.featureEditor=a;this.featureEditor.on("canceledit",this.onCancelEdit,this);this.featureEditor.add(this);this.featureEditor.doLayout()},destroy:function(){this.featureEditor.un("canceledit",this.onCancelEdit,this);this.featureEditor=null;gxp.plugins.FeatureEditorGrid.superclass.destroy.call(this)},
  onCancelEdit:function(a,b){b&&this.setSource(b.attributes)}});Ext.preg(gxp.plugins.FeatureEditorGrid.prototype.ptype,gxp.plugins.FeatureEditorGrid);Ext.namespace("gxp");
  gxp.QueryPanel=Ext.extend(Ext.Panel,{layout:"form",spatialQuery:!0,attributeQuery:!0,selectedLayer:null,featureStore:null,attributeStore:null,geometryType:null,geometryName:null,queryByLocationText:"Query by location",currentTextText:"Current extent",queryByAttributesText:"Query by attributes",layerText:"Layer",initComponent:function(){this.addEvents("ready","beforelayerchange","layerchange","beforequery","query","storeload");this.mapExtentField=new Ext.form.TextField({fieldLabel:this.currentTextText,
  readOnly:!0,anchor:"100%",value:this.getFormattedMapExtent()});this.map.events.on({moveend:this.updateMapExtent,scope:this});this.createFilterBuilder(this.layerStore.getAt(0));this.items=[{xtype:"combo",name:"layer",fieldLabel:this.layerText,store:this.layerStore,value:this.layerStore.getAt(0).get("name"),displayField:"title",valueField:"name",mode:"local",allowBlank:!0,editable:!1,triggerAction:"all",listeners:{beforeselect:function(a,b){return this.fireEvent("beforelayerchange",this,b)},select:function(a,
  b){this.createFilterBuilder(b)},scope:this}},{xtype:"fieldset",title:this.queryByLocationText,checkboxToggle:!0,collapsed:!this.spatialQuery,anchor:"95%",items:[this.mapExtentField],listeners:{collapse:function(){this.spatialQuery=!1},expand:function(){this.spatialQuery=!0},scope:this}},{xtype:"fieldset",title:this.queryByAttributesText,checkboxToggle:!0,collapsed:!this.attributeQuery,anchor:"95%",items:[this.filterBuilder],listeners:{collapse:function(){this.attributeQuery=!1},expand:function(){this.attributeQuery=
  !0},scope:this}}];gxp.QueryPanel.superclass.initComponent.apply(this,arguments)},createFilterBuilder:function(a){this.selectedLayer=a;var b=this.filterBuilder&&this.filterBuilder.ownerCt;b&&b.remove(this.filterBuilder,!0);this.attributeStore=new GeoExt.data.AttributeStore({url:a.get("schema"),listeners:{load:function(b){this.geometryName=null;b.filterBy(function(b){var c=/gml:((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry)).*/.exec(b.get("type"));c&&!this.geometryName&&(this.geometryName=b.get("name"),
  this.geometryType=c[1],this.fireEvent("layerchange",this,a));return!c},this);this.createFeatureStore()},scope:this},autoLoad:!0});this.filterBuilder=new gxp.FilterBuilder({attributes:this.attributeStore,allowGroups:!1});b&&(b.add(this.filterBuilder),b.doLayout())},getFormattedMapExtent:function(){return this.map&&this.map.getExtent()&&this.map.getExtent().toBBOX().replace(/\.(\d)\d*/g,".$1").replace(/,/g,", ")},updateMapExtent:function(){this.mapExtentField.setValue(this.getFormattedMapExtent())},
  getFilter:function(){var a=this.attributeQuery&&this.filterBuilder.getFilter(),b=this.spatialQuery&&new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,value:this.map.getExtent()});return a&&b?new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:[b,a]}):a||b},getFieldType:function(a){return{"xsd:boolean":"boolean","xsd:int":"int","xsd:integer":"int","xsd:short":"int","xsd:long":"int","xsd:date":"date","xsd:string":"string","xsd:float":"float","xsd:double":"float"}[a]},
  createFeatureStore:function(){var a=[];this.attributeStore.each(function(b){a.push({name:b.get("name"),type:this.getFieldType(b.get("type"))})},this);var b=this.selectedLayer;this.featureStore=new gxp.data.WFSFeatureStore({fields:a,srsName:this.map.getProjection(),url:b.get("url"),featureType:b.get("name"),featureNS:b.get("namespace"),geometryName:this.geometryName,schema:b.get("schema"),maxFeatures:this.maxFeatures,autoLoad:!1,autoSave:!1,listeners:{load:function(a,b,e){this.fireEvent("storeload",
  this,a,b,e)},scope:this}});this.fireEvent("ready",this,this.featureStore)},query:function(){this.featureStore&&!1!==this.fireEvent("beforequery",this)&&(this.featureStore.setOgcFilter(this.getFilter()),this.featureStore.load(),this.fireEvent("query",this,this.featureStore))},beforeDestroy:function(){this.map&&this.map.events&&this.map.events.un({moveend:this.updateMapExtent,scope:this});gxp.QueryPanel.superclass.beforeDestroy.apply(this,arguments)}});Ext.reg("gxp_querypanel",gxp.QueryPanel);Ext.namespace("gxp");
  gxp.TextSymbolizer=Ext.extend(Ext.Panel,{fonts:void 0,symbolizer:null,defaultSymbolizer:null,attributes:null,colorManager:null,haloCache:null,border:!1,layout:"form",labelValuesText:"Label values",haloText:"Halo",sizeText:"Size",priorityText:"Priority",labelOptionsText:"Label options",autoWrapText:"Auto wrap",followLineText:"Follow line",maxDisplacementText:"Maximum displacement",repeatText:"Repeat",forceLeftToRightText:"Force left to right",graphicResizeText:"Graphic resize",graphicMarginText:"Graphic margin",
  graphicTitle:"Graphic",fontColorTitle:"Font color and opacity",positioningText:"Label positioning",anchorPointText:"Anchor point",displacementXText:"Displacement (X-direction)",displacementYText:"Displacement (Y-direction)",perpendicularOffsetText:"Perpendicular offset",priorityHelp:"The higher the value of the specified field, the sooner the label will be drawn (which makes it win in the conflict resolution game)",autoWrapHelp:"Wrap labels that exceed a certain length in pixels",followLineHelp:"Should the label follow the geometry of the line?",
  maxDisplacementHelp:"Maximum displacement in pixels if label position is busy",repeatHelp:"Repeat labels after a certain number of pixels",forceLeftToRightHelp:"Labels are usually flipped to make them readable. If the character happens to be a directional arrow then this is not desirable",graphic_resizeHelp:"Specifies a mode for resizing label graphics (such as highway shields) to fit the text of the label. The default mode, \u2018none\u2019, never modifies the label graphic. In stretch mode, GeoServer will resize the graphic to exactly surround the label text, possibly modifying the image\u2019s aspect ratio. In proportional mode, GeoServer will expand the image to be large enough to surround the text while preserving its original aspect ratio.",
  graphic_marginHelp:"Similar to the margin shorthand property in CSS for HTML, its interpretation varies depending on how many margin values are provided: 1 = use that margin length on all sides of the label 2 = use the first for top & bottom margins and the second for left & right margins. 3 = use the first for the top margin, second for left & right margins, third for the bottom margin. 4 = use the first for the top margin, second for the right margin, third for the bottom margin, and fourth for the left margin.",
  initComponent:function(){this.symbolizer||(this.symbolizer={});Ext.applyIf(this.symbolizer,this.defaultSymbolizer);this.symbolizer.vendorOptions||(this.symbolizer.vendorOptions={});this.haloCache={};this.attributes.load();var a={xtype:"combo",fieldLabel:this.labelValuesText,store:this.attributes,mode:"local",lastQuery:"",editable:!1,triggerAction:"all",allowBlank:!1,displayField:"name",valueField:"name",value:this.symbolizer.label&&this.symbolizer.label.replace(/^\${(.*)}$/,"$1"),listeners:{select:function(a,
  c){this.symbolizer.label="${"+c.get("name")+"}";this.fireEvent("change",this.symbolizer)},scope:this},width:120};this.attributesComboConfig=this.attributesComboConfig||{};Ext.applyIf(this.attributesComboConfig,a);this.labelWidth=80;this.items=[this.attributesComboConfig,{cls:"x-html-editor-tb",style:"background: transparent; border: none; padding: 0 0em 0.5em;",xtype:"toolbar",items:[{xtype:"gxp_fontcombo",fonts:this.fonts||void 0,width:110,value:this.symbolizer.fontFamily,listeners:{select:function(a,
  c){this.symbolizer.fontFamily=c.get("field1");this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"tbtext",text:this.sizeText+": "},{xtype:"numberfield",allowNegative:!1,emptyText:OpenLayers.Renderer.defaultSymbolizer.fontSize,value:this.symbolizer.fontSize,width:30,listeners:{change:function(a,c){c=parseFloat(c);isNaN(c)?delete this.symbolizer.fontSize:this.symbolizer.fontSize=c;this.fireEvent("change",this.symbolizer)},scope:this}},{enableToggle:!0,cls:"x-btn-icon",iconCls:"x-edit-bold",
  pressed:"bold"===this.symbolizer.fontWeight,listeners:{toggle:function(a,c){this.symbolizer.fontWeight=c?"bold":"normal";this.fireEvent("change",this.symbolizer)},scope:this}},{enableToggle:!0,cls:"x-btn-icon",iconCls:"x-edit-italic",pressed:"italic"===this.symbolizer.fontStyle,listeners:{toggle:function(a,c){this.symbolizer.fontStyle=c?"italic":"normal";this.fireEvent("change",this.symbolizer)},scope:this}}]},{xtype:"gxp_fillsymbolizer",fillText:this.fontColorTitle,symbolizer:this.symbolizer,colorProperty:"fontColor",
  opacityProperty:"fontOpacity",checkboxToggle:!1,autoHeight:!0,width:213,labelWidth:70,plugins:this.colorManager&&[new this.colorManager],listeners:{change:function(){this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"fieldset",title:this.graphicTitle,checkboxToggle:!0,hideMode:"offsets",collapsed:!(this.symbolizer.fillColor||this.symbolizer.fillOpacity),labelWidth:70,items:[{xtype:"gxp_pointsymbolizer",symbolizer:this.symbolizer,border:!1,labelWidth:70},this.createVendorSpecificField({name:"graphic-resize",
  xtype:"combo",store:["none","stretch","proportional"],mode:"local",width:100,triggerAction:"all",fieldLabel:this.graphicResizeText}),this.createVendorSpecificField({name:"graphic-margin",width:100,fieldLabel:this.graphicMarginText,xtype:"textfield"})],listeners:{collapse:function(){this.graphicCache={externalGraphic:this.symbolizer.externalGraphic,fillColor:this.symbolizer.fillColor,fillOpacity:this.symbolizer.fillOpacity,graphicName:this.symbolizer.graphicName,pointRadius:this.symbolizer.pointRadius,
  rotation:this.symbolizer.rotation,strokeColor:this.symbolizer.strokeColor,strokeWidth:this.symbolizer.strokeWidth,strokeDashStyle:this.symbolizer.strokeDashStyle};delete this.symbolizer.externalGraphic;delete this.symbolizer.fillColor;delete this.symbolizer.fillOpacity;delete this.symbolizer.graphicName;delete this.symbolizer.pointRadius;delete this.symbolizer.rotation;delete this.symbolizer.strokeColor;delete this.symbolizer.strokeWidth;delete this.symbolizer.strokeDashStyle;this.fireEvent("change",
  this.symbolizer)},expand:function(){Ext.apply(this.symbolizer,this.graphicCache);this.doLayout();this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"fieldset",title:this.haloText,checkboxToggle:!0,collapsed:!(this.symbolizer.haloRadius||this.symbolizer.haloColor||this.symbolizer.haloOpacity),autoHeight:!0,labelWidth:50,items:[{xtype:"numberfield",fieldLabel:this.sizeText,anchor:"89%",allowNegative:!1,emptyText:OpenLayers.Renderer.defaultSymbolizer.haloRadius,value:this.symbolizer.haloRadius,
  listeners:{change:function(a,c){c=parseFloat(c);isNaN(c)?delete this.symbolizer.haloRadius:this.symbolizer.haloRadius=c;this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"gxp_fillsymbolizer",symbolizer:{fillColor:"haloColor"in this.symbolizer?this.symbolizer.haloColor:OpenLayers.Renderer.defaultSymbolizer.haloColor,fillOpacity:"haloOpacity"in this.symbolizer?this.symbolizer.haloOpacity:100*OpenLayers.Renderer.defaultSymbolizer.haloOpacity},defaultColor:OpenLayers.Renderer.defaultSymbolizer.haloColor,
  checkboxToggle:!1,width:190,labelWidth:60,plugins:this.colorManager&&[new this.colorManager],listeners:{change:function(a){this.symbolizer.haloColor=a.fillColor;this.symbolizer.haloOpacity=a.fillOpacity;this.fireEvent("change",this.symbolizer)},scope:this}}],listeners:{collapse:function(){this.haloCache={haloRadius:this.symbolizer.haloRadius,haloColor:this.symbolizer.haloColor,haloOpacity:this.symbolizer.haloOpacity};delete this.symbolizer.haloRadius;delete this.symbolizer.haloColor;delete this.symbolizer.haloOpacity;
  this.fireEvent("change",this.symbolizer)},expand:function(){Ext.apply(this.symbolizer,this.haloCache);this.doLayout();this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"fieldset",title:this.positioningText,checkboxToggle:!0,collapsed:!0,autoHeight:!0,labelWidth:75,defaults:{width:100},items:[Ext.applyIf({fieldLabel:this.anchorPointText,value:this.symbolizer.labelAlign||"lb",store:[["lt","Left-top"],["ct","Center-top"],["rt","Right-top"],["lm","Left-center"],["cm","Center"],["rm","Right-center"],
  ["lb","Left-bottom"],["cb","Center-bottom"],["rb","Right-bottom"]],listeners:{select:function(a){this.symbolizer.labelAlign=a.getValue();this.fireEvent("change",this.symbolizer)},scope:this}},this.attributesComboConfig),{xtype:"numberfield",fieldLabel:this.displacementXText,value:this.symbolizer.labelXOffset,listeners:{change:function(a,c){this.symbolizer.labelXOffset=c;this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"numberfield",fieldLabel:this.displacementYText,value:this.symbolizer.labelYOffset,
  listeners:{change:function(a,c){this.symbolizer.labelYOffset=c;this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"numberfield",fieldLabel:this.perpendicularOffsetText,value:this.symbolizer.labelPerpendicularOffset,listeners:{change:function(a,c){Ext.isEmpty(c)?delete this.symbolizer.labelPerpendicularOffset:this.symbolizer.labelPerpendicularOffset=c;this.fireEvent("change",this.symbolizer)},scope:this}}]},{xtype:"fieldset",title:this.priorityText,checkboxToggle:!0,collapsed:!0,autoHeight:!0,
  labelWidth:50,items:[Ext.applyIf({fieldLabel:this.priorityText,value:this.symbolizer.priority&&this.symbolizer.priority.replace(/^\${(.*)}$/,"$1"),allowBlank:!0,name:"priority",listeners:{select:function(a,c){this.symbolizer[a.name]="${"+c.get("name")+"}";this.fireEvent("change",this.symbolizer)},render:this.attachHelpToField,scope:this}},this.attributesComboConfig)]},{xtype:"fieldset",title:this.labelOptionsText,checkboxToggle:!0,collapsed:!0,autoHeight:!0,labelWidth:80,defaults:{width:100},items:[this.createVendorSpecificField({name:"autoWrap",
  allowBlank:!1,fieldLabel:this.autoWrapText}),this.createVendorSpecificField({name:"followLine",xtype:"checkbox",fieldLabel:this.followLineText}),this.createVendorSpecificField({name:"maxDisplacement",fieldLabel:this.maxDisplacementText}),this.createVendorSpecificField({name:"repeat",fieldLabel:this.repeatText}),this.createVendorSpecificField({name:"forceLeftToRight",xtype:"checkbox",fieldLabel:this.forceLeftToRightText})]}];this.addEvents("change");gxp.TextSymbolizer.superclass.initComponent.call(this)},
  createVendorSpecificField:function(a){var b=function(b,d){Ext.isEmpty(d)?delete this.symbolizer.vendorOptions[a.name]:this.symbolizer.vendorOptions[a.name]=d;this.fireEvent("change",this.symbolizer)};return Ext.applyIf(a,{xtype:"numberfield",allowNegative:!1,value:this.symbolizer.vendorOptions[a.name],listeners:{render:this.attachHelpToField,change:b,check:b,scope:this}})},attachHelpToField:function(a){var b=a.name.replace(/-/g,"_")+"Help";Ext.QuickTips.register({target:a.getEl(),dismissDelay:2E4,
  text:this[b]})}});Ext.reg("gxp_textsymbolizer",gxp.TextSymbolizer);Ext.namespace("gxp.form");
  gxp.form.FilterField=Ext.extend(Ext.form.CompositeField,{lowerBoundaryTip:"lower boundary",upperBoundaryTip:"upper boundary",filter:null,attributes:null,attributesComboConfig:null,initComponent:function(){this.filter||(this.filter=this.createDefaultFilter());var a="remote",b=new GeoExt.data.AttributeStore;this.attributes&&(0!=this.attributes.getCount()?(a="local",this.attributes.each(function(a){/gml:((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry)).*/.exec(a.get("type"))||b.add([a])})):b=this.attributes);
  a={xtype:"combo",store:b,editable:"local"==a,typeAhead:!0,forceSelection:!0,mode:a,triggerAction:"all",allowBlank:this.allowBlank,displayField:"name",valueField:"name",value:this.filter.property,listeners:{select:function(a,b){this.items.get(1).enable();this.filter.property=b.get("name");this.fireEvent("change",this.filter,this)},blur:function(a){var b=a.store.findExact("name",a.getValue());b!=-1?a.fireEvent("select",a,a.store.getAt(b)):a.startValue!=null&&a.setValue(a.startValue)},scope:this},width:120};
  this.attributesComboConfig=this.attributesComboConfig||{};Ext.applyIf(this.attributesComboConfig,a);this.items=this.createFilterItems();this.addEvents("change");gxp.form.FilterField.superclass.initComponent.call(this)},validateValue:function(){return this.filter.type===OpenLayers.Filter.Comparison.BETWEEN?null!==this.filter.property&&null!==this.filter.upperBoundary&&null!==this.filter.lowerBoundary:null!==this.filter.property&&null!==this.filter.value&&null!==this.filter.type},createDefaultFilter:function(){return new OpenLayers.Filter.Comparison},
  createFilterItems:function(){var a=this.filter.type===OpenLayers.Filter.Comparison.BETWEEN;return[this.attributesComboConfig,Ext.applyIf({xtype:"gxp_comparisoncombo",disabled:null==this.filter.property,allowBlank:this.allowBlank,value:this.filter.type,listeners:{select:function(a,c){this.items.get(2).enable();this.items.get(3).enable();this.items.get(4).enable();this.setFilterType(c.get("value"));this.fireEvent("change",this.filter,this)},scope:this}},this.comparisonComboConfig),{xtype:"textfield",
  disabled:null==this.filter.type,hidden:a,value:this.filter.value,width:50,grow:!0,growMin:50,anchor:"100%",allowBlank:this.allowBlank,listeners:{change:function(a,c){this.filter.value=c;this.fireEvent("change",this.filter,this)},scope:this}},{xtype:"textfield",disabled:null==this.filter.type,hidden:!a,value:this.filter.lowerBoundary,tooltip:this.lowerBoundaryTip,grow:!0,growMin:30,anchor:"100%",allowBlank:this.allowBlank,listeners:{change:function(a,c){this.filter.lowerBoundary=c;this.fireEvent("change",
  this.filter,this)},render:function(a){Ext.QuickTips.register({target:a.getEl(),text:this.lowerBoundaryTip})},autosize:function(a,c){a.setWidth(c);a.ownerCt.doLayout()},scope:this}},{xtype:"textfield",disabled:null==this.filter.type,hidden:!a,grow:!0,growMin:30,value:this.filter.upperBoundary,allowBlank:this.allowBlank,listeners:{change:function(a,c){this.filter.upperBoundary=c;this.fireEvent("change",this.filter,this)},render:function(a){Ext.QuickTips.register({target:a.getEl(),text:this.upperBoundaryTip})},
  scope:this}}]},setFilterType:function(a){this.filter.type=a;a===OpenLayers.Filter.Comparison.BETWEEN?(this.items.get(2).hide(),this.items.get(3).show(),this.items.get(4).show()):(this.items.get(2).show(),this.items.get(3).hide(),this.items.get(4).hide());this.doLayout()}});Ext.reg("gxp_filterfield",gxp.form.FilterField);
  Ext.override(GeoExt.Popup,{initComponent:function(){this.map instanceof GeoExt.MapPanel&&(this.map=this.map.map);!this.map&&this.location instanceof OpenLayers.Feature.Vector&&this.location.layer&&(this.map=this.location.layer.map);this.location instanceof OpenLayers.Feature.Vector&&(this.location=this.location.geometry);this.location instanceof OpenLayers.Geometry?("function"==typeof this.location.getCentroid&&(this.location=this.location.getCentroid()),this.location=this.location.getBounds().getCenterLonLat()):
  this.location instanceof OpenLayers.Pixel?this.location=this.map.getLonLatFromViewPortPx(this.location):this.anchored=!1;var a=this.map.getExtent();a&&this.location&&(this.insideViewport=a.containsLonLat(this.location));this.anchored?(this.addAnchorEvents(),this.elements+=",anc"):this.unpinnable=!1;this.baseCls=this.popupCls+" "+this.baseCls;GeoExt.Popup.superclass.initComponent.call(this)},makeDraggable:function(){this.draggable=!0;this.header.addClass("x-window-draggable");this.dd=new Ext.Window.DD(this)},
  onRender:function(a,b){GeoExt.Popup.superclass.onRender.call(this,a,b);this.anchored?(this.ancCls=this.popupCls+"-anc",this.createElement("anc",this.el.dom)):this.makeDraggable()}});Ext.namespace("gxp");
  gxp.FeatureEditPopup=Ext.extend(GeoExt.Popup,{closeMsgTitle:"Save Changes?",closeMsg:"This feature has unsaved changes. Would you like to save your changes?",deleteMsgTitle:"Delete Feature?",deleteMsg:"Are you sure you want to delete this feature?",editButtonText:"Edit",editButtonTooltip:"Make this feature editable",deleteButtonText:"Delete",deleteButtonTooltip:"Delete this feature",cancelButtonText:"Cancel",cancelButtonTooltip:"Stop editing, discard changes",saveButtonText:"Save",saveButtonTooltip:"Save changes",
  layout:"fit",feature:null,schema:null,readOnly:!1,allowDelete:!1,editing:!1,editorPluginConfig:{ptype:"gxp_editorgrid"},modifyControl:null,geometry:null,attributes:null,cancelButton:null,saveButton:null,editButton:null,deleteButton:null,initComponent:function(){this.addEvents("startedit","stopedit","beforefeaturemodified","featuremodified","canceledit","cancelclose");var a=this.feature;a instanceof GeoExt.data.FeatureRecord&&(a=this.feature=a.getFeature());this.location||(this.location=a);this.anchored=
  !this.editing;!this.title&&a.fid&&(this.title=a.fid);this.editButton=new Ext.Button({text:this.editButtonText,tooltip:this.editButtonTooltip,iconCls:"edit",handler:this.startEditing,scope:this});this.deleteButton=new Ext.Button({text:this.deleteButtonText,tooltip:this.deleteButtonTooltip,iconCls:"delete",hidden:!this.allowDelete,handler:this.deleteFeature,scope:this});this.cancelButton=new Ext.Button({text:this.cancelButtonText,tooltip:this.cancelButtonTooltip,iconCls:"cancel",hidden:!0,handler:function(){this.stopEditing(false)},
  scope:this});this.saveButton=new Ext.Button({text:this.saveButtonText,tooltip:this.saveButtonTooltip,iconCls:"save",hidden:!0,handler:function(){this.stopEditing(true)},scope:this});this.plugins=[Ext.apply({feature:a,schema:this.schema,fields:this.fields,excludeFields:this.excludeFields,propertyNames:this.propertyNames,readOnly:this.readOnly},this.editorPluginConfig)];this.bbar=new Ext.Toolbar({hidden:this.readOnly,items:[this.editButton,this.deleteButton,this.saveButton,this.cancelButton]});gxp.FeatureEditPopup.superclass.initComponent.call(this);
  this.on({show:function(){if(this.editing){this.editing=null;this.startEditing()}},beforeclose:function(){if(this.editing){if(this.feature.state===this.getDirtyState()){Ext.Msg.show({title:this.closeMsgTitle,msg:this.closeMsg,buttons:Ext.Msg.YESNOCANCEL,fn:function(a){if(a&&a!=="cancel"){this.stopEditing(a==="yes");this.close()}else this.fireEvent("cancelclose",this)},scope:this,icon:Ext.MessageBox.QUESTION,animEl:this.getEl()});return false}this.stopEditing(false)}},scope:this})},getDirtyState:function(){return this.feature.state===
  OpenLayers.State.INSERT?this.feature.state:OpenLayers.State.UPDATE},startEditing:function(){this.editing||(this.fireEvent("startedit",this),this.editing=!0,this.anc&&this.unanchorPopup(),this.editButton.hide(),this.deleteButton.hide(),this.saveButton.show(),this.cancelButton.show(),this.geometry=this.feature.geometry&&this.feature.geometry.clone(),this.attributes=Ext.apply({},this.feature.attributes),this.modifyControl=new OpenLayers.Control.ModifyFeature(this.feature.layer,{standalone:!0,vertexRenderIntent:this.vertexRenderIntent}),
  this.feature.layer.map.addControl(this.modifyControl),this.modifyControl.activate(),this.feature.geometry&&this.modifyControl.selectFeature(this.feature))},stopEditing:function(a){if(this.editing){this.fireEvent("stopedit",this);this.modifyControl.deactivate();this.modifyControl.destroy();var b=this.feature;if(b.state===this.getDirtyState())if(!0===a){this.fireEvent("beforefeaturemodified",this,b);if(this.schema){var c,d;for(d in b.attributes)c=this.schema.getAt(this.schema.findExact("name",d)),a=
  b.attributes[d],a instanceof Date&&(c=c.get("type").split(":").pop(),b.attributes[d]=a.format("date"==c?"Y-m-d":"c"))}this.fireEvent("featuremodified",this,b)}else b.state===OpenLayers.State.INSERT?(this.editing=!1,b.layer&&b.layer.destroyFeatures([b]),this.fireEvent("canceledit",this,null),this.close()):(d=b.layer,d.drawFeature(b,{display:"none"}),b.geometry=this.geometry,b.attributes=this.attributes,this.setFeatureState(null),d.drawFeature(b),this.fireEvent("canceledit",this,b));this.isDestroyed||
  (this.cancelButton.hide(),this.saveButton.hide(),this.editButton.show(),this.allowDelete&&this.deleteButton.show());this.editing=!1}},deleteFeature:function(){Ext.Msg.show({title:this.deleteMsgTitle,msg:this.deleteMsg,buttons:Ext.Msg.YESNO,fn:function(a){"yes"===a&&(this.setFeatureState(OpenLayers.State.DELETE),this.fireEvent("featuremodified",this,this.feature),this.close())},scope:this,icon:Ext.MessageBox.QUESTION,animEl:this.getEl()})},setFeatureState:function(a){this.feature.state=a;(a=this.feature.layer)&&
  a.events.triggerEvent("featuremodified",{feature:this.feature})}});Ext.reg("gxp_featureeditpopup",gxp.FeatureEditPopup);Ext.namespace("gxp");Ext.override(Ext.Tip,{showBy:function(a,b,c){var d=c[0],c=c[1];"b"===b.charAt(0)&&(c=-c);if("r"===b.charAt(0)||"r"===b.charAt(1))d=-d;"c"===b.charAt(0)&&(c=d=0);if("l"===b.charAt(0)||"r"===b.charAt(0))c=0;this.rendered||this.render(Ext.getBody());this.showAt(this.el.getAlignToXY(a,b||this.defaultAlign,[d,c]))}});
  GeoExt.FeatureTip=Ext.extend(Ext.Tip,{map:null,location:null,initComponent:function(){var a=this.location.geometry.getCentroid();this.location=new OpenLayers.LonLat(a.x,a.y);this.map.events.on({move:this.show,scope:this});GeoExt.FeatureTip.superclass.initComponent.call(this)},beforeDestroy:function(){this.map.events.un({move:this.show,scope:this});GeoExt.FeatureTip.superclass.beforeDestroy.call(this)},getPosition:function(){if(this.map.getExtent().containsLonLat(this.location)){var a=this.map.getPixelFromLonLat(this.location),
  b=Ext.fly(this.map.div).getBox(!0);return[a.x+b.x,a.y+b.y]}return null},show:function(){var a=this.getPosition();null!==a?this.showAt(a):this.hide()}});
  window.Timeline&&window.SimileAjax&&function(){SimileAjax.History.enabled=!1;Timeline._Band.prototype._onDblClick=Ext.emptyFn;Timeline.DefaultEventSource.prototype.remove=function(a){this._events.remove(a)};SimileAjax.EventIndex.prototype.remove=function(a){this._events.remove(this._idToEvent[a]);delete this._idToEvent[a]};Timeline._Band.prototype.zoom=function(a){if(this._zoomSteps){var b=this.getCenterVisibleDate();this._etherPainter.zoom(this._ether.zoom(a));this.setCenterVisibleDate(b)}}}();
  gxp.TimelinePanel=Ext.extend(Ext.Panel,{timeInfoEndpoint:"/maps/time_info.json?",annotationConfig:{timeAttr:"start_time",endTimeAttr:"end_time",filterAttr:"in_timeline",mapFilterAttr:"in_map"},loadingMessage:"Loading Timeline data...",instructionText:"There are too many events ({count}) to show in the timeline.<br/>Please zoom in or move the vertical slider down (maximum is {max})",errorText:"Something went wrong with retrieving the data for the timeline",layerCount:0,busyMask:null,schemaCache:{},
  propertyNamesCache:{},sldCache:{},maxFeatures:500,bufferFraction:1,layout:"border",initComponent:function(){Timeline.OriginalEventPainter.prototype._showBubble=this.handleEventClick.createDelegate(this);this.timelineContainer=new Ext.Container({region:"center"});this.eventSource=new Timeline.DefaultEventSource(0);this.items=[{region:"west",xtype:"container",layout:"vbox",margins:"10 5",width:20,items:[{xtype:"panel",margins:"3 1",cls:"x-tool x-tool-minus",listeners:{afterrender:function(a){a.getEl().on("click",
  function(){this.rangeSlider.setValue(0,this.rangeSlider.getValue()+10,!0,!0)},this)},scope:this}},{xtype:"slider",ref:"../rangeSlider",vertical:!0,flex:1,value:25,minValue:1,maxValue:100,listeners:{change:this.onChange,changecomplete:this.onChangeComplete,scope:this},plugins:[new gxp.slider.RangeSliderTip]},{xtype:"panel",margins:"3 1",cls:"x-tool x-tool-plus",listeners:{afterrender:function(a){a.getEl().on("click",function(){this.rangeSlider.setValue(0,this.rangeSlider.getValue()-10,!0,!0)},this)},
  scope:this}}]},this.timelineContainer];this.initialConfig.viewer&&(delete this.viewer,this.bindViewer(this.initialConfig.viewer));this.initialConfig.featureEditor&&(delete this.featureEditor,this.bindFeatureEditor(this.initialConfig.featureEditor));this.initialConfig.playbackTool&&(delete this.playbackTool,this.bindPlaybackTool(this.initialConfig.playbackTool));this.ownerCt&&(this.ownerCt.on("beforecollapse",function(){this._silentMapMove=true},this),this.ownerCt.on("beforeexpand",function(){delete this._silentMapMove},
  this));gxp.TimelinePanel.superclass.initComponent.call(this)},onChange:function(a,b){var c=this.playbackTool.playbackToolbar.control.range,c=this.calculateNewRange(c,b),d=new Date(c[0].getTime()-this.bufferFraction*(c[1]-c[0])),c=new Date(c[1].getTime()+this.bufferFraction*(c[1]-c[0])),d=new Date(Math.max(this.originalRange[0],d)),c=new Date(Math.min(this.originalRange[1],c));this.updateRangeSlider([d,c])},onChangeComplete:function(a,b){if(this.playbackTool){var c=this.playbackTool.playbackToolbar.control.range,
  c=this.calculateNewRange(c,b),d=this.playbackTool.playbackToolbar.control.currentTime,e=c[1]-c[0],c=new Date(d.getTime()-e/2),d=new Date(d.getTime()+e/2),f;for(f in this.layerLookup)this.layerLookup[f].layer&&this.setTimeFilter(f,this.createTimeFilter([c,d],f,this.bufferFraction));this.updateTimelineEvents({force:!0})}},setFilterMatcher:function(a){this.timeline&&(this.timeline.getBand(0).getEventPainter().setFilterMatcher(a),this.timeline.getBand(1).getEventPainter().setFilterMatcher(a),this.timeline.paint())},
  setLayerVisibility:function(a,b,c,d){var e=this.getKey(c);!1!==d&&this.clearEventsForKey(e);Ext.apply(this.layerLookup[e],{visible:b});this.setFilterMatcher(function(a){return a.getProperty("key")===e?b:!0});this.updateTimelineEvents()},applyFilter:function(a,b,c){a=this.getKey(a);c?this.layerLookup[a].clientSideFilter=b:delete this.layerLookup[a].clientSideFilter;this.layerLookup[a].layer&&(this.layerLookup[a].layer.filter=this.assembleFullFilter(a));this.updateTimelineEvents({force:!0})},setTitleAttribute:function(a,
  b){var c=this.getKey(a);this.layerLookup[c].titleAttr=b;this.clearEventsForKey(c);this.onFeaturesAdded({features:this.layerLookup[c].layer.features},c)},destroyPopup:function(){this.popup&&(this.popup.destroy(),this.popup=null)},handleEventClick:function(a,b,c){a=c.getProperty("fid");if(a=(b=this.layerLookup[c.getProperty("key")].layer)&&b.getFeatureByFid(a))if(this.destroyPopup(),b.protocol){!a.geometry&&a.bounds&&(a.geometry=a.bounds.toGeometry());var b=a.geometry.getCentroid(),d=this.viewer.mapPanel.map;
  this._silentMapMove=!0;d.setCenter(new OpenLayers.LonLat(b.x,b.y));delete this._silentMapMove;this.popup=new gxp.FeatureEditPopup({feature:a,propertyGridNameText:"Attributes",title:c.getProperty("title"),panIn:!1,width:200,height:250,collapsible:!0,readOnly:!0,hideMode:"offsets"});this.popup.show()}else this.featureEditor&&(this.featureEditor._forcePopupForNoGeometry=!0,b.events.triggerEvent("featureselected",{feature:a}),delete this.featureEditor._forcePopupForNoGeometry)},bindFeatureEditor:function(a){this.featureEditor=
  a;this.featureManager=a.getFeatureManager();this.featureManager.on("layerchange",this.onLayerChange,this)},unbindFeatureEditor:function(){this.featureManager&&(this.featureManager.featureStore&&this.featureManager.featureStore.un("write",this.onSave,this),this.featureManager.un("layerchange",this.onLayerChange,this),this.featureManager=null);this.featureEditor=null},guessTitleAttribute:function(a){var b=null;a.each(function(a){if("xsd:string"===a.get("type"))return b=a.get("name"),!1});return b},
  onLayerChange:function(a,b,c){var d=this.getKey(b),a=this.guessTitleAttribute(c);this.layerLookup[d]=Ext.apply({titleAttr:a,icon:Timeline.urlPrefix+"/images/note.png",layer:this.featureManager.featureLayer,visible:!0},this.annotationConfig);this.featureManager.on("query",function(a,b){var c=[];b.each(function(a){c.push(a.getFeature())});this.addFeatures(d,c)},this,{single:!0});if(this.featureManager.featureStore)this.featureManager.featureStore.on("write",this.onSave,this);this.annotationsRecord=
  b},onSave:function(a,b,c){for(var a=this.getKey(this.annotationsRecord),d=[],e=0,f=c.length;e<f;e++){var g=c[e].feature;d.push(g);g=g.fid;this.clearEventsForFid(a,g);this.tooltips&&this.tooltips[g]&&(this.tooltips[g].destroy(),this.tooltips[g]=null)}b!==Ext.data.Api.actions.destroy&&this.addFeatures(a,d);this.showAnnotations(this.playbackTool.playbackToolbar.control.currentTime)},bindPlaybackTool:function(a){this.playbackTool=a;this.playbackTool.on("timechange",this.onTimeChange,this);this.playbackTool.on("rangemodified",
  this.onRangeModify,this)},unbindPlaybackTool:function(){this.playbackTool&&(this.playbackTool.un("timechange",this.onTimeChange,this),this.playbackTool.un("rangemodified",this.onRangeModify,this),this.playbackTool=null)},onTimeChange:function(a,b){this._silent=!0;!0!==this._ignoreTimeChange&&this.setCenterDate(b);delete this._silent},onRangeModify:function(a,b){this._silent=!0;this.setRange(b);delete this._silent},createTimeline:function(a){if(this.rendered&&!(0===this.timelineContainer.el.getSize().width&&
  0===this.timelineContainer.el.getSize().height)){var b=Timeline.ClassicTheme.create(),c=a[1]-a[0],d=[];50<=c/1E3/60/60/24/365?(d.push(Timeline.DateTime.DECADE),d.push(Timeline.DateTime.CENTURY)):(d.push(Timeline.DateTime.YEAR),d.push(Timeline.DateTime.DECADE));a=new Date(a[0].getTime()+c/2);d=[Timeline.createBandInfo({width:"80%",intervalUnit:d[0],intervalPixels:200,eventSource:this.eventSource,date:a,theme:b,layout:"original",zoomIndex:7,zoomSteps:[{pixelsPerInterval:25,unit:d[0]},{pixelsPerInterval:50,
  unit:d[0]},{pixelsPerInterval:75,unit:d[0]},{pixelsPerInterval:100,unit:d[0]},{pixelsPerInterval:125,unit:d[0]},{pixelsPerInterval:150,unit:d[0]},{pixelsPerInterval:175,unit:d[0]},{pixelsPerInterval:200,unit:d[0]},{pixelsPerInterval:225,unit:d[0]},{pixelsPerInterval:250,unit:d[0]},{pixelsPerInterval:275,unit:d[0]},{pixelsPerInterval:300,unit:d[0]},{pixelsPerInterval:325,unit:d[0]},{pixelsPerInterval:350,unit:d[0]},{pixelsPerInterval:375,unit:d[0]}]}),Timeline.createBandInfo({width:"20%",intervalUnit:d[1],
  intervalPixels:200,eventSource:this.eventSource,date:a,theme:b,layout:"overview"})];d[1].syncWith=0;d[1].highlight=!0;d[0].decorators=[new Timeline.PointHighlightDecorator({date:a,theme:b})];this.timeline=Timeline.create(this.timelineContainer.el.dom,d,Timeline.HORIZONTAL);this._silent=!0;this.timeline.getBand(0).addOnScrollListener(this.setPlaybackCenter.createDelegate(this))}},setPlaybackCenter:function(a){a=a.getCenterVisibleDate();!0!==this._silent&&this.playbackTool&&!0!==this.playbackTool.playbackToolbar.playing&&
  (this._ignoreTimeChange=!0,this.playbackTool.setTime(a),this.timeline.getBand(0)._decorators[0]._date=a,this.timeline.getBand(0)._decorators[0].paint(),delete this._ignoreTimeChange,this.showAnnotations(a))},bindViewer:function(a){this.viewer&&this.unbindViewer();this.viewer=a;this.layerLookup||(this.layerLookup={});var b=a.mapPanel.layers;if(0<b.getCount())this.onLayerStoreAdd(b,b.getRange());b.on({add:this.onLayerStoreAdd,remove:this.onLayerStoreRemove,scope:this});a.mapPanel.map.events.on({moveend:this.onMapMoveEnd,
  scope:this})},unbindViewer:function(){var a=this.viewer&&this.viewer.mapPanel;a&&(a.layers.unregister("add",this.onLayerStoreAdd,this),a.layers.unregister("remove",this.onLayerStoreRemove,this),a.map.un({moveend:this.onMapMoveEnd,scope:this}));delete this.viewer;delete this.layerLookup;delete this.schemaCache;delete this.propertyNamesCache},getKey:function(a){return a.get("source")+"/"+a.get("name")},getTimeAttribute:function(a,b,c,d){var e=this.getKey(a);Ext.Ajax.request({method:"GET",url:this.timeInfoEndpoint,
  params:{layer:a.get("name")},success:function(f){(f=Ext.decode(f.responseText))&&d.call(this,f,e,a,b,c)},scope:this})},onLayerStoreRemove:function(a,b){var c=this.getKey(b);if(this.layerLookup[c]){var d=this.layerLookup[c].layer;d&&(this.clearEventsForKey(c),d.events.un({loadstart:this.onLoadStart,loadend:this.onLoadEnd,featuresremoved:this.onFeaturesRemoved,scope:this}),delete this.schemaCache[c],delete this.propertyNamesCache[c],delete this.layerLookup[c],d.destroy())}},parseSLD:function(a,b,c){var d=
  new OpenLayers.Format.SLD;this.sldCache[b]=d.read(a.responseXML||a.responseText);c&&c.call(this)},getFilterFromSLD:function(a,b){var c=this.sldCache[a];if(void 0===c)return!1;var d=[],e=!1,f;for(f in c.namedLayers)for(var g=0,h=c.namedLayers[f].userStyles.length;g<h;++g){var j=c.namedLayers[f].userStyles[g];if(""===b&&!0===j.isDefault||j.name===b)for(var k=0,l=j.rules.length;k<l;++k){var n=j.rules[k];if(!0===n.elseFilter){e=!0;break}else n.filter&&d.push(n.filter)}}return!0===e?!1:1===d.length?d[0]:
  0<d.length?new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.OR,filters:d}):!1},getSLD:function(a,b){var c=this.getKey(a),d=a.getLayer();Ext.Ajax.request({url:d.url,params:{SERVICE:"WMS",VERSION:"1.1.1",REQUEST:"GetStyles",LAYERS:""+d.params.LAYERS},method:"GET",disableCaching:!1,success:this.parseSLD.createDelegate(this,[c,b],1),scope:this})},onLayerStoreAdd:function(a,b){for(var c,d=0,e=b.length;d<e;++d){c=b[d];var f=c.getLayer();f.dimensions&&f.dimensions.time&&(f=this.viewer.getSource(c),
  gxp.plugins.WMSSource&&f instanceof gxp.plugins.WMSSource&&f.getWFSProtocol(c,function(a,b,c){if(!a)throw Error("Failed to get protocol for record: "+c.get("name"));var d=this.getKey(c);this.schemaCache[d]=b;var e=function(a,b,c,d,e){a.attribute&&(this.layerLookup[b]=Ext.applyIf(this.layerLookup[b]||{},{timeAttr:a.attribute,endTimeAttr:a.endAttribute,visible:!1}),this.addVectorLayer(c,d,e))},f;f=this.layerLookup&&this.layerLookup[d]&&this.layerLookup[d].timeAttr?function(){this.layerLookup[d].clientSideFilter&&
  (this.layerLookup[d].clientSideFilter=new OpenLayers.Filter(this.layerLookup[d].clientSideFilter));this.addVectorLayer(c,a,b)}:function(){this.getTimeAttribute(c,a,b,e)};this.sldCache[d]?f.call(this):this.getSLD(c,f)},this))}},onLayout:function(){gxp.TimelinePanel.superclass.onLayout.call(this,arguments);!this.timeline&&this.playbackTool&&this.playbackTool.playbackToolbar&&(this.setRange(this.playbackTool.playbackToolbar.control.range),this.setCenterDate(this.playbackTool.playbackToolbar.control.currentTime),
  delete this._silent)},findBestZoomLevel:function(a){if(this.timeline){this._silent=!0;var b=a[1]-a[0],a=this.timeline.getBand(0),c=a.getViewLength()/2;if(0<c){for(var b=b/a.getEther()._interval,c=c/b,d=Number.POSITIVE_INFINITY,e,f=0,g=a._zoomSteps.length;f<g;++f)b=Math.abs(a._zoomSteps[f].pixelsPerInterval-c),b<d&&(e=f),d=b;if(e!==a._zoomIndex)for(c=e<a._zoomIndex;e!=a._zoomIndex;)a.zoom(c);this.timeline.paint();delete this._silent}}},setRange:function(a){this.originalRange=a;this.timeline||this.createTimeline(a);
  if(this.timeline){var b=this.timeline.getBand(0);b.setMinVisibleDate(a[0]);b.setMaxVisibleDate(a[1]);this.timeline.getBand(1).getEtherPainter().setHighlight(a[0],a[1])}},updateRangeSlider:function(a){this.rangeSlider.startDate=a[0].dateFormat("Y-m-d");this.rangeSlider.endDate=a[1].dateFormat("Y-m-d")},displayTooltip:function(a){var b=null!==a.getFeature().geometry;this.tooltips||(this.tooltips={});var c=a.getFeature().fid;this.tooltips[c]||(this.tooltips[c]=b?new GeoExt.FeatureTip({map:this.viewer.mapPanel.map,
  location:a.getFeature(),cls:"gxp-annotations-tip",html:"<h4>"+a.get("title")+"</h4>"+a.get("content")}):new Ext.Tip({cls:"gxp-annotations-tip",html:"<h4>"+a.get("title")+"</h4>"+a.get("content")}));c=this.tooltips[c];b?c.show():(c.showBy(this.viewer.mapPanel.body,a.get("appearance"),[10,10]),c.showBy(this.viewer.mapPanel.body,a.get("appearance"),[10,10]))},hideTooltip:function(a){a=a.getFeature().fid;this.tooltips&&this.tooltips[a]&&this.tooltips[a].hide()},showAnnotations:function(a){this.annotationsLayer||
  (this.annotationsLayer=new OpenLayers.Layer.Vector(null,{displayInLayerSwitcher:!1,styleMap:new OpenLayers.StyleMap({"default":{label:"${title}\n${content}",fontColor:"black",fontSize:"12px",fontFamily:"Courier New, monospace",fontWeight:"bold",labelOutlineColor:"white",labelAlign:"middle",labelOutlineWidth:3}})}),this.viewer&&this.viewer.mapPanel.map.addLayer(this.annotationsLayer));var b=a.getTime()/1E3;this.featureManager&&this.featureManager.featureStore&&this.featureManager.featureStore.each(function(a){var d=
  this.annotationConfig.mapFilterAttr;if(Ext.isBoolean(a.get(d))?a.get(d):a.get(d)==="true"){var d=parseFloat(a.get(this.annotationConfig.timeAttr)),e=a.get(this.annotationConfig.endTimeAttr),f=e!=d;if(e==""||e==null)e=this.playbackTool.playbackToolbar.control.range[1].getTime();f===true?b<=parseFloat(e)&&b>=d?this.displayTooltip(a):this.hideTooltip(a):Math.abs(Math.abs(d)-Math.abs(b))/Math.abs(d)*100<=2.5?this.displayTooltip(a):this.hideTooltip(a)}},this)},setCenterDate:function(a){if(this.timeline&&
  (this.timeline.getBand(0)._decorators[0]._date=a,this.timeline.getBand(0)._decorators[0].paint(),this.timeline.getBand(0).setCenterVisibleDate(a),this.rangeInfo&&this.rangeInfo.current)){var b=this.rangeInfo.current,c=this.rangeInfo.original;if(a<c[0]||a>c[1]){var d=b[1]-b[0],c=new Date(a.getTime()-d/2),e=new Date(a.getTime()+d/2),c=new Date(Math.max(this.originalRange[0],c)),e=new Date(Math.min(this.originalRange[1],e));this.rangeInfo.current=[c,e];var f=new Date(a.getTime()-d/4),d=new Date(a.getTime()+
  d/4);this.rangeInfo.original=[f,d];c>b[0]&&c<b[1]&&(c=b[1]);c<b[0]&&e>b[0]&&(e=b[0]);for(var g in this.layerLookup)this.layerLookup[g].layer&&this.setTimeFilter(g,this.createTimeFilter([c,e],g,0,!1));this.updateTimelineEvents({force:!0,noAbort:!0},!0)}}this.showAnnotations(a)},calculateNewRange:function(a,b){if(this.playbackTool){void 0===b&&(b=this.rangeSlider.getValue());var c=this.playbackTool.playbackToolbar.control.currentTime,d=b/100*(a[1]-a[0]),e=new Date(c.getTime()-d/2),c=new Date(c.getTime()+
  d/2);return[e,c]}},createTimeFilter:function(a,b,c,d){var e=new Date(a[0].getTime()-c*(a[1]-a[0])),c=new Date(a[1].getTime()+c*(a[1]-a[0]));this.originalRange&&(e=new Date(Math.max(this.originalRange[0],e)),c=new Date(Math.min(this.originalRange[1],c)));!1!==d&&(this.rangeInfo={original:a,current:[e,c]});this.updateRangeSlider(this.rangeInfo.current);this.playbackTool&&!0!==this.playbackTool.playbackToolbar.playing&&this.findBestZoomLevel([e,c]);return this.layerLookup[b].endTimeAttr?new OpenLayers.Filter({type:OpenLayers.Filter.Logical.OR,
  filters:[new OpenLayers.Filter({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.layerLookup[b].timeAttr,lowerBoundary:OpenLayers.Date.toISOString(e),upperBoundary:OpenLayers.Date.toISOString(c)}),new OpenLayers.Filter({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.layerLookup[b].endTimeAttr,lowerBoundary:OpenLayers.Date.toISOString(e),upperBoundary:OpenLayers.Date.toISOString(c)})]}):new OpenLayers.Filter({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.layerLookup[b].timeAttr,
  lowerBoundary:OpenLayers.Date.toISOString(e),upperBoundary:OpenLayers.Date.toISOString(c)})},onLoadStart:function(){this.layerCount++;this.busyMask||(this.busyMask=new Ext.LoadMask(this.bwrap,{msg:this.loadingMessage}));this.busyMask.show()},onLoadEnd:function(){this.layerCount--;0===this.layerCount&&this.busyMask.hide()},createHitCountProtocol:function(a){return new OpenLayers.Protocol.WFS(Ext.apply({version:"1.1.0",readOptions:{output:"object"},resultType:"hits"},a))},assembleFullFilter:function(a){var b=
  this.layerLookup[a],a=[];!1!==b.sldFilter&&a.push(b.sldFilter);b.timeFilter&&a.push(b.timeFilter);b.clientSideFilter&&a.push(b.clientSideFilter);b=null;1===a.length?b=a[0]:1<a.length&&(b=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:a}));return b},setTimeFilter:function(a,b){this.layerLookup[a].timeFilter=b;this.layerLookup[a].layer&&(this.layerLookup[a].layer.filter=this.assembleFullFilter(a))},addVectorLayer:function(a,b,c){var d=this.getKey(a),a=a.getLayer().params.STYLES;
  this.layerLookup[d].sldFilter=this.getFilterFromSLD(d,a);this.playbackTool&&(a=this.playbackTool.playbackToolbar.control.range,a=this.calculateNewRange(a),this.setCenterDate(this.playbackTool.playbackToolbar.control.currentTime),this.setTimeFilter(d,this.createTimeFilter(a,d,this.bufferFraction)));a=this.assembleFullFilter(d);a=new OpenLayers.Layer.Vector(d,{strategies:[new OpenLayers.Strategy.BBOX({ratio:1.1,resFactor:1,autoActivate:!1})],filter:a,protocol:b,displayInLayerSwitcher:!1,visibility:!1});
  a.events.on({featuresadded:this.onFeaturesAdded.createDelegate(this,[d],1),featuresremoved:this.onFeaturesRemoved,scope:this});c=this.guessTitleAttribute(c);Ext.applyIf(this.layerLookup[d],{layer:a,titleAttr:c,hitCount:this.createHitCountProtocol(b.options)});this.viewer.mapPanel.map.addLayer(a)},onMapMoveEnd:function(){!0!==this._silentMapMove&&this.updateTimelineEvents();this.filterAnnotationsByBBOX()},filterAnnotationsByBBOX:function(){if(this.featureManager&&this.featureManager.featureStore){var a=
  [];this.featureManager.featureStore.each(function(b){b=b.getFeature();null!==b.geometry&&(b.geometry.getBounds().intersectsBounds(this.viewer.mapPanel.map.getExtent())||a.push(b.fid))},this);this.setFilterMatcher(function(b){return-1===a.indexOf(b.getProperty("fid"))})}},updateTimelineEvents:function(a,b){if(this.rendered){var c=[],d,e;for(e in this.layerLookup)if(d=this.layerLookup[e].layer,this.layerLookup[e].visible&&d&&null!==d.strategies){var f=this.layerLookup[e].hitCount,g=d.strategies[0].bounds;
  d.strategies[0].calculateBounds();var h=new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,value:d.strategies[0].bounds,projection:d.projection});d.strategies[0].bounds=g;d.filter&&(h=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:[d.filter,h]}));f.filter=f.options.filter=h;c.push(function(a,b){this.read({callback:function(c){void 0===b.numberOfFeatures&&(b.numberOfFeatures=0);b.numberOfFeatures+=c.numberOfFeatures;a()}})}.createDelegate(f))}gxp.util.dispatch(c,
  function(c){if(c.numberOfFeatures<=this.maxFeatures)for(e in this.timelineContainer.el.unmask(!0),this.layerLookup){if((d=this.layerLookup[e].layer)&&null!==d.strategies){!0===b?this.clearInvisibleEvents(e):this.clearEventsForKey(e);var c=this.schemaCache[e],f=this.propertyNamesCache[e];f||(f=[],c.each(function(a){var b=a.get("name");a.get("type").match(/^[^:]*:?((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry))/)||f.push(b)}),this.propertyNamesCache[e]=f);a=a||{};a.propertyNames=f;d.strategies[0].activate();
  d.strategies[0].update(a)}}else{for(e in this.layerLookup)(d=this.layerLookup[e].layer)&&null!==d.strategies&&d.strategies[0].deactivate();this.timelineContainer.el.mask(isNaN(c.numberOfFeatures)?this.errorText:(new Ext.Template(this.instructionText)).applyTemplate({count:c.numberOfFeatures,max:this.maxFeatures}),"");this.eventSource.clear()}},this)}},clearEventsForKey:function(a){for(var b=this.eventSource.getAllEventIterator(),c=[];b.hasNext();){var d=b.next();d.getProperty("key")===a&&c.push(d.getID())}a=
  0;for(b=c.length;a<b;++a)this.eventSource.remove(c[a]);this.timeline&&this.timeline.layout()},clearInvisibleEvents:function(a){if(this.timeline){for(var b=this.timeline.getBand(0),c=b.getMinVisibleDate(),d=b.getMaxVisibleDate(),e=this.eventSource.getAllEventIterator(),b=[];e.hasNext();){var f=e.next(),g=f.getProperty("start"),g=g>=c&&g<=d;f.getProperty("key")===a&&!g&&b.push(f.getID())}a=0;for(c=b.length;a<c;++a)this.eventSource.remove(b[a]);this.timeline.layout()}},clearEventsForRange:function(a,
  b){for(var c=this.eventSource.getAllEventIterator(),d=[];c.hasNext();){var e=c.next(),f=e.getProperty("start");e.getProperty("key")===a&&f>=b[0]&&f<=b[1]&&d.push(e.getID())}c=0;for(e=d.length;c<e;++c)this.eventSource.remove(d[c]);this.timeline&&this.timeline.layout()},clearEventsForFid:function(a,b){for(var c=this.eventSource.getAllEventIterator(),d=[];c.hasNext();){var e=c.next();e.getProperty("key")===a&&e.getProperty("fid")===b&&d.push(e.getID())}c=0;for(e=d.length;c<e;++c)this.eventSource.remove(d[c]);
  this.timeline&&this.timeline.layout()},onFeaturesRemoved:function(a){for(var b=0,c=a.features.length;b<c;b++)a.features[b].destroy()},addFeatures:function(a,b){var c=!1,d=this.layerLookup[a].titleAttr,e=this.layerLookup[a].timeAttr,f=this.layerLookup[a].endTimeAttr,g=this.layerLookup[a].filterAttr;f&&(c=!0);for(var h=b.length,j=[],k,l=0;l<h;++l)if(k=b[l].attributes,!1===c)j.push({start:OpenLayers.Date.parse(k[e]),title:k[d],durationEvent:!1,key:a,icon:this.layerLookup[a].icon,fid:b[l].fid});else if(Ext.isBoolean(k[g])?
  k[g]:"true"===k[g]){var n=k[e],m=k[f],o=n!=m;Ext.isEmpty(n)||(n=parseFloat(n),n=Ext.isNumber(n)?new Date(1E3*n):OpenLayers.Date.parse(n));Ext.isEmpty(m)||(m=parseFloat(m),m=Ext.isNumber(m)?new Date(1E3*m):OpenLayers.Date.parse(m));if(!1===o)m=void 0;else if(""==m||null==m)m=this.playbackTool.playbackToolbar.control.range[1];j.push({start:n,end:m,icon:this.layerLookup[a].icon,title:k[d],durationEvent:o,key:a,fid:b[l].fid})}this.eventSource.loadJSON({dateTimeFormat:"javascriptnative",events:j},"mapstory.org")},
  onFeaturesAdded:function(a,b){this.addFeatures(b,a.features)},onResize:function(){gxp.TimelinePanel.superclass.onResize.apply(this,arguments);this.timeline&&this.timeline.layout()},beforeDestroy:function(){gxp.TimelinePanel.superclass.beforeDestroy.call(this);for(var a in this.layerLookup){var b=this.layerLookup[a].layer;b&&(b.events.un({loadstart:this.onLoadStart,loadend:this.onLoadEnd,featuresremoved:this.onFeaturesRemoved,scope:this}),b.destroy())}this.annotationsLayer=this.annotationsRecord=null;
  this.destroyPopup();this.unbindViewer();this.unbindFeatureEditor();this.unbindPlaybackTool();this.rendered&&Ext.destroy(this.busyMask);this.eventSource=null;this.timeline&&(this.timeline.dispose(),this.timeline=null);this.busyMask=null},getState:function(){var a={layerLookup:{}},b;for(b in this.layerLookup){var c=this.layerLookup[b];a.layerLookup[b]={titleAttr:c.titleAttr,timeAttr:c.timeAttr,endTimeAttr:c.endTimeAttr,visible:c.visible,clientSideFilter:c.clientSideFilter}}return a}});
  Ext.reg("gxp_timelinepanel",gxp.TimelinePanel);Ext.namespace("gxp.plugins");
  gxp.plugins.Timeline=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_timeline",playbackTool:null,featureEditor:null,menuText:"Timeline",tooltip:"Show Timeline",actionTarget:null,constructor:function(a){gxp.plugins.Timeline.superclass.constructor.apply(this,arguments);this.outputConfig||(this.outputConfig={});Ext.applyIf(this.outputConfig,{title:this.menuText})},addActions:function(){return gxp.plugins.Timeline.superclass.addActions.apply(this,[[{menuText:this.menuText,tooltip:this.tooltip,handler:function(){this.addOutput()},
  scope:this}]])},addOutput:function(){return gxp.plugins.Timeline.superclass.addOutput.call(this,Ext.apply({xtype:"gxp_timelinepanel",viewer:this.target,featureEditor:this.target.tools[this.featureEditor],playbackTool:this.target.tools[this.playbackTool]},this.outputConfig))},getTimelinePanel:function(){return this.output[0]},getState:function(){var a=gxp.plugins.Timeline.superclass.getState.call(this);a.outputConfig=Ext.apply(a.outputConfig||{},this.getTimelinePanel().getState());return a}});
  Ext.preg(gxp.plugins.Timeline.prototype.ptype,gxp.plugins.Timeline);Ext.namespace("gxp.plugins");
  gxp.plugins.Measure=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_measure",outputTarget:"map",lengthMenuText:"Length",areaMenuText:"Area",lengthTooltip:"Measure length",areaTooltip:"Measure area",measureTooltip:"Measure",constructor:function(a){gxp.plugins.Measure.superclass.constructor.apply(this,arguments)},destroy:function(){this.button=null;gxp.plugins.Measure.superclass.destroy.apply(this,arguments)},createMeasureControl:function(a,b){var c=new OpenLayers.StyleMap({"default":new OpenLayers.Style(null,
  {rules:[new OpenLayers.Rule({symbolizer:{Point:{pointRadius:4,graphicName:"square",fillColor:"white",fillOpacity:1,strokeWidth:1,strokeOpacity:1,strokeColor:"#333333"},Line:{strokeWidth:3,strokeOpacity:1,strokeColor:"#666666",strokeDashstyle:"dash"},Polygon:{strokeWidth:2,strokeOpacity:1,strokeColor:"#666666",fillColor:"white",fillOpacity:0.3}}})]})}),d=function(){f&&f.destroy()},e=function(a){var b=a.measure,c=a.units;h.displaySystem="english";var d=-1<a.geometry.CLASS_NAME.indexOf("LineString")?
  h.getBestLength(a.geometry):h.getBestArea(a.geometry),e=d[0],d=d[1];h.displaySystem="metric";a=2==a.order?"<sup>2</sup>":"";return b.toFixed(2)+" "+c+a+"<br>"+e.toFixed(2)+" "+d+a},f,g=Ext.apply({},this.initialConfig.controlOptions);Ext.applyIf(g,{geodesic:!0,persist:!0,handlerOptions:{layerOptions:{styleMap:c}},eventListeners:{measurepartial:function(a){d();f=this.addOutput({xtype:"tooltip",html:e(a),title:b,autoHide:!1,closable:!0,draggable:!1,mouseOffset:[0,0],showDelay:1,listeners:{hide:d}});
  if(0<a.measure){var a=h.handler.lastUp,c=this.target.mapPanel.getPosition();f.targetXY=[c[0]+a.x,c[1]+a.y];f.show()}},deactivate:d,scope:this}});var h=new OpenLayers.Control.Measure(a,g);return h},addActions:function(){this.activeIndex=0;this.button=new Ext.SplitButton({iconCls:"gxp-icon-measure-length",tooltip:this.measureTooltip,enableToggle:!0,toggleGroup:this.toggleGroup,allowDepress:!0,handler:function(a){a.pressed&&a.menu.items.itemAt(this.activeIndex).setChecked(!0)},scope:this,listeners:{toggle:function(a,
  b){b||a.menu.items.each(function(a){a.setChecked(!1)})},render:function(a){Ext.ButtonToggleMgr.register(a)}},menu:new Ext.menu.Menu({items:[new Ext.menu.CheckItem(new GeoExt.Action({text:this.lengthMenuText,iconCls:"gxp-icon-measure-length",toggleGroup:this.toggleGroup,group:this.toggleGroup,listeners:{checkchange:function(a,b){this.activeIndex=0;this.button.toggle(b);b&&this.button.setIconClass(a.iconCls)},scope:this},map:this.target.mapPanel.map,control:this.createMeasureControl(OpenLayers.Handler.Path,
  this.lengthTooltip)})),new Ext.menu.CheckItem(new GeoExt.Action({text:this.areaMenuText,iconCls:"gxp-icon-measure-area",toggleGroup:this.toggleGroup,group:this.toggleGroup,allowDepress:!1,listeners:{checkchange:function(a,b){this.activeIndex=1;this.button.toggle(b);b&&this.button.setIconClass(a.iconCls)},scope:this},map:this.target.mapPanel.map,control:this.createMeasureControl(OpenLayers.Handler.Polygon,this.areaTooltip)}))]})});return gxp.plugins.Measure.superclass.addActions.apply(this,[this.button])}});
  Ext.preg(gxp.plugins.Measure.prototype.ptype,gxp.plugins.Measure);Ext.namespace("gxp");
  gxp.NewSourceDialog=Ext.extend(Ext.Panel,{title:"Add New Server...",cancelText:"Cancel",addServerText:"Add Server",invalidURLText:"Enter a valid URL to a WMS endpoint (e.g. http://example.com/geoserver/wms)",contactingServerText:"Contacting Server...",bodyStyle:"padding: 0px",error:null,initComponent:function(){this.addEvents("urlselected");this.urlTextField=new Ext.form.TextField({fieldLabel:"URL",allowBlank:!1,width:240,msgTarget:"under",validator:this.urlValidator.createDelegate(this)});this.form=
  new Ext.form.FormPanel({items:[this.urlTextField],border:!1,labelWidth:30,bodyStyle:"padding: 5px",autoWidth:!0,autoHeight:!0});this.bbar=[new Ext.Button({text:this.cancelText,handler:this.hide,scope:this}),new Ext.Toolbar.Fill,new Ext.Button({text:this.addServerText,iconCls:"add",handler:function(){this.error=null;this.urlTextField.validate()&&this.fireEvent("urlselected",this,this.urlTextField.getValue())},scope:this})];this.items=this.form;gxp.NewSourceDialog.superclass.initComponent.call(this);
  this.form.on("render",function(){this.loadMask=new Ext.LoadMask(this.form.getEl(),{msg:this.contactingServerText})},this);this.on({hide:this.reset,removed:this.reset,scope:this});this.on("urlselected",function(a,b){this.setLoading();this.addSource(b,this.hide,function(){this.setError(this.sourceLoadFailureMessage)},this)},this)},reset:function(){this.error=null;this.urlTextField.reset();this.loadMask.hide()},urlRegExp:/^(http(s)?:)?\/\/([\w%]+:[\w%]+@)?([^@\/:]+)(:\d+)?\//i,urlValidator:function(a){a=
  this.urlRegExp.test(a)?!this.error||this.error:this.invalidURLText;this.error=null;return a},setLoading:function(){this.loadMask.show()},setError:function(a){this.loadMask.hide();this.error=a;this.urlTextField.validate()},addSource:function(){}});Ext.reg("gxp_newsourcedialog",gxp.NewSourceDialog);Ext.namespace("gxp.plugins");
  gxp.plugins.AddLayers=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_addlayers",addActionMenuText:"Add layers",findActionMenuText:"Find layers",addActionTip:"Add layers",addServerText:"Add a New Server",addButtonText:"Add layers",untitledText:"Untitled",addLayerSourceErrorText:"Error getting WMS capabilities ({msg}).\nPlease check the url and try again.",availableLayersText:"Available Layers",expanderTemplateText:"<p><b>Abstract:</b> {abstract}</p>",panelTitleText:"Title",layerSelectionText:"View available data from:",
  doneText:"Done",uploadText:"Upload Data",relativeUploadOnly:!0,startSourceId:null,selectedSource:null,constructor:function(a){this.addEvents("sourceselected");gxp.plugins.AddLayers.superclass.constructor.apply(this,arguments)},addActions:function(){var a={tooltip:this.addActionTip,text:this.addActionText,menuText:this.addActionMenuText,disabled:!0,iconCls:"gxp-icon-addlayers"},a=this.initialConfig.search?Ext.apply(a,{menu:new Ext.menu.Menu({items:[new Ext.menu.Item({iconCls:"gxp-icon-addlayers",text:this.addActionMenuText,
  handler:this.showCapabilitiesGrid,scope:this}),new Ext.menu.Item({iconCls:"gxp-icon-addlayers",text:this.findActionMenuText,handler:this.showCatalogueSearch,scope:this})]})}):Ext.apply(a,{handler:this.showCapabilitiesGrid,scope:this}),b=gxp.plugins.AddLayers.superclass.addActions.apply(this,[a]);this.target.on("ready",function(){b[0].enable()});return b},showCatalogueSearch:function(){var a=this.initialConfig.search.selectedSource,b={},c;for(c in this.target.layerSources){var d=this.target.layerSources[c];
  if(d instanceof gxp.plugins.CatalogueSource){var e={};e[c]=d;Ext.apply(b,e)}}a=gxp.plugins.AddLayers.superclass.addOutput.apply(this,[{sources:b,selectedSource:a,xtype:"gxp_cataloguesearchpanel",map:this.target.mapPanel.map,listeners:{addlayer:function(a,b,c){this.target.mapPanel.layers.add(this.target.layerSources[b].createLayerRecord(c))},scope:this}}]);(b=a.findParentByType("window"))&&b.center();return a},showCapabilitiesGrid:function(){this.capGrid||this.initCapGrid();this.capGrid.show()},initCapGrid:function(){function a(){for(var a=
  j.getValue(),b=this.target.mapPanel.layers,c=this.target.layerSources[a],d=h.getSelectionModel().getSelections(),e,f=0,g=d.length;f<g;++f)(e=c.createLayerRecord({name:d[f].get("name"),source:a}))&&("background"===e.get("group")?b.insert(0,[e]):b.add([e]))}var b,c=[],d=this.target,e;for(e in d.layerSources)b=d.layerSources[e],b.store&&"gxp_cataloguesource"!==b.ptype&&c.push([e,b.title||e,b.url]);var f=new Ext.data.ArrayStore({fields:["id","title","url"],data:c}),d=this.createExpander(),g=0;null!==
  this.startSourceId&&f.each(function(a){a.get("id")===this.startSourceId&&(g=f.indexOf(a))},this);b=this.target.layerSources[c[g][0]];var h=new Ext.grid.GridPanel({store:b.store,autoScroll:!0,flex:1,autoExpandColumn:"title",plugins:[d],loadMask:!0,colModel:new Ext.grid.ColumnModel([d,{id:"title",header:this.panelTitleText,dataIndex:"title",sortable:!0},{header:"Id",dataIndex:"name",width:150,sortable:!0}]),listeners:{rowdblclick:a,scope:this}}),j=new Ext.form.ComboBox({ref:"../sourceComboBox",store:f,
  valueField:"id",displayField:"title",tpl:'<tpl for="."><div ext:qtip="{url}" class="x-combo-list-item">{title}</div></tpl>',triggerAction:"all",editable:!1,allowBlank:!1,forceSelection:!0,mode:"local",value:c[g][0],listeners:{select:function(a,b){var c=this.target.layerSources[b.get("id")];h.reconfigure(c.store,h.getColumnModel());h.getView().focusRow(0);this.setSelectedSource(c)},scope:this}});b=null;if(this.target.proxy||1<c.length)b=[new Ext.Toolbar.TextItem({text:this.layerSelectionText}),j];
  this.target.proxy&&b.push("-",new Ext.Button({text:this.addServerText,iconCls:"gxp-icon-addserver",handler:function(){this.outputTarget?this.addOutput(k):(new Ext.Window({title:gxp.NewSourceDialog.prototype.title,modal:!0,hideBorders:!0,width:300,items:k})).show()},scope:this}));var k={xtype:"gxp_newsourcedialog",header:!1,listeners:{hide:function(a){this.outputTarget||a.ownerCt.hide()},urlselected:function(a,b){a.setLoading();this.target.addLayerSource({config:{url:b},callback:function(b){b=new f.recordType({id:b,
  title:this.target.layerSources[b].title||this.untitledText});f.insert(0,[b]);j.onSelect(b,0);a.hide()},fallback:function(a,b){this.setError((new Ext.Template(this.addLayerSourceErrorText)).apply({msg:b}))},scope:this})},scope:this}},d={xtype:"container",region:"center",layout:"vbox",items:[h]};this.instructionsText&&d.items.push({xtype:"box",autoHeight:!0,autoEl:{tag:"p",cls:"x-form-item",style:"padding-left: 5px; padding-right: 5px"},html:this.instructionsText});e=["->",new Ext.Button({text:this.addButtonText,
  iconCls:"gxp-icon-addlayers",handler:a,scope:this}),new Ext.Button({text:this.doneText,handler:function(){this.capGrid.hide()},scope:this})];var l=this.createUploadButton();l&&e.unshift(l);l=this.outputTarget?Ext.Panel:Ext.Window;this.capGrid=new l(Ext.apply({title:this.availableLayersText,closeAction:"hide",layout:"border",height:300,width:450,modal:!0,items:d,tbar:b,bbar:e,listeners:{hide:function(){h.getSelectionModel().clearSelections()},show:function(){null===this.selectedSource?this.setSelectedSource(this.target.layerSources[c[g][0]]):
  this.setSelectedSource(this.selectedSource)},scope:this}},this.initialConfig.outputConfig));l===Ext.Panel&&this.addOutput(this.capGrid)},setSelectedSource:function(a){this.selectedSource=a;this.fireEvent("sourceselected",this,a);a.lazy&&a.store.load({callback:function(){var a=this.capGrid.sourceComboBox,c=a.store,d=a.valueField,e=c.findExact(d,a.getValue()),e=c.getAt(e),f=this.target.layerSources[e.get("id")];f?f.title!==e.get("title")&&(e.set("title",f.title),a.setValue(e.get(d))):c.remove(e)}.createDelegate(this)})},
  createUploadButton:function(){var a,b=this.initialConfig.upload,c;if(b){"boolean"===typeof b&&(b={});a=new Ext.Button({xtype:"button",text:this.uploadText,iconCls:"gxp-icon-filebrowse",hidden:!0,handler:function(){var a=new gxp.LayerUploadPanel(Ext.apply({title:this.outputTarget?this.uploadText:void 0,url:c,width:350,border:!1,bodyStyle:"padding: 10px 10px 0 10px;",frame:!0,labelWidth:65,autoScroll:!0,defaults:{anchor:"95%",allowBlank:!1,msgTarget:"side"},listeners:{uploadcomplete:function(a,b){for(var c=
  b.layers,e={},f=0,m=c.length;f<m;++f)e[c[f].name]=!0;this.selectedSource.store.load({callback:function(){var a=this.capGrid.get(0).get(0),b=a.getSelectionModel();b.clearSelections();var c=[],d=0;this.selectedSource.store.each(function(a,b){a.get("name")in e&&(d=b,c.push(a))});b.selectRecords(c);window.setTimeout(function(){a.getView().focusRow(d)},100)},scope:this});this.outputTarget?a.hide():d.close()},scope:this}},b)),d;this.outputTarget?this.addOutput(a):(d=new Ext.Window({title:this.uploadText,
  modal:!0,resizable:!1,items:[a]}),d.show())},scope:this});var d={},e=function(a,b,c){a in d?window.setTimeout(function(){b.call(c,d[a])},0):Ext.Ajax.request({url:a,disableCaching:!1,callback:function(e,k,l){e=l.status;d[a]=e;b.call(c,e)}})};this.on({sourceselected:function(b,d){a.hide();if(this.isEligibleForUpload(d)){var h=d.url.split("/");h.pop();h.push("rest");c=h.join("/");this.target.isAuthorized()&&e(c+"/upload",function(b){a.setVisible(405===b)},this)}},scope:this})}return a},isEligibleForUpload:function(a){return a.url&&
  (this.relativeUploadOnly?"/"===a.url.charAt(0):!0)&&-1===(this.nonUploadSources||[]).indexOf(a.id)},createExpander:function(){return new Ext.grid.RowExpander({tpl:new Ext.Template(this.expanderTemplateText)})}});Ext.preg(gxp.plugins.AddLayers.prototype.ptype,gxp.plugins.AddLayers);Ext.namespace("gxp.slider");
  gxp.slider.ClassBreakSlider=Ext.extend(Ext.slider.MultiSlider,{store:null,initComponent:function(){this.store=Ext.StoreMgr.lookup(this.store);"constrainThumbs"in this.initialConfig||(this.constrainThumbs=this.store.reader.raw instanceof OpenLayers.Style);this.values=this.storeToValues();this.on("changecomplete",this.valuesToStore);this.store.on("update",this.storeToValues,this);gxp.slider.ClassBreakSlider.superclass.initComponent.call(this)},storeToValues:function(){var a=[];this.store.each(function(b){var d=
  b.get("filter");d instanceof OpenLayers.Filter?d.type===OpenLayers.Filter.Comparison.BETWEEN?(0===this.store.indexOf(b)&&a.push(d.lowerBoundary),a.push(d.upperBoundary)):d.type===OpenLayers.Filter.Comparison.LESS_THAN&&a.push(d.value):a.push(d)},this);if(this.thumbs)for(var b=a.length-1;0<=b;--b)this.setValue(b,a[b]);return a},valuesToStore:function(){var a=this.getValues(),b=this.store;b.un("update",this.storeToValues,this);b.each(function(b){var d=b.get("filter"),e=a.shift();d instanceof OpenLayers.Filter?
  (d=d.clone(),d.type===OpenLayers.Filter.Comparison.BETWEEN?d.upperBoundary=e:d.type===OpenLayers.Filter.Comparison.LESS_THAN&&(d.value=e),b.get("filter").toString()!==d.toString()&&b.set("filter",d)):d!=e&&b.set("filter",e)},this);b.on("update",this.storeToValues,this)}});Ext.reg("gxp_classbreakslider",gxp.slider.ClassBreakSlider);Ext.namespace("gxp.plugins");
  gxp.plugins.LayerTree=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_layertree",shortTitle:"Layers",rootNodeText:"Layers",overlayNodeText:"Overlays",baseNodeText:"Base Layers",groups:null,defaultGroup:"default",treeNodeUI:null,constructor:function(a){gxp.plugins.LayerTree.superclass.constructor.apply(this,arguments);this.groups||(this.groups={"default":this.overlayNodeText,background:{title:this.baseNodeText,exclusive:!0}});this.treeNodeUI||(this.treeNodeUI=Ext.extend(GeoExt.tree.LayerNodeUI,new GeoExt.tree.TreeNodeUIEventMixin))},
  addOutput:function(a){a=Ext.apply(this.createOutputConfig(),a||{});return gxp.plugins.LayerTree.superclass.addOutput.call(this,a)},createOutputConfig:function(){var a=new Ext.tree.TreeNode({text:this.rootNodeText,expanded:!0,isTarget:!1,allowDrop:!1}),b=this.defaultGroup,c=this,d,e;for(e in this.groups)d="string"==typeof this.groups[e]?{title:this.groups[e]}:this.groups[e],a.appendChild(new GeoExt.tree.LayerContainer(Ext.apply({text:d.title,iconCls:"gxp-folder",expanded:!0,group:e==this.defaultGroup?
  void 0:e,loader:new GeoExt.tree.LayerLoader({baseAttrs:d.exclusive?{checkedGroup:e}:void 0,store:this.target.mapPanel.layers,filter:function(a){return function(c){return(c.get("group")||b)==a&&!0==c.getLayer().displayInLayerSwitcher}}(e),createNode:function(a){c.configureLayerNode(this,a);return GeoExt.tree.LayerLoader.prototype.createNode.apply(this,arguments)}}),singleClickExpand:!0,allowDrag:!1,listeners:{append:function(a,b){b.expand()}}},d)));return{xtype:"treepanel",root:a,rootVisible:!1,shortTitle:this.shortTitle,
  border:!1,enableDD:!0,selModel:new Ext.tree.DefaultSelectionModel({listeners:{beforeselect:this.handleBeforeSelect,scope:this}}),listeners:{contextmenu:this.handleTreeContextMenu,beforemovenode:this.handleBeforeMoveNode,scope:this},contextMenu:new Ext.menu.Menu({items:[]})}},configureLayerNode:function(a,b){b.uiProvider=this.treeNodeUI;var c=b.layer,d=b.layerStore;if(c&&d){var e=d.getAt(d.findBy(function(a){return a.getLayer()===c}));e&&(b.qtip=e.get("name"),e.get("queryable")||(b.iconCls="gxp-tree-rasterlayer-icon"),
  e.get("fixed")&&(b.allowDrag=!1),b.listeners={rendernode:function(a){e===this.target.selectedLayer&&a.select();this.target.on("layerselectionchange",function(b){!this.selectionChanging&&b===e&&a.select()},this)},scope:this})}},handleBeforeSelect:function(a,b){var c=!0,d=b&&b.layer,e;d&&(c=b.layerStore,e=c.getAt(c.findBy(function(a){return a.getLayer()===d})));this.selectionChanging=!0;c=this.target.selectLayer(e);this.selectionChanging=!1;return c},handleTreeContextMenu:function(a,b){if(a&&a.layer){a.select();
  var c=a.getOwnerTree();c.getSelectionModel().getSelectedNode()===a&&(c=c.contextMenu,c.contextNode=a,0<c.items.getCount()&&c.showAt(b.getXY()))}},handleBeforeMoveNode:function(a,b,c,d){c!==d&&(a=d.loader.store,c=a.findBy(function(a){return a.getLayer()===b.layer}),a.getAt(c).set("group",d.attributes.group))}});Ext.preg(gxp.plugins.LayerTree.prototype.ptype,gxp.plugins.LayerTree);Ext.namespace("gxp.plugins");
  gxp.plugins.CatalogueSource=Ext.extend(gxp.plugins.WMSSource,{ptype:"gxp_cataloguesource",url:null,title:null,lazy:!0,createStore:function(){this.store=new Ext.data.Store({proxy:new GeoExt.data.ProtocolProxy({setParamsAsOptions:!0,protocol:new OpenLayers.Protocol.CSW({url:this.url})}),reader:new GeoExt.data.CSWRecordsReader({fields:"title,abstract,URI,bounds,projection,references".split(",")})});this.fireEvent("ready",this)},describeLayer:function(a,b,c){a=new (Ext.data.Record.create([{name:"owsType",
  type:"string"},{name:"owsURL",type:"string"},{name:"typeName",type:"string"}]))({owsType:"WFS",owsURL:a.get("url"),typeName:a.get("name")});b.call(c,a)},destroy:function(){this.store&&this.store.destroy();this.store=null;gxp.plugins.CatalogueSource.superclass.destroy.apply(this,arguments)}});Ext.preg(gxp.plugins.CatalogueSource.prototype.ptype,gxp.plugins.CatalogueSource);Ext.namespace("gxp.form");
  gxp.form.PlaybackModeComboBox=Ext.extend(Ext.form.ComboBox,{modeFieldText:"Playback Mode",normalOptText:"Normal",cumulativeOptText:"Cumulative",rangedOptText:"Ranged",modes:[],defaultMode:!1,timeAgents:null,allowBlank:!1,mode:"local",triggerAction:"all",editable:!1,constructor:function(a){this.addEvents({modechange:!0});!a.modes&&!this.modes.length&&this.modes.push([!1,this.normalOptText],["cumulative",this.cumulativeOptText],["ranged",this.rangedOptText]);gxp.form.PlaybackModeComboBox.superclass.constructor.call(this,
  a)},initComponent:function(){Ext.applyIf(this,{displayField:"field2",valueField:"field1",store:this.modes,value:this.defaultMode,listeners:{select:this.setPlaybackMode,scope:this}});gxp.form.PlaybackModeComboBox.superclass.initComponent.call(this)},setPlaybackMode:function(a,b){this.timeAgents||(this.timeAgents=this.guessTimeAgents());var c=b.get("field1");Ext.each(this.timeAgents,function(a){a.rangeMode=c;if(c=="range"&&!a.rangeInterval)a.rangeInterval=1});this.fireEvent("modechange",this,c,this.timeAgents)},
  guessTimeAgents:function(){}});Ext.reg("gxp_playbackmodecombo",gxp.form.PlaybackModeComboBox);Ext.namespace("gxp");
  gxp.PlaybackOptionsPanel=Ext.extend(Ext.Panel,{layout:"fit",titleText:"Date & Time Options",rangeFieldsetText:"Time Range",animationFieldsetText:"Animation Options",startText:"Start",endText:"End",listOnlyText:"Use Exact List Values Only",stepText:"Animation Step",unitsText:"Animation Units",noUnitsText:"Snap To Time List",loopText:"Loop Animation",reverseText:"Reverse Animation",rangeChoiceText:"Choose the range for the time control",rangedPlayChoiceText:"Playback Mode",initComponent:function(){var a=
  Ext.applyIf(this.initialConfig,{minHeight:400,minWidth:275,ref:"optionsPanel",items:[{xtype:"form",layout:"form",ref:"form",labelWidth:10,defaultType:"textfield",items:[{xtype:"fieldset",title:this.rangeFieldsetText,defaultType:"datefield",labelWidth:60,items:[{xtype:"displayfield",text:this.rangeChoiceText},{fieldLabel:this.startText,listeners:{select:this.setStartTime,change:this.setStartTime,scope:this},ref:"../../rangeStartField"},{fieldLabel:this.endText,listeners:{select:this.setEndTime,change:this.setEndTime,
  scope:this},ref:"../../rangeEndField"}]},{xtype:"fieldset",title:this.animationFieldsetText,labelWidth:100,items:[{boxLabel:this.listOnlyText,hideLabel:!0,xtype:"checkbox",handler:this.toggleListMode,scope:this,ref:"../../listOnlyCheck"},{fieldLabel:this.stepText,xtype:"numberfield",anchor:"-25",enableKeyEvents:!0,listeners:{change:this.setStep,scope:this},ref:"../../stepValueField"},{fieldLabel:this.unitsText,xtype:"combo",anchor:"-5",store:[[OpenLayers.TimeUnit.SECONDS,"Seconds"],[OpenLayers.TimeUnit.MINUTES,
  "Minutes"],[OpenLayers.TimeUnit.HOURS,"Hours"],[OpenLayers.TimeUnit.DAYS,"Days"],[OpenLayers.TimeUnit.MONTHS,"Months"],[OpenLayers.TimeUnit.YEARS,"Years"]],valueNotFoundText:this.noUnitsText,mode:"local",forceSelection:!0,autoSelect:!1,editable:!1,triggerAction:"all",listeners:{select:this.setUnits,scope:this},ref:"../../stepUnitsField"},{fieldLabel:this.rangedPlayChoiceText,xtype:"gxp_playbackmodecombo",timeAgents:this.timeManager&&this.timeManager.timeAgents,anchor:"-5",listeners:{modechange:this.setPlaybackMode,
  scope:this},ref:"../../playbackModeField"}]},{xtype:"checkbox",boxLabel:this.loopText,handler:this.setLoopMode,scope:this,ref:"../loopModeCheck"},{xtype:"checkbox",boxLabel:this.reverseText,handler:this.setReverseMode,scope:this,ref:"../reverseModeCheck"}]}],listeners:{show:this.populateForm,scope:this},bbar:[{text:"Save",handler:this.saveValues,scope:this},{text:"Cancel",handler:this.cancelChanges,scope:this}]});Ext.apply(this,a);gxp.PlaybackOptionsPanel.superclass.initComponent.call(this)},destroy:function(){this.playbackToolbar=
  this.timeManager=null;this.un("show",this,this.populateForm);gxp.PlaybackOptionsPanel.superclass.destroy.call(this)},setStartTime:function(a,b){this.timeManager.setStart(b);this.timeManager.fixedRange=!0},setEndTime:function(a,b){this.timeManager.setEnd(b);this.timeManager.fixedRange=!0},toggleListMode:function(a,b){this.stepValueField.setDisabled(b);this.stepUnitsField.setDisabled(b);this.timeManager.snapToIntervals=b},setUnits:function(a,b){var c=b.get("field1");this.timeManager.units!=c&&(this.timeManager.units=
  c,"track"!=this.playbackToolbar.playbackMode&&this.timeManager.incrementTime())},setStep:function(a,b){a.validate()&&b&&(this.timeManager.step=b,"ranged"==this.playbackToolbar.playbackMode&&this.timeManager.rangeInterval!=b&&(this.timeManager.rangeInterval=b,this.timeManager.incrementTime(b)))},setPlaybackMode:function(a,b){switch(b){case "cumulative":this.playbackToolbar.setPlaybackMode("cumulative");break;case "ranged":this.disableListMode(!0);this.playbackToolbar.setPlaybackMode("ranged");break;
  default:this.playbackToolbar.setPlaybackMode("track")}"ranged"!=b&&this.disableListMode(!1)},disableListMode:function(a){(a=!1!==a)&&this.listOnlyCheck.setValue(!a);this.listOnlyCheck.setDisabled(a)},setLoopMode:function(a,b){this.timeManager.loop=b},setReverseMode:function(){this.timeManager.step*=-1},populateForm:function(){if(this.timeManager){this.rangeStartField.setValue(this.timeManager.range[0]);this.rangeStartField.originalValue=this.timeManager.range[0];this.rangeEndField.setValue(this.timeManager.range[1]);
  this.rangeEndField.originalValue=this.timeManager.range[1];this.stepValueField.setValue(this.timeManager.step);this.stepValueField.originalValue=this.timeManager.step;this.stepUnitsField.setValue(this.timeManager.units);this.stepUnitsField.originalValue=this.timeManager.units;this.listOnlyCheck.setValue(this.timeManager.snapToIntervals);this.listOnlyCheck.originalValue=this.timeManager.snapToIntervals;var a=this.playbackToolbar.playbackMode;if("track"==a||!a)a=!1;if(!this.playbackModeField.timeAgents||
  !this.playbackModeField.timeAgents.length)this.playbackModeField.timeAgents=this.timeManager.timeAgents;this.playbackModeField.setValue(a);this.playbackModeField.originalValue=a;this.loopModeCheck.setValue(this.timeManager.loop);this.loopModeCheck.originalValue=this.timeManager.loop;this.reverseModeCheck.setValue(0>this.timeManager.step);this.reverseModeCheck.originalValue=this.reverseModeCheck.getValue()}},saveValues:function(){if(this.ownerCt&&this.ownerCt.close)this.ownerCt[this.ownerCt.closeAction]()},
  cancelChanges:function(){this.form.getForm().items.each(function(a){a.setValue(a.originalValue)});this.saveValues()}});Ext.reg("gxp_playbackoptions",gxp.PlaybackOptionsPanel);Ext.namespace("gxp");
  gxp.GoogleEarthPanel=Ext.extend(Ext.Panel,{HORIZONTAL_FIELD_OF_VIEW:30*Math.PI/180,map:null,mapPanel:null,layers:null,earth:null,projection:null,layerCache:null,initComponent:function(){this.addEvents("beforeadd","pluginfailure","pluginready");gxp.GoogleEarthPanel.superclass.initComponent.call(this);var a=this.mapPanel;a&&!(a instanceof GeoExt.MapPanel)&&(a=Ext.getCmp(a));if(!a)throw Error("Could not get map panel from config: "+this.mapPanel);this.map=a.map;this.layers=a.layers;this.projection=new OpenLayers.Projection("EPSG:4326");
  this.on("render",this.onRenderEvent,this);this.on("show",this.onShowEvent,this);this.on("hide",function(){null!=this.earth&&this.updateMap();this.body.dom.innerHTML="";this.earth=null},this)},onEarthReady:function(a){this.earth=a;void 0===this.flyToSpeed?this.earth.getOptions().setFlyToSpeed(this.earth.SPEED_TELEPORT):null!==this.flyToSpeed&&this.earth.getOptions().setFlyToSpeed(this.flyToSpeed);this.resetCamera();this.setExtent(this.map.getExtent());this.earth.getNavigationControl().setVisibility(this.earth.VISIBILITY_SHOW);
  a=this.earth.getNavigationControl().getScreenXY();a.setXUnits(this.earth.UNITS_PIXELS);a.setYUnits(this.earth.UNITS_INSET_PIXELS);this.earth.getWindow().setVisibility(!0);this.layers.each(function(a){this.addLayer(a)},this);this.layers.on("remove",this.updateLayers,this);this.layers.on("update",this.updateLayers,this);this.layers.on("add",this.updateLayers,this);this.fireEvent("pluginready",this.earth)},onRenderEvent:function(){var a=this.ownerCt&&this.ownerCt.layout instanceof Ext.layout.CardLayout;
  if(!this.hidden&&!a)this.onShowEvent()},onShowEvent:function(){if(this.rendered){this.layerCache={};try{google.earth.createInstance(this.body.dom,this.onEarthReady.createDelegate(this),function(a){this.fireEvent("pluginfailure",this,a)}.createDelegate(this))}catch(a){}}},beforeDestroy:function(){this.layers.un("remove",this.updateLayers,this);this.layers.un("update",this.updateLayers,this);this.layers.un("add",this.updateLayers,this);gxp.GoogleEarthPanel.superclass.beforeDestroy.call(this)},updateLayers:function(){if(this.earth){try{var a=
  this.earth.getFeatures()}catch(b){return}for(var c=a.getFirstChild();null!=c;)a.removeChild(c),c=a.getFirstChild();this.layers.each(function(a){this.addLayer(a)},this)}},addLayer:function(a,b){var c=a.getLayer(),d=c&&c.url;if(this.earth&&c instanceof OpenLayers.Layer.WMS&&"string"==typeof d&&!1!==this.fireEvent("beforeadd",a)){var e=c.id;if(this.layerCache[e])d=this.layerCache[e];else{var f=this.earth.createLink("kl_"+e),d=d.replace(/\?.*/,""),g=c.params;f.setHref(d+("/kml?mode=refresh&layers="+g.LAYERS+
  "&styles="+g.STYLES));d=this.earth.createNetworkLink("nl_"+e);d.setName(e);d.set(f,!1,!1);this.layerCache[e]=d}d.setVisibility(c.getVisibility());void 0!==b&&b<this.earth.getFeatures().getChildNodes().getLength()?this.earth.getFeatures().insertBefore(this.earth.getFeatures().getChildNodes().item(b)):this.earth.getFeatures().appendChild(d)}},setExtent:function(a){var a=a.transform(this.map.getProjectionObject(),this.projection),b=a.getCenterLonLat(),a=this.getExtentWidth(a)/(2*Math.tan(this.HORIZONTAL_FIELD_OF_VIEW)),
  c=this.earth.getView().copyAsLookAt(this.earth.ALTITUDE_RELATIVE_TO_GROUND);c.setLatitude(b.lat);c.setLongitude(b.lon);c.setRange(a);this.earth.getView().setAbstractView(c)},resetCamera:function(){var a=this.earth.getView().copyAsCamera(this.earth.ALTITUDE_RELATIVE_TO_GROUND);a.setRoll(0);a.setHeading(0);a.setTilt(0);this.earth.getView().setAbstractView(a)},getExtent:function(){var a=this.earth.getView().getViewportGlobeBounds();return new OpenLayers.Bounds(a.getWest(),a.getSouth(),a.getEast(),a.getNorth())},
  updateMap:function(){var a=this.earth.getView().copyAsLookAt(this.earth.ALTITUDE_RELATIVE_TO_GROUND),b=this.reprojectToMap(new OpenLayers.LonLat(a.getLongitude(),a.getLatitude()));this.map.zoomToExtent(this.reprojectToMap(this.getExtent()),!0);this.map.setCenter(b);var a=2*a.getRange()*Math.tan(this.HORIZONTAL_FIELD_OF_VIEW),c=this.map.getResolutionForZoom(this.map.getZoom()+1),d=this.map.getExtent(),b=new OpenLayers.Bounds(b.lon-this.map.getSize().w/2*c,b.lat+this.map.getSize().h/2*c,b.lon+this.map.getSize().w/
  2*c,b.lat-this.map.getSize().h/2*c),d=Math.abs(this.getExtentWidth(d)-a);Math.abs(this.getExtentWidth(b)-a)<d&&this.map.zoomTo(this.map.getZoom()+1)},getExtentWidth:function(a){var b=a.getCenterLonLat(),c=new OpenLayers.LonLat(a.left,b.lat),a=new OpenLayers.LonLat(a.right,b.lat);return 1E3*OpenLayers.Util.distVincenty(c,a)},reprojectToGE:function(a){return a.clone().transform(this.map.getProjectionObject(),this.projection)},reprojectToMap:function(a){return a.clone().transform(this.projection,this.map.getProjectionObject())}});
  Ext.reg("gxp_googleearthpanel",gxp.GoogleEarthPanel);Ext.namespace("gxp.plugins");
  gxp.plugins.QueryForm=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_queryform",featureManager:null,autoHide:!1,schema:null,queryActionText:"Query",cancelButtonText:"Cancel",queryMenuText:"Query layer",queryActionTip:"Query the selected layer",queryByLocationText:"Query by location",currentTextText:"Current extent",queryByAttributesText:"Query by attributes",queryMsg:"Querying...",noFeaturesTitle:"No Match",noFeaturesMessage:"Your query did not return any results.",outputAction:0,constructor:function(a){Ext.applyIf(a,
  {actions:[{text:this.queryActionText,menuText:this.queryMenuText,iconCls:"gxp-icon-find",tooltip:this.queryActionTip,disabled:!0}]});gxp.plugins.QueryForm.superclass.constructor.apply(this,arguments)},addActions:function(a){gxp.plugins.QueryForm.superclass.addActions.apply(this,arguments);if(this.actions)this.target.tools[this.featureManager].on("layerchange",function(a,c,d){for(a=this.actions.length-1;0<=a;--a)this.actions[a].setDisabled(!d)},this)},addOutput:function(a){var b=this.target.tools[this.featureManager],
  a=Ext.apply({border:!1,bodyStyle:"padding: 10px",layout:"form",autoScroll:!0,items:[{xtype:"fieldset",ref:"spatialFieldset",title:this.queryByLocationText,checkboxToggle:!0,items:[{xtype:"textfield",ref:"../extent",anchor:"100%",fieldLabel:this.currentTextText,value:this.getFormattedMapExtent(),readOnly:!0}]},{xtype:"fieldset",ref:"attributeFieldset",title:this.queryByAttributesText,checkboxToggle:!0}],bbar:["->",{text:this.cancelButtonText,iconCls:"cancel",handler:function(){var a=this.outputTarget?
  c.ownerCt:c.ownerCt.ownerCt;a&&a instanceof Ext.Window?a.hide():addAttributeFilter(b,b.layerRecord,featureManater.schema)}},{text:this.queryActionText,iconCls:"gxp-icon-find",handler:function(){var a=[];!0!==c.spatialFieldset.collapsed&&a.push(new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,property:b.featureStore.geometryName,value:this.target.mapPanel.map.getExtent()}));if(!0!==c.attributeFieldset.collapsed){var e=c.filterBuilder.getFilter();e&&a.push(e)}b.loadFeatures(1<a.length?
  new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:a}):a[0])},scope:this}]},a||{}),c=gxp.plugins.QueryForm.superclass.addOutput.call(this,a),a=function(a,b,f){c.attributeFieldset.removeAll();c.setDisabled(!f);f?(c.attributeFieldset.add({xtype:"gxp_filterbuilder",ref:"../filterBuilder",attributes:f,allowBlank:!0,allowGroups:!1}),c.spatialFieldset.expand(),c.attributeFieldset.expand()):(c.attributeFieldset.rendered&&c.attributeFieldset.collapse(),c.spatialFieldset.rendered&&c.spatialFieldset.collapse());
  c.attributeFieldset.doLayout()};b.on("layerchange",a);a(b,b.layerRecord,b.schema);this.target.mapPanel.map.events.register("moveend",this,function(){c.extent.setValue(this.getFormattedMapExtent())});b.on({beforequery:function(){(new Ext.LoadMask(c.getEl(),{store:b.featureStore,msg:this.queryMsg})).show()},query:function(a,b){if(b&&(b.getCount()||Ext.Msg.show({title:this.noFeaturesTitle,msg:this.noFeaturesMessage,buttons:Ext.Msg.OK,icon:Ext.Msg.INFO}),this.autoHide)){var f=this.outputTarget?c.ownerCt:
  c.ownerCt.ownerCt;f instanceof Ext.Window&&f.hide()}},scope:this});return c},getFormattedMapExtent:function(){var a=this.target.mapPanel.map.getExtent();return a&&a.toArray().join(", ")}});Ext.preg(gxp.plugins.QueryForm.prototype.ptype,gxp.plugins.QueryForm);Ext.namespace("gxp");
  gxp.LineSymbolizer=Ext.extend(Ext.Panel,{symbolizer:null,initComponent:function(){this.items=[{xtype:"gxp_strokesymbolizer",symbolizer:this.symbolizer,listeners:{change:function(){this.fireEvent("change",this.symbolizer)},scope:this}}];this.addEvents("change");gxp.LineSymbolizer.superclass.initComponent.call(this)}});Ext.reg("gxp_linesymbolizer",gxp.LineSymbolizer);Ext.namespace("gxp.plugins");
  gxp.plugins.WizardStep=Ext.extend(gxp.plugins.Tool,{autoActivate:!1,index:null,valid:!1,wizardContainer:null,wizardData:null,constructor:function(a){gxp.plugins.WizardStep.superclass.constructor.apply(this,arguments);this.wizardData={}},addOutput:function(a){a=Ext.ComponentMgr.create(Ext.apply(a,this.outputConfig));a.on("added",function(a,c){this.wizardContainer=c.ownerCt;this.index=c.ownerCt.items.indexOf(c);c.setDisabled(0!=this.index);c.ownerCt.on({wizardstepvalid:function(a,b){Ext.apply(this.wizardData,
  b);this.previousStepsCompleted()&&c.enable()},wizardstepinvalid:function(){this.previousStepsCompleted()||c.disable()},scope:this});c.on({expand:this.activate,collapse:this.deactivate,scope:this})},this);return gxp.plugins.WizardStep.superclass.addOutput.call(this,a)},setValid:function(a,b){(this.valid=a)?this.wizardContainer.fireEvent("wizardstepvalid",this,b):this.wizardContainer.fireEvent("wizardstepinvalid",this)},previousStepsCompleted:function(){var a=this.index,b=!0;if(0<a){var c,d;for(d in this.target.tools)c=
  this.target.tools[d],c instanceof gxp.plugins.WizardStep&&c.index<a&&(b=b&&c.valid)}return b}});Ext.namespace("gxp.plugins");
  gxp.plugins.Navigation=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_navigation",menuText:"Pan Map",tooltip:"Pan Map",constructor:function(a){gxp.plugins.Navigation.superclass.constructor.apply(this,arguments)},addActions:function(){this.controlOptions=this.controlOptions||{};Ext.applyIf(this.controlOptions,{dragPanOptions:{enableKinetic:!0}});var a=[new GeoExt.Action({tooltip:this.tooltip,menuText:this.menuText,iconCls:"gxp-icon-pan",enableToggle:!0,pressed:!0,allowDepress:!1,control:new OpenLayers.Control.Navigation(this.controlOptions),
  map:this.target.mapPanel.map,toggleGroup:this.toggleGroup})];return gxp.plugins.Navigation.superclass.addActions.apply(this,[a])}});Ext.preg(gxp.plugins.Navigation.prototype.ptype,gxp.plugins.Navigation);Ext.namespace("gxp.plugins");
  gxp.plugins.DeleteSelectedFeatures=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_deleteselectedfeatures",deleteMsgTitle:"Delete",deleteFeaturesMsg:"Are you sure you want to delete {0} selected features?",deleteFeatureMsg:"Are you sure you want to delete the selected feature?",menuText:"Delete selected features",tooltip:"Delete the currently selected features",iconCls:"delete",addActions:function(){var a=gxp.plugins.DeleteSelectedFeatures.superclass.addActions.apply(this,[{text:this.buttonText,menuText:this.menuText,
  iconCls:this.iconCls,tooltip:this.tooltip,handler:this.deleteFeatures,scope:this}]);a[0].disable();var b=this.target.tools[this.featureManager].featureLayer;b.events.on({featureselected:function(){a[0].isDisabled()&&a[0].enable()},featureunselected:function(){0==b.selectedFeatures.length&&a[0].disable()}});return a},deleteFeatures:function(){var a=this.target.tools[this.featureManager],b=a.featureLayer.selectedFeatures;Ext.Msg.show({title:this.deleteMsgTitle,msg:1<b.length?String.format(this.deleteFeaturesMsg,
  b.length):this.deleteFeatureMsg,buttons:Ext.Msg.YESNO,fn:function(c){if("yes"===c){for(var c=a.featureStore,d,e=b.length-1;0<=e;--e)d=b[e],d.layer.selectedFeatures.remove(d),d.layer.events.triggerEvent("featureunselected",{feature:d}),d.state!==OpenLayers.State.INSERT&&(d.state=OpenLayers.State.DELETE,c._removing=!0),c.remove(c.getRecordFromFeature(d)),delete c._removing;c.save()}},scope:this,icon:Ext.MessageBox.QUESTION})}});Ext.preg(gxp.plugins.DeleteSelectedFeatures.prototype.ptype,gxp.plugins.DeleteSelectedFeatures);
  Ext.namespace("gxp.menu");
  gxp.menu.TimelineMenu=Ext.extend(Ext.menu.Menu,{filterLabel:"Filter",attributeLabel:"Label",showNotesText:"Show notes",layers:null,subMenuSize:[350,60],initComponent:function(){gxp.menu.TimelineMenu.superclass.initComponent.apply(this,arguments);this.timelinePanel=this.timelineTool&&this.timelineTool.getTimelinePanel();this.layers.on("add",this.onLayerAddOrRemove,this);this.layers.on("remove",this.onLayerAddOrRemove,this);this.onLayerAddOrRemove()},onRender:function(a,b){gxp.menu.TimelineMenu.superclass.onRender.apply(this,arguments)},
  beforeDestroy:function(){this.layers&&this.layers.on&&(this.layers.un("add",this.onLayerAddOrRemove,this),this.layers.un("remove",this.onLayerAddOrRemove,this));delete this.layers;gxp.menu.TimelineMenu.superclass.beforeDestroy.apply(this,arguments)},onLayerAddOrRemove:function(){this.removeAll();if(this.timelinePanel.annotationsRecord){var a=this.timelinePanel.annotationsRecord,b=this.timelinePanel.getKey(a);this.add(new Ext.menu.CheckItem({text:this.showNotesText,checked:this.timelinePanel.layerLookup[b]&&
  this.timelinePanel.layerLookup[b].visible||!0,listeners:{checkchange:function(b,d){this.timelinePanel.setLayerVisibility(b,d,a,!1)},scope:this}}))}this.layers.each(function(a){var b=a.getLayer();if(b.displayInLayerSwitcher&&b.dimensions&&b.dimensions.time){var b=this.timelinePanel.getKey(a),e=this.timelinePanel.schemaCache[b];this.add(new Ext.menu.CheckItem({text:a.get("title"),checked:this.timelinePanel.layerLookup[b]&&this.timelinePanel.layerLookup[b].visible||!1,menu:new Ext.menu.Menu({plain:!0,
  style:{overflow:"visible"},showSeparator:!1,items:[{xtype:"container",width:this.subMenuSize[0],height:this.subMenuSize[1],layout:"vbox",defaults:{border:!1},layoutConfig:{align:"stretch",pack:"start"},items:[{xtype:"form",labelWidth:75,height:30,items:[{xtype:"combo",forceSelection:!0,getListParent:function(){return this.el.up(".x-menu")},store:e,mode:"local",triggerAction:"all",value:this.timelinePanel.layerLookup[b]?this.timelinePanel.layerLookup[b].titleAttr:null,listeners:{select:function(b){this.timelinePanel.setTitleAttribute(a,
  b.getValue())},scope:this},displayField:"name",valueField:"name",fieldLabel:this.attributeLabel}]},{xtype:"container",layout:"hbox",id:"gxp_timemenufilter",layoutConfig:{align:"stretch",pack:"start"},defaults:{border:!1},items:[{width:25,xtype:"form",layout:"fit",items:[{xtype:"checkbox",checked:this.timelinePanel.layerLookup[b]&&void 0!==this.timelinePanel.layerLookup[b].clientSideFilter,ref:"../applyFilter",listeners:{check:function(b,d){var e=Ext.getCmp("gxp_timemenufilter").filter;e.isValid()&&
  this.timelinePanel.applyFilter(a,e.filter,d)},scope:this}}]},{flex:1,xtype:"form",labelWidth:75,items:[{xtype:"gxp_filterfield",ref:"../filter",filter:this.timelinePanel.layerLookup[b]?this.timelinePanel.layerLookup[b].clientSideFilter:null,listeners:{change:function(b,d){d.isValid()&&this.timelinePanel.applyFilter(a,b,Ext.getCmp("gxp_timemenufilter").applyFilter.getValue())},scope:this},attributesComboConfig:{getListParent:function(){return this.el.up(".x-menu")}},comparisonComboConfig:{getListParent:function(){return this.el.up(".x-menu")}},
  fieldLabel:this.filterLabel,attributes:e}]}],height:30}]}]}),listeners:{checkchange:function(b,d){this.timelinePanel.setLayerVisibility(b,d,a)},scope:this}}))}},this)}});Ext.reg("gxp_timelinemenu",gxp.menu.TimelineMenu);Ext.namespace("gxp.form");
  gxp.form.CSWFilterField=Ext.extend(Ext.form.CompositeField,{clearTooltip:"Clear the filter for this category",emptyText:"Select filter",property:null,map:null,type:OpenLayers.Filter.Comparison.EQUAL_TO,name:null,comboFieldLabel:null,comboStoreData:null,target:null,getFilter:function(){return"BoundingBox"===this.property?new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,property:this.property,projection:"EPSG:4326",value:this.map.getExtent().transform(this.map.getProjectionObject(),
  new OpenLayers.Projection("EPSG:4326"))}):new OpenLayers.Filter.Comparison({type:this.type,property:this.property,value:this.combo.getValue()})},initComponent:function(){this.items=[{ref:"combo",xtype:"combo",fieldLabel:this.comboFieldLabel,store:new Ext.data.ArrayStore({fields:["id","value"],data:this.comboStoreData}),displayField:"value",valueField:"id",mode:"local",listeners:{select:function(){this.filter&&this.target.removeFilter(this.filter);this.filter=this.getFilter();this.target.addFilter(this.filter);
  return!1},scope:this},emptyText:this.emptyText,triggerAction:"all"},{xtype:"button",iconCls:"gxp-icon-removelayers",tooltip:this.clearTooltip,handler:function(){this.target.removeFilter(this.filter);this.hide()},scope:this}];this.hidden=!0;gxp.form.CSWFilterField.superclass.initComponent.apply(this,arguments)},destroy:function(){this.map=this.target=this.filter=null;gxp.form.CSWFilterField.superclass.destroy.call(this)}});Ext.reg("gxp_cswfilterfield",gxp.form.CSWFilterField);Ext.namespace("gxp");
  gxp.CatalogueSearchPanel=Ext.extend(Ext.Panel,{border:!1,maxRecords:10,map:null,selectedSource:null,sources:null,searchFieldEmptyText:"Search",searchButtonText:"Search",addTooltip:"Create filter",addMapTooltip:"Add to map",advancedTitle:"Advanced",datatypeLabel:"Data type",extentLabel:"Spatial extent",categoryLabel:"Category",datasourceLabel:"Data source",filterLabel:"Filter search by",removeSourceTooltip:"Switch back to original source",initComponent:function(){this.addEvents("addlayer");this.filters=
  [];var a=[],b;for(b in this.sources)a.push([b,this.sources[b].title]);1===a.length&&(this.selectedSource=a[0][0]);b=[["datatype","data type"],["extent","spatial extent"],["category","category"]];1<a.length&&b.push(["csw","data source"]);this.items=[{xtype:"form",border:!1,ref:"form",hideLabels:!0,autoHeight:!0,style:"margin-left: 5px; margin-right: 5px; margin-bottom: 5px; margin-top: 5px",items:[{xtype:"compositefield",items:[{xtype:"textfield",emptyText:this.searchFieldEmptyText,ref:"../../search",
  name:"search",width:300},{xtype:"button",text:this.searchButtonText,handler:this.performQuery,scope:this}]},{xtype:"fieldset",collapsible:!0,collapsed:!0,hideLabels:!1,title:this.advancedTitle,items:[{xtype:"gxp_cswfilterfield",name:"datatype",property:"apiso:Type",comboFieldLabel:this.datatypeLabel,comboStoreData:[["dataset","Dataset"],["datasetcollection","Dataset collection"],["application","Application"],["service","Service"]],target:this},{xtype:"gxp_cswfilterfield",name:"extent",property:"BoundingBox",
  map:this.map,comboFieldLabel:this.extentLabel,comboStoreData:[["map","spatial extent of the map"]],target:this},{xtype:"gxp_cswfilterfield",name:"category",property:"apiso:TopicCategory",comboFieldLabel:this.categoryLabel,comboStoreData:[["farming","Farming"],["biota","Biota"],["boundaries","Boundaries"],["climatologyMeteorologyAtmosphere","Climatology/Meteorology/Atmosphere"],["economy","Economy"],["elevation","Elevation"],["environment","Environment"],["geoscientificinformation","Geoscientific Information"],
  ["health","Health"],["imageryBaseMapsEarthCover","Imagery/Base Maps/Earth Cover"],["intelligenceMilitary","Intelligence/Military"],["inlandWaters","Inland Waters"],["location","Location"],["oceans","Oceans"],["planningCadastre","Planning Cadastre"],["society","Society"],["structure","Structure"],["transportation","Transportation"],["utilitiesCommunications","Utilities/Communications"]],target:this},{xtype:"compositefield",id:"csw",ref:"../../cswCompositeField",hidden:!0,items:[{xtype:"combo",ref:"../../../sourceCombo",
  fieldLabel:this.datasourceLabel,store:new Ext.data.ArrayStore({fields:["id","value"],data:a}),displayField:"value",valueField:"id",mode:"local",listeners:{select:function(a){this.setSource(a.getValue())},render:function(){this.sourceCombo.setValue(this.selectedSource)},scope:this},triggerAction:"all"},{xtype:"button",iconCls:"gxp-icon-removelayers",tooltip:this.removeSourceTooltip,handler:function(){this.setSource(this.initialConfig.selectedSource);this.sourceCombo.setValue(this.initialConfig.selectedSource);
  this.cswCompositeField.hide()},scope:this}]},{xtype:"compositefield",items:[{xtype:"combo",fieldLabel:this.filterLabel,store:new Ext.data.ArrayStore({fields:["id","value"],data:b}),displayField:"value",valueField:"id",mode:"local",triggerAction:"all"},{xtype:"button",iconCls:"gxp-icon-addlayers",tooltip:this.addTooltip,handler:function(a){a.ownerCt.items.each(function(a){if(a.getXType()==="combo"){a=a.getValue();this.form.getForm().findField(a).show()}},this)},scope:this}]}]}]},{xtype:"grid",border:!1,
  ref:"grid",bbar:new Ext.PagingToolbar({paramNames:{start:"startPosition",limit:"maxRecords"},store:this.sources[this.selectedSource].store,pageSize:this.maxRecords}),loadMask:!0,hideHeaders:!0,store:this.sources[this.selectedSource].store,columns:[{id:"title",xtype:"templatecolumn",tpl:new Ext.XTemplate("<b>{title}</b><br/>{abstract}"),sortable:!0},{xtype:"actioncolumn",width:30,items:[{iconCls:"gxp-icon-addlayers",tooltip:this.addMapTooltip,handler:function(a,b){this.addLayer(this.grid.store.getAt(b))},
  scope:this}]}],autoExpandColumn:"title",width:400,height:300}];gxp.CatalogueSearchPanel.superclass.initComponent.apply(this,arguments)},destroy:function(){this.map=this.sources=null;gxp.CatalogueSearchPanel.superclass.destroy.call(this)},setSource:function(a){this.selectedSource=a;a=this.sources[a].store;this.grid.reconfigure(a,this.grid.getColumnModel());this.grid.getBottomToolbar().bindStore(a)},performQuery:function(){var a=this.grid.store,b=this.search.getValue(),c=void 0;""!==b&&(c=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.LIKE,
  property:"csw:AnyText",value:"*"+b+"*"}));b={resultType:"results",maxRecords:this.maxRecords,Query:{typeNames:"gmd:MD_Metadata",ElementSetName:{value:"full"}}};c=this.getFullFilter(c);void 0!==c&&Ext.apply(b.Query,{Constraint:{version:"1.1.0",Filter:c}});a.baseParams=b;a.load()},getFullFilter:function(a){var b=[];void 0!==a&&b.push(a);b=b.concat(this.filters);return 1>=b.length?b[0]:new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:b})},addFilter:function(a){this.filters.push(a)},
  removeFilter:function(a){this.filters.remove(a)},findWMS:function(a){for(var b=null,c=null,d=0,e=a.length;d<e;++d){var f=a[d];if(f&&0<f.toLowerCase().indexOf("service=wms")){a=OpenLayers.Util.createUrlObject(f);b=a.protocol+"//"+a.host+":"+a.port+a.pathname;c=a.args.layers;break}}return null!==b&&null!==c?{url:b,name:c}:!1},addLayer:function(a){var b=a.get("URI"),c=a.get("bounds"),b=this.findWMS(b);!1===b&&(b=this.findWMS(a.get("references")));!1!==b&&this.fireEvent("addlayer",this,this.selectedSource,
  Ext.apply({title:a.get("title")[0],bbox:c.toArray(),srs:"EPSG:4326"},b))}});Ext.reg("gxp_cataloguesearchpanel",gxp.CatalogueSearchPanel);Ext.namespace("gxp.plugins");
  gxp.plugins.Playback=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_playback",autoStart:!1,looped:!1,menuText:"Time Playback",tooltip:"Show Time Playback Panel",actionTarget:null,outputTarget:"map",constructor:function(a){gxp.plugins.Playback.superclass.constructor.apply(this,arguments)},addOutput:function(a){delete this._ready;a=Ext.applyIf(a||this.outputConfig||{},{xtype:"gxp_playbacktoolbar",mapPanel:this.target.mapPanel,playbackMode:this.playbackMode,looped:this.looped,autoPlay:this.autoStart,optionsWindow:new Ext.Window({title:gxp.PlaybackOptionsPanel.prototype.titleText,
  width:350,height:425,layout:"fit",items:[{xtype:"gxp_playbackoptions"}],closeable:!0,closeAction:"hide",renderTo:Ext.getBody(),listeners:{show:function(a){a=a.findByType("gxp_playbackoptions")[0];a.fireEvent("show",a)},hide:function(a){a=a.findByType("gxp_playbackoptions")[0];a.fireEvent("hide",a)}}})});a=gxp.plugins.Playback.superclass.addOutput.call(this,a);this.relayEvents(a,["timechange","rangemodified"]);this.playbackToolbar=a;a.control.layers&&this.fireEvent("rangemodified",this,a.control.range);
  return a},addActions:function(){this._ready=0;this.target.mapPanel.map.events.register("addlayer",this,function(a){var b=a.layer;b instanceof OpenLayers.Layer.WMS&&b.dimensions&&b.dimensions.time&&(this.target.mapPanel.map.events.unregister("addlayer",this,arguments.callee),this._ready+=1,1<this._ready&&this.addOutput())});this.target.on("ready",function(){this._ready+=1;1<this._ready&&this.addOutput()},this)},setTime:function(a){return this.playbackToolbar.setTime(a)},getState:function(){var a=gxp.plugins.Playback.superclass.getState.call(this),
  b=this.playbackToolbar;if(b){var c=b.control;a.outputConfig=Ext.apply(b.initialConfig,{dynamicRange:b.dyanamicRange,playbackMode:b.playbackMode});if(c&&(a.outputConfig.controlConfig={range:c.range,step:c.step,units:c.units?c.units:void 0,loop:c.loop,snapToIntervals:c.snapToIntervals},1<c.timeAgents.length)){for(var b=c.timeAgents,c=[],d=0;d<b.length;d++){for(var e={type:b[d].CLASS_NAME.split("TimeAgent.")[1],rangeMode:b[d].rangeMode,rangeInterval:b[d].rangeInterval,intervals:b[d].intervals,layers:[]},
  f=0;f<b[d].layers.length;f++){var g=app.mapPanel.layers.getByLayer(b[d].layers[f]),g=this.target.layerSources[g.get("source")].getConfigForRecord(g);e.layers.push(g)}c.push(e)}a.outputConfig.controlConfig.timeAgents=c}delete a.outputConfig.mapPanel;delete a.outputConfig.optionsWindow}return a}});Ext.preg(gxp.plugins.Playback.prototype.ptype,gxp.plugins.Playback);Ext.namespace("gxp.plugins");
  gxp.plugins.ZoomToLayerExtent=Ext.extend(gxp.plugins.ZoomToExtent,{ptype:"gxp_zoomtolayerextent",menuText:"Zoom to layer extent",tooltip:"Zoom to layer extent",iconCls:"gxp-icon-zoom-to",destroy:function(){this.selectedRecord=null;gxp.plugins.ZoomToLayerExtent.superclass.destroy.apply(this,arguments)},extent:function(){var a=this.selectedRecord.getLayer(),b=a instanceof OpenLayers.Layer.Vector&&a.getDataExtent();return a.restrictedExtent||b||a.maxExtent||map.maxExtent},addActions:function(){var a=
  gxp.plugins.ZoomToLayerExtent.superclass.addActions.apply(this,arguments);a[0].disable();this.target.on("layerselectionchange",function(b){this.selectedRecord=b;a[0].setDisabled(!b||!b.get("layer"))},this);return a}});Ext.preg(gxp.plugins.ZoomToLayerExtent.prototype.ptype,gxp.plugins.ZoomToLayerExtent);Ext.namespace("gxp.plugins");
  gxp.plugins.BingSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_bingsource",title:"Bing Layers",roadTitle:"Bing Roads",aerialTitle:"Bing Aerial",labeledAerialTitle:"Bing Aerial With Labels",apiKey:"AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf",createStore:function(){var a=[new OpenLayers.Layer.Bing({key:this.apiKey,name:this.roadTitle,type:"Road",buffer:1,transitionEffect:"resize"}),new OpenLayers.Layer.Bing({key:this.apiKey,name:this.aerialTitle,type:"Aerial",buffer:1,transitionEffect:"resize"}),
  new OpenLayers.Layer.Bing({key:this.apiKey,name:this.labeledAerialTitle,type:"AerialWithLabels",buffer:1,transitionEffect:"resize"})];this.store=new GeoExt.data.LayerStore({layers:a,fields:[{name:"source",type:"string"},{name:"name",type:"string",mapping:"type"},{name:"abstract",type:"string",mapping:"attribution"},{name:"group",type:"string",defaultValue:"background"},{name:"fixed",type:"boolean",defaultValue:!0},{name:"selected",type:"boolean"}]});this.store.each(function(a){a.set("group","background")});
  this.fireEvent("ready",this)},createLayerRecord:function(a){var b,c=this.store.findExact("name",a.name);-1<c&&(b=this.store.getAt(c).copy(Ext.data.Record.id({})),c=b.getLayer().clone(),a.title&&(c.setName(a.title),b.set("title",a.title)),"visibility"in a&&(c.visibility=a.visibility),b.set("selected",a.selected||!1),b.set("source",a.source),b.set("name",a.name),"group"in a&&b.set("group",a.group),b.data.layer=c,b.commit());return b}});Ext.preg(gxp.plugins.BingSource.prototype.ptype,gxp.plugins.BingSource);
  Ext.namespace("gxp.plugins");
  gxp.plugins.FeatureToField=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_featuretofield",format:"GeoJSON",addActions:function(){var a=this.target.tools[this.featureManager],b,c=new OpenLayers.Format[this.format];a.featureLayer.events.on({featureselected:function(a){this.target.field.setValue(c.write(a.feature));b=a.feature},featureunselected:function(){this.target.field.setValue("");b=null},scope:this});a.on("layerchange",function(){a.featureStore&&a.featureStore.on("save",function(a,e,f){if(f.create)for(a=
  f.create.length-1;0<=a;--a)e=f.create[a].feature,e==b&&this.target.field.setValue(c.write(e))},this)});return gxp.plugins.FeatureToField.superclass.addActions.apply(this,arguments)}});Ext.preg(gxp.plugins.FeatureToField.prototype.ptype,gxp.plugins.FeatureToField);Ext.namespace("gxp.plugins");
  gxp.plugins.FeatureEditor=Ext.extend(gxp.plugins.ClickableFeatures,{ptype:"gxp_featureeditor",iconClsAdd:"gxp-icon-addfeature",closeOnSave:!1,supportAbstractGeometry:!1,supportNoGeometry:!1,iconClsEdit:"gxp-icon-editfeature",exceptionTitle:"Save Failed",exceptionText:"Trouble saving features",pointText:"Point",lineText:"Line",polygonText:"Polygon",noGeometryText:"Event",createFeatureActionTip:"Create a new feature",editFeatureActionTip:"Edit existing feature",outputTarget:"map",snappingAgent:null,
  readOnly:!1,modifyOnly:!1,showSelectedOnly:!0,drawControl:null,popup:null,schema:null,constructor:function(a){this.addEvents("layereditable","featureeditable");gxp.plugins.FeatureEditor.superclass.constructor.apply(this,arguments)},init:function(a){gxp.plugins.FeatureEditor.superclass.init.apply(this,arguments);this.target.on("authorizationchange",this.enableOrDisable,this)},destroy:function(){this.target.un("authorizationchange",this.enableOrDisable,this);gxp.plugins.FeatureEditor.superclass.destroy.apply(this,
  arguments)},addActions:function(){function a(a,d){var f=Array.prototype.slice.call(arguments);f.splice(0,2);if(!e&&b&&!b.isDestroyed){if(b.editing){var g=function(){e=!0;h.call(this);"setLayer"===d?this.target.selectLayer(f[0]):"clearFeatures"===d?window.setTimeout(function(){a[d].call(a)}):a[d].apply(a,f)},h=function(){c.featureStore.un("write",g,this);b.un("canceledit",g,this);b.un("cancelclose",h,this)};c.featureStore.on("write",g,this);b.on({canceledit:g,cancelclose:h,scope:this});b.close()}return!b.editing}e=
  !1}var b,c=this.getFeatureManager(),d=c.featureLayer,e=!1;c.on({beforequery:a.createDelegate(this,"loadFeatures",1),beforelayerchange:a.createDelegate(this,"setLayer",1),beforesetpage:a.createDelegate(this,"setPage",1),beforeclearfeatures:a.createDelegate(this,"clearFeatures",1),scope:this});this.drawControl=new OpenLayers.Control.DrawFeature(d,OpenLayers.Handler.Point,{eventListeners:{featureadded:function(a){!0===this.autoLoadFeature&&(this.autoLoadedFeature=a.feature)},activate:function(){c.showLayer(this.id,
  this.showSelectedOnly&&"selected")},deactivate:function(){c.hideLayer(this.id)},scope:this}});this.selectControl=new OpenLayers.Control.SelectFeature(d,{clickout:!1,multipleKey:"fakeKey",unselect:function(){c.featureStore.getModifiedRecords().length||OpenLayers.Control.SelectFeature.prototype.unselect.apply(this,arguments)},eventListeners:{activate:function(){(!0===this.autoLoadFeature||c.paging)&&this.target.mapPanel.map.events.register("click",this,this.noFeatureClick);c.showLayer(this.id,this.showSelectedOnly&&
  "selected");this.selectControl.unselectAll(b&&b.editing&&{except:b.feature})},deactivate:function(){(!0===this.autoLoadFeature||c.paging)&&this.target.mapPanel.map.events.unregister("click",this,this.noFeatureClick);if(b){if(b.editing)b.on("cancelclose",function(){this.selectControl.activate()},this,{single:!0});b.on("close",function(){c.hideLayer(this.id)},this,{single:!0});b.close()}else c.hideLayer(this.id)},scope:this}});d.events.on({beforefeatureremoved:function(a){this.popup&&a.feature===this.popup.feature&&
  this.selectControl.unselect(a.feature)},featureunselected:function(a){(a=a.feature)&&this.fireEvent("featureeditable",this,a,!1);a&&a.geometry&&b&&!b.hidden&&b.close()},beforefeatureselected:function(){if(b)return!b.editing},featureselected:function(a){var d=a.feature;d&&this.fireEvent("featureeditable",this,d,!0);var e=c.featureStore;if(!0===this._forcePopupForNoGeometry||this.selectControl.active&&null!==d.geometry)!1===this.readOnly&&(this.selectControl.deactivate(),c.showLayer(this.id,this.showSelectedOnly&&
  "selected")),this.popup=b=this.addOutput({xtype:"gxp_featureeditpopup",collapsible:!0,feature:e.getByFeature(d),vertexRenderIntent:"vertex",readOnly:this.readOnly,fields:this.fields,excludeFields:this.excludeFields,editing:d.state===OpenLayers.State.INSERT,schema:this.schema,allowDelete:!0,width:200,height:250,listeners:{close:function(){this.readOnly===false&&this.selectControl.activate();d.layer&&d.layer.selectedFeatures.indexOf(d)!==-1&&this.selectControl.unselect(d);if(d===this.autoLoadedFeature){d.layer&&
  d.layer.removeFeatures([a.feature]);this.autoLoadedFeature=null}},featuremodified:function(a,b){a.disable();e.on({write:{fn:function(){if(a){a.isVisible()&&a.enable();this.closeOnSave&&a.close()}var b=c.layerRecord;this.target.fireEvent("featureedit",c,{name:b.get("name"),source:b.get("source")})},single:true},exception:{fn:function(b,d,f,g,h,j){b=this.exceptionText;d==="remote"?h.exceptionReport&&(b=gxp.util.getOGCExceptionText(h.exceptionReport)):b="Status: "+h.status;c.fireEvent("exception",c,
  h.exceptionReport||{},b,j);c.hasListener("exception")===false&&e.hasListener("exception")===false&&Ext.Msg.show({title:this.exceptionTitle,msg:b,icon:Ext.MessageBox.ERROR,buttons:{ok:true}});if(a&&a.isVisible()){a.enable();a.startEditing()}},single:true},scope:this});if(b.state===OpenLayers.State.DELETE){e._removing=true;e.remove(e.getRecordFromFeature(b));delete e._removing}e.save()},canceledit:function(){e.commitChanges()},scope:this}})},sketchcomplete:function(){c.featureLayer.events.register("featuresadded",
  this,function(a){c.featureLayer.events.unregister("featuresadded",this,arguments.callee);this.drawControl.deactivate();this.selectControl.activate();this.selectControl.select(a.features[0])})},scope:this});var f=this.toggleGroup||Ext.id(),g=[],h={tooltip:this.createFeatureActionTip,menuText:this.createFeatureActionText,text:this.createFeatureActionText,iconCls:this.iconClsAdd,disabled:!0,hidden:this.modifyOnly||this.readOnly,toggleGroup:f,enableToggle:!0,allowDepress:!0,control:this.drawControl,deactivateOnDisable:!0,
  map:this.target.mapPanel.map};if(!0===this.supportAbstractGeometry){var j=[];!0===this.supportNoGeometry&&j.push(new Ext.menu.CheckItem({text:this.noGeometryText,iconCls:"gxp-icon-event",groupClass:null,group:f,listeners:{checkchange:function(a,b){if(!0===b){var c=new OpenLayers.Feature.Vector(null);c.state=OpenLayers.State.INSERT;d.addFeatures([c]);this._forcePopupForNoGeometry=!0;d.events.triggerEvent("featureselected",{feature:c});delete this._forcePopupForNoGeometry}this.actions[0].items[0]instanceof
  Ext.menu.CheckItem?this.actions[0].items[0].setChecked(!1):this.actions[0].items[0].toggle(!1)},scope:this}}));var k=function(a,b,c){!0===b&&this.setHandler(c,!1);this.actions[0].items[0]instanceof Ext.menu.CheckItem?this.actions[0].items[0].setChecked(b):this.actions[0].items[0].toggle(b)};j.push(new Ext.menu.CheckItem({groupClass:null,text:this.pointText,group:f,iconCls:"gxp-icon-point",listeners:{checkchange:k.createDelegate(this,[OpenLayers.Handler.Point],2)}}),new Ext.menu.CheckItem({groupClass:null,
  text:this.lineText,group:f,iconCls:"gxp-icon-line",listeners:{checkchange:k.createDelegate(this,[OpenLayers.Handler.Path],2)}}),new Ext.menu.CheckItem({groupClass:null,text:this.polygonText,group:f,iconCls:"gxp-icon-polygon",listeners:{checkchange:k.createDelegate(this,[OpenLayers.Handler.Polygon],2)}}));g.push(new GeoExt.Action(Ext.apply(h,{menu:new Ext.menu.Menu({items:j})})))}else g.push(new GeoExt.Action(h));g.push(new GeoExt.Action({tooltip:this.editFeatureActionTip,text:this.editFeatureActionText,
  menuText:this.editFeatureActionText,iconCls:this.iconClsEdit,disabled:!0,toggleGroup:f,enableToggle:!0,allowDepress:!0,control:this.selectControl,deactivateOnDisable:!0,map:this.target.mapPanel.map}));g=gxp.plugins.FeatureEditor.superclass.addActions.call(this,g);c.on("layerchange",this.onLayerChange,this);(f=this.getSnappingAgent())&&f.registerEditor(this);return g},getFeatureManager:function(){var a=this.target.tools[this.featureManager];if(!a)throw Error("Unable to access feature manager by id: "+
  this.featureManager);return a},getSnappingAgent:function(){var a,b=this.snappingAgent;if(b&&(a=this.target.tools[b],!a))throw Error("Unable to locate snapping agent with id: "+b);return a},setHandler:function(a,b){var c=this.drawControl,d=c.active;d&&c.deactivate();c.handler.destroy();c.handler=new a(c,c.callbacks,Ext.apply(c.handlerOptions,{multi:b}));d&&c.activate()},enableOrDisable:function(){var a=!this.schema||!this.target.isAuthorized();this.actions[0].setDisabled(a);this.actions[1].setDisabled(a);
  return a},onLayerChange:function(a,b,c){this.schema=c;if(this.enableOrDisable())this.fireEvent("layereditable",this,b,!1);else{var c=this.actions[0],d={Point:OpenLayers.Handler.Point,Line:OpenLayers.Handler.Path,Curve:OpenLayers.Handler.Path,Polygon:OpenLayers.Handler.Polygon,Surface:OpenLayers.Handler.Polygon},e=a.geometryType.replace("Multi","");(d=d[e])?(this.setHandler(d,e!=a.geometryType),c.enable()):!0===this.supportAbstractGeometry&&"Geometry"===a.geometryType?c.enable():c.disable();this.fireEvent("layereditable",
  this,b,!0)}},select:function(a){this.selectControl.unselectAll(this.popup&&this.popup.editing&&{except:this.popup.feature});this.selectControl.select(a)}});Ext.preg(gxp.plugins.FeatureEditor.prototype.ptype,gxp.plugins.FeatureEditor);Ext.namespace("gxp.plugins");
  gxp.plugins.RemoveLayer=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_removelayer",removeMenuText:"Remove layer",removeActionTip:"Remove layer",addActions:function(){var a,b=gxp.plugins.RemoveLayer.superclass.addActions.apply(this,[{menuText:this.removeMenuText,iconCls:"gxp-icon-removelayers",disabled:!0,tooltip:this.removeActionTip,handler:function(){var b=a;b&&this.target.mapPanel.layers.remove(b)},scope:this}]),c=b[0];this.target.on("layerselectionchange",function(b){a=b;c.setDisabled(1>=this.target.mapPanel.layers.getCount()||
  !b)},this);var d=function(b){c.setDisabled(!a||1>=b.getCount())};this.target.mapPanel.layers.on({add:d,remove:d});return b}});Ext.preg(gxp.plugins.RemoveLayer.prototype.ptype,gxp.plugins.RemoveLayer);Ext.namespace("gxp.plugins");
  gxp.plugins.OLSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_olsource",createLayerRecord:function(a){var b,c=window;b=a.type.split(".");for(var d=0,e=b.length;d<e&&!(c=c[b[d]],!c);++d);if(c&&c.prototype&&c.prototype.initialize)b=function(){c.prototype.initialize.apply(this,a.args)},b.prototype=c.prototype,b=new b,"visibility"in a&&(b.visibility=a.visibility),b=new (GeoExt.data.LayerRecord.create([{name:"name",type:"string"},{name:"source",type:"string"},{name:"group",type:"string"},{name:"fixed",
  type:"boolean"},{name:"selected",type:"boolean"},{name:"type",type:"string"},{name:"args"}]))({layer:b,title:b.name,name:a.name||b.name,source:a.source,group:a.group,fixed:"fixed"in a?a.fixed:!1,selected:"selected"in a?a.selected:!1,type:a.type,args:a.args,properties:"properties"in a?a.properties:void 0},b.id);else throw Error("Cannot construct OpenLayers layer from given type: "+a.type);return b},getConfigForRecord:function(a){var b=gxp.plugins.OLSource.superclass.getConfigForRecord.apply(this,arguments);
  a.getLayer();return Ext.apply(b,{type:a.get("type"),args:a.get("args")})}});Ext.preg(gxp.plugins.OLSource.prototype.ptype,gxp.plugins.OLSource);Ext.namespace("gxp.plugins");
  gxp.plugins.Print=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_print",printService:null,printCapabilities:null,customParams:null,includeLegend:!1,menuText:"Print Map",tooltip:"Print Map",notAllNotPrintableText:"Not All Layers Can Be Printed",nonePrintableText:"None of your current map layers can be printed",previewText:"Print Preview",openInNewWindow:!1,constructor:function(a){gxp.plugins.Print.superclass.constructor.apply(this,arguments)},addActions:function(){if(null!==this.printService||null!=this.printCapabilities){var a=
  new GeoExt.data.PrintProvider({capabilities:this.printCapabilities,url:this.printService,customParams:this.customParams,autoLoad:!1,listeners:{beforedownload:function(a,b){if(!0===this.openInNewWindow)return window.open(b),!1},beforeencodelegend:function(a,b,c){if(c&&"gxp_layermanager"===c.ptype){var d=[];(c=c.output)&&c[0]&&c[0].getRootNode().cascade(function(a){if(a.component&&!a.component.hidden){var a=a.component,c=this.encoders.legends[a.getXType()];d=d.concat(c.call(this,a,b.pages[0].scale))}},
  a);b.legends=d;return!1}},beforeprint:function(){d.items.get(0).printMapPanel.layers.each(function(a){var a=a.get("layer").params,b;for(b in a)a[b]instanceof Array&&(a[b]=a[b].join(","))})},loadcapabilities:function(){c&&(c.initialConfig.disabled=!1,c.enable())},print:function(){try{d.close()}catch(a){}},printException:function(a,b){this.target.displayXHRTrouble&&this.target.displayXHRTrouble(b)},scope:this}}),b=gxp.plugins.Print.superclass.addActions.call(this,[{menuText:this.menuText,tooltip:this.tooltip,
  iconCls:"gxp-icon-print",disabled:null!==this.printCapabilities?!1:!0,handler:function(){if(0<g().length){var a=j.call(this);k.call(this);return a}Ext.Msg.alert(this.notAllNotPrintableText,this.nonePrintableText)},scope:this,listeners:{render:function(){a.loadCapabilities()}}}]),c=b[0].items[0],d,e=function(){if(d){try{d.items.first().printMapPanel.printPage.destroy()}catch(a){}d=null}},f=this.target.mapPanel,g=function(){var a=[];f.layers.each(function(b){b=b.getLayer();h(b)&&a.push(b)});return a},
  h=function(a){return a instanceof OpenLayers.Layer.WMS||a instanceof OpenLayers.Layer.OSM},j=function(){var b=null;if(!0===this.includeLegend){var c,g;for(c in this.target.tools)if(g=this.target.tools[c],"gxp_legend"===g.ptype){b=g.getLegendPanel();break}if(null===b)for(c in this.target.tools)if(g=this.target.tools[c],"gxp_layermanager"===g.ptype){b=g;break}}return d=new Ext.Window({title:this.previewText,modal:!0,border:!1,autoHeight:!0,resizable:!1,width:360,items:[new GeoExt.ux.PrintPreview({autoHeight:!0,
  mapTitle:this.target.about&&this.target.about.title,comment:this.target.about&&this.target.about["abstract"],minWidth:336,printMapPanel:{height:Math.min(450,Ext.get(document.body).getHeight()-150),autoWidth:!0,limitScales:!0,map:Ext.applyIf({controls:[new OpenLayers.Control.Navigation({zoomWheelEnabled:!1,zoomBoxEnabled:!1}),new OpenLayers.Control.PanPanel,new OpenLayers.Control.ZoomPanel,new OpenLayers.Control.Attribution],eventListeners:{preaddlayer:function(a){return h(a.layer)}}},f.initialConfig.map),
  items:[{xtype:"gx_zoomslider",vertical:!0,height:100,aggressive:!0}]},printProvider:a,includeLegend:this.includeLegend,legend:b,sourceMap:f})],listeners:{beforedestroy:e}})},k=function(){d.show();d.setWidth(0);var a=0;d.items.get(0).items.get(0).items.each(function(b){b.getEl()&&(a+=b.getWidth())});d.setWidth(Math.max(d.items.get(0).printMapPanel.getWidth(),a+20));d.center()};return b}}});Ext.preg(gxp.plugins.Print.prototype.ptype,gxp.plugins.Print);Ext.namespace("gxp.plugins");
  gxp.plugins.StyleWriter=Ext.extend(Ext.util.Observable,{deletedStyles:null,constructor:function(a){this.initialConfig=a;Ext.apply(this,a);this.deletedStyles=[];gxp.plugins.StyleWriter.superclass.constructor.apply(this,arguments)},init:function(a){this.target=a;a.stylesStore.on({remove:function(a,c){var d=c.get("name");c.get("name")===d&&this.deletedStyles.push(d)},scope:this});a.on({beforesaved:this.write,scope:this})},write:function(a){a.stylesStore.commitChanges();a.fireEvent("saved",a,a.selectedStyle.get("name"))}});
  Ext.namespace("gxp.plugins");
  gxp.plugins.GeoServerStyleWriter=Ext.extend(gxp.plugins.StyleWriter,{baseUrl:"/geoserver/rest",constructor:function(a){this.initialConfig=a;Ext.apply(this,a);gxp.plugins.GeoServerStyleWriter.superclass.constructor.apply(this,arguments)},write:function(a){var a=a||{},b=[],c=this.target.stylesStore;c.each(function(a){(a.phantom||-1!==c.modified.indexOf(a))&&this.writeStyle(a,b)},this);var d=function(){this.deleteStyles();for(var b=this.target.stylesStore.getModifiedRecords(),c=b.length-1;0<=c;--c)b[c].phantom=
  !1;b=this.target;b.stylesStore.commitChanges();a.success&&a.success.call(a.scope);b.fireEvent("saved",b,b.selectedStyle.get("name"))};0<b.length?gxp.util.dispatch(b,function(){this.assignStyles(a.defaultStyle,d)},this):this.assignStyles(a.defaultStyle,d)},writeStyle:function(a,b){var c=a.get("userStyle").name;b.push(function(b){Ext.Ajax.request({method:!0===a.phantom?"POST":"PUT",url:this.baseUrl+"/styles"+(!0===a.phantom?"":"/"+c+".xml"),headers:{"Content-Type":"application/vnd.ogc.sld+xml; charset=UTF-8"},
  xmlData:this.target.createSLD({userStyles:[c]}),success:!0===a.phantom?function(){Ext.Ajax.request({method:"POST",url:this.baseUrl+"/layers/"+this.target.layerRecord.get("name")+"/styles.json",jsonData:{style:{name:c}},success:b,scope:this})}:b,scope:this})})},assignStyles:function(a,b){var c=[];this.target.stylesStore.each(function(b){!a&&!0===b.get("userStyle").isDefault&&(a=b.get("name"));b.get("name")!==a&&-1===this.deletedStyles.indexOf(b.id)&&c.push({name:b.get("name")})},this);Ext.Ajax.request({method:"PUT",
  url:this.baseUrl+"/layers/"+this.target.layerRecord.get("name")+".json",jsonData:{layer:{defaultStyle:{name:a},styles:0<c.length?{style:c}:{},enabled:!0}},success:b,scope:this})},deleteStyles:function(){for(var a=0,b=this.deletedStyles.length;a<b;++a)Ext.Ajax.request({method:"DELETE",url:this.baseUrl+"/styles/"+this.deletedStyles[a]+"?purge=true"});this.deletedStyles=[]}});Ext.preg("gxp_geoserverstylewriter",gxp.plugins.GeoServerStyleWriter);Ext.namespace("gxp");
  gxp.ScaleOverlay=Ext.extend(Ext.Panel,{map:null,zoomLevelText:"Zoom level",initComponent:function(){gxp.ScaleOverlay.superclass.initComponent.call(this);this.cls="map-overlay";this.map&&(this.map instanceof GeoExt.MapPanel&&(this.map=this.map.map),this.bind(this.map));this.on("beforedestroy",this.unbind,this)},addToMapPanel:function(a){this.on({afterrender:function(){this.bind(a.map)},scope:this})},stopMouseEvents:function(a){a.stopEvent()},removeFromMapPanel:function(){var a=this.getEl();a.un("mousedown",
  this.stopMouseEvents,this);a.un("click",this.stopMouseEvents,this);this.unbind()},addScaleLine:function(){var a=new Ext.BoxComponent({autoEl:{tag:"div",cls:"olControlScaleLine overlay-element overlay-scaleline"}});this.on("afterlayout",function(){a.getEl().dom.style.position="relative";a.getEl().dom.style.display="inline";this.getEl().on("click",this.stopMouseEvents,this);this.getEl().on("mousedown",this.stopMouseEvents,this)},this);a.on("render",function(){var b=new OpenLayers.Control.ScaleLine({geodesic:!0,
  div:a.getEl().dom});this.map.addControl(b);b.activate()},this);this.add(a)},handleZoomEnd:function(){var a=this.zoomStore.queryBy(function(a){return this.map.getZoom()==a.data.level},this);0<a.length?(a=a.items[0],this.zoomSelector.setValue("1 : "+parseInt(a.data.scale,10))):this.zoomSelector.rendered&&this.zoomSelector.clearValue()},addScaleCombo:function(){this.zoomStore=new GeoExt.data.ScaleStore({map:this.map});this.zoomSelector=new Ext.form.ComboBox({emptyText:this.zoomLevelText,tpl:'<tpl for="."><div class="x-combo-list-item">1 : {[parseInt(values.scale)]}</div></tpl>',
  editable:!1,triggerAction:"all",mode:"local",store:this.zoomStore,width:110});this.zoomSelector.on({click:this.stopMouseEvents,mousedown:this.stopMouseEvents,select:function(a,b){this.map.zoomTo(b.data.level)},scope:this});this.map.events.register("zoomend",this,this.handleZoomEnd);this.add(new Ext.Panel({items:[this.zoomSelector],cls:"overlay-element overlay-scalechooser",border:!1}))},bind:function(a){this.map=a;this.addScaleLine();this.addScaleCombo();this.doLayout()},unbind:function(){this.map&&
  this.map.events&&this.map.events.unregister("zoomend",this,this.handleZoomEnd);this.zoomSelector=this.zoomStore=null}});Ext.reg("gxp_scaleoverlay",gxp.ScaleOverlay);Ext.namespace("gxp.plugins");
  gxp.plugins.WMSRasterStylesDialog={isRaster:null,init:function(a){Ext.apply(a,gxp.plugins.WMSRasterStylesDialog)},createRule:function(){var a=[new OpenLayers.Symbolizer[this.isRaster?"Raster":this.symbolType]];return new OpenLayers.Rule({symbolizers:a})},addRule:function(){var a=this.items.get(2).items.get(0);this.isRaster?(a.rules.push(this.createPseudoRule()),1==a.rules.length&&a.rules.push(this.createPseudoRule()),this.savePseudoRules()):(this.selectedStyle.get("userStyle").rules.push(this.createRule()),
  a.update(),this.selectedStyle.store.afterEdit(this.selectedStyle));this.updateRuleRemoveButton()},removeRule:function(){if(this.isRaster){var a=this.items.get(2).items.get(0),b=this.selectedRule;a.unselect();a.rules.remove(b);1==a.rules.length&&a.rules.remove(a.rules[0]);this.savePseudoRules()}else gxp.WMSStylesDialog.prototype.removeRule.apply(this,arguments)},duplicateRule:function(){var a=this.items.get(2).items.get(0);if(this.isRaster)a.rules.push(this.createPseudoRule({quantity:this.selectedRule.name,
  label:this.selectedRule.title,color:this.selectedRule.symbolizers[0].fillColor,opacity:this.selectedRule.symbolizers[0].fillOpacity})),this.savePseudoRules();else{var b=this.selectedRule.clone();b.name=gxp.util.uniqueName((b.title||b.name)+" (copy)");delete b.title;this.selectedStyle.get("userStyle").rules.push(b);a.update()}this.updateRuleRemoveButton()},editRule:function(){this.isRaster?this.editPseudoRule():gxp.WMSStylesDialog.prototype.editRule.apply(this,arguments)},editPseudoRule:function(){var a=
  this,b=this.selectedRule,c=new Ext.Window({title:"Color Map Entry: "+b.name,width:340,autoHeight:!0,modal:!0,items:[{bodyStyle:"padding-top: 5px",border:!1,defaults:{autoHeight:!0,hideMode:"offsets"},items:[{xtype:"form",border:!1,labelAlign:"top",defaults:{border:!1},style:{padding:"0.3em 0 0 1em"},items:[{layout:"column",defaults:{border:!1,style:{"padding-right":"1em"}},items:[{layout:"form",width:70,items:[{xtype:"numberfield",anchor:"95%",value:b.name,allowBlank:!1,fieldLabel:"Quantity",validator:function(c){for(var d=
  a.items.get(2).items.get(0).rules,g=d.length-1;0<=g;g--)if(b!==d[g]&&d[g].name==c)return"Quantity "+c+" is already defined";return!0},listeners:{valid:function(a){this.selectedRule.name=""+a.getValue();this.savePseudoRules()},scope:this}}]},{layout:"form",width:130,items:[{xtype:"textfield",fieldLabel:"Label",anchor:"95%",value:b.title,listeners:{valid:function(a){this.selectedRule.title=a.getValue();this.savePseudoRules()},scope:this}}]},{layout:"form",width:70,items:[new GeoExt.FeatureRenderer({symbolType:this.symbolType,
  symbolizers:[b.symbolizers[0]],isFormField:!0,fieldLabel:"Appearance"})]}]}]},{xtype:"gxp_polygonsymbolizer",symbolizer:b.symbolizers[0],bodyStyle:{padding:"10px"},border:!1,labelWidth:70,defaults:{labelWidth:70},listeners:{change:function(a){var b=c.findByType(GeoExt.FeatureRenderer)[0];b.setSymbolizers([a],{draw:b.rendered});this.selectedRule.symbolizers[0]=a;this.savePseudoRules()},scope:this}}]}]}),d=c.findByType("gxp_strokesymbolizer")[0];d.ownerCt.remove(d);c.show()},savePseudoRules:function(){var a=
  this.selectedStyle,b=this.items.get(2).items.get(0),a=a.get("userStyle"),b=b.rules;b.sort(function(a,b){var c=parseFloat(a.name),d=parseFloat(b.name);return c===d?0:c<d?-1:1});a=a.rules[0].symbolizers[0];a.colorMap=0<b.length?Array(b.length):void 0;for(var c,d=0,e=b.length;d<e;++d)c=b[d],a.colorMap[d]={quantity:parseFloat(c.name),label:c.title||void 0,color:c.symbolizers[0].fillColor||void 0,opacity:!1==c.symbolizers[0].fill?0:c.symbolizers[0].fillOpacity};this.afterRuleChange(this.selectedRule)},
  createLegend:function(a,b){var c=OpenLayers.Symbolizer.Raster;c&&a[0]&&a[0].symbolizers[0]instanceof c?(this.getComponent("rulesfieldset").setTitle("Color Map Entries"),this.isRaster=!0,this.addRasterLegend(a,b)):(this.isRaster=!1,this.addVectorLegend(a))},addRasterLegend:function(a,b){for(var b=b||{},c=a[0].symbolizers[0].colorMap||[],d=[],e=0,f=c.length;e<f;e++)d.push(this.createPseudoRule(c[e]));this.selectedRule=null!=b.selectedRuleIndex?d[b.selectedRuleIndex]:null;return this.addVectorLegend(d,
  {symbolType:"Polygon",enableDD:!1})},createPseudoRule:function(a){var b=-1;if(!a){var c=this.items.get(2);if(c.items){rules=c.items.get(0).rules;for(c=rules.length-1;0<=c;c--)b=Math.max(b,parseFloat(rules[c].name))}}a=Ext.applyIf(a||{},{quantity:++b,color:"#000000",opacity:1});return new OpenLayers.Rule({title:a.label,name:""+a.quantity,symbolizers:[new OpenLayers.Symbolizer.Polygon({fillColor:a.color,fillOpacity:a.opacity,stroke:!1,fill:0!==a.opacity})]})},updateRuleRemoveButton:function(){this.items.get(3).items.get(1).setDisabled(!this.selectedRule||
  !1===this.isRaster&&1>=this.items.get(2).items.get(0).rules.length)}};Ext.preg("gxp_wmsrasterstylesdialog",gxp.plugins.WMSRasterStylesDialog);Ext.namespace("gxp.menu");
  gxp.menu.LayerMenu=Ext.extend(Ext.menu.Menu,{layerText:"Layer",layers:null,initComponent:function(){gxp.menu.LayerMenu.superclass.initComponent.apply(this,arguments);this.layers.on("add",this.onLayerAdd,this);this.onLayerAdd()},onRender:function(a,b){gxp.menu.LayerMenu.superclass.onRender.apply(this,arguments)},beforeDestroy:function(){this.layers&&this.layers.on&&this.layers.un("add",this.onLayerAdd,this);delete this.layers;gxp.menu.LayerMenu.superclass.beforeDestroy.apply(this,arguments)},onLayerAdd:function(){this.removeAll();
  this.add({iconCls:"gxp-layer-visibility",text:this.layerText,canActivate:!1},"-");this.layers.each(function(a){if(a.getLayer().displayInLayerSwitcher){var b=new Ext.menu.CheckItem({text:a.get("title"),checked:a.getLayer().getVisibility(),group:a.get("group"),listeners:{checkchange:function(b,d){a.getLayer().setVisibility(d)}}});2<this.items.getCount()?this.insert(2,b):this.add(b)}},this)}});Ext.reg("gxp_layermenu",gxp.menu.LayerMenu);Ext.namespace("gxp");
  gxp.RulePanel=Ext.extend(Ext.TabPanel,{fonts:void 0,symbolType:"Point",rule:null,attributes:null,nestedFilters:!0,minScaleDenominatorLimit:1.577757414193268E9*Math.pow(0.5,19)*OpenLayers.DOTS_PER_INCH/256,maxScaleDenominatorLimit:1.577757414193268E9*OpenLayers.DOTS_PER_INCH/256,scaleLevels:20,scaleSliderTemplate:"{scaleType} Scale 1:{scale}",modifyScaleTipContext:Ext.emptyFn,labelFeaturesText:"Label Features",labelsText:"Labels",basicText:"Basic",advancedText:"Advanced",limitByScaleText:"Limit by scale",
  limitByConditionText:"Limit by condition",symbolText:"Symbol",nameText:"Name",initComponent:function(){Ext.applyIf(this,{plain:!0,border:!1});this.rule?this.initialConfig.symbolType||(this.symbolType=this.getSymbolTypeFromRule(this.rule)||this.symbolType):this.rule=new OpenLayers.Rule({name:this.uniqueRuleName()});this.activeTab=0;this.textSymbolizer=new gxp.TextSymbolizer({symbolizer:this.getTextSymbolizer(),attributes:this.attributes,fonts:this.fonts,listeners:{change:function(){this.fireEvent("change",
  this,this.rule)},scope:this}});this.scaleLimitPanel=new gxp.ScaleLimitPanel({maxScaleDenominator:this.rule.maxScaleDenominator||void 0,limitMaxScaleDenominator:!!this.rule.maxScaleDenominator,maxScaleDenominatorLimit:this.maxScaleDenominatorLimit,minScaleDenominator:this.rule.minScaleDenominator||void 0,limitMinScaleDenominator:!!this.rule.minScaleDenominator,minScaleDenominatorLimit:this.minScaleDenominatorLimit,scaleLevels:this.scaleLevels,scaleSliderTemplate:this.scaleSliderTemplate,modifyScaleTipContext:this.modifyScaleTipContext,
  listeners:{change:function(a,b,c){this.rule.minScaleDenominator=b;this.rule.maxScaleDenominator=c;this.fireEvent("change",this,this.rule)},scope:this}});this.filterBuilder=new gxp.FilterBuilder({allowGroups:this.nestedFilters,filter:this.rule&&this.rule.filter&&this.rule.filter.clone(),attributes:this.attributes,listeners:{change:function(a){this.rule.filter=a.getFilter();this.fireEvent("change",this,this.rule)},scope:this}});this.items=[{title:this.labelsText,autoScroll:!0,bodyStyle:{padding:"10px"},
  items:[{xtype:"fieldset",title:this.labelFeaturesText,autoHeight:!0,checkboxToggle:!0,collapsed:!this.hasTextSymbolizer(),items:[this.textSymbolizer],listeners:{collapse:function(){OpenLayers.Util.removeItem(this.rule.symbolizers,this.getTextSymbolizer());this.fireEvent("change",this,this.rule)},expand:function(){this.setTextSymbolizer(this.textSymbolizer.symbolizer);this.fireEvent("change",this,this.rule)},scope:this}}]}];if(this.getSymbolTypeFromRule(this.rule)||this.symbolType)this.items=[{title:this.basicText,
  autoScroll:!0,items:[this.createHeaderPanel(),this.createSymbolizerPanel()]},this.items[0],{title:this.advancedText,defaults:{style:{margin:"7px"}},autoScroll:!0,items:[{xtype:"fieldset",title:this.limitByScaleText,checkboxToggle:!0,collapsed:!(this.rule&&(this.rule.minScaleDenominator||this.rule.maxScaleDenominator)),autoHeight:!0,items:[this.scaleLimitPanel],listeners:{collapse:function(){delete this.rule.minScaleDenominator;delete this.rule.maxScaleDenominator;this.fireEvent("change",this,this.rule)},
  expand:function(){var a=this.getActiveTab();this.activeTab=null;this.setActiveTab(a);a=false;if(this.scaleLimitPanel.limitMinScaleDenominator){this.rule.minScaleDenominator=this.scaleLimitPanel.minScaleDenominator;a=true}if(this.scaleLimitPanel.limitMaxScaleDenominator){this.rule.maxScaleDenominator=this.scaleLimitPanel.maxScaleDenominator;a=true}a&&this.fireEvent("change",this,this.rule)},scope:this}},{xtype:"fieldset",title:this.limitByConditionText,checkboxToggle:!0,collapsed:!(this.rule&&this.rule.filter),
  autoHeight:!0,items:[this.filterBuilder],listeners:{collapse:function(){delete this.rule.filter;this.fireEvent("change",this,this.rule)},expand:function(){this.rule.filter=this.filterBuilder.getFilter();this.fireEvent("change",this,this.rule)},scope:this}}]}];this.items[0].autoHeight=!0;this.addEvents("change");this.on({tabchange:function(a,b){b.doLayout()},scope:this});gxp.RulePanel.superclass.initComponent.call(this)},hasTextSymbolizer:function(){for(var a,b,c=0,d=this.rule.symbolizers.length;c<
  d;++c)if(a=this.rule.symbolizers[c],a instanceof OpenLayers.Symbolizer.Text){b=a;break}return b},getTextSymbolizer:function(){var a=this.hasTextSymbolizer();a||(a=new OpenLayers.Symbolizer.Text({graphic:!1}));return a},setTextSymbolizer:function(a){for(var b,c=0,d=this.rule.symbolizers.length;c<d;++c)if(candidate=this.rule.symbolizers[c],this.rule.symbolizers[c]instanceof OpenLayers.Symbolizer.Text){this.rule.symbolizers[c]=a;b=!0;break}b||this.rule.symbolizers.push(a)},uniqueRuleName:function(){return OpenLayers.Util.createUniqueID("rule_")},
  createHeaderPanel:function(){this.symbolizerSwatch=new GeoExt.FeatureRenderer({symbolType:this.symbolType,isFormField:!0,fieldLabel:this.symbolText});return{xtype:"form",border:!1,labelAlign:"top",defaults:{border:!1},style:{padding:"0.3em 0 0 1em"},items:[{layout:"column",defaults:{border:!1,style:{"padding-right":"1em"}},items:[{layout:"form",width:150,items:[{xtype:"textfield",fieldLabel:this.nameText,anchor:"95%",value:this.rule&&(this.rule.title||this.rule.name||""),listeners:{change:function(a,
  b){this.rule.title=b;this.fireEvent("change",this,this.rule)},scope:this}}]},{layout:"form",width:70,items:[this.symbolizerSwatch]}]}]}},createSymbolizerPanel:function(){var a,b,c=OpenLayers.Symbolizer[this.symbolType],d=!1;if(c){for(var e=0,f=this.rule.symbolizers.length;e<f;++e)if(a=this.rule.symbolizers[e],a instanceof c){d=!0;b=a;break}b||(b=new c({fill:!1,stroke:!1}))}else throw Error("Appropriate symbolizer type not included in build: "+this.symbolType);this.symbolizerSwatch.setSymbolizers([b],
  {draw:this.symbolizerSwatch.rendered});a={xtype:"gxp_"+this.symbolType.toLowerCase()+"symbolizer",symbolizer:b,bodyStyle:{padding:"10px"},border:!1,labelWidth:70,defaults:{labelWidth:70},listeners:{change:function(a){this.symbolizerSwatch.setSymbolizers([a],{draw:this.symbolizerSwatch.rendered});d||(this.rule.symbolizers.push(a),d=!0);this.fireEvent("change",this,this.rule)},scope:this}};"Point"===this.symbolType&&this.pointGraphics&&(a.pointGraphics=this.pointGraphics);return a},getSymbolTypeFromRule:function(a){for(var b,
  c,d=0,e=a.symbolizers.length;d<e;++d)if(b=a.symbolizers[d],!(b instanceof OpenLayers.Symbolizer.Text)){c=b.CLASS_NAME.split(".").pop();break}return c}});Ext.reg("gxp_rulepanel",gxp.RulePanel);Ext.namespace("gxp.plugins");
  gxp.plugins.LoadingIndicator=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_loadingindicator",onlyShowOnFirstLoad:!1,loadingMapMessage:"Loading Map...",layerCount:0,busyMask:null,init:function(a){a.map.events.register("preaddlayer",this,function(b){var c=b.layer;if(c instanceof OpenLayers.Layer.WMS)c.events.on({loadstart:function(){this.layerCount++;this.busyMask||(this.busyMask=new Ext.LoadMask(a.map.div,{msg:this.loadingMapMessage}));this.busyMask.show();!0===this.onlyShowOnFirstLoad&&c.events.unregister("loadstart",
  this,arguments.callee)},loadend:function(){this.layerCount--;0===this.layerCount&&this.busyMask.hide();!0===this.onlyShowOnFirstLoad&&c.events.unregister("loadend",this,arguments.callee)},scope:this})})},destroy:function(){Ext.destroy(this.busyMask);this.busyMask=null;gxp.plugins.LoadingIndicator.superclass.destroy.apply(this,arguments)}});Ext.preg(gxp.plugins.LoadingIndicator.prototype.ptype,gxp.plugins.LoadingIndicator);Ext.namespace("gxp");
  gxp.NewSourceWindow=Ext.extend(Ext.Window,{bodyStyle:"padding: 0px",hideBorders:!0,width:300,closeAction:"hide",error:null,initComponent:function(){window.setTimeout(function(){throw"gxp.NewSourceWindow is deprecated. Use gxp.NewSourceDialog instead.";},0);this.addEvents("server-added");gxp.NewSourceWindow.superclass.initComponent.apply(this,arguments);this.addEvents("server-added");var a=this.add(new gxp.NewSourceDialog(Ext.applyIf({addSource:this.addSource,header:!1,listeners:{urlselected:function(a,
  c){this.fireEvent("server-added",c)}}},this.initialConfig)));this.setTitle(a.title);this.setLoading=a.setLoading.createDelegate(a);this.setError=a.setError.createDelegate(a);this.on("hide",a.onHide,a)},addSource:function(){}});Ext.namespace("gxp.form");
  gxp.form.ViewerField=Ext.extend(Ext.form.TextArea,{viewer:null,initComponent:function(){this.width=this.width||350;this.height=this.height||220;gxp.form.ViewerField.superclass.initComponent.call(this)},onRender:function(){this.el||(this.defaultAutoCreate={tag:"textarea",style:{color:"transparent",background:"none"}});gxp.form.ViewerField.superclass.onRender.apply(this,arguments);this.viewerEl=Ext.get(document.createElement("div"));this.viewerEl.setStyle("position","absolute");this.viewerEl.on({mouseenter:function(){this.hasFocus||
  this.el.focus()},mousemove:function(){this.hasFocus||this.el.focus()},mouseleave:function(){this.hasFocus&&this.el.blur()},scope:this});this.el.dom.parentNode.appendChild(this.viewerEl.dom);this.viewerEl.anchorTo(this.el,"tl-tl");var a={border:!1,renderTo:this.viewerEl,width:this.width,height:this.height,style:"border: 1px solid transparent"},b=Ext.applyIf(this.initialConfig.viewer||{},{field:this,portalConfig:a});Ext.apply(b.portalConfig,a);this.viewer=new gxp.Viewer(b)}});
  Ext.reg("gxp_viewerfield",gxp.form.ViewerField);Ext.namespace("gxp");
  gxp.LayerUploadPanel=Ext.extend(Ext.FormPanel,{titleLabel:"Title",titleEmptyText:"Layer title",abstractLabel:"Description",abstractEmptyText:"Layer description",fileLabel:"Data",fieldEmptyText:"Browse for data archive...",uploadText:"Upload",waitMsgText:"Uploading your data...",invalidFileExtensionText:"File extension must be one of: ",optionsText:"Options",workspaceLabel:"Workspace",workspaceEmptyText:"Default workspace",dataStoreLabel:"Store",dataStoreEmptyText:"Default datastore",crsLabel:"CRS",
  crsEmptyText:"Coordinate Reference System ID",invalidCrsText:"CRS identifier should be an EPSG code (e.g. EPSG:4326)",fileUpload:!0,validFileExtensions:".zip,.tif,.gz,.tar.bz2,.tar,.tgz,.tbz2".split(","),constructor:function(a){a.errorReader={read:a.handleUploadResponse||this.handleUploadResponse.createDelegate(this)};gxp.LayerUploadPanel.superclass.constructor.call(this,a)},selectedWorkspace:null,initComponent:function(){this.items=[{xtype:"textfield",name:"title",fieldLabel:this.titleLabel,emptyText:this.titleEmptyText,
  allowBlank:!0},{xtype:"textarea",name:"abstract",fieldLabel:this.abstractLabel,emptyText:this.abstractEmptyText,allowBlank:!0},{xtype:"fileuploadfield",id:"file",emptyText:this.fieldEmptyText,fieldLabel:this.fileLabel,name:"file",buttonText:"",buttonCfg:{iconCls:"gxp-icon-filebrowse"},listeners:{fileselected:function(a,b){a.setValue(b.split(/[/\\]/).pop())}},validator:this.fileNameValidator.createDelegate(this)},{xtype:"fieldset",title:this.optionsText,checkboxToggle:!0,collapsed:!0,hidden:void 0!=
  this.workspace&&void 0!=this.store&&void 0!=this.crs,hideMode:"offsets",defaults:{anchor:"97%"},items:[this.createWorkspacesCombo(),this.createDataStoresCombo(),{xtype:"textfield",name:"crs",fieldLabel:this.crsLabel,emptyText:this.crsEmptyText,allowBlank:!0,regex:/^epsg:\d+$/i,regexText:this.invalidCrsText}],listeners:{collapse:function(a){a.items.each(function(a){a.reset()})}}}];this.buttons=[{text:this.uploadText,handler:function(){var a=this.getForm();a.isValid()&&a.submit({url:this.getUploadUrl(),
  submitEmptyText:!1,waitMsg:this.waitMsgText,waitMsgTarget:!0,reset:!0,success:this.handleUploadSuccess,scope:this})},scope:this}];this.addEvents("workspaceselected","datastoreselected","uploadcomplete");gxp.LayerUploadPanel.superclass.initComponent.call(this)},fileNameValidator:function(a){for(var b=!1,c,d=0,e=this.validFileExtensions.length;d<e;++d)if(c=this.validFileExtensions[d],a.slice(-c.length).toLowerCase()===c){b=!0;break}return b||this.invalidFileExtensionText+"<br/>"+this.validFileExtensions.join(", ")},
  createWorkspacesCombo:function(){return{xtype:"combo",name:"workspace",fieldLabel:this.workspaceLabel,emptyText:this.workspaceEmptyText,store:new Ext.data.JsonStore({url:this.getWorkspacesUrl(),autoLoad:!0,root:"workspaces.workspace",fields:["name","href"]}),displayField:"name",valueField:"name",mode:"local",allowBlank:!0,triggerAction:"all",editable:!1,listeners:{select:function(a,b){this.fireEvent("workspaceselected",this,b)},scope:this}}},createDataStoresCombo:function(){var a=new Ext.data.JsonStore({autoLoad:!1,
  root:"dataStores.dataStore",fields:["name","href"]});this.on({workspaceselected:function(c,d){b.reset();var e=d.get("href");a.removeAll();a.proxy=new Ext.data.HttpProxy({url:e.split(".json").shift()+"/datastores.json"});a.load()},scope:this});var b=new Ext.form.ComboBox({name:"store",fieldLabel:this.dataStoreLabel,emptyText:this.dataStoreEmptyText,store:a,displayField:"name",valueField:"name",mode:"local",allowBlank:!0,triggerAction:"all",editable:!1,listeners:{select:function(a,b){this.fireEvent("datastoreselected",
  this,b)},scope:this}});return b},getUploadUrl:function(){return this.url+"/upload"},getWorkspacesUrl:function(){return this.url+"/workspaces.json"},handleUploadResponse:function(a){var b=(a=this.parseResponseText(a.responseText))&&a.success,c=[];b||(c=[{data:{id:"file",msg:a.message}}]);return{success:b,records:c}},parseResponseText:function(a){var b;try{b=Ext.decode(a)}catch(c){if(a=a.match(/^\s*<pre>(.*)<\/pre>\s*/))try{b=Ext.decode(a[1])}catch(d){}}return b},handleUploadSuccess:function(a,b){this.fireEvent("uploadcomplete",
  this,this.parseResponseText(b.response.responseText))}});Ext.reg("gxp_layeruploadpanel",gxp.LayerUploadPanel);Ext.namespace("gxp");
  gxp.StylePropertiesDialog=Ext.extend(Ext.Container,{titleText:"General",nameFieldText:"Name",titleFieldText:"Title",abstractFieldText:"Abstract",userStyle:null,initComponent:function(){Ext.applyIf(this,{layout:"form",items:[{xtype:"fieldset",title:this.titleText,labelWidth:75,defaults:{xtype:"textfield",anchor:"100%",listeners:{change:function(a,b){this.userStyle[a.name]=b;this.fireEvent("change",this,this.userStyle)},scope:this}},items:[{xtype:this.initialConfig.nameEditable?"textfield":"displayfield",
  fieldLabel:this.nameFieldText,name:"name",value:this.userStyle.name,maskRe:/[A-Za-z0-9_]/},{fieldLabel:this.titleFieldText,name:"title",value:this.userStyle.title},{xtype:"textarea",fieldLabel:this.abstractFieldText,name:"description",value:this.userStyle.description}]}]});this.addEvents("change");gxp.StylePropertiesDialog.superclass.initComponent.apply(this,arguments)}});Ext.reg("gxp_stylepropertiesdialog",gxp.StylePropertiesDialog);Ext.namespace("gxp");
  gxp.WMSStylesDialog=Ext.extend(Ext.Container,{addStyleText:"Add",addStyleTip:"Add a new style",chooseStyleText:"Choose style",deleteStyleText:"Remove",deleteStyleTip:"Delete the selected style",editStyleText:"Edit",editStyleTip:"Edit the selected style",duplicateStyleText:"Duplicate",duplicateStyleTip:"Duplicate the selected style",addRuleText:"Add",addRuleTip:"Add a new rule",newRuleText:"New Rule",deleteRuleText:"Remove",deleteRuleTip:"Delete the selected rule",editRuleText:"Edit",editRuleTip:"Edit the selected rule",
  duplicateRuleText:"Duplicate",duplicateRuleTip:"Duplicate the selected rule",cancelText:"Cancel",saveText:"Save",styleWindowTitle:"User Style: {0}",ruleWindowTitle:"Style Rule: {0}",stylesFieldsetTitle:"Styles",rulesFieldsetTitle:"Rules",layerRecord:null,layerDescription:null,symbolType:null,stylesStore:null,selectedStyle:null,selectedRule:null,editable:!0,modified:!1,dialogCls:Ext.Window,initComponent:function(){this.addEvents("ready","modified","styleselected","beforesaved","saved");Ext.applyIf(this,
  {layout:"form",disabled:!0,items:[{xtype:"fieldset",title:this.stylesFieldsetTitle,labelWidth:85,style:"margin-bottom: 0;"},{xtype:"toolbar",style:"border-width: 0 1px 1px 1px; margin-bottom: 10px;",items:[{xtype:"button",iconCls:"add",text:this.addStyleText,tooltip:this.addStyleTip,handler:this.addStyle,scope:this},{xtype:"button",iconCls:"delete",text:this.deleteStyleText,tooltip:this.deleteStyleTip,handler:function(){this.stylesStore.remove(this.selectedStyle)},scope:this},{xtype:"button",iconCls:"edit",
  text:this.editStyleText,tooltip:this.editStyleTip,handler:function(){this.editStyle()},scope:this},{xtype:"button",iconCls:"duplicate",text:this.duplicateStyleText,tooltip:this.duplicateStyleTip,handler:function(){var a=this.selectedStyle,b=a.get("userStyle").clone();b.isDefault=!1;b.name=this.newStyleName();var c=this.stylesStore;c.add(new c.recordType({name:b.name,title:b.title,"abstract":b.description,userStyle:b}));this.editStyle(a)},scope:this}]}]});this.createStylesStore();this.on({beforesaved:function(){this._saving=
  !0},saved:function(){delete this._saving},render:function(){gxp.util.dispatch([this.getStyles],function(){this.enable()},this)},scope:this});gxp.WMSStylesDialog.superclass.initComponent.apply(this,arguments)},addStyle:function(){if(this._ready){var a=this.selectedStyle,b=this.stylesStore,c=new OpenLayers.Style(null,{name:this.newStyleName(),rules:[this.createRule()]});b.add(new b.recordType({name:c.name,userStyle:c}));this.editStyle(a)}else this.on("ready",this.addStyle,this)},editStyle:function(a){var b=
  this.selectedStyle.get("userStyle"),c=new this.dialogCls(Ext.apply({bbar:["->",{text:this.cancelText,iconCls:"cancel",handler:function(){c.propertiesDialog.userStyle=b;c.close();a&&(this._cancelling=!0,this.stylesStore.remove(this.selectedStyle),this.changeStyle(a,{updateCombo:!0,markModified:!0}),delete this._cancelling)},scope:this},{text:this.saveText,iconCls:"save",handler:function(){c.close()}}]},{title:String.format(this.styleWindowTitle,b.title||b.name),shortTitle:b.title||b.name,bodyBorder:!1,
  autoHeight:!0,width:300,modal:!0,items:{border:!1,items:{xtype:"gxp_stylepropertiesdialog",ref:"../propertiesDialog",userStyle:b.clone(),nameEditable:!1,style:"padding: 10px;"}},listeners:{close:function(){this.selectedStyle.set("userStyle",c.propertiesDialog.userStyle)},scope:this}}));this.showDlg(c)},createSLD:function(a){var a=a||{},b={version:"1.0.0",namedLayers:{}},c=this.layerRecord.get("name");b.namedLayers[c]={name:c,userStyles:[]};this.stylesStore.each(function(d){(!a.userStyles||-1!==a.userStyles.indexOf(d.get("name")))&&
  b.namedLayers[c].userStyles.push(d.get("userStyle"))});return(new OpenLayers.Format.SLD({multipleSymbolizers:!0,profile:"GeoServer"})).write(b)},saveStyles:function(a){!0===this.modified&&this.fireEvent("beforesaved",this,a)},updateStyleRemoveButton:function(){var a=this.selectedStyle&&this.selectedStyle.get("userStyle");this.items.get(1).items.get(1).setDisabled(!a||1>=this.stylesStore.getCount()||!0===a.isDefault)},updateRuleRemoveButton:function(){this.items.get(3).items.get(1).setDisabled(!this.selectedRule)},
  createRule:function(){return new OpenLayers.Rule({symbolizers:[new OpenLayers.Symbolizer[this.symbolType]]})},addRulesFieldSet:function(){var a=new Ext.form.FieldSet({itemId:"rulesfieldset",title:this.rulesFieldsetTitle,autoScroll:!0,style:"margin-bottom: 0;",hideMode:"offsets",hidden:!0}),b=new Ext.Toolbar({style:"border-width: 0 1px 1px 1px;",hidden:!0,items:[{xtype:"button",iconCls:"add",text:this.addRuleText,tooltip:this.addRuleTip,handler:this.addRule,scope:this},{xtype:"button",iconCls:"delete",
  text:this.deleteRuleText,tooltip:this.deleteRuleTip,handler:this.removeRule,scope:this,disabled:!0},{xtype:"button",iconCls:"edit",text:this.editRuleText,toolitp:this.editRuleTip,handler:function(){this.layerDescription?this.editRule():this.describeLayer(this.editRule)},scope:this,disabled:!0},{xtype:"button",iconCls:"duplicate",text:this.duplicateRuleText,tip:this.duplicateRuleTip,handler:this.duplicateRule,scope:this,disabled:!0}]});this.add(a,b);this.doLayout();return a},addRule:function(){var a=
  this.items.get(2).items.get(0);this.selectedStyle.get("userStyle").rules.push(this.createRule());a.update();this.selectedStyle.store.afterEdit(this.selectedStyle);this.updateRuleRemoveButton()},removeRule:function(){this.selectedStyle.get("userStyle").rules.remove(this.selectedRule);this.afterRuleChange()},duplicateRule:function(){var a=this.items.get(2).items.get(0),b=this.selectedRule.clone();this.selectedStyle.get("userStyle").rules.push(b);a.update();this.selectedStyle.store.afterEdit(this.selectedStyle);
  this.updateRuleRemoveButton()},editRule:function(){var a=this.selectedRule,b=a.clone(),c=new this.dialogCls({title:String.format(this.ruleWindowTitle,a.title||a.name||this.newRuleText),shortTitle:a.title||a.name||this.newRuleText,width:340,autoHeight:!0,modal:!0,items:[{xtype:"gxp_rulepanel",ref:"rulePanel",symbolType:this.symbolType,rule:a,attributes:new GeoExt.data.AttributeStore({url:this.layerDescription.owsURL,baseParams:{SERVICE:this.layerDescription.owsType,REQUEST:"DescribeFeatureType",TYPENAME:this.layerDescription.typeName},
  method:"GET",disableCaching:!1}),autoScroll:!0,border:!1,defaults:{autoHeight:!0,hideMode:"offsets"},listeners:{change:this.saveRule,tabchange:function(){c instanceof Ext.Window&&c.syncShadow()},scope:this}}],bbar:["->",{text:this.cancelText,iconCls:"cancel",handler:function(){this.saveRule(c.rulePanel,b);c.close()},scope:this},{text:this.saveText,iconCls:"save",handler:function(){c.close()}}]});this.showDlg(c)},saveRule:function(a,b){var c=this.selectedStyle;this.items.get(2).items.get(0);var c=
  c.get("userStyle"),d=c.rules.indexOf(this.selectedRule);c.rules[d]=b;this.afterRuleChange(b)},afterRuleChange:function(a){this.items.get(2).items.get(0);this.selectedRule=a;this.selectedStyle.store.afterEdit(this.selectedStyle)},setRulesFieldSetVisible:function(a){this.items.get(3).setVisible(a&&this.editable);this.items.get(2).setVisible(a);this.doLayout()},parseSLD:function(a){var b=a.responseXML;if(!b||!b.documentElement)b=(new OpenLayers.Format.XML).read(a.responseText);var a=this.layerRecord.getLayer().params,
  c=this.initialConfig.styleName||a.STYLES;c&&(this.selectedStyle=this.stylesStore.getAt(this.stylesStore.findExact("name",c)));var d=new OpenLayers.Format.SLD({profile:"GeoServer",multipleSymbolizers:!0});try{var e=d.read(b).namedLayers[a.LAYERS].userStyles,f;a.SLD_BODY&&(f=d.read(a.SLD_BODY).namedLayers[a.LAYERS].userStyles,Array.prototype.push.apply(e,f));this.stylesStore.removeAll();this.selectedStyle=null;for(var g,h,j,b=0,k=e.length;b<k;++b)if(g=e[b],j=this.stylesStore.findExact("name",g.name),
  -1!==j&&this.stylesStore.removeAt(j),h=new this.stylesStore.recordType({name:g.name,title:g.title,"abstract":g.description,userStyle:g}),h.phantom=!1,this.stylesStore.add(h),!this.selectedStyle&&(c===g.name||!c&&!0===g.isDefault))this.selectedStyle=h;this.addRulesFieldSet();this.createLegend(this.selectedStyle.get("userStyle").rules);this.stylesStoreReady();a.SLD_BODY&&this.markModified()}catch(l){this.setupNonEditable()}},createLegend:function(a){var b=OpenLayers.Symbolizer.Raster;if(b&&a[0]&&a[0].symbolizers[0]instanceof
  b)throw Error("Raster symbolizers are not supported.");this.addVectorLegend(a)},setupNonEditable:function(){this.editable=!1;this.items.get(1).hide();(this.getComponent("rulesfieldset")||this.addRulesFieldSet()).add(this.createLegendImage());this.doLayout();this.items.get(3).hide();this.stylesStoreReady()},stylesStoreReady:function(){this.stylesStore.commitChanges();this.stylesStore.on({load:function(){this.addStylesCombo();this.updateStyleRemoveButton()},add:function(a,b,c){this.updateStyleRemoveButton();
  b=this.items.get(0).items.get(0);this.markModified();b.fireEvent("select",b,a.getAt(c),c);b.setValue(this.selectedStyle.get("name"))},remove:function(a,b,c){this._cancelling||(this._removing=!0,b=Math.min(c,a.getCount()-1),this.updateStyleRemoveButton(),c=this.items.get(0).items.get(0),this.markModified(),c.fireEvent("select",c,a.getAt(b),b),c.setValue(this.selectedStyle.get("name")),delete this._removing)},update:function(a,b){var c=b.get("userStyle");Ext.apply(b.data,{name:c.name,title:c.title||
  c.name,"abstract":c.description});this.changeStyle(b,{updateCombo:!0,markModified:!0})},scope:this});this.stylesStore.fireEvent("load",this.stylesStore,this.stylesStore.getRange());this._ready=!0;this.fireEvent("ready")},markModified:function(){!1===this.modified&&(this.modified=!0);this._saving||this.fireEvent("modified",this,this.selectedStyle.get("name"))},createStylesStore:function(){var a=this.layerRecord.get("styles");this.stylesStore=new Ext.data.JsonStore({data:{styles:a},idProperty:"name",
  root:"styles",fields:["name","title","abstract","legend","userStyle"],listeners:{add:function(a,c){for(var d,e=c.length-1;0<=e;--e)d=c[e],a.suspendEvents(),d.get("title")||d.set("title",d.get("name")),a.resumeEvents()}}})},getStyles:function(a){var b=this.layerRecord.getLayer();if(!0===this.editable){var c=b.params.VERSION;1.1<parseFloat(c)&&(c="1.1.1");Ext.Ajax.request({url:b.url,params:{SERVICE:"WMS",VERSION:c,REQUEST:"GetStyles",LAYERS:""+b.params.LAYERS},method:"GET",disableCaching:!1,success:this.parseSLD,
  failure:this.setupNonEditable,callback:a,scope:this})}else this.setupNonEditable()},describeLayer:function(a){if(this.layerDescription)window.setTimeout(function(){a.call(this)},0);else{var b=this.layerRecord.getLayer(),c=b.params.VERSION;1.1<parseFloat(c)&&(c="1.1.1");Ext.Ajax.request({url:b.url,params:{SERVICE:"WMS",VERSION:c,REQUEST:"DescribeLayer",LAYERS:""+b.params.LAYERS},method:"GET",disableCaching:!1,success:function(a){this.layerDescription=(new OpenLayers.Format.WMSDescribeLayer).read(a.responseXML&&
  a.responseXML.documentElement?a.responseXML:a.responseText)[0]},callback:a,scope:this})}},addStylesCombo:function(){var a=this.stylesStore,a=new Ext.form.ComboBox(Ext.apply({fieldLabel:this.chooseStyleText,store:a,editable:!1,displayField:"title",valueField:"name",value:this.selectedStyle?this.selectedStyle.get("title"):this.layerRecord.getLayer().params.STYLES||"default",disabled:!a.getCount(),mode:"local",typeAhead:!0,triggerAction:"all",forceSelection:!0,anchor:"100%",listeners:{select:function(a,
  c){this.changeStyle(c);!c.phantom&&!this._removing&&this.fireEvent("styleselected",this,c.get("name"))},scope:this}},this.initialConfig.stylesComboOptions));this.items.get(0).add(a);this.doLayout()},createLegendImage:function(){var a=new GeoExt.WMSLegend({showTitle:!1,layerRecord:this.layerRecord,autoScroll:!0,defaults:{listeners:{render:function(b){b.getEl().on({load:function(c,d){d.getAttribute("src")!=b.defaultImgSrc&&(this.setRulesFieldSetVisible(!0),250<b.getEl().getHeight()&&a.setHeight(250))},
  error:function(){this.setRulesFieldSetVisible(!1)},scope:this})},scope:this}}});return a},changeStyle:function(a,b){var b=b||{},c=this.items.get(2).items.get(0);this.selectedStyle=a;this.updateStyleRemoveButton();a.get("name");if(!0===this.editable){var d=a.get("userStyle"),e=c.rules.indexOf(this.selectedRule);c.ownerCt.remove(c);this.createLegend(d.rules,{selectedRuleIndex:e})}!0===b.updateCombo&&(this.items.get(0).items.get(0).setValue(d.name),!0===b.markModified&&this.markModified())},addVectorLegend:function(a,
  b){b=Ext.applyIf(b||{},{enableDD:!0});this.symbolType=b.symbolType;if(!this.symbolType){var c=["Point","Line","Polygon"];highest=0;for(var d=a[0].symbolizers,e,f=d.length-1;0<=f;f--)e=d[f].CLASS_NAME.split(".").pop(),highest=Math.max(highest,c.indexOf(e));this.symbolType=c[highest]}var g=this.items.get(2).add({xtype:"gx_vectorlegend",showTitle:!1,height:10<a.length?250:void 0,autoScroll:10<a.length,rules:a,symbolType:this.symbolType,selectOnClick:!0,enableDD:b.enableDD,listeners:{ruleselected:function(a,
  b){this.selectedRule=b;var c=this.items.get(3).items;this.updateRuleRemoveButton();c.get(2).enable();c.get(3).enable()},ruleunselected:function(){this.selectedRule=null;var a=this.items.get(3).items;a.get(1).disable();a.get(2).disable();a.get(3).disable()},rulemoved:function(){this.markModified()},afterlayout:function(){null!==this.selectedRule&&null===g.selectedRule&&-1!==g.rules.indexOf(this.selectedRule)&&g.selectRuleEntry(this.selectedRule)},scope:this}});this.setRulesFieldSetVisible(!0);return g},
  newStyleName:function(){var a=this.layerRecord.get("name");return a.split(":").pop()+"_"+gxp.util.md5(a+new Date+Math.random()).substr(0,8)},showDlg:function(a){a.show()}});
  gxp.WMSStylesDialog.createGeoServerStylerConfig=function(a,b){var c=a.getLayer();b||(b=a.get("restUrl"));b||(b=c.url.split("?").shift().replace(/\/(wms|ows)\/?$/,"/rest"));return{xtype:"gxp_wmsstylesdialog",layerRecord:a,plugins:[{ptype:"gxp_geoserverstylewriter",baseUrl:b}],listeners:{styleselected:function(a,b){c.mergeNewParams({styles:b})},modified:function(a){a.saveStyles()},saved:function(a,b){c.mergeNewParams({_olSalt:Math.random(),styles:b})},scope:this}}};
  OpenLayers.Renderer.defaultSymbolizer={fillColor:"#808080",fillOpacity:1,strokeColor:"#000000",strokeOpacity:1,strokeWidth:1,strokeDashstyle:"solid",pointRadius:3,graphicName:"square",fontColor:"#000000",fontSize:10,haloColor:"#FFFFFF",haloOpacity:1,haloRadius:1,labelAlign:"cm"};Ext.reg("gxp_wmsstylesdialog",gxp.WMSStylesDialog);Ext.namespace("gxp");
  gxp.PolygonSymbolizer=Ext.extend(Ext.Panel,{symbolizer:null,initComponent:function(){this.items=[{xtype:"gxp_fillsymbolizer",symbolizer:this.symbolizer,listeners:{change:function(){this.fireEvent("change",this.symbolizer)},scope:this}},{xtype:"gxp_strokesymbolizer",symbolizer:this.symbolizer,listeners:{change:function(){this.fireEvent("change",this.symbolizer)},scope:this}}];this.addEvents("change");gxp.PolygonSymbolizer.superclass.initComponent.call(this)}});Ext.reg("gxp_polygonsymbolizer",gxp.PolygonSymbolizer);
  Ext.namespace("gxp.plugins");
  gxp.plugins.WMSCSource=Ext.extend(gxp.plugins.WMSSource,{ptype:"gxp_wmscsource",version:"1.1.1",constructor:function(a){a.baseParams={SERVICE:"WMS",REQUEST:"GetCapabilities",TILED:!0};a.format||(this.format=new OpenLayers.Format.WMSCapabilities({keepData:!0,profile:"WMSC"}));gxp.plugins.WMSCSource.superclass.constructor.apply(this,arguments)},createLayerRecord:function(a){var b=gxp.plugins.WMSCSource.superclass.createLayerRecord.apply(this,arguments);if(b){var c;this.store.reader.raw&&(c=this.store.reader.raw.capability);
  var d=c&&c.vendorSpecific?c.vendorSpecific.tileSets:a.capability&&a.capability.tileSets;c=b.get("layer");if(d)for(var e=this.getProjection(b)||this.getMapProjection(),f=0,g=d.length;f<g;f++){var h=d[f];if(h.layers===c.params.LAYERS){var j,k;for(k in h.srs){j=new OpenLayers.Projection(k);break}if(e.equals(j)){k=h.bbox[k].bbox;c.projection=j;c.addOptions({resolutions:h.resolutions,tileSize:new OpenLayers.Size(h.width,h.height),tileOrigin:new OpenLayers.LonLat(k[0],k[1])});break}}}else this.lazy&&(j=
  a.tileSize,h=a.tileOrigin,c.addOptions({resolutions:a.resolutions,tileSize:j?new OpenLayers.Size(j[0],j[1]):void 0,tileOrigin:h?OpenLayers.LonLat.fromArray(h):void 0}),h||(c.tileOrigin=OpenLayers.LonLat.fromArray(this.target.map.maxExtent)));c.params.TILED=!1!==a.cached&&!0;return b}},getConfigForRecord:function(a){var b=gxp.plugins.WMSCSource.superclass.getConfigForRecord.apply(this,arguments),c=b.name,d,e=a.getLayer();if(b.capability){d=this.store.reader.raw.capability;var f=d.vendorSpecific&&d.vendorSpecific.tileSets;
  if(f)for(var g=f.length-1;0<=g;--g)if(d=f[g],d.layers===c&&d.srs[e.projection]){b.capability.tileSets=[d];break}}if(!b.capability||!b.capability.tileSets){if(c=e.options.tileSize)b.tileSize=[c.w,c.h];b.tileOrigin=e.options.tileOrigin;b.resolutions=e.options.resolutions}return Ext.applyIf(b,{cached:!!e.params.TILED})}});Ext.preg(gxp.plugins.WMSCSource.prototype.ptype,gxp.plugins.WMSCSource);Ext.namespace("gxp.plugins");
  gxp.plugins.SnappingAgent=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_snappingagent",init:function(a){gxp.plugins.SnappingAgent.superclass.init.apply(this,arguments);this.snappingTargets=[];this.controls={};this.setSnappingTargets(this.targets)},setSnappingTargets:function(a){this.clearSnappingTargets();if(a)for(var b=0,c=a.length;b<c;++b)this.addSnappingTarget(a[b])},clearSnappingTargets:function(){for(var a,b=0,c=this.snappingTargets.length;b<c;++b)a=this.snappingTargets[b],a.layer&&a.layer.destroy();
  this.snappingTargets.length=0},addSnappingTarget:function(a){var a=Ext.apply({},a),b=this.target.mapPanel.map,c=new OpenLayers.Layer.Vector(a.name,{strategies:[new OpenLayers.Strategy.BBOX({ratio:1.5,autoActivate:!1})],displayInLayerSwitcher:!1,visibility:!1,minResolution:a.minResolution,maxResolution:a.maxResolution});a.layer=c;this.snappingTargets.push(a);var d=new gxp.plugins.FeatureManager({maxFeatures:null,paging:!1,layer:{source:a.source,name:a.name},listeners:{layerchange:function(){c.protocol=
  d.featureStore.proxy.protocol;b.addLayer(c);b.events.on({moveend:function(){this.updateSnappingTarget(a)},scope:this});this.updateSnappingTarget(a);this.target.on({featureedit:function(b,c){c.name==a.name&&c.source==a.source&&this.updateSnappingTarget(a,{force:!0})},scope:this})},scope:this}});d.init(this.target)},updateSnappingTarget:function(a,b){var c=a.minResolution||Number.NEGATIVE_INFINITY,d=a.maxResolution||Number.POSITIVE_INFINITY,e=this.target.mapPanel.map.getResolution();c<=e&&e<d&&a.layer.strategies[0].update(b)},
  createSnappingControl:function(a){return new OpenLayers.Control.Snapping(Ext.applyIf({layer:a},this.initialConfig.controlOptions||this.initialConfig.options||{}))},registerEditor:function(a){var b=this.createSnappingControl(a.getFeatureManager().featureLayer);this.controls[a.id]=b;a.on({layereditable:this.onLayerEditable,featureeditable:this.onFeatureEditable,scope:this})},onLayerEditable:function(a,b,c){a=this.controls[a.id];if(c){for(var c=[],d,e,f=b.get("source"),g=b.get("name"),h=0,j=this.snappingTargets.length;h<
  j;++h)if(b=this.snappingTargets[h],b.restrictedLayers){e=!1;for(var k=0,l=b.restrictedLayers.length;k<l;++k)if(d=b.restrictedLayers[k],d.source===f&&d.name===g){e=!0;break}e&&c.push(b)}else c.push(b);a.setTargets(c);a.activate()}else a.deactivate()},onFeatureEditable:function(a,b,c){for(var d=a.getFeatureManager().layerRecord,a=d.get("source"),d=d.get("name"),e,f,g,h=0,j=this.snappingTargets.length;h<j;++h)e=this.snappingTargets[h],a===e.source&&d===e.name&&(f=this.targets[h].filter,!b||!b.fid||!c?
  e.filter=f:(g=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.NOT,filters:[new OpenLayers.Filter.FeatureId({fids:[b.fid]})]}),e.filter=f?new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:[f,g]}):g))}});Ext.preg(gxp.plugins.SnappingAgent.prototype.ptype,gxp.plugins.SnappingAgent);Ext.namespace("gxp");
  gxp.Viewer=Ext.extend(Ext.util.Observable,{defaultToolType:"gxp_tool",tools:null,selectedLayer:null,constructor:function(a){this.addEvents("ready","portalready","beforelayerselectionchange","layerselectionchange","featureedit","authorizationchange");Ext.apply(this,{layerSources:{},portalItems:[]});this.createLayerRecordQueue=[];(a.loadConfig||this.loadConfig).call(this,a,this.applyConfig);gxp.Viewer.superclass.constructor.apply(this,arguments)},selectLayer:function(a){var a=a||null,b=!1;!1!==this.fireEvent("beforelayerselectionchange",
  a)&&(b=!0,this.selectedLayer&&this.selectedLayer.set("selected",!1),(this.selectedLayer=a)&&this.selectedLayer.set("selected",!0),this.fireEvent("layerselectionchange",a));return b},loadConfig:function(a){this.applyConfig(a)},applyConfig:function(a){this.initialConfig=Ext.apply({},a);Ext.apply(this,this.initialConfig);this.load()},load:function(){this.proxy&&(OpenLayers.ProxyHost=this.proxy);this.initMapPanel();this.initTools();var a=[],b;for(b in this.sources)a.push(this.createSourceLoader(b));a.push(function(a){Ext.onReady(function(){this.initPortal();
  a()},this)});gxp.util.dispatch(a,this.activate,this)},createSourceLoader:function(a){return function(b){var c=this.sources[a];c.projection=this.initialConfig.map.projection;this.addLayerSource({id:a,config:c,callback:b,fallback:function(){b()},scope:this})}},addLayerSource:function(a){var b=a.id||Ext.id(null,"gxp-source-"),c,d=a.config;d.id=b;try{c=Ext.ComponentMgr.createPlugin(d,this.defaultSourceType)}catch(e){throw Error("Could not create new source plugin with ptype: "+a.config.ptype);}c.on({ready:{fn:function(){(a.callback||
  Ext.emptyFn).call(a.scope||this,b)},scope:this,single:!0},failure:{fn:function(){var c=a.fallback||Ext.emptyFn;delete this.layerSources[b];c.apply(a.scope||this,arguments)},scope:this,single:!0}});this.layerSources[b]=c;c.init(this);return c},initMapPanel:function(){var a=Ext.apply({},this.initialConfig.map),b={},c={wrapDateLine:void 0!==a.wrapDateLine?a.wrapDateLine:!0,numZoomLevels:a.numZoomLevels,displayInLayerSwitcher:!1};if(this.initialConfig.map)for(var d="theme,controls,resolutions,projection,units,maxExtent,restrictedExtent,maxResolution,numZoomLevels,panMethod".split(","),
  e,f=d.length-1;0<=f;--f)e=d[f],e in a&&(b[e]=a[e],delete a[e]);this.mapPanel=Ext.ComponentMgr.create(Ext.applyIf({xtype:a.xtype||"gx_mappanel",map:Ext.applyIf({theme:b.theme||null,controls:b.controls||[new OpenLayers.Control.Navigation({zoomWheelOptions:{interval:250},dragPanOptions:{enableKinetic:!0}}),new OpenLayers.Control.PanPanel,new OpenLayers.Control.ZoomPanel,new OpenLayers.Control.Attribution],maxExtent:b.maxExtent&&OpenLayers.Bounds.fromArray(b.maxExtent),restrictedExtent:b.restrictedExtent&&
  OpenLayers.Bounds.fromArray(b.restrictedExtent),numZoomLevels:b.numZoomLevels||20},b),center:a.center&&new OpenLayers.LonLat(a.center[0],a.center[1]),resolutions:a.resolutions,forceInitialExtent:!0,layers:[new OpenLayers.Layer(null,c)],items:this.mapItems,plugins:this.mapPlugins,tbar:a.tbar||new Ext.Toolbar({hidden:!0,listeners:{show:function(){this.mapPanel.map.updateSize()},scope:this}})},a));this.mapPanel.layers.on({add:function(a,b){for(var c,d=b.length-1;0<=d;d--)c=b[d],!0===c.get("selected")&&
  this.selectLayer(c)},remove:function(a,b){!0===b.get("selected")&&this.selectLayer()},scope:this})},initTools:function(){this.tools={};if(this.initialConfig.tools&&0<this.initialConfig.tools.length)for(var a,b=0,c=this.initialConfig.tools.length;b<c;b++){try{a=Ext.ComponentMgr.createPlugin(this.initialConfig.tools[b],this.defaultToolType)}catch(d){throw Error("Could not create tool plugin with ptype: "+this.initialConfig.tools[b].ptype);}a.init(this)}},initPortal:function(){var a=this.portalConfig||
  {};0===this.portalItems.length&&(this.mapPanel.region="center",this.portalItems.push(this.mapPanel));this.portal=Ext.ComponentMgr.create(Ext.applyIf(a,{layout:"fit",hideBorders:!0,items:{layout:"border",deferredRender:!1,items:this.portalItems}}),a.renderTo?"panel":"viewport");this.fireEvent("portalready")},activate:function(){Ext.QuickTips.init();this.addLayers();this.checkLayerRecordQueue();this.fireEvent("ready")},addLayers:function(){var a=this.initialConfig.map;if(a&&a.layers){for(var b,c,d=
  [],e=[],f=0;f<a.layers.length;++f)if(b=a.layers[f],c=this.layerSources[b.source])(b=c.createLayerRecord(b))&&("background"===b.get("group")?d.push(b):e.push(b));d.sort(function(a,b){return a.getLayer().visibility<b.getLayer().visibility});a=this.mapPanel;d=d.concat(e);d.length&&a.layers.add(d)}},getLayerRecordFromMap:function(a){var b=null;this.mapPanel&&this.mapPanel.layers.each(function(c){if(c.get("source")==a.source&&c.get("name")==a.name)return b=c,!1});return b},createLayerRecord:function(a,
  b,c){this.createLayerRecordQueue.push({config:a,callback:b,scope:c});this.checkLayerRecordQueue()},checkLayerRecordQueue:function(){for(var a,b,c,d,e=[],f=0,g=this.createLayerRecordQueue.length;f<g;++f)d=!1,a=this.createLayerRecordQueue[f],b=a.config.source,b in this.layerSources&&(b=this.layerSources[b],(c=b.createLayerRecord(a.config))?(function(a,b){window.setTimeout(function(){a.callback.call(a.scope,b)},0)}(a,c),d=!0):b.lazy&&b.store.load({callback:this.checkLayerRecordQueue,scope:this})),d||
  e.push(a);this.createLayerRecordQueue=e},getSource:function(a){return a&&this.layerSources[a.get("source")]},getState:function(){var a=Ext.apply({},this.initialConfig),b=this.mapPanel.map.getCenter();Ext.apply(a.map,{center:[b.lon,b.lat],zoom:this.mapPanel.map.zoom,layers:[]});var c={};this.mapPanel.layers.each(function(b){if(b.getLayer().displayInLayerSwitcher){var e=b.get("source"),f=this.layerSources[e];if(!f)throw Error("Could not find source for layer '"+b.get("name")+"'");a.map.layers.push(f.getConfigForRecord(b));
  c[e]||(c[e]=f.getState())}},this);Ext.apply(this.sources,c);a.tools=[];Ext.iterate(this.tools,function(b,c){c.getState!=gxp.plugins.Tool.prototype.getState&&a.tools.push(c.getState())});return a},isAuthorized:function(a){return!this.authorizedRoles||-1!==this.authorizedRoles.indexOf(a||"ROLE_ADMINISTRATOR")},setAuthorizedRoles:function(a){this.authorizedRoles=a;this.fireEvent("authorizationchange")},isAuthenticated:function(){return!this.authorizedRoles||0<this.authorizedRoles.length},destroy:function(){this.mapPanel.destroy();
  this.portal&&this.portal.destroy()}});(function(){OpenLayers.DOTS_PER_INCH=25.4/0.28})();Ext.ns("gxp.data");
  gxp.data.AutoCompleteReader=Ext.extend(GeoExt.data.FeatureReader,{read:function(a){var b=this.meta.uniqueField;this.features=[];for(var c=0,d=a.features.length;c<d;++c){var e=a.features[c];!1===this.isDuplicate(b,e.attributes[b])?this.features.push(e):e.destroy()}a.features=this.features;return gxp.data.AutoCompleteReader.superclass.read.apply(this,arguments)},isDuplicate:function(a,b){for(var c=0,d=this.features.length;c<d;++c)if(this.features[c].attributes[a]===b)return!0;return!1}});Ext.namespace("gxp.plugins");
  gxp.plugins.TimelineLayers=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_timelinelayers",menuText:"Layers",addActions:function(){return gxp.plugins.TimelineLayers.superclass.addActions.apply(this,[{text:this.menuText,iconCls:"gxp-icon-layer-switcher",menu:new gxp.menu.TimelineMenu({layers:this.target.mapPanel.layers,timelineTool:this.target.tools[this.timelineTool]})}])}});Ext.preg(gxp.plugins.TimelineLayers.prototype.ptype,gxp.plugins.TimelineLayers);Ext.namespace("gxp.plugins");
  gxp.plugins.WizardContainer={init:function(a){a.addEvents("wizardstepvalid","wizardstepinvalid","wizardstepexpanded");a.on("add",function(b){b.on("expand",function(){a.fireEvent("wizardstepexpanded",a.items.indexOf(b))})})}};Ext.preg("gxp_wizardcontainer",gxp.plugins.WizardContainer);Ext.namespace("gxp.grid");
  gxp.grid.CapabilitiesGrid=Ext.extend(Ext.grid.GridPanel,{store:null,cm:null,expander:null,mapPanel:null,url:null,autoExpandColumn:"title",allowNewSources:!0,nameHeaderText:"Name",titleHeaderText:"Title",queryableHeaderText:"Queryable",layerSelectionLabel:"View available data from:",layerAdditionLabel:"or add a new server.",expanderTemplateText:"<p><b>Abstract:</b> {abstract}</p>",constructor:function(){this.addEvents("sourceselected");gxp.grid.CapabilitiesGrid.superclass.constructor.apply(this,arguments)},
  initComponent:function(){this.store||(this.store=new GeoExt.data.WMSCapabilitiesStore({url:this.url+"?service=wms&request=GetCapabilities"}),this.store.load());this.on("afterrender",function(){this.fireEvent("sourceselected",this,this.store)},this);"expander"in this||(this.expander=new Ext.grid.RowExpander({tpl:new Ext.Template(this.expanderTemplateText)}));!this.plugins&&this.expander&&(this.plugins=this.expander);if(!this.cm){var a=[{id:"title",header:this.titleHeaderText,dataIndex:"title",sortable:!0},
  {header:this.nameHeaderText,dataIndex:"name",width:180,sortable:!0},{header:this.queryableHeaderText,dataIndex:"queryable",width:70,renderer:function(a,b){b.css="x-btn";var e="x-btn cancel";a&&(e="x-btn add");return'<div style="background-repeat: no-repeat; background-position: 50% 0%; height: 16px;" class="'+e+'">&nbsp;</div>'}}];this.expander&&a.unshift(this.expander);this.cm=new Ext.grid.ColumnModel(a)}"allowNewSources"in this||(this.allowNewSources=!!this.metaStore);if(this.allowNewSources||this.metaStore&&
  1<this.metaStore.getCount())this.sourceComboBox=new Ext.form.ComboBox({store:this.metaStore,valueField:"identifier",displayField:"name",triggerAction:"all",editable:!1,allowBlank:!1,forceSelection:!0,mode:"local",value:this.metaStore.getAt(this.metaStore.findBy(function(a){return a.get("store")==this.store},this)).get("identifier"),listeners:{select:function(a,b){this.fireEvent("sourceselected",this,b.data.store);this.reconfigure(b.data.store,this.getColumnModel());if(this.expander)this.expander.ows=
  b.get("url")},scope:this}}),this.metaStore.on("add",function(a,b,e){this.sourceComboBox.onSelect(b[0],e)},this),this.tbar=this.tbar||[],this.tbar.push(""+this.layerSelectionLabel),this.tbar.push(this.sourceComboBox);if(this.allowNewSources){var b=this;this.newSourceWindow||(this.newSourceWindow=new gxp.NewSourceWindow({modal:!0,metaStore:this.metaStore,addSource:function(){b.addSource.apply(b,arguments)}}));this.tbar.push(new Ext.Button({iconCls:"gxp-icon-addserver",text:this.layerAdditionLabel,handler:function(){this.newSourceWindow.show()},
  scope:this}))}gxp.grid.CapabilitiesGrid.superclass.initComponent.call(this)},addSource:function(a,b,c,d){d=d||this;c=new GeoExt.data.WMSCapabilitiesStore({url:a,autoLoad:!0});this.metaStore.add(new this.metaStore.recordType({url:a,store:c,identifier:a,name:a}));b.apply(d)},addLayers:function(){for(var a=this.getSelectionModel().getSelections(),b,c,d=[],e=0;e<a.length;e++)Ext.data.Record.AUTO_ID++,b=a[e].copy(Ext.data.Record.AUTO_ID),this.alignToGrid?(c=b.getLayer().clone(),c.maxExtent=new OpenLayers.Bounds(-180,
  -90,180,90)):(c=b.getLayer(),c instanceof OpenLayers.Layer.WMS&&(c=new OpenLayers.Layer.WMS(c.name,c.url,{layers:c.params.LAYERS},{attribution:c.attribution,maxExtent:OpenLayers.Bounds.fromArray(b.get("llbbox")).transform(new OpenLayers.Projection("EPSG:4326"),this.mapPanel.map.getProjectionObject())}))),b.data.layer=c,b.commit(!0),d.push(b);d.length&&(a=this.mapPanel.layers.findBy(function(a){return a.getLayer()instanceof OpenLayers.Layer.Vector}),-1!==a?this.mapPanel.layers.insert(a,d):this.mapPanel.layers.add(d))}});
  Ext.reg("gxp_capabilitiesgrid",gxp.grid.CapabilitiesGrid);Ext.namespace("gxp.plugins");
  gxp.plugins.WMSFilterView=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_wmsfilterview",featureManager:null,init:function(a){gxp.plugins.WMSFilterView.superclass.init.apply(this,arguments);this.createFilterLayer()},createFilterLayer:function(){this.filterLayer=new OpenLayers.Layer.WMS(this.id+"filterlayer",Ext.BLANK_IMAGE_URL,{format:"image/png",transparent:!0},{buffer:0,displayInLayerSwitcher:!1,tileOptions:{maxGetUrlLength:2048}});var a=this.target.mapPanel.map;a.addLayer(this.filterLayer);a.events.on({addlayer:this.raiseLayer,
  scope:this});var b=this.target.tools[this.featureManager],c=new OpenLayers.Format.SLD,a=function(){this.filterLayer.setUrl(Ext.BLANK_IMAGE_URL);this.filterLayer.setVisibility(!1)}.bind(this);b.on({clearfeatures:a,beforelayerchange:a,beforequery:function(){this.filterLayer.setUrl(Ext.BLANK_IMAGE_URL);this.filterLayer.setVisibility(!1)},query:function(a,e,f){if(f){var e=new OpenLayers.Rule,g=b.geometryType.replace(/^Multi/,""),h=b.style.all.rules[0].symbolizer;e.symbolizer[g]=Ext.applyIf(Ext.apply({},
  h[g]||h),OpenLayers.Feature.Vector.style["default"]);e=new OpenLayers.Style(null,{rules:[e]});this.filterLayer.setUrl(a.layerRecord.getLayer().url);if(f instanceof OpenLayers.Filter.Logical){a=f.filters;for(g=a.length-1;0<=g;--g)a[g].type===OpenLayers.Filter.Spatial.BBOX&&a.remove(a[g]);1==a.length&&f.type!==OpenLayers.Filter.Comparison.NOT?f=a[0]:0==a.length&&(f=null)}else f.type===OpenLayers.Filter.Spatial.BBOX&&(f=null);a={};f&&(f instanceof OpenLayers.Filter.FeatureId?a.featureid=f.fids:a.cql_filter=
  (new OpenLayers.Format.CQL).write(f));this.filterLayer.mergeNewParams(Ext.apply(a,{sld_body:c.write({namedLayers:[{name:b.layerRecord.get("name"),userStyles:[e]}]}).replace(/( (xmlns|xsi):[^\"]*\"[^\"]*"|sld:)/g,"")}));this.filterLayer.setVisibility(!0)}},scope:this})},raiseLayer:function(){var a=this.filterLayer.map;a.setLayerIndex(this.filterLayer,a.layers.length)}});Ext.preg(gxp.plugins.WMSFilterView.prototype.ptype,gxp.plugins.WMSFilterView);Ext.namespace("gxp");
  gxp.FilterBuilder=Ext.extend(Ext.Container,{builderTypeNames:["any","all","none","not all"],allowedBuilderTypes:null,allowBlank:!1,preComboText:"Match",postComboText:"of the following:",cls:"gxp-filterbuilder",builderType:null,childFilterContainer:null,customizeFilterOnInit:!0,addConditionText:"add condition",addGroupText:"add group",removeConditionText:"remove condition",allowGroups:!0,initComponent:function(){Ext.applyIf(this,{defaultBuilderType:gxp.FilterBuilder.ANY_OF});this.customizeFilterOnInit&&
  (this.filter=this.customizeFilter(this.filter));this.builderType=this.getBuilderType();this.items=[{xtype:"container",layout:"form",defaults:{anchor:"100%"},hideLabels:!0,items:[{xtype:"compositefield",style:"padding-left: 2px",items:[{xtype:"label",style:"padding-top: 0.3em",text:this.preComboText},this.createBuilderTypeCombo(),{xtype:"label",style:"padding-top: 0.3em",text:this.postComboText}]},this.createChildFiltersPanel(),{xtype:"toolbar",items:this.createToolBar()}]}];this.addEvents("change");
  gxp.FilterBuilder.superclass.initComponent.call(this)},createToolBar:function(){var a=[{text:this.addConditionText,iconCls:"add",handler:function(){this.addCondition()},scope:this}];this.allowGroups&&a.push({text:this.addGroupText,iconCls:"add",handler:function(){this.addCondition(!0)},scope:this});return a},getFilter:function(){var a;this.filter&&(a=this.filter.clone(),a instanceof OpenLayers.Filter.Logical&&(a=this.cleanFilter(a)));return a},cleanFilter:function(a){if(a instanceof OpenLayers.Filter.Logical)if(a.type!==
  OpenLayers.Filter.Logical.NOT&&1===a.filters.length)a=this.cleanFilter(a.filters[0]);else for(var b,c=0,d=a.filters.length;c<d;++c)if(b=a.filters[c],b instanceof OpenLayers.Filter.Logical)if(b=this.cleanFilter(b))a.filters[c]=b;else{a=b;break}else{if(!b||null===b.type||null===b.property||null===b[a.type===OpenLayers.Filter.Comparison.BETWEEN?"lowerBoundary":"value"]){a=!1;break}}else if(!a||null===a.type||null===a.property||null===a[a.type===OpenLayers.Filter.Comparison.BETWEEN?"lowerBoundary":"value"])a=
  !1;return a},customizeFilter:function(a){if(a){var a=this.cleanFilter(a),b,c,d;switch(a.type){case OpenLayers.Filter.Logical.AND:case OpenLayers.Filter.Logical.OR:if(!a.filters||0===a.filters.length)a.filters=[this.createDefaultFilter()];else{c=0;for(d=a.filters.length;c<d;++c)b=a.filters[c],b instanceof OpenLayers.Filter.Logical&&(a.filters[c]=this.customizeFilter(b))}a=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.OR,filters:[a]});break;case OpenLayers.Filter.Logical.NOT:if(!a.filters||
  0===a.filters.length)a.filters=[new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.OR,filters:[this.createDefaultFilter()]})];else if(b=a.filters[0],b instanceof OpenLayers.Filter.Logical)if(b.type!==OpenLayers.Filter.Logical.NOT){var e;c=0;for(d=b.filters.length;c<d;++c)e=b.filters[c],e instanceof OpenLayers.Filter.Logical&&(b.filters[c]=this.customizeFilter(e))}else a=b.filters&&0<b.filters.length?this.customizeFilter(b.filters[0]):this.wrapFilter(this.createDefaultFilter());else a.filters=
  [new OpenLayers.Filter.Logical({type:this.defaultBuilderType===gxp.FilterBuilder.NOT_ALL_OF?OpenLayers.Filter.Logical.AND:OpenLayers.Filter.Logical.OR,filters:[b]})];break;default:a=this.wrapFilter(a)}}else a=this.wrapFilter(this.createDefaultFilter());return a},createDefaultFilter:function(){return new OpenLayers.Filter.Comparison},wrapFilter:function(a){return new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.OR,filters:[new OpenLayers.Filter.Logical({type:this.defaultBuilderType===
  gxp.FilterBuilder.ALL_OF?OpenLayers.Filter.Logical.AND:OpenLayers.Filter.Logical.OR,filters:[a]})]})},addCondition:function(a){var b,c;a?(c="gxp_filterbuilder",b=this.wrapFilter(this.createDefaultFilter())):(c="gxp_filterfield",b=this.createDefaultFilter());this.childFilterContainer.add(this.newRow({xtype:c,filter:b,columnWidth:1,attributes:this.attributes,allowBlank:a?void 0:this.allowBlank,customizeFilterOnInit:a&&!1,listeners:{change:function(){this.fireEvent("change",this)},scope:this}}));this.filter.filters[0].filters.push(b);
  this.childFilterContainer.doLayout()},removeCondition:function(a,b){var c=this.filter.filters[0].filters;1<c.length&&(c.remove(b),this.childFilterContainer.remove(a,!0));this.fireEvent("change",this)},createBuilderTypeCombo:function(){for(var a=this.allowedBuilderTypes||[gxp.FilterBuilder.ANY_OF,gxp.FilterBuilder.ALL_OF,gxp.FilterBuilder.NONE_OF],b=a.length,c=Array(b),d,e=0;e<b;++e)d=a[e],c[e]=[d,this.builderTypeNames[d]];return{xtype:"combo",store:new Ext.data.SimpleStore({data:c,fields:["value",
  "name"]}),value:this.builderType,displayField:"name",valueField:"value",triggerAction:"all",mode:"local",listeners:{select:function(a,b){this.changeBuilderType(b.get("value"));this.fireEvent("change",this)},scope:this},width:60}},changeBuilderType:function(a){if(a!==this.builderType){this.builderType=a;var b=this.filter.filters[0];switch(a){case gxp.FilterBuilder.ANY_OF:this.filter.type=OpenLayers.Filter.Logical.OR;b.type=OpenLayers.Filter.Logical.OR;break;case gxp.FilterBuilder.ALL_OF:this.filter.type=
  OpenLayers.Filter.Logical.OR;b.type=OpenLayers.Filter.Logical.AND;break;case gxp.FilterBuilder.NONE_OF:this.filter.type=OpenLayers.Filter.Logical.NOT;b.type=OpenLayers.Filter.Logical.OR;break;case gxp.FilterBuilder.NOT_ALL_OF:this.filter.type=OpenLayers.Filter.Logical.NOT,b.type=OpenLayers.Filter.Logical.AND}}},createChildFiltersPanel:function(){this.childFilterContainer=new Ext.Container;for(var a=this.filter.filters[0].filters,b,c=0,d=a.length;c<d;++c){b=a[c];var e={xtype:"gxp_filterfield",allowBlank:this.allowBlank,
  columnWidth:1,filter:b,attributes:this.attributes,listeners:{change:function(){this.fireEvent("change",this)},scope:this}};this.childFilterContainer.add(this.newRow(Ext.applyIf(b instanceof OpenLayers.Filter.Logical?{xtype:"gxp_filterbuilder"}:{xtype:"container",layout:"form",hideLabels:!0,items:e},e)))}return this.childFilterContainer},newRow:function(a){var b=new Ext.Container({layout:"column",items:[{xtype:"container",width:28,height:26,style:"padding-left: 2px",items:{xtype:"button",tooltip:this.removeConditionText,
  iconCls:"delete",handler:function(){this.removeCondition(b,a.filter)},scope:this}},a]});return b},getBuilderType:function(){var a=this.defaultBuilderType;if(this.filter){var b=this.filter.filters[0];if(this.filter.type===OpenLayers.Filter.Logical.NOT)switch(b.type){case OpenLayers.Filter.Logical.OR:a=gxp.FilterBuilder.NONE_OF;break;case OpenLayers.Filter.Logical.AND:a=gxp.FilterBuilder.NOT_ALL_OF}else switch(b.type){case OpenLayers.Filter.Logical.OR:a=gxp.FilterBuilder.ANY_OF;break;case OpenLayers.Filter.Logical.AND:a=
  gxp.FilterBuilder.ALL_OF}}return a}});gxp.FilterBuilder.ANY_OF=0;gxp.FilterBuilder.ALL_OF=1;gxp.FilterBuilder.NONE_OF=2;gxp.FilterBuilder.NOT_ALL_OF=3;Ext.reg("gxp_filterbuilder",gxp.FilterBuilder);Ext.ns("gxp.data");
  gxp.data.AutoCompleteProxy=Ext.extend(GeoExt.data.ProtocolProxy,{doRequest:function(a,b,c,d,e,f,g){c.query&&(c.filter=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.LIKE,matchCase:!1,property:this.protocol.propertyNames[0],value:"*"+c.query+"*"}),delete c.query);gxp.data.AutoCompleteProxy.superclass.doRequest.apply(this,arguments)}});Ext.namespace("gxp.plugins");
  gxp.plugins.LayerProperties=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_layerproperties",menuText:"Layer Properties",toolTip:"Layer Properties",constructor:function(a){gxp.plugins.LayerProperties.superclass.constructor.apply(this,arguments);this.outputConfig||(this.outputConfig={width:265,autoHeight:!0})},addActions:function(){var a=gxp.plugins.LayerProperties.superclass.addActions.apply(this,[{menuText:this.menuText,iconCls:"gxp-icon-layerproperties",disabled:!0,tooltip:this.toolTip,handler:function(){this.removeOutput();
  this.addOutput()},scope:this}]),b=a[0];this.target.on("layerselectionchange",function(a){b.setDisabled(!a||!a.get("properties"))},this);return a},addOutput:function(a){var a=a||{},b=this.target.selectedLayer;this.outputConfig.title=(this.initialConfig.outputConfig||{}).title||this.menuText+": "+b.get("title");this.outputConfig.shortTitle=b.get("title");var c=b.get("properties")||"gxp_layerpanel",d=this.layerPanelConfig;d&&d[c]&&Ext.apply(a,d[c]);return gxp.plugins.LayerProperties.superclass.addOutput.call(this,
  Ext.apply({xtype:c,authorized:this.target.isAuthorized(),layerRecord:b,source:this.target.getSource(b),defaults:{style:"padding: 10px",autoHeight:this.outputConfig.autoHeight},listeners:{added:function(a){if(!this.outputTarget)a.on("afterrender",function(){a.ownerCt.ownerCt.center()},this,{single:!0})},scope:this}},a))}});Ext.preg(gxp.plugins.LayerProperties.prototype.ptype,gxp.plugins.LayerProperties);Ext.namespace("gxp.plugins");
  gxp.plugins.ZoomToDataExtent=Ext.extend(gxp.plugins.ZoomToExtent,{ptype:"gxp_zoomtodataextent",menuText:"Zoom to layer extent",tooltip:"Zoom to layer extent",closest:!1,iconCls:"gxp-icon-zoom-to",extent:function(){return this.target.tools[this.featureManager].featureLayer.getDataExtent()},addActions:function(){var a=gxp.plugins.ZoomToDataExtent.superclass.addActions.apply(this,arguments);a[0].disable();var b=this.target.tools[this.featureManager].featureLayer;b.events.on({featuresadded:function(){a[0].isDisabled()&&
  a[0].enable()},featuresremoved:function(){0==b.features.length&&a[0].disable()}});return a}});Ext.preg(gxp.plugins.ZoomToDataExtent.prototype.ptype,gxp.plugins.ZoomToDataExtent);Ext.namespace("gxp.plugins");
  gxp.plugins.WMSGetFeatureInfo=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_wmsgetfeatureinfo",outputTarget:"map",popupCache:null,infoActionTip:"Get Feature Info",popupTitle:"Feature Info",format:"html",addActions:function(){var a;this.popupCache={};var b=gxp.plugins.WMSGetFeatureInfo.superclass.addActions.call(this,[{tooltip:this.infoActionTip,iconCls:"gxp-icon-getfeatureinfo",toggleGroup:this.toggleGroup,enableToggle:!0,allowDepress:!0,toggleHandler:function(b,c){for(var d=0,h=a.length;d<h;d++)c?a[d].activate():
  a[d].deactivate()}}]),c=this.actions[0].items[0];a=[];var d=function(){for(var b=this.target.mapPanel.layers.queryBy(function(a){return a.get("queryable")}),d=this.target.mapPanel.map,g,h=0,j=a.length;h<j;h++)g=a[h],g.deactivate(),g.destroy();a=[];b.each(function(b){var e=b.getLayer(),g=Ext.apply({},this.vendorParams),h;if(this.layerParams)for(var j=this.layerParams.length-1;0<=j;--j)h=this.layerParams[j].toUpperCase(),g[h]=e.params[h];var p=b.get("infoFormat");void 0===p&&(p="html"==this.format?
  "text/html":"application/vnd.ogc.gml");e=new OpenLayers.Control.WMSGetFeatureInfo(Ext.applyIf({url:e.url,queryVisible:!0,layers:[e],infoFormat:p,vendorParams:g,eventListeners:{getfeatureinfo:function(a){if(a.features&&0<a.features.length){var c=b.get("title")||b.get("name");if("text/html"==p){var d=a.text.match(/<body[^>]*>([\s\S]*)<\/body>/);d&&!d[1].match(/^\s*$/)&&this.displayPopup(a,c,d[1])}else"text/plain"==p?this.displayPopup(a,c,"<pre>"+a.text+"</pre>"):this.displayPopup(a,c)}},scope:this}},
  this.controlOptions));d.addControl(e);a.push(e);c.pressed&&e.activate()},this)};this.target.mapPanel.layers.on("update",d,this);this.target.mapPanel.layers.on("add",d,this);this.target.mapPanel.layers.on("remove",d,this);return b},displayPopup:function(a,b,c){var d,e=a.xy.x+"."+a.xy.y;e in this.popupCache?d=this.popupCache[e]:(d=this.addOutput({xtype:"gx_popup",title:this.popupTitle,layout:"accordion",fill:!1,autoScroll:!0,location:a.xy,map:this.target.mapPanel,width:250,height:300,defaults:{layout:"fit",
  autoScroll:!0,autoHeight:!0,autoWidth:!0,collapsible:!0},listeners:{close:function(a){return function(){delete this.popupCache[a]}}(e),scope:this}}),this.popupCache[e]=d);a=a.features;e=[];if(!c&&a)for(var f=0,g=a.length;f<g;++f)c=a[f],e.push(Ext.apply({xtype:"propertygrid",listeners:{beforeedit:function(){return false}},title:c.fid?c.fid:b,source:c.attributes},this.itemConfig));else c&&e.push(Ext.apply({title:b,html:c},this.itemConfig));d.add(e);d.doLayout()}});
  Ext.preg(gxp.plugins.WMSGetFeatureInfo.prototype.ptype,gxp.plugins.WMSGetFeatureInfo);Ext.namespace("gxp.plugins");
  gxp.plugins.GoogleSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_googlesource",timeout:7E3,title:"Google Layers",roadmapAbstract:"Show street map",satelliteAbstract:"Show satellite imagery",hybridAbstract:"Show imagery with street names",terrainAbstract:"Show street map with terrain",constructor:function(a){this.config=a;gxp.plugins.GoogleSource.superclass.constructor.apply(this,arguments)},createStore:function(){gxp.plugins.GoogleSource.loader.onLoad({timeout:this.timeout,callback:this.syncCreateStore,
  errback:function(){delete this.store;this.fireEvent("failure",this,"The Google Maps script failed to load within the provided timeout ("+this.timeout/1E3+" s).")},scope:this})},syncCreateStore:function(){var a={ROADMAP:{"abstract":this.roadmapAbstract,MAX_ZOOM_LEVEL:20},SATELLITE:{"abstract":this.satelliteAbstract},HYBRID:{"abstract":this.hybridAbstract},TERRAIN:{"abstract":this.terrainAbstract,MAX_ZOOM_LEVEL:15}},b=[],c,d;for(c in a)d=google.maps.MapTypeId[c],b.push(new OpenLayers.Layer.Google("Google "+
  d.replace(/\w/,function(a){return a.toUpperCase()}),{type:d,typeName:c,MAX_ZOOM_LEVEL:a[c].MAX_ZOOM_LEVEL,maxExtent:new OpenLayers.Bounds(-2.003750834E7,-2.003750834E7,2.003750834E7,2.003750834E7),restrictedExtent:new OpenLayers.Bounds(-2.003750834E7,-2.003750834E7,2.003750834E7,2.003750834E7),projection:this.projection}));this.store=new GeoExt.data.LayerStore({layers:b,fields:[{name:"source",type:"string"},{name:"name",type:"string",mapping:"typeName"},{name:"abstract",type:"string"},{name:"group",
  type:"string",defaultValue:"background"},{name:"fixed",type:"boolean",defaultValue:!0},{name:"selected",type:"boolean"}]});this.store.each(function(b){b.set("abstract",a[b.get("name")]["abstract"])});this.fireEvent("ready",this)},createLayerRecord:function(a){var b,c=function(b){return b.get("name")===a.name};-1==this.target.mapPanel.layers.findBy(c)&&(b=this.store.getAt(this.store.findBy(c)).clone(),c=b.getLayer(),a.title&&(c.setName(a.title),b.set("title",a.title)),"visibility"in a&&(c.visibility=
  a.visibility),b.set("selected",a.selected||!1),b.set("source",a.source),b.set("name",a.name),"group"in a&&b.set("group",a.group),b.commit());return b}});
  gxp.plugins.GoogleSource.loader=new (Ext.extend(Ext.util.Observable,{ready:!(!window.google||!google.maps),loading:!1,constructor:function(){this.addEvents("ready","failure");return Ext.util.Observable.prototype.constructor.apply(this,arguments)},onScriptLoad:function(){var a=gxp.plugins.GoogleSource.loader;a.ready||(a.ready=!0,a.loading=!1,a.fireEvent("ready"))},onLoad:function(a){if(this.ready)window.setTimeout(function(){a.callback.call(a.scope)},0);else if(this.loading)this.on({ready:a.callback,
  failure:a.errback||Ext.emptyFn,scope:a.scope});else this.loadScript(a)},loadScript:function(a){function b(){document.getElementsByTagName("head")[0].appendChild(d)}var c={autoload:Ext.encode({modules:[{name:"maps",version:3.3,nocss:"true",callback:"gxp.plugins.GoogleSource.loader.onScriptLoad",other_params:"sensor=false"}]})},d=document.createElement("script");d.src="http://www.google.com/jsapi?"+Ext.urlEncode(c);var e=a.errback||Ext.emptyFn,c=a.timeout||gxp.plugins.GoogleSource.prototype.timeout;
  window.setTimeout(function(){gxp.plugins.GoogleSource.loader.ready||(this.ready=this.loading=!1,document.getElementsByTagName("head")[0].removeChild(d),e.call(a.scope),this.fireEvent("failure"),this.purgeListeners())}.createDelegate(this),c);this.on({ready:a.callback,scope:a.scope});this.loading=!0;if(document.body)b();else Ext.onReady(b)}}));Ext.preg(gxp.plugins.GoogleSource.prototype.ptype,gxp.plugins.GoogleSource);Ext.namespace("gxp.form");
  gxp.form.AutoCompleteComboBox=Ext.extend(Ext.form.ComboBox,{xtype:"gxp_autocompletecombo",fieldName:null,featureType:null,featurePrefix:null,fieldLabel:null,geometryName:null,maxFeatures:500,url:null,srsName:null,autoHeight:!0,hideTrigger:!0,customSortInfo:null,initComponent:function(){var a=[{name:this.fieldName}],b=[this.fieldName];null!==this.geometryName&&(a.push({name:this.geometryName}),b.push(this.geometryName));this.name||(this.name=this.fieldName);this.valueField=this.displayField=this.fieldName;
  this.tpl=new Ext.XTemplate('<tpl for="."><div class="x-form-field">',"{"+this.fieldName+"}","</div></tpl>");this.itemSelector="div.x-form-field";this.store=new Ext.data.Store({fields:a,reader:new gxp.data.AutoCompleteReader({uniqueField:this.fieldName},b),proxy:new gxp.data.AutoCompleteProxy({protocol:new OpenLayers.Protocol.WFS({version:"1.1.0",url:this.url,featureType:this.featureType,featurePrefix:this.featurePrefix,srsName:this.srsName,propertyNames:b,maxFeatures:this.maxFeatures}),setParamsAsOptions:!0}),
  sortInfo:this.customSortInfo&&{field:this.fieldName,direction:this.customSortInfo.direction}});this.customSortInfo&&(this.store.createSortFunction=this.createCustomSortFunction());return gxp.form.AutoCompleteComboBox.superclass.initComponent.apply(this,arguments)},createCustomSortFunction:function(){for(var a=RegExp(this.customSortInfo.matcher),b=this.customSortInfo.parts.length,c=Array(b),d,e=0;e<b;++e)d=this.customSortInfo.parts[e],c[e]={index:e,sortType:Ext.data.SortTypes[d.sortType||"none"],order:d.order||
  0};c.sort(function(a,b){return a.order-b.order});return function(b,d){var e="DESC"==(d||"ASC").toUpperCase()?-1:1;return function(d,g){for(var l=d.data[b],n=g.data[b],m=a.exec(l)||[],o=a.exec(n)||[],p,q,s=0,t=c.length;s<t&&!(q=c[s],p=q.sortType(m[q.index+1]||l),q=q.sortType(o[q.index+1]||n),p=p>q?1:p<q?-1:0);++s);return e*p}}}});Ext.reg(gxp.form.AutoCompleteComboBox.prototype.xtype,gxp.form.AutoCompleteComboBox);Ext.namespace("gxp.plugins");
  gxp.plugins.MapBoxSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_mapboxsource",title:"MapBox Layers",blueMarbleTopoBathyJanTitle:"Blue Marble Topography & Bathymetry (January)",blueMarbleTopoBathyJulTitle:"Blue Marble Topography & Bathymetry (July)",blueMarbleTopoJanTitle:"Blue Marble Topography (January)",blueMarbleTopoJulTitle:"Blue Marble Topography (July)",controlRoomTitle:"Control Room",geographyClassTitle:"Geography Class",naturalEarthHypsoTitle:"Natural Earth Hypsometric",naturalEarthHypsoBathyTitle:"Natural Earth Hypsometric & Bathymetry",
  naturalEarth1Title:"Natural Earth I",naturalEarth2Title:"Natural Earth II",worldDarkTitle:"World Dark",worldLightTitle:"World Light",worldGlassTitle:"World Glass",worldPrintTitle:"World Print",createStore:function(){for(var a={projection:"EPSG:900913",numZoomLevels:19,serverResolutions:[156543.03390625,78271.516953125,39135.7584765625,19567.87923828125,9783.939619140625,4891.9698095703125,2445.9849047851562,1222.9924523925781,611.4962261962891,305.74811309814453,152.87405654907226,76.43702827453613,
  38.218514137268066,19.109257068634033,9.554628534317017,4.777314267158508,2.388657133579254,1.194328566789627,0.5971642833948135],buffer:1},b=[{name:"blue-marble-topo-bathy-jan",numZoomLevels:9},{name:"blue-marble-topo-bathy-jul",numZoomLevels:9},{name:"blue-marble-topo-jan",numZoomLevels:9},{name:"blue-marble-topo-jul",numZoomLevels:9},{name:"control-room",numZoomLevels:9},{name:"geography-class",numZoomLevels:9},{name:"natural-earth-hypso",numZoomLevels:7},{name:"natural-earth-hypso-bathy",numZoomLevels:7},
  {name:"natural-earth-1",numZoomLevels:7},{name:"natural-earth-2",numZoomLevels:7},{name:"world-dark",numZoomLevels:12},{name:"world-light",numZoomLevels:12},{name:"world-glass",numZoomLevels:11},{name:"world-print",numZoomLevels:10}],c=b.length,d=Array(c),e,f=0;f<c;++f)e=b[f],d[f]=new OpenLayers.Layer.TMS(this[OpenLayers.String.camelize(e.name)+"Title"],["http://a.tiles.mapbox.com/mapbox/","http://b.tiles.mapbox.com/mapbox/","http://c.tiles.mapbox.com/mapbox/","http://d.tiles.mapbox.com/mapbox/"],
  OpenLayers.Util.applyDefaults({attribution:"<a href='http://mapbox.com'>MapBox</a> | <a href='http://mapbox.com/tos'>Terms of Service</a>",type:"png",tileOrigin:new OpenLayers.LonLat(-2.003750834E7,-2.003750834E7),layername:e.name,"abstract":'<div class="thumb-mapbox thumb-mapbox-'+e.name+'"></div>',numZoomLevels:e.numZoomLevels},a));this.store=new GeoExt.data.LayerStore({layers:d,fields:[{name:"source",type:"string"},{name:"name",type:"string",mapping:"layername"},{name:"abstract",type:"string"},
  {name:"group",type:"string"},{name:"fixed",type:"boolean"},{name:"selected",type:"boolean"}]});this.fireEvent("ready",this)},createLayerRecord:function(a){var b,c=this.store.findExact("name",a.name);-1<c&&(b=this.store.getAt(c).copy(Ext.data.Record.id({})),c=b.getLayer().clone(),a.title&&(c.setName(a.title),b.set("title",a.title)),"visibility"in a&&(c.visibility=a.visibility),b.set("selected",a.selected||!1),b.set("source",a.source),b.set("name",a.name),"group"in a&&b.set("group",a.group),b.data.layer=
  c,b.commit());return b}});Ext.preg(gxp.plugins.MapBoxSource.prototype.ptype,gxp.plugins.MapBoxSource);Ext.namespace("gxp.plugins");
  gxp.plugins.Styler=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_styler",menuText:"Edit Styles",tooltip:"Manage layer styles",sameOriginStyling:!0,rasterStyling:!1,requireDescribeLayer:!0,constructor:function(a){gxp.plugins.Styler.superclass.constructor.apply(this,arguments);this.outputConfig||(this.outputConfig={autoHeight:!0,width:265});Ext.applyIf(this.outputConfig,{closeAction:"close"})},init:function(a){gxp.plugins.Styler.superclass.init.apply(this,arguments);this.target.on("authorizationchange",this.enableOrDisable,
  this)},destroy:function(){this.target.un("authorizationchange",this.enableOrDisable,this);gxp.plugins.Styler.superclass.destroy.apply(this,arguments)},enableOrDisable:function(){this.target&&null!==this.target.selectedLayer&&this.handleLayerChange(this.target.selectedLayer)},addActions:function(){var a=gxp.plugins.Styler.superclass.addActions.apply(this,[{menuText:this.menuText,iconCls:"gxp-icon-palette",disabled:!0,tooltip:this.tooltip,handler:function(){this.addOutput()},scope:this}]);this.launchAction=
  a[0];this.target.on({layerselectionchange:this.handleLayerChange,scope:this});return a},handleLayerChange:function(a){this.launchAction.disable();if(a&&a.get("styles")){var b=this.target.getSource(a);b instanceof gxp.plugins.WMSSource&&b.describeLayer(a,function(b){this.checkIfStyleable(a,b)},this)}},checkIfStyleable:function(a,b){if(b){var c=["WFS"];!0===this.rasterStyling&&c.push("WCS")}if(b?-1!==c.indexOf(b.get("owsType")):!this.requireDescribeLayer){var c=!1,c=this.target.layerSources[a.get("source")],
  d;d=(d=a.get("restUrl"))?d+"/styles":c.url.split("?").shift().replace(/\/(wms|ows)\/?$/,"/rest/styles");(c=this.sameOriginStyling?"/"===d.charAt(0):!0)&&this.target.isAuthorized()&&this.enableActionIfAvailable(d)}},enableActionIfAvailable:function(a){Ext.Ajax.request({method:"PUT",url:a,callback:function(a,c,d){this.launchAction.setDisabled(405!==d.status)},scope:this})},addOutput:function(a){var a=a||{},b=this.target.selectedLayer;this.outputConfig.title=(this.initialConfig.outputConfig||{}).title||
  this.menuText+": "+b.get("title");this.outputConfig.shortTitle=b.get("title");Ext.apply(a,gxp.WMSStylesDialog.createGeoServerStylerConfig(b));!0===this.rasterStyling&&a.plugins.push({ptype:"gxp_wmsrasterstylesdialog"});Ext.applyIf(a,{style:"padding: 10px"});var c=gxp.plugins.Styler.superclass.addOutput.call(this,a);c.dialogCls=c.ownerCt.ownerCt instanceof Ext.Window?Ext.Window:Ext.Container;c.showDlg=function(a){a instanceof Ext.Window?a.show():(a.layout="fit",a.autoHeight=!1,c.ownerCt.add(a))};c.stylesStore.on("load",
  function(){!this.outputTarget&&c.ownerCt.ownerCt instanceof Ext.Window&&c.ownerCt.ownerCt.center()})}});Ext.preg(gxp.plugins.Styler.prototype.ptype,gxp.plugins.Styler);
  