/*! For license information please see user_status-menu.js.LICENSE.txt */ (()=>{"use strict";var e,s,a,r={33114:(t,e,s)=>{s.d(e,{A:()=>n});var a=s(95353),r=s(85168);const n={computed:{...(0,a.aH)({statusType:t=>t.userStatus.status,statusIsUserDefined:t=>t.userStatus.statusIsUserDefined,customIcon:t=>t.userStatus.icon,customMessage:t=>t.userStatus.message}),visibleMessage(){if(this.customIcon&&this.customMessage)return`${this.customIcon} ${this.customMessage}`;if(this.customMessage)return this.customMessage;if(this.statusIsUserDefined)switch(this.statusType){case"online":return this.$t("user_status","Online");case"away":case"busy":return this.$t("user_status","Away");case"dnd":return this.$t("user_status","Do not disturb");case"invisible":return this.$t("user_status","Invisible");case"offline":return this.$t("user_status","Offline")}return this.$t("user_status","Set status")}},methods:{async changeStatus(t){try{await this.$store.dispatch("setStatus",{statusType:t})}catch(t){(0,r.Qg)(this.$t("user_status","There was an error saving the new status")),console.debug(t)}}}}},53611:(t,e,s)=>{s.d(e,{A:()=>a.N});var a=s(90501)},61913:(t,e,s)=>{s.d(e,{R:()=>a});const a=()=>new Date},68238:(t,e,s)=>{s.d(e,{A:()=>u});var a=s(71354),r=s.n(a),n=s(76314),o=s.n(n)()(r());o.push([t.id,".user-status-menu-item[data-v-2c5c2586]{--color-text-maxcontrast: var(--color-text-maxcontrast-background-blur, var(--color-main-text));width:auto;min-width:44px;height:44px;margin:0;border:0;border-radius:var(--border-radius-pill);background-color:var(--color-main-background-blur);font-size:inherit;font-weight:normal;-webkit-backdrop-filter:var(--background-blur);backdrop-filter:var(--background-blur)}.user-status-menu-item[data-v-2c5c2586]:active,.user-status-menu-item[data-v-2c5c2586]:hover,.user-status-menu-item[data-v-2c5c2586]:focus-visible{background-color:var(--color-background-hover)}.user-status-menu-item[data-v-2c5c2586]:focus-visible{box-shadow:0 0 0 4px var(--color-main-background) !important;outline:2px solid var(--color-main-text) !important}.user-status-icon[data-v-2c5c2586]{width:16px;height:16px;margin-right:10px;opacity:1 !important;background-size:16px;vertical-align:middle !important}","",{version:3,sources:["webpack://./apps/user_status/src/UserStatus.vue"],names:[],mappings:"AACA,wCAEC,+FAAA,CAEA,UAAA,CACA,cAAA,CACA,WAAA,CACA,QAAA,CACA,QAAA,CACA,uCAAA,CACA,kDAAA,CACA,iBAAA,CACA,kBAAA,CAEA,8CAAA,CACA,sCAAA,CAEA,mJAGC,8CAAA,CAED,sDACC,4DAAA,CACA,mDAAA,CAIF,mCACC,UAAA,CACA,WAAA,CACA,iBAAA,CACA,oBAAA,CACA,oBAAA,CACA,gCAAA",sourcesContent:["\n.user-status-menu-item {\n\t// Ensure the maxcontrast color is set for the background\n\t--color-text-maxcontrast: var(--color-text-maxcontrast-background-blur, var(--color-main-text));\n\n\twidth: auto;\n\tmin-width: 44px;\n\theight: 44px;\n\tmargin: 0;\n\tborder: 0;\n\tborder-radius: var(--border-radius-pill);\n\tbackground-color: var(--color-main-background-blur);\n\tfont-size: inherit;\n\tfont-weight: normal;\n\n\t-webkit-backdrop-filter: var(--background-blur);\n\tbackdrop-filter: var(--background-blur);\n\n\t&:active,\n\t&:hover,\n\t&:focus-visible {\n\t\tbackground-color: var(--color-background-hover);\n\t}\n\t&:focus-visible {\n\t\tbox-shadow: 0 0 0 4px var(--color-main-background) !important;\n\t\toutline: 2px solid var(--color-main-text) !important;\n\t}\n}\n\n.user-status-icon {\n\twidth: 16px;\n\theight: 16px;\n\tmargin-right: 10px;\n\topacity: 1 !important;\n\tbackground-size: 16px;\n\tvertical-align: middle !important;\n}\n"],sourceRoot:""}]);const u=o},88973:(e,s,a)=>{var r=a(85471),n=a(21777),o=a(61338),u=a(32051),i=a(53611),c=a(17334),d=a.n(c),l=a(65043),m=a(63814),p=a(33114);const A={name:"UserStatus",components:{NcButton:u.A,NcUserStatusIcon:i.A,SetStatusModal:()=>Promise.all([a.e(4208),a.e(5133)]).then(a.bind(a,70256))},mixins:[p.A],props:{inline:{type:Boolean,default:!1}},data:()=>({heartbeatInterval:null,isAway:!1,isModalOpen:!1,mouseMoveListener:null,setAwayTimeout:null}),mounted(){this.$store.dispatch("loadStatusFromInitialState"),OC.config.session_keepalive&&(this.heartbeatInterval=setInterval(this._backgroundHeartbeat.bind(this),3e5),this.setAwayTimeout=()=>{this.isAway=!0},this.mouseMoveListener=d()((()=>{const t=this.isAway;this.isAway=!1,clearTimeout(this.setAwayTimeout),setTimeout(this.setAwayTimeout,12e4),t&&this._backgroundHeartbeat()}),2e3,!0),window.addEventListener("mousemove",this.mouseMoveListener,{capture:!0,passive:!0}),this._backgroundHeartbeat()),(0,o.B1)("user_status:status.updated",this.handleUserStatusUpdated)},beforeDestroy(){window.removeEventListener("mouseMove",this.mouseMoveListener),clearInterval(this.heartbeatInterval),(0,o.al)("user_status:status.updated",this.handleUserStatusUpdated)},methods:{openModal(){this.isModalOpen=!0},closeModal(){this.isModalOpen=!1},async _backgroundHeartbeat(){try{const t=await(async t=>{const e=(0,m.KT)("apps/user_status/api/v1/heartbeat?format=json");return(await l.Ay.put(e,{status:t?"away":"online"})).data.ocs.data})(this.isAway);t?.userId?this.$store.dispatch("setStatusFromHeartbeat",t):await this.$store.dispatch("reFetchStatusFromServer")}catch(t){console.debug("Failed sending heartbeat, got: "+t.response?.status)}},handleUserStatusUpdated(t){OC.getCurrentUser().uid===t.userId&&this.$store.dispatch("setStatusFromObject",{status:t.status,icon:t.icon,message:t.message})}}};var g=a(85072),v=a.n(g),h=a(97825),f=a.n(h),b=a(77659),y=a.n(b),S=a(55056),w=a.n(S),C=a(10540),I=a.n(C),k=a(41113),_=a.n(k),x=a(68238),M={};M.styleTagTransform=_(),M.setAttributes=w(),M.insert=y().bind(null,"head"),M.domAPI=f(),M.insertStyleElement=I(),v()(x.A,M),x.A&&x.A.locals&&x.A.locals;const T=(0,a(14486).A)(A,(function(){var t=this,e=t._self._c;return e(t.inline?"div":"li",{tag:"component"},[t.inline?e("NcButton",{on:{click:function(e){return e.stopPropagation(),t.openModal.apply(null,arguments)}},scopedSlots:t._u([{key:"icon",fn:function(){return[e("NcUserStatusIcon",{staticClass:"user-status-icon",attrs:{status:t.statusType,"aria-hidden":"true"}})]},proxy:!0}])},[t._v("\n\t\t"+t._s(t.visibleMessage)+"\n\t")]):e("button",{staticClass:"user-status-menu-item",on:{click:function(e){return e.stopPropagation(),t.openModal.apply(null,arguments)}}},[e("NcUserStatusIcon",{staticClass:"user-status-icon",attrs:{status:t.statusType,"aria-hidden":"true"}}),t._v("\n\t\t"+t._s(t.visibleMessage)+"\n\t")],1),t._v(" "),t.isModalOpen?e("SetStatusModal",{attrs:{inline:t.inline},on:{close:t.closeModal}}):t._e()],1)}),[],!1,null,"2c5c2586",null).exports;var O=a(95353);const P={state:{predefinedStatuses:[]},mutations:{addPredefinedStatus(t,e){t.predefinedStatuses=[...t.predefinedStatuses,e]}},getters:{statusesHaveLoaded:t=>t.predefinedStatuses.length>0},actions:{async loadAllPredefinedStatuses(t){let{state:e,commit:s}=t;if(e.predefinedStatuses.length>0)return;const a=await(async()=>{const t=(0,m.KT)("apps/user_status/api/v1/predefined_statuses?format=json");return(await l.Ay.get(t)).data.ocs.data})();for(const t of a)s("addPredefinedStatus",t)}}};var U=a(32981),F=a(61913),D=a(19231);const B=t=>{if(null===t)return null;const e=(0,F.R)();if("period"===t.type)return e.setSeconds(e.getSeconds()+t.time),Math.floor(e.getTime()/1e3);if("end-of"===t.type)switch(t.time){case"day":case"week":return Number((0,D.A)(e).endOf(t.time).format("X"))}return"_time"===t.type?t.time:null},E={state:{status:null,statusIsUserDefined:null,message:null,icon:null,clearAt:null,messageIsPredefined:null,messageId:null},mutations:{setStatus(t,e){let{statusType:s}=e;t.status=s,t.statusIsUserDefined=!0},setPredefinedMessage(t,e){let{messageId:s,clearAt:a,message:r,icon:n}=e;t.messageId=s,t.messageIsPredefined=!0,t.message=r,t.icon=n,t.clearAt=a},setCustomMessage(t,e){let{message:s,icon:a,clearAt:r}=e;t.messageId=null,t.messageIsPredefined=!1,t.message=s,t.icon=a,t.clearAt=r},clearMessage(t){t.messageId=null,t.messageIsPredefined=!1,t.message=null,t.icon=null,t.clearAt=null},loadStatusFromServer(t,e){let{status:s,statusIsUserDefined:a,message:r,icon:n,clearAt:o,messageIsPredefined:u,messageId:i}=e;t.status=s,t.message=r,t.icon=n,void 0!==a&&(t.statusIsUserDefined=a),void 0!==o&&(t.clearAt=o),void 0!==u&&(t.messageIsPredefined=u),void 0!==i&&(t.messageId=i)}},getters:{},actions:{async setStatus(t,e){let{commit:s,state:a}=t,{statusType:r}=e;await(async t=>{const e=(0,m.KT)("apps/user_status/api/v1/user_status/status");await l.Ay.put(e,{statusType:t})})(r),s("setStatus",{statusType:r}),(0,o.Ic)("user_status:status.updated",{status:a.status,message:a.message,icon:a.icon,clearAt:a.clearAt,userId:(0,n.HW)()?.uid})},async setStatusFromObject(t,e){let{commit:s,state:a}=t;s("loadStatusFromServer",e)},async setPredefinedMessage(t,e){let{commit:s,rootState:a,state:r}=t,{messageId:u,clearAt:i}=e;const c=B(i);await async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=(0,m.KT)("apps/user_status/api/v1/user_status/message/predefined?format=json");await l.Ay.put(s,{messageId:t,clearAt:e})}(u,c);const d=a.predefinedStatuses.predefinedStatuses.find((t=>t.id===u)),{message:p,icon:A}=d;s("setPredefinedMessage",{messageId:u,clearAt:c,message:p,icon:A}),(0,o.Ic)("user_status:status.updated",{status:r.status,message:r.message,icon:r.icon,clearAt:r.clearAt,userId:(0,n.HW)()?.uid})},async setCustomMessage(t,e){let{commit:s,state:a}=t,{message:r,icon:u,clearAt:i}=e;const c=B(i);await async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const a=(0,m.KT)("apps/user_status/api/v1/user_status/message/custom?format=json");await l.Ay.put(a,{message:t,statusIcon:e,clearAt:s})}(r,u,c),s("setCustomMessage",{message:r,icon:u,clearAt:c}),(0,o.Ic)("user_status:status.updated",{status:a.status,message:a.message,icon:a.icon,clearAt:a.clearAt,userId:(0,n.HW)()?.uid})},async clearMessage(t){let{commit:e,state:s}=t;await(async()=>{const t=(0,m.KT)("apps/user_status/api/v1/user_status/message?format=json");await l.Ay.delete(t)})(),e("clearMessage"),(0,o.Ic)("user_status:status.updated",{status:s.status,message:s.message,icon:s.icon,clearAt:s.clearAt,userId:(0,n.HW)()?.uid})},async reFetchStatusFromServer(t){let{commit:e}=t;e("loadStatusFromServer",await(async()=>{const t=(0,m.KT)("apps/user_status/api/v1/user_status");return(await l.Ay.get(t)).data.ocs.data})())},async setStatusFromHeartbeat(t,e){let{commit:s}=t;s("loadStatusFromServer",e)},loadStatusFromInitialState(t){let{commit:e}=t;e("loadStatusFromServer",(0,U.C)("user_status","status"))}}},j={state:{status:null,statusIsUserDefined:null,message:null,icon:null,clearAt:null,messageIsPredefined:null,messageId:null},mutations:{loadBackupStatusFromServer(t,e){let{status:s,statusIsUserDefined:a,message:r,icon:n,clearAt:o,messageIsPredefined:u,messageId:i}=e;t.status=s,t.message=r,t.icon=n,void 0!==a&&(t.statusIsUserDefined=a),void 0!==o&&(t.clearAt=o),void 0!==u&&(t.messageIsPredefined=u),void 0!==i&&(t.messageId=i)}},getters:{},actions:{async fetchBackupFromServer(t){let{commit:e}=t;try{e("loadBackupStatusFromServer",await(async t=>{const e=(0,m.KT)("apps/user_status/api/v1/statuses/{userId}",{userId:"_"+t});return(await l.Ay.get(e)).data.ocs.data})((0,n.HW)()?.uid))}catch(t){}},async revertBackupFromServer(t,e){let{commit:s}=t,{messageId:a}=e;const r=await(async t=>{const e=(0,m.KT)("apps/user_status/api/v1/user_status/revert/{messageId}",{messageId:t});return(await l.Ay.delete(e)).data.ocs.data})(a);r&&(s("loadBackupStatusFromServer",{}),s("loadStatusFromServer",r),(0,o.Ic)("user_status:status.updated",{status:r.status,message:r.message,icon:r.icon,clearAt:r.clearAt,userId:(0,n.HW)()?.uid}))}}};r.Ay.use(O.Ay);const $=new O.il({modules:{predefinedStatuses:P,userStatus:E,userBackupStatus:j},strict:!0});a.nc=btoa((0,n.do)()),r.Ay.prototype.t=t,r.Ay.prototype.$t=t;const H=()=>{const t=document.getElementById("user_status-menu-entry");new r.Ay({el:t,render:t=>t(T),store:$})};document.getElementById("user_status-menu-entry")?H():(0,o.B1)("core:user-menu:mounted",H),document.addEventListener("DOMContentLoaded",(function(){OCA.Dashboard&&OCA.Dashboard.registerStatus("status",(t=>new(r.Ay.extend(T))({propsData:{inline:!0},store:$}).$mount(t)))}))}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var s=n[t]={id:t,loaded:!1,exports:{}};return r[t].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}o.m=r,e=[],o.O=(t,s,a,r)=>{if(!s){var n=1/0;for(d=0;d=r)&&Object.keys(o.O).every((t=>o.O[t](s[i])))?s.splice(i--,1):(u=!1,r0&&e[d-1][2]>r;d--)e[d]=e[d-1];e[d]=[s,a,r]},o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var s in e)o.o(e,s)&&!o.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o.f={},o.e=t=>Promise.all(Object.keys(o.f).reduce(((e,s)=>(o.f[s](t,e),e)),[])),o.u=t=>(5133===t?"user-status-modal":t)+"-"+t+".js?v="+{2441:"bd6d3dc836e836cd4795",5133:"83ea44ce1d3bb8e64c8c",5775:"bdb5a44b157eaff757ea",5862:"18c97d281a8207f0ce8d"}[t],o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s={},a="nextcloud:",o.l=(t,e,r,n)=>{if(s[t])s[t].push(e);else{var u,i;if(void 0!==r)for(var c=document.getElementsByTagName("script"),d=0;d{u.onerror=u.onload=null,clearTimeout(p);var r=s[t];if(delete s[t],u.parentNode&&u.parentNode.removeChild(u),r&&r.forEach((t=>t(a))),e)return e(a)},p=setTimeout(m.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=m.bind(null,u.onerror),u.onload=m.bind(null,u.onload),i&&document.head.appendChild(u)}},o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),o.j=9953,(()=>{var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var s=e.getElementsByTagName("script");if(s.length)for(var a=s.length-1;a>-1&&(!t||!/^http(s?):/.test(t));)t=s[a--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t})(),(()=>{o.b=document.baseURI||self.location.href;var t={9953:0};o.f.j=(e,s)=>{var a=o.o(t,e)?t[e]:void 0;if(0!==a)if(a)s.push(a[2]);else{var r=new Promise(((s,r)=>a=t[e]=[s,r]));s.push(a[2]=r);var n=o.p+o.u(e),u=new Error;o.l(n,(s=>{if(o.o(t,e)&&(0!==(a=t[e])&&(t[e]=void 0),a)){var r=s&&("load"===s.type?"missing":s.type),n=s&&s.target&&s.target.src;u.message="Loading chunk "+e+" failed.\n("+r+": "+n+")",u.name="ChunkLoadError",u.type=r,u.request=n,a[1](u)}}),"chunk-"+e,e)}},o.O.j=e=>0===t[e];var e=(e,s)=>{var a,r,n=s[0],u=s[1],i=s[2],c=0;if(n.some((e=>0!==t[e]))){for(a in u)o.o(u,a)&&(o.m[a]=u[a]);if(i)var d=i(o)}for(e&&e(s);co(88973)));u=o.O(u)})(); //# sourceMappingURL=user_status-menu.js.map?v=09746af7b1933afc65f1