openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 2.1 kB
JavaScript
import{n as e,r as t}from"./rolldown-runtime-8BhlS34s.js";import{$n as n,Cr as r,Ft as i,It as a,Lt as o,b as s,er as c,wr as l,x as u,y as d}from"./control-ui-core-DtLivg_r.js";import{C as f,S as p,k as m,w as h}from"./ui-CmSP4d14.js";import{n as g,t as _}from"./user-prefs-request-Cs35VjAf.js";var v=t({readProfileAppearancePrefs:()=>x,writeProfileAppearancePrefs:()=>b});function y(e,t){let{runtimeConfig:n}=e;if(!n.state.connected)return null;let i=e.gateway.snapshot;return t&&d[t].configSync===!1&&!i.selfUser?!1:t&&i.selfUser?r(i.hello?.auth??null):n.canPatch!==!1}async function b(e,t,n){let r=t,i=r.theme!==void 0||r.themeMode!==void 0;if(i&&(r=Object.fromEntries(Object.entries(r).filter(([e])=>[`theme`,`themeMode`,`accent`,`fontUi`,`fontChat`].includes(e)))),!e||!n)return{ok:!1,reason:`unavailable`,error:`Profile preferences are unavailable.`,batch:r};i&&a(e);try{if(i){let t={...r.accent===void 0?{}:{accent:r.accent},...r.fontUi===void 0?{}:{fontUi:r.fontUi},...r.fontChat===void 0?{}:{fontChat:r.fontChat}};return{ok:!0,value:await e.request(`themes.set`,{...r.theme===void 0?{}:{id:r.theme},...r.themeMode===void 0?{}:{mode:r.themeMode},...Object.keys(t).length?{appearance:t}:{}}),refresh:{ok:!0},batch:r}}if(r.tabIcon!=null&&!m(r.tabIcon))return{ok:!1,reason:`rejected`,error:`Invalid tab icon preference.`,batch:r};let t=Object.fromEntries(Object.entries(r).flatMap(([e,t])=>u(e)?[[p[e],t]]:[])),n=await o(e,{entries:t});return n.status===`ok`?{ok:!0,value:n,refresh:{ok:!0},batch:r}:{ok:!1,reason:`rejected`,error:`Profile preferences are unavailable.`,batch:r}}catch(e){return{ok:!1,reason:e instanceof c&&(e.gatewayCode===`INVALID_REQUEST`||e.gatewayCode===`FORBIDDEN`)?`rejected`:`error`,error:e instanceof Error?e.message:String(e),batch:r}}finally{i&&a(e)}}async function x(e,t){let n=await g(e,t,{keys:Object.values(p)});if(n.status!==`ok`)return null;let r={};for(let[e,t]of Object.entries(p)){if(!u(e))continue;let i=h(t,n.entries[t]);i!==void 0&&Object.assign(r,{[e]:i})}return r}function S(){return(S=e((()=>{f(),n(),l(),s(),i(),_()})))()}export{S as n,v as r,y as t};