function dg_d7_services_request_pre_postprocess_alter(e,t){if("system"==e.service&&"connect"==e.resource){jDrupal.connected=!0;var n=t.user;if(n.uid){var r={uid:[{value:n.uid}],name:[{value:n.name}],mail:[{value:n.mail}],status:[{value:n.status}],created:[{value:n.created}],changed:[{value:n.changed}],access:[{value:n.access}],init:[{value:n.init}],roles:[]};for(var s in n.roles)n.roles.hasOwnProperty(s)&&r.roles.push({target_id:n.roles[s],target_type:"user_role"});jDrupal.setCurrentUser(new jDrupal.User(r))}else jDrupal.setCurrentUser(jDrupal.userDefaults())}else"user"==e.service&&"logout"==e.resource&&jDrupal.setCurrentUser(jDrupal.userDefaults())}function dg_d7_deviceready(){return d7.config("sitePath",jDrupal.config("sitePath")),new Promise(function(e,t){var n=function(t,n,r){console.log(arguments);var s="deviceready_offline";jDrupal.moduleImplements(s)?jDrupal.moduleInvokeAll(s,t,n,r):(e(),setTimeout(function(){dg.error(t,n,r)},1))};dg.hasConnection()?system_connect({success:function(t){dg.continue(),e()},error:n}):n(null,null,dg.t("No network connection."))})}function dg_d7_pre_process_route_change(e,t){d7.clearMenuObjectType(),d7.clearMenuObject()}function dg_d7_form_alter(e,t,n){return new Promise(function(t,r){"UserLoginForm"==n&&(e._submit=["dg_d7.user_login_form_submit"]),t()})}dg.createModule("dg_d7");var d7=dg_d7;d7.init=function(){d7.settings={sitePath:null,basePath:"/"}},d7.init(),d7.config=function(e){var t="undefined"!=typeof arguments[1]?arguments[1]:null;return t?void(d7.settings[e]=t):d7.settings[e]},d7.sitePath=function(){return d7.settings.sitePath},d7.basePath=function(){return d7.settings.basePath},d7.restPath=function(){return this.sitePath()+this.basePath()},d7.path=function(){return this.restPath().substr(this.restPath().indexOf("://")+3).replace("localhost","")},d7._menuObjectType=null,d7._menuObject=null,d7.getMenuObjectType=function(){return d7._menuObjectType},d7.getMenuObject=function(){return d7._menuObject},d7.setMenuObjectType=function(e){d7._menuObjectType=e},d7.setMenuObject=function(e){d7._menuObject=e},d7.clearMenuObjectType=function(){d7._menuObjectType=null},d7.clearMenuObject=function(){d7._menuObject=null},d7.entityViewController=function(e){var t=dg.router.load(dg.getPath()),n=t.defaults._dgEntityType,r=n.replaceAll("_","-"),s=r+"-"+e;return{entity:{_theme:"bucket",_attributes:{id:s,class:[r]},_fill:function(u){entity_load(n,e,{success:function(e){d7.setMenuObjectType(n),d7.setMenuObject(e),"node"===n&&dg.qs("#"+s).classList.add(r+"-"+e.type.replaceAll("_","-")),u(t.defaults._dgController(e))},error:function(e,n,r){u(t.defaults._dgController(null,e,n,r))}})}}}},d7.fieldHasItem=function(e,t,n,r){return n||(n=language_default()),"undefined"==typeof r&&(r=0),e[t]&&e[t][n]&&e[t][n].length&&e[t][n][r]},d7.fieldGetItem=function(e,t,n,r){return n||(n=language_default()),"undefined"==typeof r&&(r=0),e[t][n][r]},d7.fieldGetItemCount=function(e,t,n){return n?d7.fieldGetItems(e,t,n).length:d7.fieldGetItems(e,t).length},d7.fieldGetItems=function(e,t,n){return n||(n=language_default()),e[t][n]},d7.fieldSetItem=function(e,t,n,r,s,u){s||(s=language_default()),"undefined"==typeof u&&(u=0),e[t]||(e[t]={}),n?(e[t][s]||(e[t][s]=[]),e[t][s][u]||(e[t][s][u]={}),e[t][s][u][n]=r):e[t][s][u]=r},d7.showFormErrors=function(e){var t=[],n=JSON.parse(e);if(n.form_errors)for(var r in n.form_errors)n.form_errors.hasOwnProperty(r)&&t.push(n.form_errors[r]);else t.push(e);t.length&&dg.alert(t.join("
"))},dg_d7.user_login_form_submit=function(e,t){return new Promise(function(e,n){user_login(t.getValue("name"),t.getValue("pass"),{success:function(t){console.log(t),e()},error:function(e,t,r){console.log(arguments),document.getElementById("edit-pass").value="",dg.alert(JSON.parse(r)[0]),n()}})})},d7.Views=function(e){this.path=e,this.results=null,this._count=null,this._page=null,this._pages=null,this._limit=null,this._pagerReady=!1},d7.Views.prototype.getPath=function(){return this.path},d7.Views.prototype.getResults=function(){return this.results},d7.Views.prototype.getCount=function(){return this._count},d7.Views.prototype.setCount=function(e){this._count=e},d7.Views.prototype.getPage=function(){return this._page},d7.Views.prototype.setPage=function(e){this._page=e},d7.Views.prototype.getPages=function(){return this._pages},d7.Views.prototype.setPages=function(e){this._pages=e},d7.Views.prototype.getLimit=function(){return this._limit},d7.Views.prototype.setLimit=function(e){this._limit=e},d7.Views.prototype.hasPages=function(){return!!this.getPages()},d7.Views.prototype.setPager=function(e){this._pager=e},d7.Views.prototype.getPager=function(){return this._pager},d7.Views.prototype.pagerReady=function(){return!!this.getPager()},d7.Views.prototype.getView=function(){var e=this;return new Promise(function(t,n){var r=new XMLHttpRequest;r.dg={service:"views",resource:null};var s=d7.restPath()+e.getPath(),u=null!==e.getPage()?e.getPage():dg._GET("page");u&&(s+=(s.indexOf("?")==-1?"?":"&")+"page="+u),r.open("GET",s);var o=function(){e.results=[];var n=JSON.parse(r.response),s=n.view;if(e.setCount(s.count),e.setPage(s.page),e.setPages(s.pages),e.setLimit(s.limit),n.view.count)for(var u in n[n.view.root])n[n.view.root].hasOwnProperty(u)&&e.results.push(n[n.view.root][u][n.view.child]);t()};r.onload=function(){if(200==r.status){var e=jDrupal.moduleInvokeAll("rest_post_process",r);e?e.then(o):o()}else n(Error(r.statusText))},r.onerror=function(){n(Error("Network Error"))},r.send()})},d7.viewsLoad=function(e){return new Promise(function(t,n){var r=new d7.Views(e);r.getView().then(function(){t(r)})})};