UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

318 lines 47.3 kB
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{R as t,_i as n,gi as r,wr as i,z as a}from"./control-ui-foundation-Cydpkyqa.js";import{Eo as o,Oo as s,Sc as c,bc as l,bs as ee,cc as te,dc as ne,uc as re,yc as ie,ys as ae}from"./control-ui-core-Rwzhj6nO.js";import{$ as oe,K as u,X as d,at as f,q as p,st as se}from"./lit-runtime-CV_MH99K.js";import{An as ce,B as le,I as ue,V as de,Zt as fe,_ as m,_n as pe,en as me,g as he,jn as ge,nn as _e,tn as ve}from"./control-ui-core-YphAl4aM.js";import{Gt as ye,Wt as be,Yt as h,en as g}from"./control-ui-core-vvcQQV2m.js";import{An as _,Bn as v,Fn as xe,Hn as y,In as Se,Jn as b,Kn as x,Mn as Ce,Nn as S,Pn as we,Qn as C,Sn as Te,Xn as w,_n as Ee,bn as De,cr as T,gn as Oe,hn as ke,ir as E,mn as Ae,ur as D,vn as je,xn as Me,yn as Ne}from"./control-ui-boot-shared-BYq7Cchl.js";import{Ca as Pe,Cr as Fe,F as Ie,P as O,Sa as Le,Sr as Re,Ta as ze,xr as Be,zi as Ve}from"./control-ui-boot-shared-DfZ39Yj9.js";import{G as He,H as k,J as A,K as Ue,L as j,Q as M,V as N,W as We,X as P,Z as Ge,an as Ke,et as qe,on as Je,tt as F,z as Ye}from"./control-ui-boot-chat-_QSl8fbH.js";import{F as Xe,N as Ze}from"./control-ui-boot-shared-3juXI2I2.js";import{n as Qe,t as $e}from"./select-picker-BNhpItgu.js";import{r as et,t as tt}from"./wizard-step-controls-BcNiLuAR.js";import{a as nt,r as I}from"./settings-targets-BmloFKW8.js";import{n as rt,t as it}from"./settings-workspace-Bseic8Tf.js";import{a as at,c as ot,i as st,n as ct,r as lt,s as ut,t as dt}from"./github-identity-view-B8sN2SqT.js";var ft,pt;function mt(){return(mt=e((()=>{xe(),we(),ft=v([b(`auth`),b(`rate_limit`),b(`billing`),b(`timeout`),b(`format`),b(`unavailable`),b(`unknown`)]),pt=S({disposition:b(`rejected-before-promotion`),status:ft})})))()}var ht,gt,_t,vt,yt,bt,L;function xt(){return(xt=e((()=>{xe(),we(),Ce(),mt(),ht=v([b(`running`),b(`done`),b(`cancelled`),b(`error`)]),S({mode:T(v([b(`local`),b(`remote`)])),workspace:T(y()),installDaemon:T(C()),flow:T(v([b(`setup`),b(`channels`)])),channel:T(_)}),gt=S({stepId:_,value:T(E())}),S({sessionId:_,answer:T(gt)}),S({sessionId:_}),_t=S({value:E(),label:_,hint:T(y())}),vt=S({code:_,expiresInMinutes:T(w({minimum:1,maximum:1440})),message:T(y())}),yt=S({id:_,type:v([b(`note`),b(`select`),b(`text`),b(`confirm`),b(`multiselect`),b(`progress`),b(`action`)]),title:T(y()),message:T(y()),format:T(v([b(`plain`)])),options:T(D(_t)),initialValue:T(E()),placeholder:T(y()),sensitive:T(C()),executor:T(v([b(`gateway`),b(`client`)])),externalUrl:T(y()),deviceCode:T(vt)}),bt=S({channel:_,accountId:_}),L={done:C(),step:T(yt),status:T(ht),error:T(y()),channels:T(D(_)),accounts:T(D(bt)),preparedModelRef:T(_),modelActivation:T(S({modelRef:_,gatewayRestartRequired:T(b(!0))})),activationRejection:T(pt)},S(L),S({sessionId:_,...L}),S({status:ht,error:T(y())})})))()}function St(e){return e===void 0||e===!0}var R,Ct,z,B,wt,V,Tt,Et,Dt,Ot,H,U,W,G,K,kt,At,q,J,jt,Mt,Nt;function Pt(){return(Pt=e((()=>{xe(),Te(),we(),Ce(),xt(),R=`git.coauthor.enabled`,Ct=`gateway-owner`,z=y({minLength:1,maxLength:128}),B=y({maxLength:256}),wt=y({minLength:1,maxLength:128,pattern:`\\S`}),V=y({pattern:`^.{1,256}$`}),Tt=Se(V,E()),Et=Se(V,E(),{maxProperties:32}),Dt=v([b(`image/png`),b(`image/jpeg`),b(`image/webp`)]),Ot=S({login:y({minLength:1,maxLength:39}),profileUrl:_,avatarUrl:_}),H=S({id:z,displayName:v([B,x()]),avatarMime:v([Dt,x()]),mergedInto:v([z,x()]),createdAt:w({minimum:0}),updatedAt:w({minimum:0}),emails:D(_),githubIdentity:v([Ot,x()]),hasAvatar:C(),role:T(wt)}),S({}),S({profiles:D(H)}),S({}),S({profile:H}),S({email:y({minLength:1,maxLength:320}),targetProfileId:z}),S({profile:H}),S({profileId:z,displayName:v([B,x()])}),S({profile:H}),S({profileId:z,role:v([wt,x()])}),S({profile:H}),S({profileId:z,mime:Dt,avatarBase64:y({minLength:1,maxLength:7e5})}),S({profile:H,avatarRevision:_}),U=y({minLength:1,maxLength:256}),W=y({minLength:1,maxLength:128}),G=y({minLength:1,maxLength:128}),K=S({provider:W,authProfileId:U,updatedAt:w({minimum:0})}),kt=S({authProfileId:U,provider:W,label:y({minLength:1,maxLength:256}),authType:v([b(`api_key`),b(`oauth`),b(`token`)]),selected:C()}),S({profileId:T(z),cursor:T(U)}),S({profileId:z,accounts:D(kt,{maxItems:50}),nextCursor:T(U),links:D(K)}),S({profileId:T(z),authProfileId:U}),S({links:D(K)}),At=T(v([b(`auto`),b(`user`),b(`user-link`)])),q=y({minLength:1,maxLength:256}),v([S({kind:b(`automatic`),label:q}),S({kind:b(`personal`),label:q,authProfileId:T(U),source:At}),S({kind:b(`shared`),label:q,authProfileId:U,source:At})]),S({profileId:z}),S({links:D(K)}),S({profileId:z,authProfileId:U}),S({links:D(K)}),S({profileId:z,provider:W}),S({links:D(K)}),S({profileId:z}),S({providers:D(S({id:W,label:_,methods:D(S({id:_,label:_,hint:T(y())}))}))}),S({profileId:z,provider:W,method:_}),S({connectId:G,expiresAtMs:w({minimum:0})}),S({profileId:z,connectId:G,...gt.properties}),S({profileId:z,connectId:G}),v([S({status:b(`pending`),step:T(yt),error:T(y())}),S({status:b(`connected`),authProfileId:U,links:D(K)}),S({status:b(`cancelled`)}),S({status:b(`expired`)}),S({status:b(`failed`),reason:v([b(`exchange`),b(`identity`),b(`authority`),b(`unavailable`)])})]),S({authProfileId:U,links:D(K)}),S({keys:T(D(V,{maxItems:32,uniqueItems:!0}))}),v([S({status:b(`ok`),entries:Tt}),S({status:b(`no_durable_identity`)})]),S({entries:Et}),v([S({status:b(`ok`)}),S({status:b(`no_durable_identity`)})]),S({profileId:z,keys:D(V,{maxItems:32,uniqueItems:!0})}),J=y({format:`uuid`,maxLength:36}),jt=S({accountId:w({minimum:1,maximum:2**53-1}),login:y({minLength:1,maxLength:39,pattern:`^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$`})}),S({}),Mt=S({requestId:J,userCode:y({pattern:`^[A-Z0-9]{4}-[A-Z0-9]{4}$`}),verificationUri:b(`https://github.com/login/device`),expiresInMs:w({minimum:0,maximum:9e5}),pollAfterMs:w({minimum:1,maximum:6e4})}),S({requestId:J}),S({requestId:J}),S({cancelled:C()}),S({}),S({disconnected:b(!0)}),Nt=S({state:v([b(`connected`),b(`disconnected`),b(`unavailable`)]),generation:v([J,x()]),account:v([jt,x()]),accessExpiresAtMs:v([w({minimum:0}),x()]),refreshState:v([b(`available`),b(`refreshing`),b(`expired`),b(`failed`),b(`not_applicable`)]),pending:v([Mt,x()])}),S({}),S({personal:Nt,system:Ae}),v([De,Me,ke,Oe,je,Ne,Ee,S({status:b(`success`),personal:Nt})])})))()}var Y;function Ft(){return(Ft=e((()=>{a(),u(),oe(),m(),_e(),j(),h(),ee(),c(),nt(),ot(),dt(),Y=class extends l{constructor(...e){super(...e),this.purpose=`personal`,this.setupOpen=!1,this.snapshot=null,this.revision=0,this.canRead=!1,this.canAdmin=!1,this.profileId=null,this.subscriptions=[],this.personal=new ut({requestUpdate:()=>this.requestUpdate()}),this.system=new ut({requestUpdate:()=>this.requestUpdate(),runExternalMutation:(e,t)=>this.context.runtimeConfig.runExternalMutation(e,t)})}connectedCallback(){super.connectedCallback(),this.subscriptions=[this.context.gateway.subscribe(e=>this.applySnapshot(e)),this.context.agents.subscribe(()=>this.syncControllers()),this.context.runtimeConfig.subscribe(()=>this.syncControllers())],this.applySnapshot(this.context.gateway.snapshot)}disconnectedCallback(){for(let e of this.subscriptions)e();this.subscriptions=[],this.personal.dispose(),this.system.dispose(),this.snapshot=null,this.revision+=1,super.disconnectedCallback()}applySnapshot(e){let t=this.snapshot,n=!t||t.client!==e.client||t.phase!==e.phase||t.hello!==e.hello||this.profileId!==(e.selfUser?.id??null);this.snapshot=e,this.profileId=e.phase===`connected`?e.selfUser?.id??null:null,this.canRead=e.phase===`connected`&&!!e.hello?.auth&&me(e.hello?.auth??null),this.canAdmin=this.canRead&&fe(e.hello?.auth??null),n&&(this.revision+=1,this.setupOpen=!1,this.purpose=this.profileId?`personal`:`system`),this.syncControllers(),this.canAdmin&&this.context.runtimeConfig.ensureLoaded()}syncControllers(){let e=this.snapshot;if(!e)return;let t={client:e.client,connected:e.phase===`connected`,clientRevision:this.revision};this.personal.sync({...t,target:this.profileId?{kind:`personal`,profileId:this.profileId}:null,statusReadable:this.canRead&&this.profileId!==null,authorizable:this.canRead&&this.profileId!==null,configurable:!1});let n=this.context.agents.state.agentsList?.defaultId;this.system.sync({...t,target:n?{kind:`shared`,scope:`system`,agentId:n,config:ae(this.context.runtimeConfig.state)}:null,statusReadable:this.canAdmin,authorizable:this.canAdmin,configurable:this.canAdmin}),this.personal.statusReadable&&!this.personal.personal&&!this.personal.loading&&!this.personal.error&&this.personal.verify(),n&&this.canAdmin&&!this.system.status&&!this.system.loading&&!this.system.error&&this.system.verify(),this.requestUpdate()}get locked(){return this.personal.loading||this.system.loading||this.personal.authorizationActive||this.system.authorizationActive||this.personal.busy||this.system.busy}openSetup(e){this.locked||(e===`personal`?!this.profileId||!this.canRead:!this.canAdmin)||(this.purpose=e,this.setupOpen=!0)}render(){let e=this.personal.personal,t=this.system.status?.selected.identity??this.personal.system,n=this.purpose===`personal`?this.personal:this.system,r=this.setupOpen||this.personal.authorizationActive||this.system.authorizationActive,i=e?.state===`connected`,a=e?.state===`unavailable`||e?.refreshState===`expired`||e?.refreshState===`failed`,o=this.profileId?g(a?`githubConnections.reconnectRequired`:i?`githubConnections.connected`:e?`githubConnections.disconnected`:`githubConnections.notLoaded`):g(`githubConnections.signInRequired`);return d`<div id=${I.githubConnections}> ${P({title:g(`githubConnections.title`),description:g(`githubConnections.description`),actions:this.canRead&&(this.profileId||this.canAdmin)?d`<button class="btn btn--sm" ?disabled=${this.locked||!this.profileId&&!this.system.status} @click=${()=>this.openSetup(this.profileId?`personal`:`system`)} > ${g(`agentTools.githubConnect`)} </button> <button class="btn btn--sm" ?disabled=${this.locked} @click=${()=>{this.personal.verify(),this.system.verify()}} > ${g(`agentTools.githubVerify`)} </button>`:void 0},d` <div data-github-connection="personal"> ${A({title:g(`githubConnections.mine`),description:this.profileId?d`${e?.account?`@${e.account.login} · `:``}${g(`githubConnections.personalDescription`)}`:g(`githubConnections.unboundDescription`),control:d`${M({kind:a?`warn`:i?`ok`:`muted`,label:o})} ${this.profileId&&this.canRead?d`<button class="btn btn--sm" ?disabled=${this.locked} @click=${()=>this.openSetup(`personal`)} > ${g(i?`githubConnections.changeMine`:`githubConnections.connectMine`)} </button>`:p}`})} </div> <div data-github-connection="system"> ${A({title:g(`githubConnections.system`),description:d`${t?.account?`@${t.account.login} · `:``}${g(`githubConnections.systemDescription`)}`,control:d`${at(t)}${this.canAdmin?d`<button class="btn btn--sm" ?disabled=${this.locked||!this.system.status} @click=${()=>this.openSetup(`system`)} > ${g(`githubConnections.changeSystem`)} </button>`:F(g(`githubConnections.adminManaged`))}`})} </div> ${ct(this.personal.error??this.system.error,d`<button class="btn btn--sm" ?disabled=${this.locked} @click=${()=>{this.personal.verify(),this.system.verify()}} > ${g(`common.retry`)} </button>`)} ${r?d`<div class="settings-subrows" data-github-setup> ${A({title:g(`githubConnections.purpose`),control:this.profileId&&this.canAdmin&&this.system.status?Ge({value:this.purpose,options:[{value:`personal`,label:g(`githubConnections.forMe`)},{value:`system`,label:g(`githubConnections.forSystem`)}],disabled:this.locked,ariaLabel:g(`githubConnections.purpose`),onChange:e=>this.openSetup(e)}):F(this.purpose===`personal`?g(`githubConnections.forMe`):g(`githubConnections.forSystem`))})} ${lt(n)} ${this.locked?p:A({title:g(`githubConnections.purposeHint`),control:d`<button class="btn btn--sm" @click=${()=>{this.setupOpen=!1,n.hidePatFallback()}} > ${g(`common.close`)} </button>`})} </div>`:p} <details class="settings-row settings-row--stacked"> <summary class="settings-row__title">${g(`githubConnections.usage`)}</summary> <div class="settings-row__desc">${g(`githubConnections.usageDescription`)}</div> ${st(t)} </details> ${this.canAdmin&&this.system.status?.selected.configured?A({title:g(`agentTools.githubUseNativeNewRuns`),description:g(`agentTools.githubSystemMutationHint`),control:d`<button class="btn btn--sm" ?disabled=${this.locked} @click=${()=>void this.system.inherit()} > ${g(`agentTools.githubUseNativeNewRuns`)} </button>`}):p} `)} ${this.profileId&&this.canRead&&e&&e.state!==`disconnected`?P({danger:!0},A({title:g(`githubConnections.disconnectMine`),description:g(`githubConnections.disconnectDescription`),control:d`<button class="btn btn--sm" ?disabled=${this.locked} @click=${()=>void this.personal.disconnect()} > ${g(`githubConnections.disconnectMine`)} </button>`})):p} </div>`}},i([t({context:he,subscribe:!1})],Y.prototype,`context`,void 0),i([f()],Y.prototype,`purpose`,void 0),i([f()],Y.prototype,`setupOpen`,void 0),customElements.get(`openclaw-github-connections`)||customElements.define(`openclaw-github-connections`,Y)})))()}function It(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)throw new X(`invalid-image`);let n=Math.min(e,t),r=Math.min(1,Ht/n);return{sourceEdge:n,sourceX:Math.max(0,Math.round((e-n)/2)),sourceY:Math.max(0,Math.round((t-n)/2)),edge:Math.max(1,Math.round(n*r))}}async function Lt(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,e.src=t,await e.decode(),e}catch{throw new X(`invalid-image`)}finally{URL.revokeObjectURL(t)}}function Rt(e,t,n){return new Promise(r=>{e.toBlob(r,t,n)})}function zt(e){let t=[];for(let n=0;n<e.length;n+=32768)t.push(String.fromCharCode(...e.subarray(n,n+32768)));return btoa(t.join(``))}async function Bt(e,t){if(e.size>Ut)throw new X(`too-large`);let n=new Uint8Array(await e.arrayBuffer()),r=zt(n);if(r.length>Wt)throw new X(`too-large`);return{mime:t,avatarBase64:r,byteLength:n.byteLength}}async function Vt(e){if(![`image/png`,`image/jpeg`,`image/webp`].includes(e.type))throw new X(`invalid-image`);if(e.size>Gt)throw new X(`source-too-large`);let t=await Lt(e),n=It(t.naturalWidth,t.naturalHeight),r=document.createElement(`canvas`);r.width=n.edge,r.height=n.edge;let i=r.getContext(`2d`);if(!i)throw new X(`invalid-image`);i.drawImage(t,n.sourceX,n.sourceY,n.sourceEdge,n.sourceEdge,0,0,n.edge,n.edge);let a=e.type===`image/webp`?`image/webp`:`image/png`,o=await Rt(r,a,a===`image/webp`?.9:void 0);if((!o||o.type!==a||o.size>Ut)&&(a=`image/webp`,o=await Rt(r,a,.82)),!o||o.type!==a)throw new X(`invalid-image`);return Bt(o,a)}var Ht,Ut,Wt,Gt,X;function Kt(){return(Kt=e((()=>{Ht=512,Ut=524288,Wt=7e5,Gt=10485760,X=class extends Error{constructor(e){super(e),this.code=e,this.name=`ProfileAvatarError`}}})))()}function qt(e){return e.target.value}function Jt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return g(`profilePage.modelAccounts.gatewayUnavailable`)}}function Yt(e,t){return e.some(e=>e.authProfileId!==t.authProfileId&&e.provider===t.provider&&e.label===t.label)?d` <code>${t.authProfileId}</code>`:``}function Xt(e,t){let n=e.accounts.find(e=>e.authProfileId===t.authProfileId);return A({title:d` <span class="model-accounts__id" >${n?.label??g(`profilePage.modelAccounts.gatewayAccount`)}</span > <span class="model-accounts__provider">${Pe(t.provider)}</span> `,description:d`${g(`profilePage.modelAccounts.linkedDescription`)}${n?Yt(e.accounts,n):``}`,control:d` ${M({kind:`ok`,label:g(`profilePage.modelAccounts.linkedStatus`)})} <button type="button" class="btn btn--sm profile-auth-link-unlink" ?disabled=${e.busy} @click=${()=>e.onUnlink(t.provider)} > ${g(`profilePage.modelAccounts.unlinkAction`)} </button> `})}function Zt(e,t){return A({title:d` <span class="model-accounts__id">${t.label}</span> <span class="model-accounts__provider">${Pe(t.provider)}</span> `,description:d`${g(`profilePage.modelAccounts.authTypes.${t.authType}`)}${Yt(e.accounts,t)}`,control:d` <button type="button" class="btn btn--sm profile-auth-account-select" data-auth-profile-id=${t.authProfileId} ?disabled=${e.busy} @click=${()=>e.onSelectAccount(t.authProfileId)} > ${g(`profilePage.modelAccounts.selectAction`)} </button> `})}function Qt(e){let t=e.signIn;if(!t)return``;let n=t.providers.find(e=>e.id===t.provider),r=e.connectFlow,i=r?.step,a=d`<button type="button" class="btn btn--sm profile-auth-connect-cancel" ?disabled=${e.cancelBusy} @click=${r?e.onConnectCancel:e.onCloseSignIn} > ${g(`profilePage.modelAccounts.cancelAction`)} </button>`;return A({title:r?r.step?.title??n?.label??g(`profilePage.modelAccounts.connectAction`):g(`profilePage.modelAccounts.addAccount`),stacked:!0,control:r?d`<div class="model-accounts-flow"> ${i?et({step:i,value:e.stepValue,busy:e.busy,inputId:`profile-account-auth-answer`,leadingAction:a,onValueChange:t=>e.onStepValueChange(i.id,t),onAnswer:t=>e.onStepAnswer(i.id,t)}):d`<span role="status">${g(`common.loading`)}</span>${a}`} ${e.statusUnavailable?d`<button type="button" class="btn btn--sm profile-auth-connect-check" ?disabled=${e.cancelBusy} @click=${e.onConnectCheck} > ${g(`profilePage.modelAccounts.checkStatusAction`)} </button>`:``} </div>`:d`<div class="model-accounts-choice"> ${Qe({label:g(`profilePage.modelAccounts.provider`),className:`profile-auth-provider`,value:t.provider||null,options:t.providers.map(e=>({value:e.id,label:e.label})),disabled:e.busy,renderLeading:e=>ze(e.value),onChange:e.onProviderChange})} ${n?Qe({label:g(`profilePage.modelAccounts.method`),className:`profile-auth-method`,value:t.method||null,options:n.methods.map(e=>({value:e.id,label:e.label,description:e.hint})),disabled:e.busy,onChange:e.onMethodChange}):``} ${!e.busy&&!e.error&&t.providers.length===0?d`<span>${g(`profilePage.modelAccounts.noMethods`)}</span>`:``} <div class="wizard-step__actions"> ${a} <button type="button" class="btn btn--sm primary profile-auth-connect-start" ?disabled=${e.busy||!t.method} @click=${e.onConnectStart} > ${g(`profilePage.modelAccounts.connectAction`)} </button> </div> </div>`})}function $t(e){return A({title:g(`profilePage.modelAccounts.inputLabel`),description:g(`profilePage.modelAccounts.inputDescription`),stackedOnNarrow:!0,control:d` <form class="model-accounts-form" @submit=${t=>{t.preventDefault(),e.onLink()}} > <input class="settings-input profile-auth-link-input" type="text" aria-label=${g(`profilePage.modelAccounts.inputLabel`)} .value=${e.linkDraft} placeholder=${g(`profilePage.modelAccounts.inputPlaceholder`)} ?disabled=${e.busy} @input=${t=>e.onLinkDraftInput(qt(t))} /> <button type="submit" class="btn btn--sm profile-auth-link-submit" ?disabled=${e.busy||!e.linkDraft.trim()} > ${g(`profilePage.modelAccounts.linkAction`)} </button> </form> `})}function en(e){return d` ${e.links.length===0?N(g(`profilePage.modelAccounts.empty`)):e.links.map(t=>Xt(e,t))} ${e.accounts.filter(e=>!e.selected).map(t=>Zt(e,t))} ${e.hasMore?A({title:g(`profilePage.modelAccounts.savedAccounts`),control:d`<button type="button" class="btn btn--sm profile-auth-accounts-more" ?disabled=${e.busy} @click=${e.onLoadMore} > ${g(`profilePage.modelAccounts.loadMore`)} </button>`}):``} ${Qt(e)} ${e.showManualLink?$t(e):``} ${e.notice?d`<div class="settings-row model-accounts-notice" role="status"> <span class="settings-row__desc">${e.notice}</span> </div>`:``} ${e.error?d`<div class="settings-row model-accounts-error" role="alert"> <span class="settings-row__desc">${e.error}</span> </div>`:``} ${e.inventoryError?d`<div class="settings-row model-accounts-error" role="alert"> ${g(`profilePage.modelAccounts.inventoryFailed`)} ${e.inventoryError} </div>`:``} `}function tn(e,t){let n=d` ${A({title:g(`profilePage.modelAccounts.gateway`),stackedOnNarrow:!0,control:F(Jt(e.gatewayUrl),{mono:!0})})} ${A({title:g(`profilePage.modelAccounts.person`),stackedOnNarrow:!0,control:F(e.personLabel??g(`profilePage.modelAccounts.noPerson`))})} ${A({title:g(`profilePage.modelAccounts.scope`),description:g(`profilePage.modelAccounts.personalDescription`),control:F(g(`profilePage.modelAccounts.personal`))})} ${t?en(t):A({title:g(`profilePage.modelAccounts.signInUnavailable`),description:g(`profilePage.modelAccounts.unavailable.${e.unavailableReason}`),stacked:!0,control:d` <button type="button" class="btn btn--sm" @click=${e.onConnectionSettings}> ${g(`profilePage.modelAccounts.connectionSettings`)} </button> ${Ye(`https://docs.openclaw.ai/concepts/multi-user#per-person-model-accounts`)} `})} `;return P({title:g(`profilePage.modelAccounts.title`),description:g(`profilePage.modelAccounts.description`),actions:t?d`${t.signIn?``:d`<button type="button" class="btn btn--sm primary profile-auth-add-account" ?disabled=${t.busy} @click=${t.onAddAccount} > ${g(`profilePage.modelAccounts.addAccount`)} </button>`}<button type="button" class="btn btn--sm profile-auth-accounts-refresh" ?disabled=${t.inventoryLoading} @click=${t.onRefresh} > ${g(`common.refresh`)} </button>`:void 0},n)}function nn(){return(nn=e((()=>{u(),Le(),$e(),j(),tt(),h(),O(),Ie()})))()}var Z;function rn(){return(rn=e((()=>{a(),u(),oe(),m(),_e(),h(),O(),s(),c(),nn(),Ie(),Z=class extends ie{constructor(...e){super(...e),this.identityId=null,this.profileId=null,this.personLabel=null,this.links=[],this.accounts=[],this.inventoryLoading=!1,this.inventoryError=null,this.action=null,this.error=null,this.notice=null,this.linkDraft=``,this.signIn=null,this.connectFlow=null,this.statusUnavailable=!1,this.target=null,this.generation=0,this.inventoryRequest=0,this.unsubscribe=null,this.pollTimer=null}connectedCallback(){super.connectedCallback(),this.unsubscribe=this.context.gateway.subscribe(e=>{this.applySnapshot(e),this.requestUpdate()}),this.applySnapshot(this.context.gateway.snapshot)}disconnectedCallback(){this.unsubscribe?.(),this.unsubscribe=null,this.generation+=1,this.target=null,this.stopPoll(),super.disconnectedCallback()}willUpdate(e){(e.has(`profileId`)||e.has(`identityId`))&&this.isConnected&&this.applySnapshot(this.context.gateway.snapshot)}applySnapshot(e){let t=e.phase===`connected`&&ve(e.hello?.auth??null),n=t?e.client:null,r=e.selfUser?.id??null,i=n&&r===this.identityId?this.profileId:null,a=t&&fe(e.hello?.auth??null);(this.target?.client!==n||this.target?.identityId!==r||this.target?.profileId!==i||this.target?.canAdmin!==a)&&(this.generation+=1,this.stopPoll(),this.target=n&&r&&i?{client:n,identityId:r,profileId:i,canAdmin:a}:null,this.links=[],this.accounts=[],this.nextCursor=void 0,this.inventoryRequest+=1,this.inventoryLoading=!1,this.inventoryError=null,this.action=null,this.error=null,this.notice=null,this.linkDraft=``,this.signIn=null,this.connectFlow=null,this.stepValue=void 0,this.statusUnavailable=!1,this.target&&this.loadAccounts())}applyLinks(e){this.links=e,this.accounts=this.accounts.map(t=>({...t,selected:e.some(e=>e.authProfileId===t.authProfileId)}))}async loadAccounts(e){let t=this.target;if(!t)return;let n=++this.inventoryRequest,r=()=>this.isConnected&&this.target===t&&n===this.inventoryRequest;this.inventoryLoading=!0,this.inventoryError=null;try{let n=await t.client.request(`users.listModelAccounts`,{profileId:t.profileId,...e?{cursor:e}:{}});r()&&(this.accounts=e?[...this.accounts,...n.accounts]:n.accounts,this.nextCursor=n.nextCursor,this.applyLinks(n.links))}catch(e){r()&&(this.inventoryError=o(e))}finally{r()&&(this.inventoryLoading=!1)}}isCurrent(e,t){return this.isConnected&&this.target===e&&this.generation===t}async runAction(e,t,n){let r=this.target;if(!r||this.action&&(e!==`cancel`||this.action!==`answer`))return;let i=++this.generation;this.stopPoll(),this.action=e,this.error=null,this.notice=null,this.statusUnavailable=!1;try{let e=await t(r);this.isCurrent(r,i)&&n(e)}catch(e){this.isCurrent(r,i)&&(this.error=o(e,g(`profilePage.modelAccounts.actionFailed`)))}finally{this.isCurrent(r,i)&&(this.action=null,this.schedulePoll(this.connectFlow?.step?2e3:0))}}updateLink(e){let t=`authProfileId`in e;t&&(!e.authProfileId||!this.target?.canAdmin)||this.runAction(`request`,n=>n.client.request(t?`users.linkAuthProfile`:`users.unlinkAuthProfile`,{profileId:n.profileId,...e}),e=>{this.applyLinks(e.links),this.linkDraft=``,this.notice=t?`selected`:`cleared`,this.loadAccounts()})}selectAccount(e){this.runAction(`request`,t=>t.client.request(`users.selectModelAccount`,{profileId:t.profileId,authProfileId:e}),e=>{this.applyLinks(e.links),this.notice=`selected`,this.loadAccounts()})}openSignIn(){this.signIn={providers:[],provider:``,method:``},this.runAction(`request`,e=>e.client.request(`users.authConnect.catalog`,{profileId:e.profileId}),e=>{this.signIn={providers:e.providers,provider:``,method:``}})}selectProvider(e){let t=this.signIn,n=t?.providers.find(t=>t.id===e);t&&n&&!this.action&&!this.connectFlow&&(this.signIn={...t,provider:e,method:n.methods.length===1?n.methods[0]?.id??``:``})}startConnect(){let e=this.signIn;e?.providers.some(t=>t.id===e.provider&&t.methods.some(t=>t.id===e.method))&&this.runAction(`request`,t=>t.client.request(`users.authConnect.start`,{profileId:t.profileId,provider:e.provider,method:e.method}),e=>{this.connectFlow=e,this.stepValue=void 0})}applyConnectStatus(e){if(e.status===`pending`){e.error&&(this.error=o(e.error)),this.connectFlow&&=(this.connectFlow.step?.id!==e.step?.id&&(this.stepValue=e.step?.sensitive?void 0:e.step?.initialValue),{...this.connectFlow,step:e.step});return}if(this.error=null,this.statusUnavailable=!1,this.stopPoll(),this.signIn=null,this.connectFlow=null,this.stepValue=void 0,e.status===`failed`){this.error=g(`profilePage.modelAccounts.connectErrors.${e.reason}`);return}e.status===`connected`&&(this.applyLinks(e.links),this.loadAccounts()),this.notice=e.status}connectStatus(e){let t=this.connectFlow;t&&this.runAction(e===`status`?`request`:e,n=>n.client.request(`users.authConnect.${e}`,{profileId:n.profileId,connectId:t.connectId}),e=>this.applyConnectStatus(e))}answerStep(e,t){let n=this.connectFlow,r=n?.step;!n||!r||r.id!==e||r.type===`progress`||(r.sensitive&&(this.stepValue=void 0),this.runAction(`answer`,e=>e.client.request(`users.authConnect.answer`,{profileId:e.profileId,connectId:n.connectId,stepId:r.id,...t===void 0?{}:{value:t}}),e=>this.applyConnectStatus(e)))}stopPoll(){this.pollTimer!==null&&(clearTimeout(this.pollTimer),this.pollTimer=null)}schedulePoll(e=2e3){this.stopPoll();let t=this.connectFlow;if(!t||!this.target||this.action)return;let n=Math.max(0,Math.min(e,t.expiresAtMs-Date.now()));this.pollTimer=setTimeout(()=>{this.pollTimer=null,this.pollStatus()},n)}async pollStatus(){let e=this.target,t=this.connectFlow,n=this.generation;if(!(!e||!t||this.action))try{let r=await e.client.request(`users.authConnect.status`,{profileId:e.profileId,connectId:t.connectId});if(!this.isCurrent(e,n)||this.connectFlow?.connectId!==t.connectId)return;this.applyConnectStatus(r),this.connectFlow&&(Date.now()>=t.expiresAtMs?(this.statusUnavailable=!0,this.error=g(`profilePage.modelAccounts.statusTimedOut`)):this.schedulePoll())}catch(t){this.isCurrent(e,n)&&(this.statusUnavailable=!0,this.error=o(t,g(`profilePage.modelAccounts.statusFailed`)))}}render(){let e=this.context.gateway.snapshot;if(e.phase!==`connected`||!e.client)return p;let t=e.selfUser?.id===this.identityId?e.selfUser:null;return tn({gatewayUrl:(this.target?.client??e.client).gatewayUrl,personLabel:t?this.personLabel||t.name||t.email||g(`profilePage.modelAccounts.currentPerson`):null,unavailableReason:t?ve(e.hello?.auth??null)?`profile`:`write`:`identity`,onConnectionSettings:()=>this.context.navigate(`connection`)},this.target?{links:this.links,accounts:this.accounts,hasMore:!!this.nextCursor,inventoryLoading:this.inventoryLoading,inventoryError:this.inventoryError,showManualLink:this.target.canAdmin,busy:this.inventoryLoading||this.action!==null,cancelBusy:this.action!==null&&this.action!==`answer`,error:this.error,notice:this.notice?g(`profilePage.modelAccounts.notices.${this.notice}`):null,statusUnavailable:this.statusUnavailable,linkDraft:this.linkDraft,signIn:this.signIn,connectFlow:this.connectFlow,stepValue:this.stepValue,onLinkDraftInput:e=>{this.linkDraft=e},onLink:()=>this.updateLink({authProfileId:this.linkDraft.trim()}),onUnlink:e=>this.updateLink({provider:e}),onSelectAccount:e=>this.selectAccount(e),onLoadMore:()=>void this.loadAccounts(this.nextCursor),onRefresh:()=>void this.loadAccounts(),onAddAccount:()=>this.openSignIn(),onProviderChange:e=>this.selectProvider(e),onMethodChange:e=>{this.signIn&&!this.action&&!this.connectFlow&&(this.signIn={...this.signIn,method:e})},onCloseSignIn:()=>{!this.action&&!this.connectFlow&&(this.signIn=null,this.error=null)},onConnectStart:()=>this.startConnect(),onStepValueChange:(e,t)=>{this.connectFlow?.step?.id===e&&(this.stepValue=t)},onStepAnswer:(e,t)=>this.answerStep(e,t),onConnectCancel:()=>this.connectStatus(`cancel`),onConnectCheck:()=>this.connectStatus(`status`)}:null)}},i([t({context:he,subscribe:!1})],Z.prototype,`context`,void 0),i([se({attribute:!1})],Z.prototype,`identityId`,void 0),i([se({attribute:!1})],Z.prototype,`profileId`,void 0),i([se({attribute:!1})],Z.prototype,`personLabel`,void 0),i([f()],Z.prototype,`links`,void 0),i([f()],Z.prototype,`accounts`,void 0),i([f()],Z.prototype,`nextCursor`,void 0),i([f()],Z.prototype,`inventoryLoading`,void 0),i([f()],Z.prototype,`inventoryError`,void 0),i([f()],Z.prototype,`action`,void 0),i([f()],Z.prototype,`error`,void 0),i([f()],Z.prototype,`notice`,void 0),i([f()],Z.prototype,`linkDraft`,void 0),i([f()],Z.prototype,`signIn`,void 0),i([f()],Z.prototype,`connectFlow`,void 0),i([f()],Z.prototype,`stepValue`,void 0),i([f()],Z.prototype,`statusUnavailable`,void 0),customElements.get(`openclaw-model-accounts`)||customElements.define(`openclaw-model-accounts`,Z)})))()}function an(e,t){return{id:e.id,name:e.displayName??void 0,email:e.emails[0],avatarUrl:t??void 0,watchedSessions:[]}}function on(e){let t=e.profile.displayName??``,n=e.displayName.trim()!==t,r=e.profile.emails.join(`, `),i=e.profile.githubIdentity,a=e.profile.id===Ct;return d`<div id=${I.identity}> ${P({title:g(`profilePage.identity.title`),description:g(`profilePage.identity.description`)},d` ${A({title:g(`profilePage.identity.avatar`),description:g(`profilePage.identity.avatarDescription`),control:d` <span class="identity-avatar-control"> <openclaw-viewer-avatar .user=${an(e.profile,e.avatarUrl)} variant="profile" ></openclaw-viewer-avatar> <button type="button" class="btn btn--sm" ?disabled=${e.busy!==null} @click=${e=>{let t=e.currentTarget,n=t instanceof HTMLButtonElement?t.nextElementSibling:null;n instanceof HTMLInputElement&&n.click()}} > ${e.busy===`avatar`?g(`profilePage.identity.processingAvatar`):g(`profilePage.identity.chooseAvatar`)} </button> <input type="file" accept="image/png,image/jpeg,image/webp" hidden ?disabled=${e.busy!==null} @change=${t=>{let n=t.currentTarget,r=n.files?.[0];n.value=``,r&&e.onAvatarSelect(r)}} /> </span> `})} ${A({title:g(`profilePage.identity.displayName`),description:g(`profilePage.identity.displayNameDescription`),control:d` <form class="identity-name-control" @submit=${t=>{t.preventDefault(),e.onSaveDisplayName()}} > <input class="settings-input" type="text" maxlength="256" aria-label=${g(`profilePage.identity.displayName`)} .value=${e.displayName} ?disabled=${e.busy!==null} @input=${t=>e.onDisplayNameInput(t.currentTarget.value)} /> <button type="submit" class="btn btn--sm" ?disabled=${e.busy!==null||!n} > ${e.busy===`display-name`?g(`common.saving`):g(`common.save`)} </button> </form> `})} ${a?p:A({title:g(`profilePage.identity.linkedEmails`),description:g(`profilePage.identity.linkedEmailsDescription`),control:r?F(r):p})} ${A({title:g(`profilePage.identity.githubAccount`),description:g(a?`profilePage.identity.ownerGithubDescription`:i?`profilePage.identity.githubAccountDescription`:`profilePage.identity.githubUnavailableDescription`),control:i?d` <a class="settings-account" href=${i.profileUrl} target=${Be} rel=${Re()} > <img class="settings-account__avatar" src=${i.avatarUrl} alt="" /> <span class="settings-row__value settings-row__value--mono" >@${i.login}</span > </a> ${M({kind:`ok`,label:g(`profilePage.identity.githubVerified`)})} `:M({kind:`muted`,label:g(`profilePage.identity.githubUnavailable`)})})} ${qe({title:g(`profilePage.identity.gitCoauthor`),description:g(a?`profilePage.identity.ownerGitCoauthorDescription`:i?`profilePage.identity.gitCoauthorDescription`:`profilePage.identity.gitCoauthorUnavailable`),checked:!!(i&&e.gitCoauthorEnabled),disabled:e.busy!==null||!i,onChange:e.onGitCoauthorChange})} ${e.error?d`<div class="settings-row identity-error" role="alert"> <span class="settings-row__desc">${e.error}</span> </div>`:p} `)} </div>`}function sn(){return(sn=e((()=>{u(),Pt(),j(),h(),Ve(),Fe(),nt()})))()}function cn(e,t,r,i=``,a){let o=a??globalThis.location?.href;if(!o)return null;try{let a=new URL(o),s=new URL(e,a);if(s.protocol===`ws:`?s.protocol=`http:`:s.protocol===`wss:`&&(s.protocol=`https:`),![`http:`,`https:`].includes(s.protocol))return null;s.username=``,s.password=``;let c=s.origin===a.origin?n(i):``;return new URL(Ze(t,r,c),s.origin).href}catch{return null}}function ln(){return(ln=e((()=>{r(),Xe()})))()}function un(e){let t=re(e.row,e.identity),n=ne(e.identity?.avatar)??ne(e.row.identity?.emoji)??ne(e.row.identity?.avatar),r=dn(e),i=t?.startsWith(`/`)?e.resolveImageUrl(t):t;return t&&t!==e.failedAvatarUrl&&i?d`<img class="profile-hero__avatar-image" src=${i} alt=${r} @error=${()=>e.onAvatarError(t)} />`:n?d`<span class="profile-hero__avatar-text">${n}</span>`:d`<span class="profile-hero__avatar-mascot" aria-hidden="true">${be.lobster}</span>`}function dn(e){return e.identity?.name?.trim()||e.row.identity?.name?.trim()||e.row.name?.trim()||e.agentId}function fn(e){return k(d` <section class="profile-hero"> <div class="profile-hero__avatar">${un(e)}</div> <div class="profile-hero__name">${dn(e)}</div> <div class="profile-hero__handle"> <span>@${e.agentId}</span> <span class="profile-hero__badge">OpenClaw</span> </div> </section> `)}function pn(){return(pn=e((()=>{u(),ye(),j(),te()})))()}function Q(e){return o(e,g(`profilePage.identity.profileUnavailable`))}var mn,$;function hn(){return(hn=e((()=>{a(),u(),oe(),Pt(),pe(),m(),le(),_e(),j(),it(),h(),O(),Je(),s(),c(),nt(),Ft(),Kt(),rn(),sn(),ln(),pn(),Ie(),mn=`https://docs.openclaw.ai/concepts/user-model`,$=class extends l{constructor(...e){super(...e),this.selfUser=null,this.ownProfile=null,this.displayName=``,this.gitCoauthorEnabled=!0,this.identityLoading=!1,this.identityBusy=null,this.identityError=null,this.failedHeroAvatarUrl=null,this.client=null,this.connected=!1,this.canWrite=!1,this.heroAvatarAuthCandidates=[],this.heroAvatarAuthReady=!1,this.heroAvatarLoader=new Ke(this),this.identityRequestId=0,this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.subscriptions=[this.context.gateway.subscribe(e=>this.applyGatewaySnapshot(e)),this.context.agents.subscribe(()=>this.requestUpdate()),this.context.agentIdentity.subscribe(()=>this.requestUpdate())],this.applyGatewaySnapshot(this.context.gateway.snapshot)}disconnectedCallback(){for(let e of this.subscriptions)e();this.subscriptions=[],this.identityRequestId+=1,this.heroAvatarAuthCandidates=[],this.heroAvatarAuthReady=!1,this.client=null,this.connected=!1,this.canWrite=!1,super.disconnectedCallback()}applyGatewaySnapshot(e){let t=de({hello:e.hello,settings:{token:this.context.gateway.connection.token},password:this.context.gateway.connection.password});t.join(`\0`)!==this.heroAvatarAuthCandidates.join(`\0`)&&(this.heroAvatarAuthCandidates=t),this.heroAvatarAuthReady=!!(e.hello||this.context.gateway.connection.token.trim()||this.context.gateway.connection.password.trim());let n=e.client!==this.client,r=e.phase===`connected`,i=r&&ve(e.hello?.auth??null),a=i!==this.canWrite,o=r!==this.connected,s=r?ue({snapshotUser:e.selfUser}):null,c=s?.id!==this.selfUser?.id,l=n||o||c||a;this.client=e.client,this.connected=r,this.canWrite=i,this.selfUser=s,this.requestUpdate(),l&&(this.identityRequestId+=1,this.ownProfile=null,this.displayName=``,this.gitCoauthorEnabled=!0,this.identityLoading=!1,this.identityBusy=null,this.identityError=null),!(!r||!e.client)&&(s&&i&&l&&this.loadIdentity(),this.context.agents.ensureList().then(e=>{e&&this.context.agentIdentity.ensure([e.defaultId])}))}async loadIdentity(){let e=this.client;if(!e||!this.connected||!this.canWrite||this.identityLoading)return;let t=++this.identityRequestId,n=this.ownProfile,r=this.displayName,i=n!==null&&r.trim()!==(n.displayName??``);this.identityLoading=!0,this.identityError=null;try{let n=await e.request(`users.self`,{});if(t!==this.identityRequestId)return;let a=n?.profile;if(!a)return;if(this.ownProfile=a,this.displayName=i?r:a.displayName??``,this.gitCoauthorEnabled=!0,a.githubIdentity){let n=await e.request(`users.prefs.get`,{keys:[R]});if(t!==this.identityRequestId)return;this.gitCoauthorEnabled=n.status===`ok`&&St(n.entries[`git.coauthor.enabled`])}}catch(e){t===this.identityRequestId&&(this.identityError=Q(e))}finally{t===this.identityRequestId&&(this.identityLoading=!1)}}applyOwnProfile(e){this.ownProfile=e,this.displayName=e.displayName??``}async saveDisplayName(){let e=this.client,t=this.ownProfile;if(!e||!t||!this.canWrite||this.identityBusy||this.identityLoading)return;this.identityBusy=`display-name`,this.identityError=null;let n=this.identityRequestId,r=!1;try{let i=this.displayName.trim()||null,a=await e.request(`users.setDisplayName`,{profileId:t.id,displayName:i});if(e!==this.client||n!==this.identityRequestId)return;this.applyOwnProfile(a.profile),this.context.gateway.updateSelfUser?.({name:a.profile.displayName??void 0}),r=!0}catch(t){e===this.client&&n===this.identityRequestId&&(this.identityError=Q(t))}finally{n===this.identityRequestId&&this.identityBusy===`display-name`&&(this.identityBusy=null)}r&&e===this.client&&n===this.identityRequestId&&this.loadIdentity()}async saveAvatar(e){let t=this.client,n=this.ownProfile;if(!t||!n||!this.canWrite||this.identityBusy||this.identityLoading)return;this.identityBusy=`avatar`,this.identityError=null;let r=this.identityRequestId,i=this.displayName,a=i.trim()!==(n.displayName??``),o=this.selfUser?.id===n.id?this.selfUser.avatarUrl:void 0,s=!1;try{let c=await Vt(e);if(t!==this.client||r!==this.identityRequestId)return;let l=await t.request(`users.setAvatar`,{profileId:n.id,mime:c.mime,avatarBase64:c.avatarBase64});if(t!==this.client||r!==this.identityRequestId)return;this.ownProfile=l.profile,this.displayName=a?i:l.profile.displayName??``;let ee=cn(this.context.gateway.connection.gatewayUrl,l.profile.id,l.avatarRevision,this.context.resourceBasePath),te=this.selfUser?.id===l.profile.id&&this.selfUser.avatarUrl!==o;ee&&!te&&this.context.gateway.updateSelfUser?.({avatarUrl:ee}),s=!0}catch(e){t===this.client&&r===this.identityRequestId&&(this.identityError=e instanceof X?g(e.code===`too-large`?`profilePage.identity.avatarErrors.tooLarge`:e.code===`source-too-large`?`profilePage.identity.avatarErrors.sourceTooLarge`:`profilePage.identity.avatarErrors.invalid`):Q(e))}finally{r===this.identityRequestId&&this.identityBusy===`avatar`&&(this.identityBusy=null)}s&&t===this.client&&r===this.identityRequestId&&this.loadIdentity()}async saveGitCoauthorPreference(e){let t=this.client,n=this.ownProfile;if(!t||!n?.githubIdentity||!this.canWrite||this.identityBusy||this.identityLoading)return;this.identityBusy=`git-coauthor`,this.identityError=null;let r=this.identityRequestId;try{let n=await t.request(`users.prefs.set`,{entries:{[R]:e}});if(t!==this.client||r!==this.identityRequestId)return;if(n.status!==`ok`)throw Error(g(`profilePage.identity.profileUnavailable`));this.gitCoauthorEnabled=e}catch(e){t===this.client&&r===this.identityRequestId&&(this.identityError=Q(e))}finally{r===this.identityRequestId&&this.identityBusy===`git-coauthor`&&(this.identityBusy=null)}}renderIdentity(){if(!this.selfUser)return d`<div id=${I.identity}> ${P({title:g(`profilePage.identity.title`)},N(g(`profilePage.identity.unidentified`)))} </div>`;if(!this.canWrite)return d`<div id=${I.identity}> ${P({title:g(`profilePage.identity.title`)},N(g(`profilePage.identity.writeRequired`)))} </div>`;if(!this.ownProfile){let e=this.identityError?this.identityError:d`<div class="profile-identity-empty"> <span>${g(`profilePage.identity.notSet`)}</span> <button type="button" class="btn btn--sm" @click=${()=>void this.loadIdentity()}> ${g(`profilePage.identity.setIdentity`)} </button> </div>`;return d`<div id=${I.identity}> ${P({title:g(`profilePage.identity.title`)},this.identityLoading?We({label:g(`profilePage.identity.loading`),rows:2}):N(e))} </div>`}let e=this.selfUser?.id===this.ownProfile.id&&this.selfUser.avatarUrl?this.selfUser.avatarUrl:cn(this.context.gateway.connection.gatewayUrl,this.ownProfile.id,this.ownProfile.updatedAt,this.context.resourceBasePath);return on({profile:this.ownProfile,avatarUrl:e,displayName:this.displayName,gitCoauthorEnabled:this.gitCoauthorEnabled,busy:this.identityLoading?`loading`:this.identityBusy,error:this.identityError,onDisplayNameInput:e=>{this.displayName=e},onSaveDisplayName:()=>void this.saveDisplayName(),onAvatarSelect:e=>void this.saveAvatar(e),onGitCoauthorChange:e=>void this.saveGitCoauthorPreference(e)})}renderModelAccounts(){return d`<openclaw-model-accounts .identityId=${this.selfUser?.id??null} .profileId=${this.ownProfile?.id??null} .personLabel=${this.ownProfile?this.ownProfile.displayName?.trim()||this.ownProfile.emails[0]||g(`profilePage.modelAccounts.currentPerson`):null} ></openclaw-model-accounts>`}refreshManually(){this.selfUser&&this.canWrite&&!this.identityBusy&&!this.identityLoading&&this.loadIdentity()}renderHero(){let e=this.context.agents.state.agentsList,t=e?.defaultId??`main`;return fn({agentId:t,row:e?.agents.find(e=>e.id===t)??{id:t},identity:this.context.agentIdentity.get(t),resolveImageUrl:e=>this.heroAvatarAuthReady?this.heroAvatarLoader.resolve(e,this.heroAvatarAuthCandidates):null,failedAvatarUrl:this.failedHeroAvatarUrl,onAvatarError:e=>{this.failedHeroAvatarUrl=e}})}renderBody(){return!this.connected||!this.client?Ue(k(N(g(`profilePage.offline`)))):Ue(d` ${this.renderHero()} ${this.renderIdentity()} ${this.renderModelAccounts()} <openclaw-github-connections></openclaw-github-connections> ${k(He({title:g(`profilePage.usageStatistics`),description:g(`profilePage.usageStatisticsDescription`),onClick:()=>this.context.navigate(`usage`)}))} `)}render(){return this.heroAvatarLoader.withActiveRoutes(()=>this.renderContent())}renderContent(){return d` <section class="content-header"> <div> <div class="page-title">${ge(`profile`)}</div> <div class="page-subtitle"> ${ce(`profile`)} ${Ye(mn)} </div> </div> ${this.selfUser?d`<button class="btn profile-refresh" ?disabled=${this.identityLoading||this.identityBusy!==null} @click=${()=>this.refreshManually()} > ${this.identityLoading?g(`common.refreshing`):g(`common.refresh`)} </button>`:p} </section> ${rt(this.renderBody())} `}},i([t({context:he,subscribe:!1})],$.prototype,`context`,void 0),i([f()],$.prototype,`selfUser`,void 0),i([f()],$.prototype,`ownProfile`,void 0),i([f()],$.prototype,`displayName`,void 0),i([f()],$.prototype,`gitCoauthorEnabled`,void 0),i([f()],$.prototype,`identityLoading`,void 0),i([f()],$.prototype,`identityBusy`,void 0),i([f()],$.prototype,`identityError`,void 0),i([f()],$.prototype,`failedHeroAvatarUrl`,void 0),customElements.get(`openclaw-profile-page`)||customElements.define(`openclaw-profile-page`,$)})))()}hn(); //# sourceMappingURL=profile-page-CjF-EkDM.js.map