sogo/UI/WebServerResources/js/Common.js
2018-05-17 01:24:35 -04:00

2 lines
78 KiB
JavaScript

!function(){"use strict";angular.module("SOGo.Common",["ngAnimate","ngMessages","ngSanitize","ngMaterial","mdColors"]).value("sgSettings",{isPopup:document.body.classList.contains("popup"),baseURL:function(){return ApplicationBaseURL||null},resourcesURL:function(){return ResourcesURL||null},activeUser:function(e){var t={login:UserLogin||null,identification:UserIdentification||null,email:UserEmail||null,language:UserLanguage||null,folderURL:UserFolderURL||null,isSuperUser:IsSuperUser||null,path:{calendar:UserCalendarPath||null,contacts:UserContactsPath||null,mail:UserMailPath||null,preferences:UserPreferencesPath||null,administration:IsSuperUser?UserAdministrationPath:null,help:HelpURL||null,logoff:UserLogoffPath||null}};return e?t[e]:t},minimumSearchLength:function(){return angular.isNumber(minimumSearchLength)?minimumSearchLength:2}}).constant("sgColors",{selection:["#FFFFFF","#330033","#C0C0C0","#999999","#666666","#333333","#000000","#FFCCCC","#FF6666","#FF0000","#CC0000","#990000","#660000","#330000","#FFCC99","#FF9966","#FF9900","#FF6600","#CC6600","#993300","#663300","#FFFF99","#FFFF66","#FFCC66","#FFCC33","#CC9933","#996633","#663333","#FFFFCC","#FFFF33","#FFFF00","#FFCC00","#999900","#666600","#333300","#CCCCCC","#66FF99","#33FF33","#33CC00","#009900","#006600","#003300","#99FFFF","#33FFFF","#66CCCC","#00CCCC","#339999","#336666","#003333","#CCFFFF","#66FFFF","#33CCFF","#3366FF","#3333FF","#000099","#000066","#CCCCFF","#9999FF","#6666CC","#6633FF","#6600CC","#333399","#330099","#FFCCFF","#FF99FF","#CC66CC","#CC33CC","#993399","#663366","#99FF99"]}).constant("sgConstant",{xs:"(max-width: 599px)","gt-xs":"(min-width: 600px)",sm:"(min-width: 600px) and (max-width: 959px)","gt-sm":"(min-width: 960px)",md:"(min-width: 960px) and (max-width: 1023px)","gt-md":"(min-width: 1024px)",lg:"(min-width: 1024px) and (max-width: 1279px)","gt-lg":"(min-width: 1280px)",xl:"(min-width: 1920px)",print:"print"}).config(e).factory("AuthInterceptor",t).factory("ErrorInterceptor",n),e.$inject=["$logProvider","$compileProvider","$httpProvider","$mdThemingProvider","$mdAriaProvider"];function e(e,t,n,r,i){r.definePalette("sogo-green",{50:"eaf5e9",100:"cbe5c8",200:"aad6a5",300:"88c781",400:"66b86a",500:"56b04c",600:"4da143",700:"388e3c",800:"367d2e",900:"225e1b",A100:"fafafa",A200:"69f0ae",A400:"00e676",A700:"00c853",contrastDefaultColor:"dark",contrastLightColors:["300","400","500","600","700","800","900"]}),r.definePalette("sogo-blue",{50:"f0faf9",100:"e1f5f3",200:"ceebe8",300:"bfe0dd",400:"b2d6d3",500:"a1ccc8",600:"8ebfbb",700:"7db3b0",800:"639997",900:"4d8080",A100:"d4f7fa",A200:"c3f5fa",A400:"53e3f0",A700:"00b0c0",contrastDefaultColor:"light",contrastDarkColors:["50","100","200"]}),r.definePalette("sogo-paper",{50:"fcf7f8",100:"f7f1dc",200:"ede5ca",300:"e6d8ba",400:"e2d2a3",500:"d6c48d",600:"baa870",700:"857545",800:"524517",900:"433809",1000:"000000",A100:"ffffff",A200:"eeeeee",A400:"bdbdbd",A700:"616161",contrastDefaultColor:"dark",contrastLightColors:["800","900"]});var o=r.extendPalette("grey",{600:"00B0C0"});r.definePalette("sogo-grey",o),r.theme("default").primaryPalette("sogo-blue",{default:"900","hue-1":"400","hue-2":"800","hue-3":"A700"}).accentPalette("sogo-green",{default:"500","hue-1":"A100","hue-2":"300","hue-3":"A700"}).backgroundPalette("sogo-grey"),DebugEnabled||(e.debugEnabled(!1),t.debugInfoEnabled(!1),i.disableWarnings(),r.generateThemesOnDemand(!0)),n.interceptors.push("AuthInterceptor"),n.interceptors.push("ErrorInterceptor")}t.$inject=["$window","$q"];function t(e,t){return{response:function(n){return n&&/^application\/json/.test(n.config.headers.Accept)&&/^[\n\r ]*<!DOCTYPE html>/.test(n.data)?(e.location.reload(!0),t.reject()):n}}}n.$inject=["$rootScope","$window","$q","$injector"];function n(e,t,n,r){return{responseError:function(i){var o,s;if(/^application\/json/.test(i.config.headers.Accept)){if(t.usesCASAuthentication&&-1==i.status)return o=n.defer(),(s=angular.element('<iframe class="ng-hide" src="'+t.UserFolderURL+'recover"></iframe>')).on("load",function(){r.get("$http")(i.config).then(o.resolve,o.reject),s.remove()}),document.body.appendChild(s[0]),o.promise;t.usesSAML2Authentication&&401==i.status?t.location.reload(!0):e.$broadcast("http:Error",i)}return n.reject(i)}}}}(),function(){"use strict";var e;angular.module("mdColors",["ngMaterial"]).config(t).run(n),t.$inject=["$mdThemingProvider"];function t(t){e=t}n.$inject=["$interpolate","$document","$log"];function n(t,n,r){function i(e){return e.join("")}for(var o=t(i([".md-{{theme}}-theme",".md-fg"])+" { color:{{value}};}"),s=t(i([".md-{{theme}}-theme",".md-bg"])+" { background-color:{{value}};}"),a=t(i([".md-{{theme}}-theme",".md-bdr"])+" { border-color:{{value}};}"),l=t(i([".md-{{theme}}-theme",".md-{{hue}}",".md-fg"])+" { color:{{value}};}"),c=t(i([".md-{{theme}}-theme",".md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),u=t(i([".md-{{theme}}-theme",".md-{{palette}}",".md-fg"])+" { color:{{value}};}"),d=t(i([".md-{{theme}}-theme",".md-{{palette}}",".md-bg"])+" { background-color:{{value}}; color:{{contrast}} !important; }"),h=t(i([".md-{{theme}}-theme",".md-{{palette}}",".md-bdr"])+" { border-color:{{value}};}"),m=t(i([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-fg"])+" { color:{{value}};}"),g=t(i([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),p=function(){var e=n[0].head.querySelector('style[title="Dynamic-Generated-by-mdColors"]');null===e&&((e=n[0].createElement("style")).title="Dynamic-Generated-by-mdColors",e.appendChild(n[0].createTextNode("")),n[0].head.appendChild(e));return e.sheet}(),f=0;p.cssRules.length>0;)p.deleteRule(0);angular.forEach(e._THEMES,function(t,n){y(o,s,n,"primary",e._PALETTES[t.colors.primary.name][t.colors.primary.hues.default]),y(l,c,n,"primary",e._PALETTES[t.colors.primary.name][t.colors.primary.hues["hue-2"]],"hue-2"),y(l,c,n,"primary",e._PALETTES[t.colors.primary.name][t.colors.primary.hues["hue-3"]],"hue-3"),y(l,c,n,"primary",e._PALETTES[t.colors.primary.name][t.colors.primary.hues["hue-1"]],"hue-1"),v(a,n,"primary",e._PALETTES[t.colors.primary.name][t.colors.primary.hues.default]),angular.forEach(t.colors,function(t,r){y(u,d,n,r,e._PALETTES[t.name][t.hues.default]),v(h,n,r,e._PALETTES[t.name][t.hues.default]),y(m,g,n,r,e._PALETTES[t.name][t.hues["hue-2"]],"hue-2"),y(m,g,n,r,e._PALETTES[t.name][t.hues["hue-3"]],"hue-3"),y(m,g,n,r,e._PALETTES[t.name][t.hues["hue-1"]],"hue-1")})});function y(e,t,n,r,i,o){if(i){var s={theme:n,palette:r,value:"rgb("+i.value[0]+","+i.value[1]+","+i.value[2]+")",contrast:"rgb("+i.contrast[0]+","+i.contrast[1]+","+i.contrast[2]+")",hue:o};p.insertRule(e(s),f),f+=1,p.insertRule(t(s),f),f+=1}}function v(e,t,n,r,i){if(r){var o="rgb("+r.value[0]+","+r.value[1]+","+r.value[2]+")";p.insertRule(e({theme:t,palette:n,value:o,hue:i}),f),f+=1}}}}(),function(){"use strict";e.$inject=["$window"];function e(e){return e.decodeURIComponent}angular.module("SOGo.Common").filter("decodeUri",e)}(),function(){"use strict";e.$inject=["$window"];function e(e){return e.encodeURIComponent}angular.module("SOGo.Common").filter("encodeUri",e)}(),function(){"use strict";e.$inject=["$sce"];function e(e){return function(t){var n=angular.element("<div>"+t+"</div>");return n.find("a").attr("target","_blank"),e.trustAs("html",n.html())}}angular.module("SOGo.Common").filter("ensureTarget",e)}(),function(){"use strict";angular.module("SOGo.Common").filter("loc",function(){return l})}(),function(){"use strict";angular.module("SOGo.Common").filter("range",function(){return function(e){for(var t=[],n=0;n<parseInt(e);n++)t.push(n);return t}})}(),function(){"use strict";e.$inject=["linkyFilter"];function e(e){return function(t){return t?String(e(t," _blank")).replace(/&#10;/gm,"<br>"):void 0}}angular.module("SOGo.Common").filter("txt2html",e)}(),function(){"use strict";e.$inject=["$document","$timeout","$mdDialog","Dialog","usersWithACL","User","folder"];function e(e,t,n,r,i,o,s){var a=this;a.users=i,a.folder=s,a.selectedUser=null,a.selectedUid=null,a.userToAdd="",a.searchText="",a.folderClassName=function(){return!!angular.isFunction(s.getClassName)&&s.getClassName("bg")},a.templateName=function(t){return"UIx"+(e[0].getElementById("UIxAnonymousUserRightsEditor")&&t.$isAnonymous()?"Anonymous":"")+"UserRightsEditor"},a.userFilter=function(e){return o.$filter(e,s.$acl.users)},a.closeModal=function(){s.$acl.$resetUsersRights(),n.hide()},a.saveModal=function(){s.$acl.$saveUsersRights().then(function(){n.hide()},function(e,t){r.alert(l("Warning"),l("An error occured please try again."))})},a.confirmChange=function(e){var t=e.$confirmRights(a.folder);t&&(a.confirmation.showing=!0,a.confirmation.message=t)},a.removeUser=function(e){t(function(){s.$acl.$removeUser(e.uid)},500)},a.addUser=function(e){e&&s.$acl.$addUser(e).then(function(e){a.userToAdd="",a.searchText="",a.selectedUid=null,e&&c(e)})},a.selectAllRights=function(e){s.$acl.$selectAllRights(e)},a.selectUser=c,a.showRights=function(e){return a.selectedUid==e.uid&&!e.inactive},a.confirmation={showing:!1,message:""};function c(e,t){if(t&&t.target.parentNode.classList.contains("md-secondary"))return!1;a.selectedUid==e.uid?a.selectedUid=null:(a.selectedUid=e.uid,a.selectedUser=e,e.inactive||a.selectedUser.$rights())}}angular.module("SOGo.Common").controller("AclController",e)}(),function(){"use strict";e.$inject=["$rootScope","$scope","$timeout","$interval","$http","$window","$mdSidenav","$mdToast","$mdMedia","$log","sgConstant","sgSettings","Resource","Alarm"];function e(e,t,n,r,i,o,s,a,c,u,d,h,m,g){var p=new m(h.baseURL(),h.activeUser());this.$onInit=function(){t.isPopup=h.isPopup,t.activeUser=h.activeUser(),t.baseURL=h.baseURL(),t.leftIsClose=!c(d["gt-md"]),t.centerIsClose=!!o.centerIsClose&&!t.leftIsClose,t.currentDay=window.currentDay,n(function(){r(function(){i.get("../date").then(function(e){t.currentDay=e})},864e5)},1e3*window.currentDay.secondsBeforeTomorrow),t.$watch(function(){return c(d["gt-md"])},function(e){t.isGtMedium=e,e&&(t.leftIsClose=!1)}),e.$on("http:Error",f),h.activeUser("path").calendar&&g.getAlarms()},t.toggleLeft=function(){t.isGtMedium?t.leftIsClose=!t.leftIsClose:(t.leftIsClose=!s("left").isOpen(),t.leftIsClose&&angular.element(o).triggerHandler("resize"),s("left").toggle().then(function(){u.debug("toggle left is done")}))},t.toggleRight=function(){s("right").toggle().then(function(){u.debug("toggle right is done")})},t.toggleCenter=function(e){t.centerIsClose=!t.centerIsClose,e&&e.save&&p.post(null,"saveListState",{state:t.centerIsClose?"collapse":"rise"})};function f(e,t){var n;t.data&&t.data.message&&angular.isString(t.data.message)?n=t.data.message:t.status&&(n=t.statusText),n?a.show({template:["<md-toast>",' <div class="md-toast-content">',' <md-icon class="md-warn md-hue-1">error_outline</md-icon>'," <span flex>"+l(n)+"</span>"," </div>","</md-toast>"].join(""),hideDelay:5e3,position:"top right"}):u.debug("untrap error")}}angular.module("SOGo.Common").controller("navController",e)}(),function(){"use strict";function e(e){this.folderId=e}e.factory=["$q","$timeout","sgSettings","Resource","User",function(t,n,r,i,o){return angular.extend(e,{$q:t,$timeout:n,$$resource:new i(r.activeUser("folderURL"),r.activeUser()),$User:o}),e}],angular.module("SOGo.Common").factory("Acl",e.factory),e.prototype.$users=function(t){var n,r=this,i=e.$q.defer();if(!this.users){return(angular.isDefined(t)?e.$$resource.userResource(t).fetch(this.folderId,"acls"):e.$$resource.fetch(this.folderId,"acls")).then(function(o){return r.users=[],angular.forEach(o.users,function(i){(n=new e.$User(i)).canSubscribeUser=n.isSubscribed,n.wasSubscribed=n.isSubscribed,n.$rights=angular.bind(n,n.$acl,r.folderId,t),r.users.push(n)}),i.resolve(r.users),r.users})}return i.resolve(this.users),i.promise},e.prototype.$addUser=function(t,n){var r=this,i=e.$q.defer(),o={uid:t.uid};if(!t.uid||_.indexOf(_.map(this.users,"uid"),t.uid)>-1)i.resolve();else{(angular.isDefined(n)?e.$$resource.userResource(n).fetch(this.folderId,"addUserInAcls",o):e.$$resource.fetch(this.folderId,"addUserInAcls",o)).then(function(){t.wasSubscribed=!1,t.userClass=t.isGroup?"normal-group":"normal-user",t.$rights=angular.bind(t,t.$acl,r.folderId,n),r.users.push(t),i.resolve(t)},function(e,t){i.reject(l("An error occured please try again."))})}return i.promise},e.prototype.$removeUser=function(t,n){var r=this,i={uid:t};return(angular.isDefined(n)?e.$$resource.userResource(n).fetch(this.folderId,"removeUserFromAcls",i):e.$$resource.fetch(this.folderId,"removeUserFromAcls",i)).then(function(){var e=_.indexOf(_.map(r.users,"uid"),t);e>=0&&(r.users[e].$shadowRights=null,r.users.splice(e,1))})},e.prototype.$selectAllRights=function(e){_.forEach(e.rights,function(t,n){angular.isNumber(e.rights[n])?e.rights[n]=1:e.rights[n]="Modifier"})},e.prototype.$resetUsersRights=function(){angular.forEach(this.users,function(e){e.$resetRights()})},e.prototype.$saveUsersRights=function(t){var n=this,r=e.$q.defer(),i=e.$q.defer(),o={action:"saveUserRights"},s=[];if(angular.forEach(this.users,function(e){e.$rightsAreDirty()&&s.push(e.$omit())}),s.length){(angular.isDefined(t)?e.$$resource.userResource(t).save(this.folderId,s,o):e.$$resource.save(this.folderId,s,o)).then(function(){angular.forEach(n.users,function(e){e.$rightsAreDirty()&&(e.$shadowRights=angular.copy(e.rights))}),r.resolve()},r.reject)}else r.resolve();return s=[],angular.forEach(this.users,function(e){!e.wasSubscribed&&e.isSubscribed&&s.push(e.uid)}),s.length?(o={uids:s.join(",")},e.$$resource.fetch(this.folderId,"subscribeUsers",o).then(function(){angular.forEach(n.users,function(e){e.wasSubscribed=e.isSubscribed}),i.resolve()},i.reject)):i.resolve(),e.$q.all([r.promise,i.promise])}}(),function(){"use strict";function e(){this.currentAlarm=null}e.getAlarms=function(){var t=this,n=new Date,r=Math.floor(n.getTime()/1e3);this.$$resource.fetch("","alarmslist?browserTime="+r).then(function(n){var r=n.alarms.sort(function(e,t){var n=parseInt(e[2]);return parseInt(t[2])-n});if(r.length>0){var i=r.pop(),o=new Date,s=Math.floor(o.getTime()/1e3),a=i[0]+"/"+i[1],l=parseInt(i[2]),c=l;l>0&&(c-=s);new Date(1e3*l);var u=angular.bind(t,e.showAlarm,a);t.currentAlarm&&t.$timeout.cancel(t.currentAlarm),t.currentAlarm=t.$timeout(u,1e3*c)}})},e.showAlarm=function(e){var t=this;this.$$resource.fetch(e,"?resetAlarm=yes").then(function(n){t.$toast.show({position:"top right",hideDelay:0,template:["<md-toast>",' <div class="md-toast-content">',' <div layout="column" layout="start end">',' <p class="sg-padded--top">{{ summary }}</p>',' <div layout="row" layout-align="start center">'," <md-input-container>",' <label style="color: white">{{ "Snooze for " | loc }}</label>',' <md-select ng-model="reminder">',' <md-option value="5">',l("5 minutes")," </md-option>",' <md-option value="10">',l("10 minutes")," </md-option>",' <md-option value="15">',l("15 minutes")," </md-option>",' <md-option value="30">',l("30 minutes")," </md-option>",' <md-option value="45">',l("45 minutes")," </md-option>",' <md-option value="60">',l("1 hour")," </md-option>",' <md-option value="1440">',l("1 day")," </md-option>"," </md-select>"," </md-input-container>",' <md-button ng-click="snooze()">',l("Snooze")," </md-button>",' <md-button ng-click="close()">',l("Close")," </md-button>"," </div>"," </div>"," </div>","</md-toast>"].join(""),locals:{url:e},controller:r}),r.$inject=["scope","$mdToast","url"];function r(e,r,i){e.summary=n.summary,e.reminder="10",e.close=function(){r.hide()},e.snooze=function(){t.$$resource.fetch(i,"view?snoozeAlarm="+e.reminder),r.hide()}}})},t.$inject=["$timeout","sgSettings","Resource","$mdToast"];function t(t,n,r,i){return angular.extend(e,{$timeout:t,$$resource:new r(n.activeUser("folderURL")+"Calendar",n.activeUser()),$toast:i}),e}angular.module("SOGo.Common").factory("Alarm",t)}(),function(){"use strict";angular.module("SOGo.Authentication",["ngCookies"]).constant("passwordPolicyConfig",{PolicyPasswordChangeUnsupported:-3,PolicyPasswordSystemUnknown:-2,PolicyPasswordUnknown:-1,PolicyPasswordExpired:0,PolicyAccountLocked:1,PolicyChangeAfterReset:2,PolicyPasswordModNotAllowed:3,PolicyMustSupplyOldPassword:4,PolicyInsufficientPasswordQuality:5,PolicyPasswordTooShort:6,PolicyPasswordTooYoung:7,PolicyPasswordInHistory:8,PolicyNoError:65535}).provider("Authentication",function(){function e(e,t){var n,r,i,o,s,a;return n=e,t&&(n+="@"+t.value),r=""+window.location.href,"/"==(i=ApplicationBaseURL+encodeURIComponent(n))[0]&&(o=r.split("/"),s=o[2],a=o[0],i=a+"//"+s+i),r.startsWith(i)&&!r.endsWith("/logoff")?r:i}this.$get=t,t.$inject=["$q","$http","$cookies","passwordPolicyConfig"];function t(t,n,r,i){function o(){var e,t=null,n=r.get("0xHIGHFLYxSOGo");return n&&n.length>8&&(e=decodeURIComponent(n.substr(8)),t=e.base64decode().split(":")),t}return{login:function(r){var s,a=t.defer(),c=r.username,u=r.password,d=r.domain,h=r.rememberLogin?1:0;return r.loginSuffix&&!c.endsWith(r.loginSuffix)&&(c+=loginSuffix,d=!1),r.language&&"WONoSelectionString"!=r.language&&(s=r.language),n({method:"POST",url:"/SOGo/connect",data:{userName:c,password:u,domain:d,language:s,rememberLogin:h}}).then(function(t){var n=t.data,r=o();r?void 0!==n.expire&&void 0!==n.grace?n.expire<0&&n.grace>0?a.reject({grace:n.grace}):n.expire>0&&-1==n.grace?a.reject({expire:n.expire}):a.resolve({cn:n.cn,url:e(c,d)}):a.resolve({url:e(c,d)}):a.reject(l("cookiesNotEnabled"))},function(e){var t,n,r=e.data;r&&r.LDAPPasswordPolicyError?(n=r.LDAPPasswordPolicyError,t=n==i.PolicyNoError?l("Wrong username or password."):n==i.PolicyAccountLocked?l("Your account was locked due to too many failed attempts."):l("Login failed due to unhandled error case: ")+n):t=l("Unhandled error response"),a.reject({error:t})}),a.promise},changePassword:function(e){var s=t.defer(),a=o(),c=r.get("XSRF-TOKEN");return r.remove("XSRF-TOKEN",{path:"/SOGo/"}),n({method:"POST",url:"/SOGo/so/changePassword",headers:{"X-XSRF-TOKEN":c},data:{userName:a[0],password:a[1],newPassword:e}}).then(s.resolve,function(e){var t,n=e.data,o=n.LDAPPasswordPolicyError;o?o==i.PolicyNoError?t=l("Password change failed"):o==i.PolicyPasswordModNotAllowed?t=l("Password change failed - Permission denied"):o==i.PolicyInsufficientPasswordQuality?t=l("Password change failed - Insufficient password quality"):o==i.PolicyPasswordTooShort?t=l("Password change failed - Password is too short"):o==i.PolicyPasswordTooYoung?t=l("Password change failed - Password is too young"):o==i.PolicyPasswordInHistory?t=l("Password change failed - Password is in history"):(t=l("Unhandled policy error: %{0}").formatted(o),o=i.PolicyPasswordUnknown):(o=i.PolicyPasswordSystemUnknown,t=_("Unhandled error response")),r.put("XSRF-TOKEN",c,{path:"/SOGo/"}),s.reject(t)}),s.promise}}}})}(),function(){"use strict";function e(){}e.alert=function(e,t){var n=this.$modal.alert().title(e).htmlContent(t).ok(l("OK")).multiple(!0);this.$modal.show(n)},e.confirm=function(e,t,n){var r=this.$modal.confirm().title(e).htmlContent(t).ok(n&&n.ok?n.ok:l("OK")).cancel(n&&n.cancel?n.cancel:l("Cancel"));return this.$modal.show(r)},e.prompt=function(e,t,n){var r=n||{},i=e.asCSSIdentifier(),o=this.$q.defer();this.$modal.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,template:['<md-dialog flex="50" flex-xs="90">',' <form name="'+i+'Form" ng-submit="ok()">',' <md-dialog-content class="md-dialog-content" layout="column">',' <h2 class="md-title" ng-bind="title"></h2>'," <md-input-container>"," <label>"+t+"</label>",' <input type="'+(r.inputType||"text")+'"',' aria-label="'+e+'"',' ng-model="name" md-autofocus="true" required />'," </md-input-container>"," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="cancel()">'," "+l("Cancel")," </md-button>",' <md-button type="submit" class="md-primary" ng-disabled="'+i+'Form.$invalid">'," "+l("OK")," </md-button>"," </md-dialog-actions>"," </form>","</md-dialog>"].join(""),controller:s}),s.$inject=["scope","$mdDialog"];function s(t,n){t.title=e,t.name="",t.cancel=function(){o.reject(),n.hide()},t.ok=function(){o.resolve(t.name),n.hide()}}return o.promise},t.$inject=["$q","$mdDialog"];function t(t,n){return angular.extend(e,{$q:t,$modal:n}),e}angular.module("SOGo.Common").factory("Dialog",t)}(),function(){"use strict";angular.module("SOGo.Common").factory("Gravatar",function(){return function(e,t,n,r){var i,o,s,a=t,l=n;return e?((i=e.indexOf("<"))>=0&&(o=e.indexOf(">",i))>i&&(e=e.substring(i+1,o)),t||(a=48),s=e.md5(),l&&"none"!=l||(n=r&&r.no_404?"mm":"404"),"https://www.gravatar.com/avatar/"+s+"?s="+a+"&d="+n):""}})}(),function(){"use strict";function e(e,t,n,r,i,o){angular.extend(this,{_http:e,_q:t,_window:n,_path:r,_activeUser:i}),angular.extend(this,o),this._path=this._path.replace(/\/$/,"")}e.$factory=["$http","$q","$window",function(t,n,r){return function(i,o,s){return new e(t,n,r,i,o,s)}}],angular.module("SOGo.Common").factory("Resource",e.$factory),e.prototype.userResource=function(t){var n=_.compact(this._activeUser.folderURL.split("/"));return t&&n.splice(n.length-1,1,escape(t)),new e(this._http,this._q,"/"+n.join("/"),this._activeUser)},e.prototype.path=function(){var e=[this._path];return arguments.length>0&&Array.prototype.push.apply(e,Array.prototype.slice.call(arguments)),e.join("/")},e.prototype.fetch=function(e,t,n){var r=this._q.defer(),i=[this._path];return e&&i.push(e.split("/")),t&&i.push(t),i=_.compact(_.flatten(i)).join("/"),this._http({method:"GET",url:i,params:n}).then(function(e){return r.resolve(e.data)},r.reject),r.promise},e.prototype.newguid=function(e){var t=this._q.defer(),n=this._path+"/"+e+"/newguid";return this._http.get(n).then(function(e){return t.resolve(e.data)},t.reject),t.promise},e.prototype.create=function(e,t){var n=this._q.defer(),r=this._path+"/"+e;return this._http.post(r,{name:t}).then(function(e){return n.resolve(e.data)},n.reject),n.promise},e.prototype.post=function(e,t,n){var r=this._q.defer(),i=[this._path];return e&&i.push(e),t&&i.push(t),i=_.compact(_.flatten(i)).join("/"),this._http.post(i,n).then(function(e){return r.resolve(e.data)},r.reject),r.promise},e.prototype.save=function(e,t,n){var r=n&&n.action?n.action:"save";return this.post(e,r,t)},e.prototype.download=function(e,t,n,r){this._q.defer();var i=r&&r.type?r.type:"application/zip",o=[this._path];e&&o.push(e),t&&o.push(t),o=_.compact(_.flatten(o)).join("/");return this._http({method:"POST",url:o,data:n,headers:{accept:i},responseType:"arraybuffer",cache:!1,transformResponse:function(e,t,n){var o,s=null;if(n<200||n>299)throw new Error("Bad gateway");e&&(s=new Blob([e],{type:i})),r&&r.filename?o=r.filename:(a=t("content-disposition"))&&a.split(";")[1].trim().split("=")[1].replace(/"/g,"");var a;if(!saveAs)throw new Error("To use Resource.download, FileSaver.js must be loaded.");saveAs(s,o)}})},e.prototype.open=function(e,t){var n=[this._path];e&&n.push(e),t&&n.push(t),n=_.compact(_.flatten(n)).join("/"),this._window.location.href=n},e.prototype.remove=function(e){var t=this._q.defer(),n=this._path+"/"+e+"/delete";return this._http.get(n).then(function(e){return t.resolve(e.data)},t.reject),t.promise}}(),function(){"use strict";e.$inject=["$rootScope","$timeout"];function e(e,t){return function(n){t(function(){e.$broadcast("sgFocusOn",n)})}}angular.module("SOGo.Common").factory("sgFocus",e)}(),function(){"use strict";e.$inject=["$mdDialog","$sgHotkeys"];function e(e,t){return angular.extend(t,{$modal:e}),new t}angular.module("SOGo.Common").service("sgHotkeys",e).provider("$sgHotkeys",function(){var e={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"caps",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},t={42:"*",63:"?"};this.$get=n,n.$inject=["$rootScope","$window"];function n(n,r){var i=function(e){this.id=e.id||guid(),this.key=e.key,this.description=e.description||null,this.context=e.context||null,this.callback=e.callback,this.preventInClass=e.preventInClass,this.args=e.args,this.onKeyUp=!1,this.key.length>1&&(this.lkey=l("key_"+this.key))};i.prototype.clone=function(){return new i(this)};var o=function(){this._hotkeys={},this._hotkeysUp={},this._preventIn=["INPUT","SELECT","TEXTAREA","MD-OPTION"],this._preventInClass=["md-chip-content"],this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.initialize()};return o.prototype.initialize=function(){this.registerHotkey(this.createHotkey({key:"?",description:l("Show or hide this help"),callback:this._toggleCheatSheet.bind(this)})),r.addEventListener("keydown",this._onKeydown,!0),r.addEventListener("keyup",this._onKeyup,!0),r.addEventListener("keypress",this._onKeypress,!0)},o.prototype._invokeHotkeyHandlers=function(e,t,n){for(var r=0,i=n.length;r<i;r++){var o=n[r],s=e.target||e.srcElement,a=s.nodeName.toUpperCase();if(!_.includes(this._preventIn,a)&&0===_.intersection(s.classList,this._preventInClass).length&&0===_.intersection(s.classList,o.preventInClass).length)try{o.callback.call(o.context,e,o.args)}catch(e){console.error("HotKeys: ",o.key,e.message)}}},o.prototype._onKeydown=function(e){var t=this.keyStringFromEvent(e);this._hotkeys[t]&&this._invokeHotkeyHandlers(e,t,this._hotkeys[t])},o.prototype._onKeyup=function(e){var t=this.keyStringFromEvent(e);this._hotkeysUp[t]&&this._invokeHotkeyHandlers(this._hotkeysUp[t],t)},o.prototype._onKeypress=function(e){var n,r;n=e.keyCode||e.which,(r=t[n])&&this._hotkeys[r]&&this._invokeHotkeyHandlers(e,r,this._hotkeys[r])},o.prototype.keyStringFromEvent=function(t){var n=[],r=t.which;return r=e[r]?e[r]:String.fromCharCode(r).toLowerCase(),t.ctrlKey&&n.push("ctrl"),t.altKey&&n.push("alt"),t.shiftKey&&n.push("shift"),t.metaKey&&n.push("meta"),n.push(r),_.uniq(n).join("+")},o.prototype._deregisterHotkey=function(e){var t,n=this._hotkeys;if(e.onKeyUp&&(n=this._hotkeysUp),n[e.key]){for(var r=n[e.key],i=0;i<r.length;++i){var o=r[i];(e.callback===o.callback&&o.context===e.context||e.id===o.id)&&(t=r.splice(i,1))}0===r.length&&delete this._hotkeys[e.key]}return t},o.prototype.deregisterHotkey=function(e){var t=[];if(this._validateHotkey(e),angular.isArray(e.key))for(var n=e.key.length-1;n>=0;n--){var r=e.clone();r.key=e.key[n];var i=this._deregisterHotkey(r);void 0!==i&&t.push(i[0])}else t.push(this._deregisterHotkey(e));return t},o.prototype._validateHotkey=function(e){if(!(e instanceof i))throw new TypeError("Hotkeys: Expected a hotkey object be instance of HotKey")},o.prototype._registerKey=function(e){var t=this._hotkeys;return e.onKeyUp&&(t=this._hotkeysUp),t[e.key]=t[e.key]||[],t[e.key].push(e),e},o.prototype._registerKeys=function(e){var t=[];if(angular.isArray(e.key))for(var n=e.key.length-1;n>=0;n--){var r=e.clone();r.id=guid(),r.key=e.key[n],t.push(this._registerKey(r))}else t.push(this._registerKey(e));return t},o.prototype.registerHotkey=function(e){return this._validateHotkey(e),this._registerKeys(e)},o.prototype.registerHotkeyUp=function(e){this._validateHotkey(e),e.onKeyUp=!0,this._registerKeys(e)},o.prototype.createHotkey=function(e){if(null===e.key||void 0===e.key)throw new TypeError('HotKeys: Argument "key" is required');if(null===e.callback||void 0===e.callback)throw new TypeError('HotKeys: Argument "callback" is required');e.callback=(t=e.callback,function(e,r){n.$apply(function(){t.call(this,e,r)}.bind(this))});var t;return new i(e)},o.prototype.match=function(e,t){angular.isArray(t)||(t=[t]);var n=this.keyStringFromEvent(e);return Boolean(~t.indexOf(n))},o.prototype._toggleCheatSheet=function(){var e=this;this._cheatSheet?(o.$modal.hide(),this._cheatSheet=null):this._cheatSheet=o.$modal.show({clickOutsideToClose:!0,escapeToClose:!0,template:["<md-dialog>"," <md-dialog-content>"," <md-list>",' <md-list-item ng-repeat="(hotkey, keys) in hotkeys">',' <div class="sg-hotkey-container">'," <sg-hotkey>{{keys[0].lkey || hotkey}}</sg-hotkey>"," </div>"," {{keys[0].description}}"," </md-list-item>"," </md-list>"," </md-dialog-content>","</md-dialog>"].join(""),controller:t,locals:{hotkeys:e._hotkeys}}).finally(function(){e._cheatSheet=null}),t.$inject=["$scope","hotkeys"];function t(e,t){e.hotkeys=t,e.closeDialog=function(){o.$modal.hide()}}},o}})}(),function(){"use strict";function e(e){e&&this.init(e)}e.factory=["$q","$log","sgSettings","Resource",function(t,n,r,i){return angular.extend(e,{$q:t,$log:n,$$resource:new i(r.activeUser("folderURL"),r.activeUser()),$query:"",$users:[]}),e}],angular.module("SOGo.Common").factory("User",e.factory),e.$filter=function(t,n,r){var i=e.$$resource,o={search:t};if(r&&r.dry)r&&r.uid&&(i=e.$$resource.userResource(r.uid));else{if(!t)return e.$users.splice(0,e.$users.length),e.$q.when(e.$users);if(e.$query==t)return e.$q.when(e.$users);e.$query=t}return i.fetch(null,"usersSearch",o).then(function(t){var i,o,s,a,l=function(e){return this.uid==e.uid};for(r?r.dry?a=[]:r.results&&(a=r.results):a=e.$users,i=n?_.filter(t.users,function(e){return!_.find(n,_.bind(l,e))}):t.users,o=a.length-1;o>=0;o--)s=a[o],_.find(i,_.bind(l,s))||a.splice(o,1);return _.forEach(i,function(t,n){if(_.isUndefined(_.find(a,_.bind(l,t)))){var r=new e(t);a.splice(n,0,r)}}),e.$log.debug(a),a})},e.prototype.init=function(e){angular.extend(this,e),this.$$shortFormat||(this.$$shortFormat=this.$shortFormat()),this.$$image||(this.$$image=this.image),this.$avatarIcon=this.$isGroup()||this.$isSpecial()?"group":"person",this.empty=" "},e.prototype.$fullname=function(){var e=this.cn||this.uid;return this.c_info&&(e+=" ("+this.c_info.split("\n").join("; ")+")"),e},e.prototype.$shortFormat=function(e){var t=this.$fullname(),n=this.c_email;return!(e&&!1===e.email)&&n&&t!=n&&(t+=" <"+n+">"),t},e.prototype.$acl=function(t,n){var r=this,i=e.$q.defer(),o={uid:this.uid};if(this.$shadowRights)i.resolve(this.rights);else{(angular.isDefined(n)?e.$$resource.userResource(n).fetch(t,"userRights",o):e.$$resource.fetch(t,"userRights",o)).then(function(e){return r.rights=e,r.$shadowRights=angular.copy(e),i.resolve(e),e})}return i.promise},e.prototype.$isGroup=function(){return this.isGroup||this.userClass&&"normal-group"==this.userClass},e.prototype.$isAnonymous=function(){return"anonymous"==this.uid},e.prototype.$isSpecial=function(){return this.userClass&&"public-user"==this.userClass},e.prototype.$confirmRights=function(e){var t=!1;return!this.$confirmation&&(_.some(_.values(this.rights))&&("anonymous"==this.uid?"AddressBook"==e.constructor.name?t=l('Potentially anyone on the Internet will be able to access your address book "%{0}", even if they do not have an account on this system. Is this information suitable for the public Internet?',e.name):"Calendar"==e.constructor.name&&(t=l('Potentially anyone on the Internet will be able to access your calendar "%{0}", even if they do not have an account on this system. Is this information suitable for the public Internet?',e.name)):"anyone"!=this.uid&&"<default>"!=this.uid||("AddressBook"==e.constructor.name?t=l('Any user with an account on this system will be able to access your address book "%{0}". Are you certain you trust them all?',e.name):"Calendar"==e.constructor.name?t=l('Any user with an account on this system will be able to access your calendar "%{0}". Are you certain you trust them all?',e.name):"Mailbox"==e.constructor.name&&(t=l('Any user with an account on this system will be able to access your mailbox "%{0}". Are you certain you trust them all?',e.name)))),this.$confirmation=t,t)},e.prototype.$rightsAreDirty=function(){return this.rights&&!_.isEqual(this.rights,this.$shadowRights)},e.prototype.$resetRights=function(e){var t=this;e?_.map(_.keys(this.rights),function(e){angular.isString(t.rights[e])?t.rights[e]="None":t.rights[e]=0}):this.$shadowRights&&(this.rights=angular.copy(this.$shadowRights))},e.prototype.$folders=function(t){var n=this,r=e.$q.defer(),i={type:t};return this.$$folders?r.resolve(this.$$folders):e.$$resource.userResource(this.uid).fetch(null,"foldersSearch",i).then(function(e){n.$$folders=e.folders,r.resolve(e.folders)}),r.promise},e.prototype.$omit=function(){var e={};return angular.forEach(this,function(t,n){"constructor"!=n&&"$"!=n[0]&&(e[n]=t)}),e},e.prototype.toString=function(){return"[User "+this.c_email+"]"}}(),function(){"use strict";e.$inject=["$scope","$element","$http","$q","Preferences","Gravatar"];function e(e,t,n,r,i,o){var s,a;s=this,e.$on("$destroy",function(){a&&t.off("click",a)}),e.$watch(function(){return s.email},function(e,t){e&&s.urlEmail!=e?(l(),i.defaults.SOGoGravatarEnabled&&function(e){var t=o(e,s.size,i.defaults.SOGoAlternateAvatar);n({method:"GET",url:t,cache:!0,headers:{Accept:"image/*"}}).then(function(){s.url||(s.url=t,s.urlEmail=e,c())},function(){l()})}(e)):e||l()}),"sg-src"in t[0].attributes&&e.$watch(function(){return s.src},function(e){e&&(s.url=e,s.urlEmail=""+s.email,t.addClass("sg-avatar-image--zoomable"),a=function(){t.toggleClass("sg-avatar-image--zoom")},t.on("click",a),c())});function l(){s.url=null,s.urlEmail=null,s.img.addClass("ng-hide"),s.genericImg.removeClass("ng-hide")}function c(){s.genericImg.addClass("ng-hide"),s.img.removeClass("ng-hide")}}angular.module("SOGo.Common").directive("sgAvatarImage",function(){return{restrict:"AE",scope:{},bindToController:{size:"@",email:"=sgEmail",src:"=sgSrc"},transclude:!0,template:['<div class="sg-icon-badge-container">'," <md-icon ng-transclude></md-icon>",' <md-icon class="md-warn sg-icon--badge sg-icon--badge-bottom"',' style="display: none">not_interested</md-icon>',' <img class="ng-hide" ng-src="{{vm.url}}">',"</div>"].join(""),link:function(e,t,n,r){var i,o=t.find("img"),s=t.find("md-icon"),a=angular.element(s[0]),l=angular.element(s[1]);n.size&&(o.attr("width",n.size),o.attr("height",n.size),a.css("font-size",n.size+"px"),l.css("font-size",parseInt(.4*n.size)+"px")),angular.isDefined(n.ngDisabled)&&(i=e.$watch(n.ngDisabled,function(e){n.disabled&&l.css({display:"block"}),i()})),r.img=o,r.genericImg=a},controller:"sgAvatarImageController",controllerAs:"vm"}}).controller("sgAvatarImageController",e)}(),function(){"use strict";e.$inject=["$mdUtil","$animateCss","$$rAF"];function e(e,t,n){return{link:function(e,r){var i=r[0].querySelector(".sg-button-toggle"),o=i.querySelector(".sg-icon-toggle"),s="md-rotate-180-ccw",a=r[0].querySelector(".sg-block-toggle"),l=!1;i.classList.add("md-clickable"),angular.element(i).on("click",function(){(l=!l)?o.classList.add(s):o.classList.remove(s);l&&(a.style.visibility="visible");n(function(){var e=l?a.scrollHeight:0;t(angular.element(a),{easing:"cubic-bezier(0.35, 0, 0.25, 1)",to:{height:e+"px"},duration:.75}).start().then(function(){c()})})}),c();function c(){a.setAttribute("aria-hidden",!l),a.setAttribute("aria-expanded",l),l||(a.style.visibility="hidden")}}}}angular.module("SOGo.Common").directive("sgBlockToggle",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgCheckmark",e),e.$inject=["$parse","$mdAria","$mdTheming","$mdUtil"];function e(e,t,n,r){var i="sg-checked";return{restrict:"E",replace:!0,transclude:!0,require:"?ngModel",template:['<button class="md-button sg-checkmark" type="button">'," <md-icon>check</md-icon>"," <span ng-transclude></span","</button>"].join(""),compile:function(o,s){return o.on("click",function(e){this.hasAttribute("disabled")&&e.stopImmediatePropagation()}),function(o,s,a,l){var c=d(e,o,"sgTrueValue",a.sgTrueValue,!0),u=d(e,o,"sgFalseValue",a.sgFalseValue,!1);l=l||r.fakeNgModel(),n(s),t.expectWithText(s,"aria-label"),s.on("click",function(e){s[0].hasAttribute("disabled")||o.$apply(function(){var t=l.$viewValue==c?u:c;l.$setViewValue(t,e&&e.type),l.$render()})}),l.$render=function(){l.$viewValue==c?s.addClass(i):s.removeClass(i)};function d(e,t,n,r,i){var o;if(angular.isDefined(r)){if(!(o=e(r)).constant)throw Error("Expected constant expression for `"+n+"`, but saw `"+r+"`.");return o(t)}return i}}}}}}(),function(){"use strict";e.$inject=["$scope","$element","$mdPanel","sgColors"];function e(e,t,n,r){var i,o,s;this.$onInit=function(){i=this,o=t.controller("ngModel")},this.$postLink=function(){this.buttonIcon=t.find("md-icon"),o.$render=function(){a(o.$viewValue)}};function a(e){s=e,i.buttonIcon.css("color",s)}this.showPicker=function(e){for(var t=n.newPanelPosition().relativeTo(i.buttonIcon).addPanelPosition(n.xPosition.ALIGN_START,n.yPosition.ALIGN_TOPS),l=n.newPanelAnimation().openFrom(i.buttonIcon).duration(100).withAnimation(n.animation.FADE),c=[],u="",d=0;d<r.selection.length;d++){var h=r.selection[d],m=contrast(h),g=h==s;d%7==0&&(u.length&&c.push(u),u=""),u+="<span ",g&&(u+='class="selected" '),u+='style="background-color: '+h+'" ng-click="$menuCtrl.setColor($event, \''+h+"')\">",g&&(u+='<md-icon class="icon-check" style="color: '+m+'"></md-icon>'),u+="</span>"}var p={attachTo:angular.element(document.body),bindToController:!0,controller:f,controllerAs:"$menuCtrl",position:t,animation:l,targetEvent:e,template:['<div class="sg-color-picker-panel" md-whiteframe="3">'," <div>"+c.join("</div><div>")+"</div>","</div>"].join(""),trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};n.open(p).then(function(e){e.panelEl.one("click",function(){e.close()})}),f.$inject=["mdPanelRef","$state","$mdDialog","User"];function f(e,t,n,r){this.setColor=function(e,t){e&&(_.forEach(e.currentTarget.parentElement.children,function(e){e.classList.remove("selected")}),e.currentTarget.classList.add("selected")),a(t),o.$setViewValue(t)}}}}angular.module("SOGo.Common").directive("sgColorPicker",function(){return{restrict:"E",require:"ngModel",template:[' <md-button class="md-icon-button"',' label:aria-label="Options"',' ng-click="$ctrl.showPicker($event)">'," <md-icon>format_color_fill</md-icon>"," </md-button>"].join(""),controller:e,controllerAs:"$ctrl"}})}(),function(){"use strict";e.$inject=["$compile"];function e(e){return{restrict:"A",link:function(t,n,r){var i=t.$watch(function(e){return e.$eval(r.sgCompile)},function(r){n.html(r),e(n.contents())(t),i()})}}}angular.module("SOGo.Common").directive("sgCompile",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgDatepickerReadonlyInput",function(){return{link:function(e,t,n,r){var i=e.$watch(function(){return t.find("input").eq(0)},function(e){e.length&&(i(),e.prop("disabled",!0),e.parent().addClass("sg-datepicker-readonly-input-container"))})},require:"mdDatepicker",restrict:"A"}})}(),function(){"use strict";e.$inject=["$parse","$rootScope","$document","$timeout","$log"];function e(e,t,n,r,i){return{restrict:"A",link:function(o,s,a){var l;r(function(){var t,n,r;t=e(a.sgDraggable)(o),n=a.sgDragStart?e(a.sgDragStart):null,r=a.sgDragCount?e(a.sgDragCount):null,l=new c(s,t,n,r)}),o.$on("$destroy",function(){l.$destroy()});function c(e,t,r,i){if(this.$element=e,this.folder=t,this.dragStart=r,this.count=i,this.helper=n.find("sg-draggable-helper"),!this.helper)throw Error("sg-draggable requires a sg-draggable-helper element.");this.bindedOnDragDetect=angular.bind(this,this.onDragDetect),this.bindedOnDrag=angular.bind(this,this.onDrag),this.$element.on("mousedown",this.bindedOnDragDetect)}c.prototype={dragHasStarted:!1,$destroy:function(){this.$element.off("mousedown",this.bindedOnDragDetect)},getDistanceFromStart:function(e){var t={x:this.startPosition.clientX-e.clientX,y:this.startPosition.clientY-e.clientY};return Math.sqrt(t.x*t.x+t.y*t.y)},onDragDetect:function(e){e.stopPropagation(),this.dragStart&&!this.dragStart(o)||(n.on("mousemove",this.bindedOnDrag),n.one("mouseup",angular.bind(this,this.onDragEnd)))},onDrag:function(e){var n;this.startPosition?!this.dragHasStarted&&this.getDistanceFromStart(e)>10&&(n=this.helper.find("sg-draggable-helper-counter"),this.dragHasStarted=!0,this.helper.removeClass("ng-hide"),this.count&&this.count(o)>1?n.text(this.count(o)).removeClass("ng-hide"):n.addClass("ng-hide"),i.debug("emit folder:dragstart"),t.$emit("folder:dragstart",this.folder)):this.startPosition={clientX:e.clientX,clientY:e.clientY},this.dragHasStarted&&(e.shiftKey||this.folder.isRemote?this.helper.addClass("sg-draggable-helper--copy"):this.helper.removeClass("sg-draggable-helper--copy"),this.helper.css({top:e.pageY+5+"px",left:e.pageX+5+"px"}))},onDragEnd:function(e){var r="move";this.startPosition=null,n.off("mousemove",this.bindedOnDrag),this.dragHasStarted&&((e.shiftKey||this.folder.isRemote)&&(r="copy"),i.debug("emit folder:dragend"),t.$emit("folder:dragend",this.folder,r),this.dragHasStarted=!1,this.helper.addClass("ng-hide"))}}}}}angular.module("SOGo.Common").directive("sgDraggable",e)}(),function(){"use strict";e.$inject=["$parse","$rootScope","$document","$timeout","$log"];function e(e,t,n,r,i){return{restrict:"A",link:function(n,r,i){var o,s,a,l,c=!1;if(!i.sgDrop)throw Error("sg-droppable requires a sg-drop action.");c=!1,s=e(i.sgDroppable),o=e(i.sgDrop),a=t.$on("folder:dragstart",function(e,t){s(n,{dragFolder:t})&&(r.on("mouseenter",u),r.on("mouseleave",d))}),l=t.$on("folder:dragend",function(e,t,i){r.off("mouseenter"),r.off("mouseleave"),c&&(angular.bind(r[0],d)(e),o(n,{dragFolder:t,dragMode:i}))}),n.$on("destroy",function(){a(),l()});function u(e){c=!0,r.addClass("sg-droppable-over")}function d(e){c=!1,this.classList.remove("sg-droppable-over"),r.off("mousemove")}}}}angular.module("SOGo.Common").directive("sgDroppable",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgEnter",function(){return function(e,t,n){t.bind("keydown keypress",function(t){13===t.which&&(e.$apply(n.sgEnter),t.preventDefault())})}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgEscape",function(){return function(e,t,n){t.bind("keydown",function(t){27===t.keyCode&&e.$apply(n.sgEscape)})}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgFocusOn",function(){return function(e,t,n){e.$on("sgFocusOn",function(e,r){r===n.sgFocusOn&&(t[0].focus(),"function"==typeof t[0].select&&t[0].select())})}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgFolderStylesheet",function(){return{restrict:"E",require:"ngModel",scope:{ngModel:"="},replace:!0,bindToController:!0,controller:function(){this.contrast=contrast,this.transparent=function(e,t){var n=hexToRgb(e);return["rgba("+n.r,n.g,n.b,t+")"].join(",")}},controllerAs:"cssCtrl",template:['<style type="text/css">'," .bg-folder{{ cssCtrl.ngModel.id }} {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .sg-event.bg-folder{{ cssCtrl.ngModel.id }} md-icon {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," md-toolbar.bg-folder{{ cssCtrl.ngModel.id }} md-icon:not(.sg-icon-toolbar-bg) {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .bg-folder{{ cssCtrl.ngModel.id }} label,"," .bg-folder{{ cssCtrl.ngModel.id }} .md-input {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," opacity: 0.8;"," }"," .fg-folder{{ cssCtrl.ngModel.id }},"," .sg-event.fg-folder{{ cssCtrl.ngModel.id }} md-icon {"," color: {{ cssCtrl.ngModel.color }} !important;"," }"," .bdr-folder{{ cssCtrl.ngModel.id }} {"," border-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .contrast-bdr-folder{{ cssCtrl.ngModel.id }} {"," border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .checkbox-folder{{ cssCtrl.ngModel.id }} .md-icon {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .checkbox-folder{{ cssCtrl.ngModel.id }}.md-checked .md-icon:after {"," border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .md-switch-folder{{ cssCtrl.ngModel.id }}.md-checked .md-thumb {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .md-switch-folder{{ cssCtrl.ngModel.id }}.md-checked .md-bar {",' background-color: {{ cssCtrl.transparent(cssCtrl.ngModel.color, "0.5") }} !important;'," }"," .md-switch-folder{{ cssCtrl.ngModel.id }} .md-bar {",' background-color: {{ cssCtrl.transparent(cssCtrl.ngModel.color, "0.3") }} !important;'," }","</style>"].join("")}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgNoDirtyCheck",function(){return{restrict:"A",require:"ngModel",link:function(e,t,n,r){if(r){var i=r.$pristine&&!r.$dirty;i&&(r.$pristine=!1,r.$dirty=!0)}}}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgPlaceholder",function(){return{restrict:"A",scope:{placeholder:"=sgPlaceholder"},link:function(e,t,n){e.$watch("placeholder",function(){t[0].placeholder=e.placeholder})}}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgResetOnDisabled",function(){return{link:function(e,t,n,r){var i=e.$watch(function(){return t.find("input").eq(0)},function(e){e.length&&(i(),r.$scope.$watch("ctrl.isDisabled",function(e){e&&r.ngModelCtrl.$invalid&&r.$scope.$emit("md-calendar-change",r.date)}))})},require:"mdDatepicker",restrict:"A"}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgRippleClick",e),e.$inject=["$log","$timeout"];function e(e,t){return{restrict:"A",compile:function(n,r){return function(n,r,i){var o,s,a,l;for(l=r.attr("sg-ripple-click"),a=r[0].parentNode;a&&a.id!=l;)a=a.parentNode;a?(s=a.querySelector("sg-ripple-content"))?((o=a.querySelector("sg-ripple"))?o=angular.element(o):(o=angular.element('<sg-ripple class="md-default-theme md-bg"></sg-ripple>'),a.appendChild(o[0]),s.classList.contains("ng-hide")||s.classList.add("ng-hide")),r.on("click",c),n.$on("$destroy",function(){r.off("click",c)})):e.error("sg-ripple-content not found inside #"+l):e.error("No parent element found with id "+l);function c(e){var n;r[0].hasAttribute("disabled")||(n=e.pageX&&e.pageY?{left:e.pageX,top:e.pageY}:e.target.getBoundingClientRect(),s.classList.contains("ng-hide")?(angular.element(a).css({overflow:"hidden",position:"relative"}),angular.element(s).css({top:a.scrollTop+"px"}),t(function(){o.css({top:n.top-a.offsetTop+a.scrollTop+"px",left:n.left-a.offsetLeft+"px",height:"400vmin",width:"400vmin"}),s.classList.remove("ng-hide")})):(o.css({top:n.top-a.offsetTop+a.scrollTop+"px",left:n.left-a.offsetLeft+"px",height:"0px",width:"0px"}),s.classList.add("ng-hide"),t(function(){angular.element(a).css({overflow:"",position:""})},800)))}}}}}}(),function(){"use strict";e.$inject=["$parse"];function e(e){return{restrict:"A",controller:"sgSearchController",controllerAs:"$sgSearchController",priority:1001,compile:function(t,n){t.find("md-input-container");var r=t.find("input"),i=t.find("md-select"),o=t.find("md-button");r.attr("ng-model","$sgSearchController.searchText"),r.attr("ng-model-options","$sgSearchController.searchTextOptions"),r.attr("ng-change","$sgSearchController.onChange()"),i&&(i.attr("ng-model","$sgSearchController.searchField"),i.attr("ng-change","$sgSearchController.onChange()"));o&&o.attr("sg-search-cancel")?(o.attr("ng-click",o.attr("sg-search-cancel")),o.removeAttr("sg-search-cancel")):o=null;return function(t,n,i,s){var a=n.find("button");s.formName=n.attr("name"),s.inputName=r.attr("name"),s.allowDot=e(n.attr("sg-allow-dot"))(t),s.fields=e(n.attr("sg-search-fields"))(t),s.doSearch=e(n.attr("sg-search")),o&&a&&a.on("click",s.cancelSearch)}}}}t.$inject=["$window","$scope","$element"];function t(e,t,n){var r=this;if(r.searchText=null,r.searchTextOptions={updateOn:"default blur",debounce:{default:300,blur:0}},n.attr("sg-search-fields"))var i=t.$watch(r.fields,function(e){r.searchField=_.clone(r.fields),i()});r.onChange=function(){var e=t[r.formName],n=e[r.inputName],i=n.$viewValue;(r.allowDot&&"."==i||e.$valid&&i)&&("."==i&&n.$setValidity("minlength",!0),r.doSearch(t,{searchText:i,searchField:r.searchField}))},r.cancelSearch=function(){r.searchText=null}}angular.module("SOGo.Common").controller("sgSearchController",t).directive("sgSearch",e).directive("sgSearch",function(){return{restrict:"A",priority:1e3,transclude:!0,compile:function(e,t){return function(e,t,n,r,i){i(function(e){t.append(e)})}}}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgSelectOnly",function(){return{link:function(e,t,n,r){var i=e.$watch(function(){return t.find("input").eq(0)},function(t){var n;t.length&&(i(),n=t.controller("ngModel"),t.on("blur",function(){r.scope.selectedItem||e.$applyAsync(n.$setValidity("required",!1))}))})},require:"mdAutocomplete",restrict:"A"}})}(),function(){"use strict";e.$inject=["User"];function e(e){return{restrict:"A",scope:{folderType:"@sgSubscribe",onFolderSelect:"&sgSubscribeOnSelect"},replace:!1,bindToController:!0,controller:n,controllerAs:"$sgSubscribeDialogController",link:t}}function t(e,t,n,r){t.find("input");t.on("click",r.showDialog)}n.$inject=["$mdDialog"];function n(e){var t=this;t.showDialog=function(){e.show({templateUrl:"../Contacts/UIxContactsUserFolders",clickOutsideToClose:!0,locals:{folderType:t.folderType,onFolderSelect:t.onFolderSelect},controller:r,controllerAs:"subscribe"})}}r.$inject=["$mdDialog","folderType","onFolderSelect","User"];function r(e,t,n,r){var i=this;i.selectedUser=null,i.users=[],i.searchTextOptions={updateOn:"default blur",debounce:{default:300,blur:0}},i.onChange=function(e){r.$filter(i.searchText,null,{results:i.users}).then(function(t){e.$setValidity("matches",t.length>0),e.$setTouched(),i.selectedUser&&_.isUndefined(_.find(t,function(e){return e.uid==i.selectedUser.uid}))&&(i.selectedUser=null)})},i.selectUser=function(e){i.selectedUser==i.users[e]?i.selectedUser=null:i.users[e].$folders(t).then(function(){i.selectedUser=i.users[e]})},i.selectFolder=function(e){n({folderData:e})},i.close=function(){e.hide()}}angular.module("SOGo.Common").directive("sgSubscribe",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgTimePane",function(){return{template:['<div class="sg-time-pane">',' <div class="hours-pane">',' <div ng-repeat="hoursBigLine in hours" layout="row" layout-xs="column">',' <div ng-repeat="hoursLine in hoursBigLine" layout="row" class="hours">',' <md-button class="hourBtn sg-time-selection-indicator" id="{{hour.id}}"'," md-no-ink",' ng-repeat="hour in hoursLine"',' ng-click="hourClickHandler(hour.displayName)">{{hour.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div class="min5" ng-show="is5min()">',' <div layout="row" layout-xs="column">',' <div ng-repeat="minutesLine in min5" layout="row">',' <md-button class="minuteBtn sg-time-selection-indicator" id="{{minute.id}}"'," md-no-ink",' ng-repeat="minute in minutesLine"',' ng-click="minuteClickHandler(minute.displayName)">{{minute.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div class="sg-time-scroll-mask" ng-hide="is5min()">',' <div class="min1" layout="row" layout-xs="column" layout-wrap>',' <div ng-repeat="minutesLine in min1" layout="row" layout-align="space-around center">',' <md-button class="minuteBtn sg-time-selection-indicator" id="{{minute.id}}"'," md-no-ink",' ng-repeat="minute in minutesLine"',' ng-click="minuteClickHandler(minute.displayName)">{{minute.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div flex layout="row" layout-align="center center" md-colors="::{background: \'default-background-200\'}">',' <md-button class="toggleBtn md-fab md-mini" ng-bind="getToggleBtnLbl()" ng-click="toggleManual5min()"></md-button>'," </div>","</div>"].join(""),scope:{},require:["ngModel","sgTimePane","?^mdInputContainer"],controller:t,controllerAs:"ctrl",bindToController:!0,link:function(e,t,n,r){var i=r[0],o=r[1],s=r[2];if(s)throw Error("sg-timepicker should not be placed inside md-input-container.");o.configureNgModel(i,o)}}});var e=0;t.$inject=["$element","$scope","$$mdDateUtil","$mdUtil","$mdConstant","$mdTheming","$$rAF","$attrs","$mdDateLocale"];function t(t,n,r,i,o,s,a,l,c){var u;s(t),this.$element=t,this.$scope=n,this.dateUtil=r,this.$mdUtil=i,this.keyCode=o.KEY_CODE,this.$$rAF=a,this.timePaneElement=t[0].querySelector(".sg-time-pane"),this.ngModelCtrl=null,this.SELECTED_TIME_CLASS="sg-time-selected",this.FOCUSED_TIME_CLASS="md-focus",this.id=e++,this.displayTime=null,this.selectedTime=null,this.isInitialized=!1,n.hours=[],n.hours[0]=[],n.hours[0][0]=[],n.hours[0][1]=[],n.hours[1]=[],n.hours[1][0]=[],n.hours[1][1]=[];for(var d=0;d<6;d++)n.hours[0][0][d]={id:"tp-"+this.id+"-hour-"+d,displayName:d<10?"0"+d:""+d,selected:!1},n.hours[0][1][d]={id:"tp-"+this.id+"-hour-"+(d+6),displayName:d+6<10?"0"+(d+6):""+(d+6),selected:!1},n.hours[1][0][d]={id:"tp-"+this.id+"-hour-"+(d+12),displayName:""+(d+12),selected:!1},n.hours[1][1][d]={id:"tp-"+this.id+"-hour-"+(d+18),displayName:""+(d+18),selected:!1};for(n.min5=[],n.min5[0]=[],n.min5[1]=[],d=0;d<6;d++)u=5*d,n.min5[0][d]={id:"tp-"+this.id+"-minute5-"+u,displayName:u<10?":0"+u:":"+u,selected:!0},n.min5[1][d]={id:"tp-"+this.id+"-minute5-"+(u+30),displayName:":"+(u+30),selected:!1};for(n.min1=[],d=0;d<12;d++){n.min1[d]=[];for(var h=0;h<5;h++)u=5*d+h,n.min1[d][h]={id:"tp-"+this.id+"-minute-"+u,displayName:u<10?":0"+u:":"+u,selected:!0}}n.show5min=!0,n.getToggleBtnLbl=function(){return n.is5min()?">>":"<<"},n.toggleManual5min=function(){n.manual5min=!n.is5min()},n.is5min=function(){return!0===n.manual5min||!1===n.manual5min?n.manual5min:n.show5min},l.tabindex||t.attr("tabindex","-1");var m=this;this.hourClickHandler=function(e){var t=new Date(m.displayTime);t.setHours(Number(e)),m.setNgModelValue(t,"hours")},n.hourClickHandler=this.hourClickHandler,this.minuteClickHandler=function(e){var t=e.substr(1),n=new Date(m.displayTime);n.setMinutes(Number(t)),m.setNgModelValue(n,"minutes")},n.minuteClickHandler=this.minuteClickHandler;var g=angular.bind(this,this.handleKeyEvent);angular.element(document.body).on("keydown",g),n.$on("$destroy",function(){angular.element(document.body).off("keydown",g)})}t.prototype.configureNgModel=function(e,t){var n=this;n.ngModelCtrl=e,n.$mdUtil.nextTick(function(){n.isInitialized=!0}),e.$render=function(){var e=this.$viewValue;n.$mdUtil.nextTick(function(){n.changeSelectedTime(e,t)})}},t.prototype.changeSelectedTime=function(e,t){var n=this.selectedTime;if(this.selectedTime=e,this.displayTime=new Date(e),n){var r=n.getHours(),i=document.getElementById("tp-"+t.id+"-hour-"+r);i&&(i.classList.remove(this.SELECTED_TIME_CLASS),i.setAttribute("aria-selected","false"));var o=n.getMinutes(),s=document.getElementById("tp-"+t.id+"-minute-"+o);s&&(s.classList.remove(this.SELECTED_TIME_CLASS),s.setAttribute("aria-selected","false"));var a=document.getElementById("tp-"+t.id+"-minute5-"+o);a&&(a.classList.remove(this.SELECTED_TIME_CLASS),a.setAttribute("aria-selected","false"))}if(e){var l,c=e.getHours(),u=document.getElementById("tp-"+t.id+"-hour-"+c);u&&(u.classList.add(this.SELECTED_TIME_CLASS),u.setAttribute("aria-selected","true"));var d=e.getMinutes();d%5==0?(t.$scope.show5min=!0,(l=document.getElementById("tp-"+t.id+"-minute5-"+d))&&(l.classList.add(this.SELECTED_TIME_CLASS),l.setAttribute("aria-selected","true"))):t.$scope.show5min=!1,(l=document.getElementById("tp-"+t.id+"-minute-"+d))&&(l.classList.add(this.SELECTED_TIME_CLASS),l.setAttribute("aria-selected","true"))}},t.prototype.setNgModelValue=function(e,t){return this.$scope.$emit("sg-time-pane-change",{date:e,changed:t}),this.ngModelCtrl.$setViewValue(e),this.ngModelCtrl.$render(),e},t.prototype.handleKeyEvent=function(e){var t=this;this.$scope.$apply(function(){return e.which==t.keyCode.ESCAPE||e.which==t.keyCode.TAB?(t.$scope.$emit("md-time-pane-close"),void(e.which==t.keyCode.TAB&&e.preventDefault())):e.which===t.keyCode.ENTER?(t.setNgModelValue(t.displayTime,"enter"),void e.preventDefault()):void 0})},t.prototype.focus=function(e,t){var n=e||this.selectedTime||this.today,r=this.timePaneElement.querySelector(".md-focus");if(r&&r.classList.remove(this.FOCUSED_TIME_CLASS),n){var i=n.getHours(),o=document.getElementById("tp-"+t.id+"-hour-"+i);o&&(o.classList.add(this.FOCUSED_TIME_CLASS),o.focus())}}}(),function(){"use strict";angular.module("SOGo.Common").directive("sgTimepicker",e),e.$inject=["$mdUtil","$mdAria"];function e(e,t){return{template:function(e,t){var n=t.ariaLabel||t.mdPlaceholder;return['<md-button class="sg-timepicker-button md-icon-button" type="button" ',' tabindex="-1" aria-hidden="true" ',' ng-click="ctrl.openTimePane($event)">',' <md-icon class="sg-timepicker-icon">access_time</md-icon>',"</md-button>",'<div class="md-default-theme sg-timepicker-input-container" '," ng-class=\"{'sg-timepicker-focused': ctrl.isFocused}\">",' <input class="sg-timepicker-input" ',n?'aria-label="'+n+'" ':"",' aria-haspopup="true"',' aria-expanded="{{ctrl.isTimeOpen}}" ',' aria-owns="{{::ctrl.timePaneId}}"',' ng-focus="ctrl.setFocused(true)" ng-blur="ctrl.setFocused(false)">',' <md-button type="button" md-no-ink ',' class="sg-timepicker-triangle-button md-icon-button" ',' ng-click="ctrl.openTimePane($event)" ',' aria-label="{{::ctrl.dateLocale.msgOpenCalendar}}">',' <div class="sg-timepicker-expand-triangle"></div>'," </md-button>","</div>",'<div class="sg-timepicker-time-pane md-whiteframe-z1" id="{{::ctrl.timePaneId}}">',' <div class="sg-timepicker-input-mask">',' <div class="sg-timepicker-input-mask-opaque"></div>'," </div>",' <div class="sg-timepicker-time" md-colors="::{background: \'default-background-A100\'}">',' <sg-time-pane role="dialog" aria-label="{{::ctrl.dateLocale.msgCalendar}}" ',' ng-model="ctrl.time" ng-if="ctrl.isTimeOpen"></sg-time-pane>'," </div>","</div>"].join("")},require:["ngModel","sgTimepicker","?^form"],scope:{placeholder:"@mdPlaceholder"},controller:s,controllerAs:"ctrl",bindToController:!0,link:function(t,n,r,i){var o=i[0],s=i[1],a=i[2];e.parseAttributeBoolean(r.mdNoAsterisk);if(s.configureNgModel(o),a)var l=t.$watch(function(){return a.$submitted},function(e){e&&(s.updateErrorState(),l())})}}}var t="sg-timepicker-invalid",n="sg-timepicker-open",r={MIN5:{GTXS:192,XS:311},MIN1:{GTXS:384,XS:474}},i={GTXS:530,XS:294},o=/ipad|iphone|ipod|android/i;s.$inject=["$scope","$element","$attrs","$window","$mdConstant","$mdTheming","$mdUtil","$mdDateLocale","$$mdDateUtil","$$rAF","$mdMedia"];function s(e,t,n,r,i,s,a,l,c,u,d){this.$window=r,this.dateLocale=l,this.dateUtil=c,this.$mdConstant=i,this.$mdUtil=a,this.$$rAF=u,this.$mdMedia=d,this.documentElement=angular.element(document.documentElement),this.ngModelCtrl=null,this.inputElement=t[0].querySelector("input"),this.ngInputElement=angular.element(this.inputElement),this.inputContainer=t[0].querySelector(".sg-timepicker-input-container"),this.timePane=t[0].querySelector(".sg-timepicker-time-pane"),this.timeButton=t[0].querySelector(".sg-timepicker-button"),this.inputMask=angular.element(t[0].querySelector(".sg-timepicker-input-mask-opaque")),this.$element=t,this.$attrs=n,this.$scope=e,this.date=null,this.isFocused=!1,this.isDisabled=!1,this.setDisabled(t[0].disabled||angular.isString(n.disabled)),this.isTimeOpen=!1,this.timePaneOpenedFrom=null,this.timePaneId="sg-time-pane"+a.nextUid(),this.bodyClickHandler=angular.bind(this,this.handleBodyClick),this.windowEventName=o.test(navigator.userAgent||navigator.vendor||window.opera)?"orientationchange":"resize",this.windowEventHandler=a.debounce(angular.bind(this,this.closeTimePane),100),this.windowBlurHandler=angular.bind(this,this.handleWindowBlur),this.leftMargin=20,this.topMargin=null,n.tabindex?(this.ngInputElement.attr("tabindex",n.tabindex),n.$set("tabindex",null)):n.$set("tabindex","-1"),s(t),s(angular.element(this.timePane)),this.installPropertyInterceptors(),this.attachChangeListeners(),this.attachInteractionListeners();var h=this;e.$on("$destroy",function(){h.detachTimePane()})}s.prototype.configureNgModel=function(e){this.ngModelCtrl=e;var t=this;t.ngModelCtrl.$formatters.push(function(e){if(e&&!(e instanceof Date))throw Error("The ng-model for sg-timepicker must be a Date instance. Currently the model is a: "+typeof e);return t.time=e,t.inputElement.value=t.dateLocale.formatTime(e),t.resizeInputElement(),t.updateErrorState(),e}),e.$viewChangeListeners.unshift(angular.bind(this,this.updateErrorState))},s.prototype.attachChangeListeners=function(){var e=this;e.$scope.$on("sg-time-pane-change",function(n,r){var i=new Date(r.date);e.ngModelCtrl.$setViewValue(i),e.time=i,e.inputElement.value=e.dateLocale.formatTime(i),"minutes"==r.changed&&e.closeTimePane(),e.resizeInputElement(),e.inputContainer.classList.remove(t)}),e.ngInputElement.on("input",angular.bind(e,e.resizeInputElement));var n=angular.isDefined(this.debounceInterval)?this.debounceInterval:500;e.ngInputElement.on("input",e.$mdUtil.debounce(e.handleInputEvent,n,e))},s.prototype.attachInteractionListeners=function(){var e=this,t=this.$scope,n=this.$mdConstant.KEY_CODE;e.ngInputElement.on("keydown",function(r){r.altKey&&r.keyCode==n.DOWN_ARROW&&(e.openTimePane(r),t.$digest())}),t.$on("md-time-close",function(){e.closeTimePane()})},s.prototype.installPropertyInterceptors=function(){var e=this;if(this.$attrs.ngDisabled){var t=this.$scope.$parent;t&&t.$watch(this.$attrs.ngDisabled,function(t){e.setDisabled(t)})}Object.defineProperty(this,"placeholder",{get:function(){return e.inputElement.placeholder},set:function(t){e.inputElement.placeholder=t||""}})},s.prototype.setDisabled=function(e){this.isDisabled=e,this.inputElement.disabled=e,this.timeButton&&(this.timeButton.disabled=e)},s.prototype.updateErrorState=function(e){var n=e||this.date;this.clearErrorState(),this.dateUtil.isValidDate(n)||this.ngModelCtrl.$setValidity("valid",null===n),this.ngModelCtrl.$valid||this.inputContainer.classList.add(t)},s.prototype.clearErrorState=function(){this.inputContainer.classList.remove(t),["valid"].forEach(function(e){this.ngModelCtrl.$setValidity(e,!0)},this)},s.prototype.resizeInputElement=function(){this.inputElement.size=this.inputElement.value.length+3},s.prototype.handleInputEvent=function(e){var t=this.inputElement.value,n=t?this.dateLocale.parseTime(t):null;if(""===t||this.dateUtil.isValidDate(n)){var r=new Date(this.time);r.setHours(n.getHours()),r.setMinutes(n.getMinutes()),this.ngModelCtrl.$setViewValue(r),this.time=r}this.updateErrorState(n)},s.prototype.attachTimePane=function(){var e=this.timePane,t=document.body;e.style.transform="",this.$element.addClass(n),angular.element(t).addClass("md-datepicker-is-showing");var o=this.inputContainer.getBoundingClientRect(),s=t.getBoundingClientRect();(!this.topMargin||this.topMargin<0)&&(this.topMargin=(this.inputMask.parent().prop("clientHeight")-this.ngInputElement.prop("clientHeight"))/2);var a=o.top-s.top-this.topMargin,l=o.left-s.left-this.leftMargin,c=s.top<0&&0===t.scrollTop?-s.top:document.body.scrollTop,u=s.left<0&&0===t.scrollLeft?-s.left:document.body.scrollLeft,d=c+this.$window.innerHeight,h=u+this.$window.innerWidth;this.inputMask.css({position:"absolute",left:this.leftMargin+"px",top:this.topMargin+"px",width:o.width-1+"px",height:o.height-2+"px"});var m=this.$mdMedia("xs")?i.XS:i.GTXS;if(l+m>h){if(h-m>0)l=h-m;else{l=u;var g=this.$window.innerWidth/m;e.style.transform="scale("+g+")"}e.classList.add("sg-timepicker-pos-adjusted")}var p="object"==typeof this.time&&this.time.getMinutes()%5==0?"MIN5":"MIN1",f=this.$mdMedia("xs")?r[p].XS:r[p].GTXS;a+f>d&&d-f>c&&(a=d-f,e.classList.add("sg-timepicker-pos-adjusted")),e.style.left=l+"px",e.style.top=a+"px",document.body.appendChild(e),this.$$rAF(function(){e.classList.add("md-pane-open")})},s.prototype.detachTimePane=function(){this.$element.removeClass(n),angular.element(document.body).removeClass("md-datepicker-is-showing"),this.timePane.classList.remove("md-pane-open"),this.timePane.classList.remove("md-timepicker-pos-adjusted"),this.isTimeOpen&&this.$mdUtil.enableScrolling(),this.timePane.parentNode&&this.timePane.parentNode.removeChild(this.timePane)},s.prototype.openTimePane=function(e){if(!this.isTimeOpen&&!this.isDisabled){this.isTimeOpen=!0,this.timePaneOpenedFrom=e.target,this.$mdUtil.disableScrollAround(this.timePane),this.attachTimePane(),this.evalAttr("ngFocus");var t=this;this.$mdUtil.nextTick(function(){t.documentElement.on("click touchstart",t.bodyClickHandler)},!1),window.addEventListener(this.windowEventName,this.windowEventHandler)}},s.prototype.closeTimePane=function(){if(this.isTimeOpen){this.detachTimePane(),this.ngModelCtrl.$setTouched(),this.evalAttr("ngBlur"),this.documentElement.off("click touchstart",this.bodyClickHandler),window.removeEventListener(this.windowEventName,this.windowEventHandler),this.timePaneOpenedFrom.focus(),this.timePaneOpenedFrom=null,this.isTimeOpen=!1}},s.prototype.getTimePaneCtrl=function(){return angular.element(this.timePane.querySelector("sg-time-pane")).controller("sgTimePane")},s.prototype.focusTime=function(){var e=this;this.$mdUtil.nextTick(function(){var t=e.getTimePaneCtrl();e.getTimePaneCtrl().focus(null,t)},!1)},s.prototype.setFocused=function(e){e||this.ngModelCtrl.$setTouched(),this.evalAttr(e?"ngFocus":"ngBlur"),this.isFocused=e},s.prototype.handleBodyClick=function(e){if(this.isTimeOpen){this.$mdUtil.getClosest(e.target,"sg-time-pane")||this.closeTimePane(),this.$scope.$digest()}},s.prototype.handleWindowBlur=function(){this.inputFocusedOnWindowBlur=document.activeElement===this.inputElement},s.prototype.evalAttr=function(e){this.$attrs[e]&&this.$scope.$parent.$eval(this.$attrs[e])}}(),function(){"use strict";e.$inject=["$parse","$mdUtil","$mdColors"];function e(e,t,n){return{restrict:"A",require:["mdGridList","?ngModel"],compile:function(e,r){return function(i,o,s,a){var l,c,u,d,h,m=e.find("md-grid-tile"),g=[];for((c=a[1]||t.fakeNgModel()).$render=function(){var e=c.$viewValue;g=c.$viewValue,r.sgToggleGridAttr&&(d=r.sgToggleGridAttr,e=_.map(c.$viewValue,r.sgToggleGridAttr));_.forEach(m,function(t){var n=angular.element(t);_.includes(e,n.attr("value"))&&n.addClass("sg-active")}),c.$validate(),p(c.$invalid)},c.$isEmpty=function(e){return!e||0===e.length},h=function(){var e=angular.element(this),t=e.attr("value");e.toggleClass("sg-active"),function(e){var t=_.findIndex(g,function(t){return d?t[d]==e:t==e});if(t<0)if(d){var n={};n[d]=e,g.push(n)}else g.push(e);else g.splice(t,1);i.$apply(function(){c.$setViewValue(g),c.$setDirty(),c.$validate(),p(c.$invalid)})}(t)},u=0;u<m.length;u++)(l=angular.element(m[u])).addClass("sg-icon-button"),l.find("figure").addClass("md-icon"),l.on("click",h);function p(e){var t=o.parent().children()[0];e?(o.addClass("sg-toggle-grid-invalid"),"LABEL"==t.tagName&&(t.style.color=n.getThemeColor("warn"))):(o.removeClass("sg-toggle-grid-invalid"),"LABEL"==t.tagName&&(t.style.color=""))}}}}}angular.module("SOGo.Common").directive("sgToggleGrid",e)}(),String.prototype.endsWith=function(e){return-1!==this.indexOf(e,this.length-e.length)},String.prototype.startsWith=function(e,t){return t=angular.isNumber(t)?t:0,this.lastIndexOf(e,t)===t},String.prototype.encodeEntities=function(){return this.replace(/&/g,"&amp;").replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,function(e){return"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";"}).replace(/([^#-~ |!])/g,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")},String.prototype._base64_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",String.prototype.base64encode=function(){for(var e,t,n,r,i,o,s,a="",l=0,c=this.utf8encode();l<c.length;)r=(e=c.charCodeAt(l++))>>2,i=(3&e)<<4|(t=c.charCodeAt(l++))>>4,o=(15&t)<<2|(n=c.charCodeAt(l++))>>6,s=63&n,isNaN(t)?o=s=64:isNaN(n)&&(s=64),a=a+this._base64_keyStr.charAt(r)+this._base64_keyStr.charAt(i)+this._base64_keyStr.charAt(o)+this._base64_keyStr.charAt(s);return a},String.prototype.base64decode=function(){for(var e,t,n,r,i,o,s="",a=0,l=""+this;a<l.length;)e=this._base64_keyStr.indexOf(l.charAt(a++))<<2|(r=this._base64_keyStr.indexOf(l.charAt(a++)))>>4,t=(15&r)<<4|(i=this._base64_keyStr.indexOf(l.charAt(a++)))>>2,n=(3&i)<<6|(o=this._base64_keyStr.indexOf(l.charAt(a++))),s+=String.fromCharCode(e),64!=i&&(s+=String.fromCharCode(t)),64!=o&&(s+=String.fromCharCode(n));return s},String.prototype.md5=function(){if(this.length){return function(e){function t(e,t){return e<<t|e>>>32-t}function n(e,t){var n,r,i,o,s;return i=2147483648&e,o=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(r=1073741824&t)?2147483648^s^i^o:n|r?1073741824&s?3221225472^s^i^o:1073741824^s^i^o:s^i^o}function r(e,r,i,o,s,a,l){var c,u,d;return n(t(e=n(e,n(n((c=r,u=i,d=o,c&u|~c&d),s),l)),a),r)}function i(e,r,i,o,s,a,l){var c,u,d;return n(t(e=n(e,n(n((c=r,u=i,d=o,c&d|u&~d),s),l)),a),r)}function o(e,r,i,o,s,a,l){var c,u,d;return n(t(e=n(e,n(n((c=r,u=i,d=o,c^u^d),s),l)),a),r)}function s(e,r,i,o,s,a,l){var c,u,d;return n(t(e=n(e,n(n((c=r,u=i,d=o,u^(c|~d)),s),l)),a),r)}function a(e){var t,n="",r="";for(t=0;t<=3;t++)n+=(r="0"+(e>>>8*t&255).toString(16)).substr(r.length-2,2);return n}var l,c,u,d,h,m,g,p,f,y=Array();for(y=function(e){for(var t,n=e.length,r=n+8,i=16*((r-r%64)/64+1),o=Array(i-1),s=0,a=0;a<n;)s=a%4*8,o[t=(a-a%4)/4]=o[t]|e.charCodeAt(a)<<s,a++;return s=a%4*8,o[t=(a-a%4)/4]=o[t]|128<<s,o[i-2]=n<<3,o[i-1]=n>>>29,o}(e=function(e){e=e.replace(/rn/g,"n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)),m=1732584193,g=4023233417,p=2562383102,f=271733878,l=0;l<y.length;l+=16)c=m,u=g,d=p,h=f,g=s(g=s(g=s(g=s(g=o(g=o(g=o(g=o(g=i(g=i(g=i(g=i(g=r(g=r(g=r(g=r(g,p=r(p,f=r(f,m=r(m,g,p,f,y[l+0],7,3614090360),g,p,y[l+1],12,3905402710),m,g,y[l+2],17,606105819),f,m,y[l+3],22,3250441966),p=r(p,f=r(f,m=r(m,g,p,f,y[l+4],7,4118548399),g,p,y[l+5],12,1200080426),m,g,y[l+6],17,2821735955),f,m,y[l+7],22,4249261313),p=r(p,f=r(f,m=r(m,g,p,f,y[l+8],7,1770035416),g,p,y[l+9],12,2336552879),m,g,y[l+10],17,4294925233),f,m,y[l+11],22,2304563134),p=r(p,f=r(f,m=r(m,g,p,f,y[l+12],7,1804603682),g,p,y[l+13],12,4254626195),m,g,y[l+14],17,2792965006),f,m,y[l+15],22,1236535329),p=i(p,f=i(f,m=i(m,g,p,f,y[l+1],5,4129170786),g,p,y[l+6],9,3225465664),m,g,y[l+11],14,643717713),f,m,y[l+0],20,3921069994),p=i(p,f=i(f,m=i(m,g,p,f,y[l+5],5,3593408605),g,p,y[l+10],9,38016083),m,g,y[l+15],14,3634488961),f,m,y[l+4],20,3889429448),p=i(p,f=i(f,m=i(m,g,p,f,y[l+9],5,568446438),g,p,y[l+14],9,3275163606),m,g,y[l+3],14,4107603335),f,m,y[l+8],20,1163531501),p=i(p,f=i(f,m=i(m,g,p,f,y[l+13],5,2850285829),g,p,y[l+2],9,4243563512),m,g,y[l+7],14,1735328473),f,m,y[l+12],20,2368359562),p=o(p,f=o(f,m=o(m,g,p,f,y[l+5],4,4294588738),g,p,y[l+8],11,2272392833),m,g,y[l+11],16,1839030562),f,m,y[l+14],23,4259657740),p=o(p,f=o(f,m=o(m,g,p,f,y[l+1],4,2763975236),g,p,y[l+4],11,1272893353),m,g,y[l+7],16,4139469664),f,m,y[l+10],23,3200236656),p=o(p,f=o(f,m=o(m,g,p,f,y[l+13],4,681279174),g,p,y[l+0],11,3936430074),m,g,y[l+3],16,3572445317),f,m,y[l+6],23,76029189),p=o(p,f=o(f,m=o(m,g,p,f,y[l+9],4,3654602809),g,p,y[l+12],11,3873151461),m,g,y[l+15],16,530742520),f,m,y[l+2],23,3299628645),p=s(p,f=s(f,m=s(m,g,p,f,y[l+0],6,4096336452),g,p,y[l+7],10,1126891415),m,g,y[l+14],15,2878612391),f,m,y[l+5],21,4237533241),p=s(p,f=s(f,m=s(m,g,p,f,y[l+12],6,1700485571),g,p,y[l+3],10,2399980690),m,g,y[l+10],15,4293915773),f,m,y[l+1],21,2240044497),p=s(p,f=s(f,m=s(m,g,p,f,y[l+8],6,1873313359),g,p,y[l+15],10,4264355552),m,g,y[l+6],15,2734768916),f,m,y[l+13],21,1309151649),p=s(p,f=s(f,m=s(m,g,p,f,y[l+4],6,4149444226),g,p,y[l+11],10,3174756917),m,g,y[l+2],15,718787259),f,m,y[l+9],21,3951481745),m=n(m,c),g=n(g,u),p=n(p,d),f=n(f,h);return(a(m)+a(g)+a(p)+a(f)).toLowerCase()}(this.toLowerCase())}},String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)},String.prototype.asDate=function(){var e,t=this.split("/");return 3==t.length?e=new Date(t[2],t[1]-1,t[0]):3==(t=this.split("-")).length?e=new Date(t[0],t[1]-1,t[2]):8==this.length&&(e=new Date(this.substring(0,4),this.substring(4,6)-1,this.substring(6,8))),e},String.prototype.formatted=function(){for(var e=this,t=0;t<arguments.length;t++)e=e.replace("%{"+t+"}",arguments[t],"g");return e},String.prototype.isValidEmail=function(){return/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i.test(this)},String.prototype.asCSSIdentifier=function(){for(var e=["_","\\.","#","@","\\*",":",","," ","'","&","\\+"],t=["_U_","_D_","_H_","_A_","_S_","_C_","_CO_","_SP_","_SQ_","_AM_","_P_"],n=this,r=0;r<e.length;r++){var i=new RegExp(e[r],"g");n=n.replace(i,t[r])}return n=n.replace(/[^\x00-\x7F]/g,""),/^\d+/.test(n)&&(n="_"+n),n},String.prototype.timeInterval=function(){return"once_per_hour"==this?3600:"every_minute"==this?60:60*parseInt(this.substr(6))},String.prototype.parseDate=function(e,t){var n,r,i,o,s,a,c,u,d,h;for(n=""+this,r=/%[dembByYHIMp]/g,s=new Date,a={year:s.getYear()+1900,month:s.getMonth(),day:s.getDate(),hour:0,minute:0},c={"%d":[/\d\d/,function(e){return a.day=parseInt(e),a.day<32}],"%e":[/ ?\d?\d/,function(e){return a.day=parseInt(e),a.day<32}],"%m":[/\d\d/,function(e){return a.month=parseInt(e)-1,a.month<12}],"%b":[/[^\d\s\.\/\-]{2,}/,function(t){var n=_.indexOf(_.map(e.shortMonths,_.toLower),_.toLower(t));return n>=0&&(a.month=n),n>=0}],"%B":[/[^\d\s\.\/\-]{2,}/,function(t){var n=_.indexOf(_.map(e.months,_.toLower),_.toLower(t));return n>=0&&(a.month=n),n>=0}],"%y":[/\d\d/,function(e){var t=parseInt(s.getFullYear().toString().substring(2))+5;return a.year=parseInt(e),a.year<t?a.year+=2e3:a.year+=1900,!0}],"%Y":[/[12]\d\d\d/,function(e){return a.year=parseInt(e),!0}],"%H":[/\d{1,2}/,function(e){return a.hour=parseInt(e),a.hour<24}],"%I":[/\d{1,2}/,function(e){return a.hour=parseInt(e),a.hour<=12}],"%M":[/[0-5]\d/,function(e){return a.minute=parseInt(e),a.minute<60}],"%p":[/[^\d\s\/\-]+/,function(e){var t=_.toLower(e),n=_.toLower(l("AM")),r=_.toLower(l("PM"));return t==r&&(a.hour+=12),t==n||t==r}]},i=t.match(r)||[],h=0,u=0;u<i.length;u++)o=i[u],(d=(n.match(c[o][0])||[])[0])&&(n=n.slice(n.indexOf(d)+d.length),c[o][1](d)&&h++);return i.length===h?new Date(a.year,a.month,a.day,a.hour,a.minute):new Date(NaN)},Date.prototype.daysUpTo=function(e){var t=[],n=this.getTime(),r=e.getTime();if(n>r){var i=n;n=r,r=i}for(var o=Math.round((r-n)/864e5)+1,s=0;s<o;s++){var a=new Date;a.setTime(n+864e5*s),t.push(a)}return t},Date.prototype.minutesTo=function(e){return Math.floor(e.valueOf()-this.valueOf())/1e3/60-(e.getTimezoneOffset()-this.getTimezoneOffset())},Date.prototype.stringWithSeparator=function(e){var t=""+(this.getMonth()+1),n=""+this.getDate(),r=this.getYear();return r<1e3&&(r=""+(r+1900)),1==t.length&&(t="0"+t),1==n.length&&(n="0"+n),str="-"==e?r+"-"+t+"-"+n:n+"/"+t+"/"+r,str},Date.prototype.addDays=function(e){var t,n,r;return n=this.getTime(),t=new Date(n),n+=864e5*e,this.setTime(n),0!==(r=this.getTimezoneOffset()-t.getTimezoneOffset())&&(n=this.getTime()+60*r*1e3,this.setTime(n)),this},Date.prototype.addHours=function(e){var t=this.getTime();t+=36e5*e,this.setTime(t)},Date.prototype.addMinutes=function(e){var t=this.getTime();t+=6e4*e,this.setTime(t)},Date.prototype.beginOfDay=function(){var e=new Date(this.getTime());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),e},Date.prototype.dayOfWeek=function(e){var t,n;return(t=e.firstDayOfWeek)>(n=this.getDay())&&(n+=7),n-t},Date.prototype.firstWeekOfYearForDate=function(e){var t,n,r;return t=e.firstWeekOfYear,(r=new Date(this.getTime())).setMonth(0),r.setDate(1),n=r.dayOfWeek(e),"First4DayWeek"==t?n<4?r.beginOfWeek(e.firstDayOfWeek):r.addDays(7).beginOfWeek(e.firstDayOfWeek):"FirstFullWeek"==t?0===n?r.beginOfWeek(e.firstDayOfWeek):r.addDays(7).beginOfWeek(e.firstDayOfWeek):r.beginOfWeek(e.firstDayOfWeek)},Date.prototype.getWeek=function(e){var t,n,r,i;return(i=new Date(this.getTime())).addDays(6),(t=i.firstWeekOfYearForDate(e)).getTime()<i.getTime()?r=1+Math.floor((i.getTime()-t.getTime())/6048e5):((n=new Date(i.getTime())).addDays(-7),t=n.firstWeekOfYearForDate(e),r=2+Math.floor((n.getTime()-t.getTime())/6048e5)),r},Date.prototype.beginOfWeek=function(e){var t=e-this.getDay();t>0&&(t-=7);var n=this.beginOfDay();return n.setHours(12),n.addDays(t),n},Date.prototype.endOfWeek=function(e){var t=this.beginOfWeek(e);return t.addDays(6),t.setHours(23),t.setMinutes(59),t.setSeconds(59),t.setMilliseconds(999),t},Date.prototype.getDayString=function(){var e=this.getYear();e<1e3&&(e+=1900);var t=""+(this.getMonth()+1);1==t.length&&(t="0"+t),e+=t;var n=""+this.getDate();return 1==n.length&&(n="0"+n),e+=n},Date.prototype.getHourString=function(){var e=this.getHours()+"00";return 3==e.length&&(e="0"+e),e},Date.prototype.format=function(e,t){var n,r,i,o,s=[],a=/%[deaAmbByYUHIMp]/g,c={"%d":this.getDate(),"%e":this.getDate(),"%a":e.shortDays[this.getDay()],"%A":e.days[this.getDay()],"%m":this.getMonth()+1,"%b":e.shortMonths[this.getMonth()],"%B":e.months[this.getMonth()],"%y":this.getFullYear().toString().substring(2),"%Y":this.getFullYear(),"%U":this.getWeek(e),"%H":this.getHours(),"%M":this.getMinutes()};for(c["%I"]=c["%H"]>12?c["%H"]%12:c["%H"],c["%p"]=c["%H"]<12?l("AM"):l("PM"),c["%d"]=(c["%d"]<10?"0":"")+c["%d"],c["%e"]=(c["%e"]<10?" ":"")+c["%e"],c["%m"]=(c["%m"]<10?"0":"")+c["%m"],c["%H"]=(c["%H"]<10?"0":"")+c["%H"],c["%I"]=(c["%I"]<10?"0":"")+c["%I"],c["%M"]=(c["%M"]<10?"0":"")+c["%M"],n=t.replace(a,"\0").split("\0"),i=0,o=(r=t.match(a)).length;i<=o;i++)n.length&&s.push(n.shift()),s.push(c[r[i]]);return s.join("")};function l(){var e,t,n=arguments[0],r=n,i=arguments;for(labels[n]?r=labels[n]:clabels[n]&&(r=clabels[n]),e=1,t=0;e<i.length;e++,t++)r=r.replace("%{"+t+"}",i[e]);return e=1,i.length>1&&(r=r.replace(/%((%)|s|d)/g,function(t){var n=null;if(t[2])n=t[2];else{switch(n=i[e],t){case"%d":n=parseFloat(n),isNaN(n)&&(n=0)}e++}return n})),r}function hexToRgb(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function contrast(e){var t,n,r=1;if(t=hexToRgb(e)){n=[t.r/255,t.g/255,t.b/255];for(var i=0;i<n.length;++i)n[i]<=.03928?n[i]=n[i]/12.92:n[i]=Math.pow((n[i]+.055)/1.055,2.4);r=.2126*n[0]+.7152*n[1]+.0722*n[2]}return r>.179?"black":"white"}function guid(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return(e()+e()+"-"+e()+"-4"+e().substr(0,3)+"-"+e()+"-"+e()+e()+e()).toLowerCase()}
//# sourceMappingURL=Common.js.map