openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 17.8 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Qt as t,Xt as n,Yt as r,Zt as i}from"./control-ui-connection-Bfj9beF_.js";import{BA as a,dj as o,mj as s,pj as c,zA as l}from"./control-ui-boot-shared-DFTSUQQ0.js";import{C as u,Ct as d,F as f,I as p,O as m,S as h,St as ee,U as g,_t as te,d as _,f as v,g as y,gt as ne,j as b,l as x,s as S,u as C,w as re,x as w,yt as ie}from"./solid-runtime-C416s-HC.js";import{n as T,t as E}from"./en-settings-YsyvL-Mv.js";import{o as ae,t as oe}from"./settings-targets-BBXeSTMi.js";import{_ as D,d as O,h as k,l as se,v as A,y as ce}from"./settings-ui-Ck6BJLhD.js";import{n as le,t as j}from"./settings-select-row-D3ueky7t.js";import{n as ue,t as M}from"./settings-section-header-C8eeyGtb.js";import{n as de,t as fe}from"./timezone-suggestions-po3ow91w.js";function pe(e){return`${String(Math.floor(e/60)).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`}function me(e,t){let n=/^(\d{2}):(\d{2})$/u.exec(e);return n?Number(n[1])*60+Number(n[2]):t}function N(e){return e===`identified`||e===`detailed`?e:`private`}function P(){return[{value:`private`,label:s(`configView.notifications.private`)},{value:`identified`,label:s(`configView.notifications.namesOnly`)},{value:`detailed`,label:s(`configView.notifications.detailed`)}]}function F(e){return[{value:`inherit`,label:e},{value:`on`,label:s(`configForm.enumOn`)},{value:`off`,label:s(`configForm.enumOff`)}]}function I(e){var t=R(),n=t.firstChild,r=n.nextSibling;return _(t,b(O,{get title(){return s(`configView.notifications.quietHoursWindow`)},get control(){return b(u,{each:[[`startMinute`,`quietHoursStart`],[`endMinute`,`quietHoursEnd`]],keyed:e=>e[0],children:(t,n)=>[v(()=>v(()=>n()>0)()&&B()),(()=>{var n=z();return n.addEventListener(`change`,n=>e.onChange({...e.quietHours,[t()[0]]:me(n.currentTarget.value,e.quietHours[t()[0]])})),x(()=>({e:e.disabled,t:s(`configView.notifications.${t()[1]}`),a:pe(e.quietHours[t()[0]])}),({e,t,a:r},i)=>{e!==i?.e&&y(n,`disabled`,e),t!==i?.t&&y(n,`aria-label`,t),n.value=r??``}),n})()]})}}),n),_(t,b(j,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.timeZone`)},get value(){return e.quietHours.timeZone},get options(){return de([e.quietHours.timeZone]).map(e=>({value:e,label:e.replaceAll(`_`,` `)}))},onChange:t=>e.onChange({...e.quietHours,timeZone:t})}),r),t}function L(e){return b(O,{get title(){return s(`configView.notifications.onlyAgents`)},get control(){var t=V();return t.addEventListener(`change`,t=>e.onChange(t.currentTarget.value.split(`,`).map(e=>e.trim()).filter(Boolean))),x(()=>({e:e.disabled,t:s(`configView.notifications.onlyAgents`),a:e.agentIds.join(`, `)}),({e,t:n,a:r},i)=>{e!==i?.e&&y(t,`disabled`,e),n!==i?.t&&y(t,`aria-label`,n),t.value=r??``}),t}})}function he(e){let t=t=>e.onChange({...e.preferences,...t});var n=H(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,c=o.nextSibling,l=c.nextSibling;return _(n,b(M,{get title(){return s(`configView.notifications.accountDefaults`)}}),r),_(r,b(u,{each:G,children:n=>b(D,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.${n}`)},get checked(){return e.preferences.categories[n]===!0},onChange:r=>t({categories:{...e.preferences.categories,[n]:r}})})}),i),_(r,b(j,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.lockScreenDetail`)},get description(){return s(`configView.notifications.lockScreenDetailHint`)},get value(){return e.preferences.detailLevel},get options(){return P()},onChange:e=>t({detailLevel:N(e)})}),a),_(r,b(D,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.quietHours`)},get checked(){return e.preferences.quietHours.enabled},onChange:n=>t({quietHours:{...e.preferences.quietHours,enabled:n}})}),o),_(r,b(m,{get when(){return e.preferences.quietHours.enabled},get children(){return b(I,{get disabled(){return e.disabled},get quietHours(){return e.preferences.quietHours},onChange:e=>t({quietHours:e})})}}),c),_(r,b(L,{get disabled(){return e.disabled},get agentIds(){return e.preferences.agentIds},onChange:e=>t({agentIds:e})}),l),n}function ge(e){let t=t=>e.onChange({...e.preferences,...t});var n=U(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,c=o.nextSibling,l=c.nextSibling,d=l.nextSibling,f=d.nextSibling,p=f.nextSibling;return _(n,b(M,{get title(){return s(`configView.notifications.installedApp`)}}),r),_(r,b(D,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.deliverDevice`)},get checked(){return e.preferences.enabled},onChange:e=>t({enabled:e})}),i),_(r,b(O,{get title(){return s(`configView.notifications.notificationLabel`)},get control(){var n=W();return n.addEventListener(`change`,e=>t({label:e.currentTarget.value})),x(()=>({e:e.disabled,t:s(`configView.notifications.notificationLabel`),a:e.preferences.label}),({e,t,a:r},i)=>{e!==i?.e&&y(n,`disabled`,e),t!==i?.t&&y(n,`aria-label`,t),n.value=r??``}),n}}),a),_(r,b(j,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.lockScreenDetail`)},get value(){return e.preferences.detailLevel??`inherit`},get options(){return[{value:`inherit`,label:s(`configView.notifications.inheritDetail`)},...P()]},onChange:e=>t({detailLevel:e===`inherit`?void 0:N(e)})}),o),_(r,b(j,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.quietHours`)},get value(){return v(()=>e.preferences.quietHours===void 0)()?`inherit`:e.preferences.quietHours.enabled?`on`:`off`},get options(){return F(s(`configView.notifications.inheritQuietHours`))},onChange:n=>t({quietHours:n===`inherit`?void 0:{enabled:n===`on`,startMinute:e.preferences.quietHours?.startMinute??1320,endMinute:e.preferences.quietHours?.endMinute??420,timeZone:e.preferences.quietHours?.timeZone??`UTC`}})}),c),_(r,b(m,{get when(){return v(()=>!!e.preferences.quietHours?.enabled)()?e.preferences.quietHours:void 0},children:n=>b(I,{get disabled(){return e.disabled},get quietHours(){return n()},onChange:e=>t({quietHours:e})})}),l),_(r,b(j,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.onlyAgents`)},get value(){return e.preferences.agentIds===void 0?`inherit`:`override`},get options(){return[{value:`inherit`,label:s(`configView.notifications.inherit`)},{value:`override`,label:s(`configView.notifications.overrideAgents`)}]},onChange:e=>t({agentIds:e===`inherit`?void 0:[]})}),d),_(r,b(m,{get when(){return e.preferences.agentIds},children:n=>b(L,{get disabled(){return e.disabled},get agentIds(){return n()},onChange:e=>t({agentIds:e})})}),f),_(r,b(u,{each:G,children:n=>b(j,{get disabled(){return e.disabled},get title(){return s(`configView.notifications.${n}`)},get value(){return v(()=>e.preferences.categories?.[n]===void 0)()?`inherit`:e.preferences.categories?.[n]?`on`:`off`},get options(){return F(s(`configView.notifications.inherit`))},onChange:r=>{let i={...e.preferences.categories};r===`inherit`?delete i[n]:i[n]=r===`on`,t({categories:i})}})}),p),n}var R,z,B,V,H,U,W,G;function _e(){return(_e=e((()=>{C(),g(),ce(),o(),fe(),ue(),le(),R=w(`<div class="settings-subrows quiet-hours-window"><!><!>`),z=w(`<input type=time class=settings-input>`),B=w(`<span class=settings-row__value aria-hidden=true>–`),V=w(`<input type=text class=settings-input>`),H=w(`<section class=settings-section><div class=settings-group><!><!><!><!><!>`),U=w(`<section class=settings-section><div class=settings-group><!><!><!><!><!><!><!><!>`),W=w(`<input type=text class=settings-input maxlength=80>`),G=[`approvalRequested`,`agentFinished`,`agentQuestion`,`humanMentioned`,`scheduledTaskFailed`]})))()}function ve(e){var t=Ce(),n=t.firstChild;return _(n,()=>e.children),t}function ye(e){return b(O,{get title(){return s(`configView.notifications.blocked`)},get description(){return e.description},get control(){return b(k,{kind:`danger`,get label(){return s(`configView.notifications.denied`)}})}})}function K(e){var t=we(),n=t.firstChild,r=n.firstChild,i=r.nextSibling,a=n.nextSibling;return _(r,()=>e.title),_(i,()=>e.status),_(t,()=>e.description,a),_(a,()=>e.children),x(()=>oe.notifications,e=>{y(t,`id`,e)}),t}function be(e){let t=()=>{switch(e.native.permission){case`granted`:return{kind:`ok`,label:s(`configView.notifications.granted`)};case`denied`:return{kind:`danger`,label:s(`configView.notifications.denied`)};case`notDetermined`:return{kind:`accent`,label:s(`configView.notifications.notRequested`)};default:return{kind:`muted`,label:s(`configView.notifications.checking`)}}},i=()=>e.native.test?.state===`sent`?s(`configView.notifications.testQueued`):``,[a,o]=p(!1),c=()=>a()||e.native.test?.state===`pending`,u=ie(function*(t,n){n===e.actions.presentationRetired()&&o(!0),yield Promise.race([t,n])}),d=async()=>{let t=e.actions.presentationRetired(),n=e.actions.onNativeNotificationsSendTest?.();return await Promise.resolve(),u(n,t)};return b(K,{get title(){return s(`configView.notifications.nativeTitle`)},get status(){return b(k,{get kind(){return t().kind},get label(){return t().label}})},get children(){return[(()=>{var e=Te();return _(e,i),e})(),b(O,{get title(){return s(`configView.notifications.permission`)},get control(){return b(A,{get value(){return t().label}})}}),b(m,{get when(){return e.native.permission===`notDetermined`||e.native.permission===`denied`||e.native.permission===`granted`},get children(){return b(ve,{get children(){return v(()=>e.native.permission===`granted`)()?(()=>{var e=q(),t=e.firstChild,n=t.nextSibling;return e._$$click=()=>void d(),_(e,b(l,{get name(){return c()?`loader`:`send`}}),t),_(e,(()=>{var e=v(()=>!!c());return()=>e()?s(`configView.notifications.sendingTest`):s(`configView.notifications.sendTest`)})(),n),x(()=>c(),t=>{y(e,`disabled`,t)}),e})():(()=>{var t=J();return t._$$click=()=>e.actions.onNativeNotificationsRequestPermission?.(),_(t,()=>s(e.native.permission===`notDetermined`?`configView.notifications.enable`:`configView.notifications.openSystemSettings`)),x(()=>e.native.permission===`notDetermined`,e=>{t.classList.toggle(`primary`,e)}),t})()}})}}),b(m,{get when(){return e.native.permission===`denied`},get children(){return b(ye,{get description(){return s(`configView.notifications.nativeBlockedHint`)}})}}),b(m,{get when(){return c()},get fallback(){return b(m,{get when(){return e.native.test},keyed:!0,children:e=>{let t=f(()=>{if(e.state===`error`)throw new r(e.message);return e.state});return b(h,{fallback:e=>b(Z,{state:`error`,get message(){return n(e())}}),get children(){return b(Z,{get state(){return t()}})}})}})},get children(){return b(Z,{state:`pending`})}})]}})}function xe(e){let t=f(()=>e.push.read),n=f(()=>(t(),e.push.preferences)),[r,a]=p(()=>n()),[o,c]=p(!1,{equals:!1}),u=f(()=>e.push.command),g=ie(function*(e,t){c(!0),t&&a(e=>e&&{...e,[t.scope]:t.value}),yield e,te(n)}),S=(e,t)=>{e&&ne(()=>{g(e,t).catch(()=>{})})},C=()=>o()||e.push.loading,w=()=>e.push.subscription===`registered`,T=()=>w()||e.push.subscription===`vapid-mismatch`||e.push.subscription===`local`,E=()=>s(e.push.permission===`granted`?`configView.notifications.granted`:e.push.permission===`denied`?`configView.notifications.denied`:e.push.permission==="default"?`configView.notifications.notRequested`:`configView.notifications.unsupported`),ae=()=>s(w()?`configView.notifications.subscribed`:e.push.subscription===`unknown`?`configView.notifications.checking`:e.push.subscription===`local`?`configView.notifications.localSubscription`:`configView.notifications.notSubscribed`),oe=()=>s(e.push.supported?e.push.canManage?e.push.permission===`denied`?`configView.notifications.blocked`:w()?`configView.notifications.subscribed`:e.push.subscription===`vapid-mismatch`?`configView.notifications.unavailable`:e.push.subscription===`unknown`?`configView.notifications.checking`:`configView.notifications.ready`:`configView.notifications.unavailable`:`configView.notifications.unsupported`),D=()=>!e.push.supported||!e.push.canManage?`muted`:e.push.permission===`denied`||e.push.subscription===`vapid-mismatch`?`danger`:w()?`ok`:`accent`;return[b(K,{get title(){return s(`configView.notifications.title`)},get status(){return b(k,{get kind(){return D()},get label(){return oe()}})},get description(){return v(()=>e.push.permission===`install-required`)()?(()=>{var e=X();return _(e,()=>s(`configView.notifications.iosInstallRequired`)),e})():v(()=>!!(e.push.supported&&e.push.canManage&&w()))()?(()=>{var e=X();return _(e,()=>s(`configView.notifications.testAllBrowsersHint`)),e})():void 0},get children(){return[b(O,{get title(){return s(`configView.notifications.browserSupport`)},get control(){return b(A,{get value(){return s(e.push.supported?`configView.notifications.available`:`configView.notifications.notSupported`)}})}}),b(O,{get title(){return s(`configView.notifications.permission`)},get control(){return b(A,{get value(){return E()}})}}),b(O,{get title(){return s(`configView.notifications.status`)},get control(){return b(k,{get kind(){return w()?`ok`:`muted`},get label(){return ae()}})}}),b(m,{get when(){return v(()=>!!e.push.supported)()?!e.push.canManage:e.push.supported},get children(){return b(O,{get title(){return s(`configView.notifications.gatewayAccess`)},get description(){return s(e.actions.connected?`configView.notifications.gatewayAccessRequired`:`configView.notifications.gatewayDisconnected`)},get control(){return b(k,{kind:`muted`,get label(){return s(`configView.notifications.unavailable`)}})}})}}),b(m,{get when(){return v(()=>!!(e.push.supported&&e.push.permission!==`denied`))()?e.push.canManage||T():e.push.supported&&e.push.permission!==`denied`},get children(){return b(ve,{get children(){return v(()=>!!T())()?[(()=>{var t=Ee(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>S(e.actions.onWebPushUnsubscribe?.()),_(t,b(l,{name:`x`}),n),_(t,()=>s(`configView.notifications.unsubscribe`),r),x(()=>C()||!e.actions.connected,e=>{y(t,`disabled`,e)}),t})(),b(m,{get when(){return v(()=>!!w())()?e.push.canManage:w()},get children(){var t=De(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>S(e.actions.onWebPushTest?.()),_(t,b(l,{name:`send`}),n),_(t,()=>s(`configView.notifications.testAllBrowsers`),r),x(()=>C()||!e.actions.connected,e=>{y(t,`disabled`,e)}),t}})]:b(m,{get when(){return e.push.canManage},get children(){var t=q(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>S(e.actions.onWebPushSubscribe?.()),_(t,b(m,{get when(){return C()},get children(){return b(l,{name:`loader`})}}),n),_(t,()=>s(C()?`configView.notifications.subscribing`:`configView.notifications.enable`),r),x(()=>C()||!e.actions.connected,e=>{y(t,`disabled`,e)}),t}})}})}}),b(m,{get when(){return e.push.permission===`denied`},get children(){return b(ye,{get description(){return s(`configView.notifications.blockedHint`)}})}}),b(m,{get when(){return e.push.error},get children(){var t=Y(),n=t.firstChild.firstChild;return _(n,()=>i(e.push.error)),t}}),b(h,{fallback:Q,get children(){return b(re,{get on(){return e.push.command},fallback:null,get children(){return u(),null}})}})]}}),b(h,{fallback:Q,get children(){return b(re,{get on(){return e.push.read},fallback:null,get children(){return b(m,{get when(){return v(()=>!!e.push.canReadPreferences)()?d(r):(t(),void 0)},children:t=>(()=>{var r=Oe(),i=r.firstChild,a=i.nextSibling;return _(r,b(m,{get when(){return t().durableIdentity},get children(){return b(he,{get disabled(){return!e.push.canManage||!e.actions.connected},get preferences(){return t().user},onChange:t=>S(e.actions.onWebPushSetUserPreferences?.(t),{scope:`user`,value:t})})}}),i),_(r,b(ge,{get disabled(){return!e.push.canManage||!e.actions.connected},get preferences(){return t().device},onChange:t=>S(e.actions.onWebPushSetDevicePreferences?.(t),{scope:`device`,value:t})}),a),x(()=>C()||ee(n),e=>{y(r,`inert`,e)}),r})()})}})}})]}function Se(e){return b(se,{get children(){return b(m,{get when(){return e.nativeNotifications},get fallback(){return b(m,{get when(){return e.webPush},get fallback(){return b(K,{get title(){return s(`configView.notifications.title`)},get status(){return b(k,{kind:`muted`,get label(){return s(`configView.notifications.unavailable`)}})},get children(){var e=ke(),t=e.firstChild.firstChild;return _(t,()=>s(`configView.notifications.unavailableHint`)),e}})},children:t=>b(xe,{get push(){return t()},actions:e})})},children:t=>b(be,{get native(){return t()},actions:e})})}})}var Ce,we,Te,q,J,Y,X,Ee,De,Oe,ke,Z,Q;function $(){return($=e((()=>{C(),g(),a(),ce(),E(),t(),o(),ae(),_e(),Ce=w(`<div class=settings-row><div class=settings-row__control>`),we=w(`<section class=settings-section><div class=settings-section__header><h2 class=settings-section__heading></h2><div class=settings-section__actions></div></div><div class=settings-group>`),Te=w(`<span class=sr-only role=status aria-live=polite>`),q=w(`<button class="btn primary"><!><!>`),J=w(`<button class=btn>`),Y=w(`<div class=settings-row><div class=settings-row__text><span class=cfg-field__error role=alert>`),X=w(`<p class=settings-section__desc>`),Ee=w(`<button class=btn> <!>`),De=w(`<button class="btn primary"> <!>`),Oe=w(`<div class=settings-stack><!><!>`),ke=w(`<div class=settings-row><div class=settings-row__text><span class=settings-row__desc>`),c(T),Z=e=>b(O,{get title(){return s(`configView.notifications.testOutcome`)},get description(){return e.message},get role(){return e.state===`error`?`alert`:void 0},get control(){return b(k,{get kind(){return v(()=>e.state===`pending`)()?`accent`:e.state===`sent`?`ok`:`danger`},get label(){return s(e.state===`pending`?`configView.notifications.sendingTest`:e.state===`sent`?`configView.notifications.testQueued`:`configView.notifications.testFailed`)}})}}),Q=e=>(()=>{var t=Y(),r=t.firstChild.firstChild;return _(r,()=>n(e())),t})(),S([`click`])})))()}$();export{Se as NotificationsSection};