text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],{11:function(e,t,i){"use strict";(function(n){var a,s;function l(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function o(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}i(18),i(42),i(8),i(44),i(14),i(86),i(48),i(16),i(10),i(63),i(4),i(32),i(64),i(41),i(35),i(5),i(61),i(58),i(54),i(7),a=[i(123),i(2),i(6),i,i(0),i(1),i(126),i(3),i(13),i(78),i(190),i(105),i(153),i(87),i(21),i(34),i(128),i(60),i(426),i(427),i(428),i(191),i(193),i(355),i(431),i(194),i(432),i(356),i(84),i(27),i(196),i(348),i(197),i(156)],void 0===(s=function(e,t,i,a,s,r,d,c,u,p,h,f,m,g,v,b){n=window.$=s;var y=window.wcDocker;s=s||n||window.$,d=d||window.Bootstrap;var C=p.default,_=c.Browser=c.Browser||{},w=t("Please select an object in the tree view.");g.setPGCSRFToken(c.csrf_token_header,c.csrf_token);var x={};x[y.EVENT.VISIBILITY_CHANGED]=function(){if(this.isVisible()){var e=c.Browser,t=e.tree?e.tree.selected():void 0,i=t&&1==t.length?e.tree.itemData(t):void 0;if(i&&e.Nodes[i._type].callbacks.selected&&r.isFunction(e.Nodes[i._type].callbacks.selected))return e.Nodes[i._type].callbacks.selected.apply(e.Nodes[i._type],[t,i,e])}};var k=function(e){var t=JSON.parse(e).data;return t.length&&"column"!==t[0]._type&&"catalog_object_column"!==t[0]._type&&(t=t.sort((function(e,t){return c.natural_sort(e.label,t.label)}))),r.each(t,(function(e){e._label=e.label,e.label=r.escape(e.label)})),t},N=c.Browser.initializeBrowserTree=function(e){s("#tree").aciTree({ajax:{url:i("browser.nodes"),converters:{"text json":k}},ajaxHook:function(t,i){if(null!=t){var n=this.itemData(t),a=e.Nodes[n._type];a&&(i.url=a.generate_url(t,"children",n,!0))}},loaderDelay:100,show:{duration:75},hide:{duration:75},view:{duration:75},animateRoot:!0,unanimated:!1,fullRow:!0}),e.tree=s("#tree").aciTree("api"),e.treeMenu.register(s("#tree")),e.treeMenu.registerDraggableType({"collation domain domain_constraints fts_configuration fts_dictionary fts_parser fts_template synonym table partition type sequence package view mview foreign_table edbvar":function(t,i){return v.fully_qualify(e,t,i)},"schema column database cast event_trigger extension language foreign_data_wrapper foreign_server user_mapping compound_trigger index index_constraint primary_key unique_constraint check_constraint exclusion_constraint foreign_key rule":function(e){return v.quote_ident(e._label)},"trigger trigger_function":function(e){return e._label},"edbfunc function edbproc procedure":function(t,i){var n,a=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?l(Object(i),!0).forEach((function(t){o(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):l(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},t),s="",r={from:0,to:0};if(n=v.parseFuncParams(a._label),a._label=n.func_name,s=v.fully_qualify(e,a,i),n.params.length>0){s+="(",r.from=s.length,s+=n.params[0][0],r.to=s.length;for(var d=1;d<n.params.length;d++)s=s+", "+n.params[d][0];s+=")"}else s+="()",r.from=r.to=s.length+1;return{text:s,cur:r}}})};return r.extend(c.Browser,{URL:i("browser.index"),docker:null,editor:null,tree:null,treeMenu:new e.Tree,scripts:{},stdW:{sm:500,md:700,lg:900,default:500},stdH:{sm:200,md:400,lg:550,default:550},panels:{browser:new c.Browser.Panel({name:"browser",title:t("Browser"),showTitle:!0,isCloseable:!1,isPrivate:!0,icon:"",content:'<div id="tree" class="aciTree"></div>',onCreate:function(e){f.initializeToolbar(e,y)}}),properties:new c.Browser.Panel({name:"properties",title:t("Properties"),icon:"",width:500,isCloseable:!1,isPrivate:!0,elContainer:!0,content:'<div class="obj_properties container-fluid"><div role="status" class="pg-panel-message">'+w+"</div></div>",events:x,onCreate:function(e,t){t.addClass("pg-no-overflow")}}),statistics:new c.Browser.Panel({name:"statistics",title:t("Statistics"),icon:"",width:500,isCloseable:!1,isPrivate:!0,content:'<div class="negative-space p-2"><div role="status" class="pg-panel-message pg-panel-statistics-message">'+w+'</div><div class="pg-panel-statistics-container d-none"></div></div>',events:x}),sql:new c.Browser.Panel({name:"sql",title:t("SQL"),icon:"",width:500,isCloseable:!1,isPrivate:!0,content:'<label for="sql-textarea" class="sr-only">'+t("SQL Code")+'</label><div class="sql_textarea"><textarea id="sql-textarea" name="sql-textarea" title="'+t("SQL Code")+'"></textarea></div>'}),dependencies:new c.Browser.Panel({name:"dependencies",title:t("Dependencies"),icon:"",width:500,isCloseable:!1,isPrivate:!0,content:'<div class="negative-space p-2"><div role="status" class="pg-panel-message pg-panel-depends-message">'+w+'</div><div class="pg-panel-dependencies-container d-none"></div></div>',events:x}),dependents:new c.Browser.Panel({name:"dependents",title:t("Dependents"),icon:"",width:500,isCloseable:!1,isPrivate:!0,content:'<div class="negative-space p-2"><div role="status" class="pg-panel-message pg-panel-depends-message">'+w+'</div><div class="pg-panel-dependents-container d-none"></div></div>',events:x})},frames:{},menus:{context:{},file:{},edit:{},object:{},management:{},tools:{},help:{}},add_panels:function(){var e=JSON.parse(_.panels_items);r.each(e,(function(e){e.isIframe?_.frames[e.name]=new _.Frame({name:e.name,title:e.title,icon:e.icon,width:e.width,height:e.height,showTitle:e.showTitle,isCloseable:e.isCloseable,isPrivate:e.isPrivate,url:e.content}):_.panels[e.name]=new _.Panel({name:e.name,title:e.title,icon:e.icon,width:e.width,height:e.height,showTitle:e.showTitle,isCloseable:e.isCloseable,isPrivate:e.isPrivate,content:e.content?e.content:"",events:e.events?e.events:"",canHide:e.canHide?e.canHide:""})}))},menu_categories:{create:{label:t("Create"),priority:1,above:!1,below:!0,single:!0}},register_script:function(e,t,i){var n=this.scripts;n[e]=r.isArray(n[e])?n[e]:[],n[e].push({name:t,path:i,loaded:!1})},masterpass_callback_queue:[],enable_disable_menus:function(e){var i=this,n=s("#navbar-menu > ul").first().find("li#mnu_obj .dropdown-menu").first(),a=i.tree.itemData(e);if(f.enable(t("View Data"),!1),f.enable(t("Filtered Rows"),!1),n.empty(),r.each([{m:"file",id:"#mnu_file"},{m:"management",id:"#mnu_management"},{m:"tools",id:"#mnu_tools"},{m:"help",id:"#mnu_help"}],(function(t){r.each(i.menus[t.m],(function(t){!function t(i){if(i instanceof c.Browser.MenuItem)i.update(a,e);else for(var n in i)t(i[n])}(t)}))})),e&&i.menus.object&&i.menus.object[a._type])c.Browser.MenuCreator(n,i.menus.object[a._type],i.menu_categories,a,e);else{var l=c.Browser.MenuGroup(i.menu_categories.create,[{$el:s('<li><a class="dropdown-item disabled" href="#" role="menuitem">'+t("No object selected")+"</a></li>"),priority:1,category:"create",update:function(){}}],!1);n.append(l.$el)}},init:function(){var e=this;if(!e.initialized){if(e.initialized=!0,e.cache_preferences(),e.add_panels(),e.docker=new y("#dockerContainer",{allowContextMenu:!0,allowCollapse:!1,loadingClass:"pg-sp-icon",themePath:i("static",{filename:"css"}),theme:"webcabin.overrides.css"}),e.docker){r.each(e.panels,(function(t,i){e.panels[i].load(e.docker)})),r.each(e.frames,(function(t,i){e.frames[i].load(e.docker)}));var t=_.utils.layout;e.restore_layout(e.docker,t,e.buildDefaultLayout.bind(e)),e.docker.on(y.EVENT.LAYOUT_CHANGED,(function(){e.save_current_layout("Browser/Layout",e.docker)}))}e.editor=C.fromTextArea(document.getElementById("sql-textarea"),{lineNumbers:!0,mode:"text/x-pgsql",readOnly:!0,extraKeys:c.Browser.editor_shortcut_keys});var n=setInterval((function(){e.get_preferences_for_module("sqleditor")&&(clearInterval(n),e.reflectPreferences("sqleditor"))}),500);e.onPreferencesChange("sqleditor",(function(){e.reflectPreferences("sqleditor")})),setTimeout((function(){e.editor.setValue("-- "+w),e.editor.refresh()}),10),N(e),s("#tree").contextMenu({selector:".aciTreeLine",autoHide:!1,build:function(t){var i=e.tree.itemFrom(t),n=e.tree.itemData(i),a=e.menus.context[n._type],l=s("<div></div>"),o={};return c.Browser.MenuCreator(l,a,e.menu_categories,n,i,o),{autoHide:!1,items:o}},events:{hide:function(){e.keyboardNavigation.bindLeftTree()}}}),s("#tree").on("acitree",(function(t,i,n,a,s){var l,o=n?e.tree.itemData(n):null;if(o&&e.Nodes[o._type]){if(l=e.Nodes[o._type],r.isObject(l.callbacks)&&a in l.callbacks&&"function"==typeof l.callbacks[a]&&!l.callbacks[a].apply(l,[n,o,e,s,a]))return!1;try{l.trigger("browser-node."+a,l,n,o)}catch(e){console.warn(e.stack||e)}}try{e.Events.trigger("pgadmin-browser:tree",a,n,o),e.Events.trigger("pgadmin-browser:tree:"+a,n,o,l)}catch(e){console.warn(e.stack||e)}return!0})),_.utils.registerScripts(this),_.utils.addMenus(e);var a={};a[c.csrf_token_header]=c.csrf_token,setInterval((function(){s.ajax({url:i("misc.cleanup"),type:"POST",headers:a}).done((function(){})).fail((function(){}))}),3e5),e.set_master_password(""),e.Events.on("pgadmin:browser:tree:add",e.onAddTreeNode,e),e.Events.on("pgadmin:browser:tree:update",e.onUpdateTreeNode,e),e.Events.on("pgadmin:browser:tree:refresh",e.onRefreshTreeNode,e),e.Events.on("pgadmin-browser:tree:loadfail",e.onLoadFailNode,e),e.bind_beforeunload(),e.log_activity(),e.register_to_activity_listener(document),e.start_inactivity_timeout_daemon()}},init_master_password:function(){var e=this;u.dlgMasterPass||u.dialog("dlgMasterPass",(function(){return{main:function(e,t,i){this.set("title",e),this.message=t,this.reset=i},build:function(){u.pgDialogBuild.apply(this)},setup:function(){return{buttons:[{text:"",className:"btn btn-secondary pull-left fa fa-question pg-alertify-icon-button",attrs:{name:"dialog_help",type:"button",label:t("Master password"),url:i("help.static",{filename:"master_password.html"})}},{text:t("Reset Master Password"),className:"btn btn-secondary fa fa-trash-o pg-alertify-button pull-left"},{text:t("Cancel"),className:"btn btn-secondary fa fa-times pg-alertify-button",key:27},{text:t("OK"),key:13,className:"btn btn-primary fa fa-check pg-alertify-button"}],focus:{element:"#password",select:!0},options:{modal:!0,resizable:!1,maximizable:!1,pinnable:!1}}},prepare:function(){this.setContent(this.message),this.reset?s(this.__internal.buttons[1].element).removeClass("d-none"):s(this.__internal.buttons[1].element).addClass("d-none")},callback:function(i){var n=this;if(3==i.index)e.set_master_password(s("#frmMasterPassword #password").val(),!0,n.set_callback);else if(2==i.index)e.masterpass_callback_queue=[];else if(1==i.index)i.cancel=!0,u.confirm(t("Reset Master Password"),t("This will remove all the saved passwords. This will also remove established connections to the server and you may need to reconnect again. Do you wish to continue?"),(function(){return e.reset_master_password(),n.close(),!0}),(function(){return!0})).set("labels",{ok:t("Yes"),cancel:t("No")});else if(0==i.index)return i.cancel=!0,void e.showHelp(i.button.element.name,i.button.element.getAttribute("url"),null,null)}}}))},check_master_password:function(e){s.ajax({url:i("browser.check_master_password"),type:"GET",contentType:"application/json"}).done((function(t){e&&(t.data?e(!0):e(!1))})).fail((function(e,t,i){u.pgRespErrorNotify(e,i)}))},reset_master_password:function(){var e=this;s.ajax({url:i("browser.set_master_password"),type:"DELETE",contentType:"application/json"}).done((function(t){t.data||e.set_master_password("")})).fail((function(e,t,i){u.pgRespErrorNotify(e,i)}))},set_master_password:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},a=null,l=this;null==e&&""==e||(a=JSON.stringify({password:e,button_click:t})),l.masterpass_callback_queue.push(n),s.ajax({url:i("browser.set_master_password"),type:"POST",data:a,dataType:"json",contentType:"application/json"}).done((function(e){e.data.present?setTimeout((function(){for(;l.masterpass_callback_queue.length>0;){l.masterpass_callback_queue.shift()()}}),500):(l.init_master_password(),u.dlgMasterPass(e.data.title,e.data.content,e.data.reset))})).fail((function(e,t,i){u.pgRespErrorNotify(e,i)}))},bind_beforeunload:function(){s(window).on("beforeunload",(function(e){var i=b.default.pgAdmin.Browser,n=_.get_preference("browser","browser_tree_state_save_interval"),a=i.get_preference("browser","confirm_on_refresh_close");if(r.isUndefined(n)||-1===n.value||c.Browser.browserTreeState.save_state(),!r.isUndefined(a)&&a.value){var s=t("Are you sure you want to close the %s browser?",_.utils.app_name);return e.originalEvent.returnValue=s,s}}))},add_menu_category:function(e,t,i,n,a,s,l){this.menu_categories[e]={label:t,priority:i,icon:n,above:!0===a,below:!0===s,single:l}},add_menus:function(e){var t=this,i=this.menus,n=c.Browser.MenuItem;r.each(e,(function(e){r.each(e.applies,(function(a){if(s.inArray(a,["context","file","edit","object","management","tools","help"])>=0){var l;if(!h(t,e.node))return;if(r.has(e,"module")&&!r.isUndefined(e.module)&&!h(t,e.module.type))return;i[a]=i[a]||{},l=r.isString(e.node)?i[a][e.node]=i[a][e.node]||{}:r.isString(e.category)?i[a][e.category]=i[a][e.category]||{}:i[a];var o=function(e){return new n({name:e.name,label:e.label,module:e.module,category:e.category,callback:e.callback,priority:e.priority,data:e.data,url:e.url||"#",target:e.target,icon:e.icon,enable:""==e.enable||(!r.isString(e.enable)||"false"!=e.enable.toLowerCase())&&e.enable,node:e.node,checked:e.checked})};if(!r.has(l,e.name)&&(l[e.name]=o(e),e.menu_items)){for(var d=[],c=0;c<e.menu_items.length;c++)d.push(o(e.menu_items[c]));l[e.name].menu_items=d}}else console.warn("Developer warning: Category '"+a+"' is not supported!\nSupported categories are: context, file, edit, object, tools, management, help")}))}))},create_menus:function(){var e=s("#navbar-menu > ul").first(),t=this;r.each([{menu:"file",id:"#mnu_file"},{menu:"management",id:"#mnu_management"},{menu:"tools",id:"#mnu_tools"},{menu:"help",id:"#mnu_help"}],(function(i){var n=e.children(i.id).first(),a=n.children(".dropdown-menu").first();a.empty(),c.Browser.MenuCreator(a,t.menus[i.menu],t.menu_categories)&&n.removeClass("d-none")})),e.children("#mnu_obj").removeClass("d-none"),t.enable_disable_menus()},showHelp:function(e,t,i,n){if("object_help"==e){var a=i.getTreeNodeHierarchy(n).server,s=_.utils.pg_help_path;"ppas"==a.server_type&&(s=_.utils.edbas_help_path);var l=m.getHelpUrl(s,t,a.version);window.open(l,"postgres_help")}else"dialog_help"==e&&window.open(t,"pgadmin_help")},_findTreeChildNode:function(e,t,i){var n=i.t.wasLoad(e),a=function(){for(var n,a,s,l=i.t.children(e),o=0,d=l.length;o<d;o++)if(n=l.eq(o),(a=i.t.itemData(n))._type===t._type){if(!i.hasId||a._id==t._id)return i.i=n,i.d=t,i.pathOfTreeItems.push({coll:!1,item:n,d:t}),void i.success()}else if((s=i.b.Nodes[a._type])&&s.collection_node&&a.nodes&&-1!=r.indexOf(a.nodes,t._type))return i.i=n,i.d=null,i.pathOfTreeItems.push({coll:!0,item:n,d:a}),i.t.isInode(n)||(i.load=!1),void i.b._findTreeChildNode(n,t,i);i.notFound&&"function"==typeof i.notFound&&i.notFound(t)};!n&&i.load?i.t.open(e,{success:a,unanimated:!0,fail:function(){var e=i&&i.o&&i.o.fail;e&&"function"==typeof e&&e.apply(i.t,[])}}):n?a():i.notFound&&"function"==typeof i.notFound&&i.notFound(t)},onAddTreeNode:function(e,t,i){var n={b:this,d:null,hasId:!0,i:null,p:r.toArray(t||{}).sort((function(e,t){return e.priority===t.priority?0:e.priority<t.priority?-1:1})),pathOfTreeItems:[],t:this.tree,o:i},a=function(){var t,i=this;return i.success=a,i.p.length&&(t=i.p.shift(),i.p.length||(t._id=e._pid,i.success=l),i.b._findTreeChildNode(i.i,t,i),e._pid||l.apply(i,arguments)),!0}.bind(n),l=function(){var t=this,i=(t.i||this.t.wasLoad(t.i))&&this.t.first(t.i),n=function(t,i){this.success=t,this.notFound=i,this.b._findTreeChildNode(this.i,e,this)}.bind(t),a=function(){this.t.openPath(this.i),this.t.select(this.i),t.o&&t.o.success&&"function"==typeof t.o.success&&t.o.success.apply(t.t,[t.i,e])}.bind(t),l=function(){var t,i=this,n=i.t.children(i.i),a=0,l=n.length-1;if(function(){for(var s,o,r;l-a>22;){if(t=n.eq(a),"column"===(s=i.t.itemData(t))._type){if(-1!=c.numeric_comparator(s._id,e._id))return!0}else if(-1!=c.natural_sort(s._label,e._label))return!0;if(t=n.eq(l),"column"===(s=i.t.itemData(t))._type){if(-1==c.numeric_comparator(s._id,e._id))return!1}else if(1!=c.natural_sort(s._label,e._label))return!0;if(o=a+Math.round((l-a)/2),t=n.eq(o),0==(r="column"===(s=i.t.itemData(t))._type?c.numeric_comparator(s._id,e._id):c.natural_sort(s._label,e._label)))return!0;-1==r?(a=o+1,l--):(a++,l=o-1)}return function(){for(;l>=a;){t=n.eq(a);var s=i.t.itemData(t);if("column"===s._type){if(1==c.numeric_comparator(s._id,e._id))return!0}else if(1==c.natural_sort(s._label,e._label))return!0;a++}return l!=n.length-1?(t=n.eq(l),!0):(t=null,!1)}()}())i.t.before(t,{itemData:e,success:function(){i.o&&i.o.success&&"function"==typeof i.o.success&&i.o.success.apply(i.t,[t,e])},fail:function(){console.warn("Failed to add before...",arguments),i.o&&i.o.fail&&"function"==typeof i.o.fail&&i.o.fail.apply(i.t,[t,e])}});else{var o=function(){var t=this,i=t.t.wasLoad(t.i),n=t.t.itemData(t.i);t.t.append(t.i,{itemData:e,success:function(a,l){var o=s(l.items[0]);i&&n&&n._type.search(e._type)>-1?(t.t.openPath(o),t.t.select(o)):n&&t.t.unload(t.i,{success:function(e){t.t.open(e)}}),t.o&&t.o.success&&"function"==typeof t.o.success&&t.o.success.apply(t.t,[o,e])},fail:function(){console.warn("Failed to append...",arguments),t.o&&t.o.fail&&"function"==typeof t.o.fail&&t.o.fail.apply(t.t,[t.i,e])}})}.bind(i);i.i&&!i.t.isInode(i.i)?i.t.setInode(i.i,{success:o}):o()}}.bind(t);i||!t.t.wasLoad(t.i)?n(a,l):t.t.unload(t.i,{success:function(){n(a,function(){var t=this&&this.o;t&&t.fail&&"function"==typeof t.fail&&t.fail.apply(this.t,[this.i,e])}.bind(this))}.bind(this),fail:function(){var t=this&&this.o;t&&t.fail&&"function"==typeof t.fail&&t.fail.apply(this.t,[this.i,e])}.bind(this)})}.bind(n);n.t.wasInit()&&e&&(e._label=e.label,e.label=r.escape(e.label),a())},onUpdateTreeNode:function(e,t,i,n){var a={b:this,d:null,i:null,hasId:!0,p:r.toArray(i||{}).sort((function(e,t){return e.priority===t.priority?0:e.priority<t.priority?-1:1})),pathOfTreeItems:[],t:this.tree,o:n,load:!0,old:e,new:t,op:null},l=function(){var i=this.o&&this.o.fail;i&&"function"==typeof i&&i.apply(this.t,[this.i,t,e])}.bind(a),o=function(){var e=this,t=this.pathOfTreeItems,i=function(){if(t.length){t.pop();var e=t.length;this.i=e&&t[e-1].item||null,this.d=e&&t[e-1].d||null,e&&t[e-1].coll&&(t.pop(),e=t.length,this.i=e&&t[e-1].item||null,this.d=e&&t[e-1].d||null)}else this.i=null,this.d=null}.bind(this),n=this.i&&this.t.hasParent(this.i)&&this.t.parent(this.i)||null,o=n?this.t.hasParent(n)&&this.t.parent(n):null;if(this.i&&this.d&&this.old._id==this.d._id&&this.old._type==this.d._type){var d=this.t.parent(this.i)||null;if(0==d.length&&"UPDATE"==a.op)u();else{var c=function(){if(!n||o){var t=this.d;return i(),void(this.i?(this.load=!0,this.success=function(){h()}.bind(this),this.notFound=l,this.b._findTreeChildNode(this.i,{_id:this.new._pid,_type:t._type},this)):h())}var a=null,d=this.t.siblings(this.i)||[];if(d.push(this.i[0]),r.each(d,(function(t){var i=e.t.itemData(s(t));i._id==e.new._pid&&(a=t,e.pathOfTreeItems.push({coll:!0,item:a,d:i}))})),a){this.load=!0,this.success=function(){h()}.bind(this),this.notFound=l,a=s(a);var c=function(){e.i=a,e.pathOfTreeItems.push({coll:!1,item:a,d:e.d}),e.success()};!this.t.wasLoad(a)&&e.load?e.t.open(a,{success:c,unanimated:!0,fail:function(){var t=e&&e.o&&e.o.fail;t&&"function"==typeof t&&t.apply(e.t,[])}}):c()}}.bind(this);this.t.remove(this.i,{success:function(){return i(),n&&!o&&d&&0==e.t.children(d).length?e.t.setInode(d,{success:function(){e.t.unload(d,{success:function(){setTimeout(c)}})}}):setTimeout(c),!0}})}}l()}.bind(a),d=function(e){var t=function(){var e=this.pathOfTreeItems;if(e.length){e.pop();var t=e.length;this.i=t&&e[t-1].item||null,this.d=t&&e[t-1].d||null,t&&e[t-1].coll&&(e.pop(),t=e.length,this.i=t&&e[t-1].item||null,this.d=t&&e[t-1].d||null)}else this.i=null,this.d=null}.bind(this);this.i?(this.load=!0,this.success=function(){h()}.bind(this),e._type==this.old._type&&(t(),e=this.d,t()),e=this.new._pid,this.notFound=l,this.b._findTreeChildNode(this.i,e,this)):h()}.bind(a),u=function(){if(this.i&&this.d&&this.new._type==this.d._type){var i=this,n=this.d._id;if(this.new._id!=this.d._id)this.t.itemData(a.i)._id=n=this.new._id;this.new._id==n&&(r.extend(this.d,{_id:this.new._id,_label:this.new._label,label:this.new.label}),this.t.setLabel(a.i,{label:this.new.label}),this.t.addIcon(a.i,{icon:this.new.icon}),this.t.setId(a.i,{id:this.new.id}),this.t.openPath(this.i),this.t.deselect(this.i),setTimeout((function(){i.t.select(i.i)}),10))}var s=this.o&&this.o.success;s&&"function"==typeof s&&s.apply(this.t,[this.i,e,t])}.bind(a),p=function(){var e,t=this;return t.success=p,t.p.length?(e=t.p.shift(),t.p.length||("RECREATE"==t.op?(t.load=!1,t.success=o,t.notFound=d):(t.success=u,t.notFound=l)),t.b._findTreeChildNode(t.i,e,t)):1==t.p.length&&(t.notFound=d),!0}.bind(a),h=function(){var i=this,n=(i.i||this.t.wasLoad(i.i))&&this.t.first(i.i),a=function(e,i){this.success=e,this.notFound=i,this.b._findTreeChildNode(this.i,t,this)}.bind(i),l=function(){this.t.openPath(this.i),this.t.select(this.i),i.o&&i.o.success&&"function"==typeof i.o.success&&i.o.success.apply(i.t,[i.i,t])}.bind(i),o=function(){var i,n=this,a=n.t.children(n.i),l=0,o=a.length-1;if(function(){for(;o-l>22;){i=a.eq(l);var e=n.t.itemData(i);if(-1!=c.natural_sort(e._label,t._label))return!0;if(i=a.eq(o),e=n.t.itemData(i),1!=c.natural_sort(e._label,t._label))return!0;var s=l+Math.round((o-l)/2);i=a.eq(s),e=n.t.itemData(i);var r=c.natural_sort(e._label,t._label);if(0==r)return!0;-1==r?(l=s+1,o--):(l++,o=s-1)}return function(){for(;o>=l;){i=a.eq(l);var e=n.t.itemData(i);if(1==c.natural_sort(e._label,t._label))return!0;l++}return o!=a.length-1?(i=a.eq(o),!0):(i=null,!1)}()}())n.t.before(i,{itemData:t,success:function(){var a=s(arguments[1].items[0]);n.t.openPath(a),n.t.select(a),n.o&&n.o.success&&"function"==typeof n.o.success&&n.o.success.apply(n.t,[i,e,t])},fail:function(){console.warn("Failed to add before..",arguments),n.o&&n.o.fail&&"function"==typeof n.o.fail&&n.o.fail.apply(n.t,[i,e,t])}});else{var r=function(){n.t.append(n.i,{itemData:t,success:function(){var i=s(arguments[1].items[0]);n.t.openPath(i),n.t.select(i),n.o&&n.o.success&&"function"==typeof n.o.success&&n.o.success.apply(n.t,[n.i,e,t])},fail:function(){console.warn("Failed to append...",arguments),n.o&&n.o.fail&&"function"==typeof n.o.fail&&n.o.fail.apply(n.t,[n.i,e,t])}})};n.i&&!n.t.isInode(n.i)?n.t.setInode(n.i,{success:r}):r()}}.bind(i);n||!i.t.wasLoad(i.i)?a(l,o):i.t.unload(i.i,{success:function(){a(l,function(){var i=this&&this.o;i&&i.fail&&"function"==typeof i.fail&&i.fail.apply(this.t,[this.i,e,t])}.bind(this))}.bind(this),fail:function(){var i=this&&this.o;i&&i.fail&&"function"==typeof i.fail&&i.fail.apply(this.t,[this.i,e,t])}.bind(this)})}.bind(a);a.t.wasInit()&&t&&e&&(a.pathOfTreeItems.push(e),t._label=t.label,t.label=r.escape(t.label),a.b.Nodes[t._type].is_collection&&"collection_count"in e&&e.collection_count>0&&(t.label=r.escape(t._label)+" <span>("+e.collection_count+")</span>"),"server"==e._type&&"server"==t._type&&(e._pid!=t._pid||e._label!=t._label||e.icon!=t.icon)||e._pid!=t._pid||e._label!=t._label||e._id!=t._id?(a.op="RECREATE",p()):(a.op="UPDATE",p()))},onRefreshTreeNode:function(e,i){var n,a=e&&this.tree.itemData(e),l=a&&a._type&&this.Nodes[a._type],o={b:this,d:a,i:e,p:null,pathOfTreeItems:[],t:this.tree,o:i},d=-1;if(this.Events.trigger("pgadmin-browser:tree:refreshing",e,a,l),l?n=this.tree.isInode(e)&&this.tree.isOpen(e):(e=null,o.i=null,o.d=null),o.branch=o.t.serialize(e,{},(function(e,t,i){if(!++d||i.inode&&i.open)return{_id:i._id,_type:i._type,branch:i.branch,open:i.open}})),l){var c=function(e,i,n){var a=n.getTreeNodeHierarchy(e),l=n.generate_url(e,"nodes",i,!0);s.ajax({url:l,type:"GET",cache:!1,dataType:"json"}).done((function(e){var t=e.result||e.data;t._label=t.label,t.label=r.escape(t.label),o.t.setLabel(o.i,{label:t.label}),o.t.addIcon(o.i,{icon:t.icon}),o.t.setId(o.i,{id:t.id}),t.inode&&o.t.setInode(o.i,{inode:!0});var i=o.t.itemData(o.i);if(r.extend(i,t),!n.can_expand||"function"!=typeof n.can_expand||n.can_expand(i)){o.b._refreshNode(o,o.branch);var a=o.o&&o.o.success||o.success;a&&"function"==typeof a&&a()}else o.t.unload(o.i)})).fail((function(s,l,r){if(!u.pgHandleItemError(s,l,r,{item:e,info:a})){var d=s.getResponseHeader("Content-Type"),p=d&&0==d.indexOf("application/json")&&JSON.parse(s.responseText)||{};if(410==s.status&&0==p.success){var h=o.t.parent(o.i);o.t.remove(o.i,{success:function(){if(h)try{_.Events.trigger("pgadmin:browser:tree:refresh",h)}catch(e){console.warn(e.stack||e)}}})}u.pgNotifier(l,s,t("Error retrieving details for the node."),(function(t){"CRYPTKEY_SET"==t?c(e,i,n):console.warn(arguments)}))}}))}.bind(this);if(l&&l.collection_node){var p=o.i=this.tree.parent(e),h=function(){this.tree.unload(e,{success:function(){e=p,a=o.d=o.t.itemData(o.i),l=o.b.Nodes[a._type],c(e=p,a,l)},fail:function(){console.warn(arguments)}})}.bind(this);this.tree.isInode(e)?h():this.tree.setInode(e,{success:h})}else n?this.tree.unload(e,{success:c.bind(this,e,a,l),fail:function(){console.warn(arguments)}}):!this.tree.isInode(e)&&a.inode?this.tree.setInode(e,{success:c.bind(this,e,a,l),fail:function(){console.warn(arguments)}}):c(e,a,l)}else o.t.destroy({success:function(){N(o.b),o.t=o.b.tree,o.i=null,o.b._refreshNode(o,o.branch)},error:function(){var e=i.o&&i.o.fail||i.fail;"function"==typeof e&&e()}})},onLoadFailNode:function(e){var t=this,i=t.tree.isSelected(e);t.check_master_password((function(n){n||t.set_master_password("",(function(){i&&t.tree.select(e),t.tree.open(e)}))}))},removeChildTreeNodesById:function(e,t,i){var n=_.tree;if(e&&t){var a,s,l=n.children(e),o=0,r=l.length;for(e=null;o<r;o++)if(a=l.eq(o),(s=n.itemData(a))._type==t){e=a;break}}if(e){for(o=0,r=(l=n.children(e)).length;o<r;o++)a=l.eq(o),s=n.itemData(a),-1!=i.indexOf(s._id)&&_.removeTreeNode(a,!1,e);return!0}return!1},removeTreeNode:function(e,t,i){var n=_.tree,a=null;return!!e&&(t&&((a=n.next(e))&&a.length||(a=n.prev(e))&&a.length||(a=i||n.parent(e)),a&&n.select(a)),n.remove(e),!0)},findSiblingTreeNode:function(e,t){for(var i,n,a=_.tree,s=a.parent(e),l=a.children(s),o=0;o<l.length;o++)if(n=l.eq(o),(i=a.itemData(n))&&i._id==t)return n;return null},findParentTreeNodeByType:function(e,t){var i,n=_.tree,a=e;do{if((i=n.itemData(a))&&i._type==t)return a;a=n.hasParent(a)?n.parent(a):null}while(a);return null},findChildCollectionTreeNode:function(e,t){var i,n=_.tree,a=0,s=e,l=e&&n.children(e);if(!l||!l.length)return null;for(;a<l.length;a++)if(s=l.eq(a),(i=n.itemData(s))&&i._type==t)return s;return null},addChildTreeNodes:function(e,t,i,n,a){var l=i in _.Nodes&&_.Nodes[i],o=n.length&&r.extend({},r.mapObject(e,(function(e){return e.priority-=1,e}))),d=[],c=function e(t){if(n.length){var a,r={_id:n.pop(),_type:i,priority:0};o[i]=r,a=l.generate_url(null,"nodes",r,!0,o),s.ajax({url:a,dataType:"json"}).done((function(i){i.success&&d.push(i.data),e(t)})).fail((function(i,n,a){u.pgRespErrorNotify(i,a),e(t)}))}else t&&t()};l?_.tree.wasLoad(t)||_.tree.isLeaf(t)?c((function(){r.each(d,(function(t){_.Events.trigger("pgadmin:browser:tree:add",t,e)})),a&&a()})):a&&a():console.warn("Developer: Couldn't find the module for the given child: ",r.clone(arguments))},_refreshNode:function(e,t){var i=function(e){for(var t,i,n=0,a=e.branch&&e.branch.length||0,s=function(e,t,i){setTimeout((function(){i.b._findTreeChildNode(e,t,i)}),0)};n<a;n++){i=e.branch[n];var l=this.b.Nodes[i._type];(t={b:this.b,t:this.t,pathOfTreeItems:[],i:this.i,d:i,select:this.select,hasId:l&&!l.collection_node,o:this.o,load:!0}).success=function(){this.b._refreshNode.call(this.b,this,this.d)}.bind(t),s(this.i,i,t)}}.bind(e,t);t&&t.open&&(e.t.isOpen(e.i)?i():e.t.open(e.i,{unanimated:!0,success:i,fail:function(){}}))},editor_shortcut_keys:{"Ctrl-Space":"autocomplete","Cmd-Space":"autocomplete","Ctrl-A":"selectAll","Cmd-A":"selectAll","Ctrl-Y":"redo","Cmd-Y":"redo","Ctrl-Z":"undo","Cmd-Z":"undo","Ctrl-D":"deleteLine","Cmd-D":"deleteLine","Alt-Up":"goLineUp","Alt-Down":"goLineDown","Ctrl-Alt-Left":"goGroupLeft","Cmd-Alt-Left":"goGroupLeft","Ctrl-Alt-Right":"goGroupRight","Cmd-Alt-Right":"goGroupRight","Shift-Tab":"indentLess"},editor_options:{tabSize:parseInt(_.utils.tabSize),wrapCode:_.utils.wrapCode,insert_pair_brackets:_.utils.insertPairBrackets,brace_matching:_.utils.braceMatching,indent_with_tabs:_.utils.is_indent_with_tabs},get_browser:function(){var e,t=navigator.userAgent,i=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(i[1])?{name:"IE",version:(e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""}:"Chrome"===i[1]&&null!=(e=t.match(/\bOPR|Edge\/(\d+)/))?{name:e[0],version:e[1]}:(i=i[2]?[i[1],i[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&i.splice(1,1,e[1]),{name:i[0],version:i[1]})}}),delete C.keyMap.emacsy["Ctrl-V"],"True"==_.utils.useSpaces&&(c.Browser.editor_shortcut_keys.Tab="insertSoftTab"),c.Browser}.apply(t,a))||(e.exports=s)}).call(this,i(0))},13:function(e,t,i){"use strict";(function(n){var a,s;i(8),i(14),i(16),i(185),i(186),i(5),i(38),i(9),i(7),a=[i(2),i(50),i(0),i(21)],void 0===(s=function(e,t,i,a){t.defaults.transition="zoom",t.defaults.theme.ok="btn btn-primary fa fa-lg fa-check pg-alertify-button",t.defaults.theme.cancel="btn btn-secondary fa fa-lg fa-times pg-alertify-button",t.defaults.theme.input="form-control",t.defaults.closable=!1,t.pgIframeDialog||t.dialog("pgIframeDialog",(function(){var e;return{main:function(e){return this.set({pg_msg:e})},setup:function(){return{options:{padding:!1,overflow:!1,closable:!0}}},build:function(){(e=document.createElement("iframe")).src="",e.frameBorder="no",e.width="100%",e.height="100%",this.elements.content.appendChild(e),this.elements.body.style.minHeight=.5*screen.height+"px"},settings:{pg_msg:void 0},settingUpdated:function(t,i,n){switch(t){case"pg_msg":var a=e.contentWindow||e.contentDocument;a.document&&(a=a.document),a.open(),a.write(n),a.close()}},hooks:{onupdate:function(t,i,n){switch(t){case"resizable":n?(this.elements.content.removeAttribute("style"),e&&e.removeAttribute("style")):(this.elements.content.style.minHeight="inherit",e&&(e.style.minHeight="inherit"))}}}}})),t.pgNotifier=function(i,a,s,l){var o=a.responseText,r=a.getResponseHeader("Content-Type");if(0==a.status)o=e("Connection to the server has been lost."),s=e("Connection Lost");else if(r)try{if(0==r.indexOf("application/json")){var d=JSON.parse(o);if("CRYPTKEY_MISSING"==d.info)return void window.pgAdmin.Browser.set_master_password("",(function(){l&&"function"==typeof l&&l("CRYPTKEY_SET")}));if(null!=d.result&&(!d.errormsg||""==d.errormsg)&&l&&"function"==typeof l)return l(d.result);o=n.escape(d.result)||n.escape(d.errormsg)||"Unknown error"}if(0==r.indexOf("text/html")){var c=s;return"error"===i&&(c='                  <div class="media text-danger text-14">                    <div class="media-body media-middle">                      <div class="alert-text" role="alert">'+s+'</div><br/>                      <div class="alert-text" role="alert">'+e("Click for details.")+"</div>                    </div>                  </div>"),void t.notify(c,i,0,(function(){t.pgIframeDialog().show().set({frameless:!1}).set("pg_msg",o)}))}}catch(e){t.alert().show().set("message",e.message).set("title","Error").set("closable",!0)}t.alert().show().set("message",o.replace(new RegExp(/\r?\n/,"g"),"<br />")).set("title",s).set("closable",!0)},t.pgRespErrorNotify=function(i,a){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",l=i.getResponseHeader("Content-Type");try{if(0===i.status)a=e("Connection to the server has been lost.");else{if(l&&l.indexOf("application/json")>=0){var o=JSON.parse(i.responseText);a=n.escape(o.result)||n.escape(o.errormsg)||e("Unknown error")}if(l.indexOf("text/html")>=0){var r='                <div class="media text-danger text-14">                  <div class="media-body media-middle">                    <div class="alert-text" role="alert">'+e("INTERNAL SERVER ERROR")+'</div><br/>                    <div class="alert-text" role="alert">'+e("Click for details.")+"</div>                  </div>                </div>";return void t.notify(r,"error",0,(function(){t.pgIframeDialog().show().set({frameless:!1}).set("pg_msg",i.responseText)}))}}}catch(e){a=e.message}t.error(s+" "+a)};var s=function(e){e&&(this.pgResizeRecursion=!1),this.pgResizeTimeout||(this.pgResizeTimeout=setTimeout(function(){var e=i(this.elements.dialog),t=e.width(),n="xs";this.pgResizeTimeout=null,t<480&&(n="xs"),t>=480&&(n="sm"),t>=768&&(n="md"),t>=992&&(n="lg"),t>=1200&&(n="xl"),e.attr("el",n)}.bind(this),100))},l=function e(t){var i=this;t&&(i.pgResizeRecursion=!0),setTimeout((function(){s.apply(i),i.pgResizeRecursion&&e.apply(i,[!1])}),100)};t.pgDialogBuild=function(){this.set("onshow",(function(){var t=this;this.elements.dialog.classList.add("pg-el-container"),i(this.elements.commands.close).attr("title",e("Close")),i(this.elements.commands.maximize).attr("title",e("Maximize")),i(this.elements.commands.close).attr("aria-label",e("Close")),i(this.elements.commands.maximize).attr("aria-label",e("Maximize")),s.apply(this,arguments);var n=this,l=Object.values(this.elements.commands);i(l).on("keydown","button",(function(e){if(e.shiftKey&&9==e.keyCode&&0==i(t).nextAll("button:not([disabled])").length){var s=i(n.elements.footer);a.findAndSetFocus(s.find("button:not([disabled]):last"))}}))})),this.set("onresize",l.bind(this,!0)),this.set("onresized",s.bind(this,!0)),this.set("onmaximized",s),this.set("onrestored",s);for(var t=0;t<this.__internal.buttons.length;t++)n.isUndefined(this.__internal.buttons[t].key)&&(this.__internal.buttons[t].key=null);var o=this;i(this.elements.footer).on("keydown","button",(function(e){if(!e.shiftKey&&9==e.keyCode&&0==i(this).nextAll("button:not([disabled])").length)return a.findAndSetFocus(i(o.elements.dialog)),!1}))},t.pgHandleItemError=function(t,n,a,s){var l=window.pgAdmin.Browser;if(t&&l){var o=t.getResponseHeader("Content-Type"),r=o&&0==o.indexOf("application/json")&&JSON.parse(t.responseText);if(r&&(503==t.status?"CONNECTION_LOST"==r.info&&"server"in s.info&&r.data.sid>=0&&r.data.sid==s.info.server._id:428==t.status&&r.errormsg&&r.errormsg==e("Connection to the server has been lost."))){s.preHandleConnectionLost&&"function"==typeof s.preHandleConnectionLost&&s.preHandleConnectionLost.apply(this,arguments);var d=l.Nodes.server,c={resp:r,xhr:t,args:s},u=function(){var e=function(i,n,a){this.args.info.server._id==i&&(l.Events.off("pgadmin:server:connected",e),l.Events.off("pgadmin:server:connect:cancelled",t),this.resp.data.database&&this.resp.data.database!=a.db&&l.Events.trigger("pgadmin:database:connection:lost",this.args.item,this.resp,!0))}.bind(this),t=function(i,n,a){i==this.args.info.server.id&&(l.Events.off("pgadmin:server:connected",e),l.Events.off("pgadmin:server:connect:cancelled",t),l.Events.trigger("pgadmin:database:connect:cancelled",i,this.resp.data.database||a.db,n,a))}.bind(this);l.Events.on("pgadmin:server:connected",e),l.Events.on("pgadmin:server:connect:cancelled",t),l.Events.trigger("pgadmin:server:connection:lost",this.args.item,this.resp)}.bind(c);return i.ajax({url:d.generate_url(null,"connect",s.info.server,!0,s.info),dataType:"json"}).done((function(e){e.success&&"connected"in e.data&&e.data.connected?l.Events.trigger("pgadmin:database:connection:lost",s.item,r):u()})).fail((function(){u()})),!0}return r&&"CRYPTKEY_MISSING"==r.info&&t.status,!1}};var o=t.success,r=t.error;return n.extend(t,{orig_success:o,orig_error:r}),n.extend(t,{success:function(e,i,n){var a='<div class="d-flex px-3 py-2">\n        <div class="pr-2">\n          <i class="fa fa-check text-success" aria-hidden="true"></i>\n        </div>\n        <div class="text-body" role="status">'.concat(e,"</div>\n      </div>");return t.orig_success(a,i,n)},error:function(e,i,n){var a='<div class="d-flex px-3 py-2">\n        <div class="pr-2">\n          <i class="fa fa-exclamation-triangle text-danger" aria-hidden="true"></i>\n        </div>\n        <div class="text-body" role="status">'.concat(e,"</div>\n      </div>");return t.orig_error(a,i,n)},info:function(e,i){var n='<div class="d-flex px-3 py-2">\n        <div class="mr-3">\n          <i class="fa fa-info text-primary" aria-hidden="true"></i>\n        </div>\n        <div class="text-body" role="status">'.concat(e,"</div>\n      </div>");return t.notify(n,i)}}),t.confirm().set({onshow:function(){i(this.elements.commands.close).attr("title",e("Close")),i(this.elements.commands.maximize).attr("title",e("Maximize")),i(this.elements.content).addClass("ajs-wrap-text"),i(this.elements.header).attr("id","confirm-dialog-header"),i(this.elements.body).attr("id","confirm-dialog-body"),i(this.elements.dialog).attr({role:"alertdialog","aria-modal":"true","aria-labelledby":"confirm-dialog-header","aria-describedby":"confirm-dialog-body"})},reverseButtons:!0}),t.prompt().set({reverseButtons:!0}),t.alert().set({onshow:function(){i(this.elements.header).attr("id","alert-dialog-header"),i(this.elements.body).attr("id","alert-dialog-body"),i(this.elements.modal).attr({role:"alertdialog","aria-modal":"true","aria-labelledby":"alert-dialog-header","aria-describedby":"alert-dialog-body"})}}),i("body").off("keyup").on("keyup",(function(e){if(13===e.which||27===e.which)for(var t=["select2-selection","select2-search__field"],n=i(e.target),a=0;a<t.length;a++)if(n.hasClass(t[a])){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();break}})),t}.apply(t,a))||(e.exports=s)}).call(this,i(1))},135:function(e,t,i){"use strict";var n,a;i(8),i(22),i(16),n=[i(2),i(0),i(1),i(3),i(15),i(76),i(50),i(62),i(104),i(84)],void 0===(a=function(e,t,i,n,a,s,l,o){t.fn.select2.amd.define("select2/selectAllAdapter",["select2/utils","select2/dropdown","select2/dropdown/attachBody"],(function(i,n,a){function s(){}return s.prototype.render=function(n){var a=this,s=n.call(this),l=t(['<button class="btn btn-secondary btn-sm" type="button"',' style="width: 49%;margin: 0 0.5%;">','<i class="fa fa-check-square-o" role="img"></i>','<span style="padding: 0px 5px;">',e("Select All"),"</span></button>"].join("")),o=t(['<button class="btn btn-secondary btn-sm" type="button"',' style="width: 49%;margin: 0 0.5%;">','<i class="fa fa-square-o"></i><span style="padding: 0px 5px;" role="img">',e("Unselect All"),"</span></button>"].join("")),r=t('<div class="select2-select-all-adapter-container">').append(l).append(o);return this.$element.prop("multiple")?(s.find(".select2-dropdown").prepend(r),l.on("click",(function(){s.find(".select2-results__option[aria-selected=false]").each((function(){var e=i.GetData(t(this)[0],"data");a.trigger("select",{data:e})})),a.trigger("close")})),o.on("click",(function(){s.find(".select2-results__option[aria-selected=true]").each((function(){var e=i.GetData(t(this)[0],"data");a.trigger("unselect",{data:e})})),a.trigger("close")})),s):s},i.Decorate(i.Decorate(n,a),s)}));var r=s.NodeAjaxOptionsControl=s.Select2Control.extend({defaults:i.extend(s.Select2Control.prototype.defaults,{url:void 0,transform:void 0,url_with_id:!1,select2:{allowClear:!0,placeholder:e("Select an item..."),width:"style"}}),initialize:function(){s.Select2Control.prototype.initialize.apply(this,arguments);var e=this,a=e.field.get("url")||e.defaults.url,l=e.model.top||e.model,o=e.field.get("url_jump_after_node")||null;if(a){var r,d=this.field.get("schema_node"),c=this.field.get("node_info"),u=this.field.get("url_with_id")||!1,p=d.generate_url.apply(d,[null,a,this.field.get("node_data"),u,c,o]),h=this.field.get("cache_node");h=h&&n.Browser.Nodes[h]||d,r=this.field.has("cache_level")?this.field.get("cache_level"):h.cache_level(c,u);var f=h.cache(d.type+"#"+a,c,r);this.field.get("version_compatible")&&(i.isUndefined(f)||i.isNull(f))&&(l.trigger("pgadmin:view:fetching",l,e.field),t.ajax({async:!1,url:p}).done((function(e){f=h.cache(d.type+"#"+a,c,r,e.data)})).fail((function(){l.trigger("pgadmin:view:fetch:error",l,e.field)})),l.trigger("pgadmin:view:fetched",l,e.field)),f=f&&f.data||[];var m=this.field.get("transform")||e.defaults.transform;m&&i.isFunction(m)?e.field.set("options",m.bind(e,f)):e.field.set("options",f)}}}),d=function(e){if(!e.id)return e.text;var i=t(e.element).data("image");return i?t("<span></span>").append(t("<span></span>",{class:"wcTabIcon "+i})).append(t("<span></span>").text(e.text)):e.text},c=s.NodeListByIdControl=r.extend({controlClassName:"pgadmin-node-select form-control",defaults:i.extend({},r.prototype.defaults,{url:"nodes",filter:void 0,transform:function(e){var t=this,n=t.field.get("schema_node"),a=[],s=t.field.get("filter")||function(){return!0};return s=s.bind(t),i.each(e,(function(e){if(s(e)){var l=i.isFunction(n.node_label)?n.node_label.apply(n,[e,t.model,t]):e.label,o=i.isFunction(n.node_image)?n.node_image.apply(n,[e,t.model,t]):n.node_image||"icon-"+n.type;a.push({value:e._id,image:o,label:l})}})),a},select2:{allowClear:!0,placeholder:e("Select an item..."),width:"style",templateResult:d,templateSelection:d}})});s.NodeListByNameControl=c.extend({defaults:i.extend({},c.prototype.defaults,{transform:function(e){var t=this,n=t.field.get("schema_node"),a=[],s=t.field.get("filter")||function(){return!0};return s=s.bind(t),i.each(e,(function(e){if(s(e)){var l=i.isFunction(n.node_label)?n.node_label.apply(n,[e,t.model,t]):e.label,o=i.isFunction(n.node_image)?n.node_image.apply(n,[e,t.model,t]):n.node_image||"icon-"+n.type;a.push({value:e.label,image:o,label:l})}})),a}})}),t.fn.pgMakeVisible=function(e){return this.each((function(){if(this&&t(this.length))for(var i,n,a=t(this);a&&a.length>0;)if(i=a.get(0).offsetTop+a.height(),a=a.parent(),(n=a)&&n.length>0&&n.get(0).scrollHeight>n.height()&&a.scrollTop(i),a.hasClass(e))return}))},t.fn.pgMakeBackgridVisible=function(e){return this.each((function(){if(this&&t(this.length)){var i=t(this),n=t(this).offsetParent().parent(),a=n.offset().top,s=n.height(),l=t(this).closest(e);if(0==l.length)return!1;if(s>l[0].offsetHeight-a){var o=i.get(0).offsetTop+i.height();l.find(".tab-content").scrollTop(o)}return!0}}))};var u=o.Extension.NodeAjaxOptionsCell=o.Extension.Select2Cell.extend({defaults:i.extend({},o.Extension.Select2Cell.prototype.defaults,{url:void 0,transform:void 0,url_with_id:!1,select2:{allowClear:!0,placeholder:e("Select an item..."),width:"style"},opt:{label:null,value:null,image:null,selected:!1}}),template:i.template('<option <% if (image) { %> data-image=<%= image %> <% } %> value="<%- value %>" <%= selected ? \'selected="selected"\' : "" %>><%- label %></option>'),initialize:function(){o.Extension.Select2Cell.prototype.initialize.apply(this,arguments);var e=this.column.get("url")||this.defaults.url,a=i.has(this.column.attributes,"options_cached"),s=a&&this.column.get("options_cached");if(e&&!s){var l,r=this,d=this.model,c=this.column,u=d.top||d,p=c.get("schema_node"),h=c.get("node_info"),f=c.get("url_with_id")||!1,m=this.column.get("url_jump_after_node")||null,g=p.generate_url.apply(p,[null,e,c.get("node_data"),f,h,m]),v=c.get("cache_node");v=v&&n.Browser.Nodes[v]||p,l=c.has("cache_level")?c.get("cache_level"):v.cache_level(h,f);var b=v.cache(p.type+"#"+e,h,l);c.get("version_compatible")&&(i.isUndefined(b)||i.isNull(b))&&(u.trigger("pgadmin:view:fetching",d,c),t.ajax({async:!1,url:g}).done((function(t){b=v.cache(p.type+"#"+e,h,l,t.data)})).fail((function(){u.trigger("pgadmin:view:fetch:error",d,c)})),u.trigger("pgadmin:view:fetched",d,c)),b=b&&b.data||[];var y=c.get("transform")||r.defaults.transform;y&&i.isFunction(y)?c.set("options",y.bind(c,b)):c.set("options",b),a&&c.set("options_cached",!0)}}});return o.Extension.NodeListByIdCell=u.extend({controlClassName:"pgadmin-node-select backgrid-cell",defaults:i.extend({},u.prototype.defaults,{url:"nodes",filter:void 0,transform:function(e,t){var n=t||this,a=n.column.get("schema_node"),s=[],l=n.column.get("filter")||function(){return!0};return l=l.bind(n),i.each(e,(function(e){if(l(e)){var t=i.isFunction(a.node_label)?a.node_label.apply(a,[e,n.model,n]):e.label,o=i.isFunction(a.node_image)?a.node_image.apply(a,[e,n.model,n]):a.node_image||"icon-"+a.type;s.push({value:e._id,image:o,label:t})}})),s},select2:{placeholder:e("Select an item..."),width:"style",templateResult:d,templateSelection:d}})}),o.Extension.NodeListByNameCell=u.extend({controlClassName:"pgadmin-node-select backgrid-cell",defaults:i.extend({},u.prototype.defaults,{url:"nodes",filter:void 0,transform:function(e,t){var n=t||this,a=n.column.get("schema_node"),s=[],l=n.column.get("filter")||function(){return!0};return l=l.bind(n),i.each(e,(function(e){if(l(e)){var t=i.isFunction(a.node_label)?a.node_label.apply(a,[e,n.model,n]):e.label,o=i.isFunction(a.node_image)?a.node_image.apply(a,[e,n.model,n]):a.node_image||"icon-"+a.type;s.push({value:e.label,image:o,label:t})}})),s},select2:{placeholder:e("Select an item..."),width:"style",templateResult:d,templateSelection:d}})}),o.Extension.MultiSelectAjaxCell=o.Extension.NodeAjaxOptionsCell.extend({defaults:i.extend({},u.prototype.defaults,{transform:void 0,url_with_id:!1,select2:{allowClear:!0,placeholder:e("Select an item..."),width:"style",multiple:!0},opt:{label:null,value:null,image:null,selected:!1}}),getValueFromDOM:function(){var e=[];return this.$el.find("select").find(":selected").each((function(){e.push(t(this).attr("value"))})),e}}),s.MultiSelectAjaxControl=r.extend({defaults:i.extend({},r.prototype.defaults,{select2:{multiple:!0,allowClear:!0,width:"style"}})}),s}.apply(t,n))||(e.exports=a)},20:function(e,t,i){"use strict";(function(n){var a,s;i(30),i(8),i(14),i(22),i(33),i(103),i(36),i(28),i(16),i(10),i(41),i(12),i(35),i(5),i(38),i(9),i(29),i(82),i(7),i(37),a=[i(2),i(1),i(0),i(15),i(76),i(62),i(53),i(59),i(70),i(34),i(150),i(386),i(31),i(104),i(187)],void 0===(s=function(e,t,i,n,a,s,l,o,r,d,c,u){var p=window.pgAdmin=window.pgAdmin||{},h=p.Browser;p.editableCell=function(){if(this.attributes&&!t.isUndefined(this.attributes.disabled)&&!t.isNull(this.attributes.disabled)){if(t.isFunction(this.attributes.disabled))return!this.attributes.disabled.apply(this,arguments);if(t.isBoolean(this.attributes.disabled))return!this.attributes.disabled}},t.extend(a,{controlLabelClassName:"control-label pg-el-sm-3 pg-el-12",controlsClassName:"pgadmin-controls pg-el-sm-9 pg-el-12",controlContainerClassName:"pgadmin-controls pg-el-sm-9 pg-el-12",groupClassName:"pgadmin-control-group form-group row pg-el-12",setGroupClassName:"set-group pg-el-12",tabClassName:"backform-tab pg-el-12",setGroupContentClassName:"fieldset-content pg-el-12",accordianGroupClassName:"accordian-group pg-el-12",accordianContentClassName:"accordian-content pg-el-12",hiddenClassName:"d-none",helpMessageClassName:"form-text text-muted help-block",helpBlockControlClass:"pgadmin-controls offset-sm-3 pg-el-sm-9 pg-el-12"}),a.controlMapper={int:["uneditable-input","numeric","integer"],text:["uneditable-input","input","string"],numeric:["uneditable-input","numeric","numeric"],date:"datepicker",datetime:"datetimepicker",boolean:"boolean",options:["readonly-option","select",s.Extension.PGSelectCell],multiline:["textarea","textarea","string"],collection:["sub-node-collection","sub-node-collection","string"],uniqueColCollection:["unique-col-collection","unique-col-collection","string"],switch:"switch",select2:"select2",note:"note",color:"color",radioModern:"radioModern"},a.getMappedControl=function(e,i){if(e in a.controlMapper){var n=a.controlMapper[e];if(!t.isArray(n))return n;var s=1,l=t.size(n);switch(i){case"properties":s=0;break;case"edit":case"create":case"control":s=1;break;case"cell":s=2;break;default:s=0}return n[s>l?0:s]}return e};var f=a.RawFormatter=function(){};t.extend(f.prototype,{fromRaw:function(e){return e},toRaw:function(e){return e}});var m=a.Control.prototype.initialize,g=a.Control.prototype.remove;t.extend(a.Control.prototype,{defaults:t.extend(a.Control.prototype.defaults,{helpMessage:null}),initialize:function(){m.apply(this,arguments);var e=this.field.get("deps"),i=this;e&&t.isArray(e)&&t.each(e,(function(e){var t=e.split(".").shift();i.listenTo(i.model,"change:"+t,i.render)}))},remove:function(){var e=this,i=e.field.get("deps"),a=this.field.get("name").split("."),s=a.shift();e.stopListening(e.model,"change:"+s,e.render),e.model.errorModel instanceof n.Model&&e.stopListening(e.model.errorModel,"change:"+s,e.updateInvalid),i&&t.isArray(i)&&t.each(i,(function(t){var i=t.split(".").shift();e.stopListening(e.model,"change:"+i,e.render)})),this.cleanup&&this.cleanup.apply(this),g?g.apply(e,arguments):n.View.prototype.remove.apply(e,arguments)},template:t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>','<div class="<%=Backform.controlsClassName%>">','  <input id="<%=cId%>" class="<%=Backform.controlClassName%> uneditable-input" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%> id="<%=cId%>" value="<%-value%>" />',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),clearInvalid:function(){return this.$el.removeClass(a.errorClassName),this.$el.find(".pgadmin-control-error-message").remove(),this},updateInvalid:function(){var e=this,s=this.model.errorModel;if(!(s instanceof n.Model))return this;this.clearInvalid(),this.$el.find(":input[name]").not("button").each((function(n,l){var o=e.keyPathAccessor(s.toJSON(),i(l).attr("name"));t.isEmpty(o)||e.$el.addClass(a.errorClassName)}))},render:function(){var e=t.defaults(this.field.toJSON(),this.defaults),i=this.model.toJSON(),n=e.name.split("."),s=n.shift(),l=n.join("."),o=this.keyPathAccessor(i[s],l),r=t.extend(e,{rawValue:o,value:this.formatter.fromRaw(o,this.model),attributes:i,formatter:this.formatter}),d=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};return t.extend(r,{disabled:d(r.disabled,r,this.model),readonly:d(r.readonly,r,this.model),visible:d(r.visible,r,this.model),required:d(r.required,r,this.model)}),r.cId=r.cId||t.uniqueId("pgC_"),this.$el.removeClass(a.hiddenClassName),r.visible||this.$el.addClass(a.hiddenClassName),this.$el.html(this.template(r)).addClass(e.name),this.updateInvalid(),this}}),t.extend(a.InputControl.prototype,{template:t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>','<div class="<%=Backform.controlContainerClassName%>">','  <input type="<%=type%>" id="<%=cId%>" class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>" name="<%=name%>" maxlength="<%=maxlength%>" value="<%-value%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%> <%=required ? "required" : ""%> />',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),events:{"change input":"onChange","blur input":"onChange","keyup input":"onKeyUp","focus input":"clearInvalid"},onKeyUp:function(e){this.key_timeout&&clearTimeout(this.key_timeout),this.keyup_timeout=setTimeout(function(){this.onChange(e)}.bind(this),400)}}),t.extend(a.TextareaControl.prototype,{defaults:t.extend(a.TextareaControl.prototype.defaults,{rows:5,helpMessage:null,maxlength:null}),events:{"change textarea":"onChange","keyup textarea":"onKeyUp","paste textarea":"onChange","selectionchange textarea":"onChange","focus textarea":"clearInvalid"},template:t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>','<div class="<%=Backform.controlsClassName%>">','  <textarea id="<%=cId%>"','    class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>" name="<%=name%>"',"  <% if (maxlength) { %>",'    maxlength="<%=maxlength%>"',"  <% } %>",'    placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%>','    rows=<%=rows ? rows : ""%>','    <%=required ? "required" : ""%>><%-value%></textarea>',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),onKeyUp:function(e){this.key_timeout&&clearTimeout(this.key_timeout),this.keyup_timeout=setTimeout(function(){this.onChange(e)}.bind(this),400)}}),a.SelectControl.prototype.render=function(){var e=t.defaults(this.field.toJSON(),this.defaults),i=this.model.toJSON(),n=e.name.split("."),s=n.shift(),l=n.join("."),o=this.keyPathAccessor(i[s],l),r=t.extend(e,{rawValue:o,value:this.formatter.fromRaw(o,this.model),attributes:i,formatter:this.formatter}),d=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};if(t.extend(r,{disabled:d(r.disabled,r,this.model),visible:d(r.visible,r,this.model),required:d(r.required,r,this.model)}),t.isFunction(r.options))try{r.options=r.options(this)}catch(e){r.options=[],this.model.trigger("pgadmin-view:transform:error",this.model,this.field,e)}return r.cId=r.cId||t.uniqueId("pgC_"),this.$el.removeClass(a.hiddenClassName),r.visible||this.$el.addClass(a.hiddenClassName),this.$el.html(this.template(r)).addClass(e.name),this.updateInvalid(),this},a.SelectControl.prototype.template=t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>','<div class="<%=Backform.controlContainerClassName%>">','  <select id="<%=cId%>" class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>" name="<%=name%>" value="<%-value%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "disabled" : ""%> <%=required ? "required" : ""%> >',"    <% for (var i=0; i < options.length; i++) { %>","      <% var option = options[i]; %>",'      <option value="<%-formatter.fromRaw(option.value)%>" <%=option.value === rawValue ? "selected=\'selected\'" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%></option>',"    <% } %>","  </select>","</div>"].join("\n")),t.extend(a.SelectControl.prototype.defaults,{helpMessage:null}),a.ReadonlyOptionControl=a.SelectControl.extend({template:t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>','<div class="<%=Backform.controlsClassName%>">',"<% for (var i=0; i < options.length; i++) { %>"," <% var option = options[i]; %>"," <% if (option.value === rawValue) { %>",' <input id="<%=cId%>" class="<%=Backform.controlClassName%> uneditable-input" readonly value="<%-option.label%>"></span>'," <% } %>","<% } %>","<% if (helpMessage && helpMessage.length) { %>",'  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"<% } %>","</div>"].join("\n")),events:{},getValueFromDOM:function(){return this.formatter.toRaw(this.$el.find("span").text(),this.model)}}),t.extend(a.RadioControl.prototype,{updateInvalid:function(){var e=this,s=this.model.errorModel;if(!(s instanceof n.Model))return this;this.clearInvalid(),this.$el.find(":input[name]").not("button").each((function(n,l){var o=e.keyPathAccessor(s.toJSON(),i(l).attr("name"));t.isEmpty(o)||e.$el.addClass(a.errorClassName).find('[type="radio"]').append(i("<div></div>").addClass("pgadmin-control-error-message pg-el-offset-4 pg-el-8 pg-el-8 help-block").text(o))}))}}),a.RadioModernControl=a.RadioControl.extend({defaults:{controlLabelClassName:a.controlLabelClassName,controlsClassName:a.controlsClassName,extraClasses:[],helpMessage:"",name:""},events:t.extend({},a.InputControl.prototype.events,{"click label.btn":"toggle"}),toggle:function(e){var t=i(e.currentTarget);t.closest(".btn-group").find(".btn").removeClass("btn-primary").addClass("btn-secondary").find(".fa").addClass("visibility-hidden").siblings("input").prop("checked",!1),t.removeClass("btn-secondary").addClass("btn-primary").find(".fa").removeClass("visibility-hidden").siblings("input").prop("checked",!0).trigger("change"),e.preventDefault(),e.stopPropagation()},template:t.template(["<% if (label) { %>",'<label class="<%=controlLabelClassName%>" id="<%=cId%>_grplabel"><%=label%></label>',"<% } %>","<div class=\"<%=controlsClassName%> <%=extraClasses.join(' ')%>\">",' <div class="btn-group pgadmin-controls-radio-none<% if (disabled) {%> disabled <%}%>" role="radiogroup" <% if (label) {%> aria-labelledby="<%=cId%>_grplabel" <%}%>>',"  <% for (var i=0; i < options.length; i++) { %>","  <% var option = options[i]; %>",'  <label role="radio" class="btn btn-radiomodern <% if (option.value == value) { %> btn-primary <%} else {%> btn-secondary <%}%> <% if (!option.disabled && !disabled) { %>" tabindex="0"<% } else { %> disabled"<% } %>>','    <i class="fa fa-check  <% if (option.value != value) { %>visibility-hidden <%}%>" role="img"></i>','    <input type="radio" name="<%=name%>" autocomplete="off" value=<%-formatter.fromRaw(option.value)%> <% if (option.value == value) { %> checked<%}%> <% if (option.disabled || disabled) { %> disabled <%}%>> <%-option.label%>',"  </label>","  <% } %>"," </div>"," <% if (helpMessage && helpMessage.length) { %>",'  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>'," <% } %>","</div>"].join("\n")),formatter:f,getValueFromDOM:function(){return this.formatter.toRaw(this.$el.find('input[type="radio"]:checked').attr("value"),this.model)},render:function(){var e=t.defaults(this.field.toJSON(),this.defaults),n=this.model.toJSON(),s=e.name.split("."),l=s.shift(),o=s.join("."),r=this.keyPathAccessor(n[l],o),d=t.extend(e,{rawValue:r,value:this.formatter.fromRaw(r,this.model),attributes:n,formatter:this.formatter}),c=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};return t.extend(d,{disabled:c(d.disabled,d,this.model),visible:c(d.visible,d,this.model),required:c(d.required,d,this.model)}),d.cId=d.cId||t.uniqueId("pgC_"),d.options=t.isFunction(d.options)?d.options.apply(d,[this.model]):d.options,this.$el.removeClass(a.hiddenClassName),d.visible||this.$el.addClass(a.hiddenClassName),this.$el.html(this.template(d)).addClass(e.name),this.updateInvalid(),this.$el.find(".btn").on("keyup",(function(e){switch(e.keyCode){case 32:i(e.currentTarget).trigger("click")}})),this}}),a.SwitchControl=a.InputControl.extend({defaults:{label:"",options:{onText:e("Yes"),offText:e("No"),onColor:"success",offColor:"ternary",size:"mini",width:null,height:null},controlLabelClassName:a.controlLabelClassName,controlsClassName:a.controlsClassName,extraClasses:[],helpMessage:null,extraToggleClasses:null},template:t.template(['<span class="<%=controlLabelClassName%>"><%=label%></span>','<label class="sr-value sr-only" for="<%=cId%>"></label>',"<div class=\"<%=controlsClassName%> <%=extraClasses.join(' ')%>\">",'      <input tabindex="-1" type="checkbox" aria-hidden="true" aria-label="'+e("Toggle button")+'" data-style="quick" data-toggle="toggle"','      data-size="<%=options.size%>" data-height="<%=options.height%>"  ','      data-on="<%=options.onText%>" data-off="<%=options.offText%>" ','      data-onstyle="<%=options.onColor%>" data-offstyle="<%=options.offColor%>" data-width="<%=options.width%>" ','      name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=readonly ? "disabled" : ""%> <%=required ? "required" : ""%> />',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),getValueFromDOM:function(){return this.formatter.toRaw(this.$input.prop("checked"),this.model)},events:{"change input":"onChange",keyup:"toggleSwitch"},setSrValue:function(){var i=t.defaults(this.field.get("options"),this.defaults.options),n=i.onText,a=i.offText,s=this.field.get("label");this.$el.find(".toggle.btn").hasClass("off")?this.$el.find(".sr-value").text("\n          ".concat(s,", ").concat(a,", ")+e("Toggle button")+"\n        "):this.$el.find(".sr-value").text("\n          ".concat(s,", ").concat(n,", ")+e("Toggle button")+"\n        ")},onChange:function(){a.InputControl.prototype.onChange.apply(this,arguments),this.setSrValue()},toggleSwitch:function(e){32==e.keyCode&&(this.$el.find("input[type=checkbox]").bootstrapToggle("toggle"),e.preventDefault(),this.setSrValue())},render:function(){var e=t.defaults(this.field.toJSON(),this.defaults),n=this.model.toJSON(),s=e.name.split("."),l=s.shift(),o=s.join("."),r=this.keyPathAccessor(n[l],o),d=t.extend(e,{rawValue:r,value:this.formatter.fromRaw(r,this.model),attributes:n,formatter:this.formatter}),c=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};return t.extend(d,{disabled:c(e.disabled,e,this.model),readonly:c(e.readonly,e,this.model),visible:c(d.visible,e,this.model),required:c(d.required,e,this.model)}),d.cId=d.cId||t.uniqueId("pgC_"),this.$el.removeClass(a.hiddenClassName),d.visible||this.$el.addClass(a.hiddenClassName),a.requiredInputClassName&&this.$el.removeClass(a.requiredInputClassName),d.required&&this.$el.addClass(a.requiredInputClassName),d.options=t.defaults({disabled:d.disabled||d.readonly},this.field.get("options"),this.defaults.options,i.fn.bootstrapToggle.defaults),this.$el.html(this.template(d)).addClass(e.name),t.isNull(e.extraToggleClasses)||this.$el.addClass(e.extraToggleClasses),this.$input=this.$el.find("input[type=checkbox]").first(),this.$input.bootstrapToggle(),this.$el.find(".toggle.btn").attr("tabindex",d.disabled?"-1":"0").attr("id",d.cId),this.$el.find(".toggle.btn .toggle-group .btn").attr("aria-hidden",!0),this.setSrValue(),this.updateInvalid(),d.readonly&&this.$el.find(".select2-selection").attr("tabindex",0),this}}),a.Dialog=a.Form.extend({schema:void 0,tagName:"div",legend:!0,className:function(){return"pg-el-sm-12 pg-el-md-12 pg-el-lg-12 pg-el-12"},tabPanelClassName:function(){return a.tabClassName},tabIndex:0,initialize:function(e){var i=e.schema;i&&t.isArray(i)&&(this.schema=t.each(i,(function(i){!i.fields||i.fields instanceof n.Collection||(i.fields=new a.Fields(i.fields)),i.cId=i.cId||t.uniqueId("pgC_"),i.hId=i.hId||t.uniqueId("pgH_"),i.disabled=i.disabled||!1,i.legend=e.legend})),e.tabPanelClassName&&t.isFunction(e.tabPanelClassName)&&(this.tabPanelClassName=e.tabPanelClassName)),this.model.errorModel=e.errorModel||this.model.errorModel||new n.Model,this.controls=[]},template:{header:t.template(['<li class="nav-item" <%=disabled ? "disabled" : ""%>>',' <a class="nav-link" data-toggle="tab" role="tab" tabindex="-1" data-tab-index="<%=tabIndex%>" href="#<%=cId%>"','  id="<%=hId%>" aria-controls="<%=cId%>">',"<%=label%></a></li>"].join(" ")),panel:t.template('<div role="tabpanel" tabindex="-1" class="tab-pane <%=label%> <%=tabPanelCodeClass%> pg-el-sm-12 pg-el-md-12 pg-el-lg-12 pg-el-12 fade" id="<%=cId%>" aria-labelledby="<%=hId%>"></div>')},render:function(){this.cleanup();var e=this.$el.children().first().children(".active").first().attr("id"),n=this.model,a=this.controls,s=this.template,l=this,o=100*this.tabIndex;this.$el.empty().attr("role","tabpanel").attr("class",t.result(this,"tabPanelClassName")),n.panelEl=this.$el;var r=i('<ul class="nav nav-tabs" role="tablist"></ul>').appendTo(this.$el),d=i('<div class="tab-content pg-el-sm-12 pg-el-md-12 pg-el-lg-12 pg-el-12"></div>').appendTo(this.$el);t.each(this.schema,(function(e){if(o++,e.version_compatible&&function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e}(e.visible,e,n)){var c=i(s.panel(t.extend(e,{tabIndex:o,tabPanelCodeClass:e.tabPanelCodeClass?e.tabPanelCodeClass:""}))).appendTo(d).removeClass("collapse").addClass("collapse");i(s.header(e)).appendTo(r),e.fields.each((function(e){var t=new(e.get("control"))({field:e,model:n,dialog:l,tabIndex:o});c.append(t.render().$el),a.push(t)})),r.find('a[data-toggle="tab"]').off("shown.bs.tab").off("hidden.bs.tab").on("hidden.bs.tab",(function(){l.hidden_tab=i(this).data("tabIndex")})).on("shown.bs.tab",(function(){this.shown_tab=i(this).data("tabIndex"),n.trigger("pg-property-tab-changed",{model:n,shown:this.shown_tab,hidden:this.hidden_tab,tab:this})}))}}));var c=r.find('[id="'+e+'"]').first();return 1==c.length?(c.addClass("active show"),d.find("#"+c.attr("aria-controls")).addClass("active show")):(r.find(".nav-link").first().addClass("active show"),d.find(".tab-pane").first().addClass("active show")),this},remove:function(e){e&&e.data&&(this.model&&(this.model.reset&&this.model.reset({validate:!1,silent:!0,stop:!0}),this.model.clear({validate:!1,silent:!0,stop:!0}),delete this.model),this.errorModel&&(this.errorModel.clear({validate:!1,silent:!0,stop:!0}),delete this.errorModel)),this.cleanup(),a.Form.prototype.remove.apply(this,arguments)}}),a.Accordian=a.Dialog.extend({className:function(){return"set-group pg-el-12"},tabPanelClassName:function(){return a.tabClassName},legendClass:"badge",contentClass:a.accordianContentClassName+" collapse show",template:{header:t.template(['<div class="<%=Backform.accordianGroupClassName%>" <%=disabled ? "disabled" : ""%>>'," <% if (legend != false) { %>",'  <div class="<%=legendClass%>" <%=collapse ? "data-toggle=\'collapse\'" : ""%> data-target="#<%=cId%>" aria-controls="<%=cId%>" aria-level="3" role="heading"><%=collapse ? "<span class=\'caret\'></span>" : "" %><%=label%></legend>'," <% } %>","</div>"].join("\n")),content:t.template('  <div id="<%= cId %>" class="<%=contentClass%>"></div>')},collapse:!0,render:function(){this.cleanup();var e=this.model,n=this.$el,a=this.template,s=this.controls,l={className:t.result(this,"className"),legendClass:t.result(this,"legendClass"),contentClass:t.result(this,"contentClass"),collapse:t.result(this,"collapse")},o=100*this.tabIndex;return this.$el.empty(),t.each(this.schema,(function(r){if(o++,r.version_compatible&&function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e}(r.visible,r,e)&&r.fields){var d=t.extend({},l,r),c=i(a.header(d)).appendTo(n),u=i(a.content(d)).appendTo(c);r.fields.each((function(t){var i=new(t.get("control"))({field:t,model:e,tabIndex:o});u.append(i.render().$el),s.push(i)}))}})),this},getValueFromDOM:function(){return""},events:{}}),a.Fieldset=a.Dialog.extend({className:function(){return"set-group pg-el-12"},tabPanelClassName:function(){return a.tabClassName},fieldsetClass:a.setGroupClassName,legendClass:"badge",contentClass:a.setGroupContentClassName+" collapse show",template:{header:t.template(['<fieldset class="<%=fieldsetClass%>" <%=disabled ? "disabled" : ""%>>'," <% if (legend != false) { %>",'  <legend class="<%=legendClass%>" <%=collapse ? "data-toggle=\'collapse\'" : ""%> data-target="#<%=cId%>"><%=collapse ? "<span class=\'caret\'></span>" : "" %><%=label%></legend>'," <% } %>","</fieldset>"].join("\n")),content:t.template('  <div id="<%= cId %>" class="<%=contentClass%>"></div>')},collapse:!0,render:function(){this.cleanup();var e=this.model,n=this.$el,a=this.template,s=this.controls,l={className:t.result(this,"className"),fieldsetClass:t.result(this,"fieldsetClass"),legendClass:t.result(this,"legendClass"),contentClass:t.result(this,"contentClass"),collapse:t.result(this,"collapse")},o=100*this.tabIndex;return this.$el.empty(),t.each(this.schema,(function(r){if(o++,r.version_compatible&&function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e}(r.visible,r,e)&&r.fields){var d=t.extend({},l,r),c=i(a.header(d)).appendTo(n),u=i(a.content(d)).appendTo(c);r.fields.each((function(t){var i=new(t.get("control"))({field:t,model:e,tabIndex:o});u.append(i.render().$el),s.push(i)}))}})),this},getValueFromDOM:function(){return""},events:{}}),a.generateGridColumnsFromModel=function(e,i,n,l,o){var r,d=a.generateViewSchema(e,i,n,o,!0,!0),c=[],u=[],p=0;if(t.isNull(l)||t.isUndefined(l))r=function(e){e.cell_priority=p,p+=1,!e.headerCell&&e.cellHeaderClasses&&(e.headerCell=s.Extension.CustomHeaderCell)};else if(t.isArray(l))r=function(e){e.cell_priority=t.indexOf(l,e.name),!e.headerCell&&e.cellHeaderClasses&&(e.headerCell=s.Extension.CustomHeaderCell)};else if(t.isObject(l)){var h=Object.keys(l);r=function(e){var i,n=e.name in l&&l[e.name];t.isNull(n)||t.isUndefined(n)?e.cell_priority=-1:(t.isObject(n)&&("index"in n?(e.cell_priority=n.index,p=p>n.index?p+1:n.index):(i=t.indexOf(h,e.name),e.cell_priority=p=i>p?i:p,p+=1),e.headerCell||(e.cellHeaderClasses&&(e.headerCell=s.Extension.CustomHeaderCell),"class"in n&&t.isString(n.class)&&(e.headerCell=s.Extension.CustomHeaderCell,e.cellHeaderClasses=(e.cellHeaderClasses||"")+" "+n.class))),t.isString(n)&&(i=t.indexOf(h,e.name),e.cell_priority=p=i>p?i:p,p+=1,e.headerCell||(e.headerCell=s.Extension.CustomHeaderCell),e.cellHeaderClasses=(e.cellHeaderClasses||"")+" "+n))}}return t.each(d,(function(e){t.each(e.fields,(function(e){e.cell&&(r(e),-1!=e.cell_priority&&u.push(e))})),c.push(e)})),{columns:t.sortBy(u,(function(e){return e.cell_priority})),schema:c}},a.UniqueColCollectionControl=a.Control.extend({initialize:function(){a.Control.prototype.initialize.apply(this,arguments);var e=this.field.get("uniqueCol")||[],i=this.field.get("model"),n=i.prototype.schema||i.__super__.schema,s=[],l=this;if(t.each(n,(function(e){s.push(e.id)})),e.length>t.intersection(s,e).length){var o="Developer: Unique columns [ "+t.difference(e,s)+" ] not found in collection model [ "+s+" ].";alert(o)}var r=l.collection=l.model.get(l.field.get("name"));r||(r=l.collection=new p.Browser.Node.Collection(null,{model:l.field.get("model"),silent:!0,handler:l.model,top:l.model.top||l.model,attrName:l.field.get("name")}),l.model.set(l.field.get("name"),r,{silent:!0})),this.field.get("version_compatible")&&(l.listenTo(r,"add",l.collectionChanged),l.listenTo(r,"change",l.collectionChanged))},cleanup:function(){this.stopListening(this.collection,"change",this.collectionChanged),this.field.get("version_compatible")&&(this.stopListening(self.collection,"add",this.collectionChanged),this.stopListening(self.collection,"change",this.collectionChanged)),this.grid&&(this.grid.remove(),delete this.grid),this.$el.empty()},collectionChanged:function(e,n,a){var s=this.field.get("uniqueCol")||[],l=[];if(e.attributes&&(t.each(s,(function(i){t.has(e.attributes,i)&&l.push(i)})),0!=l.length)){var o=this.model.get(this.field.get("name"));this.stopListening(o,"change",this.collectionChanged);var r=void 0,d=void 0;if(o.each((function(i){if(e!=i){var n=[];t.each(s,(function(a){var s=e.get(a);t.isUndefined(s)||s!=i.get(a)||n.push(s)})),n.length==s.length&&(r=e,d=i)}})),r&&(a&&a.add?setTimeout((function(){o.remove(r)}),0):r.set(l[0],r.previous(l[0])),d)){var c=o.indexOf(d);if(c>-1){var u=this.grid.body.rows[c].$el;u.addClass("new"),i(u).pgMakeVisible("backform-tab"),setTimeout((function(){u.removeClass("new")}),3e3)}}this.listenTo(o,"change",this.collectionChanged)}},render:function(){this.undelegateEvents(),this.$el.empty();var e=t.defaults(this.field.toJSON(),this.defaults),i=this.model.toJSON(),n=e.name.split("."),a=n.shift(),s=n.join("."),l=this.keyPathAccessor(i[a],s),o=t.extend(e,{rawValue:l,value:this.formatter.fromRaw(l,this.model),attributes:i,formatter:this.formatter}),r=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};if(t.extend(o,{disabled:e.version_compatible&&r.apply(this.field,[o.disabled,o,this.model]),visible:r.apply(this.field,[o.visible,o,this.model]),required:r.apply(this.field,[o.required,o,this.model]),canAdd:e.version_compatible&&r.apply(this.field,[o.canAdd,o,this.model]),canAddRow:o.canAddRow,canDelete:r.apply(this.field,[o.canDelete,o,this.model]),canEdit:r.apply(this.field,[o.canEdit,o,this.model])}),t.extend(o,{add_label:""}),!o.visible)return this;this.control_data=t.clone(o);var d=this.showGridControl(o);return this.$el.html(d).addClass(e.name),this.updateInvalid(),this.delegateEvents(),this},showGridControl:function(n){n.cId=n.cId||t.uniqueId("pgC_");var l=this,o=t.template(['<div class="subnode-header">','  <span  class="control-label pg-el-sm-10" id="<%=cId%>"><%-label%></span>','  <button aria-label="'+e("Add new row")+'" class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> title="'+e("Add new row")+'"><%-add_label%></button>',"</div>"].join("\n")),c=i('<div class="pgadmin-control-group backgrid form-group pg-el-12 object subnode "></div>').append(o(n));if(l.grid&&l.grid.remove(),!n.subnode)return"";var u=n.subnode.schema?n.subnode:n.subnode.prototype,p=a.generateGridColumnsFromModel(n.node_info,u,this.field.get("mode"),n.columns);if("properties"==n.mode&&i(c).find("button.add").remove(),!n.disabled&&n.canDelete&&p.columns.unshift({name:"pg-backform-delete",label:"",cell:s.Extension.DeleteCell,editable:!1,cell_priority:-1,canDeleteRow:n.canDeleteRow}),0==n.disabled&&n.canEdit){var f=s.Extension.ObjectCell.extend({schema:p.schema});p.columns.unshift({name:"pg-backform-edit",label:"",cell:f,cell_priority:-2,canEditRow:n.canEditRow})}var m=this.model.get(n.name);m.on("enteringEditMode",(function(e){var t=this,i=e[0];this.each((function(e){if(i.model!=e){var n=t.indexOf(e);if(n>-1){var a=l.grid.body.rows[n].$el.find(".subnode-edit-in-process").parent();if(a.length>0){var s=new Event("click");a[0].dispatchEvent(s)}}}}))}),m),l.grid=new s.Grid({columns:p.columns,collection:m,className:"backgrid table presentation table-bordered table-noouter-border table-hover",attr:{"aria-labelledby":n.cId}});var g=l.grid.render().$el;n.canDelete&&n.canEdit&&(i(g).find("th.pg-backform-delete").remove(),i(g).find("th.pg-backform-edit").attr("colspan","2"));var v=c.append(g),b=h;0==h.preferences_cache.length&&(b=d.default.pgAdmin.Browser);var y=b.get_preferences_for_module("browser");if(y){var C=v.find(".add");i(C).attr("title",r.shortcut_title(e("Add new row"),y.add_grid_row))}return n.disabled||0==n.canAdd||v.find("button.add").first().on("click",(function(e){if(e.preventDefault(),!t.isFunction(n.canAddRow)||n.canAddRow.apply(l,[l.model])){if(t.each(l.grid.body.rows,(function(e){var t=e.$el.find(".subnode-edit-in-process").parent();if(t.length>0){var i=new Event("click");t[0].dispatchEvent(i)}})),!!!l.field.get("allowMultipleEmptyRows")&&m){var a=!1;if(m.each((function(e){var i=[];t.each(e.attributes,(function(e){i.push(e)})),t.some(i,t.identity)||(a=!0)})),a)return!1}i(l.grid.body.$el.find(i("tr.new"))).removeClass("new");var s=new n.model(null,{silent:!0,handler:m,top:l.model.top||l.model,collection:m,node_info:l.model.node_info});m.add(s);var o=m.indexOf(s),r=l.grid.body.rows[o].$el;return r.addClass("new"),i(r).pgMakeBackgridVisible(".backform-tab")||i(r).pgMakeBackgridVisible(".set-group"),!1}})),v},clearInvalid:function(){return this.$el.removeClass("subnode-error"),this.$el.find(".pgadmin-control-error-message").remove(),this},updateInvalid:function(){var e=this,a=this.model.errorModel;if(!(a instanceof n.Model))return this;this.clearInvalid(),this.$el.find(".subnode-body").each((function(){var n=e.keyPathAccessor(a.toJSON(),e.field.get("name"));t.isEmpty(n)||e.$el.addClass("subnode-error").append(i("<div></div>").addClass("pgadmin-control-error-message pg-el-offset-4 pg-el-8 help-block").text(n))}))}}),a.SubNodeCollectionControl=a.Control.extend({row:s.Row,render:function(){var e=t.defaults(this.field.toJSON(),this.defaults),i=this.model.toJSON(),n=e.name.split("."),s=n.shift(),l=n.join("."),o=this.keyPathAccessor(i[s],l),r=t.extend(e,{rawValue:o,value:this.formatter.fromRaw(o,this.model),attributes:i,formatter:this.formatter}),d=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};t.extend(r,{disabled:d(r.disabled,r,this.model),visible:d(r.visible,r,this.model),required:d(r.required,r,this.model),canAdd:d(r.canAdd,r,this.model),canAddRow:r.canAddRow,canEdit:d(r.canEdit,r,this.model),canDelete:d(r.canDelete,r,this.model),showError:r.showError||!0});var c=null==r.subnode?"":this.showGridControl(r);return this.$el.removeClass(a.hiddenClassName),r.visible||this.$el.addClass(a.hiddenClassName),this.$el.html(c).addClass(e.name),this.updateInvalid(),this},updateInvalid:function(){var e=this.model.errorModel;if(!(e instanceof n.Model))return this;this.clearInvalid();var a=this.field.get("name").split(".").join("."),s=this.keyPathAccessor(e.toJSON(),a);t.isEmpty(s)||this.field.get("showError")&&this.$el.addClass("subnode-error").append(i("<div></div>").addClass("pgadmin-control-error-message pg-el-offset-4 pg-el-8 help-block").text(s))},cleanup:function(){this.grid&&this.grid.remove(),this.collection&&this.collection.off("enteringEditMode")},clearInvalid:function(){return this.field.get("showError")&&(this.$el.removeClass("subnode-error"),this.$el.find(".pgadmin-control-error-message").remove()),this},showGridControl:function(n){var l=this,o=this,c=["<div class='subnode-header'>","  <span class='control-label pg-el-sm-10'>"+n.label+"</span>",'  <button aria-label="'+e("Add")+"\" class='btn btn-sm-sq btn-secondary add fa fa-plus' title='"+e("Add new row")+"'></button>","</div>"].join("\n"),u=i("<div class='pgadmin-control-group backgrid form-group pg-el-12 object subnode'></div>").append(c),p=n.subnode.schema?n.subnode:n.subnode.prototype,f=a.generateGridColumnsFromModel(n.node_info,p,this.field.get("mode"),n.columns,n.schema_node);if(o.grid&&o.grid.remove(),(n.disabled||0==n.canAdd)&&i(u).find("button.add").remove(),0==n.disabled&&n.canDelete&&f.columns.unshift({name:"pg-backform-delete",label:"",cell:s.Extension.DeleteCell,editable:!1,cell_priority:-1,canDeleteRow:n.canDeleteRow,customDeleteMsg:n.customDeleteMsg,customDeleteTitle:n.customDeleteTitle}),0==n.disabled&&n.canEdit){var m=s.Extension.ObjectCell.extend({schema:f.schema}),g=o.field.has("canEdit")&&o.field.get("canEdit")||!0;f.columns.unshift({name:"pg-backform-edit",label:"",cell:m,cell_priority:-2,editable:g,canEditRow:n.canEditRow})}var v=o.model.get(n.name);v||(v=new h.Node.Collection(null,{handler:o.model.handler||o.model,model:n.model,top:o.model.top||o.model,silent:!0}),o.model.set(n.name,v,{silent:!0}));v.on("enteringEditMode",(function(e){var t=this,i=e[0];this.each((function(e){if(i.model!=e){var n=t.indexOf(e);if(n>-1){var a=b.body.rows[n].$el.find(".subnode-edit-in-process").parent();if(a.length>0){var s=new Event("click");a[0].dispatchEvent(s)}}}}))}),v);var b=o.grid=new s.Grid({columns:f.columns,collection:v,row:this.row,className:"backgrid table presentation table-bordered table-noouter-border table-hover"}),y=b.render().$el;n.canDelete&&n.canEdit&&(i(y).find("th.pg-backform-delete").remove(),i(y).find("th.pg-backform-edit").attr("colspan","2"));var C=u.append(y),_=h;0==h.preferences_cache.length&&(_=d.default.pgAdmin.Browser);var w=_.get_preferences_for_module("browser");if(w){var x=C.find(".add");i(x).attr("title",r.shortcut_title(e("Add new row"),w.add_grid_row))}return C.find("button.add").on("click",(function(e){if(e.preventDefault(),!t.isFunction(n.canAddRow)||n.canAddRow.apply(o,[o.model])){t.each(b.body.rows,(function(e){var t=e.$el.find(".subnode-edit-in-process").parent();if(t.length>0){var i=new Event("click");t[0].dispatchEvent(i)}})),b.insertRow({});var a=i(b.body.rows[v.length-1].$el);return a.attr("class","new").on("click",(function(){i(l).attr("class","editable")})),i(a).pgMakeBackgridVisible(".backform-tab")||i(a).pgMakeBackgridVisible(".set-group"),!1}})),C}}),a.SqlTabControl=a.Control.extend({defaults:{label:"",controlsClassName:"pgadmin-controls pg-el-sm-12 SQL",extraClasses:[],helpMessage:null},template:t.template(['<label for="<%=cId%>" class="sr-only"><%=(label==""?"SQL":label)%></label>','<div class="<%=controlsClassName%>">','  <textarea id="<%=cId%>" class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>" name="<%=name%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%> <%=required ? "required" : ""%>><%-value%></textarea>',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),initialize:function(e){a.Control.prototype.initialize.apply(this,arguments),this.dialog=e.dialog,this.tabIndex=e.tabIndex,t.bindAll(this,"onTabChange","onPanelResized")},getValueFromDOM:function(){return this.formatter.toRaw(this.$el.find("textarea").val(),this.model)},reflectPreferences:function(){if(this.sqlCtrl){var e=p.Browser.get_preferences_for_module("sqleditor");i(this.sqlCtrl.getWrapperElement()).css("font-size",o.calcFontSize(e.sql_font_size)),this.sqlCtrl.setOption("tabSize",e.tab_size),this.sqlCtrl.setOption("lineWrapping",e.wrap_code),this.sqlCtrl.setOption("autoCloseBrackets",e.insert_pair_brackets),this.sqlCtrl.setOption("matchBrackets",e.brace_matching),this.sqlCtrl.refresh()}},render:function(){this.sqlCtrl&&(this.sqlCtrl.toTextArea(),delete this.sqlCtrl,this.sqlCtrl=null,this.$el.empty(),this.model.off("pg-property-tab-changed",this.onTabChange,this),this.model.off("pg-browser-resized",this.onPanelResized,this)),a.Control.prototype.render.apply(this,arguments),this.sqlCtrl=l.fromTextArea(this.$el.find("textarea")[0],{lineNumbers:!0,mode:"text/x-pgsql",readOnly:!0,extraKeys:p.Browser.editor_shortcut_keys}),this.reflectPreferences();var e=this;return this.$el.find("textarea").attr("tabindex",-1),h.onPreferencesChange("sqleditor",(function(){e.reflectPreferences()})),this.model.on("pg-property-tab-changed",this.onTabChange,this),this.model.on("pg-browser-resized",this.onPanelResized,this),this},onTabChange:function(n){if(this.dialog&&n.shown==this.tabIndex){if(this.model.sessChanged())if(0==t.size(this.model.errorModel.attributes)){var a=this,s=a.field.get("schema_node"),l=s.generate_url.apply(s,[null,"msql",this.field.get("node_data"),!a.model.isNew(),this.field.get("node_info"),s.url_jump_after_node]);a.model.trigger("pgadmin-view:msql:fetching",a.method,s),i.ajax({url:l,type:"GET",cache:!1,data:a.model.toJSON(!0,"GET"),dataType:"json",contentType:"application/json"}).done((function(e){a.sqlCtrl.clearHistory(),a.sqlCtrl.setValue(e.data)})).fail((function(){a.model.trigger("pgadmin-view:msql:error",a.method,s,arguments)})).always((function(){a.model.trigger("pgadmin-view:msql:fetched",a.method,s,arguments)}))}else this.sqlCtrl.clearHistory(),this.sqlCtrl.setValue("-- "+e("Definition incomplete."));else this.sqlCtrl.clearHistory(),this.sqlCtrl.setValue("-- "+e("No updates."));this.sqlCtrl.refresh.apply(this.sqlCtrl)}},onPanelResized:function(e){if(e&&e.container){var t=e.container.find(".backform-tab > .tab-content").first(),i=t.find("div[role=tabpanel].tab-pane.SQL");i.hasClass("active")&&i.find(".CodeMirror").css("cssText","height: "+(t.height()+8)+"px !important;")}},remove:function(){this.sqlCtrl&&(this.sqlCtrl.toTextArea(),delete this.sqlCtrl,this.sqlCtrl=null,this.$el.empty()),this.model.off("pg-property-tab-changed",this.onTabChange,this),this.model.off("pg-browser-resized",this.onPanelResized,this),a.Control.__super__.remove.apply(this,arguments)}}),a.NumericControl=a.InputControl.extend({defaults:{type:"number",label:"",min:void 0,max:void 0,maxlength:255,extraClasses:[],helpMessage:null},template:t.template(['<label for="<%=cId%>" class="<%=Backform.controlLabelClassName%>"><%=label%></label>','<div class="<%=Backform.controlsClassName%>">','  <input type="<%=type%>" id="<%=cId%>" class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>" name="<%=name%>" min="<%=min%>" max="<%=max%>"maxlength="<%=maxlength%>" value="<%-value%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%> <%=required ? "required" : ""%> />',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n"))}),a.generateViewSchema=function(i,n,s,l,o,r,d){var c=n&&n.prototype||n,u=d||c&&c.schema,f=[],m={};if(u&&t.isArray(u)){var g,v=v=function(e){return e&&c[e]&&"function"==typeof c[e]?c[e]:e},b={},y=i&&"server"in i&&h.serverInfo&&h.serverInfo[i.server._id],C=i&&"catalog"in i;if(t.each(u,(function(r){if("group"==r.type){var d=!0;return g=!!t.isUndefined(y)||(!!t.isUndefined(r.server_type)||y.type in r.server_type)&&(!!t.isUndefined(r.min_version)||y.version>=r.min_version)&&(!!t.isUndefined(r.max_version)||y.version<=r.max_version),r.mode&&t.isObject(r.mode)&&(d=t.indexOf(r.mode,s)>-1),d&&(d=v(r.visible)),void(m[r.id]={label:r.label||r.id,version_compatible:g,visible:d,tabPanelCodeClass:""})}if(!r.mode||r&&r.mode&&t.isObject(r.mode)&&-1!=t.indexOf(r.mode,s)){var c=r.group||e("General"),u=r.control||a.getMappedControl(r.type,s),f=r.cell||a.getMappedControl(r.type,"cell");if(null==u)return;b[c]=b[c]||[];var _=!(g=!!t.isUndefined(y)||(!!t.isUndefined(r.server_type)||y.type in r.server_type)&&(!!t.isUndefined(r.min_version)||y.version>=r.min_version)&&(!!t.isUndefined(r.max_version)||y.version<=r.max_version))||C,w="properties"==s,x=r.node&&t.isString(r.node)&&r.node in h.Nodes&&h.Nodes[r.node]||l,k=t.extend(t.clone(r),{name:r.id,disabled:!!_||v(r.disabled),readonly:!!w||v(r.readonly),editable:t.isUndefined(r.editable)?p.editableCell:v(r.editable),subnode:t.isString(r.model)&&r.model in h.Nodes?h.Nodes[r.model].model:r.model,canAdd:!_&&!w&&v(r.canAdd),canAddRow:!_&&!w&&v(r.canAddRow),canEdit:!_&&!w&&v(r.canEdit),canDelete:!_&&!w&&v(r.canDelete),canEditRow:!_&&!w&&v(r.canEditRow),canDeleteRow:!_&&!w&&v(r.canDeleteRow),transform:v(r.transform),mode:s,control:u,cell:f,node_info:i,schema_node:x,visible:v(r.visible),node:l,node_data:o,version_compatible:g});delete k.id,b[c].push(k),"nested"==r.type&&(delete k.name,delete k.cell,k.schema=a.generateViewSchema(i,n,s,l,o,!0,r.schema),k.control=k.control||"tab")}})),t.isEmpty(b))return null;r||!l||!l.hasSQL||"create"!=s&&"edit"!=s||(b[e("SQL")]=[{name:"sql",visible:!0,disabled:!1,type:"text",control:"sql-tab",node_info:i,schema_node:l,node_data:o}]),t.each(b,(function(e,i){var n=t.pluck(e,"tabPanelCodeClass");n&&(n=n.join(" ").trim()),f.push(t.extend(t.defaults(m[i]||{label:i,tabPanelCodeClass:n},{version_compatible:!0,visible:!0}),{fields:e}))}))}return f};var v=function(){};t.extend(v.prototype,{fromRaw:function(e){return encodeURIComponent(e)},toRaw:function(e,i,n){return t.isArray(e)?n&&n.tags?e:t.map(e,decodeURIComponent):t.isNull(e)||t.isUndefined(e)?null:decodeURIComponent(e)}}),a.Select2Control=a.SelectControl.extend({defaults:t.extend({},a.SelectControl.prototype.defaults,{select2:{first_empty:!0,multiple:!1,emptyOptions:!1,preserveSelectionOrder:!1,isDropdownParent:!1},controlLabelClassName:a.controlLabelClassName,controlsClassName:a.controlsClassName}),events:function(){return t.extend({},a.SelectControl.prototype.events,{"select2:select":"onSelect"})},onSelect:function(e){var n=this.field.get("select2");if(!t.isUndefined(n)&&!t.isNull(n)&&n.multiple&&n.preserveSelectionOrder){var a=e.params.data.element,s=i(a);s.detach(),i(this.$sel).append(s),i(this.$sel).trigger("change")}var l=t.findWhere(this.field.get("options"),{value:e.params.data.id});l&&!t.isUndefined(l.preview_src)&&l.preview_src&&this.$el.find(".preview-img img").attr("src",l.preview_src)},formatter:v,template:t.template(["<% if(label == false) {} else {%>",'  <label class="<%=controlLabelClassName%>" for="<%=cId%>"><%=label%></label>',"<% }%>",'<div class="<%=controlsClassName%>">',' <select title="<%=name%>" id="<%=cId%>" class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>"','  name="<%=name%>" value="<%-value%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "disabled" : ""%>','  <%=required ? "required" : ""%><%= select2.multiple ? " multiple>" : ">" %>','  <%=select2.first_empty ? " <option></option>" : ""%>',"  <% for (var i=0; i < options.length; i++) {%>","   <% var option = options[i]; %>","   <option ","    <% if (option.image) { %> data-image=<%=option.image%> <%}%>","    value=<%- formatter.fromRaw(option.value) %>",'    <% if (option.selected) {%>selected="selected"<%} else {%>','    <% if (!select2.multiple && option.value === rawValue) {%>selected="selected"<%}%>','    <% if (select2.multiple && rawValue && rawValue.indexOf(option.value) != -1){%>selected="selected" data-index="rawValue.indexOf(option.value)"<%}%>',"    <%}%>",'    <%= disabled ? "disabled" : ""%> <%=readonly ? "disabled" : ""%>><%-option.label%></option>',"  <%}%>"," </select>"," <% if (helpMessage && helpMessage.length) { %>",' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>'," <% } %>"," <% for (var i=0; i < options.length; i++) {%>","   <% var option = options[i]; %>","     <% if (option.preview_src && option.value === rawValue) { %>",'       <div class="preview-img mt-2">','         <img src="<%=option.preview_src%>" class="img-fluid mx-auto d-block w-50 border" alt="'+e("Preview not available...")+'">',"       </div>","    <%}%>"," <%}%>","</div>"].join("\n")),render:function(){var e=this;this.$sel&&this.$sel.select2&&this.$sel.select2.hasOwnProperty("destroy")&&this.$sel.select2("destroy");var n=t.defaults(this.field.toJSON(),this.defaults),s=this.model.toJSON(),l=n.name.split("."),o=l.shift(),r=l.join("."),d=this.keyPathAccessor(s[o],r),u=t.extend(n,{rawValue:d,value:this.formatter.fromRaw(d,this.model),attributes:s,formatter:this.formatter}),p=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};if(u.select2=u.select2||{},t.defaults(u.select2,this.defaults.select2,{first_empty:!0,multiple:!1,emptyOptions:!1,preserveSelectionOrder:!1,isDropdownParent:!1,showOnScroll:!0}),t.extend(u,{disabled:p(u.disabled,u,this.model),readonly:p(u.readonly,u,this.model),visible:p(u.visible,u,this.model),required:p(u.required,u,this.model)}),t.isFunction(u.options))try{u.options=u.options(this)}catch(e){u.options=[],this.model.trigger("pgadmin-view:transform:error",this.model,this.field,e)}u.cId=u.cId||t.uniqueId("pgC_"),this.$el.removeClass(a.hiddenClassName),u.visible||this.$el.addClass(a.hiddenClassName),this.$el.html(this.template(u)).addClass(n.name);var h=t.extend({disabled:u.disabled||u.readonly},n.select2,{options:this.field.get("options")||this.defaults.options});return u.select2.isDropdownParent&&(h.dropdownParent=u.select2.dropdownParent||this.$el),(u.disabled||u.readonly)&&(h.placeholder=""),u.select2.tags&&u.select2.emptyOptions&&(h.data=u.rawValue),h=c.default(h),this.$sel=this.$el.find("select").select2(h),u.select2.tags&&u.select2.emptyOptions&&(this.$sel.val(u.rawValue),this.$sel.trigger("change.select2"),this.$sel.on("select2:unselect",(function(e){i(this).find('option[value="'+e.params.data.text.replace("'","\\'").replace('"','\\"')+'"]').remove(),i(this).trigger("change.select2"),null==i(this).val()&&i(this).empty()}))),this.$sel&&this.$sel.data("select2").on("keypress",(function(e){9===e.which&&this.isOpen()&&(e.preventDefault(),this.trigger("results:select",{}))})),u.readonly&&!u.disabled&&setTimeout((function(){e.$el.find(".select2-selection").attr("tabindex",0)}),500),this.updateInvalid(),this},getValueFromDOM:function(){var e=t.extend({},this.field.get("select2")||this.defaults.select2),i=this.formatter.toRaw(this.$sel.val(),this.model,e);return e.multiple&&null==i?[]:i}}),a.FieldsetControl=a.Fieldset.extend({initialize:function(e){a.Control.prototype.initialize.apply(this,arguments),a.Dialog.prototype.initialize.apply(this,[{schema:e.field.get("schema")}]),this.dialog=e.dialog,this.tabIndex=e.tabIndex,this.contentClass=e.field.get("contentClass")?e.field.get("contentClass"):"";var i=this.field.get("deps"),n=this;i&&t.isArray(i)&&t.each(i,(function(e){var t=e.split(".").shift();n.listenTo(n.model,"change:"+t,n.render)}))},orig_render:a.Fieldset.prototype.render,render:function(){var e=t.defaults(this.field.toJSON(),this.defaults),i=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};return e.version_compatible&&i(e.visible,e,this.model)?this.orig_render.apply(this,arguments):(this.cleanup(),this.$el.empty()),this},formatter:function(){},cleanup:function(){a.Fieldset.prototype.cleanup.apply(this)},remove:function(){a.Control.prototype.remove.apply(this,arguments),a.Dialog.prototype.remove.apply(this,arguments)},className:function(){return"set-group"},tabPanelClassName:function(){return a.tabClassName},fieldsetClass:"inline-fieldset",legendClass:"",collapse:!1}),a.TabControl=a.FieldsetControl.extend({tagName:"div",className:"inline-tab-panel",tabPanelClassName:"inline-tab-panel",tabPanelExtraClasses:"",initialize:function(e){a.FieldsetControl.prototype.initialize.apply(this,arguments),this.tabIndex=(e.tabIndex||parseInt(1e3*Math.random()))+1,e.field.get("tabPanelExtraClasses")&&(this.tabPanelExtraClasses=e.field.get("tabPanelExtraClasses")),this.tabPanelClassName=this.tabPanelClassName+" "+this.tabPanelExtraClasses},orig_render:a.Dialog.prototype.render,template:a.Dialog.prototype.template}),a.PlainFieldsetControl=a.FieldsetControl.extend({initialize:function(){a.FieldsetControl.prototype.initialize.apply(this,arguments)},template:{header:t.template(['<fieldset class="<%=fieldsetClass%>" <%=disabled ? "disabled" : ""%>>'," <% if (legend != false) { %>",'  <div><legend class="<%=legendClass%>" <%=collapse ? "data-toggle=\'collapse\'" : ""%> data-target="#<%=cId%>"><%=collapse ? "<span class=\'caret\'></span>" : "" %></legend></div>'," <% } %>","</fieldset>"].join("\n")),content:t.template('  <div id="<%= cId %>" class="<%=contentClass%>"></div>')},fieldsetClass:"inline-fieldset-without-border",legend:!1}),a.SqlFieldControl=a.TextareaControl.extend({defaults:{label:"",extraClasses:[],helpMessage:null,maxlength:4096,rows:void 0},template:t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>',"<div class=\"<%=Backform.controlsClassName%> sql_field_layout <%=extraClasses.join(' ')%>\">",'  <textarea id="<%=cId%>"','    class="<%=Backform.controlClassName%> " name="<%=name%>"','    maxlength="<%=maxlength%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%>',"    rows=<%=rows%>",'    <%=required ? "required" : ""%>><%-value%></textarea>',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),initialize:function(){a.TextareaControl.prototype.initialize.apply(this,arguments),this.sqlCtrl=null,t.bindAll(this,"onFocus","onBlur","refreshTextArea")},getValueFromDOM:function(){return this.sqlCtrl.getValue()},reflectPreferences:function(){var e=this;if(e.sqlCtrl){var t=d.default.pgAdmin.Browser.get_preferences_for_module("sqleditor");i(e.sqlCtrl.getWrapperElement()).css("font-size",o.calcFontSize(t.sql_font_size)),e.sqlCtrl.setOption("indentWithTabs",!t.use_spaces),e.sqlCtrl.setOption("indentUnit",t.tab_size),e.sqlCtrl.setOption("tabSize",t.tab_size),e.sqlCtrl.setOption("lineWrapping",t.wrap_code),e.sqlCtrl.setOption("autoCloseBrackets",t.insert_pair_brackets),e.sqlCtrl.setOption("matchBrackets",t.brace_matching),setTimeout((function(){e.sqlCtrl&&e.sqlCtrl.refresh()}),500)}},render:function(){this.sqlCtrl&&(this.model.off("pg-property-tab-changed",this.refreshTextArea,this),this.sqlCtrl.off("focus",this.onFocus),this.sqlCtrl.off("blur",this.onBlur),this.sqlCtrl.toTextArea(),delete this.sqlCtrl,this.sqlCtrl=null,this.$el.empty()),a.TextareaControl.prototype.render.apply(this,arguments);var e=t.defaults(this.field.toJSON(),this.defaults),i=this.model.toJSON(),n=e.name.split("."),s=n.shift(),o=n.join("."),r=this.keyPathAccessor(i[s],o),d=t.extend(e,{rawValue:r,value:this.formatter.fromRaw(r,this.model),attributes:i,formatter:this.formatter}),c=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};d.cId=d.cId||t.uniqueId("pgC_");var u=c(d.disabled,d,this.model),f=c(d.visible,d,this.model),m=c(d.readonly,d,this.model),g=this;if(g.sqlCtrl=l.fromTextArea(g.$el.find("textarea")[0],{lineNumbers:!0,mode:"text/x-pgsql",extraKeys:p.Browser.editor_shortcut_keys}),g.reflectPreferences(),h.onPreferencesChange("sqleditor",(function(){g.reflectPreferences()})),u||m){g.sqlCtrl.setOption("readOnly",!0),g.sqlCtrl.setOption("extraKeys",{Tab:!1,"Shift-Tab":!1});var v=g.sqlCtrl.getWrapperElement();v&&(v.className+=" cm_disabled hide-cursor-workaround")}return f||g.$el.addClass(a.hiddenClassName),g.model.on("pg-property-tab-changed",this.refreshTextArea,this),this.sqlCtrl.on("focus",this.onFocus),this.sqlCtrl.on("blur",this.onBlur),setTimeout((function(){g.refreshTextArea.apply(g)}),0),g},onFocus:function(){var e=this.$el.find(".pgadmin-controls").first();e.hasClass("focused")||e.addClass("focused")},onBlur:function(){this.$el.find(".pgadmin-controls").first().removeClass("focused")},refreshTextArea:function(){this.sqlCtrl&&this.sqlCtrl.refresh()},remove:function(){this.sqlCtrl&&(this.sqlCtrl.off("focus",this.onFocus),this.sqlCtrl.off("blur",this.onBlur),delete this.sqlCtrl,this.sqlCtrl=null,this.$el.empty()),this.model.off("pg-property-tab-changed",this.refreshTextArea,this),a.TextareaControl.prototype.remove.apply(this,arguments)}}),a.SqlCodeControl=a.SqlFieldControl.extend({template:t.template(['<label class="sr-only" for="<%=cId%>"><%=(label==""?"Code":label)%></label>',"<div class=\"pgadmin-controls pg-el-12 <%=extraClasses.join(' ')%>\">",'  <textarea id="<%=cId%>" ','    class="<%=Backform.controlClassName%> " name="<%=name%>"','    maxlength="<%=maxlength%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%> ',"    rows=<%=rows%>",'    <%=required ? "required" : ""%>><%-value%></textarea>',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n"))}),a.NoteControl=a.Control.extend({defaults:{label:e("Note"),text:"",extraClasses:["pg-el-12","d-flex"],noteClass:"backform-note",faIcon:"fa-file-text-o",faExtraClass:"fa-rotate-180 fa-flip-vertical",iconWidthClass:"col-0 pr-2",textWidthClass:"col-sm"},template:t.template(["<div class=\"<%=noteClass%> <%=extraClasses.join(' ')%>\">",'  <div class="icon <%=iconWidthClass%>">','    <i class="fa <%=faIcon%> <%=faExtraClass%>" aria-hidden="true"></i>',"  </div>",'  <div class="<%=textWidthClass%>">',"    <span><%=text%></span>","  </div>","</div>"].join("\n"))}),a.FileControl=a.InputControl.extend({defaults:{type:"text",label:"",min:void 0,max:void 0,maxlength:255,extraClasses:[],dialog_title:"",btn_primary:"",helpMessage:null,dialog_type:"select_file"},initialize:function(){a.InputControl.prototype.initialize.apply(this,arguments)},template:t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>','<div class="<%=Backform.controlsClassName%>">','<div class="input-group">','<input type="<%=type%>" id="<%=cId%>" class="form-control <%=extraClasses.join(\' \')%>" name="<%=name%>" min="<%=min%>" max="<%=max%>"maxlength="<%=maxlength%>" value="<%-value%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%> <%=required ? "required" : ""%> />','<div class="input-group-append">','<button class="btn btn-secondary fa fa-ellipsis-h select_item" <%=disabled ? "disabled" : ""%> <%=readonly ? "disabled" : ""%> aria-hidden="true" aria-label="'+e("Select file")+'" title="'+e("Select file")+'"></button>',"</div>","</div>","<% if (helpMessage && helpMessage.length) { %>",'<span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"<% } %>","</div>"].join("\n")),events:function(){return t.extend({},a.InputControl.prototype.events,{"click .select_item":"onSelect"})},onSelect:function(){var e=this.field.get("dialog_type"),t=this.field.get("supp_types"),i=this.field.get("btn_primary"),n={supported_types:t,dialog_type:e,dialog_title:this.field.get("dialog_title"),btn_primary:i};p.FileManager.init(),p.FileManager.show_dialog(n),this.listen_file_dlg_events()},storage_dlg_hander:function(e){var t=this.field.get("name").split(".").shift();this.remove_file_dlg_event_listeners(),this.model.set(t,decodeURI(e)),this.$el.find("input[type=text]").focus()},storage_close_dlg_hander:function(){this.remove_file_dlg_event_listeners()},listen_file_dlg_events:function(){p.Browser.Events.on("pgadmin-storage:finish_btn:"+this.field.get("dialog_type"),this.storage_dlg_hander,this),p.Browser.Events.on("pgadmin-storage:cancel_btn:"+this.field.get("dialog_type"),this.storage_close_dlg_hander,this)},remove_file_dlg_event_listeners:function(){p.Browser.Events.off("pgadmin-storage:finish_btn:"+this.field.get("dialog_type"),this.storage_dlg_hander,this),p.Browser.Events.off("pgadmin-storage:cancel_btn:"+this.field.get("dialog_type"),this.storage_close_dlg_hander,this)},clearInvalid:function(){return a.InputControl.prototype.clearInvalid.apply(this,arguments),this.$el.removeClass("pgadmin-file-has-error"),this},updateInvalid:function(){a.InputControl.prototype.updateInvalid.apply(this,arguments),this.$el.addClass("pgadmin-file-has-error")},disable_button:function(){this.$el.find("button.select_item").attr("disabled","disabled")},enable_button:function(){this.$el.find("button.select_item").removeAttr("disabled")}}),a.DatetimepickerControl=a.InputControl.extend({defaults:{type:"text",label:"",options:{format:"YYYY-MM-DD HH:mm:ss Z",icons:{clear:"fa fa-trash"},buttons:{showToday:!0},toolbarPlacement:"top",widgetPositioning:{horizontal:"auto",vertical:"bottom"},keepOpen:!1},placeholder:"YYYY-MM-DD HH:mm:ss Z",extraClasses:[],helpMessage:null},events:{"blur input":"onChange","change input":"onChange","changeDate input":"onChange","focus input":"clearInvalid","focusout input":"closePicker","change.datetimepicker":"onChange","click .input-group":"togglePicker","keydown .datetimepicker-input":"keyboardEvent"},togglePicker:function(){this.has_datepicker&&this.$el.find("input").datetimepicker("toggle")},closePicker:function(){this.has_datepicker&&this.$el.find("input").datetimepicker("hide")},template:t.template(['<label for="<%=cId%>" class="<%=Backform.controlLabelClassName%>"><%=label%></label>','<div class="input-group  <%=Backform.controlsClassName%>">',' <input id="<%=cId%>" type="text" class="<%=Backform.controlClassName%> datetimepicker-input <%=extraClasses.join(\' \')%>" name="<%=name%>" value="<%-value%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=readonly ? "readonly aria-readonly=true" : ""%> <%=required ? "required" : ""%> data-toggle="datetimepicker"/>',' <div class="input-group-append">','   <span class="input-group-text fa fa-calendar"></span>'," </div>","</div>","<% if (helpMessage && helpMessage.length) { %>",'<div class="<%=Backform.helpBlockControlClass%>">',' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"</div>","<% } %>"].join("\n")),keyboardEvent:function(e){var t=!1;e.altKey||38!=e.keyCode||this.up(),e.altKey||40!=e.keyCode||this.down(),37==e.keyCode&&this.left(),39==e.keyCode&&this.right(),27==e.keyCode&&(this.$el.find("input").datetimepicker("hide"),t=!0),13==e.keyCode&&(this.$el.find(".datepicker").is(":visible")||this.$el.find(".timepicker").is(":visible")?this.$el.find("input").datetimepicker("hide"):this.$el.find("input").datetimepicker("show")),e.altKey&&84==e.keyCode&&this.timePicker(),e.altKey&&38==e.keyCode&&this.controlUp(),e.altKey&&40==e.keyCode&&this.controlDown(),t&&e.stopImmediatePropagation()},down:function(){var e=this.$el.find(".datetimepicker-input"),t=e.data("datetimepicker").date().clone();this.$el.find(".datepicker").is(":visible")?e.datetimepicker("date",t.add(7,"d")):e.datetimepicker("date",t.subtract(1,"m"))},up:function(){var e=this.$el.find(".datetimepicker-input"),t=e.data("datetimepicker").date().clone();this.$el.find(".datepicker").is(":visible")?e.datetimepicker("date",t.subtract(7,"d")):e.datetimepicker("date",t.add(1,"m"))},left:function(){var e=this.$el.find(".datetimepicker-input"),t=e.data("datetimepicker").date().clone();this.$el.find(".datepicker").is(":visible")&&e.datetimepicker("date",t.subtract(1,"d"))},right:function(){var e=this.$el.find(".datetimepicker-input"),t=e.data("datetimepicker").date().clone();this.$el.find(".datepicker").is(":visible")&&e.datetimepicker("date",t.add(1,"d"))},timePicker:function(){this.$el.find(".timepicker").is(":visible")?this.$el.find(".fa-calendar").click():this.$el.find(".fa-clock-o").click()},controlUp:function(){this.$el.find(".fa-clock-o").click();var e=this.$el.find(".datetimepicker-input"),t=e.data("datetimepicker").date().clone();e.datetimepicker("date",t.add(1,"h"))},controlDown:function(){this.$el.find(".fa-clock-o").click();var e=this.$el.find(".datetimepicker-input"),t=e.data("datetimepicker").date().clone();e.datetimepicker("date",t.subtract(1,"h"))},render:function(){var e=t.defaults(this.field.toJSON(),this.defaults),i=this.model.toJSON(),n=e.name.split("."),s=n.shift(),l=n.join("."),o=this.keyPathAccessor(i[s],l),r=t.extend(e,{rawValue:o,value:this.formatter.fromRaw(o,this.model),attributes:i,formatter:this.formatter}),d=function(e,i){return t.isFunction(e)?!!e(i):!!e};if(t.extend(r,{disabled:d(r.disabled,this.model),readonly:d(r.readonly,this.model),visible:d(r.visible,this.model),required:d(r.required,this.model)}),r.cId=r.cId||t.uniqueId("pgC_"),r.disabled||"properties"==r.mode||(r.placeholder=r.placeholder||this.defaults.placeholder),this.has_datepicker&&this.$el.find("input").datetimepicker("destroy"),this.$el.empty(),this.$el.removeClass(a.hiddenClassName),this.$el.html(this.template(r)).addClass(e.name),r.visible){this.has_datepicker=!0;var c=this;t.isUndefined(r.value)||t.isNull(r.value)||"infinity"!==r.value.toLowerCase()||(r.value=null),this.$el.find("input").first().datetimepicker(t.extend({keyBinds:{enter:function(e){var t=this;e?setTimeout((function(){t.toggle(),c.$el.find("input").first().trigger("blur")}),10):setTimeout((function(){t.toggle()}),10)},tab:function(e){e||setTimeout((function(){c.$el.find("input").first().trigger("blur")}),10)},escape:function(e){if(e){var t=this;setTimeout((function(){t.toggle(),c.$el.find("input").first().trigger("blur")}),10)}}}},this.defaults.options,this.field.get("options"),{date:r.value,minDate:r.value}))}else this.has_datepicker=!1,this.$el.addClass(a.hiddenClassName);return this.updateInvalid(),this},clearInvalid:function(){return a.InputControl.prototype.clearInvalid.apply(this,arguments),this.$el.removeClass("pgadmin-datepicker-has-error"),this},updateInvalid:function(){a.InputControl.prototype.updateInvalid.apply(this,arguments),this.$el.addClass("pgadmin-datepicker-has-error")},cleanup:function(){this.has_datepicker&&this.$el.find("input").datetimepicker("destroy"),this.$el.empty()}}),a.ColorControl=a.InputControl.extend({defaults:{label:"",extraClasses:[],helpMessage:null,showPalette:!0,allowEmpty:!0,colorFormat:"HEX",defaultColor:null,position:"right-middle",clearText:e("No color")},template:t.template(['<label class="<%=Backform.controlLabelClassName%>" for="<%=cId%>"><%=label%></label>','<div class="<%=Backform.controlsClassName%>">','  <input id="<%=cId%>" class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%> d-none" name="<%=name%>" value="<%-value%>" <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',"  <p></p>","  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),applyColor:function(e,t,i){i?(t.applyColor(!0),this.model.set(e,t.getSelectedColor().toHEXA().toString(),{silent:!0})):this.model.set(e,"",{silent:!0})},render:function(){var e=this;this.picker&&(this.picker.destroyAndRemove(),this.picker=null);var i=t.defaults(this.field.toJSON(),this.defaults),n=this.model.toJSON(),s=i.name.split("."),l=s.shift(),o=s.join("."),r=this.keyPathAccessor(n[l],o),d=t.extend(i,{rawValue:r,value:this.formatter.fromRaw(r,this.model),attributes:n,formatter:this.formatter}),c=function(e,i,n){return t.isFunction(e)?!!e.apply(i,[n]):!!e};return t.extend(d,{disabled:c(d.disabled,d,this.model),visible:c(d.visible,d,this.model),required:c(d.required,d,this.model)}),d.cId=d.cId||t.uniqueId("pgC_"),this.$el.empty(),d.visible||this.$el.addClass(a.hiddenClassname),this.$el.html(this.template(d)).addClass(i.name),d.colorFormat=d.colorFormat?d.colorFormat.toUpperCase():"HEX",d.value=d.value&&""!=d.value?d.value:d.defaultColor,this.picker=new u({el:this.$el.find("p")[0],theme:"monolith",swatches:["#000","#666","#ccc","#fff","#f90","#ff0","#0f0","#f0f","#f4cccc","#fce5cd","#d0e0e3","#cfe2f3","#ead1dc","#ea9999","#b6d7a8","#a2c4c9","#d5a6bd","#e06666","#93c47d","#76a5af","#c27ba0","#f1c232","#6aa84f","#45818e","#a64d79","#bf9000","#0c343d","#4c1130"],position:d.position,strings:{clear:d.clearText},components:{palette:d.showPalette,preview:!0,hue:d.showPalette,interaction:{clear:d.allowEmpty,defaultRepresentation:d.colorFormat,disabled:d.disabled}}}),this.picker.on("init",(function(t){e.picker.setColor(d.value,!0),d.disabled&&e.picker.disable();var i=t.getRoot().preview.lastColor,n=t.getRoot().interaction.clear;n.addEventListener("keydown",(function(e){9===e.keyCode&&(e.preventDefault(),e.stopPropagation(),i.focus())})),i.addEventListener("keydown",(function(e){9===e.keyCode&&e.shiftKey&&(e.preventDefault(),e.stopPropagation(),n.focus())}))})).on("clear",(function(t){e.applyColor(l,t,null)})).on("change",(function(t,i){e.applyColor(l,i,t)})).on("show",(function(e,t){t.getRoot().palette.palette.focus()})).on("hide",(function(e,t){t.getRoot().button.focus()})),this.updateInvalid(),this}});var b=a.KeyCodeControlFormatter=function(){};return t.extend(b.prototype,{fromRaw:function(e){return e.char},toRaw:void 0}),a.KeyCodeControl=a.InputControl.extend({defaults:t.defaults({escapeKeyCodes:[16,17,18,27]},a.InputControl.prototype.defaults),events:{"keydown input":"onkeyDown","keyup input":"preventEvent","focus select":"clearInvalid"},formatter:b,preventEvent:function(e){var i=e.which||e.keyCode;-1==t.defaults(this.field.toJSON(),this.defaults).escapeKeyCodes.indexOf(i)&&(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation())},template:t.template(['<label class="<%=Backform.controlLabelClassName%> keyboard-shortcut-label"><%=label%></label>','<div class="<%=Backform.controlsClassName%>">','  <input aria-label="<%=name%>" type="<%=type%>" class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>" name="<%=name%>" oncopy="return false; oncut="return false; onpaste="return false;" maxlength="<%=maxlength%>" value="<%-value%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',"  <% if (helpMessage && helpMessage.length) { %>",'    <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',"  <% } %>","</div>"].join("\n")),onkeyDown:function(i){var a,s,l=this,o=this.model,r=this.field.get("name").split(".").shift(),d=i.which||i.keyCode;-1==t.defaults(this.field.toJSON(),this.defaults).escapeKeyCodes.indexOf(d)&&(this.model.errorModel instanceof n.Model&&this.model.errorModel.unset(r),s=e(i.key),32==d&&(s=e("Space")),a={key_code:i.which||i.keyCode,char:s},this.stopListening(this.model,"change:"+r,this.render),o.set(r,a),this.listenTo(this.model,"change:"+r,this.render),setTimeout((function(){l.$el.find("input").val(s)})),i.preventDefault())},keyPathAccessor:function(e,i){var n=e;i=i.split(".");for(var a=0;a<i.length;a++){if(t.isNull(n))return null;t.isEmpty(i[a])||(t.isUndefined(n[i[a]])||(n=n[i[a]]))}return n}}),a.KeyboardShortcutControl=a.Control.extend({initialize:function(){a.Control.prototype.initialize.apply(this,arguments);var e=this.field.get("fields");if(null==e||null==e)throw new ReferenceError('"fields" not found in keyboard shortcut');this.innerModel=new n.Model,this.controls=[]},cleanup:function(){this.stopListening(this.innerModel,"change",this.onInnerModelChange),t.each(this.controls,(function(e){e.remove()})),this.controls.length=0},template:t.template(['<label class="<%=Backform.controlLabelClassName%>"><%=label%></label>','<div class="<%=Backform.controlsClassName%> d-flex flex-row">',"</div>"].join("\n")),onInnerModelChange:function(){var e=this.field.get("name"),t=i.extend(!0,{},this.model.get(e));this.stopListening(this.model,"change:"+e,this.render),this.model.set(e,i.extend(!0,t,this.innerModel.toJSON())),this.listenTo(this.model,"change:"+e,this.render)},render:function(){this.cleanup(),this.$el.empty();var e=this,n={},s=t.defaults(this.field.toJSON(),this.defaults),l=e.model.get(s.name),o=s.fields;this.$el.html(e.template(s)).addClass(s.name);var r=i(e.$el.find(".pgadmin-controls"));return t.each(o,(function(e){n[e.name]=l[e.name]})),e.innerModel.set(n),e.listenTo(e.innerModel,"change",e.onInnerModelChange),t.each(o,(function(n){var s=new a.Field(t.extend({},{id:n.name,name:n.name,control:"checkbox"==n.type?"checkboxWithBox":n.type,label:n.label})),l=new(s.get("control"))({field:s,model:e.innerModel});(l.render(),"checkbox"==n.type)?(l.$el.find("label.control-label").text().trim().length<=0&&l.$el.find("label.control-label").remove(),"alt"==n.name?r.append(i('<div class="pg-el-sm-3 pg-el-12"></div>').append(l.$el)):r.append(i('<div class="pg-el-sm-2 pg-el-12"></div>').append(l.$el))):r.append(i('<div class="pg-el-sm-5 pg-el-12"></div>').append(l.$el));e.controls.push(l)})),e},remove:function(){this.cleanup(),a.Control.prototype.remove.apply(this,arguments)}}),a.CheckboxWithBoxControl=a.CheckboxControl.extend({events:t.extend({},a.CheckboxControl.prototype.events,{"click button":"onButtonClick"}),template:t.template(['<label class="<%=Backform.controlLabelClassName%>"><%=controlLabel%></label>','<div class="<%=Backform.controlContainerClassName%>">','  <button class="btn btn-secondary btn-checkbox">',"  <div class=\"custom-control custom-checkbox <%=extraClasses.join(' ')%>\">",'    <input tabindex="-1" type="checkbox" class="custom-control-input" id="<%=cId%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />','    <label class="custom-control-label" for="<%=cId%>">',"      <%=label%>","    </label>","  </div>","  </button>","</div>"].join("\n")),onButtonClick:function(e){"BUTTON"===e.target.nodeName&&this.$el.find("input[type=checkbox]").trigger("click")}}),a}.apply(t,a))||(e.exports=s)}).call(this,i(3))},242:function(e,t,i){"use strict";var n,a;i(243),i(244),n=[i(2),i(6),i(0),i(1),i(3),i(13)],void 0===(a=function(e,t,i,n,a,s){return(a=a||window.pgAdmin||{}).FileManager||(a.FileManager={init:function(){this.initialized||(this.initialized=!0)},show_dialog:function(e){"create_file"==e.dialog_type?s.createModeDlg(e).resizeTo(a.Browser.stdW.md,a.Browser.stdH.lg):s.fileSelectionDlg(e).resizeTo(a.Browser.stdW.md,a.Browser.stdH.lg)}}),a.FileManager}.apply(t,n))||(e.exports=a)},27:function(e,t,i){"use strict";var n,a;i(30),i(8),i(14),i(22),i(33),i(48),i(36),i(16),i(10),i(7),i(37),n=[i(2),i(0),i(1),i(3),i(15),i(50),i(76),i(62),i(154),i(20),i(31),i(84),i(155)],void 0===(a=function(e,t,i,n,a,s,l,o,r){var d=n.Browser=n.Browser||{};return d.Collection||(d.Collection=function(){},i.extend(d.Collection,i.clone(d.Node),{Init:function(){this.node_initialized||(this.node_initialized=!0,n.Browser.add_menus([{name:"refresh",node:this.type,module:this,applies:["object","context"],callback:"refresh",priority:1,label:e("Refresh..."),icon:"fa fa-refresh"}]),n.unsupported_nodes&&-1==i.indexOf(n.unsupported_nodes,this.type)&&("database"==this.type&&this.allowConn||"database"!=this.type)&&(n.Browser.add_menus([{name:"show_query_tool",node:this.type,module:this,applies:["context"],callback:"show_query_tool",priority:998,label:e("Query Tool..."),icon:"pg-font-icon icon-query-tool"}]),n.Browser.add_menus([{name:"search_objects",node:this.type,module:this,applies:["context"],callback:"show_search_objects",priority:997,label:e("Search Objects..."),icon:"fa fa-search"}])))},hasId:!1,is_collection:!0,collection_node:!0,hasCollectiveStatistics:!0,canDrop:!0,canDropCascade:!0,showProperties:function(a,r,c){var u=this,p=c.$container.find(".obj_properties").first(),h=p.data("obj-view"),f=t("<div></div>").addClass("pg-prop-content col-12 has-pg-prop-btn-group"),m=d.Nodes[u.node],g="",v=this.generate_url(a,"properties",r),b=this.getTreeNodeHierarchy.apply(this,[a]),y=l.generateGridColumnsFromModel(b,m.model,"properties",u.columns),C=function(e,n,a){if(e&&i.isArray(e)&&e.length>0){var s=t('<div class="pg-prop-btn-group"></div>'),l=i.template(['<button tabindex="0" type="<%= type %>" ',"class=\"btn <%=extraClasses.join(' ')%>\"",'<% if (disabled) { %> disabled="disabled"<% } %> title="<%-tooltip%>">','<span class="<%= icon %>" role="img"></span><% if (label != "") { %>&nbsp;<%-label%><% } %><span class="sr-only"><%-tooltip%></span></button>'].join(" "));return"header"==n?s.appendTo(u.header):s.appendTo(u.footer),a&&s.addClass(a),i.each(e,(function(e){e.icon||(e.icon="");var i=t(l(e));s.append(i),e.register(i)})),s}return null}.bind(c);u.collection=new(m.Collection.extend({url:v,model:m.model})),((i.isFunction(u.canDrop)?u.canDrop.apply(u,[r,a]):u.canDrop)||(i.isFunction(u.canDropCascade)?u.canDropCascade.apply(u,[r,a]):u.canDropCascade))&&y.columns.unshift({name:"oid",cell:o.Extension.SelectRowCell.extend({initialize:function(e){this.column=e.column,this.column instanceof o.Column||(this.column=new o.Column(this.column));var t=this.column,i=this.model,n=this.$el;this.listenTo(t,"change:renderable",(function(e,t){n.toggleClass("renderable",t)})),o.callByNeed(t.renderable(),t,i)&&n.addClass("renderable width_percent_3"),this.listenTo(i,"backgrid:select",this.toggleCheckbox)},toggleCheckbox:function(e,t){!1===this.checkbox().prop("disabled")&&this.checkbox().prop("checked",t).change()},render:function(){var t=this.model.toJSON(),n="canDrop"in t&&!1===t.canDrop,a="row-".concat(i.uniqueId(t.oid||t.name));return this.$el.empty().append('\n                  <div class="custom-control custom-checkbox custom-checkbox-no-label">\n                    <input tabindex="-1" type="checkbox" class="custom-control-input" id="'.concat(a,'" ').concat(n?"disabled":"",'/>\n                    <label class="custom-control-label" for="').concat(a,'">\n                      <span class="sr-only">')+e("Select")+"<span>\n                    </label>\n                  </div>\n                "),this.delegateEvents(),this}}),headerCell:o.Extension.SelectAllHeaderCell}),u.grid=new o.Grid({emptyText:e("No data found"),columns:y.columns,collection:u.collection,className:"backgrid table presentation table-bordered table-noouter-border table-hover"});var _={remove:function(){this.grid&&(this.grid.collection&&(this.grid.collection.reset([],{silent:!0}),delete this.grid.collection),delete this.grid,this.grid=null)},grid:u.grid};if(h){if(i.isEqual(t(c).data("node-prop"),v))return;t(c).data("node-prop",v),p.data("obj-view",null)}p.empty(),p.data("obj-view",_),g='<div role="status" class="pg-panel-message pg-panel-properties-message">'+e("Retrieving data from the server...")+"</div>",g=t(g).appendTo(p),u.header=t("<div></div>").addClass("pg-prop-header");var w,x=[];x.push({label:"",type:"delete",tooltip:e("Delete/Drop"),extraClasses:["btn-secondary m-1","delete_multiple"],icon:"fa fa-lg fa-trash-o",disabled:i.isFunction(u.canDrop)?!u.canDrop.apply(self,[r,a]):!u.canDrop,register:function(e){e.on("click",(function(){k("drop")}))}}),x.push({label:"",type:"delete",tooltip:e("Drop Cascade"),extraClasses:["btn-secondary m-1","delete_multiple_cascade"],icon:"pg-font-icon icon-drop-cascade",disabled:i.isFunction(u.canDropCascade)?!u.canDropCascade.apply(self,[r,a]):!u.canDropCascade,register:function(e){e.on("click",(function(){k("dropCascade")}))}}),C(x,"header","pg-prop-btn-group-above"),f.append('<div class="pg-prop-coll-container"></div>'),f.find(".pg-prop-coll-container").append(u.grid.render().$el);!function l(){t.ajax({url:v,type:"GET",beforeSend:function(t){t.setRequestHeader(n.csrf_token_header,n.csrf_token),w=setTimeout((function(){g.text(e("Retrieving data from the server...")),g.removeClass("d-none"),self.grid&&self.grid.remove()}),1e3)}}).done((function(n){clearTimeout(w),i.isUndefined(u.grid)||i.isNull(u.grid)||(u.data=n,u.data.length>0?(g.hasClass("d-none")||g.addClass("d-none"),u.header.appendTo(p),p.append(f),t(".pg-prop-content").on("scroll",u.__loadMoreRows.bind(u)),u.collection.reset(u.data.splice(0,50))):(t(".pg-prop-content").off("scroll",u.__loadMoreRows),g.text(e("No properties are available for the selected object."))))})).fail((function(t,i){d.Events.trigger("pgadmin:node:retrieval:error","properties",t,i.message,a,u),s.pgHandleItemError(t,i.message,{item:a,info:b})||s.pgNotifier(i,t,e("Error retrieving properties - %s",i.message||u.label),(function(e){"CRYPTKEY_SET"===e?l():console.warn(arguments)})),g.text(e("Failed to retrieve data from the server."))}))}();var k=function(i){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=this.grid.getSelectedModels(),l=[],o=d.tree.selected(),r=o?d.tree.itemData(o):null,c=d.Nodes[r._type],u=void 0,p=void 0,h=void 0;if(0!==(l=c.type&&"coll-constraints"==c.type?a.map((function(e){return{id:e.get("oid"),_type:e.get("_type")}})):a.map((function(e){return e.id}))).length){"dropCascade"===i?(u=c.generate_url(o,"delete"),p=e("Are you sure you want to drop all the selected objects and all the objects that depend on them?"),h=e("DROP CASCADE multiple objects?")):(u=c.generate_url(o,"drop"),p=e("Are you sure you want to drop all the selected objects?"),h=e("DROP multiple objects?"));var f=function(){t.ajax({url:u,type:"DELETE",data:JSON.stringify({ids:l}),contentType:"application/json; charset=utf-8"}).done((function(e){return 0==e.success?d.report_error(e.errormsg,e.info):(t(d.panels.properties.panel).removeData("node-prop"),d.Events.trigger("pgadmin:browser:tree:refresh",o||d.tree.selected(),{success:function(){c.callbacks.selected.apply(c,[o])}})),!0})).fail((function(n,a){s.pgNotifier(a,n,e("Error dropping %s",r._label.toLowerCase()),(function(e){"CRYPTKEY_SET"==e?k(i,!1):(t(d.panels.properties.panel).removeData("node-prop"),d.Events.trigger("pgadmin:browser:tree:refresh",o||d.tree.selected(),{success:function(){c.callbacks.selected.apply(c,[o])}}))}))}))};n?s.confirm(h,p,f,null).show():f()}else s.alert(e("Drop Multiple"),e("Please select at least one object to delete."))}.bind(u)},__loadMoreRows:function(e){var t=e.currentTarget;t.scrollHeight-10<t.scrollTop+t.offsetHeight&&this.data.length>0&&this.collection.add(this.data.splice(0,50))},generate_url:function(e,t){var i={properties:"obj",children:"nodes",drop:"obj"},a=this,s=this.getTreeNodeHierarchy(e),l=t in i?i[t]:t;return r.generate_url(n.Browser.URL,s,l,a.node,(function(e,t){return t!=a.type}))},show_query_tool:function(){n.DataGrid&&n.DataGrid.show_query_tool("",n.Browser.tree.selected())},show_search_objects:function(){n.SearchObjects&&n.SearchObjects.show_search_objects("",n.Browser.tree.selected())}})),d.Collection}.apply(t,n))||(e.exports=a)},31:function(e,t,i){"use strict";(function(n,a){var s,l;i(30),i(8),i(14),i(17),i(22),i(33),i(86),i(36),i(16),i(10),i(387),i(12),i(81),i(35),i(5),i(9),i(58),i(29),i(82),i(19),i(7),i(37),s=[i(2),i(1),i(0),i(15),i(76),i(62),i(50),i(112),i(390),i(21),i(70),i(150),i(391),i(151),i(187)],void 0===(l=function(e,t,i,n,s,l,o,r,d,c,u,p){var h=(window.pgAdmin=window.pgAdmin||{}).Browser;t.extend(l.Column.prototype.defaults,{cellFunction:void 0}),t.extend(l.Cell.prototype.events,{mouseover:function(){var e=i(this.el);e.text().length>0&&!e.attr("title")&&e.innerWidth()+1<e[0].scrollWidth&&e.attr("title",i.trim(e.text()))}}),t.extend(l.InputCellEditor.prototype.events,{keydown:function(e){var t=h.get_preferences_for_module("browser");u.validateShortcutKeys(t.add_grid_row,e)?h.keyboardNavigation.bindAddGridRow():l.InputCellEditor.prototype.saveOrCancel.apply(this,arguments)}}),t.extend(l.Body.prototype,{sort:function(e,i){if(!t.contains(["ascending","descending",null],i))throw new RangeError('direction must be one of "ascending", "descending" or `null`');t.isString(e)&&(e=this.columns.findWhere({name:e}));var a,s=this.collection;a="ascending"===i?-1:"descending"===i?1:null;var l=e.get("cell").prototype.className||"string-cell",o=this.makeComparator(e.get("name"),a,a?e.sortValue():function(e){return 1*e.cid.replace("c","")},l);return n.PageableCollection&&s instanceof n.PageableCollection?(s.setSorting(a&&e.get("name"),a,{sortValue:e.sortValue()}),s.fullCollection?(null==s.fullCollection.comparator&&(s.fullCollection.comparator=o),s.fullCollection.sort(),s.trigger("backgrid:sorted",e,i,s)):s.fetch({reset:!0,success:function(){s.trigger("backgrid:sorted",e,i,s)}})):(s.comparator=o,s.sort(),s.trigger("backgrid:sorted",e,i,s)),e.set("direction",i),this},makeComparator:function(e,i,n,a){return function(s,l){var o,r=n(s,e),c=n(l,e);if(!t.isUndefined(r)&&!t.isUndefined(c)){if(t.include(["number-cell","integer-cell"],a)){var u,p;try{u=new d(r)}catch(e){u=NaN}try{p=new d(c)}catch(e){p=NaN}return 1===i&&(o=u,u=p,p=o),u.eq(p)?0:u.lt(p)?-1:1}return 1===i&&(o=r,r=c,c=o),r===c?0:null===r&&null!=c?-1:null!=r&&null===c?1:r<c?-1:1}}},moveToNextCell:function(e,t,n){var a,s,o,r,d,c=this.collection.indexOf(e),u=this.columns.indexOf(t);if(-1===u)return this;if(this.rows[c].cells[u].exitEditMode(),n.moveUp()||n.moveDown()||n.moveLeft()||n.moveRight()||n.save()){var p=this.columns.length,h=p*this.collection.length;if(n.moveUp()||n.moveDown()){r=c+(n.moveUp()?-1:1);var f=this.rows[r];f?(a=f.cells[u],l.callByNeed(a.column.editable(),a.column,e)&&(a.enterEditMode(),e.trigger("backgrid:next",r,u,!1))):e.trigger("backgrid:next",r,u,!0)}else if(n.moveLeft()||n.moveRight()){for(var m=n.moveRight(),g=c*p+u+(m?1:-1);g>=0&&g<h;m?g++:g--){if(d=g-(r=~~(g/p))*p,a=this.rows[r].cells[d],s=l.callByNeed(a.column.renderable(),a.column,a.model),o=l.callByNeed(a.column.editable(),a.column,e),a&&a.$el.hasClass("edit-cell")&&!a.$el.hasClass("privileges")||a.$el.hasClass("delete-cell")){e.trigger("backgrid:next",r,d,!1),a.$el.hasClass("delete-cell")&&setTimeout((function(){i(a.$el).trigger("focus")}),50);break}if(s&&o){a.enterEditMode(),e.trigger("backgrid:next",r,d,!1);break}}g==h&&e.trigger("backgrid:next",~~(g/p),g-r*p,!0)}}return this}}),t.extend(l.Row.prototype,{makeCell:function(e){return new(this.getCell(e))({column:e,model:this.model})},getCell:function(e){var i=e.get("cellFunction");if(!t.isFunction(i))return e.get("cell");var n=i.apply(e,[this.model]);try{return l.resolveNameToClass(n,"Cell")}catch(t){if(t instanceof ReferenceError)return e.get("cell");throw t}}});var f=l.Extension.ObjectCellEditor=l.CellEditor.extend({modalTemplate:t.template(['<div class="subnode-dialog" tabindex="0">','    <div class="subnode-body"></div>',"</div>"].join("\n")),stringTemplate:t.template(['<div class="form-group">','  <label class="control-label col-sm-4"><%=label%></label>','  <div class="col-sm-8">','    <input type="text" class="form-control" name="<%=name%>" value="<%=value%>" placeholder="<%=placeholder%>" />',"  </div>","</div>"].join("\n")),extendWithOptions:function(e){t.extend(this,e)},render:function(){return this},postRender:function(e,n){var a=this.columns_length,l=this.schema.length?this.schema:this.column.get("schema");if(null!=n&&n.get("name")!=this.column.get("name"))return!1;if(!t.isArray(l))throw new TypeError("schema must be an array");var o=this.createDialog(a),r=i('<form class="form-dialog"></form>');o.find("div.subnode-body").append(r);var d=o.find("form.form-dialog");return this.objectView=new s.Dialog({el:d,model:this.model,schema:l,tabPanelClassName:function(){return"sub-node-form col-sm-12"},events:{keydown:function(e){var t=h.get_preferences_for_module("browser");u.validateShortcutKeys(t.add_grid_row,e)&&h.keyboardNavigation.bindAddGridRow()}}}),this.objectView.render(),this},createDialog:function(e){e=e||1;var t=this.$dialog=i(this.modalTemplate({title:""})),n=i('<tr class="nohover editor-row">'),a=i("<td>",{class:"editable sortable renderable",style:"height: auto",colspan:e+2}).appendTo(n);return this.tr=n,a.append(t.css("display","block")),this.el.parent("tr").after(n),t},save:function(){return this.model.trigger("backgrid:edited",this.model,this.column,new l.Command({keyCode:13})),this.tr&&this.tr.remove(),this},remove:function(){return this.objectView.remove(),l.CellEditor.prototype.remove.apply(this,arguments),this.tr&&this.tr.remove(),this}});l.Extension.PGSelectCell=l.SelectCell.extend({optionValues:function(){var e=[],i=t.result(this.column.attributes,"options");return t.each(i,(function(t){e.push([t.label,t.value])})),e}}),l.Extension.ObjectCell=l.Cell.extend({editorOptionDefaults:{schema:[]},className:"edit-cell",editor:f,initialize:function(e){l.Cell.prototype.initialize.apply(this,arguments);var n=this,a={};t.each(this.editorOptionDefaults,(function(t,i){n[i]||(n[i]=t),e&&e[i]&&(n[i]=e[i]),a[i]=n[i]})),a.el=i(this.el),a.columns_length=this.column.collection.length,a.el.attr("tabindex",0),this.listenTo(this.model,"backgrid:edit",(function(e,t,i,n){t.get("name")==this.column.get("name")&&n.extendWithOptions(a)})),this.$el.on("keydown",(function(e){32==e.keyCode&&i(this).click()}))},enterEditMode:function(){var n=!(!t.isUndefined(this.column.get("canEditRow"))&&t.isFunction(this.column.get("canEditRow")))||l.callByNeed(this.column.get("canEditRow"),this.column,this.model);if(n){this.model.trigger("enteringEditMode",[this]),l.Cell.prototype.enterEditMode.apply(this,arguments),this.delegateEvents();var a=l.callByNeed(this.column.editable(),this.column,this.model);if(a){this.$el.html("<i class='fa fa-pencil-square subnode-edit-in-process' title='"+e("Edit row")+"' aria-label='"+e("Edit row")+"'></i>");var s=i(this.$el).parents()[1],r=i(s).find(".tab-content:first > .tab-pane.active:first");c.findAndSetFocus(r),h.keyboardNavigation.getDialogTabNavigator(i(s).find(".subnode-dialog")),this.model.trigger("pg-sub-node:opened",this.model,this)}}else o.alert(e("Edit object"),e("This object is not user editable."),(function(){return!0}))},render:function(){return this.$el.empty(),this.$el.html("<i class='fa fa-pencil-square-o' title='"+e("Edit row")+"' aria-label='"+e("Edit row")+"'></i>"),this.delegateEvents(),this.grabFocus&&this.$el.trigger("focus"),this},exitEditMode:function(){if(!t.isUndefined(this.currentEditor)||!t.isEmpty(this.currentEditor)){var e=i(this.currentEditor.objectView.el).find('.nav-tabs > .active > a[data-toggle="tab"]').first().data("tabIndex");l.Cell.prototype.exitEditMode.apply(this,arguments),this.model.trigger("pg-sub-node:closed",this,e),this.grabFocus=!0}},events:{click:function(e){this.$el.find("i").first().hasClass("subnode-edit-in-process")?(this.undelegateEvents(),this.currentEditor.save()):this.enterEditMode.call(this,[]),e.preventDefault()},keydown:function(e){var t=this.model,i=this.column,n=new l.Command(e);n.moveLeft()&&setTimeout((function(){t.trigger("backgrid:edited",t,i,n)}),20)}}}),l.Extension.DeleteCell=l.Cell.extend({defaults:t.defaults({defaultDeleteMsg:e("Are you sure you wish to delete this row?"),defaultDeleteTitle:e("Delete Row")},l.Cell.prototype.defaults),className:"delete-cell",events:{click:"deleteRow"},deleteRow:function(n){n.preventDefault();var a=this;if(!(!t.isUndefined(this.column.get("canDeleteRow"))&&t.isFunction(this.column.get("canDeleteRow")))||l.callByNeed(this.column.get("canDeleteRow"),this.column,this.model)){var s=t.isUndefined(this.column.get("customDeleteMsg"))?a.defaults.defaultDeleteMsg:this.column.get("customDeleteMsg"),r=t.isUndefined(this.column.get("customDeleteTitle"))?a.defaults.defaultDeleteTitle:this.column.get("customDeleteTitle");o.confirm(r,s,(function(){var e=i(a.el).parents("tbody").eq(0);a.model.collection.remove(a.model);var t=i(e).find("tr");t.length>0?t.first().children()[0].focus():i(e).parents(".subnode").eq(0).find(".add").focus()}),(function(){return!0}))}else o.alert(e("Delete object"),e("This object cannot be deleted."),(function(){return!0}))},exitEditMode:function(){this.$el.removeClass("editor")},initialize:function(){l.Cell.prototype.initialize.apply(this,arguments)},render:function(){var t=this;return this.$el.empty(),i(this.$el).attr("tabindex",0),this.$el.html('<i aria-label="'+e("Delete row")+"\" class='fa fa-trash' title='"+e("Delete row")+"'></i>"),this.$el.on("keydown",(function(e){var i;if(32==e.keyCode&&t.$el.click(),9!=e.keyCode&&16!=e.keyCode||(i=e.shiftKey?t.$el.prev():t.$el.next()),i){var n=new l.Command({key:"Tab",keyCode:9,which:9,shiftKey:e.shiftKey});setTimeout((function(){i.hasClass("editable")?(e.preventDefault(),e.stopPropagation(),t.model.trigger("backgrid:edited",t.model,t.column,n)):t.model.trigger("backgrid:edited",t.model,t.column,n)}),20)}})),this.delegateEvents(),this}}),l.Extension.CustomHeaderCell=l.HeaderCell.extend({initialize:function(){l.HeaderCell.prototype.initialize.apply(this,arguments);var e=this.column.get("cellHeaderClasses"),t=this.column.get("cellAriaLabel");e&&this.$el.addClass(e),t&&this.$el.attr("aria-label",t)},render:function(){if(l.HeaderCell.prototype.render.apply(this,arguments),""==this.column.get("label")||!this.column.get("label")){var e=this.column.get("cellAriaLabel");e&&this.$el.append('<span class="sr-only">'.concat(e,"</span>"))}return this}}),a&&a.fn.bootstrapToggle&&(i.fn.bootstrapToggle=a.fn.bootstrapToggle),l.Extension.SwitchCell=l.BooleanCell.extend({defaults:{options:t.defaults({onText:e("Yes"),offText:e("No"),onColor:"success",offColor:"ternary",size:"mini",width:null,height:null},i.fn.bootstrapToggle.defaults)},className:"switch-cell",initialize:function(){l.BooleanCell.prototype.initialize.apply(this,arguments),this.onChange=this.onChange.bind(this)},enterEditMode:function(){this.$el.addClass("editor"),i(this.$el.find(".toggle.btn")).trigger("focus")},exitEditMode:function(){this.$el.removeClass("editor")},events:{"change input":"onChange","blur input":"exitEditMode",keydown:"onKeyDown"},onKeyDown:function(e){var t=h.get_preferences_for_module("browser");u.validateShortcutKeys(t.add_grid_row,e)&&h.keyboardNavigation.bindAddGridRow()},onChange:function(){var e=this.model,t=this.column,i=this.formatter.toRaw(this.$input.prop("checked"),e);this.enterEditMode(),e.set(t.get("name"),i),this.setSrValue()},setSrValue:function(){var i=t.defaults({},this.column.get("options"),this.defaults.options),n=i.onText,a=i.offText;this.$el.find(".toggle.btn").hasClass("off")?this.$el.find(".sr-value").text("\n          ".concat(a,", ").concat(e("Toggle button"),"\n        ")):this.$el.find(".sr-value").text("\n          ".concat(n,", ").concat(e("Toggle button"),"\n        "))},render:function(){var e=this,n=t.defaults(this.column.toJSON(),this.defaults),a=this.model,s=this.column,o=this.formatter.fromRaw(a.get(s.get("name")),a),r=l.callByNeed(n.editable,s,a),d=t.defaults({},n.options,this.defaults.options),c=t.uniqueId("pgC_");return this.undelegateEvents(),this.$el.empty(),this.$el.append('<label class="sr-value sr-only" for="'+c+'"></label>'),this.$el.append(i("<input>",{tabIndex:-1,type:"checkbox","aria-hidden":"true","aria-label":s.get("name")}).prop("checked",o).prop("disabled",!r).attr("data-toggle","toggle").attr("data-size",d.size).attr("data-on",d.onText).attr("data-off",d.offText).attr("data-width",d.width).attr("data-height",d.height).attr("data-onstyle",d.onColor).attr("data-offstyle",d.offColor)),this.$input=this.$el.find("input[type=checkbox]").first(),this.$input.bootstrapToggle(),this.$el.find(".toggle.btn").attr("tabindex",r?"0":"-1").attr("id",c).on("keydown",(function(t){32==t.keyCode&&(e.$el.find("input[type=checkbox]").bootstrapToggle("toggle"),t.preventDefault(),t.stopPropagation(),e.setSrValue())})),this.$el.find(".toggle.btn .toggle-group .btn").attr("aria-hidden",!0),this.setSrValue(),this.$el.on("keydown",(function(t){var i;if(9==t.keyCode&&(i=t.shiftKey?e.$el.prev():e.$el.next()),i&&i.length>0){i.hasClass("editable")&&(t.preventDefault(),t.stopPropagation());var n=new l.Command({key:"Tab",keyCode:9,which:9,shiftKey:t.shiftKey});setTimeout((function(){i.hasClass("editable")&&i.hasClass("edit-cell")?i.trigger("focus"):i.hasClass("editable")?(setTimeout((function(){e.model.trigger("backgrid:edited",e.model,e.column,n)}),10),i.trigger("focus")):setTimeout((function(){e.model.trigger("backgrid:edited",e.model,e.column,n)}),10)}),20)}})),this.delegateEvents(),this}}),l.Extension.Select2Cell=l.SelectCell.extend({className:"select2-cell",editor:null,defaults:t.defaults({select2:{},opt:{label:null,value:null,selected:!1}},l.SelectCell.prototype.defaults),enterEditMode:function(){this.$el.hasClass("editor")||this.$el.addClass("editor"),this.$select.select2("focus"),this.$select.select2("open"),this.$select.on("blur",this.exitEditMode)},exitEditMode:function(){this.$select.off("blur",this.exitEditMode),this.$select.select2("close"),this.$el.removeClass("editor"),this.$el.find(".select2-selection").trigger("focus")},saveOrCancel:function(e){var t,i=this,n=new l.Command(e),a="blur"===e.type;if((n.moveUp()||n.moveDown()||n.moveLeft()||n.moveRight()||n.save()||a)&&(9!=e.keyCode&&16!=e.keyCode||(t=e.shiftKey?i.$el.prev():i.$el.next(),0==i.$el.next().length&&setTimeout((function(){i.$el.find(".select2-selection").blur()}),100)),t)){var s=new l.Command({key:"Tab",keyCode:9,which:9,shiftKey:e.shiftKey});setTimeout((function(){t.hasClass("editable")?(e.preventDefault(),e.stopPropagation(),i.model.trigger("backgrid:edited",i.model,i.column,s)):i.model.trigger("backgrid:edited",i.model,i.column,s)}),20)}},events:{"select2:open":"enterEditMode","select2:close":"exitEditMode",change:"onSave","select2:unselect":"onSave",blur:"saveOrCancel",keydown:"saveOrCancel"},template:t.template(['<option value="<%- value %>" ','<%= selected ? \'selected="selected"\' : "" %>>',"<%- label %></option>"].join(""),null,{variable:null}),initialize:function(){l.SelectCell.prototype.initialize.apply(this,arguments),this.onSave=this.onSave.bind(this),this.enterEditMode=this.enterEditMode.bind(this),this.exitEditMode=this.exitEditMode.bind(this)},render:function(){var e=t.defaults(this.column.toJSON(),this.defaults),n=this.model,a=this.column,s=l.callByNeed(e.editable,a,n),o=t.clone(this.optionValues||(t.isFunction(this.column.get("options"))?this.column.get("options")(this):this.column.get("options")));if(this.undelegateEvents(),this.$select&&(this.$select.data("select2")&&this.$select.select2("destroy"),delete this.$select,this.$select=null),this.$el.empty(),!t.isArray(o))throw new TypeError("optionValues must be an array");var r=null,d=null,c=this,u=n.get(this.column.get("name")),h=t.extend({openOnEnter:!1,multiple:!1,showOnScroll:!0,first_empty:!0},c.defaults.select2,e.select2||{}),f=t.template('<select <%=multiple ? "multiple" : "" %>></select>'),m=c.$select=i(f({multiple:h.multiple})).appendTo(c.$el);h.first_empty&&o.unshift(this.defaults.opt);for(var g=0;g<o.length;g++){var v=o[g];t.isArray(v)?(r=v[0],d=v[1],m.append(c.template({label:r,value:d,selected:u==d||h.multiple&&t.indexOf(u,d)>-1}))):(v=t.defaults({},v,{selected:u==v.value||h.multiple&&t.indexOf(u,v.value)>-1},c.defaults.opt),m.append(c.template(v)))}if(e&&t.has(e.disabled)){t.extend(h,{disabled:function(){var e=[];Array.prototype.push.apply(e,arguments);var t=e.shift();return"function"==typeof t?t.apply(c,e):t}(e.disabled,e,n)})}else t.extend(h,{disabled:!s});return this.delegateEvents(),s&&"properties"!==e.mode||(h.placeholder=""),h=p.default(h),this.$sel=this.$select.select2(h),this.$sel&&this.$sel.data("select2").on("keypress",(function(e){9===e.which&&this.isOpen()&&(this.trigger("results:select",{}),e.preventDefault())})),this},onSave:function(){var e=this.model,t=this.column;e.set(t.get("name"),this.$select.val())},remove:function(){this.$select.off("change",this.onSave),this.$select.data("select2")&&this.$select.select2("destroy"),this.$el.empty(),l.SelectCell.prototype.remove.apply(this,arguments)}});var m=l.TextareaCellEditor=l.InputCellEditor.extend({tagName:"textarea",events:{blur:"saveOrCancel",keydown:""}});l.Extension.TextareaCell=l.Cell.extend({className:"textarea-cell",editor:m}),l.Extension.CustomHeaderIconCell=l.HeaderCell.extend({className:"header-icon-cell",events:{click:"addHeaderIcon"},addHeaderIcon:function(e){this.collection.add(new this.collection.model),e.preventDefault()},render:function(){return this.$el.empty(),this.$el.html("<label><a><span style='font-weight:normal;'>"+e("Array Values")+"</a></span></label> <button class='btn-sm btn-secondary add'>"+e("Add")+"</button>"),this.delegateEvents(),this}});var g=n.Model.extend({defaults:{value:null}}),v=l.Extension.InputArrayCellEditor=l.CellEditor.extend({tagName:"div",events:{blur:"lostFocus"},render:function(){var t=this.model.get(this.column.get("name")),n="string";switch(this.model.get("type").replace("[]","")){case"boolean":n="boolean";break;case"integer":case"smallint":case"bigint":case"serial":case"smallserial":case"bigserial":case"oid":case"cid":case"xid":case"tid":n="integer";break;case"real":case"numeric":case"double precision":case"decimal":n="number";break;case"date":n="date"}var a=[{name:"value",label:e("Array Values"),type:"text",cell:n,headerCell:l.Extension.CustomHeaderIconCell,cellHeaderClasses:"width_percent_100"}],s=i("<div class='pgadmin-control-group backgrid form-group col-12 object subnode'></div>");this.$el.attr("tabindex","1"),a.unshift({name:"pg-backform-delete",label:"",cell:l.Extension.DeleteCell,editable:!1,cell_priority:-1}),this.$el.empty();var o,r=this.grid=new l.Grid({columns:a,collection:t});return this.grid.listenTo(t,"backgrid:error",(o=this,function(e){o.model.trigger("backgrid:error",o.model,o.column,new l.Command(e))})),this.grid.listenTo(t,"backgrid:edited",function(e){return function(t){e.model.trigger("backgrid:edited",e.model,e.column,new l.Command(t))}}(this)),r.render(),s.append(r.$el),this.$el.html(s),i(this.$el).pgMakeVisible("backform-tab"),this.delegateEvents(),this},lostFocus:function(e){var t=this;setTimeout((function(){if(t.$el[0]!=document.activeElement&&!function(e,t){for(var i=t.parentNode;null!=i;){if(i==e)return!0;i=i.parentNode}return!1}(t.$el[0],document.activeElement)){var i=t.model,n=t.column;i.trigger("backgrid:edited",i,n,new l.Command(e)),setTimeout((function(){t.grid&&(t.grid.remove(),t.grid=null)}),10)}}),10)}}),b=l.Extension.InputStringArrayCellFormatter=function(){};t.extend(b.prototype,{fromRaw:function(e){var i=[];return e.each((function(e){var n=e.get("value");t.isUndefined(n)?i.push("null"):i.push(e.get("value"))})),i.toString()},toRaw:function(e){return e}});var y=l.Extension.InputIntegerArrayCellFormatter=function(){};t.extend(y.prototype,{fromRaw:function(e){var i=[];return e.each((function(e){var n=e.get("value");t.isUndefined(n)||t.isNull(n)?i.push("NULL"):i.push(e.get("value"))})),i.toString()},toRaw:function(e){return e.each((function(e){e.set("value",parseInt(e.get("value")),{silent:!0})})),e}});var C=l.Extension.InputNumberArrayCellFormatter=function(){};t.extend(C.prototype,{fromRaw:function(e){var i=[];return e.each((function(e){var n=e.get("value");t.isUndefined(n)||t.isNull(n)?i.push("NULL"):i.push(e.get("value"))})),i.toString()},toRaw:function(e){return e.each((function(e){e.set("value",parseFloat(e.get("value")),{silent:!0})})),e}}),l.Extension.InputStringArrayCell=l.Cell.extend({className:"width_percent_25",formatter:b,editor:v,initialize:function(){l.Cell.prototype.initialize.apply(this,arguments);var e=arguments[0].model;t.isUndefined(this.collection)&&(this.collection=new(n.Collection.extend({model:g}))(e.get("value"))),this.model.set(this.column.get("name"),this.collection),this.listenTo(this.collection,"remove",this.render)}}),l.Extension.InputIntegerArrayCell=l.IntegerCell.extend({className:"width_percent_25",formatter:y,editor:v,initialize:function(){l.IntegerCell.prototype.initialize.apply(this,arguments);var e=arguments[0].model;t.each(e.get("value"),(function(e){"NULL"===e.value&&(e.value=null)})),t.isUndefined(this.collection)&&(this.collection=new(n.Collection.extend({model:g}))(e.get("value"))),this.model.set(this.column.get("name"),this.collection),this.listenTo(this.collection,"remove",this.render)}}),l.Extension.InputNumberArrayCell=l.NumberCell.extend({className:"width_percent_25",formatter:C,editor:v,initialize:function(){l.NumberCell.prototype.initialize.apply(this,arguments);var e=arguments[0].model;t.each(e.get("value"),(function(e){"NULL"===e.value&&(e.value=null)})),t.isUndefined(this.collection)&&(this.collection=new(n.Collection.extend({model:g}))(e.get("value"))),this.model.set(this.column.get("name"),this.collection),this.listenTo(this.collection,"remove",this.render)}}),l.Extension.InputBooleanArrayCell=l.BooleanCell.extend({className:"width_percent_25",editor:v,initialize:function(){l.BooleanCell.prototype.initialize.apply(this,arguments);var e=arguments[0].model;t.isUndefined(this.collection)&&(this.collection=new(n.Collection.extend({model:g}))(e.get("value"))),this.model.set(this.column.get("name"),this.collection),this.listenTo(this.collection,"remove",this.render)}});var _=l.Extension.DependentCell=function(){};t.extend(_.prototype,{initialize:function(){var e=this.column.get("deps"),i=this;e&&t.isArray(e)&&t.each(e,(function(e){var t=e.split(".").shift();i.listenTo(i.model,"change:"+t,i.dependentChanged)}))},remove:function(){var e=this,i=e.column.get("deps");i&&t.isArray(i)&&t.each(i,(function(t){var i=t.split(".").shift();e.stopListening(e.model,"change:"+i,e.dependentChanged)}))}});var w=l.PasswordFormatter=function(){};w.prototype=new l.CellFormatter,t.extend(w.prototype,{fromRaw:function(e){if(t.isUndefined(e)||t.isNull(e))return"";for(var i="",n=0;n<e.length;n++)i+="*";return i}}),l.Extension.PasswordCell=l.StringCell.extend({formatter:w,editor:l.InputCellEditor.extend({attributes:{type:"password",autocomplete:"new-password"},render:function(){var e=this.model;return this.$el.val(e.get(this.column.get("name"))),this}})}),t.extend(l.NumberFormatter.prototype,{fromRaw:function(e){if(t.isNull(e)||t.isUndefined(e))return"";var i=(e=parseFloat(e).toFixed(~~this.decimals)).split("."),n=i[0],a=i[1]?(this.decimalSeparator||".")+i[1]:"";return n.replace(this.HUMANIZED_NUM_RE,"$1"+this.orderSeparator)+a}});var x=l.Extension.JSONBCellFormatter=function(){};t.extend(x.prototype,{fromRaw:function(e){if(t.isArray(e)){return"{"+t.map(e,(function(e){return JSON.stringify(JSON.stringify(e))})).join()+"}"}return t.isObject(e)?JSON.stringify(e):e},toRaw:function(e){return e}}),l.Extension.JSONBCell=l.StringCell.extend({className:"jsonb-cell",formatter:x}),l.Extension.DatepickerCell=l.Cell.extend({editor:k});var k=l.InputCellEditor.extend({events:{},initialize:function(){l.InputCellEditor.prototype.initialize.apply(this,arguments);var e=this;i(this.el).prop("readonly",!0),i(this.el).datepicker({onClose:function(t){var i=new l.Command({});e.model.set(e.column.get("name"),t),e.model.trigger("backgrid:edited",e.model,e.column,i),i=e=null}})}}),N=l.Extension.MomentFormatter=function(e){t.extend(this,this.defaults,e)};N.prototype=new l.CellFormatter,t.extend(N.prototype,{defaults:{modelInUnixOffset:!1,modelInUnixTimestamp:!1,modelInUTC:!0,modelLang:r.locale(),modelFormat:r.defaultFormat,displayInUnixOffset:!1,displayInUnixTimestamp:!1,displayInUTC:!0,displayLang:r.locale(),displayFormat:r.defaultFormat,allowEmpty:!1},fromRaw:function(e){if(null==e)return"";var t=this.modelInUnixOffset?r(e):this.modelInUnixTimestamp?r.unix(e):this.modelInUTC?r.utc(e,this.modelFormat,this.modelLang):r(e,this.modelFormat,this.modelLang);return this.displayInUnixOffset?+t:this.displayInUnixTimestamp?t.unix():(this.displayLang&&t.locale(this.displayLang),this.displayInUTC?t.utc():t.local(),this.displayFormat!=r.defaultFormat?t.format(this.displayFormat):t.format())},toRaw:function(e){var t=this.displayInUnixOffset?r(+e):this.displayInUnixTimestamp?r.unix(+e):this.displayInUTC?r.utc(e,this.displayFormat,this.displayLang):r(e,this.displayFormat,this.displayLang);return t&&t.isValid()?this.modelInUnixOffset?+t:this.modelInUnixTimestamp?t.unix():(this.modelLang&&t.locale(this.modelLang),this.modelInUTC?t.utc():t.local(),this.modelFormat!=r.defaultFormat?t.format(this.modelFormat):t.format()):this.allowEmpty&&""===e?null:void 0}});var E=l.Extension.MomentCell=l.Cell.extend({editor:l.InputCellEditor,className:"datetime-cell",formatter:N,initialize:function(e){E.__super__.initialize.apply(this,arguments);var i=N.prototype.defaults,n=t.keys(i),a=t.pick(this,n),s=t.pick(e,n),l=t.pick(this.column.toJSON(),n);t.extend(this.formatter,i,a,s,l),this.editor=this.editor.extend({attributes:t.extend({},this.editor.prototype.attributes||this.editor.attributes||{},{placeholder:this.formatter.displayFormat}),options:this.column.get("options")})}});l.Extension.DatetimePickerEditor=l.InputCellEditor.extend({postRender:function(){var e=this,i=t.extend({format:"YYYY-MM-DD HH:mm:ss Z",icons:{clear:"fa fa-trash"},buttons:{showToday:!0},toolbarPlacement:"top",widgetPositioning:{horizontal:"auto",vertical:"bottom"},keepOpen:!1},function(){var t=[];Array.prototype.push.apply(t,arguments);var i=t.shift();return"function"==typeof i?i.apply(e,t):i}(this.column.get("options")),{keyBinds:{"shift tab":function(t){t&&setTimeout((function(){e.closeIt({keyCode:9,shiftKey:!0})}),10)},tab:function(t){t&&setTimeout((function(){e.closeIt({keyCode:9})}),10)}}});this.tabKeyPress=!1,this.$el.datetimepicker(i),this.$el.datetimepicker("show"),this.picker=this.$el.data("datetimepicker")},events:{"hide.datetimepicker":"closeIt",focusout:"closeIt",keydown:"keydownHandler"},keydownHandler:function(e){var t=!1;if(e.altKey||38!=e.keyCode)if(e.altKey||40!=e.keyCode){if(39==e.keyCode){var n=this.$el.data("datetimepicker").date().clone();i(this.el).datetimepicker("date",n.add(1,"d"))}else if(37==e.keyCode){var a=this.$el.data("datetimepicker").date().clone();i(this.el).datetimepicker("date",a.subtract(1,"d"))}}else{var s=this.$el.data("datetimepicker").date().clone();this.$el.data("datetimepicker").widget.find(".datepicker").is(":visible")?i(this.el).datetimepicker("date",s.add(7,"d")):i(this.el).datetimepicker("date",s.subtract(7,"m"))}else{var l=this.$el.data("datetimepicker").date().clone();this.$el.data("datetimepicker").widget.find(".datepicker").is(":visible")?i(this.el).datetimepicker("date",l.subtract(7,"d")):i(this.el).datetimepicker("date",l.add(7,"m"))}if(e.altKey&&84==e.keyCode&&(this.$el.data("datetimepicker").widget.find(".timepicker").is(":visible")?this.$el.data("datetimepicker").widget.find(".fa-calendar").click():this.$el.data("datetimepicker").widget.find(".fa-clock-o").click()),e.altKey&&38==e.keyCode){var o=this.$el.data("datetimepicker").date().clone();i(this.el).datetimepicker("date",o.add(1,"h"))}else if(e.altKey&&40==e.keyCode){var r=this.$el.data("datetimepicker").date().clone();i(this.el).datetimepicker("date",r.subtract(1,"h"))}27==e.keyCode&&(this.$el.datetimepicker("hide"),t=!0),t&&e.stopImmediatePropagation();9===e.keyCode&&this.el===e.target&&this.closeIt(e,!0)},closeIt:function(e,i){if(!this.is_closing&&!this.tabKeyPress){this.is_closing=!0,this.tabKeyPress=i;var n=this.formatter,a=this.model,s=this.column,o=this.$el.val(),r=n.toRaw(o,a);this.$el.datetimepicker("destroy"),this.is_closing=!1,(t.isUndefined(r)||""==String(o).replace(/^\s+|\s+$/g,""))&&(r=null),a.set(s.get("name"),r);var d=new l.Command(e);a.trigger("backgrid:edited",a,s,d)}}}),t.extend(E.prototype,N.prototype.defaults),l.Extension.StringDepCell=l.StringCell.extend({initialize:function(){l.StringCell.prototype.initialize.apply(this,arguments),l.Extension.DependentCell.prototype.initialize.apply(this,arguments)},dependentChanged:function(){this.$el.empty();var e=this,i=this.model,n=this.column,a=this.column.get("editable");this.render();var s=t.isFunction(a)?!!a.apply(n,[i]):!!a;return setTimeout((function(){e.$el.removeClass("editor"),s?e.$el.addClass("editable"):e.$el.removeClass("editable")}),10),this.delegateEvents(),this},remove:l.Extension.DependentCell.prototype.remove}),l.Extension.Select2DepCell=l.Extension.Select2Cell.extend({initialize:function(){l.Extension.Select2Cell.prototype.initialize.apply(this,arguments),l.Extension.DependentCell.prototype.initialize.apply(this,arguments)},dependentChanged:function(){var e=this.model,i=this.column,n=this.column.get("editable");return this.render(),(t.isFunction(n)?n.apply(i,[e]):n)?this.$el.addClass("editable"):this.$el.removeClass("editable"),this.delegateEvents(),this},remove:l.Extension.DependentCell.prototype.remove}),l.Extension.ClientSideFilter=l.Extension.ClientSideFilter.extend({$customSearchBox:null,template:function(e){return'<span class="search">&nbsp;</span><input type="search" '+(e.placeholder?'aria-label= "'+e.placeholder+'"':"")+" "+(e.placeholder?'placeholder="'+e.placeholder+'"':"")+' name="'+e.name+'" '+(e.value?'value="'+e.value+'"':"")+'/><a class="clear" data-backgrid-action="clear" href="#">&times;</a>'},searchBox:function(){return this.$customSearchBox?this.$customSearchBox:this.$el.find("input[type=search]")},setCustomSearchBox:function(e){return this.$customSearchBox=e,this.$customSearchBox.attr("type","search"),this.$customSearchBox.on("keydown",this.search.bind(this)),this.$customSearchBox.on("mousedown",this.search.bind(this)),this},unsetCustomSearchBox:function(){return this.$customSearchBox.off("keydown",this.search.bind(this)),this.$customSearchBox=null,this}});var T=l.BooleanCellFormatter=function(){};return t.extend(T.prototype,{fromRaw:function(e){return!t.isUndefined(e)&&!t.isNull(e)&&("1"===e||"True"===e||"0"!==e&&"False"!==e&&e)},toRaw:function(e){return e}}),l.BooleanCell=l.BooleanCell.extend({className:"boolean-cell",enterEditMode:function(){this.$el.addClass("editor"),i(this.$el.find("input[type=checkbox]")).trigger("focus")},exitEditMode:function(){this.$el.removeClass("editor")},events:{"change input":"onChange","blur input":"exitEditMode",keydown:"onKeyDown"},onChange:function(e){var t=this.model,i=this.column,n=this.formatter.toRaw(this.$input.prop("checked"),t);this.enterEditMode(),t.set(i.get("name"),n),t.trigger("backgrid:edited",t,i,new l.Command(e))},render:function(){this.$el.empty();var n=this.model,a=this.column,s=l.callByNeed(a.editable(),a,n),o=a.get("align_center")||!1,r=this.formatter.fromRaw(n.get(a.get("name")),n),d="column.get('name')_".concat(t.uniqueId());return this.$el.empty(),this.$el.append(i('<div class="custom-control custom-checkbox custom-checkbox-no-label '.concat(o?"text-center":"",'">\n          <input tabindex="0" type="checkbox" class="custom-control-input" id="').concat(d,'" ').concat(s?"":"disabled"," ").concat(r?"checked":"",'/>\n          <label class="custom-control-label" for="').concat(d,'">\n            <span class="sr-only">')+e("Select")+"<span>\n          </label>\n        </div>")),this.$input=this.$el.find("input"),this.delegateEvents(),this}}),l}.apply(t,s))||(e.exports=l)}).call(this,i(3),i(0))},355:function(e,t,i){"use strict";var n,a;function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}i(18),i(24),i(25),i(8),i(14),i(17),i(22),i(86),i(16),i(10),i(12),i(23),i(19),n=[i(1),i(3),i(0),i(21)],void 0===(a=function(e,t,i,n){t.Browser=t.Browser||{};var a=t.Browser.MenuItem=function(t){e.extend(this,{url:"#",target:"_self",enable:!0},e.pick(t,["name","label","priority","module","callback","data","enable","category","target","url","node","checked","menu_items"]))};e.extend(t.Browser.MenuItem.prototype,{$el:null,generate:function(e,t){return this.create_el(e,t),this.context={name:this.label,disabled:this.is_disabled,callback:this.context_menu_callback.bind(this,t)},this.$el},create_el:function(n,a){if(this.menu_items){e.each(this.menu_items,(function(e){e.generate(n,a)}));var s=t.Browser.MenuGroup({label:this.label,id:this.name},this.menu_items);this.$el=s.$el}else{var l=i("<a></a>",{id:this.name,href:this.url,target:this.target,"data-toggle":"pg-menu",role:"menuitem"}).data("pgMenu",{module:this.module||t.Browser,cb:this.callback,data:this.data}).addClass("dropdown-item");this.is_disabled=this.disabled(n,a),this.icon?l.append(i("<i></i>",{class:this.icon})):e.isUndefined(this.checked)||l.append(i("<i></i>",{class:"fa fa-check "+(this.checked?"":"visibility-hidden")})),l.addClass(this.is_disabled?" disabled":"");var o=i('<span data-test="menu-item-text"></span>').text("  "+this.label);l.append(o),this.$el=i("<li/>").append(l)}},update:function(e,t){this.$el&&!this.$el.find(".dropdown-item").hasClass("disabled")&&this.$el.find(".dropdown-item").addClass("disabled"),this.is_disabled=this.disabled(e,t),this.$el&&!this.is_disabled&&this.$el.find(".dropdown-item").removeClass("disabled"),this.context={name:this.label,disabled:this.is_disabled,callback:this.context_menu_callback.bind(this,t)}},context_menu_callback:function(e){var i,a=this;a.module.callbacks&&a.callback in a.module.callbacks?i=a.module.callbacks[a.callback]:a.callback in a.module&&(i=a.module[a.callback]),i?i.apply(a.module,[a.data,e]):t.Browser.report_error(n.sprintf('Developer Warning: Callback - "%s" not found!',a.cb))},disabled:function(t,i){if(null==this.enable)return!1;if(this.node){if(!t)return!0;if(e.isArray(this.node)?-1==e.indexOf(this.node,t):this.node!=t._type)return!0}return e.isBoolean(this.enable)?!this.enable:e.isFunction(this.enable)?!this.enable.apply(this.module,[t,i,this.data]):this.module&&e.isBoolean(this.module[this.enable])?!this.module[this.enable]:!(!this.module||!e.isFunction(this.module[this.enable]))&&!this.module[this.enable].apply(this.module,[t,i,this.data])},change_checked:function(t){e.isUndefined(this.checked)||(this.checked=t,this.checked?this.$el.find(".fa-check").removeClass("visibility-hidden"):this.$el.find(".fa-check").addClass("visibility-hidden"))}}),t.Browser.MenuGroup=function(t,n,a,s){var l,o=e.template(['<% if (above) { %><li class="dropdown-divider"></li><% } %>','<li class="dropdown-submenu" role="menuitem">',' <a href="#" class="dropdown-item">','  <% if (icon) { %><i class="<%= icon %>"></i><% } %>',"  <span><%= label %></span>"," </a>",' <ul class="dropdown-menu">'," </ul>","</li>",'<% if (below) { %><li class="dropdown-divider"></li><% } %>'].join("\n")),r={label:t.label,icon:t.icon,above:t.above&&!a,below:t.below},d=i(o(r)),c=d.find(".dropdown-menu"),u={},p=1;for(var h in s=e.uniqueId(s+"_sub_"),n.sort((function(e,t){return e.label.localeCompare(t.label)})),n.sort((function(e,t){return e.priority-t.priority})),n)l=n[h],c.append(l.$el),l.is_disabled||(u[s+p]=l.context),p++;var f=0==e.size(u);return{$el:d,priority:t.priority||10,label:t.label,above:r.above,below:t.below,is_disabled:f,context:{name:t.label,icon:t.icon,items:u,disabled:f}}},t.Browser.MenuCreator=function(i,n,s,l,o,r){var d,c={common:[]},u=0,p=e.uniqueId("ctx_"),h=function e(t){if(t instanceof a)t.$el&&(t.$el.remove(),delete t.$el),t.generate(l,o),(c[t.category||"common"]=c[t.category||"common"]||[]).push(t);else for(var i in t)e(t[i])},f=1;for(u in n)h(n[u]);r=r||{},d=c.common,delete c.common;var m=!0;for(var g in c){var v=c[g],b=s[g]||{label:g,single:!1},y=t.Browser.MenuGroup(b,v,m,p);if(v.length<=1&&!b.single)for(u in m=!1,v)d.push(v[u]);else m=v.below,d.push(y)}d.sort((function(e,t){return e.label.localeCompare(t.label)})),d.sort((function(e,t){return e.priority-t.priority}));var C=e.size(d);for(u in d){(o=d[u]).priority=o.priority||10,i.append(o.$el);var _=p+"_"+o.priority+"_"+f;1!=f&&o.above&&!o.is_disabled&&(r[_+"_ma"]="----"),o.is_disabled||(r[_+"_ms"]=o.context),p!=C&&o.below&&!o.is_disabled&&(r[_+"_mz"]="----"),f++}return C>0};var l=function e(t,n){this.$element=i(t),this.options=i.extend({},e.DEFAULTS,n),this.isLoading=!1};function o(e,t){return this.each((function(){var n=i(this),a=n.data("pg.menu"),o="object"==s(e)&&e;a||n.data("pg.menu",a=new l(this,o)),a.toggle(t)}))}l.DEFAULTS={},l.prototype.toggle=function(e){if(this.$element.closest(".dropdown-item").hasClass("disabled"))return e.preventDefault(),!1;var i=this.$element.data("pgMenu");if(i.cb){var n=i.module&&i.module.callbacks&&i.module.callbacks[i.cb]||i.module&&i.module[i.cb];n?(n.apply(i.module,[i.data,t.Browser.tree.selected()]),e.preventDefault()):t.Browser.report_error('Developer Warning: Callback - "'+i.cb+'" not found!')}};var r=i.fn.button;return i.fn.pgmenu=o,i.fn.pgmenu.Constructor=l,i.fn.pgmenu.noConflict=function(){return i.fn.pgmenu=r,this},i(document).on("click.pg.menu.data-api",'[data-toggle^="pg-menu"]',(function(e){var t=i(e.target);t.hasClass("dropdown-item")||(t=t.closest(".dropdown-item")),o.call(t,"toggle",e)})).on("focus.pg.menu.data-api blur.pg.menu.data-api",'[data-toggle^="pg-menu"]',(function(e){i(e.target).closest(".menu").toggleClass("focus",/^focus(in)?$/.test(e.type))})).on("mouseenter",".dropdown-submenu",(function(e){i(e.currentTarget).removeClass("dropdown-submenu-visible").addClass("dropdown-submenu-visible"),i(e.currentTarget).find(".dropdown-menu").first().addClass("show")})).on("mouseleave",".dropdown-submenu",(function(e){i(e.currentTarget).removeClass("dropdown-submenu-visible"),i(e.currentTarget).find(".dropdown-menu").first().removeClass("show")})).on("hidden.bs.dropdown",(function(e){i(e.target).find(".dropdown-submenu.dropdown-submenu-visible").removeClass("dropdown-submenu-visible").find(".dropdown-menu.show").removeClass("show")})),t.Browser.MenuItem}.apply(t,n))||(e.exports=a)},356:function(e,t,i){"use strict";var n,a;i(16),i(10),i(7),n=[i(1),i(3),i(0),i(60)],void 0===(a=function(e,t,i){var n=t.Browser=t.Browser||{},a=window.wcDocker,s=window.wcIFrame;return t.Browser.Frame=function(t){e.extend(this,e.pick(t,["name","title","width","height","showTitle","isCloseable","isPrivate","url","icon","onCreate"]))},e.extend(t.Browser.Frame.prototype,{name:"",title:"",width:300,height:600,showTitle:!0,isClosable:!0,isPrivate:!1,url:"",icon:"",panel:null,frame:null,onCreate:null,load:function(t){var l=this;l.panel||t.registerPanelType(this.name,{title:l.title,isPrivate:l.isPrivate,onCreate:function(t){i(t).data("pgAdminName",l.name),t.initSize(l.width,l.height),0==t.showTitle&&t.title(!1),t.icon(l.icon),t.closeable(!!l.isCloseable);var o=i('<div style="position:absolute;top:0 !important;width:100%;height:100%;display:table;z-index:0;">');t.layout().addItem(o),l.panel=t;var r=new s(o,t);i(t).data("frameInitialized",!1),i(t).data("embeddedFrame",r),""!=l.url&&"about:blank"!=l.url?setTimeout((function(){r.openURL(l.url),i(t).data("frameInitialized",!0),n.Events.trigger("pgadmin-browser:frame:urlloaded:"+l.name,r,l.url,self)}),50):(r.openURL("about:blank"),i(t).data("frameInitialized",!0),n.Events.trigger("pgadmin-browser:frame:urlloaded:"+l.name,r,l.url,self)),l.events&&e.isObject(l.events)&&e.each(l.events,(function(i,n){i&&e.isFunction(i)&&t.on(n,i)})),e.each([a.EVENT.UPDATED,a.EVENT.VISIBILITY_CHANGED,a.EVENT.BEGIN_DOCK,a.EVENT.END_DOCK,a.EVENT.GAIN_FOCUS,a.EVENT.LOST_FOCUS,a.EVENT.CLOSED,a.EVENT.BUTTON,a.EVENT.ATTACHED,a.EVENT.DETACHED,a.EVENT.MOVE_STARTED,a.EVENT.MOVE_ENDED,a.EVENT.MOVED,a.EVENT.RESIZE_STARTED,a.EVENT.RESIZE_ENDED,a.EVENT.RESIZED,a.EVENT.SCROLLED],(function(e){t.on(e,l.eventFunc.bind(t,e))})),l.onCreate&&e.isFunction(l.onCreate)&&l.onCreate.apply(l,[t,r])}})},eventFunc:function(e){var t=i(this).data("pgAdminName");try{n.Events.trigger("pgadmin-browser:frame",e,this,arguments),n.Events.trigger("pgadmin-browser:frame:"+e,this,arguments),t&&(n.Events.trigger("pgadmin-browser:frame-"+t,e,this,arguments),n.Events.trigger("pgadmin-browser:frame-"+t+":"+e,this,arguments))}catch(e){console.warn(e.stack||e)}}}),t.Browser.Frame}.apply(t,n))||(e.exports=a)},363:function(e,t,i){"use strict";var n,a;i(8),i(14),i(22),i(103),i(36),i(10),i(81),i(35),i(5),i(9),i(7),i(37),n=[i(2),i(1),i(0),i(15),i(76),i(62),i(50),i(3),i(84),i(135)],void 0===(a=function(e,t,i,n,a,s,l,o,r){var d=s.Row.extend({modelDuplicateClass:"bg-model-duplicate",initialize:function(){s.Row.prototype.initialize.apply(this,arguments);var e=this;e.model.on("change:name",(function(){setTimeout((function(){e.columns.each((function(t){if("value"==t.get("name")){e.model.set({value:void 0},{silent:!0});var i=e.columns.indexOf(t),n=new(t.get("cellFunction").apply(t,[e.model]))({column:t,model:e.model});e.cells[i].remove(),e.cells[i]=n,e.render()}}))}),10)})),e.listenTo(e.model,"pgadmin-session:model:duplicate",e.modelDuplicate),e.listenTo(e.model,"pgadmin-session:model:unique",e.modelUnique)},modelDuplicate:function(){i(this.el).removeClass("new"),i(this.el).addClass(this.modelDuplicateClass)},modelUnique:function(){i(this.el).removeClass(this.modelDuplicateClass)}}),c=r.VariableModel=r.Model.extend({keys:["name"],defaults:{name:void 0,value:void 0,role:null,database:null},schema:[{id:"name",label:e("Name"),type:"text",cellHeaderClasses:"width_percent_30",editable:function(e){return e instanceof n.Collection||e.isNew()},cell:s.Extension.NodeAjaxOptionsCell.extend({initialize:function(){s.Extension.NodeAjaxOptionsCell.prototype.initialize.apply(this,arguments);var e=t.clone(this.optionValues||(t.isFunction(this.column.get("options"))?this.column.get("options")(this):this.column.get("options")));this.column.set("options",e)}}),url:"vopts",select2:{allowClear:!1},transform:function(e,i){var n=[],a={};return t.each(e,(function(e){n.push({value:e.name,image:void 0,label:e.name}),a[e.name]=e})),i.column.set("availVariables",a),n}},{id:"value",label:e("Value"),type:"text",editable:!0,cellFunction:function(e){var i=e.get("name"),n={};this.collection.each((function(e){"name"==e.get("name")&&(n=e.get("availVariables"))}));var a=i?n[i]:void 0,l=e.get("value");switch(a&&a.vartype){case"bool":return e.set("value",!!e.get("value"),{silent:!0}),s.Extension.SwitchCell;case"enum":e.set({value:l},{silent:!0});var o=[],r=a.enumvals;return t.each(r,(function(e){o.push([e,e])})),s.Extension.Select2Cell.extend({optionValues:o});case"integer":return t.isNaN(parseInt(l))?e.set({value:void 0},{silent:!0}):e.set({value:parseInt(l)},{silent:!0}),s.IntegerCell;case"real":return t.isNaN(parseFloat(l))?e.set({value:void 0},{silent:!0}):e.set({value:parseFloat(l)},{silent:!0}),s.NumberCell.extend({decimals:0});case"string":return s.StringCell;default:return e.set({value:void 0},{silent:!0}),s.Cell}},cellHeaderClasses:"width_percent_40"},{id:"database",label:e("Database"),type:"text",editable:!0,node:"database",cell:s.Extension.NodeListByNameCell},{id:"role",label:e("Role"),type:"text",editable:!0,node:"role",cell:s.Extension.NodeListByNameCell}],toJSON:function(){var e=n.Model.prototype.toJSON.apply(this);return(t.isUndefined(e.database)||t.isNull(e.database))&&delete e.database,(t.isUndefined(e.role)||t.isNull(e.role))&&delete e.role,e},validate:function(){var i=null;return t.isUndefined(this.get("name"))||t.isNull(this.get("name"))||""==String(this.get("name")).replace(/^\s+|\s+$/g,"")?(i=e("Please select a parameter name."),this.errorModel.set("name",i)):t.isUndefined(this.get("value"))||t.isNull(this.get("value"))||""==String(this.get("value")).replace(/^\s+|\s+$/g,"")?(i=e("Please enter a value for the parameter."),this.errorModel.set("value",i),this.errorModel.unset("name")):(this.errorModel.unset("name"),this.errorModel.unset("value")),i}});return a.VariableCollectionControl=a.UniqueColCollectionControl.extend({hasDatabase:!1,hasRole:!1,initialize:function(e){var t=this,i=["name"];t.hasDatabase=e.field.get("hasDatabase"),t.hasRole=e.field.get("hasRole"),t.hasDatabase?i.push("database"):t.hasRole&&i.push("role"),e&&e.field&&(e.field instanceof a.Field?e.field.set({model:r.VariableModel.extend({keys:i})},{silent:!0}):e.field.extend({model:r.VariableModel.extend({keys:i})})),a.UniqueColCollectionControl.prototype.initialize.apply(t,arguments),t.availVariables={};var n=["name","value"];t.hasDatabase&&n.push("database"),t.hasRole&&n.push("role"),t.gridSchema=a.generateGridColumnsFromModel(t.field.get("node_info"),c.extend({keys:i}),"edit",n,t.field.get("schema_node")),t.getVariables()},getVariables:function(){var e=this,n=this.field.get("url"),a=e.model;if(this.field.get("version_compatible")&&n&&!a.isNew()){var s,l=e.field.get("node"),o=e.field.get("node_data"),r=e.field.get("node_info"),d=l.generate_url.apply(l,[null,n,o,!0,r]),c=e.collection.trackChanges;c&&e.collection.stopSession(),a.trigger("pgadmin-view:fetching",a,e.field),i.ajax({async:!1,url:d}).done((function(e){s=e.data})).fail((function(){a.trigger("pgadmin-view:fetch:error",a,e.field)})),a.trigger("pgadmin-view:fetched",a,e.field),s&&t.isArray(s)&&e.collection.reset(s,{silent:!0}),c&&e.collection.startNewSession()}},showGridControl:function(n){var a=this,l=t.template(["<div class='subnode-header'>","<span class='control-label'><%-label%></span>","<button class='btn btn-sm-sq btn-secondary add fa fa-plus' title='"+e("Add new row")+"' <%=canAdd ? '' : 'disabled=\"disabled\"'%>><span class=\"sr-only\">"+e("Add new row")+"</span></button>","</div>"].join("\n")),o=i("<div class='pgadmin-control-group backgrid form-group col-12 object subnode'></div>").append(l(n));a.grid&&a.grid.remove();var r=t.clone(this.gridSchema);t.each(r.columns,(function(e){"value"==e.name&&(e.availVariables=a.availVariables)})),0==n.disabled&&n.canDelete&&r.columns.unshift({name:"pg-backform-delete width_percent_5",label:"",cell:s.Extension.DeleteCell,editable:!1,cell_priority:-1}),a.collection.each((function(e){var t,i=e.get("name");if(i in a.availVariables)switch(a.availVariables[i].vartype){case"real":t=parseFloat(e.get("value")),e.set("value",isNaN(t)?void 0:t,{silent:!0});break;case"integer":t=parseInt(e.get("value")),e.set("value",isNaN(t)?void 0:t,{silent:!0})}}));var c=a.grid=new s.Grid({columns:r.columns,collection:a.collection,row:d,className:"backgrid table presentation table-bordered table-noouter-border table-hover"});return a.$grid=c.render().$el,o.append(a.$grid),n.disabled||0==n.canAdd||o.find("button.add").first().on("click",(function(e){if(e.preventDefault(),!t.isFunction(n.canAddRow)||n.canAddRow.apply(a,[a.model])){if(!!!a.field.get("allowMultipleEmptyRows")&&a.collection){var s=!1;if(a.collection.each((function(e){var i=[];t.each(e.attributes,(function(e){i.push(e)})),t.some(i,t.identity)||(s=!0)})),s)return!1}i(c.body.$el.find(i("tr.new"))).removeClass("new");var l=new n.model(null,{silent:!0,handler:a.collection,top:a.model.top||a.model,collection:a.collection,node_info:a.model.node_info});a.collection.add(l);var o=a.collection.indexOf(l),r=c.body.rows[o].$el;return r.addClass("new"),i(r).pgMakeVisible("backform-tab"),!1}})),o},addVariable:function(e){e.preventDefault();var t=new(this.field.get("model"))(this.headerData.toJSON(),{silent:!0,top:this.collection.top,handler:this.collection}),n=this.model.get(this.field.get("name"));n.add(t);var a=n.indexOf(t);if(a>-1){this.$grid.find(".new").removeClass("new");var s=this.grid.body.rows[a].$el;s.addClass("new"),i(s).pgMakeVisible("backform-tab")}return!1}}),c}.apply(t,n))||(e.exports=a)},371:function(e,t,i){"use strict";(function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}i(18),i(24),i(25),i(72),i(17),i(22),i(12),i(23),i(19),function(e){function i(e,i,n,a){return t.isUndefined(n)&&a.has_default_val?"<span class='pull-left disabled_cell'>[default]</span>":t.isUndefined(n)&&a.not_null||t.isUndefined(n)||null===n?"<span class='pull-left disabled_cell'>[null]</span>":null}e.extend(!0,window,{Slick:{Formatters:{JsonString:function(a,s,l,o,r){var d=i(a,s,l,o);if(d)return d;if("object"!==n(l)||Array.isArray(l)){if(Array.isArray(l)){var c=[];return e.each(l,(function(e,t){"object"===n(t)?c.push(JSON.stringify(t)):c.push(t)})),t.escape("["+c.join()+"]")}return t.escape(l)}return t.escape(JSON.stringify(l))},Numbers:function(e,i,n,a,s){var l=function(e,i,n,a){if(t.isUndefined(n)&&a.has_default_val)return"<span class='pull-right disabled_cell'>[default]</span>";if(t.isUndefined(n)&&a.not_null||t.isUndefined(n)||null===n)return"<span class='pull-right disabled_cell'>[null]</span>";return null}(0,0,n,a);return l||"<span style='float:right'>"+t.escape(n)+"</span>"},Checkmark:function(e,t,n,a,s){var l=i(e,t,n,a);return l||(n?"true":"false")},Text:function(e,n,a,s,l){var o=i(e,n,a,s);return o||t.escape(a)},Binary:function(e,n,a,s,l){var o=i(e,n,a,s);return o||"<span class='pull-left disabled_cell'>["+t.escape(a)+"]</span>"}}}})}(e)}).call(this,i(0),i(1))},372:function(e,t,i){"use strict";(function(e,t){i(18),i(24),i(25),i(8),i(72),i(17),i(22),i(43),i(12),i(5),i(23),i(29),i(82),i(19);var n=s(i(303)),a=s(i(2));function s(e){return e&&e.__esModule?e:{default:e}}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,i){function n(){return e("<div class='pg-text-editor' />")}function s(){return e("<textarea class='pg-textarea text-12' hidefocus rows=5'>")}function o(t){var i=e("<div class='pg_buttons' />"),n=t?(0,a.default)("Cancel"):(0,a.default)("OK");return e("<button class='btn "+(t?"btn-secondary":"btn-primary")+" long_text_editor pg-alertify-button' data-label=\""+n+'"><span class="fa '+(t?"fa-times":"fa-check")+' pg-alertify-button"></span>&nbsp;'+n+"</button>").appendTo(i),t&&e("<button class='btn btn-primary long_text_editor' data-label=\""+(0,a.default)("OK")+'"><span class="fa fa-check pg-alertify-button"></span>&nbsp;'+(0,a.default)("OK")+"</button>").appendTo(i),i}function r(t){return!(""!=(t=e.trim(t))&&("{"!=t.charAt(0)||"}"!=t.charAt(t.length-1)))}function d(e,n,a,s){var l=e.grid;if(n.is_row_copied){l.copied_rows||(l.copied_rows=[[]]);var o=l.getActiveCell(),r=o.row,d=o.cell,c=n[e.column.pos];c="number"===s&&t.isEmpty(c)||c,n[e.column.field]=a,c&&t.isNull(a)&&(t.isUndefined(l.copied_rows[r])||t.isUndefined(l.copied_rows[r][d]))&&(n[e.column.field]=void 0,null==l.copied_rows[r]&&(l.copied_rows[r]=[]),l.copied_rows[r][d]=1)}else n[e.column.field]="jsonb"===s&&null!=a?i.stringify(i.parse(a)):a}function c(e,t){var i=t.parent().find("#datagrid");e.top=e.top-t.height();var n=i.width(),a=t.width()+32;return(a+=e.left)>n&&(e.left-=a-n),e}e.extend(!0,window,{Slick:{Editors:{pgText:function(i){var l,u,p,h,f=this;this.init=function(){var t=e("body");u=n().appendTo(t),l=s().appendTo(u),(p=o(!0).appendTo(u)).find("button:first").on("click",this.cancel),p.find("button:last").on("click",this.save),l.on("keydown",this.handleKeyDown),f.position(i.position),l.trigger("focus").trigger("select")},this.handleKeyDown=function(t){t.which==e.ui.keyCode.ENTER&&t.ctrlKey?f.save():t.which==e.ui.keyCode.ESCAPE?(t.preventDefault(),f.cancel()):t.which==e.ui.keyCode.TAB&&t.shiftKey?(t.preventDefault(),i.grid.navigatePrev()):t.which==e.ui.keyCode.TAB&&(t.preventDefault(),i.grid.navigateNext())},this.save=function(){i.commitChanges()},this.cancel=function(){l.val(h),i.cancelChanges()},this.hide=function(){u.hide()},this.show=function(){u.show()},this.position=function(e){c(e,u),u.css("top",e.top).css("left",e.left)},this.destroy=function(){u.remove()},this.focus=function(){l.trigger("focus")},this.loadValue=function(e){t.isUndefined(e[i.column.field])||t.isNull(e[i.column.field])?l.val(h=""):i.column.is_array?(l.val(h=e[i.column.field]),l.trigger("select")):""===e[i.column.field]?l.val(h="''"):"''"===e[i.column.field]?l.val(h="\\'\\'"):'""'===e[i.column.field]?l.val(h='\\"\\"'):(l.val(h=e[i.column.field]),l.trigger("select"))},this.serializeValue=function(){var t=l.val();return""===t?null:i.column.is_array?e.trim(t):"''"===t||'""'===t?"":"\\'\\'"===t?"''":'\\"\\"'===t?'""':t},this.applyValue=function(e,t){d(i,e,t,"text")},this.isValueChanged=function(){return(""!=l.val()||!t.isUndefined(h))&&(!(""==l.val()&&t.isNull(h))&&l.val()!==h)},this.validate=function(){if(i.column.validator){var e=i.column.validator(l.val());if(!e.valid)return e}return i.column.is_array&&!r(l.val())?{valid:!1,msg:(0,a.default)('Arrays must start with "{" and end with "}"')}:{valid:!0,msg:null}},this.init()},JsonText:function(a){var r,u,p,h,f=this;this.init=function(){var t=e("body");u=n().appendTo(t),r=s().appendTo(u),(p=o(!0).appendTo(u)).find("button:first").on("click",this.cancel),p.find("button:last").on("click",this.save),r.on("keydown",this.handleKeyDown),f.position(a.position),r.trigger("focus").trigger("select")},this.handleKeyDown=function(t){t.which==e.ui.keyCode.ENTER&&t.ctrlKey?f.save():t.which==e.ui.keyCode.ESCAPE?(t.preventDefault(),f.cancel()):t.which==e.ui.keyCode.TAB&&t.shiftKey?(t.preventDefault(),a.grid.navigatePrev()):t.which==e.ui.keyCode.TAB&&(t.preventDefault(),a.grid.navigateNext())},this.save=function(){a.commitChanges()},this.cancel=function(){r.val(h),a.cancelChanges()},this.hide=function(){u.hide()},this.show=function(){u.show()},this.position=function(e){c(e,u),u.css("top",e.top).css("left",e.left)},this.destroy=function(){u.remove()},this.focus=function(){r.trigger("focus")},this.loadValue=function(t){var n=h=t[a.column.field];if("jsonb"!==a.column.column_type_internal||Array.isArray(n)||null==n){if(Array.isArray(n)){var s=[];e.each(n,(function(e,t){"object"===l(t)?s.push(i.stringify(t,null,4)):s.push(t)})),n="["+s.join()+"]"}}else n=i.stringify(i.parse(n),null,4);r.val(n),r.trigger("select")},this.serializeValue=function(){return""===r.val()?null:r.val()},this.applyValue=function(e,t){"jsonb"===a.column.column_type_internal?d(a,e,t,"jsonb"):d(a,e,t,"text")},this.isValueChanged=function(){return(""!=r.val()||!t.isUndefined(h))&&(!(""==r.val()&&t.isNull(h))&&r.val()!=h)},this.validate=function(){if("jsonb"===a.column.column_type_internal||"json"===a.column.column_type_internal)try{""!=r.val()&&JSON.parse(r.val())}catch(e){return r.addClass("pg-text-invalid"),{valid:!1,msg:e.message}}return r.removeClass("pg-text-invalid"),{valid:!0,msg:null}},this.init()},CustomNumber:function(i){var n,s;this.init=function(){(n=e("<input type=text class='editor-text' />")).on("keydown.nav",(function(t){t.keyCode!==e.ui.keyCode.LEFT&&t.keyCode!==e.ui.keyCode.RIGHT||t.stopImmediatePropagation()})),n.appendTo(i.container),n.trigger("focus").trigger("select")},this.destroy=function(){n.remove()},this.focus=function(){n.trigger("focus")},this.loadValue=function(e){s=e[i.column.field],!Array.isArray(s)||t.isNull(s)||t.isUndefined(s)?n.val(s):n.val("{"+s.join()+"}"),n[0].defaultValue=s,n.trigger("select")},this.serializeValue=function(){var e=n.val();return""===e?null:e},this.applyValue=function(e,t){d(i,e,t,"number")},this.isValueChanged=function(){return(""!=n.val()||!t.isUndefined(s))&&(""==n.val()&&""==s||!(""==n.val()&&t.isNull(s))&&n.val()!=s)},this.validate=function(){var e=n.val();if(!i.column.is_array&&isNaN(e))return{valid:!1,msg:(0,a.default)("Please enter a valid number")};if(i.column.validator){var t=i.column.validator(e);if(!t.valid)return t}if(i.column.is_array){if(!r(e))return{valid:!1,msg:(0,a.default)('Arrays must start with "{" and end with "}"')};var s,l=e.trim().slice(1,-1);for(var o in s=""==l?[]:l.split(","))if(isNaN(s[o]))return{valid:!1,msg:(0,a.default)("Please enter a valid number")}}return{valid:!0,msg:null}},this.init()},Checkbox:function(i){var n,a,s;this.init=function(){var t=this;(n=e("<div class='multi-checkbox' tabindex=\"0\"><span class='check' hideFocus></span></div>")).appendTo(i.container),n.trigger("focus"),n.on("click",this.changeValue),n.on("keydown",(function(i){i.which==e.ui.keyCode.SPACE&&(i.preventDefault(),t.changeValue(i))}))},this.changeValue=function(){var e=["unchecked","partial","checked"],t=n.find(".check").data("state")||0;t++,n.find(".check").removeClass("unchecked partial checked").addClass(e[t%e.length]).data("state",t%e.length)},this.destroy=function(){n.remove()},this.focus=function(){n.trigger("focus")},this.loadValue=function(e){a=e[i.column.field],s=1,t.isNull(a)||t.isUndefined(a)?n.find(".check").data("state",1).addClass("partial"):(a=!!e[i.column.field])?(n.find(".check").data("state",2).addClass("checked"),s=2):(n.find(".check").data("state",0).addClass("unchecked"),s=0)},this.serializeValue=function(){return 1==n.find(".check").data("state")?null:2==n.find(".check").data("state")},this.applyValue=function(e,t){e[i.column.field]=t},this.isValueChanged=function(){return n.find(".check").data("state")!==s},this.validate=function(){if(i.column.validator){var e=i.column.validator(this.serializeValue());if(!e.valid)return e}return{valid:!0,msg:null}},this.init()},ReadOnlyText:function(t){var i,n;this.init=function(){i=e("<input type=text class='editor-text' readonly/>").appendTo(t.container).on("keydown.nav",(function(t){t.keyCode!==e.ui.keyCode.LEFT&&t.keyCode!==e.ui.keyCode.RIGHT||t.stopImmediatePropagation()})).trigger("focus").trigger("select")},this.destroy=function(){i.remove()},this.focus=function(){i.trigger("focus")},this.getValue=function(){return i.val()},this.loadValue=function(e){var a=e[t.column.field];void 0===a&&void 0===a&&(a=""),n=a,i.val(n),i[0].defaultValue=n,i.trigger("select")},this.serializeValue=function(){return i.val()},this.applyValue=function(e,i){e[t.column.field]=i},this.isValueChanged=function(){return!(""==i.val()&&null==n)&&i.val()!=n},this.validate=function(){if(t.column.validator){var e=t.column.validator(i.val());if(!e.valid)return e}return{valid:!0,msg:null}},this.init()},ReadOnlyCheckbox:function(i){var n,a;this.init=function(){(n=e("<input type=checkbox value='true' class='editor-checkbox' hideFocus disabled>")).appendTo(i.container),n.trigger("focus")},this.destroy=function(){n.remove()},this.focus=function(){n.trigger("focus")},this.loadValue=function(e){a=e[i.column.pos],t.isNull(a)||t.isUndefined(a)?(n.prop("indeterminate",!0),n.data("checked",2)):(a=!!e[i.column.pos])?(n.prop("checked",!0),n.data("checked",0)):(n.prop("checked",!1),n.data("checked",1))},this.serializeValue=function(){return n.prop("indeterminate")?null:n.prop("checked")},this.applyValue=function(e,t){e[i.column.pos]=t},this.isValueChanged=function(){var e=n.data("checked");return!(2===e&&(null==a||null==a))&&e!==a},this.validate=function(){return{valid:!0,msg:null}},this.init()},ReadOnlypgText:function(t){var i,a,l,r=this;this.init=function(){var l=e("body");a=n().appendTo(l),i=s().appendTo(a),o(!1).appendTo(a).find("button:first").on("click",this.cancel),i.on("keydown",this.handleKeyDown),r.position(t.position),i.trigger("focus").trigger("select")},this.handleKeyDown=function(i){i.which==e.ui.keyCode.ENTER&&i.ctrlKey?r.cancel():i.which==e.ui.keyCode.ESCAPE?(i.preventDefault(),r.cancel()):i.which==e.ui.keyCode.TAB&&i.shiftKey?(r.cancel(),i.preventDefault(),t.grid.navigatePrev()):i.which==e.ui.keyCode.TAB&&(r.cancel(),i.preventDefault(),t.grid.navigateNext())},this.cancel=function(){i.val(l),t.cancelChanges()},this.hide=function(){a.hide()},this.show=function(){a.show()},this.position=function(e){c(e,a),a.css("top",e.top).css("left",e.left)},this.destroy=function(){a.remove()},this.focus=function(){i.trigger("focus")},this.loadValue=function(e){i.val(l=e[t.column.field]),i.trigger("select")},this.serializeValue=function(){return i.val()},this.applyValue=function(e,i){e[t.column.field]=i},this.isValueChanged=function(){return!(""==i.val()&&null==l)&&i.val()!=l},this.validate=function(){if(t.column.validator){var e=t.column.validator(i.val());if(!e.valid)return e}return{valid:!0,msg:null}},this.init()},ReadOnlyJsonText:function(t){var a,r,d,u=this;this.init=function(){var i=e("body");r=n().appendTo(i),a=s().appendTo(r),o(!1).appendTo(r).find("button:first").on("click",this.cancel),a.on("keydown",this.handleKeyDown),u.position(t.position),a.trigger("focus").trigger("select")},this.handleKeyDown=function(i){i.which==e.ui.keyCode.ENTER&&i.ctrlKey?u.cancel():i.which==e.ui.keyCode.ESCAPE?(i.preventDefault(),u.cancel()):i.which==e.ui.keyCode.TAB&&i.shiftKey?(u.cancel(),i.preventDefault(),t.grid.navigatePrev()):i.which==e.ui.keyCode.TAB&&(u.cancel(),i.preventDefault(),t.grid.navigateNext())},this.cancel=function(){a.val(d),t.cancelChanges()},this.hide=function(){r.hide()},this.show=function(){r.show()},this.position=function(e){c(e,r),r.css("top",e.top).css("left",e.left)},this.destroy=function(){r.remove()},this.focus=function(){a.trigger("focus")},this.loadValue=function(n){var s=d=n[t.column.field];if("jsonb"!==t.column.column_type_internal||Array.isArray(s)){if(Array.isArray(s)){var o=[];e.each(s,(function(e,t){"object"===l(t)?o.push(i.stringify(t,null,4)):o.push(t)})),s="["+o.join()+"]"}}else s=i.stringify(i.parse(s),null,4);a.val(s),a.trigger("select")},this.serializeValue=function(){return a.val()},this.applyValue=function(e,i){e[t.column.field]=i},this.isValueChanged=function(){return!(""==a.val()&&null==d)&&a.val()!=d},this.validate=function(){if(t.column.validator){var e=t.column.validator(a.val());if(!e.valid)return e}return{valid:!0,msg:null}},this.init()}}}})}(e,n.default)}).call(this,i(0),i(1))},431:function(e,t,i){"use strict";var n,a;i(16),i(10),i(7),n=[i(1),i(3),i(0),i(60)],void 0===(a=function(e,t,i){var n=t.Browser=t.Browser||{},a=window.wcDocker;return t.Browser.Panel=function(t){e.extend(this,e.pick(t,["name","title","width","height","showTitle","isCloseable","isPrivate","isLayoutMember","content","icon","events","onCreate","elContainer","canHide","limit","extraClasses"]))},e.extend(t.Browser.Panel.prototype,{name:"",title:"",width:300,height:600,showTitle:!0,isCloseable:!0,isPrivate:!1,isLayoutMember:!0,content:"",icon:"",panel:null,onCreate:null,elContainer:!1,limit:null,extraClasses:null,load:function(t,n){var s=this;s.panel||t.registerPanelType(s.name,{title:s.title,isPrivate:s.isPrivate,limit:s.limit,isLayoutMember:s.isLayoutMember,onCreate:function(t){if(i(t).data("pgAdminName",s.name),t.initSize(s.width,s.height),s.showTitle){var l='<a href="#" tabindex="-1" class="panel-link-heading">'+(n||s.title)+"</a>";t.title(l),""!=s.icon&&t.icon(s.icon)}else t.title(!1);var o=i("<div>",{class:"pg-panel-content"}).append(i(s.content));e.isNull("extraClasses")||o.addClass(s.extraClasses),t.closeable(!!s.isCloseable),t.layout().addItem(o),s.panel=t,s.events&&e.isObject(s.events)&&e.each(s.events,(function(i,n){i&&e.isFunction(i)&&t.on(n,i)})),e.each([a.EVENT.UPDATED,a.EVENT.VISIBILITY_CHANGED,a.EVENT.BEGIN_DOCK,a.EVENT.END_DOCK,a.EVENT.GAIN_FOCUS,a.EVENT.LOST_FOCUS,a.EVENT.CLOSED,a.EVENT.BUTTON,a.EVENT.ATTACHED,a.EVENT.DETACHED,a.EVENT.MOVE_STARTED,a.EVENT.MOVE_ENDED,a.EVENT.MOVED,a.EVENT.RESIZE_STARTED,a.EVENT.RESIZE_ENDED,a.EVENT.RESIZED,a.EVENT.SCROLLED],(function(e){t.on(e,s.eventFunc.bind(t,e))})),s.onCreate&&e.isFunction(s.onCreate)&&s.onCreate.apply(s,[t,o]),s.elContainer&&(t.pgElContainer=o,o.addClass("pg-el-container"),e.each([a.EVENT.RESIZED,a.EVENT.ATTACHED,a.EVENT.DETACHED,a.EVENT.VISIBILITY_CHANGED],(function(e){t.on(e,s.resizedContainer.bind(t))})),s.resizedContainer.apply(t)),s.canHide&&e.each([a.EVENT.CLOSED,a.EVENT.VISIBILITY_CHANGED],(function(e){t.on(e,s.handleVisibility.bind(t,e))}))}})},eventFunc:function(e){var t=i(this).data("pgAdminName");try{n.Events.trigger("pgadmin-browser:panel",e,this,arguments),n.Events.trigger("pgadmin-browser:panel:"+e,this,arguments),t&&(n.Events.trigger("pgadmin-browser:panel-"+t,e,this,arguments),n.Events.trigger("pgadmin-browser:panel-"+t+":"+e,this,arguments))}catch(e){console.warn(e.stack||e)}},resizedContainer:function(){var e=this;if(e.pgElContainer&&!e.pgResizeTimeout){if(!e.isVisible())return clearTimeout(e.pgResizeTimeout),void(e.pgResizeTimeout=null);e.pgResizeTimeout=setTimeout((function(){var t=e.width(),i="xs";e.pgResizeTimeout=null,t<480&&(i="xs"),t>=480&&(i="sm"),t>=768&&(i="md"),t>=992&&(i="lg"),t>=1200&&(i="xl"),e.pgElContainer.attr("el",i)}),100)}},handleVisibility:function(i){if("dashboard"==this._type&&!e.isUndefined(t.Dashboard))if("panelClosed"==i)t.Dashboard.toggleVisibility(!1,!0);else if("panelVisibilityChanged"==i&&n.tree){var a=n.tree.selected();e.isUndefined(t.Dashboard)||t.Dashboard.toggleVisibility(n.panels.dashboard.panel.isVisible()),a.length&&n.Events.trigger("pgadmin-browser:tree:selected",a,n.tree.itemData(a),n.Node)}}}),t.Browser.Panel}.apply(t,n))||(e.exports=a)},432:function(e,t,i){"use strict";var n,a;n=[i(2),i(1),i(50),i(3)],void 0===(a=function(e,t,i,n){return n.Browser=n.Browser||{},t.extend(n.Browser,{report_error:function(n,a,s){n=t.escape(n),a=t.escape(a),s=t.escape(s);var l='<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">           <div class="panel panel-default">           <div class="panel-heading" role="tab" id="headingOne">           <h4 class="panel-title">           <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">           '+e("Error message")+'</a>        </h4>        </div>        <div id="collapseOne" class="panel-collapse collapse show" role="tabpanel" aria-labelledby="headingOne">        <div class="panel-body" style="overflow: auto;">'+a+"</div>        </div>        </div>";null!=s&&""!=s&&(l+='<div class="panel panel-default">            <div class="panel-heading" role="tab" id="headingTwo">            <h4 class="panel-title">            <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">            '+e("Additional info")+'</a>          </h4>          </div>          <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">          <div class="panel-body" style="overflow: auto;">'+s+"</div>          </div>          </div>          </div>"),l+="</div>",i.alert(n,l).set("closable",!0)}}),n.Browser.report_error}.apply(t,n))||(e.exports=a)},433:function(e,t,i){"use strict";var n,a;function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}i(18),i(24),i(25),i(114),i(17),i(103),i(48),i(36),i(10),i(41),i(12),i(186),i(5),i(38),i(23),i(19),i(7),i(37),n=[i(1),i(3),i(0),i(15),i(21)],void 0===(a=function(e,t,i,n,a){var l=t.Browser=t.Browser||{};return l.DataModel=n.Model.extend({on_server:!1,parse:function(t){var i=this;t&&e.isObject(t)&&"node"in t&&t.node&&(i.tnode=e.extend({},t.node),delete t.node);return function a(s){s&&e.isArray(s)&&e.each(s,(function(s){var o,r;switch(s.type){case"collection":o=i.get(s.id),r=t[s.id],e.isArray(r)||e.isObject(r)?o&&o instanceof n.Collection?o.reset(r,{silent:!0,parse:!0,on_server:!0}):(o=new l.Node.Collection(r,{model:e.isString(s.model)&&s.model in l.Nodes?l.Nodes[s.model].model:s.model,top:i.top||i,handler:i,parse:!0,silent:!0,attrName:s.id}),i.set(s.id,o,{silent:!0,parse:!0,on_server:!0})):o=null,i.set(s.id,o,{silent:!0}),t[s.id]=o;break;case"model":o=i.get(s.id),r=t[s.id],e.isUndefined(r)||e.isNull(r)?o=null:(o&&o instanceof n.Model||(o=e.isString(s.model)&&s.model in l.Nodes[s.model]?new l.Nodes[s.model].Model(o,{silent:!0,top:i.top||i,handler:i,attrName:s.id}):new s.model(o,{silent:!0,top:i.top||i,handler:i,attrName:s.id})),o.set(r,{parse:!0,silent:!0})),t[s.id]=o;break;case"nested":a(s.schema)}}))}(i.schema),t},isNew:function(){return this.has(this.idAttribute)?!this.has(this.idAttribute):!this.on_server},primary_key:function(){if(this.keys&&e.isArray(this.keys)){var t={},i=this;return e.each(i.keys,(function(e){t[e]=i.attributes[e]})),JSON.stringify(t)}return this.cid},initialize:function(t,i){var a,s=this;s._previous_key_values={},!e.isUndefined(i)&&"on_server"in i&&i.on_server&&(s.on_server=!0),n.Model.prototype.initialize.apply(s,arguments),(e.isUndefined(i)||e.isNull(i))&&(i=t||{},t=null),s.sessAttrs={},s.fieldData={},s.origSessAttrs={},s.objects=[],s.arrays=[],s.attrName=i.attrName,s.top=i.top||s.collection&&s.collection.top||s.collection||s,s.handler=i.handler||s.collection&&s.collection.handler,s.trackChanges=!1,s.errorModel=new n.Model,s.node_info=i.node_info;var o=function t(i){i&&e.isArray(i)&&e.each(i,(function(i){switch(i.type){case"int":case"numeric":s.fieldData[i.id]={id:i.id,label:i.label,type:i.type,min:e.isUndefined(i.min)?void 0:i.min,max:e.isUndefined(i.max)?void 0:i.max};break;default:s.fieldData[i.id]={id:i.id,label:i.label,type:i.type}}switch(i.type){case"array":s.arrays.push(i.id);break;case"collection":if(!((a=s.get(i.id))&&a instanceof l.Node.Collection))if(e.isString(i.model)&&i.model in l.Nodes){var o=l.Nodes[i.model];a=new o.Collection(a,{model:o.model,top:s.top||s,handler:s,attrName:i.id})}else a=new l.Node.Collection(a,{model:i.model,top:s.top||s,handler:s,attrName:i.id});a.name=i.id,s.objects.push(i.id),s.set(i.id,a,{silent:!0});break;case"model":(a=s.get(i.id))&&a instanceof n.Model||(a=e.isString(i.model)&&i.model in l.Nodes[i.model]?new l.Nodes[i.model].Model(a,{top:s.top||s,handler:s,attrName:i.id}):new i.model(a,{top:s.top||s,handler:s,attrName:i.id})),a.name=i.id,s.objects.push(i.id),s.set(i.id,a,{silent:!0});break;case"nested":t(i.schema);break;default:return}}))};return o(s.schema),s.handler&&s.handler.trackChanges&&s.startNewSession(),"keys"in s&&e.isArray(s.keys)&&e.each(s.keys,(function(e){s.on("change:"+e,(function(t){s._previous_key_values[e]=t.previous(e)}))})),s},reset:function(e){var t,i=!(!e||!e.reindex);if(e&&e.stop&&this.stopSession(),i){for(var a in this.objects)(t=this.get(a))&&(t instanceof l.DataModel?t.reset(e):t instanceof n.Model?t.clear(e):t instanceof l.DataCollection?t.reset([],e):t instanceof n.Collection&&(t.each((function(i){i instanceof n.DataModel&&(t.reset(),t.clear(e))})),n.Collection.prototype.reset.call(t,[],e)));n.Collection.prototype.reset.apply(this,arguments)}},sessChanged:function(){var t=this;return e.size(t.sessAttrs)>0||e.some(t.objects,(function(i){var n=t.get(i);return!e.isNull(n)&&!e.isUndefined(n)&&n.sessChanged()}))},sessValid:function(){return(!("default_validate"in this)||"function"!=typeof this.default_validate||!e.isString(this.default_validate()))&&!("validate"in this&&e.isFunction(this.validate)&&e.isString(this.validate.apply(this)))},set:function(t,i,a){var l=e.isObject(t)?i:a;this._changing=!0,this._previousAttributes=e.clone(this.attributes),this.changed={};var o=n.Model.prototype.set.call(this,t,i,a);if(this._changing=!1,l&&l.internal||!this.trackChanges)return!0;if(null!=t&&o){var r,d={},c=this,u=function(t,i){i in c.objects||(d[i]=t,e.isEqual(c.origSessAttrs[i],t)||null===c.origSessAttrs[i]&&""===t?delete c.sessAttrs[i]:c.sessAttrs[i]=t)};return"object"===s(t)?e.each(t,u):u(i,t),c.trigger("pgadmin-session:set",c,d),a&&a.silent||c.trigger("change",c,a),"default_validate"in c&&"function"==typeof c.default_validate&&(r=c.default_validate()),"validate"in c&&"function"==typeof c.validate&&(r||(r=c.validate(e.keys(d)))),0==e.size(c.errorModel.attributes)?c.collection||c.handler?(c.collection||c.handler).trigger("pgadmin-session:model:valid",c,c.collection||c.handler):c.trigger("pgadmin-session:valid",c.sessChanged(),c):(r=r||e.values(c.errorModel.attributes)[0],c.collection||c.handler?(c.collection||c.handler).trigger("pgadmin-session:model:invalid",r,c,c.collection||c.handler):c.trigger("pgadmin-session:invalid",r,c)),o}return o},toJSON:function(t,i){var a,s=this,l=s.isNew();return!(t=void 0!==t&&1==t)||l?a=n.Model.prototype.toJSON.call(this,arguments):((a={})[s.idAttribute||"_id"]=s.get(s.idAttribute||"_id"),a=e.extend(a,s.sessAttrs)),e.each(s.objects,(function(e){var n=s.get(e);t?a[e]instanceof Array?a[e]=JSON.stringify(a[e]):n&&n.sessChanged&&n.sessChanged()||l?(a[e]=n&&n.toJSON(!l),n&&i&&"GET"==i&&(a[e]=JSON.stringify(a[e]))):delete a[e]:a[e]instanceof Array||(a[e]=n&&n.toJSON())})),t&&e.each(s.arrays,(function(e){a[e]&&a[e]instanceof Array&&(a[e]=JSON.stringify(a[e]))})),a},startNewSession:function(){var t=this;t.trackChanges&&(t.trigger("pgadmin-session:stop",t),t.off("pgadmin-session:model:invalid",t.onChildInvalid),t.off("pgadmin-session:model:valid",t.onChildValid),t.off("pgadmin-session:changed",t.onChildChanged),t.off("pgadmin-session:added",t.onChildChanged),t.off("pgadmin-session:removed",t.onChildChanged)),t.trackChanges=!0,t.sessAttrs={},t.origSessAttrs=e.clone(t.attributes),e.each(t.objects,(function(i){var n=t.get(i);e.isUndefined(n)||e.isNull(n)||(delete t.origSessAttrs[i],n&&"startNewSession"in n&&e.isFunction(n.startNewSession)&&n.startNewSession())})),t.trigger("pgadmin-session:start",t),t.on("pgadmin-session:model:invalid",t.onChildInvalid),t.on("pgadmin-session:model:valid",t.onChildValid),t.on("pgadmin-session:changed",t.onChildChanged),t.on("pgadmin-session:added",t.onChildChanged),t.on("pgadmin-session:removed",t.onChildChanged)},onChildInvalid:function(t,i){var n=this;if(n.trackChanges&&i){var a=i.attrName;if(!a){var s=i.primary_key&&"function"==typeof i.primary_key,l=s?i.primary_key():i.cid,o=s?function(e){var t=n.get("k");return!(!t||t.primary_key()!==l)&&(a=e,!0)}:function(e){return n.get(e).cid===l&&(a=e,!0)};e.findIndex(n.objects,o)}a&&(n.errorModel.set(a,t),n.handler?n.handler.trigger("pgadmin-session:model:invalid",t,n,n.handler):n.trigger("pgadmin-session:invalid",t,n))}return this},onChildValid:function(t){var i=this;if(i.trackChanges&&t){var a=t.attrName;if(!a){var s=t.primary_key&&"function"==typeof t.primary_key,l=s?t.primary_key():t.cid,o=s?function(e){var t=i.get("k");return!(!t||t.primary_key()!==l)&&(a=e,!0)}:function(e){var t=i.get("k");return!(!t||t.cid!==l)&&(a=e,!0)};e.findIndex(i.objects,o)}var r=null,d=function(t,i){return"default_validate"in t&&"function"==typeof t.default_validate&&(r=t.default_validate(),e.isString(r))?r:"validate"in t&&"function"==typeof t.validate?r=t.validate(i):null};if(t instanceof n.Collection){for(var c in t.models)if(d(t.models[c]))break}else t instanceof n.Model&&d(t);a&&i.errorModel.has(a)&&(r?i.errorModel.set(a,r):i.errorModel.unset(a)),0!=e.size(i.errorModel.attributes)||d(i,a&&[a])?(r=r||e.values(i.errorModel.attributes)[0],i.handler?i.handler.trigger("pgadmin-session:model:invalid",r,i,i.handler):i.trigger("pgadmin-session:invalid",r,i)):i.handler?i.handler.trigger("pgadmin-session:model:valid",i,i.handler):i.trigger("pgadmin-session:valid",i.sessChanged(),i)}},onChildChanged:function(){this.trackChanges&&this.collection&&this.collection.trigger("change",this)},stopSession:function(){var t=this;t.trackChanges&&(t.off("pgadmin-session:model:invalid",t.onChildInvalid),t.off("pgadmin-session:model:valid",t.onChildValid),t.off("pgadmin-session:changed",t.onChildChanged),t.off("pgadmin-session:added",t.onChildChanged),t.off("pgadmin-session:removed",t.onChildChanged)),t.trackChanges=!1,t.sessAttrs={},t.origSessAttrs={},e.each(t.objects,(function(i){var n=t.get(i);e.isUndefined(n)||e.isNull(n)||(t.origSessAttrs[i]=null,delete t.origSessAttrs[i],n&&"stopSession"in n&&e.isFunction(n.stopSession)&&n.stopSession())})),t.trigger("pgadmin-session:stop")},default_validate:function(){for(var t,i,n,a,s=0,l=e.keys(this.attributes),o=l.length;s<o;s++)if(n=this.attributes[l[s]],i=this.fieldData[l[s]],t=null,e.isUndefined(n)||e.isNull(n)||""===String(n))i&&this.errorModel.unset(i.id);else{if(!i)continue;if(!(a=i.type||void 0))continue;switch(a){case"int":t=this.integer_validate(n,i);break;case"numeric":t=this.number_validate(n,i)}if(t)return this.errorModel.set(i.id,t),t;this.errorModel.unset(i.id)}return null},check_min_max:function(i,n){var s=n.label,l=n.min,o=n.max;return!e.isUndefined(l)&&i<l?a.sprintf(t.Browser.messages.MUST_GR_EQ,s,l):!e.isUndefined(o)&&i>o?a.sprintf(t.Browser.messages.MUST_LESS_EQ,s,o):null},number_validate:function(e,i){return new RegExp("^-?[0-9]+(.?[0-9]*)?$").test(e)?this.check_min_max(e,i):a.sprintf(t.Browser.messages.MUST_BE_NUM,i.label)},integer_validate:function(e,i){return new RegExp("^-?[0-9]*$").test(e)?this.check_min_max(e,i):a.sprintf(t.Browser.messages.MUST_BE_INT,i.label)}}),l.DataCollection=n.Collection.extend({initialize:function(e,t){return t=t||{},this.sessAttrs={changed:[],added:[],deleted:[],invalid:[]},this.top=t.top||this,this.attrName=t.attrName,this.handler=t.handler,this.trackChanges=!1,this.on("add",this.onModelAdd),this.on("remove",this.onModelRemove),this.on("change",this.onModelChange),this.handler&&this.handler.trackChanges&&this.startNewSession(),this},startNewSession:function(){var t,i=this;i.trackChanges&&(i.trigger("pgadmin-session:stop",i),i.off("pgadmin-session:model:invalid",i.onModelInvalid),i.off("pgadmin-session:model:valid",i.onModelValid)),i.trackChanges=!0,i.sessAttrs={changed:[],added:[],deleted:[],invalid:[]},e.each(i.models,(function(n){"startNewSession"in n&&e.isFunction(n.startNewSession)&&n.startNewSession(),"default_validate"in n&&"function"==typeof n.default_validate&&(t=n.default_validate()),(e.isString(t)||"validate"in n&&"function"==typeof n.validate&&(t=n.validate()))&&(i.sessAttrs.invalid[n.cid]=t)})),i.trigger("pgadmin-session:start",i),i.on("pgadmin-session:model:invalid",i.onModelInvalid),i.on("pgadmin-session:model:valid",i.onModelValid)},onModelInvalid:function(e,t){var i=this.sessAttrs.invalid;return this.trackChanges&&(i[t.cid]=e,this.handler?this.handler.trigger("pgadmin-session:model:invalid",e,this,this.handler):this.trigger("pgadmin-session:invalid",e,this)),!0},onModelValid:function(e){var t=this.sessAttrs.invalid;if(this.trackChanges){var i=this.checkDuplicateWithModel(e);i&&e.cid in t&&delete t[e.cid],i&&this.triggerValidationEvent.apply(this)}return!0},stopSession:function(){this.trackChanges=!1,this.sessAttrs={changed:[],added:[],deleted:[],invalid:[]},e.each(this.models,(function(t){"stopSession"in t&&e.isFunction(t.stopSession)&&t.stopSession()}))},sessChanged:function(){return this.sessAttrs.changed.length>0||this.sessAttrs.added.length>0||this.sessAttrs.deleted.length>0},toJSON:function(t){if(t=void 0!==t&&1==t){var i={added:[]};return e.each(this.sessAttrs.added,(function(e){i.added.push(e.toJSON())})),0==i.added.length&&delete i.added,i.changed=[],e.each(this.sessAttrs.changed,(function(e){i.changed.push(e.toJSON(!0))})),0==i.changed.length&&delete i.changed,i.deleted=[],e.each(this.sessAttrs.deleted,(function(e){i.deleted.push(e.toJSON())})),0==i.deleted.length&&delete i.deleted,0==e.size(i)?null:i}return n.Collection.prototype.toJSON.call(this)},reset:function(e,t){t&&t.stop&&this.stopSession(),this.each((function(e){e&&(e instanceof l.DataModel?e.reset(t):e.clear(t))})),n.Collection.prototype.reset.apply(this,arguments)},objFindInSession:function(t,i){var n=t.primary_key&&"function"==typeof t.primary_key,a=n?t.primary_key():t.cid,s=n?function(e){return e.primary_key()===a}:function(e){return e.cid===a};return e.findIndex(this.sessAttrs[i],s)},onModelAdd:function(t){if(!this.trackChanges)return!0;var i,n=this.objFindInSession(t,"deleted");if(n>=0){var a=this.sessAttrs.deleted[n];t.origSessAttrs=e.clone(a.origSessAttrs),t.attributes=e.extend(t.attributes,a.attributes),t.sessAttrs=e.clone(a.sessAttrs),this.sessAttrs.deleted.splice(n,1),"sessChanged"in t&&!t.sessChanged()||this.sessAttrs.changed.push(t),(this.handler||this).trigger("pgadmin-session:added",this,t),"default_validate"in t&&"function"==typeof t.default_validate&&(i=t.default_validate()),(e.isString(i)||"validate"in t&&"function"==typeof t.validate&&(i=t.validate()))&&(this.sessAttrs.invalid[t.cid]=i)}else"default_validate"in t&&"function"==typeof t.default_validate&&(i=t.default_validate()),(e.isString(i)||"validate"in t&&"function"==typeof t.validate&&(i=t.validate()))&&(this.sessAttrs.invalid[t.cid]=i),this.sessAttrs.added.push(t),(this.handler||this).trigger("pgadmin-session:added",this,t);return this.triggerValidationEvent.apply(this),!0},onModelRemove:function(t){if(!this.trackChanges)return!0;t.errorModel.clear();var i=this.sessAttrs.invalid,n=e.clone(t),a=this.objFindInSession(t,"added");return t.cid in i&&delete i[t.cid],a>=0?(this.sessAttrs.added.splice(a,1),(this.handler||this).trigger("pgadmin-session:removed",this,n),this.checkDuplicateWithModel(n),this.triggerValidationEvent.apply(this),!0):((a=this.objFindInSession(t,"changed"))>=0?(this.sessAttrs.changed.splice(a,1),(this.handler||this).trigger("pgadmin-session:removed",this,n)):(this.handler||this).trigger("pgadmin-session:removed",this,n),this.sessAttrs.deleted.push(t),this.checkDuplicateWithModel(t),this.triggerValidationEvent.apply(this),!0)},triggerValidationEvent:function(){var e=null,t=this.sessAttrs.invalid,i=[];for(var n in t){if(e=t[n])break;i.push(n)}for(n in i)delete t[i[n]];e?this.handler?this.handler.trigger("pgadmin-session:model:invalid",e,this,this.handler):this.trigger("pgadmin-session:invalid",e,this):this.handler?this.handler.trigger("pgadmin-session:model:valid",this,this.handler):this.trigger("pgadmin-session:valid",this.sessChanged(),this)},onModelChange:function(e){if(!(this.trackChanges&&e instanceof l.Node.Model))return!0;var t=this.objFindInSession(e,"added");return t>=0?((this.handler||this).trigger("pgadmin-session:changed",this,e),!0):(t=this.objFindInSession(e,"changed"),"sessChanged"in e?t>=0?e.sessChanged()?((this.handler||this).trigger("pgadmin-session:changed",this,e),!0):(this.sessAttrs.changed.splice(t,1),(this.handler||this).trigger("pgadmin-session:changed",this,e),!0):(e.sessChanged()&&(this.sessAttrs.changed.push(e),(this.handler||this).trigger("pgadmin-session:changed",this,e)),!0):((this.handler||this).trigger("pgadmin-session:changed",this,e),t>=0||this.sessAttrs.changed.push(e),!0))},checkDuplicateWithModel:function(t){if(!("keys"in t)||e.isEmpty(t.keys))return!0;var i=this,n={},a={};e.each(t.keys,(function(e){n[e]=t.get(e),e in t._previous_key_values?a[e]=t._previous_key_values[e]:a[e]=t.previous(e)})),t._previous_key_values={};var s=i.where(a);if(1==s.length){var l=s[0];i.clearInvalidSessionIfModelValid(l)}var o=i.where(n);if(0==o.length)i.clearInvalidSessionIfModelValid(t);else{if(1!=o.length){var r="Duplicate rows.";return setTimeout((function(){e.each(o,(function(e){i.trigger("pgadmin-session:model:invalid",r,e,i.handler),e.trigger("pgadmin-session:model:duplicate",e,r)}))}),10),!1}i.clearInvalidSessionIfModelValid(t),i.clearInvalidSessionIfModelValid(o[0])}return!0},clearInvalidSessionIfModelValid:function(t){var i=t.errorModel.attributes,n=this.sessAttrs.invalid;t.trigger("pgadmin-session:model:unique",t),0==e.size(i)?delete n[t.cid]:n[t.cid]=i[Object.keys(i)[0]]}}),l.Events=e.extend({},n.Events),l}.apply(t,n))||(e.exports=a)},68:function(e,t,i){"use strict";var n,a;i(42),i(8),i(22),i(36),i(16),i(10),i(7),i(37),n=[i(2),i(1),i(0),i(15),i(76),i(62),i(50),i(84),i(21),i(135)],void 0===(a=function(e,t,i,n,a,s,l,o,r){var d=o.Model.extend({idAttribute:"privilege_type",defaults:{privilege_type:void 0,privilege:!1,with_grant:!1},validate:function(){return null}}),c=o.PrivilegeRoleModel=o.Model.extend({idAttribute:"grantee",defaults:{grantee:void 0,grantor:void 0,privileges:void 0},keys:["grantee","grantor"],privileges:[],schema:[{id:"grantee",label:e("Grantee"),type:"text",group:null,editable:!0,cellHeaderClasses:"width_percent_40",node:"role",options_cached:!1,disabled:function(e){return e instanceof n.Model&&!(e.top&&e.top.node_info&&e.top.node_info.server.user.name==e.get("grantor"))},transform:function(){var e=s.Extension.NodeListByNameCell.prototype.defaults.transform.apply(this,arguments);return e.unshift({label:"PUBLIC",value:"PUBLIC"}),e},cell:s.Extension.NodeListByNameCell.extend({initialize:function(e){var t=this,i=!0;e&&e.column&&e.column instanceof n.Model&&e.column.get("options_cached")&&(i=!1),s.Extension.NodeListByNameCell.prototype.initialize.apply(t,arguments),i&&(e=t.column.get("options"),t.column.set("options",t.omit_selected_roles.bind(t,e)));var a=function(e){var t=this;"grantee"in e.changed&&this.model.cid!=e.cid&&setTimeout((function(){t.render()}),50)}.bind(this);this.listenTo(t.model.collection,"change",a,this),this.listenTo(t.model.collection,"remove",a,this)},omit_selected_roles:function(e,i){var n=e(i),a={},s=i.model,l=s.cid,o=(t.has(s.top,"node_info")&&!t.isUndefined(s.top.node_info)?s.top.node_info:s.handler.top.node_info).server.user.name;return s.collection.each((function(e){var i=e.get("grantee");e.cid==l||t.isUndefined(i)||o!=e.get("grantor")||(a[i]=e.cid)})),n=t.filter(n,(function(e){return!(e.value in a)}))}})},{id:"privileges",label:e("Privileges"),type:"collection",model:d,group:null,cell:"privilege",control:"text",cellHeaderClasses:"width_percent_40",disabled:function(e){return!(e instanceof n.Collection)&&!(this.node_info&&this.node_info.server.user.name==e.get("grantor")||this.attributes.node_info.server.user.name==e.get("grantor"))}},{id:"grantor",label:e("Grantor"),type:"text",readonly:!0,cell:"node-list-by-name",node:"role"}],initialize:function(e,i){o.Model.prototype.initialize.apply(this,arguments),t.isNull(e)&&this.set("grantor",i&&i.top&&i.top.node_info&&i.top.node_info.server.user.name,{silent:!0});var n=this,a=n.get("privileges"),s=this.get("privileges")||{};t.isArray(s)&&(s=new o.Collection(a,{model:d,top:this.top||this,handler:this,silent:!0,parse:!1}),this.set("privileges",s,{silent:!0}));var l={};return t.each(n.privileges,(function(e){l[e]={privilege_type:e,privilege:!1,with_grant:!1}})),s.each((function(e){delete l[e.get("privilege_type")]})),t.each(l,(function(e){s.add(e,{silent:!0})})),n.on("change:grantee",n.granteeChanged),s.on("change",(function(){n.trigger("change:privileges",n)})),n},granteeChanged:function(){var e=this.get("privileges");"PUBLIC"==this.get("grantee")&&e.each((function(e){e.set("with_grant",!1,{silent:!0})}))},toJSON:function(){var e=[];return this.attributes&&!this.attributes.privileges?null:(this.attributes.privileges.each((function(t){t.get("privilege")&&e.push(t.toJSON())})),{grantee:this.get("grantee"),grantor:this.get("grantor"),privileges:e})},validate:function(){var i,n=null;if(t.isUndefined(this.get("grantee"))?(i=e("A grantee must be selected."),this.errorModel.set("grantee",i),n=i):this.errorModel.unset("grantee"),this.attributes&&this.attributes.privileges){var a=!1;this.attributes.privileges.each((function(e){e.get("privilege")&&(a=!0)})),a?this.errorModel.unset("privileges"):(i=e("At least one privilege should be selected."),this.errorModel.set("privileges",i),n=n||i)}return n}}),u=s.Extension.PrivilegeCellEditor=s.CellEditor.extend({tagName:"div",Labels:{C:"CREATE",T:"TEMPORARY",c:"CONNECT",a:"INSERT",r:"SELECT",w:"UPDATE",d:"DELETE",D:"TRUNCATE",x:"REFERENCES",t:"TRIGGER",U:"USAGE",X:"EXECUTE"},template:t.template(['<tr class="<%= header ? "header" : "" %>">',' <td class="renderable">','  <div class="custom-control custom-checkbox privilege-checkbox">','    <input tabindex="0" type="checkbox" class="custom-control-input" id="<%= checkbox_id %>" name="privilege" privilege="<%- privilege_type %>" target="<%- target %>" <%= privilege ? \'checked\' : "" %>/>','    <label class="custom-control-label" for="<%= checkbox_id %>">',"      <%- privilege_label %>","    </label>","  </div>"," </td>",' <td class="renderable">','  <div class="custom-control custom-checkbox privilege-checkbox">','    <input tabindex="0" type="checkbox" class="custom-control-input" id="wgo_<%= checkbox_id %>" name="with_grant" privilege="<%- privilege_type %>" target="<%- target %>" <%= with_grant ? \'checked\' : "" %> <%= enable_with_grant ? "" : \'disabled\'%>/>','    <label class="custom-control-label" for="wgo_<%= checkbox_id %>">',"      WITH GRANT OPTION","    </label>","  </div>"," </td>","</tr>"].join(" "),null,{variable:null}),events:{change:"privilegeChanged",blur:"lostFocus",keydown:"lostFocus"},render:function(){this.$el.empty(),this.$el.attr("tabindex","1"),this.$el.attr("target",this.elId);var e=this.model.get(this.column.get("name")),n=i("<table aria-label="+this.column.get("label")+"></table>").appendTo(this.$el),a=this,s=!0,l=!0,o=t.uniqueId();return e.each((function(e){var i=e.toJSON();s=s&&i.privilege,l=l&&s&&i.with_grant,t.extend(i,{target:a.cid,header:!1,privilege_label:a.Labels[i.privilege_type],with_grant:"PUBLIC"!=a.model.get("grantee")&&i.with_grant,enable_with_grant:"PUBLIC"!=a.model.get("grantee")&&i.privilege,checkbox_id:i.privilege_type+""+o}),s=s&&i.privilege,l=l&&s&&i.with_grant,n.append(a.template(i))})),e.length>1&&n.prepend(a.template({target:a.cid,privilege_label:"ALL",privilege_type:"ALL",privilege:s,with_grant:"PUBLIC"!=a.model.get("grantee")&&l,enable_with_grant:"PUBLIC"!=a.model.get("grantee")&&s,header:!0,checkbox_id:"all"+o})),a.$el.find("input[type=checkbox]").first().trigger("focus"),i(a.$el.find("input[type=checkbox]")).on("blur",(function(){a.$el.trigger("blur")})),i(a.$el).pgMakeVisible("backform-tab"),a.delegateEvents(),this},privilegeChanged:function(t){if(t&&t.target){var n,a,s,l=i(t.target),o=l.attr("privilege"),r=l.attr("name"),d=l.prop("checked"),c=l.closest("tr"),u=c.closest("table"),p=this.model.get("privileges"),h=this.model.get("grantee");if(this.undelegateEvents(),"ALL"==o){var f,m;s=c.find("input[name=with_grant]"),a=u.find("input[name=privilege][privilege!='ALL']"),n=u.find("input[name=with_grant][privilege!='ALL']"),"privilege"==r?(f=d,m=!1,d?(a.prop("checked",!0),"PUBLIC"==h?(n.prop("disabled",!0),s.prop("disabled",!0)):(n.prop("disabled",!1),s.prop("disabled",!1))):(a.prop("checked",!1),s.prop("checked",!1),n.prop("checked",!1),s.prop("disabled",!0),n.prop("disabled",!0))):(f=!0,m=d,n.prop("checked",d)),p.each((function(e){e.set({privilege:f,with_grant:m},{silent:!0})}))}else{var g={};a=(u=c.closest("table")).find("input[name=privilege][privilege='ALL']"),n=u.find("input[name=with_grant][privilege='ALL']"),g[r]=d,"privilege"==r?(s=l.closest("tr").find("input[name=with_grant]"),d?"PUBLIC"!=h&&s.prop("disabled",!1):(g.with_grant=!1,s.prop("checked",!1).prop("disabled",!0),a.prop("checked",!1),n.prop("disabled",!0),n.prop("checked",!1))):d||n.prop("checked",!1),p.get(o).set(g,{silent:!0}),d&&(a=u.find("input[name=privilege][privilege!='ALL']:checked")).length>1&&a.length==p.models.length&&(a.prop("checked",!0),"with_grant"==r?(n=u.find("input[name=with_grant][privilege!='ALL']:checked")).length==p.models.length&&(n.prop("disabled",!1),n.prop("checked",!0)):"PUBLIC"!=h&&n.prop("disabled",!1))}this.model.trigger("change",this.model);var v=!1,b=null;p.each((function(e){v=v||e.get("privilege")})),v?(this.model.errorModel.unset("privileges"),this.model.errorModel.has("grantee")&&(b=this.model.errorModel.get("grantee"))):(this.model.errorModel.set("privileges",e("At least one privilege should be selected.")),b=e("At least one privilege should be selected.")),b?this.model.collection.trigger("pgadmin-session:model:invalid",b,this.model):this.model.collection.trigger("pgadmin-session:model:valid",this.model)}this.delegateEvents()},lostFocus:function(e){var t=this,n=this.model,a=this.column,l=new s.Command(e),o=this.model.get(this.column.get("name"));if("Tab"==e.key&&r.handleKeyNavigation(event),l.moveUp()||l.moveDown()||l.save())return e.preventDefault(),e.stopPropagation(),void this.model.trigger("backgrid:edited",this.model,this.column,l);if(l.cancel())return e.stopPropagation(),void n.trigger("backgrid:edited",n,a,l);if(l.moveRight()){if(o.last().get("privilege_type")===i(e.target).attr("privilege")&&("privilege"===e.target.name&&!e.target.checked||"with_grant"===i(e.target).attr("name")))return e.stopPropagation(),void n.trigger("backgrid:edited",n,a,l)}else if(l.moveLeft()&&"privilege"===e.target.name&&"ALL"===i(e.target).attr("privilege"))return e.stopPropagation(),void n.trigger("backgrid:edited",n,a,l);setTimeout((function(){if(("DIV"==document.activeElement.tagName||"BUTTON"==document.activeElement.tagName)&&t.$el[0]!=document.activeElement&&!function(e,t){for(var i=t.parentNode;null!=i;){if(i==e)return!0;i=i.parentNode}return!1}(t.$el[0],document.activeElement)){var i=t.model;i.trigger("backgrid:edited",i,t.column,new s.Command(e))}}),10)}}),p=s.Extension.PrivilegeCellFormatter=function(){};return t.extend(p.prototype,{notation:{CREATE:"C",TEMPORARY:"T",CONNECT:"c",INSERT:"a",SELECT:"r",UPDATE:"w",DELETE:"d",TRUNCATE:"D",REFERENCES:"x",TRIGGER:"t",USAGE:"U",EXECUTE:"X"},fromRaw:function(e){var t="";return e instanceof n.Collection&&e.each((function(e){e.get("privilege")&&(t+=e.get("privilege_type"),e.get("with_grant")&&(t+="*"))})),t}}),s.Extension.PrivilegeCell=s.Cell.extend({className:"edit-cell",formatter:p,editor:u,initialize:function(){var e=this;s.Cell.prototype.initialize.apply(this,arguments),e.model.on("change:grantee",(function(){e.$el.hasClass("editor")||setTimeout((function(){e.render()}),10)}))},events:{click:"enterEditMode",keydown:"saveOrCancel"},saveOrCancel:function(e){var t=this.model,i=this.column,n=new s.Command(e);n.moveUp()||n.moveDown()||n.moveLeft()||n.moveRight()||n.save()?(e.preventDefault(),e.stopPropagation(),t.trigger("backgrid:edited",t,i,n)):n.cancel()&&(e.stopPropagation(),t.trigger("backgrid:edited",t,i,n))}}),c}.apply(t,n))||(e.exports=a)},84:function(e,t,i){"use strict";var n,a;i(8),i(14),i(17),i(22),i(195),i(36),i(28),i(16),i(12),i(5),i(29),i(19),i(7),i(37),n=[i(49),i(6),i(2),i(0),i(1),i(3),i(355),i(15),i(13),i(433),i(76),i(154),i(153),i(21),i(128),i(20)],void 0===(a=function(e,t,i,n,a,s,l,o,r,d,c,u,p,h){var f=window.wcDocker,m=13,g=27,v=112;return d.Node?d.Node:(d.Nodes=d.Nodes||{},d.Node=function(){},d.Node.extend=function(e,t){var i,n=this;if(i=function(){return n.apply(this,arguments)},a.extend(i,n,a.omit(e,"callbacks")),i.callbacks=a.extend({},n.callbacks,e.callbacks),!1===t)return i;for(var s,l=a.keys(i.callbacks),o=0;o<l.length;o++)s=l[o],"function"==typeof i.callbacks[s]&&(i.callbacks[s]=i.callbacks[s].bind(i));return i.Init.apply(i),this.Init.apply(i),i},a.extend(s.Browser.Node,o.Events,{type:void 0,label:"",sqlAlterHelp:"",sqlCreateHelp:"",dialogHelp:"",title:function(e,t){return e.label+(t?" - "+t.label:"")},hasId:!0,Init:function(){var e=this;if(!e.node_initialized){if(e.node_initialized=!0,s.Browser.add_menus([{name:"refresh",node:e.type,module:e,applies:["object","context"],callback:"refresh",priority:1,label:i("Refresh..."),icon:"fa fa-refresh"}]),e.canEdit&&s.Browser.add_menus([{name:"show_obj_properties",node:e.type,module:e,applies:["object","context"],callback:"show_obj_properties",priority:999,label:i("Properties..."),data:{action:"edit"},icon:"fa fa-pencil-square-o"}]),e.canDrop&&(s.Browser.add_menus([{name:"delete_object",node:e.type,module:e,applies:["object","context"],callback:"delete_obj",priority:e.dropPriority,label:e.dropAsRemove?i("Remove %s",e.label):i("Delete/Drop"),data:{url:"drop"},icon:"fa fa-trash",enable:a.isFunction(e.canDrop)?function(){return!!e.canDrop.apply(e,arguments)}:!!e.canDrop}]),e.canDropCascade&&s.Browser.add_menus([{name:"delete_object_cascade",node:e.type,module:e,applies:["object","context"],callback:"delete_obj",priority:3,label:i("Drop Cascade"),data:{url:"delete"},icon:"fa fa-trash",enable:a.isFunction(e.canDropCascade)?function(){return e.canDropCascade.apply(e,arguments)}:!!e.canDropCascade}])),-1==a.indexOf(s.unsupported_nodes,e.type)){var t=function(e){return!("database"!=e._type||!e.allowConn)||"database"!=e._type};s.Browser.add_menus([{name:"show_query_tool",node:e.type,module:e,applies:["context"],callback:"show_query_tool",priority:998,label:i("Query Tool..."),icon:"pg-font-icon icon-query-tool",enable:t}]),s.Browser.add_menus([{name:"search_objects",node:e.type,module:s.SearchObjects,applies:["context"],callback:"show_search_objects",priority:997,label:i("Search Objects..."),icon:"fa fa-search",enable:t}])}e.hasScriptTypes&&a.isArray(e.hasScriptTypes)&&e.hasScriptTypes.length>0&&a.each(e.hasScriptTypes,(function(t){var n=i("%s Script",t.toUpperCase());t=t.toLowerCase(),s.Browser.add_menus([{name:"show_script_"+t,node:e.type,module:e,applies:["object","context"],callback:"show_script",priority:4,label:n,category:i("Scripts"),data:{script:t},icon:"fa fa-pencil",enable:e.check_user_permission}])}))}},check_user_permission:function(e,t,i){if("server_group"==e._type||"server"==e._type)return!1;if("database"==e._type&&!e.allowConn)return!1;var n=d.Nodes[e._type].getTreeNodeHierarchy(t);return-1==a.indexOf(["create","insert","update","delete"],i.script)||(!("role"!=e.type||!n.server.user.can_create_role)||!!(n.server&&(n.server.user.is_superuser||n.server.user.can_create_db)||n.schema&&n.schema.can_create))},getView:function(e,t,s,l,o,u,p,f){var m=this;if(!this.type||""==this.type)return null;if(this.model){var g=this.generate_url(e,t,l,!1,null,m.url_jump_after_node);if(!g)return null;var v={};"create"!==t&&(v[this.model.idAttribute||this.model.prototype.idAttribute||"id"]=l._id);var b=this.getTreeNodeHierarchy.apply(this,[e]),y=new(this.model.extend({urlRoot:g}))(v,{node_info:b}),C=c.generateViewSchema(b,y,t,this,l);if("create"==t||"edit"==t){(u=u&&p?u.bind(p):function(){console.warn("Broke something!!! Why we don't have the callback or the context???")})(!1,!1),y.on("pgadmin-session:valid",(function(e){a.isUndefined(m.statusBar)||m.statusBar.empty().css("visibility","hidden"),u(!1,e)})),y.on("pgadmin-session:invalid",(function(e){var t='\n            <div class="error-in-footer">\n              <div class="d-flex px-2 py-1">\n                <div class="pr-2">\n                  <i class="fa fa-exclamation-triangle text-danger" aria-hidden="true" role="img"></i>\n                </div>\n                <div role="alert" class="alert-text">'.concat(e,'</div>\n                <div class="ml-auto close-error-bar">\n                  <a class="close-error fa fa-times text-danger"></a>\n                </div>\n              </div>\n            </div>');a.isUndefined(m.statusBar)||(m.statusBar.html(t).css("visibility","visible"),m.statusBar.find("a.close-error").bind("click",function(){this.empty().css("visibility","hidden")}.bind(m.statusBar)));var i=!1;return this.sessChanged&&this.sessChanged()&&(i=!0),u(!0,i),!0}))}if(a.size(C)){var _;_="fieldset"==o?new c.Accordian({el:s,model:y,schema:C}):new c.Dialog({el:s,model:y,schema:C});var w=function(){var e=n(s).find(".tab-content:first > .tab-pane.active:first");h.findAndSetFocus(e)};if(y.isNew())_.render(),w(),y.startNewSession();else{var x='<div role="status" class="pg-panel-message pg-panel-properties-message">'+i("Retrieving data from the server...")+"</div>",k=n(x),N=setTimeout((function(e){a.isUndefined(e)||k.appendTo(e)}),1e3,p);!function t(){y.fetch({success:function(){clearTimeout(N),k.addClass("d-none"),_.render(),w(),y.startNewSession()},error:function(n,a,s){var l=m&&e?m.getTreeNodeHierarchy(e)[m.type].label:"";d.Events.trigger("pgadmin:node:retrieval:error","properties",a,s.textStatus,s.errorThrown,e),r.pgHandleItemError(a,s.textStatus,s.errorThrown,{item:e,info:b})||r.pgNotifier(s.textStatus,a,i("Error retrieving properties - %s",s.errorThrown||l),(function(e){"CRYPTKEY_SET"===e?t():console.warn(arguments)})),f&&f()}})}()}}return _}return null},register_node_panel:function(){var e=d.docker.findPanels("node_props");if(!e||1!=e.length){var t={};t[f.EVENT.RESIZE_ENDED]=function(){var e=this.$container.find(".obj_properties").first(),t=e.data("obj-view");t&&t.model&&t.model&&t.model.trigger("pg-browser-resized",{view:t,panel:this,container:e})},(e=new d.Panel({name:"node_props",showTitle:!0,isCloseable:!0,isPrivate:!0,isLayoutMember:!1,elContainer:!0,content:'<div class="obj_properties container-fluid"><div role="status" class="pg-panel-message">'+i("Please wait while we fetch information about the node from the server...")+"</div></div>",onCreate:function(e,t){t.addClass("pg-no-overflow")},events:t})).load(d.docker)}},hasScriptTypes:["create"],canEdit:!0,canDrop:!1,canDropCascade:!1,dropAsRemove:!1,dropPriority:2,callbacks:{show_obj_properties:function(e,t){var n=d.tree,l=e&&e.item||t||n.selected(),o=l&&1==l.length?n.itemData(l):void 0,c=this,u=c.title.apply(this,[o]);if(d.Node.register_node_panel(),o){var p=this,m=a.isArray(this.parent_type)?function(e){return-1!=a.indexOf(p.parent_type,e._type)}:function(e){return p.parent_type==e._type},g=function(){var e,t,i,n,a=window.document,l=a.body,o=a.createElement("div");a.body.insertBefore(o,a.body.firstChild),e=screen.width<800?s.toPx(o,"95%","width",!0):(e=s.toPx(o,p.width||d.stdW.default+"px","width",!0))<=d.stdW.sm?d.stdW.sm:e<=d.stdW.md?d.stdW.md:d.stdW.lg,t=screen.height<600?s.toPx(o,"95%","height",!0):(t=s.toPx(o,p.height||d.stdH.default+"px","height",!0))<=d.stdH.sm?d.stdH.sm:t<=d.stdH.md?d.stdH.md:d.stdH.lg,i=(l.offsetWidth-e)/2,n=(l.offsetHeight-t)/4;var r=d.docker.addPanel("node_props",f.DOCK.FLOAT,void 0,{w:e+"px",h:t+"px",x:i+"px",y:n+"px"});return l.removeChild(o),r};if("create"==e.action){if(p.parent_type&&!m(o))for(;l&&n.hasParent(l);){l=n.parent(l);var v=n.itemData(l);if(m(v)){o=v;break}}if(!o||null!=this.parent_type&&!m(o))return;if(!o)return;u=i("Create - %s",this.label),b=g(),setTimeout((function(){c.showProperties(l,o,b,e.action)}),10)}else if(d.Node.panels&&d.Node.panels[o.id]&&d.Node.panels[o.id].$container){var b=d.Node.panels[o.id];if(b.$container.attr("action-mode")){var y=i('Are you sure want to stop editing the properties of %s "%s"?');"edit"==e.action&&(y=i('Are you sure want to reset the current changes and re-open the panel for %s "%s"?')),r.confirm(i("Edit in progress?"),h.sprintf(y,c.label.toLowerCase(),o.label),(function(){setTimeout((function(){c.showProperties(l,o,b,e.action)}),10)}),null).show()}else setTimeout((function(){c.showProperties(l,o,b,e.action)}),10)}else d.Node.panels=d.Node.panels||{},b=d.Node.panels[o.id]=g(),setTimeout((function(){c.showProperties(l,o,b,e.action)}),10);b.title(u),b.icon("icon-"+this.type),b.focus()}},delete_obj:function(e,t){var s=e||{url:"drop"},l=this,o=d.tree,c=s.item||t||o.selected(),u=c&&1==c.length?o.itemData(c):void 0;if(u){l=d.Nodes[u._type];var p,h,f=u.label;if("delete"==s.url){if(p=i('Are you sure you want to drop %s "%s" and all the objects that depend on it?',l.label.toLowerCase(),u.label),h=i("DROP CASCADE %s?",l.label),!(a.isFunction(l.canDropCascade)?l.canDropCascade.apply(l,[u,c]):l.canDropCascade))return void r.error(i('The %s "%s" cannot be dropped.',l.label,u.label),10)}else if(l.dropAsRemove?(p=i('Are you sure you want to remove %s "%s"?',l.label.toLowerCase(),u.label),h=i("Remove %s?",l.label)):(p=i('Are you sure you want to drop %s "%s"?',l.label.toLowerCase(),u.label),h=i("Drop %s?",l.label)),!(a.isFunction(l.canDrop)?l.canDrop.apply(l,[u,c]):l.canDrop))return void r.error(i('The %s "%s" cannot be dropped/removed.',l.label,u.label),10);r.confirm(h,p,(function(){n.ajax({url:l.generate_url(c,s.url,u,!0),type:"DELETE"}).done((function(e){return 0==e.success?d.report_error(e.errormsg,e.info):d.removeTreeNode(c,!0),!0})).fail((function(e){var t=e.responseText;if(417==e.status||410==e.status||500==e.status)try{t=JSON.parse(e.responseText).errormsg}catch(e){console.warn(e.stack||e)}d.report_error(i('Error dropping/removing %s: "%s"',l.label,f),t)}))}),null).set("labels",{ok:i("Yes"),cancel:i("No")}).show()}},show_script:function(e,t){var i,n=e.script,a=this,l=d.tree,o=t||l.selected(),r=o&&1==o.length?l.itemData(o):void 0;r&&(a=d.Nodes[r._type],i="insert"==n?"insert_sql":"update"==n?"update_sql":"delete"==n?"delete_sql":"select"==n?"select_sql":"exec"==n?"exec_sql":"sql",s.DataGrid.show_query_tool(a.generate_url(o,i,r,!0),o,n))},show_query_tool:function(e,t){var i=d.tree,n=t||i.selected();(n&&1==n.length?i.itemData(n):void 0)&&s.DataGrid.show_query_tool("",n)},change_server_background:function(e,t){if(e&&t&&t&&t._type&&"server"==t._type){var i=n(e).find("span.aciTreeItem").first()||null,a=t.icon.split(" ")[1]||null,s=t.icon.split(" ")[2]||"";if(a){var l,o=i.parents()[3]||null,r="pga_server_"+t._id+"_bgcolor";l="<style id="+r+" type='text/css'> \n",l+="."+r+" .aciTreeItem {",l+=" border-radius: 3px; margin-bottom: 2px;",l+=" background: "+a+"} \n",s&&(l+="."+r+" .aciTreeText {",l+=" color: "+s+";} \n"),l+="</style>",n("#"+r).remove(),n(l).appendTo("head"),o&&n(o).addClass(r)}}},added:function(e,t,i){var n=(i||d).tree,s=n.parent(e),l=s&&n.itemData(s),o=l&&d.Nodes[l._type];o&&o.is_collection&&("collection_count"in l||(l.collection_count=0),l.collection_count++,n.setLabel(s,{label:a.escape(l._label)+" <span>("+l.collection_count+")</span>"})),d.Events.trigger("pgadmin:browser:tree:expand-from-previous-tree-state",e),d.Node.callbacks.change_server_background(e,t)},selected:function(e,t,i){var n=i||d,a=n.tree,l=t||a.itemData(e);return s.Browser.enable_disable_menus.apply(n,[e]),l&&n&&"properties"in n.panels&&n.panels.properties&&n.panels.properties.panel&&n.panels.properties.panel.isVisible()&&this.showProperties(e,l,n.panels.properties.panel),d.Events.trigger("pgadmin:browser:tree:update-tree-state",e),!0},removed:function(e){var t=this,i=d.tree,n=i.parent(e),s=n&&i.itemData(n),l=s&&d.Nodes[s._type];l&&l.is_collection&&"collection_count"in s&&(s.collection_count--,i.setLabel(n,{label:a.escape(s._label)+" <span>("+s.collection_count+")</span>"})),setTimeout((function(){t.clear_cache.apply(t,e)}),0)},unloaded:function(e){var t=d.tree,i=e&&t.itemData(e);this.is_collection&&"collection_count"in i&&(delete i.collection_count,t.setLabel(e,{label:a.escape(i._label)}))},refresh:function(e,t){var i=this,a=d.tree,s=t&&a.itemData(t);n(d.panels.properties.panel).removeData("node-prop"),d.Events.trigger("pgadmin:browser:tree:refresh",t||d.tree.selected(),{success:function(){i.callbacks.selected.apply(i,[t,s,d])}})},opened:function(e){var t=d.tree,i=d.get_preference("browser","auto_expand_sole_children");d.Events.trigger("pgadmin:browser:tree:update-tree-state",e),i&&1==i.value&&1==t.children(e).length&&t.open(t.first(e))},closed:function(e){d.Events.trigger("pgadmin:browser:tree:remove-from-tree-state",e)}},showProperties:function(e,t,l,o){var c=this,u=s.Browser.tree,h=l.$container.find(".obj_properties").first(),b=h.data("obj-view"),y=n("<div></div>").addClass("pg-prop-content col-12"),C=!0,_=function(e,t){if(!l||"node_props"===l._type)switch(e.which){case g:$(!0);break;case m:if(e.target!==t)return;if(b&&b.model&&b.model.sessChanged()){var i=n(e.target).closest(".obj_properties").find(".pg-prop-btn-group").find("button.btn-primary");I.call(this,b,i)}break;case v:E()}}.bind(l);setTimeout((function(){l.$container.find(".backform-tab").on("keydown",(function(e){_(e,this)}))}),200);var w=function(e){var t=n('<div role="status"></div>').addClass("pg-prop-status-bar").appendTo(h);return t.css("visibility","hidden"),"header"==e?t.appendTo(c.header):t.prependTo(c.footer),c.statusBar=t,t}.bind(l),x=function(e,t,i){if(e&&a.isArray(e)&&e.length>0){var s=n('<div class="pg-prop-btn-group"></div>'),l=a.template(['<button tabindex="0" type="<%= type %>" ',"class=\"btn <%=extraClasses.join(' ')%>\"",'<% if (disabled) { %> disabled="disabled"<% } %> title="<%-tooltip%>"','<% if (label != "") {} else { %> aria-label="<%-tooltip%>"<% } %> >','<span class="<%= icon %>"></span><% if (label != "") { %>&nbsp;<%-label%><% } %></button>'].join(" "));return"header"==t?s.appendTo(c.header):s.appendTo(c.footer),i&&s.addClass(i),a.each(e,(function(e){e.icon||(e.icon="");var t=n(l(e));s.append(t),e.register(t)})),s}return null}.bind(l),k=function(){var s=u.selected(),l=s&&u.itemData(s),o=(s&&l&&d.Nodes[l._type]).getTreeNodeHierarchy(s);if(!a.isEqual(n(this).data("node-prop"),o)){if(n(this).data("node-prop",o),y.hasClass("has-pg-prop-btn-group")||y.addClass("has-pg-prop-btn-group"),b&&(b.remove({data:!0,internal:!0,silent:!0}),b=null,h.data("obj-view",null)),h.empty(),c.header=n("<div></div>").addClass("pg-prop-header").appendTo(h),c.footer=n("<div></div>").addClass("pg-prop-footer").appendTo(h),b=c.getView(e,"properties",y,t,"fieldset",void 0,h)){h.data("obj-view",b);var r=[];r.push({label:i("Edit"),type:"edit",tooltip:i("Edit"),extraClasses:["btn","btn-primary","pull-right","m-1"],icon:"fa fa-sm fa-pencil",disabled:!c.canEdit,register:function(e){e.on("click",(function(){B()}))}}),r.push({label:"",type:"help",tooltip:i("SQL help for this object type."),extraClasses:["btn-secondary","btn-secondary","m-1"],icon:"fa fa-lg fa-info",disabled:""==c.sqlAlterHelp&&""==c.sqlCreateHelp,register:function(e){e.on("click",(function(){N()}))}}),x(r,"header","pg-prop-btn-group-above")}h.append(y)}}.bind(l),N=function(){var t=c.getTreeNodeHierarchy(e).server,i=d.utils.pg_help_path;"ppas"==t.server_type&&(i=d.utils.edbas_help_path);var n="";n=""==c.sqlCreateHelp&&""!=c.sqlAlterHelp?p.getHelpUrl(i,c.sqlAlterHelp,t.version):""!=c.sqlCreateHelp&&""==c.sqlAlterHelp||b.model.isNew()?p.getHelpUrl(i,c.sqlCreateHelp,t.version):p.getHelpUrl(i,c.sqlAlterHelp,t.version),window.open(n,"postgres_help")}.bind(l),E=function(){window.open(c.dialogHelp,"pgadmin_help")}.bind(l),T=function(e,t){var n=this.$container.find(".obj_properties").first(),a=n&&n.data("obj-view"),s=this;return d.get_preferences_for_module("browser").confirm_on_properties_close&&C&&a&&a.model?!a.model.sessChanged()||void r.confirm(i("Warning"),e,(function(){return setTimeout(function(){t()}.bind(s),50),!0}),(function(){return!0})).set("labels",{ok:i("Yes"),cancel:i("No")}).show():(t(),!0)}.bind(l),S=function(e){var t,n=this.$container.find(".obj_properties").first(),s=n&&n.data("obj-view"),l=this;return!s||!s.model||a.isUndefined(s.model.warn_text)||a.isNull(s.model.warn_text)?(e(),!0):(t=i(s.model.warn_text),!s.model.sessChanged()||void r.confirm(i("Warning"),t,(function(){return setTimeout(function(){e()}.bind(l),50),!0}),(function(){return!0})).set("labels",{ok:i("Yes"),cancel:i("No")}).show())}.bind(l),I=function(e,t){var s=e.model,l=s.toJSON(!0),o=setTimeout((function(){n(".obj_properties").addClass("show_progress")}),1e3);t&&n(t).prop("disabled",!0),l&&!a.isEmpty(l)&&s.save({},{attrs:l,validate:!1,cache:!1,wait:!0,success:function(){O.call(),n(".obj_properties").removeClass("show_progress"),clearTimeout(o);var e=d.docker.findPanels("properties")[0],t=d.docker.findPanels("sql")[0],i=d.docker.findPanels("statistics")[0],a=d.docker.findPanels("dependencies")[0],s=d.docker.findPanels("dependents")[0];e&&n(e).removeData("node-prop"),t&&n(t).removeData("node-prop"),i&&n(i).removeData("node-prop"),a&&n(a).removeData("node-prop"),s&&n(s).removeData("node-prop")},error:function(e,a){r.pgNotifier("error",a,i("Error saving properties")),n(".obj_properties").removeClass("show_progress"),clearTimeout(o),t&&n(t).prop("disabled",!1)}})}.bind(l),D=function(){var s=this;o&&"properties"==o&&(o="edit"),s.$container.attr("action-mode",o),b&&(b.remove({data:!0,internal:!0,silent:!0}),b=null,h.data("obj-view",null)),h.empty(),c.header=n("<div></div>").addClass("pg-prop-header").appendTo(h),c.footer=n("<div></div>").addClass("pg-prop-footer").appendTo(h);(b=c.getView(e,o,y,t,"dialog",(function(e,t){var i=this.find(".pg-prop-btn-group"),n=i.find("button.btn-primary"),a=i.find('button.btn-secondary[type="reset"]');e||!t?(n.prop("disabled",!0),n.attr("disabled","disabled")):(n.prop("disabled",!1),n.removeAttr("disabled")),t?(a.prop("disabled",!1),a.removeAttr("disabled")):(a.prop("disabled",!0),a.attr("disabled","disabled"))}),h,M))&&(h.data("obj-view",b),s.icon(a.isFunction(c.node_image)?c.node_image.apply(c,[t,b.model]):c.node_image||"icon-"+c.type),x([{label:"",type:"help",tooltip:i("SQL help for this object type."),extraClasses:["btn-secondary","pull-left","mx-1"],icon:"fa fa-lg fa-info",disabled:""==c.sqlAlterHelp&&""==c.sqlCreateHelp,register:function(e){e.on("click",(function(){N()}))}},{label:"",type:"help",tooltip:i("Help for this dialog."),extraClasses:["btn-secondary","pull-left","mx-1"],icon:"fa fa-lg fa-question",disabled:""==c.dialogHelp,register:function(e){e.on("click",(function(){E()}))}},{label:i("Cancel"),type:"cancel",tooltip:i("Cancel changes to this object."),extraClasses:["btn-secondary","mx-1"],icon:"fa fa-close pg-alertify-button",disabled:!1,register:function(e){e.on("click",(function(){s.$container.removeAttr("action-mode"),M.call(!0)}))}},{label:i("Reset"),type:"reset",tooltip:i("Reset the fields on this dialog."),extraClasses:["btn-secondary","mx-1"],icon:"fa fa-recycle pg-alertify-button",disabled:!0,register:function(e){e.on("click",(function(){T.call(s,i("Changes will be lost. Are you sure you want to reset?"),(function(){setTimeout((function(){D.call()}),0)}))}))}},{label:i("Save"),type:"save",tooltip:i("Save this object."),extraClasses:["btn-primary","mx-1"],icon:"fa fa-save pg-alertify-button",disabled:!0,register:function(e){e.on("click",(function(){S.call(s,(function(){setTimeout((function(){I.call(this,b,e)}),0)}))}))}}],"footer","pg-prop-btn-group-below").on("keydown","button",(function(e){if(!e.shiftKey&&9==e.keyCode&&0==n(this).nextAll("button:not([disabled])").length)return b.$el.closest(".wcFloating").find('[tabindex]:not([tabindex="-1"]').first().focus(),!1;var t=n(s.$container.find(".pg-prop-btn-group")),i=n(t).find("button:first");s.$container.find(".number-cell.editable:last").is(":visible")&&9===e.keyCode&&e.shiftKey&&n(i).is(n(e.target))&&(n(s.$container.find("td.editable:last").trigger("click")),e.preventDefault(),e.stopPropagation())})),setTimeout((function(){d.keyboardNavigation.getDialogTabNavigator(s.pgElContainer)}),200));w("footer"),y.addClass("pg-prop-has-btn-group-below"),h.prepend(y),b.$el.closest(".wcFloating").find('.wcFrameButtonBar > .wcFrameButton[style!="display: none;"]').on("keydown",(function(e){e.shiftKey&&9===e.keyCode&&(e.stopPropagation(),setTimeout((function(){b.$el.closest(".wcFloating").find('[tabindex]:not([tabindex="-1"]):not([disabled])').last().focus()}),10))}))}.bind(l),$=function(e){a.isUndefined(e)||(C=e),this.close()}.bind(l),A=function(t){var i=this.$container.find(".obj_properties").first().data("obj-view");setTimeout((function(){t.clear_cache.apply(t,e)}),0);try{d.Events.trigger("pgadmin:browser:tree:add",a.clone(i.model.tnode),a.clone(i.model.node_info))}catch(e){console.warn(e.stack||e)}$(!1)}.bind(l,c),M=$,O=function(i){var n=t,s=a.clone(b.model.tnode),l=a.clone(b.model.node_info);setTimeout((function(){i.clear_cache.apply(i,e)}),0),d.Events.trigger("pgadmin:browser:tree:update",n,s,l,{success:function(e,t,i){d.Events.trigger("pgadmin:browser:node:updated",e,t,i),d.Events.trigger("pgadmin:browser:node:"+t._type+":updated",e,t,i)}}),$(!1)}.bind(l,c),B=D.bind(l);if(o?("create"==o&&(M=$,O=A),"properties"!=o?D():k()):(k(),B=function(){setTimeout((function(){c.callbacks.show_obj_properties.apply(c,[{action:"edit",item:e}])}),0)}.bind(l)),l.closeable()){l.on(f.EVENT.CLOSING,T.bind(l,i("Changes will be lost. Are you sure you want to close the dialog?"),(function(){l.off(f.EVENT.CLOSING),l.close()})));var j=function(){var e=this.$container.find(".obj_properties").first(),t=e&&e.data("obj-view");t&&t.remove({data:!0,internal:!0,silent:!0})}.bind(l);l.on(f.EVENT.CLOSED,j)}},_find_parent_node:function(e,t,i){if(this.parent_type)if(i=i||e.itemData(t),a.isString(this.parent_type)){if(this.parent_type==i._type)return t;for(;e.hasParent(t);)if(t=e.parent(t),i=e.itemData(t),this.parent_type==i._type)return t}else{if(a.indexOf(this.parent_type,i._type)>=0)return t;for(;e.hasParent(t);)if(t=e.parent(t),i=e.itemData(t),a.indexOf(this.parent_type,i._type)>=0)return t}return null},generate_url:function(e,t,i,n,s,l){var o={create:"obj",drop:"obj",edit:"obj",properties:"obj",statistics:"stats"},r=-1/0,c=a.isUndefined(e)||a.isNull(e)?s||{}:this.getTreeNodeHierarchy(e),p=t in o?o[t]:t,h=n&&i._type==this.type?encodeURIComponent(i._id):"";if(this.parent_type)if(a.isString(this.parent_type)){var f=c[this.parent_type];f&&(r=f.priority)}else a.each(this.parent_type,(function(e){var t=c[e];t&&r<t.priority&&(r=t.priority)}));var m=r;l&&c[l]&&(m=c[l].priority);return u.generate_url(d.URL,c,p,this.type,(function(e){return e.priority<=m||e.priority==r}),h)},Collection:d.DataCollection,Model:d.DataModel,getTreeNodeHierarchy:e.getTreeNodeHierarchyFromIdentifier.bind(d),cache:function(e,t,i,n){var s=this.cached=this.cached||{},l=e,o=t&&t[i]&&t[i].priority||0;if(t&&a.each(a.sortBy(a.values(a.pick(t,(function(e){return e.priority<=o}))),(function(e){return e.priority})),(function(e){l=h.sprintf("%s/%s",l,encodeURI(e._id))})),a.isUndefined(n)){var r=s[l];return!a.isUndefined(r)&&r.at-Date.now()>3e5&&(r=void 0),r}return r=s[l]={data:n,at:Date.now(),level:i}},clear_cache:function(e){this.cached={};d.Events.trigger("pgadmin:browser:node:"+this.type+":cache_cleared",e,this)},cache_level:function(e,t){if(e){if(t&&this.type in e)return this.type;if(a.isArray(this.parent_type)){for(var i in this.parent_type)if(i in e)return i;return this.type}return this.parent_type}}}),s.Browser.Node)}.apply(t,n))||(e.exports=a)}}]);