import{r as xe,a as He,o as Z,w as ne,b as de,e as ce,f as _e,g as le,t as z,h as Se,F as pi,i as Re,j as hi,k as mi,c as fi}from"./style-Cs_h5sE5.chunk.mjs";import{t as S,_ as gi,N as vi,a as ki,s as Ee,b as Pe,c as yi,g as xi,l as _i}from"./_plugin-vue_export-helper-DW41pV1w.chunk.mjs";import{N as Si}from"./NcSettingsSection-EAR0ylbd-ByiYMvhA.chunk.mjs";import{B as Q}from"./BrowserStorage-CMzlsepb.chunk.mjs";var Ei="2.0.9",Ni=500,je="user-agent",$="",Ge="?",f={FUNCTION:"function",OBJECT:"object",STRING:"string",UNDEFINED:"undefined"},y="browser",D="cpu",I="device",N="engine",_="os",W="result",o="name",i="type",r="vendor",a="version",k="architecture",re="major",t="model",me="console",l="mobile",h="tablet",g="smarttv",C="wearable",be="xr",ae="embedded",Ci="fetcher",H="inapp",Be="brands",B="formFactors",Fe="fullVersionList",Y="platform",ze="platformVersion",ke="bitness",L="sec-ch-ua",Ii=L+"-full-version-list",Oi=L+"-arch",Ti=L+"-"+ke,Di=L+"-form-factors",Ui=L+"-"+l,Vi=L+"-"+t,ci=L+"-"+Y,qi=ci+"-version",li=[Be,Fe,l,t,Y,ze,k,B,ke],we="Amazon",R="Apple",We="ASUS",Ye="BlackBerry",A="Google",$e="Huawei",Ne="Lenovo",Je="Honor",ue="LG",Ce="Microsoft",Ie="Motorola",Xe="Nvidia",Ze="OnePlus",Oe="OPPO",K="Samsung",Qe="Sharp",ee="Sony",Te="Xiaomi",De="Zebra",Ke="Chrome",ei="Chromium",V="Chromecast",fe="Edge",ie="Firefox",P="Opera",Ue="Facebook",ii="Sogou",j="Mobile ",G=" Browser",Le="Windows",Mi=typeof window!==f.UNDEFINED,x=Mi&&window.navigator?window.navigator:void 0,F=x&&x.userAgentData?x.userAgentData:void 0,Li=function(e,s){var n={},c=s;if(!ge(s)){c={};for(var m in s)for(var b in s[m])c[b]=s[m][b].concat(c[b]?c[b]:[])}for(var d in e)n[d]=c[d]&&c[d].length%2===0?c[d].concat(e[d]):e[d];return n},pe=function(e){for(var s={},n=0;n0){for(var n in e)if(M(s)==M(e[n]))return!0;return!1}return se(e)?M(s)==M(e):!1},ge=function(e,s){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(s?ge(e[n]):!1)},se=function(e){return typeof e===f.STRING},Ve=function(e){if(e){for(var s=[],n=J(/\\?\"/g,e).split(","),c=0;c-1){var m=ve(n[c]).split(";v=");s[c]={brand:m[0],version:m[1]}}else s[c]=ve(n[c]);return s}},M=function(e){return se(e)?e.toLowerCase():e},qe=function(e){return se(e)?J(/[^\d\.]/g,e).split(".")[0]:void 0},U=function(e){for(var s in e)if(e.hasOwnProperty(s)){var n=e[s];typeof n==f.OBJECT&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},J=function(e,s){return se(s)?s.replace(e,$):s},te=function(e){return J(/\\?\"/g,e)},ve=function(e,s){return e=J(/^\s\s*/,String(e)),typeof s===f.UNDEFINED?e:e.substring(0,s)},Me=function(e,s){if(!(!e||!s))for(var n=0,c,m,b,d,p,w;n0?d.length===2?typeof d[1]==f.FUNCTION?this[d[0]]=d[1].call(this,w):this[d[0]]=d[1]:d.length>=3&&(typeof d[1]===f.FUNCTION&&!(d[1].exec&&d[1].test)?d.length>3?this[d[0]]=w?d[1].apply(this,d.slice(2)):void 0:this[d[0]]=w?d[1].call(this,w,d[2]):void 0:d.length==3?this[d[0]]=w?w.replace(d[1],d[2]):void 0:d.length==4?this[d[0]]=w?d[3].call(this,w.replace(d[1],d[2])):void 0:d.length>4&&(this[d[0]]=w?d[3].apply(this,[w.replace(d[1],d[2])].concat(d.slice(4))):void 0)):this[d]=w||void 0;n+=2}},E=function(e,s){for(var n in s)if(typeof s[n]===f.OBJECT&&s[n].length>0){for(var c=0;c2&&this.set(t,"iPad").set(i,h);break;case _:!this.get(o)&&F&&F[Y]&&this.set(o,F[Y]);break;case W:var e=this.data,s=function(n){return e[n].getItem().detectFeature().get()};this.set(y,s(y)).set(D,s(D)).set(I,s(I)).set(N,s(N)).set(_,s(_))}return this},q.prototype.parseUA=function(){switch(this.itemType!=W&&Me.call(this.data,this.ua,this.rgxMap),this.itemType){case y:this.set(re,qe(this.get(a)));break;case _:if(this.get(o)=="iOS"&&this.get(a)=="18.6"){var e=/\) Version\/([\d\.]+)/.exec(this.ua);e&&parseInt(e[1].substring(0,2),10)>=26&&this.set(a,e[1])}break}return this},q.prototype.parseCH=function(){var e=this.uaCH,s=this.rgxMap;switch(this.itemType){case y:case N:var n=e[Fe]||e[Be],c;if(n)for(var m=0;m=13?"11":"10"),this.set(o,O).set(a,ye)}this.get(o)==Le&&e[t]=="Xbox"&&this.set(o,"Xbox").set(a,void 0);break;case W:var wi=this.data,X=function(ui){return wi[ui].getItem().setCH(e).parseCH().get()};this.set(y,X(y)).set(D,X(D)).set(I,X(I)).set(N,X(N)).set(_,X(_))}return this};function T(e,s,n){if(typeof e===f.OBJECT?(ge(e,!0)?(typeof s===f.OBJECT&&(n=s),s=e):(n=e,s=void 0),e=void 0):typeof e===f.STRING&&!ge(s,!0)&&(n=s,s=void 0),n)if(typeof n.append===f.FUNCTION){var c={};n.forEach(function(v,O){c[String(O).toLowerCase()]=v}),n=c}else{var m={};for(var b in n)n.hasOwnProperty(b)&&(m[String(b).toLowerCase()]=n[b]);n=m}if(!(this instanceof T))return new T(e,s,n).getResult();var d=typeof e===f.STRING?e:n&&n[je]?n[je]:x&&x.userAgent?x.userAgent:$,p=new bi(n,!0),w=s?Li(ai,s):ai,u=function(v){return v==W?function(){return new q(v,d,w,p).set("ua",d).set(y,this.getBrowser()).set(D,this.getCPU()).set(I,this.getDevice()).set(N,this.getEngine()).set(_,this.getOS()).get()}:function(){return new q(v,d,w[v],p).parseUA().get()}};return U.call(this,[["getBrowser",u(y)],["getCPU",u(D)],["getDevice",u(I)],["getEngine",u(N)],["getOS",u(_)],["getResult",u(W)],["getUA",function(){return d}],["setUA",function(v){return se(v)&&(d=ve(v,Ni)),this}]]).setUA(d),this}T.VERSION=Ei,T.BROWSER=pe([o,a,re,i]),T.CPU=pe([k]),T.DEVICE=pe([t,r,i,me,l,g,h,C,ae]),T.ENGINE=T.OS=pe([o,a]);const oe={EMAIL_SEND_OFF:0,EMAIL_SEND_HOURLY:1,EMAIL_SEND_3HOURLY:2,EMAIL_SEND_DAILY:3,EMAIL_SEND_WEEKLY:4},ri=[{label:S("notifications","Never"),value:oe.EMAIL_SEND_OFF},{label:S("notifications","1 hour"),value:oe.EMAIL_SEND_HOURLY},{label:S("notifications","3 hours"),value:oe.EMAIL_SEND_3HOURLY},{label:S("notifications","1 day"),value:oe.EMAIL_SEND_DAILY},{label:S("notifications","1 week"),value:oe.EMAIL_SEND_WEEKLY}],si={id:null,label:S("notifications","None")},Fi=new T,ni=Fi.getBrowser(),di=ni.name==="Safari"||ni.name==="Mobile Safari",zi={name:"UserSettings",components:{NcCheckboxRadioSwitch:ki,NcSelect:vi,NcSettingsSection:Si},setup(){const e=Re(_i("notifications","config")),s=Re({secondary_speaker:Q.getItem("secondary_speaker")==="true",secondary_speaker_device:JSON.parse(Q.getItem("secondary_speaker_device"))??si}),n=hi([]),c=mi({get(){return ri.find(({value:m})=>m===e.setting_batchtime)},set({value:m}){e.setting_batchtime=m}});return{BATCHTIME_OPTIONS:ri,isSafari:di,config:e,currentBatchTime:c,devices:n,storage:s}},methods:{t:S,async updateSettings(){try{const e=new FormData;e.append("batchSetting",this.config.setting_batchtime),e.append("soundNotification",this.config.sound_notification?"yes":"no"),e.append("soundTalk",this.config.sound_talk?"yes":"no"),await yi.post(xi("apps/notifications/api/v2/settings"),e),Pe(S("notifications","Your settings have been updated."))}catch(e){Ee(S("notifications","An error occurred while updating your settings.")),console.error(e)}},updateLocalSettings(){try{Q.setItem("secondary_speaker",this.storage.secondary_speaker),this.storage.secondary_speaker&&this.storage.secondary_speaker_device.id?Q.setItem("secondary_speaker_device",JSON.stringify(this.storage.secondary_speaker_device)):Q.removeItem("secondary_speaker_device"),Pe(S("notifications","Your settings have been updated."))}catch(e){Ee(S("notifications","An error occurred while updating your settings.")),console.error(e)}},async initializeDevices(){if(!(!di&&navigator?.mediaDevices?.getUserMedia&&navigator?.mediaDevices?.enumerateDevices)||this.devices.length>0)return;let e=null;try{e=await navigator.mediaDevices.getUserMedia({audio:!0}),this.devices=(await navigator.mediaDevices.enumerateDevices()??[]).filter(s=>s.kind==="audiooutput").map(s=>({id:s.deviceId,label:s.label?s.label:s.fallbackLabel})).concat([si])}catch(s){Ee(S("notifications","An error occurred while updating your settings.")),console.error("Error while requesting or initializing audio devices: ",s)}finally{e&&e.getTracks().forEach(s=>s.stop())}}}},Hi={class:"notification-frequency__warning"},Ri={key:0},Pi={class:"notification-frequency__wrapper"},ji={for:"notification_reminder_batchtime",class:"notification-frequency__label"},Gi={key:0,class:"notification-frequency__warning"};function Wi(e,s,n,c,m,b){const d=xe("NcSelect"),p=xe("NcCheckboxRadioSwitch"),w=xe("NcSettingsSection");return Z(),He(w,{name:b.t("notifications","Notifications")},{default:ne(()=>[de("div",Hi,[c.config.is_email_set?le("",!0):(Z(),_e("strong",Ri,z(b.t("notifications","You need to set up your email address before you can receive notification emails.")),1))]),de("div",Pi,[de("label",ji,z(b.t("notifications","Send email reminders about unhandled notifications after:")),1),ce(d,{id:"notification_reminder_batchtime",modelValue:c.currentBatchTime,"onUpdate:modelValue":[s[0]||(s[0]=u=>c.currentBatchTime=u),b.updateSettings],class:"notification-frequency__select",clearable:!1,labelOutside:"",options:c.BATCHTIME_OPTIONS},null,8,["modelValue","options","onUpdate:modelValue"])]),ce(p,{modelValue:c.config.sound_notification,"onUpdate:modelValue":[s[1]||(s[1]=u=>c.config.sound_notification=u),b.updateSettings]},{default:ne(()=>[Se(z(b.t("notifications","Play sound when a new notification arrives")),1)]),_:1},8,["modelValue","onUpdate:modelValue"]),ce(p,{modelValue:c.config.sound_talk,"onUpdate:modelValue":[s[2]||(s[2]=u=>c.config.sound_talk=u),b.updateSettings]},{default:ne(()=>[Se(z(b.t("notifications","Play sound when a call started (requires Nextcloud Talk)")),1)]),_:1},8,["modelValue","onUpdate:modelValue"]),c.config.sound_talk?(Z(),_e(pi,{key:0},[ce(p,{modelValue:c.storage.secondary_speaker,"onUpdate:modelValue":[s[3]||(s[3]=u=>c.storage.secondary_speaker=u),b.updateLocalSettings],class:"additional-margin-top",disabled:c.isSafari},{default:ne(()=>[Se(z(b.t("notifications","Also repeat sound on a secondary speaker")),1)]),_:1},8,["modelValue","disabled","onUpdate:modelValue"]),c.isSafari?(Z(),_e("div",Gi,[de("strong",null,z(b.t("notifications","Selection of the speaker device is currently not supported by Safari")),1)])):le("",!0),!c.isSafari&&c.storage.secondary_speaker?(Z(),He(d,{key:1,modelValue:c.storage.secondary_speaker_device,"onUpdate:modelValue":[s[4]||(s[4]=u=>c.storage.secondary_speaker_device=u),b.updateLocalSettings],inputId:"device-selector-audio-output",options:c.devices,label:"label","aria-label-combobox":b.t("notifications","Select a device"),clearable:!1,placeholder:b.t("notifications","Select a device"),onOpen:b.initializeDevices},null,8,["modelValue","options","aria-label-combobox","placeholder","onOpen","onUpdate:modelValue"])):le("",!0)],64)):le("",!0)]),_:1},8,["name"])}const Yi=gi(zi,[["render",Wi],["__scopeId","data-v-13fb3c25"]]);fi(Yi).mount("#notifications-user-settings"); //# sourceMappingURL=notifications-settings.mjs.map