UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 14.3 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./control-ui-boot-new-pHXPNTZp.js","./route-controls-runtime-LXiVRSj4.js","./control-ui-boot-new-styles-C3bRIOZh.js","./command-discovery-english-zfhZUSVO.js","./composer-invocation-menus-Dvscf6c8.js","./en-openclaw-id-dialogs-BFGCHK4v.js","./feature-lifetime-BHVdXhSD.js","./error-message-B7DmySYB.js","./src-UIxrOiBg.js","./secret-reveal-DnJn0UfT.js","./device-key-DH9ZSZCT.js","./tooltip-CiZaaGC3.js","./en-profile-edyrJlYL.js","./_1____________________________.css","./_0____________________________________.css","./control-ui-boot-new-styles-C8rpwVHV.css","./secret-reveal-DOtum12G.css","./make-reachable-dialog-4YLepLfU.css","./owner-devices-dialog-DlHzLOTK.js","./owner-approval-lifetime-B8hNV4Yn.js","./owner-approval-dialog-CdJ_2bpR.js","./owner-devices-dialog-Cqj3g9OJ.css","./exec-approval-card-DGfgNbQP.js","./rebind-Cs3NDOde.js","./exec-approval-card-CKSHrQlk.css"])))=>i.map(i=>d[i]); import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{$u as t,Qu as n,Wo as r}from"./_4____________________________.js";import{FN as i,GN as a,Hv as o,JN as s,Op as c,PN as l,Vv as u,aA as d,fN as f,fk as ee,iA as te,iT as ne,kp as re,mk as p,pN as m,qN as ie,sT as ae}from"./_2_____________________________.js";import{Bi as oe,Hi as se}from"./deferred-ui-support-DZEPWjAk.js";import{B as ce,F as h,J as le,U as ue,_t as g,d as _,g as v,gt as de,j as y,l as fe,u as b,v as pe,x,y as me}from"./_6____________________.js";import{n as he,t as ge}from"./en-openclaw-id-Don6YXzi.js";import{c as _e,i as S,n as ve,s as ye}from"./account-BSv2LwQC.js";import{n as C,t as be}from"./ui-error-Bk6jJOft.js";import{n as xe,o as Se,s as w,t as Ce}from"./app-sidebar-identity-menu-B7rPYnWX.js";import{t as we}from"./claw-name-Dq5hFb9H.js";async function Te(){let e=navigator.serviceWorker?.controller;if(!e)throw Error(`The remote session is unavailable. Reload this page and try again.`);let t=await new Promise((t,n)=>{let i=new MessageChannel,a=(e,r)=>{window.clearTimeout(o),s(),i.port1.close(),i.port2.close(),e?n(e):t(r)},o=window.setTimeout(()=>a(Error(`Sign-out was not confirmed. Reload this page and try again.`)),1e4),s=r(i.port1,`message`,e=>{let t=e.data?.value?.logoutUrl;if(typeof t!=`string`){a(Error(`The loader could not finish sign-out. Reload and try again.`));return}let n;try{n=new URL(t)}catch{a(Error(`The loader returned an invalid sign-out address.`));return}n.protocol!==`https:`||n.pathname!==`/logout`||n.username||n.password?a(Error(`The loader returned an invalid sign-out address.`)):a(void 0,n.href)},{once:!0});i.port1.start();try{e.postMessage({type:`ocl-signout`,endIssuer:!0},[i.port2])}catch(e){a(e instanceof Error?e:Error(String(e)))}});window.location.assign(t)}function T(){return(T=e((()=>{})))()}function E(e){let t=e.connection;if(e.channel===`tunnel`){if(t?.kind===`member`){let n=t.role===`operator`?s(`openclawId.roleOperator`):t.role===`viewer`?s(`openclawId.roleViewer`):t.role;return{name:t.email||s(`openclawId.accountFallback`),detail:s(`openclawId.memberRoleOnClaw`,{role:n,claw:e.link.hostname?we(e.link.hostname):s(`openclawId.thisClaw`)})}}if(t?.kind!==`owner`)return{name:s(`openclawId.accountFallback`),detail:s(`openclawId.encryptedConnection`)};let n=t.accountEmail;return{name:t.accountName||n||s(`openclawId.accountFallback`),detail:n?`${n} · ${s(`openclawId.ownerRole`)}`:s(`openclawId.ownerRole`)}}let n=S();if(e.accountSignIn===`device`)return n?{name:n.name||n.email||s(`openclawId.accountFallback`),detail:n.email?`${n.email} · ${s(`openclawId.menuTitle`)}`:s(`openclawId.menuTitle`)}:null;if(n){let e=t?.kind===`local`?t.accountEmail:null;return{name:(t?.kind===`local`?t.accountName:null)||e||s(`openclawId.accountFallback`),detail:e?`${e} · ${s(`openclawId.localOperator`)}`:s(`openclawId.localOperator`)}}return{name:s(`openclawId.localOperator`),detail:s(`openclawId.thisComputer`)}}function D(e,t,n,r,i,a){return{kind:`content`,id:`openclaw-id-${e}`,content:(()=>{var e=P(),o=e.firstChild,c=o.nextSibling,l=c.firstChild;return v(e,`data-attention`,a?`true`:void 0),v(e,`role`,a?`status`:void 0),pe(o,`color`,a?`var(--warn)`:void 0),_(o,y(f,{name:n})),_(l,t),_(c,r?(()=>{var e=F();return _(e,r),e})():void 0,null),_(e,i===void 0?void 0:(()=>{var e=I();return v(e,`data-online`,i?`true`:`false`),_(e,()=>s(i?`openclawId.online`:`openclawId.offline`)),e})(),null),e})()}}function O(e){return e.remoteAccessSetup?e.services.loaderDomain?void 0:s(`openclawId.needsLoaderDomain`):s(e.accountSignIn===`device`?`openclawId.makeReachableAdminOnly`:`openclawId.makeReachableLocalOnly`)}function k(e,t){let n=t?.state===`failed`?t.code:void 0,r=e.status.state===`keys_refused`,i=r?`keys-refused`:n===`binding_superseded`?`binding-superseded`:n===`needs_link_code`?`needs-link-code`:null;if(!i)return[];let a=r?e.status.reason===`key_mismatch`?`keysMismatch`:`keysMissing`:n===`binding_superseded`?`bindingSuperseded`:`needsLinkCode`,o=r?`keysRefusedDetail`:`${a}Detail`,c=[D(i,s(`openclawId.${a}`),`alertTriangle`,s(`openclawId.${o}`),void 0,!0)];return i===`needs-link-code`&&c.push(w(Z,s(`openclawId.publishNewKeys`),`radio`)),c}function A(e){return e.channel===`tunnel`&&e.connection?.kind===`member`&&!e.owner}function j(e,t,n=()=>!1){if(!e||e.status.state===`off`)return[];if(e.channel!==`tunnel`&&!S()){let t=e.accountSignIn?e.services.clientId?void 0:s(`openclawId.signInUnconfigured`):s(`openclawId.signInLocalOnly`);return[{id:W,label:s(`openclawId.signIn`),disabled:!!t,render:e=>(()=>{var n=L(),r=n.firstChild.nextSibling,i=r.firstChild;return me(n,[e,{type:`button`,role:`button`,class:`oc-menu-item sidebar-openclaw-id__card sidebar-openclaw-id__status sidebar-openclaw-id__sign-in`,"aria-description":t,get disabled(){return e[`aria-disabled`]===`true`}}],!0),_(i,()=>s(`openclawId.signIn`)),_(r,t?(()=>{var e=F();return _(e,t),e})():void 0,null),_(n,t?void 0:(()=>{var e=R();return _(e,y(f,{name:`arrowRight`})),e})(),null),n})()}]}let r=[];if(e.channel===`tunnel`){let t=e.connection,n=t?.kind===`owner`?s(`openclawId.thisDevice`,{label:t.deviceLabel||s(`openclawId.unnamedDevice`)}):t?.kind===`member`&&t.invitedBy?s(`openclawId.invitedBy`,{owner:t.invitedBy.name||t.invitedBy.email||s(`openclawId.accountFallback`)}):null;r.push(D(`encrypted`,s(`openclawId.encryptedConnection`),`lock`,n))}else if(e.link.linked&&e.link.hostname&&S()){let t=e.channel===`local_operator`;t&&e.status.state!==`keys_refused`?r.push({id:Y,label:s(`openclawId.copyRemoteLink`),closeOnSelect:!1,class:`sidebar-openclaw-id__card sidebar-openclaw-id__linked`,attributes:{"aria-description":e.link.hostname,get"data-copied"(){return n()?`true`:void 0}},content:(()=>{var t=z(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.firstChild,o=a.nextSibling.firstChild,c=o.nextSibling,l=i.nextSibling;return _(n,y(f,{name:`radio`})),_(r,()=>s(`openclawId.remoteAccessOn`)),_(a,()=>s(e.status.tunnel?.relayOnline===!0?`openclawId.online`:`openclawId.offline`)),_(o,y(f,{name:`copy`})),_(c,y(f,{name:`check`})),_(l,()=>e.link.hostname),fe(()=>e.status.tunnel?.relayOnline===!0?`true`:`false`,e=>{v(a,`data-online`,e)}),t})()}):(e.status.state!==`keys_refused`&&r.push(D(`reachable`,s(`openclawId.remoteAccessOn`),`radio`,e.link.hostname,e.status.tunnel?.relayOnline===!0)),t&&r.push(w(Y,s(`openclawId.copyRemoteLink`),`link`)))}else{let t=O(e);r.push(w(G,s(`openclawId.makeReachable`),`radio`,{disabled:!!t,title:t,details:y(f,{name:`arrowRight`})}))}let i=[{kind:`group`,id:`openclaw-id-card`,class:e.channel===`local_operator`&&e.link.linked&&e.status.state!==`keys_refused`?void 0:`sidebar-openclaw-id__card`,items:r}];return e.channel===`local_operator`&&e.link.linked&&S()?(i.push(...k(e,t)),i.push(w(X,s(`openclawId.moveToNewKeys`),`key`))):e.remoteAccessSetup===`personal_admin`&&e.link.linked&&S()&&i.push(...k(e,t??e.publication)),A(e)?i.push(w(K,s(`openclawId.approveNewDevice`),`plus`),w(q,s(`openclawId.yourDevices`),`monitor`)):e.owner&&e.link.linked&&(e.channel===`tunnel`||S())&&i.push(w(q,s(`openclawId.yourDevices`),`monitor`)),i}function Ee(e){return!e||e.status.state===`off`?[]:(e.channel===`tunnel`?navigator.serviceWorker?.controller:e.accountSignIn&&S())?[{id:J,label:s(`openclawId.signOut`),class:`sidebar-customize-menu__item`,icon:(()=>{var e=V();return _(e,y(te,{get children(){return B()}})),e})(),content:(()=>{var e=H();return _(e,()=>s(`openclawId.signOut`)),e})()}]:[]}function M(e,t=`open`){e().catch(e=>p({severity:`error`,message:C(e,t),durationMs:12e3}))}function N(e,t,r){M(async()=>(await n(async()=>{let{showMakeReachableDialog:e}=await import(`./make-reachable-dialog-BLdelXJl.js`);return{showMakeReachableDialog:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]),import.meta.url)).showMakeReachableDialog({client:e,loaderDomain:t,signedIn:S(),linkProfile:r.remoteAccessSetup===`personal_admin`}))}function De(e,t,n){let r=t?.services.loaderDomain;!t||t.link.linked||!r||O(t)?p({severity:`success`,message:s(`openclawId.signedIn`,{account:n})}):p({severity:`info`,message:s(`openclawId.reachOffer`,{account:n}),actionLabel:s(`openclawId.makeReachable`),onAction:()=>N(e,r,t),durationMs:3e4})}function Oe(e){return e.channel===`local_operator`?S():null}function ke(e){return e.remoteAccessSetup?S():null}function Ae(e,t){if(!e.startsWith(U)||!t.status||t.status.status.state===`off`)return!1;let{client:r,status:i}=t;if((e===K||e===q)&&A(i))window.location.assign(`/_loader/?stay=1&view=${e===K?`approve`:`devices`}`);else if(e===q&&r&&i?.owner)M(async()=>(await n(async()=>{let{showOwnerDevicesDialog:e}=await import(`./owner-devices-dialog-CWAtkD2N.js`);return{showOwnerDevicesDialog:e}},__vite__mapDeps([18,5,6,7,8,19,10,20,13,14,21]),import.meta.url)).showOwnerDevicesDialog({client:r}));else if(e===Y&&i?.channel===`local_operator`&&i.link.hostname)u(`https://${i.link.hostname}`).then(e=>{e&&t.onLinkCopied?.(),p({severity:e?`success`:`error`,message:s(e?`openclawId.remoteLinkCopied`:`openclawId.remoteLinkCopyFailed`)})});else if(e===J)i?.channel===`tunnel`?M(Te,`signOut`):M(async()=>{await se({title:s(`openclawId.signOut`),message:s(`openclawId.signOutReachability`),confirmLabel:s(`openclawId.signOut`)})&&_e()},`signOut`);else if(e===W&&r&&i.accountSignIn===`device`)M(async()=>(await n(async()=>{let{showDeviceSignInDialog:e}=await import(`./device-sign-in-dialog-Cd2yPFpR.js`);return{showDeviceSignInDialog:e}},__vite__mapDeps([18,5,6,7,13,14,21]),import.meta.url)).showDeviceSignInDialog({client:r,basePath:t.basePath}),`signIn`);else if(e===W&&r&&i.accountSignIn===`popup`)ye({client:r,basePath:t.basePath}).then(e=>De(r,i,e.email??s(`openclawId.accountFallback`)),e=>p({severity:`error`,message:C(e,`signIn`),durationMs:12e3}));else if(e===G&&r&&i?.services.loaderDomain)N(r,i.services.loaderDomain,i);else if(e===X&&r&&i.link.hostname){let e=Oe(i),a=i.link.hostname;e&&M(async()=>{await(await n(async()=>{let{showMoveKeysDialog:e}=await import(`./move-keys-dialog-K3_RgkJv.js`).then(e=>(e.t(),e.n));return{showMoveKeysDialog:e}},__vite__mapDeps([22,5,6,7,23,8,13,14,24]),import.meta.url)).showMoveKeysDialog({client:r,signedIn:e,hostname:a})&&t.onKeysChanged?.()})}else if(e===Z&&r){let e=ke(i);e&&M(async()=>{let{publishWithLinkCode:i}=await n(async()=>{let{publishWithLinkCode:e}=await import(`./rebind-Cs3NDOde.js`).then(e=>(e.r(),e.a));return{publishWithLinkCode:e}},__vite__mapDeps([8,13,14]),import.meta.url),{publication:a}=await i(r,e);if(a?.state===`failed`)throw Object.assign(Error(`OpenClaw ID publication failed`),a);t.onKeysChanged?.(),p({severity:`success`,message:s(`openclawId.newKeysPublished`)})},`linkCode`)}return!0}var P,F,I,L,R,z,B,V,H,U,W,G,K,q,J,Y,X,Z;function Q(){return(Q=e((()=>{b(),ge(),o(),ve(),T(),be(),a(),ee(),Se(),oe(),m(),d(),t(),P=x(`<div class=sidebar-openclaw-id__status><span class=nav-item__icon aria-hidden=true></span><span class=sidebar-openclaw-id__lines><span>`),F=x(`<span class=sidebar-openclaw-id__detail>`),I=x(`<span class=sidebar-openclaw-id__pill>`),L=x(`<button><span class=nav-item__icon aria-hidden=true><svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="m10 17 5-5-5-5M15 12H3M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"></path></svg></span><span class=sidebar-openclaw-id__lines><span>`),R=x(`<span class=oc-menu-item__details>`),z=x(`<span class=sidebar-openclaw-id__linked-content><span class=nav-item__icon aria-hidden=true></span><span class=sidebar-openclaw-id__label></span><span class=sidebar-openclaw-id__trailing><span class=sidebar-openclaw-id__pill></span><span class=sidebar-openclaw-id__copy aria-hidden=true><span class=sidebar-openclaw-id__copy-a></span><span class=sidebar-openclaw-id__copy-b></span></span></span><span class=sidebar-openclaw-id__detail>`),B=x(`<svg><path d="m16 17 5-5-5-5M21 12H9M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></svg>`,2),V=x(`<span class=nav-item__icon aria-hidden=true>`),H=x(`<span class=sidebar-customize-menu__text>`),ie(he),U=`openclaw-id:`,W=`${U}sign-in`,G=`${U}make-reachable`,K=`${U}approve-device`,q=`${U}devices`,J=`${U}sign-out`,Y=`${U}copy-link`,X=`${U}move-keys`,Z=`${U}publish-keys`})))()}function je(e){let t=i(),n=ae(t.gateway),r=h(()=>{let{snapshot:e,connectionRevision:t}=n.read();return e.phase===`connected`&&e.client?{client:e.client,revision:t}:null},{equals:(e,t)=>e?.client===t?.client&&e?.revision===t?.revision}),a=h(async()=>r()?.client.request(`openclawId.status`,{}).catch(()=>null)??null,{loadingValue:null}),o=h(()=>{let e=r(),n=a();if(!e||n?.channel!==`local_operator`||!n.owner||!n.link.linked)return null;let i=h(t=>e.client.request(`openclawId.people`,{}).then(({link:e})=>e.publication??null).catch(()=>t),{loadingValue:null}),o=e=>{e.event===`openclawId.people.changed`&&g(i)};return de(()=>t.gateway.subscribeEvents(o)),i}),[s,l]=ce(!1),u=c(()=>l(!1),2200),d=h(()=>{let n=a();if(n&&n.status.state!==`off`)return{identity:E(n),entries:j(n,o()?.(),s),signOut:Ee(n),onSelect:n=>Ae(n,{status:a(),client:t.gateway.snapshot.client,basePath:e.basePath,onLinkCopied:()=>{l(!0),u.schedule()},onKeysChanged:()=>t.sidebarAttention.refreshOpenClawId()})}});return y(xe,le(e,{get extension(){return d()}}))}function $(){return($=e((()=>{b(),ue(),ne(),l(),re(),Ce(),Q()})))()}$();export{je as OpenClawIdIdentityMenu};