@bodhiapp/bodhi-js-react-core 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ export type BodhiBadgeSize = 'sm' | 'md' | 'lg';
3
+ export type BodhiBadgeVariant = 'light' | 'dark';
4
+ export interface BodhiBadgeProps {
5
+ /** Size of the badge (sm=32px, md=48px, lg=64px). Default: 'md' */
6
+ size?: BodhiBadgeSize;
7
+ /** Visual variant for different backgrounds. Default: 'light' */
8
+ variant?: BodhiBadgeVariant;
9
+ /** Additional CSS classes for custom styling */
10
+ className?: string;
11
+ /** Inline styles for custom styling */
12
+ style?: React.CSSProperties;
13
+ }
14
+ /**
15
+ * BodhiBadge component - displays Bodhi App logo with link to getbodhi.app
16
+ */
17
+ export declare function BodhiBadge({ size, variant, className, style, }: BodhiBadgeProps): React.ReactElement;
@@ -17,7 +17,7 @@ export interface BodhiContext {
17
17
  setupState: SetupState;
18
18
  auth: AuthState;
19
19
  isAuthLoading: boolean;
20
- login: () => Promise<void>;
20
+ login: () => Promise<AuthState | void>;
21
21
  logout: () => Promise<void>;
22
22
  showSetup: () => Promise<void>;
23
23
  hideSetup: () => void;
@@ -31,5 +31,5 @@ export interface BodhiContext {
31
31
  isDirect: boolean;
32
32
  }
33
33
  export declare const BodhiReactContext: import('react').Context<BodhiContext | null>;
34
- export declare function BodhiProvider({ children, client, modalHtmlPath, handleCallback, callbackPath, basePath, logLevel, }: BodhiProviderProps): import("react/jsx-runtime").JSX.Element;
34
+ export declare function BodhiProvider({ children, client, modalHtmlPath, handleCallback, callbackPath: userCallbackPath, basePath, logLevel, }: BodhiProviderProps): import("react/jsx-runtime").JSX.Element;
35
35
  export declare function useBodhi(): BodhiContext;
@@ -4,6 +4,7 @@
4
4
  * Public API exports - minimal surface area following industry best practices
5
5
  */
6
6
  export { BodhiProvider, BodhiReactContext, useBodhi, type BodhiContext, type BodhiProviderProps, type SetupState, } from './BodhiProvider';
7
+ export { BodhiBadge, type BodhiBadgeProps, type BodhiBadgeSize, type BodhiBadgeVariant, } from './BodhiBadge';
7
8
  export type { ClientContextState, ClientContextStatus } from './client-ctx';
8
9
  export { INITIAL_CLIENT_CONTEXT_STATE, INITIALIZING_CLIENT_CONTEXT_STATE } from './client-ctx';
9
10
  export { ClientCtxState, clientStateToContextState, isClientCtxInitialized, isClientCtxInitializing, isClientCtxNotInitialized, isClientCtxReady, isOverallReady, } from './client-ctx';
@@ -0,0 +1,2 @@
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="vite-plugin-svgr/client" />
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),s=require("@bodhiapp/bodhi-js-core"),r=require("react"),p={MODAL_READY:"modal:ready",MODAL_REFRESH:"modal:refresh",MODAL_CLOSE:"modal:close",MODAL_COMPLETE:"modal:complete",MODAL_LNA_CONNECT:"modal:lna:connect",MODAL_LNA_SKIP:"modal:lna:skip",MODAL_CONFIRM_SERVER_INSTALL:"modal:confirm-server-install",MODAL_SELECT_CONNECTION:"modal:select-connection"};function H({client:e,modalHtmlPath:i,hideSetup:L,onSetupReady:_,setupState:R,basePath:m="/",logLevel:A="warn"}){const y=R!=="ready",O=r.useMemo(()=>new s.Logger("SetupModalProcessor",A),[A]),l=r.useRef(null),u=r.useMemo(()=>new s.BodhiClientUserPrefsManager(s.createStoragePrefixWithBasePath(m,"bodhijs:")),[m]),C=r.useRef(null),E=r.useCallback(t=>t==="direct"?"lna":t==="extension"?"extension":null,[]),v=r.useCallback(t=>t.extension==="ready"?{status:"ready",version:"unknown",id:t.extensionId}:t.extension==="not-found"?{status:"not-installed",error:{message:"Extension not found",code:"ext-not-installed"}}:{status:"unreachable",error:{message:"Client not initialized",code:"ext-connection-failed"}},[]),b=r.useCallback(t=>{if(t.server.status==="pending-extension-ready")return{status:"pending-extension-ready",error:{message:"Extension not ready",code:"server-pending-ext-ready"}};const n=t.server;switch(n.status){case"ready":return{status:"ready",version:n.version||"unknown"};case"setup":return{status:"setup",version:n.version||"unknown",error:{message:n.error?.message||"Setup required",code:"server-in-setup-status"}};case"resource-admin":return{status:"resource-admin",version:n.version||"unknown",error:{message:n.error?.message||"Resource admin required",code:"server-in-admin-status"}};case"error":return{status:"error",error:{message:n.error?.message||"Unknown error",code:"server-unexpected-error"}};case"not-reachable":return{status:"unreachable",error:{message:n.error?.message||"Server not reachable",code:"server-conn-refused"}};default:return{status:"unreachable",error:{message:"Unknown server status",code:"server-unexpected-error"}}}},[]),g=r.useCallback(t=>{if(t.server.status==="not-connected")return{status:"pending-lna-ready"};const n=t.server;switch(n.status){case"ready":return{status:"ready",version:n.version||"unknown"};case"setup":return{status:"setup",version:n.version||"unknown"};case"resource-admin":return{status:"resource-admin",version:n.version||"unknown"};case"error":case"not-reachable":return{status:"error",error:{message:n.error?.message||"Connection error"}};default:return{status:"error",error:{message:"Unknown server status"}}}},[]),I=r.useCallback((t,n)=>{if(t.server.status!=="pending-extension-ready"){const o=t.server.status;if(o==="ready"||o==="setup"||o==="resource-admin")return!0}if(n.server.status!=="not-connected"){const o=n.server.status;if(o==="ready"||o==="setup"||o==="resource-admin")return!0}return!1},[]),h=r.useCallback((t,n,o)=>{if(n==="skipped")return{status:"skipped",serverUrl:o};if(t.server.status!=="not-connected"){const d=t.server;return d.status==="ready"||d.status==="setup"||d.status==="resource-admin"?{status:"granted",serverUrl:o}:{status:"unreachable",serverUrl:o,error:{message:d.error?.message||"Server unreachable",code:"lna-unreachable"}}}return n==="granted"?{status:"granted",serverUrl:o}:{status:"prompt",serverUrl:o}},[]),S=r.useCallback(async(t=!1)=>{const n=s.detectBrowser().type,o=s.detectOS().type;let d=await e.getExtensionState();(d.extension==="not-initialized"||t)&&(d=await e.testExtensionConnectivity());let a=await e.getDirectState();const c=u.getDirectStatus();c==="granted"&&(a.server.status==="not-connected"||t)&&(a=await e.testDirectConnectivity());const w=s.getServerUrl(a)||"http://localhost:1135",x=h(a,c,w);return e.getConnectionMode()===null&&(s.isDirectServerReady(a)?await e.setConnectionMode("direct"):s.isExtensionServerReady(d)&&await e.setConnectionMode("extension")),u.isServerInstallConfirmed()||I(d,a)&&u.setServerInstallConfirmed(!0),{extension:v(d),server:b(d),lna:x,lnaServer:g(a),env:{browser:n,os:o},browsers:s.BROWSER_CONFIGS,os:s.OS_CONFIGS,userConfirmations:{serverInstall:u.isServerInstallConfirmed()},selectedConnection:E(e.getConnectionMode())}},[e,u,v,b,g,E,h,I]),f=r.useCallback(()=>{if(!C.current)throw new Error("Cannot get state: currentStateRef is null");return{...C.current,userConfirmations:{serverInstall:u.isServerInstallConfirmed()},selectedConnection:E(e.getConnectionMode())}},[u,e,E]),T=r.useMemo(()=>({[p.MODAL_READY]:async()=>(O.info("MODAL_READY: building initial state"),{setupState:f()}),[p.MODAL_REFRESH]:async()=>{O.info("MODAL_REFRESH: refreshing state");const t=await S(!0);C.current=t;const n=f();return O.info(`MODAL_REFRESH: state refreshed
2
- `,JSON.stringify(n,null,2)),l.current?.updateState(f()),{setupState:n}},[p.MODAL_LNA_CONNECT]:async t=>{const n=t.payload.serverUrl;console.log("[SetupModalProcessor] LNA connect:",n);const o=await e.testDirectConnectivity(n);if(o.server.status!=="not-connected"){const a=o.server.status;if(a==="ready"||a==="setup"||a==="resource-admin"){u.setDirectStatus("granted"),e.getConnectionMode()===null&&await e.setConnectionMode("direct");const c=await S();return C.current=c,l.current?.updateState(f()),{success:!0}}}const d=await S();return C.current=d,l.current?.updateState(f()),{success:!1}},[p.MODAL_LNA_SKIP]:async()=>{u.setDirectStatus("skipped");const t=await S();return C.current=t,l.current?.updateState(f()),{success:!0}},[p.MODAL_CLOSE]:()=>{L()},[p.MODAL_COMPLETE]:()=>{L()},[p.MODAL_CONFIRM_SERVER_INSTALL]:t=>(u.setServerInstallConfirmed(t.payload.confirmed),l.current?.updateState(f()),{success:!0}),[p.MODAL_SELECT_CONNECTION]:async t=>{const o=t.payload.connection==="lna"?"direct":"extension";return await e.setConnectionMode(o),l.current?.updateState(f()),{success:!0}}}),[O,e,u,S,f,g,L]);return r.useEffect(()=>(l.current=new s.OnboardingModal({modalHtmlPath:i,handlers:T}),()=>{l.current?.destroy(),l.current=null}),[i,T]),r.useEffect(()=>{y&&l.current?S(!0).then(t=>{C.current=t,l.current?.show(t),_?.()}).catch(t=>{console.error("[SetupModalProcessor] buildSetupState failed:",t)}):!y&&l.current&&l.current.destroy()},[y,S,_]),null}const P={status:"not-initialized",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null},z={status:"initializing",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null};function B(e){return e.status==="not-initialized"}function j(e){return e.status==="initializing"}function U(e){return e.status!=="not-initialized"&&e.status!=="initializing"}function D(e){return e.status==="ready"}function F(e){return D(e)&&e.server.status==="ready"}function G(e){return s.isExtensionState(e)?{status:e.extension==="not-initialized"?"initializing":e.extension==="not-found"?"extension-not-found":"ready",mode:"extension",extensionId:e.extensionId,url:null,server:e.server,error:e.server.error}:{status:e.url===null?"direct-not-connected":"ready",mode:"direct",extensionId:null,url:e.url,server:e.server,error:e.server.error}}const K={isNotInitialized:B,isInitializing:j,isInitialized:U,isReady:D,isOverallReady:F},N=r.createContext(null);N.displayName="BodhiContext";function V({children:e,client:i,modalHtmlPath:L,handleCallback:_=!0,callbackPath:R="/callback",basePath:m="/",logLevel:A="warn"}){const y=r.useMemo(()=>new s.Logger("BodhiProvider",A),[A]),O=r.useRef(!1),l=r.useRef(!1),[u,C]=r.useState(P),[E,v]=r.useState(s.INITIAL_AUTH_STATE),[b,g]=r.useState(!1),[I,h]=r.useState("ready");r.useEffect(()=>{const a=c=>{switch(c.type){case"client-state":C(G(c.state));break;case"auth-state":v(c.state),g(!1);break}};return i.setStateCallback(a),()=>{i.setStateCallback(s.NOOP_STATE_CALLBACK)}},[i]);const S=r.useCallback(async()=>{h("loading")},[]),f=r.useCallback(()=>{h("ready")},[]),T=r.useCallback(()=>{h("loaded")},[]),t=r.useCallback(async a=>{C(z);try{await i.init(a||{})}catch(c){y.error("Init failed:",c)}},[i,y]);r.useEffect(()=>{if(l.current)return;l.current=!0,(async()=>{if(await t(),!_)return;const c=new URL(window.location.href);if(c.pathname!==R)return;const M=c.searchParams.get("code"),w=c.searchParams.get("state");!M||!w||O.current||(O.current=!0,s.isWebUIClient(i)&&(g(!0),i.handleOAuthCallback(M,w).then(()=>{window.history.replaceState({},"",m)}).catch(x=>{y.error("OAuth callback failed:",x),v({status:"error",user:null,accessToken:null,error:{message:x instanceof Error?x.message:"OAuth callback failed",code:"OAUTH_CALLBACK_FAILED"}}),g(!1),window.history.replaceState({},"",m)})))})()},[t,i,_,R,m]);const n=r.useCallback(async()=>{g(!0);try{await i.login()}catch(a){v({status:"error",user:null,accessToken:null,error:{message:a instanceof Error?a.message:"Login failed",code:"LOGIN_FAILED"}}),g(!1)}},[i]),o=r.useCallback(async()=>{try{await i.logout()}catch(a){v({status:"error",user:null,accessToken:null,error:{message:a instanceof Error?a.message:"Logout failed",code:"LOGOUT_FAILED"}})}},[i]),d=r.useMemo(()=>{const a=u.status==="ready",c=u.server.status==="ready";return{client:i,clientState:u,auth:E,isAuthLoading:b,login:n,logout:o,showSetup:S,hideSetup:f,setupState:I,isAuthenticated:E.status==="authenticated",canLogin:a&&!b,isReady:a,isServerReady:c,isOverallReady:a&&c,isInitializing:u.status==="initializing",isExtension:u.mode==="extension",isDirect:u.mode==="direct"}},[i,u,E,b,I,n,o,S,f]);return k.jsxs(N.Provider,{value:d,children:[k.jsx(H,{client:i,modalHtmlPath:L,hideSetup:f,onSetupReady:T,setupState:I,basePath:m,logLevel:A}),e]})}function W(){const e=r.useContext(N);if(!e)throw new Error("useBodhi must be used within BodhiProvider");return e}const q="production";Object.defineProperty(exports,"createApiError",{enumerable:!0,get:()=>s.createApiError});Object.defineProperty(exports,"createOperationError",{enumerable:!0,get:()=>s.createOperationError});Object.defineProperty(exports,"isApiResultError",{enumerable:!0,get:()=>s.isApiResultError});Object.defineProperty(exports,"isApiResultOperationError",{enumerable:!0,get:()=>s.isApiResultOperationError});Object.defineProperty(exports,"isApiResultSuccess",{enumerable:!0,get:()=>s.isApiResultSuccess});Object.defineProperty(exports,"isAuthError",{enumerable:!0,get:()=>s.isAuthError});Object.defineProperty(exports,"isAuthLoading",{enumerable:!0,get:()=>s.isAuthLoading});Object.defineProperty(exports,"isAuthenticated",{enumerable:!0,get:()=>s.isAuthenticated});Object.defineProperty(exports,"isClientReady",{enumerable:!0,get:()=>s.isClientReady});Object.defineProperty(exports,"isDirectState",{enumerable:!0,get:()=>s.isDirectState});Object.defineProperty(exports,"isExtensionState",{enumerable:!0,get:()=>s.isExtensionState});Object.defineProperty(exports,"isOperationError",{enumerable:!0,get:()=>s.isOperationError});Object.defineProperty(exports,"isWebUIClient",{enumerable:!0,get:()=>s.isWebUIClient});exports.BodhiProvider=V;exports.BodhiReactContext=N;exports.ClientCtxState=K;exports.INITIALIZING_CLIENT_CONTEXT_STATE=z;exports.INITIAL_CLIENT_CONTEXT_STATE=P;exports.REACT_CORE_BUILD_MODE=q;exports.clientStateToContextState=G;exports.isClientCtxInitialized=U;exports.isClientCtxInitializing=j;exports.isClientCtxNotInitialized=B;exports.isClientCtxReady=D;exports.isOverallReady=F;exports.useBodhi=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),s=require("@bodhiapp/bodhi-js-core"),r=require("react");function W(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const g in e)if(g!=="default"){const h=Object.getOwnPropertyDescriptor(e,g);Object.defineProperty(a,g,h.get?h:{enumerable:!0,get:()=>e[g]})}}return a.default=e,Object.freeze(a)}const o=W(r),A={MODAL_READY:"modal:ready",MODAL_REFRESH:"modal:refresh",MODAL_CLOSE:"modal:close",MODAL_COMPLETE:"modal:complete",MODAL_LNA_CONNECT:"modal:lna:connect",MODAL_LNA_SKIP:"modal:lna:skip",MODAL_CONFIRM_SERVER_INSTALL:"modal:confirm-server-install",MODAL_SELECT_CONNECTION:"modal:select-connection"};function q({client:e,modalHtmlPath:a,hideSetup:g,onSetupReady:h,setupState:I,basePath:E="/",logLevel:m="warn"}){const L=I!=="ready",x=r.useMemo(()=>new s.Logger("SetupModalProcessor",m),[m]),i=r.useRef(null),f=r.useMemo(()=>new s.BodhiClientUserPrefsManager(s.createStoragePrefixWithBasePath(E,"bodhijs:")),[E]),y=r.useRef(null),S=r.useCallback(t=>t==="direct"?"lna":t==="extension"?"extension":null,[]),R=r.useCallback(t=>t.extension==="ready"?{status:"ready",version:"unknown",id:t.extensionId}:t.extension==="not-found"?{status:"not-installed",error:{message:"Extension not found",code:"ext-not-installed"}}:{status:"unreachable",error:{message:"Client not initialized",code:"ext-connection-failed"}},[]),M=r.useCallback(t=>{if(t.server.status==="pending-extension-ready")return{status:"pending-extension-ready",error:{message:"Extension not ready",code:"server-pending-ext-ready"}};const n=t.server;switch(n.status){case"ready":return{status:"ready",version:n.version||"unknown"};case"setup":return{status:"setup",version:n.version||"unknown",error:{message:n.error?.message||"Setup required",code:"server-in-setup-status"}};case"resource-admin":return{status:"resource-admin",version:n.version||"unknown",error:{message:n.error?.message||"Resource admin required",code:"server-in-admin-status"}};case"error":return{status:"error",error:{message:n.error?.message||"Unknown error",code:"server-unexpected-error"}};case"not-reachable":return{status:"unreachable",error:{message:n.error?.message||"Server not reachable",code:"server-conn-refused"}};default:return{status:"unreachable",error:{message:"Unknown server status",code:"server-unexpected-error"}}}},[]),v=r.useCallback(t=>{if(t.server.status==="not-connected")return{status:"pending-lna-ready"};const n=t.server;switch(n.status){case"ready":return{status:"ready",version:n.version||"unknown"};case"setup":return{status:"setup",version:n.version||"unknown"};case"resource-admin":return{status:"resource-admin",version:n.version||"unknown"};case"error":case"not-reachable":return{status:"error",error:{message:n.error?.message||"Connection error"}};default:return{status:"error",error:{message:"Unknown server status"}}}},[]),_=r.useCallback((t,n)=>{if(t.server.status!=="pending-extension-ready"){const c=t.server.status;if(c==="ready"||c==="setup"||c==="resource-admin")return!0}if(n.server.status!=="not-connected"){const c=n.server.status;if(c==="ready"||c==="setup"||c==="resource-admin")return!0}return!1},[]),O=r.useCallback((t,n,c)=>{if(n==="skipped")return{status:"skipped",serverUrl:c};if(t.server.status!=="not-connected"){const l=t.server;return l.status==="ready"||l.status==="setup"||l.status==="resource-admin"?{status:"granted",serverUrl:c}:{status:"unreachable",serverUrl:c,error:{message:l.error?.message||"Server unreachable",code:"lna-unreachable"}}}return n==="granted"?{status:"granted",serverUrl:c}:{status:"prompt",serverUrl:c}},[]),b=r.useCallback(async(t=!1)=>{const n=s.detectBrowser().type,c=s.detectOS().type;let l=await e.getExtensionState();(l.extension==="not-initialized"||t)&&(l=await e.testExtensionConnectivity());let C=await e.getDirectState();const w=f.getDirectStatus();w==="granted"&&(C.server.status==="not-connected"||t)&&(C=await e.testDirectConnectivity());const u=s.getServerUrl(C)||"http://localhost:1135",N=O(C,w,u);return e.getConnectionMode()===null&&(s.isDirectServerReady(C)?await e.setConnectionMode("direct"):s.isExtensionServerReady(l)&&await e.setConnectionMode("extension")),f.isServerInstallConfirmed()||_(l,C)&&f.setServerInstallConfirmed(!0),{extension:R(l),server:M(l),lna:N,lnaServer:v(C),env:{browser:n,os:c},browsers:s.BROWSER_CONFIGS,os:s.OS_CONFIGS,userConfirmations:{serverInstall:f.isServerInstallConfirmed()},selectedConnection:S(e.getConnectionMode())}},[e,f,R,M,v,S,O,_]),p=r.useCallback(()=>{if(!y.current)throw new Error("Cannot get state: currentStateRef is null");return{...y.current,userConfirmations:{serverInstall:f.isServerInstallConfirmed()},selectedConnection:S(e.getConnectionMode())}},[f,e,S]),T=r.useMemo(()=>({[A.MODAL_READY]:async()=>(x.info("MODAL_READY: building initial state"),{setupState:p()}),[A.MODAL_REFRESH]:async()=>{x.info("MODAL_REFRESH: refreshing state");const t=await b(!0);y.current=t;const n=p();return x.info(`MODAL_REFRESH: state refreshed
2
+ `,JSON.stringify(n,null,2)),i.current?.updateState(p()),{setupState:n}},[A.MODAL_LNA_CONNECT]:async t=>{const n=t.payload.serverUrl;console.log("[SetupModalProcessor] LNA connect:",n);const c=await e.testDirectConnectivity(n);if(c.server.status!=="not-connected"){const C=c.server.status;if(C==="ready"||C==="setup"||C==="resource-admin"){f.setDirectStatus("granted"),e.getConnectionMode()===null&&await e.setConnectionMode("direct");const w=await b();return y.current=w,i.current?.updateState(p()),{success:!0}}}const l=await b();return y.current=l,i.current?.updateState(p()),{success:!1}},[A.MODAL_LNA_SKIP]:async()=>{f.setDirectStatus("skipped");const t=await b();return y.current=t,i.current?.updateState(p()),{success:!0}},[A.MODAL_CLOSE]:()=>{g()},[A.MODAL_COMPLETE]:()=>{g()},[A.MODAL_CONFIRM_SERVER_INSTALL]:t=>(f.setServerInstallConfirmed(t.payload.confirmed),i.current?.updateState(p()),{success:!0}),[A.MODAL_SELECT_CONNECTION]:async t=>{const c=t.payload.connection==="lna"?"direct":"extension";return await e.setConnectionMode(c),i.current?.updateState(p()),{success:!0}}}),[x,e,f,b,p,v,g]);return r.useEffect(()=>(i.current=new s.OnboardingModal({modalHtmlPath:a,handlers:T}),()=>{i.current?.destroy(),i.current=null}),[a,T]),r.useEffect(()=>{L&&i.current?b(!0).then(t=>{y.current=t,i.current?.show(t),h?.()}).catch(t=>{console.error("[SetupModalProcessor] buildSetupState failed:",t)}):!L&&i.current&&i.current.destroy()},[L,b,h]),null}const j={status:"not-initialized",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null},U={status:"initializing",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null};function F(e){return e.status==="not-initialized"}function G(e){return e.status==="initializing"}function H(e){return e.status!=="not-initialized"&&e.status!=="initializing"}function P(e){return e.status==="ready"}function V(e){return P(e)&&e.server.status==="ready"}function K(e){return s.isExtensionState(e)?{status:e.extension==="not-initialized"?"initializing":e.extension==="not-found"?"extension-not-found":"ready",mode:"extension",extensionId:e.extensionId,url:null,server:e.server,error:e.server.error}:{status:e.url===null?"direct-not-connected":"ready",mode:"direct",extensionId:null,url:e.url,server:e.server,error:e.server.error}}const X={isNotInitialized:F,isInitializing:G,isInitialized:H,isReady:P,isOverallReady:V},D=r.createContext(null);D.displayName="BodhiContext";function Y({children:e,client:a,modalHtmlPath:g,handleCallback:h=!0,callbackPath:I,basePath:E="/",logLevel:m="warn"}){const L=E==="/"?"":E.replace(/\/$/,""),x=I??`${L}/callback`,i=r.useMemo(()=>new s.Logger("BodhiProvider",m),[m]),f=r.useRef(!1),y=r.useRef(!1),[S,R]=r.useState(j),[M,v]=r.useState(s.INITIAL_AUTH_STATE),[_,O]=r.useState(!1),[b,p]=r.useState("ready");r.useEffect(()=>{const d=u=>{switch(u.type){case"client-state":R(K(u.state));break;case"auth-state":v(u.state),O(!1);break}};return a.setStateCallback(d),()=>{a.setStateCallback(s.NOOP_STATE_CALLBACK)}},[a]);const T=r.useCallback(async()=>{p("loading")},[]),t=r.useCallback(()=>{p("ready")},[]),n=r.useCallback(()=>{p("loaded")},[]),c=r.useCallback(async d=>{R(U);try{await a.init(d||{})}catch(u){i.error("Init failed:",u)}},[a,i]);r.useEffect(()=>{if(y.current)return;y.current=!0,(async()=>{if(await c(),!h)return;const u=new URL(window.location.href);if(u.pathname!==x)return;const N=u.searchParams.get("code"),B=u.searchParams.get("state");!N||!B||f.current||(f.current=!0,s.isWebUIClient(a)&&(O(!0),a.handleOAuthCallback(N,B).then(()=>{window.history.replaceState({},"",E)}).catch(z=>{i.error("OAuth callback failed:",z),v({status:"error",user:null,accessToken:null,error:{message:z instanceof Error?z.message:"OAuth callback failed",code:"OAUTH_CALLBACK_FAILED"}}),O(!1),window.history.replaceState({},"",E)})))})()},[c,a,h,x,E]);const l=r.useCallback(async()=>{O(!0);try{await a.login()}catch(d){const u={status:"error",user:null,accessToken:null,error:{message:d instanceof Error?d.message:"Login failed",code:"LOGIN_FAILED"}};return v(u),O(!1),u}},[a]),C=r.useCallback(async()=>{try{await a.logout()}catch(d){v({status:"error",user:null,accessToken:null,error:{message:d instanceof Error?d.message:"Logout failed",code:"LOGOUT_FAILED"}})}},[a]),w=r.useMemo(()=>{const d=S.status==="ready",u=S.server.status==="ready";return{client:a,clientState:S,auth:M,isAuthLoading:_,login:l,logout:C,showSetup:T,hideSetup:t,setupState:b,isAuthenticated:M.status==="authenticated",canLogin:d&&!_,isReady:d,isServerReady:u,isOverallReady:d&&u,isInitializing:S.status==="initializing",isExtension:S.mode==="extension",isDirect:S.mode==="direct"}},[a,S,M,_,b,l,C,T,t]);return k.jsxs(D.Provider,{value:w,children:[k.jsx(q,{client:a,modalHtmlPath:g,hideSetup:t,onSetupReady:n,setupState:b,basePath:E,logLevel:m}),e]})}function Z(){const e=r.useContext(D);if(!e)throw new Error("useBodhi must be used within BodhiProvider");return e}const J=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 479.995 479.995",width:"480px",height:"480px",...e},o.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.56l-0.01-0.01c0-0.01,0.01-0.01,0.01-0.02c-4.64-8.78-65.7-144.8-212.22-85.2 c-14.36,5.85-19.78,23.45-11.19,36.36c11.11,16.69,22.86,30.01,34.91,40.53c-27.85,7.89-45.6,33.8-43.3,61.55 c0.96,11.6,13.29,18.52,23.71,13.35c33.99-16.84,60.03-2.51,80.35,2.14c56.68,12.99,113.71,4.53,125.52-46.29 c0.52-2.22,0.95-4.51,1.28-6.89c0.01-0.04,0.01-0.08,0.02-0.12c0.066-0.492,0.126-0.978,0.181-1.458 c0.455-3.631,0.712-7.438,0.739-11.452c-0.02-1.44-0.02-2.01,0-2.25v-0.09c0-0.02,0-0.04,0.01-0.05c0-0.02,0.01-0.03,0.02-0.06 c0-0.01,0.01-0.01,0.01-0.02C240.018,374.569,240.008,374.56,239.998,374.56z"}),o.createElement("path",{fill:"#ffa4b8",d:"M471.798,427.769c-0.96,11.6-13.29,18.52-23.71,13.35c-33.99-16.84-60.03-2.51-80.35,2.14 c-63.41,14.53-127.25,2.22-127.74-66.21c0.033-2.642-0.044-2.302,0.04-2.47c-0.02-0.01-0.03-0.02-0.04-0.02l0.01-0.01 c0-0.01-0.01-0.01-0.01-0.02c4.64-8.78,65.7-144.8,212.22-85.2c14.36,5.85,19.78,23.45,11.19,36.36 c-11.11,16.69-22.86,30.01-34.91,40.53C456.348,374.109,474.098,400.019,471.798,427.769z"}),o.createElement("path",{fill:"#befa91",d:"M428.498,366.219c27.85,7.89,45.6,33.8,43.3,61.55c-0.96,11.6-13.29,18.52-23.71,13.35 c-33.99-16.84-60.03-2.51-80.35,2.14c-63.41,14.53-127.928,2.222-127.74-66.21c0.007-2.683-0.02-2.351,0.04-2.47 C248.598,379.129,345.858,438.329,428.498,366.219z"}),o.createElement("path",{fill:"#befa91",d:"M51.498,366.219c82.76,72.22,180.18,12.74,188.5,8.34c0.01,0,0.02,0.01,0.04,0.02 c-0.058,0.116-0.047-0.169-0.04,2.47c0.188,68.432-64.33,80.74-127.74,66.21c-20.32-4.65-46.36-18.98-80.35-2.14 c-10.42,5.17-22.75-1.75-23.71-13.35C5.898,400.019,23.648,374.109,51.498,366.219z"}),o.createElement("path",{fill:"#ffbfcb",d:"M235.228,365.299c-32.29-36.09-89.98-73-179.74-36.49c-1.979,0.805-3.787,1.834-5.413,3.042 c-10.569,7.856-25.473,5.765-32.82-5.164c-0.223-0.331-0.445-0.664-0.667-0.997c-8.59-12.91-3.17-30.51,11.19-36.36 C155.168,237.509,217.948,333.56,235.228,365.299z"}),o.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.549c-12.85-2.2-214.54-23.33-193.03-240.71c1.49-14.99,15.86-25.15,30.48-21.55 c108.49,26.72,149.07,91.39,162.55,149.92C252.768,317.699,241.178,367.679,239.998,374.549z"}),o.createElement("path",{fill:"#ffbfcb",d:"M193.698,174.638c11.866,12.406-3.013,31.792-18.056,23.52 c-21.875-12.028-50.044-10.573-70.207,3.701c-24.832,17.579-59.398-0.365-60.013-30.784c-0.237-11.724,0.248-24.123,1.545-37.237 c1.49-14.99,15.86-25.15,30.48-21.55C131.23,125.537,168.324,148.11,193.698,174.638z"}),o.createElement("path",{fill:"#ffa4b8",d:"M221.538,39.599c9.78-11.13,27.15-11.12,36.93,0.01c157.02,178.77-7.48,323.95-18.47,334.94 C229.988,364.549,63.948,218.989,221.538,39.599z"}),o.createElement("path",{fill:"#ffbfcb",d:"M261.523,43.131c9.452,11.033,8.166,27.623-2.74,37.221c-0.784,0.69-1.535,1.439-2.245,2.247 c-35.942,40.915-55.05,80.07-63.012,116.258c-5.176,23.523-39.936,19.717-39.551-4.366c0.741-46.282,18.411-98.941,67.563-154.892 c9.78-11.13,27.15-11.12,36.93,0.01C259.5,40.785,260.518,41.959,261.523,43.131z"}),o.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.549c-1.18-6.87-12.77-56.85,0-112.34c13.48-58.53,54.06-123.2,162.55-149.92 c14.62-3.6,28.99,6.56,30.48,21.55C454.538,351.219,252.848,372.349,239.998,374.549z"}),o.createElement("path",{fill:"#ff8ca5",d:"M239.998,374.549c-3.115-0.536-17.362-2.183-36.835-7.483c-3.181-0.866-6.028-2.682-8.145-5.209 c-49.098-58.608-75.675-130.75-61.047-205.793c2.165-11.107,14.881-16.444,24.408-10.337c0.756,0.485,1.506,0.972,2.249,1.462 C126.798,274.139,232.088,366.649,239.998,374.549z"}),o.createElement("path",{fill:"#ff8ca5",d:"M281.608,365.729c-21.9,6.37-38.24,8.25-41.61,8.82c8.67-8.67,112.98-100.94,79.35-227.34v-0.01 c0.742-0.489,1.49-0.975,2.244-1.459c9.551-6.123,22.265-0.733,24.422,10.406C369.565,277.734,281.608,363.204,281.608,365.729z"}),o.createElement("path",{fill:"#ff8ca5",d:"M417.451,302.932c-32.211,44.193-80.706,72.823-134.571,87.345c-3.396,0.916-6.999,0.754-10.3-0.463 c-20.772-7.664-31.911-15.254-32.583-15.254c0.826-0.825,112.667-9.463,166.4-98.31C419.37,278.279,424.743,292.927,417.451,302.932 z"}),o.createElement("path",{fill:"#ff8ca5",d:"M62.565,302.932c32.211,44.193,80.705,72.823,134.571,87.345c3.396,0.916,6.999,0.754,10.3-0.463 c20.772-7.664,31.911-15.254,32.583-15.254c-0.828-0.828-112.665-9.458-166.4-98.31C60.646,278.279,55.273,292.927,62.565,302.932z"}),o.createElement("path",{fill:"#9ceb63",d:"M433.464,393.091c-52.749,39.415-118.979,42.09-182.861,13.657 c-4.441-1.977-7.606-6.011-8.633-10.763c-1.552-7.18-1.884-14.238-1.973-21.326c0.172-0.345,9.566,5.934,26.76,12.89 c36.31,14.71,102.75,30.15,161.74-21.33C440.977,369.752,443.403,385.664,433.464,393.091z"}),o.createElement("path",{fill:"#9ceb63",d:"M240.038,374.579c0,0.01-0.01,0.01-0.01,0.02s-0.01,0.03-0.01,0.05c0,0,0,0,0,0.01 c-0.01,0.03-0.01,0.06-0.02,0.1v0.04c-0.13,1.3,0.09,7.59-0.92,15.16c-0.01,0.04-0.01,0.08-0.02,0.12 c-0.26,1.91-0.59,3.91-1.03,5.92c-0.07,0.33-0.15,0.65-0.25,0.97c-1.23,4.33-4.28,7.95-8.41,9.79 c-63.06,28.05-129.47,26.21-182.79-13.63c-9.94-7.43-7.63-23.36,4.92-26.91c13.1,11.46,28.11,20.79,44.16,26.79 c19.78,7.48,34.99,8.98,53.83,8.68c34.33-0.55,60.1-11.03,90.51-27.13C240.008,374.56,240.018,374.569,240.038,374.579z"}),o.createElement("path",{d:"M443.143,363.426c9.579-9.648,18.604-20.804,26.926-33.305c11.399-17.132,4.201-40.447-14.837-48.202 c-12.321-5.012-24.515-8.844-36.391-11.454c17.945-34.197,27.974-78.94,22.188-137.413c-1.925-19.503-20.802-33.354-40.394-28.53 c-17.952,4.421-34.806,10.063-50.093,16.768c-4.046,1.775-5.888,6.494-4.113,10.54c1.774,4.046,6.493,5.887,10.54,4.113 c14.45-6.338,30.429-11.682,47.492-15.885c9.885-2.435,19.599,4.434,20.607,14.573c9.088,90.121-21.147,164.341-99.823,205.213 c-3.921,2.037-5.448,6.866-3.411,10.787c2.043,3.933,6.879,5.442,10.787,3.411c27.191-14.125,56.267-35.849,77.701-68.994 c12.564,2.375,25.617,6.296,38.878,11.69c9.68,3.943,13.334,15.824,7.549,24.518c-10.205,15.33-21.482,28.43-33.516,38.936 c-49.396,43.107-111.979,41.39-169.834,12.419c56.638-56.971,92.247-132.34,77.074-212.524 c-8.101-42.81-30.305-85.119-65.997-125.754c-12.964-14.759-36.003-14.748-48.946-0.016 c-28.645,32.607-48.657,66.371-59.602,100.512c-21.999-13.018-47.7-23.197-76.569-30.307c-19.338-4.763-38.383,8.699-40.354,28.53 C26.197,262.501,90.89,324.677,147.416,354.042c3.92,2.036,8.75,0.51,10.787-3.411c2.037-3.921,0.51-8.75-3.411-10.787 c-52.141-27.086-111.791-84.677-99.863-205.213c1.007-10.132,10.713-17.01,20.606-14.574c31.115,7.663,58.223,19.013,80.571,33.735 c4.863,3.204,10.891,0.586,12.257-4.539c9.392-35.245,29.306-70.362,59.188-104.378c6.581-7.492,18.316-7.487,24.904,0.014 c128.735,146.565,37.449,269.122-12.476,318.519c-30.274-29.828-76.759-87.727-78.002-162.831 c-0.073-4.417-3.698-7.933-8.131-7.867c-4.417,0.073-7.939,3.714-7.867,8.131c1.382,83.483,54.096,146.516,85.999,177.099 c-0.353,20.737-7.099,36.575-20.104,47.086c-20.129,16.267-55.786,20.072-97.831,10.438c-19.181-4.396-48.632-19.874-85.688-1.511 c-5.361,2.657-11.689-0.859-12.186-6.844c-1.888-22.74,12.042-43.926,33.548-51.893c13.4,11.096,27.797,19.551,43.11,25.275 c20.238,7.653,36.036,9.525,56.788,9.196c15.85-0.254,30.814-2.572,45.747-7.085c4.229-1.278,6.622-5.743,5.343-9.972 c-1.278-4.229-5.744-6.622-9.972-5.344c-13.494,4.078-27.027,6.173-41.373,6.403c-17.347,0.275-31.911-0.993-50.901-8.174 c-31.69-11.847-56.387-35.98-75.211-64.258c-5.791-8.704-2.122-20.58,7.548-24.52c4.092-1.667,6.058-6.335,4.391-10.427 c-1.667-4.092-6.334-6.058-10.427-4.391c-19.062,7.765-26.214,31.095-14.832,48.202c8.365,12.566,17.352,23.674,26.917,33.31 C12.89,375.664-2.037,401.187,0.226,428.434c1.427,17.192,19.743,27.533,35.235,19.857c30.84-15.283,54.311-1.971,75.01,2.771 c36.708,8.411,82.166,10.086,111.461-13.59c14.777-11.943,23.305-28.715,25.489-49.937 c61.607,30.736,128.694,32.482,182.835-12.326c21.516,7.959,35.456,29.153,33.567,51.902c-0.493,5.939-6.786,9.519-12.186,6.844 c-30.339-15.034-55.535-7.379-73.932-1.791c-31.306,9.51-74.736,14.144-102.884-2.498c-3.803-2.248-8.709-0.989-10.958,2.815 c-2.249,3.803-0.989,8.709,2.815,10.958c29.214,17.272,69.817,15.19,102.844,7.622c20.72-4.747,44.177-18.05,75.01-2.771 c15.523,7.691,33.811-2.693,35.235-19.856C482.032,401.183,467.102,375.655,443.143,363.426z"})),$={sm:32,md:48,lg:64};function Q({size:e="md",variant:a="light",className:g="",style:h={}}){const I=$[e],E={display:"inline-block",cursor:"pointer",transition:"all 250ms ease",borderRadius:"50%",...a==="dark"&&{backgroundColor:"rgba(255, 255, 255, 0.05)",padding:"8px"},...h};return k.jsx("a",{href:"https://getbodhi.app",target:"_blank",rel:"noopener noreferrer",title:"Powered by Bodhi","aria-label":"Powered by Bodhi - Visit getbodhi.app",className:g,style:E,onMouseEnter:m=>{m.currentTarget.style.transform="scale(1.1)",m.currentTarget.style.boxShadow="0 0 20px rgba(255, 164, 184, 0.6)"},onMouseLeave:m=>{m.currentTarget.style.transform="scale(1)",m.currentTarget.style.boxShadow="none"},children:k.jsx(J,{width:I,height:I,style:{display:"block"}})})}const ee="production";Object.defineProperty(exports,"createApiError",{enumerable:!0,get:()=>s.createApiError});Object.defineProperty(exports,"createOperationError",{enumerable:!0,get:()=>s.createOperationError});Object.defineProperty(exports,"isApiResultError",{enumerable:!0,get:()=>s.isApiResultError});Object.defineProperty(exports,"isApiResultOperationError",{enumerable:!0,get:()=>s.isApiResultOperationError});Object.defineProperty(exports,"isApiResultSuccess",{enumerable:!0,get:()=>s.isApiResultSuccess});Object.defineProperty(exports,"isAuthError",{enumerable:!0,get:()=>s.isAuthError});Object.defineProperty(exports,"isAuthLoading",{enumerable:!0,get:()=>s.isAuthLoading});Object.defineProperty(exports,"isAuthenticated",{enumerable:!0,get:()=>s.isAuthenticated});Object.defineProperty(exports,"isClientReady",{enumerable:!0,get:()=>s.isClientReady});Object.defineProperty(exports,"isDirectState",{enumerable:!0,get:()=>s.isDirectState});Object.defineProperty(exports,"isExtensionState",{enumerable:!0,get:()=>s.isExtensionState});Object.defineProperty(exports,"isOperationError",{enumerable:!0,get:()=>s.isOperationError});Object.defineProperty(exports,"isWebUIClient",{enumerable:!0,get:()=>s.isWebUIClient});exports.BodhiBadge=Q;exports.BodhiProvider=Y;exports.BodhiReactContext=D;exports.ClientCtxState=X;exports.INITIALIZING_CLIENT_CONTEXT_STATE=U;exports.INITIAL_CLIENT_CONTEXT_STATE=j;exports.REACT_CORE_BUILD_MODE=ee;exports.clientStateToContextState=K;exports.isClientCtxInitialized=H;exports.isClientCtxInitializing=G;exports.isClientCtxNotInitialized=F;exports.isClientCtxReady=P;exports.isOverallReady=V;exports.useBodhi=Z;
@@ -1,8 +1,9 @@
1
- import { jsxs as F, jsx as H } from "react/jsx-runtime";
2
- import { Logger as B, BodhiClientUserPrefsManager as G, createStoragePrefixWithBasePath as K, detectBrowser as V, detectOS as W, getServerUrl as j, isDirectServerReady as Y, isExtensionServerReady as q, OS_CONFIGS as X, BROWSER_CONFIGS as J, OnboardingModal as Z, BACKEND_SERVER_NOT_CONNECTED as P, isExtensionState as Q, INITIAL_AUTH_STATE as $, NOOP_STATE_CALLBACK as ee, isWebUIClient as te } from "@bodhiapp/bodhi-js-core";
3
- import { createApiError as Ae, createOperationError as Oe, isApiResultError as Le, isApiResultOperationError as he, isApiResultSuccess as we, isAuthError as xe, isAuthLoading as Ie, isAuthenticated as _e, isClientReady as Re, isDirectState as De, isExtensionState as Me, isOperationError as Ne, isWebUIClient as Te } from "@bodhiapp/bodhi-js-core";
4
- import { useMemo as _, useRef as T, useCallback as d, useEffect as b, createContext as re, useState as N, useContext as ne } from "react";
5
- const m = {
1
+ import { jsxs as K, jsx as P } from "react/jsx-runtime";
2
+ import { Logger as H, BodhiClientUserPrefsManager as W, createStoragePrefixWithBasePath as j, detectBrowser as Y, detectOS as q, getServerUrl as X, isDirectServerReady as Z, isExtensionServerReady as $, OS_CONFIGS as J, BROWSER_CONFIGS as Q, OnboardingModal as ee, BACKEND_SERVER_NOT_CONNECTED as G, isExtensionState as te, INITIAL_AUTH_STATE as re, NOOP_STATE_CALLBACK as ne, isWebUIClient as se } from "@bodhiapp/bodhi-js-core";
3
+ import { createApiError as Le, createOperationError as be, isApiResultError as Ie, isApiResultOperationError as _e, isApiResultSuccess as Re, isAuthError as Te, isAuthLoading as De, isAuthenticated as Ne, isClientReady as ze, isDirectState as ke, isExtensionState as Be, isOperationError as Pe, isWebUIClient as Ue } from "@bodhiapp/bodhi-js-core";
4
+ import * as a from "react";
5
+ import { useMemo as T, useRef as z, useCallback as f, useEffect as k, createContext as ae, useState as N, useContext as ce } from "react";
6
+ const y = {
6
7
  // Modal lifecycle
7
8
  MODAL_READY: "modal:ready",
8
9
  MODAL_REFRESH: "modal:refresh",
@@ -16,22 +17,22 @@ const m = {
16
17
  // Connection selection
17
18
  MODAL_SELECT_CONNECTION: "modal:select-connection"
18
19
  };
19
- function se({
20
+ function oe({
20
21
  client: e,
21
- modalHtmlPath: o,
22
- hideSetup: w,
23
- onSetupReady: x,
24
- setupState: R,
25
- basePath: g = "/",
26
- logLevel: A = "warn"
22
+ modalHtmlPath: s,
23
+ hideSetup: A,
24
+ onSetupReady: w,
25
+ setupState: x,
26
+ basePath: S = "/",
27
+ logLevel: m = "warn"
27
28
  }) {
28
- const p = R !== "ready", E = _(() => new B("SetupModalProcessor", A), [A]), u = T(null), a = _(
29
- () => new G(K(g, "bodhijs:")),
30
- [g]
31
- ), f = T(null), v = d(
29
+ const I = x !== "ready", M = T(() => new H("SetupModalProcessor", m), [m]), c = z(null), l = T(
30
+ () => new W(j(S, "bodhijs:")),
31
+ [S]
32
+ ), h = z(null), C = f(
32
33
  (t) => t === "direct" ? "lna" : t === "extension" ? "extension" : null,
33
34
  []
34
- ), y = d((t) => t.extension === "ready" ? {
35
+ ), _ = f((t) => t.extension === "ready" ? {
35
36
  status: "ready",
36
37
  version: "unknown",
37
38
  // TODO: have ExtensionState also get extension version
@@ -42,7 +43,7 @@ function se({
42
43
  } : {
43
44
  status: "unreachable",
44
45
  error: { message: "Client not initialized", code: "ext-connection-failed" }
45
- }, []), O = d((t) => {
46
+ }, []), O = f((t) => {
46
47
  if (t.server.status === "pending-extension-ready")
47
48
  return {
48
49
  status: "pending-extension-ready",
@@ -95,7 +96,7 @@ function se({
95
96
  }
96
97
  };
97
98
  }
98
- }, []), C = d((t) => {
99
+ }, []), E = f((t) => {
99
100
  if (t.server.status === "not-connected")
100
101
  return { status: "pending-lna-ready" };
101
102
  const r = t.server;
@@ -118,169 +119,169 @@ function se({
118
119
  error: { message: "Unknown server status" }
119
120
  };
120
121
  }
121
- }, []), L = d(
122
+ }, []), L = f(
122
123
  (t, r) => {
123
124
  if (t.server.status !== "pending-extension-ready") {
124
- const s = t.server.status;
125
- if (s === "ready" || s === "setup" || s === "resource-admin")
125
+ const n = t.server.status;
126
+ if (n === "ready" || n === "setup" || n === "resource-admin")
126
127
  return !0;
127
128
  }
128
129
  if (r.server.status !== "not-connected") {
129
- const s = r.server.status;
130
- if (s === "ready" || s === "setup" || s === "resource-admin")
130
+ const n = r.server.status;
131
+ if (n === "ready" || n === "setup" || n === "resource-admin")
131
132
  return !0;
132
133
  }
133
134
  return !1;
134
135
  },
135
136
  []
136
- ), h = d(
137
- (t, r, s) => {
137
+ ), v = f(
138
+ (t, r, n) => {
138
139
  if (r === "skipped")
139
- return { status: "skipped", serverUrl: s };
140
+ return { status: "skipped", serverUrl: n };
140
141
  if (t.server.status !== "not-connected") {
141
- const c = t.server;
142
- return c.status === "ready" || c.status === "setup" || c.status === "resource-admin" ? { status: "granted", serverUrl: s } : {
142
+ const i = t.server;
143
+ return i.status === "ready" || i.status === "setup" || i.status === "resource-admin" ? { status: "granted", serverUrl: n } : {
143
144
  status: "unreachable",
144
- serverUrl: s,
145
+ serverUrl: n,
145
146
  error: {
146
- message: c.error?.message || "Server unreachable",
147
+ message: i.error?.message || "Server unreachable",
147
148
  code: "lna-unreachable"
148
149
  }
149
150
  };
150
151
  }
151
- return r === "granted" ? { status: "granted", serverUrl: s } : { status: "prompt", serverUrl: s };
152
+ return r === "granted" ? { status: "granted", serverUrl: n } : { status: "prompt", serverUrl: n };
152
153
  },
153
154
  []
154
- ), S = d(
155
+ ), g = f(
155
156
  async (t = !1) => {
156
- const r = V().type, s = W().type;
157
- let c = await e.getExtensionState();
158
- (c.extension === "not-initialized" || t) && (c = await e.testExtensionConnectivity());
159
- let n = await e.getDirectState();
160
- const i = a.getDirectStatus();
161
- i === "granted" && (n.server.status === "not-connected" || t) && (n = await e.testDirectConnectivity());
162
- const M = j(n) || "http://localhost:1135", I = h(n, i, M);
163
- return e.getConnectionMode() === null && (Y(n) ? await e.setConnectionMode("direct") : q(c) && await e.setConnectionMode("extension")), a.isServerInstallConfirmed() || L(c, n) && a.setServerInstallConfirmed(!0), {
164
- extension: y(c),
165
- server: O(c),
166
- lna: I,
167
- lnaServer: C(n),
168
- env: { browser: r, os: s },
169
- browsers: J,
170
- os: X,
171
- userConfirmations: { serverInstall: a.isServerInstallConfirmed() },
172
- selectedConnection: v(e.getConnectionMode())
157
+ const r = Y().type, n = q().type;
158
+ let i = await e.getExtensionState();
159
+ (i.extension === "not-initialized" || t) && (i = await e.testExtensionConnectivity());
160
+ let d = await e.getDirectState();
161
+ const b = l.getDirectStatus();
162
+ b === "granted" && (d.server.status === "not-connected" || t) && (d = await e.testDirectConnectivity());
163
+ const o = X(d) || "http://localhost:1135", D = v(d, b, o);
164
+ return e.getConnectionMode() === null && (Z(d) ? await e.setConnectionMode("direct") : $(i) && await e.setConnectionMode("extension")), l.isServerInstallConfirmed() || L(i, d) && l.setServerInstallConfirmed(!0), {
165
+ extension: _(i),
166
+ server: O(i),
167
+ lna: D,
168
+ lnaServer: E(d),
169
+ env: { browser: r, os: n },
170
+ browsers: Q,
171
+ os: J,
172
+ userConfirmations: { serverInstall: l.isServerInstallConfirmed() },
173
+ selectedConnection: C(e.getConnectionMode())
173
174
  };
174
175
  },
175
176
  [
176
177
  e,
177
- a,
178
- y,
178
+ l,
179
+ _,
179
180
  O,
181
+ E,
180
182
  C,
181
183
  v,
182
- h,
183
184
  L
184
185
  ]
185
- ), l = d(() => {
186
- if (!f.current)
186
+ ), p = f(() => {
187
+ if (!h.current)
187
188
  throw new Error("Cannot get state: currentStateRef is null");
188
189
  return {
189
- ...f.current,
190
+ ...h.current,
190
191
  // Override userConfirmations from storage (in case updated outside buildSetupState)
191
192
  userConfirmations: {
192
- serverInstall: a.isServerInstallConfirmed()
193
+ serverInstall: l.isServerInstallConfirmed()
193
194
  },
194
195
  // Override selectedConnection from client (in case changed via handler)
195
- selectedConnection: v(e.getConnectionMode())
196
+ selectedConnection: C(e.getConnectionMode())
196
197
  };
197
- }, [a, e, v]), D = _(
198
+ }, [l, e, C]), R = T(
198
199
  () => ({
199
- [m.MODAL_READY]: async () => (E.info("MODAL_READY: building initial state"), { setupState: l() }),
200
- [m.MODAL_REFRESH]: async () => {
201
- E.info("MODAL_REFRESH: refreshing state");
202
- const t = await S(!0);
203
- f.current = t;
204
- const r = l();
205
- return E.info(`MODAL_REFRESH: state refreshed
206
- `, JSON.stringify(r, null, 2)), u.current?.updateState(l()), { setupState: r };
200
+ [y.MODAL_READY]: async () => (M.info("MODAL_READY: building initial state"), { setupState: p() }),
201
+ [y.MODAL_REFRESH]: async () => {
202
+ M.info("MODAL_REFRESH: refreshing state");
203
+ const t = await g(!0);
204
+ h.current = t;
205
+ const r = p();
206
+ return M.info(`MODAL_REFRESH: state refreshed
207
+ `, JSON.stringify(r, null, 2)), c.current?.updateState(p()), { setupState: r };
207
208
  },
208
- [m.MODAL_LNA_CONNECT]: async (t) => {
209
+ [y.MODAL_LNA_CONNECT]: async (t) => {
209
210
  const r = t.payload.serverUrl;
210
211
  console.log("[SetupModalProcessor] LNA connect:", r);
211
- const s = await e.testDirectConnectivity(r);
212
- if (s.server.status !== "not-connected") {
213
- const n = s.server.status;
214
- if (n === "ready" || n === "setup" || n === "resource-admin") {
215
- a.setDirectStatus("granted"), e.getConnectionMode() === null && await e.setConnectionMode("direct");
216
- const i = await S();
217
- return f.current = i, u.current?.updateState(l()), { success: !0 };
212
+ const n = await e.testDirectConnectivity(r);
213
+ if (n.server.status !== "not-connected") {
214
+ const d = n.server.status;
215
+ if (d === "ready" || d === "setup" || d === "resource-admin") {
216
+ l.setDirectStatus("granted"), e.getConnectionMode() === null && await e.setConnectionMode("direct");
217
+ const b = await g();
218
+ return h.current = b, c.current?.updateState(p()), { success: !0 };
218
219
  }
219
220
  }
220
- const c = await S();
221
- return f.current = c, u.current?.updateState(l()), { success: !1 };
221
+ const i = await g();
222
+ return h.current = i, c.current?.updateState(p()), { success: !1 };
222
223
  },
223
- [m.MODAL_LNA_SKIP]: async () => {
224
- a.setDirectStatus("skipped");
225
- const t = await S();
226
- return f.current = t, u.current?.updateState(l()), { success: !0 };
224
+ [y.MODAL_LNA_SKIP]: async () => {
225
+ l.setDirectStatus("skipped");
226
+ const t = await g();
227
+ return h.current = t, c.current?.updateState(p()), { success: !0 };
227
228
  },
228
- [m.MODAL_CLOSE]: () => {
229
- w();
229
+ [y.MODAL_CLOSE]: () => {
230
+ A();
230
231
  },
231
- [m.MODAL_COMPLETE]: () => {
232
- w();
232
+ [y.MODAL_COMPLETE]: () => {
233
+ A();
233
234
  },
234
- [m.MODAL_CONFIRM_SERVER_INSTALL]: (t) => (a.setServerInstallConfirmed(t.payload.confirmed), u.current?.updateState(l()), { success: !0 }),
235
- [m.MODAL_SELECT_CONNECTION]: async (t) => {
236
- const s = t.payload.connection === "lna" ? "direct" : "extension";
237
- return await e.setConnectionMode(s), u.current?.updateState(l()), { success: !0 };
235
+ [y.MODAL_CONFIRM_SERVER_INSTALL]: (t) => (l.setServerInstallConfirmed(t.payload.confirmed), c.current?.updateState(p()), { success: !0 }),
236
+ [y.MODAL_SELECT_CONNECTION]: async (t) => {
237
+ const n = t.payload.connection === "lna" ? "direct" : "extension";
238
+ return await e.setConnectionMode(n), c.current?.updateState(p()), { success: !0 };
238
239
  }
239
240
  }),
240
- [E, e, a, S, l, C, w]
241
+ [M, e, l, g, p, E, A]
241
242
  );
242
- return b(() => (u.current = new Z({ modalHtmlPath: o, handlers: D }), () => {
243
- u.current?.destroy(), u.current = null;
244
- }), [o, D]), b(() => {
245
- p && u.current ? S(!0).then((t) => {
246
- f.current = t, u.current?.show(t), x?.();
243
+ return k(() => (c.current = new ee({ modalHtmlPath: s, handlers: R }), () => {
244
+ c.current?.destroy(), c.current = null;
245
+ }), [s, R]), k(() => {
246
+ I && c.current ? g(!0).then((t) => {
247
+ h.current = t, c.current?.show(t), w?.();
247
248
  }).catch((t) => {
248
249
  console.error("[SetupModalProcessor] buildSetupState failed:", t);
249
- }) : !p && u.current && u.current.destroy();
250
- }, [p, S, x]), null;
250
+ }) : !I && c.current && c.current.destroy();
251
+ }, [I, g, w]), null;
251
252
  }
252
- const oe = {
253
+ const ie = {
253
254
  status: "not-initialized",
254
255
  mode: null,
255
256
  extensionId: null,
256
257
  url: null,
257
- server: P,
258
+ server: G,
258
259
  error: null
259
- }, ae = {
260
+ }, ue = {
260
261
  status: "initializing",
261
262
  mode: null,
262
263
  extensionId: null,
263
264
  url: null,
264
- server: P,
265
+ server: G,
265
266
  error: null
266
267
  };
267
- function ie(e) {
268
+ function le(e) {
268
269
  return e.status === "not-initialized";
269
270
  }
270
- function ue(e) {
271
+ function de(e) {
271
272
  return e.status === "initializing";
272
273
  }
273
- function ce(e) {
274
+ function fe(e) {
274
275
  return e.status !== "not-initialized" && e.status !== "initializing";
275
276
  }
276
- function U(e) {
277
+ function V(e) {
277
278
  return e.status === "ready";
278
279
  }
279
- function de(e) {
280
- return U(e) && e.server.status === "ready";
280
+ function pe(e) {
281
+ return V(e) && e.server.status === "ready";
281
282
  }
282
- function le(e) {
283
- return Q(e) ? {
283
+ function me(e) {
284
+ return te(e) ? {
284
285
  status: e.extension === "not-initialized" ? "initializing" : e.extension === "not-found" ? "extension-not-found" : "ready",
285
286
  mode: "extension",
286
287
  extensionId: e.extensionId,
@@ -297,177 +298,221 @@ function le(e) {
297
298
  };
298
299
  }
299
300
  const ve = {
300
- isNotInitialized: ie,
301
- isInitializing: ue,
302
- isInitialized: ce,
303
- isReady: U,
304
- isOverallReady: de
305
- }, z = re(null);
306
- z.displayName = "BodhiContext";
307
- function me({
301
+ isNotInitialized: le,
302
+ isInitializing: de,
303
+ isInitialized: fe,
304
+ isReady: V,
305
+ isOverallReady: pe
306
+ }, U = ae(null);
307
+ U.displayName = "BodhiContext";
308
+ function ye({
308
309
  children: e,
309
- client: o,
310
- modalHtmlPath: w,
311
- handleCallback: x = !0,
312
- callbackPath: R = "/callback",
313
- basePath: g = "/",
314
- logLevel: A = "warn"
310
+ client: s,
311
+ modalHtmlPath: A,
312
+ handleCallback: w = !0,
313
+ callbackPath: x,
314
+ basePath: S = "/",
315
+ logLevel: m = "warn"
315
316
  }) {
316
- const p = _(() => new B("BodhiProvider", A), [A]), E = T(!1), u = T(!1), [a, f] = N(oe), [v, y] = N($), [O, C] = N(!1), [L, h] = N("ready");
317
- b(() => {
318
- const n = (i) => {
319
- switch (i.type) {
317
+ const I = S === "/" ? "" : S.replace(/\/$/, ""), M = x ?? `${I}/callback`, c = T(() => new H("BodhiProvider", m), [m]), l = z(!1), h = z(!1), [C, _] = N(ie), [O, E] = N(re), [L, v] = N(!1), [g, p] = N("ready");
318
+ k(() => {
319
+ const u = (o) => {
320
+ switch (o.type) {
320
321
  case "client-state":
321
- f(le(i.state));
322
+ _(me(o.state));
322
323
  break;
323
324
  case "auth-state":
324
- y(i.state), C(!1);
325
+ E(o.state), v(!1);
325
326
  break;
326
327
  }
327
328
  };
328
- return o.setStateCallback(n), () => {
329
- o.setStateCallback(ee);
329
+ return s.setStateCallback(u), () => {
330
+ s.setStateCallback(ne);
330
331
  };
331
- }, [o]);
332
- const S = d(async () => {
333
- h("loading");
334
- }, []), l = d(() => {
335
- h("ready");
336
- }, []), D = d(() => {
337
- h("loaded");
338
- }, []), t = d(
339
- async (n) => {
340
- f(ae);
332
+ }, [s]);
333
+ const R = f(async () => {
334
+ p("loading");
335
+ }, []), t = f(() => {
336
+ p("ready");
337
+ }, []), r = f(() => {
338
+ p("loaded");
339
+ }, []), n = f(
340
+ async (u) => {
341
+ _(ue);
341
342
  try {
342
- await o.init(n || {});
343
- } catch (i) {
344
- p.error("Init failed:", i);
343
+ await s.init(u || {});
344
+ } catch (o) {
345
+ c.error("Init failed:", o);
345
346
  }
346
347
  },
347
- [o, p]
348
+ [s, c]
348
349
  );
349
- b(() => {
350
- if (u.current) return;
351
- u.current = !0, (async () => {
352
- if (await t(), !x) return;
353
- const i = new URL(window.location.href);
354
- if (i.pathname !== R) return;
355
- const k = i.searchParams.get("code"), M = i.searchParams.get("state");
356
- !k || !M || E.current || (E.current = !0, te(o) && (C(!0), o.handleOAuthCallback(k, M).then(() => {
357
- window.history.replaceState({}, "", g);
358
- }).catch((I) => {
359
- p.error("OAuth callback failed:", I), y({
350
+ k(() => {
351
+ if (h.current) return;
352
+ h.current = !0, (async () => {
353
+ if (await n(), !w) return;
354
+ const o = new URL(window.location.href);
355
+ if (o.pathname !== M) return;
356
+ const D = o.searchParams.get("code"), F = o.searchParams.get("state");
357
+ !D || !F || l.current || (l.current = !0, se(s) && (v(!0), s.handleOAuthCallback(D, F).then(() => {
358
+ window.history.replaceState({}, "", S);
359
+ }).catch((B) => {
360
+ c.error("OAuth callback failed:", B), E({
360
361
  status: "error",
361
362
  user: null,
362
363
  accessToken: null,
363
364
  error: {
364
- message: I instanceof Error ? I.message : "OAuth callback failed",
365
+ message: B instanceof Error ? B.message : "OAuth callback failed",
365
366
  code: "OAUTH_CALLBACK_FAILED"
366
367
  }
367
- }), C(!1), window.history.replaceState({}, "", g);
368
+ }), v(!1), window.history.replaceState({}, "", S);
368
369
  })));
369
370
  })();
370
- }, [t, o, x, R, g]);
371
- const r = d(async () => {
372
- C(!0);
371
+ }, [n, s, w, M, S]);
372
+ const i = f(async () => {
373
+ v(!0);
373
374
  try {
374
- await o.login();
375
- } catch (n) {
376
- y({
375
+ await s.login();
376
+ } catch (u) {
377
+ const o = {
377
378
  status: "error",
378
379
  user: null,
379
380
  accessToken: null,
380
381
  error: {
381
- message: n instanceof Error ? n.message : "Login failed",
382
+ message: u instanceof Error ? u.message : "Login failed",
382
383
  code: "LOGIN_FAILED"
383
384
  }
384
- }), C(!1);
385
+ };
386
+ return E(o), v(!1), o;
385
387
  }
386
- }, [o]), s = d(async () => {
388
+ }, [s]), d = f(async () => {
387
389
  try {
388
- await o.logout();
389
- } catch (n) {
390
- y({
390
+ await s.logout();
391
+ } catch (u) {
392
+ E({
391
393
  status: "error",
392
394
  user: null,
393
395
  accessToken: null,
394
396
  error: {
395
- message: n instanceof Error ? n.message : "Logout failed",
397
+ message: u instanceof Error ? u.message : "Logout failed",
396
398
  code: "LOGOUT_FAILED"
397
399
  }
398
400
  });
399
401
  }
400
- }, [o]), c = _(() => {
401
- const n = a.status === "ready", i = a.server.status === "ready";
402
+ }, [s]), b = T(() => {
403
+ const u = C.status === "ready", o = C.server.status === "ready";
402
404
  return {
403
- client: o,
404
- clientState: a,
405
- auth: v,
406
- isAuthLoading: O,
407
- login: r,
408
- logout: s,
409
- showSetup: S,
410
- hideSetup: l,
411
- setupState: L,
405
+ client: s,
406
+ clientState: C,
407
+ auth: O,
408
+ isAuthLoading: L,
409
+ login: i,
410
+ logout: d,
411
+ showSetup: R,
412
+ hideSetup: t,
413
+ setupState: g,
412
414
  // Computed auth properties
413
- isAuthenticated: v.status === "authenticated",
414
- canLogin: n && !O,
415
+ isAuthenticated: O.status === "authenticated",
416
+ canLogin: u && !L,
415
417
  // Computed connection properties
416
- isReady: n,
417
- isServerReady: i,
418
- isOverallReady: n && i,
419
- isInitializing: a.status === "initializing",
420
- isExtension: a.mode === "extension",
421
- isDirect: a.mode === "direct"
418
+ isReady: u,
419
+ isServerReady: o,
420
+ isOverallReady: u && o,
421
+ isInitializing: C.status === "initializing",
422
+ isExtension: C.mode === "extension",
423
+ isDirect: C.mode === "direct"
422
424
  };
423
- }, [o, a, v, O, L, r, s, S, l]);
424
- return /* @__PURE__ */ F(z.Provider, { value: c, children: [
425
- /* @__PURE__ */ H(
426
- se,
425
+ }, [s, C, O, L, g, i, d, R, t]);
426
+ return /* @__PURE__ */ K(U.Provider, { value: b, children: [
427
+ /* @__PURE__ */ P(
428
+ oe,
427
429
  {
428
- client: o,
429
- modalHtmlPath: w,
430
- hideSetup: l,
431
- onSetupReady: D,
432
- setupState: L,
433
- basePath: g,
434
- logLevel: A
430
+ client: s,
431
+ modalHtmlPath: A,
432
+ hideSetup: t,
433
+ onSetupReady: r,
434
+ setupState: g,
435
+ basePath: S,
436
+ logLevel: m
435
437
  }
436
438
  ),
437
439
  e
438
440
  ] });
439
441
  }
440
- function ge() {
441
- const e = ne(z);
442
+ function Ae() {
443
+ const e = ce(U);
442
444
  if (!e) throw new Error("useBodhi must be used within BodhiProvider");
443
445
  return e;
444
446
  }
445
- const pe = "production";
447
+ const Ce = (e) => /* @__PURE__ */ a.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 479.995 479.995", width: "480px", height: "480px", ...e }, /* @__PURE__ */ a.createElement("path", { fill: "#ffa4b8", d: "M239.998,374.56l-0.01-0.01c0-0.01,0.01-0.01,0.01-0.02c-4.64-8.78-65.7-144.8-212.22-85.2 c-14.36,5.85-19.78,23.45-11.19,36.36c11.11,16.69,22.86,30.01,34.91,40.53c-27.85,7.89-45.6,33.8-43.3,61.55 c0.96,11.6,13.29,18.52,23.71,13.35c33.99-16.84,60.03-2.51,80.35,2.14c56.68,12.99,113.71,4.53,125.52-46.29 c0.52-2.22,0.95-4.51,1.28-6.89c0.01-0.04,0.01-0.08,0.02-0.12c0.066-0.492,0.126-0.978,0.181-1.458 c0.455-3.631,0.712-7.438,0.739-11.452c-0.02-1.44-0.02-2.01,0-2.25v-0.09c0-0.02,0-0.04,0.01-0.05c0-0.02,0.01-0.03,0.02-0.06 c0-0.01,0.01-0.01,0.01-0.02C240.018,374.569,240.008,374.56,239.998,374.56z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ffa4b8", d: "M471.798,427.769c-0.96,11.6-13.29,18.52-23.71,13.35c-33.99-16.84-60.03-2.51-80.35,2.14 c-63.41,14.53-127.25,2.22-127.74-66.21c0.033-2.642-0.044-2.302,0.04-2.47c-0.02-0.01-0.03-0.02-0.04-0.02l0.01-0.01 c0-0.01-0.01-0.01-0.01-0.02c4.64-8.78,65.7-144.8,212.22-85.2c14.36,5.85,19.78,23.45,11.19,36.36 c-11.11,16.69-22.86,30.01-34.91,40.53C456.348,374.109,474.098,400.019,471.798,427.769z" }), /* @__PURE__ */ a.createElement("path", { fill: "#befa91", d: "M428.498,366.219c27.85,7.89,45.6,33.8,43.3,61.55c-0.96,11.6-13.29,18.52-23.71,13.35 c-33.99-16.84-60.03-2.51-80.35,2.14c-63.41,14.53-127.928,2.222-127.74-66.21c0.007-2.683-0.02-2.351,0.04-2.47 C248.598,379.129,345.858,438.329,428.498,366.219z" }), /* @__PURE__ */ a.createElement("path", { fill: "#befa91", d: "M51.498,366.219c82.76,72.22,180.18,12.74,188.5,8.34c0.01,0,0.02,0.01,0.04,0.02 c-0.058,0.116-0.047-0.169-0.04,2.47c0.188,68.432-64.33,80.74-127.74,66.21c-20.32-4.65-46.36-18.98-80.35-2.14 c-10.42,5.17-22.75-1.75-23.71-13.35C5.898,400.019,23.648,374.109,51.498,366.219z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ffbfcb", d: "M235.228,365.299c-32.29-36.09-89.98-73-179.74-36.49c-1.979,0.805-3.787,1.834-5.413,3.042 c-10.569,7.856-25.473,5.765-32.82-5.164c-0.223-0.331-0.445-0.664-0.667-0.997c-8.59-12.91-3.17-30.51,11.19-36.36 C155.168,237.509,217.948,333.56,235.228,365.299z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ffa4b8", d: "M239.998,374.549c-12.85-2.2-214.54-23.33-193.03-240.71c1.49-14.99,15.86-25.15,30.48-21.55 c108.49,26.72,149.07,91.39,162.55,149.92C252.768,317.699,241.178,367.679,239.998,374.549z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ffbfcb", d: "M193.698,174.638c11.866,12.406-3.013,31.792-18.056,23.52 c-21.875-12.028-50.044-10.573-70.207,3.701c-24.832,17.579-59.398-0.365-60.013-30.784c-0.237-11.724,0.248-24.123,1.545-37.237 c1.49-14.99,15.86-25.15,30.48-21.55C131.23,125.537,168.324,148.11,193.698,174.638z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ffa4b8", d: "M221.538,39.599c9.78-11.13,27.15-11.12,36.93,0.01c157.02,178.77-7.48,323.95-18.47,334.94 C229.988,364.549,63.948,218.989,221.538,39.599z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ffbfcb", d: "M261.523,43.131c9.452,11.033,8.166,27.623-2.74,37.221c-0.784,0.69-1.535,1.439-2.245,2.247 c-35.942,40.915-55.05,80.07-63.012,116.258c-5.176,23.523-39.936,19.717-39.551-4.366c0.741-46.282,18.411-98.941,67.563-154.892 c9.78-11.13,27.15-11.12,36.93,0.01C259.5,40.785,260.518,41.959,261.523,43.131z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ffa4b8", d: "M239.998,374.549c-1.18-6.87-12.77-56.85,0-112.34c13.48-58.53,54.06-123.2,162.55-149.92 c14.62-3.6,28.99,6.56,30.48,21.55C454.538,351.219,252.848,372.349,239.998,374.549z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ff8ca5", d: "M239.998,374.549c-3.115-0.536-17.362-2.183-36.835-7.483c-3.181-0.866-6.028-2.682-8.145-5.209 c-49.098-58.608-75.675-130.75-61.047-205.793c2.165-11.107,14.881-16.444,24.408-10.337c0.756,0.485,1.506,0.972,2.249,1.462 C126.798,274.139,232.088,366.649,239.998,374.549z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ff8ca5", d: "M281.608,365.729c-21.9,6.37-38.24,8.25-41.61,8.82c8.67-8.67,112.98-100.94,79.35-227.34v-0.01 c0.742-0.489,1.49-0.975,2.244-1.459c9.551-6.123,22.265-0.733,24.422,10.406C369.565,277.734,281.608,363.204,281.608,365.729z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ff8ca5", d: "M417.451,302.932c-32.211,44.193-80.706,72.823-134.571,87.345c-3.396,0.916-6.999,0.754-10.3-0.463 c-20.772-7.664-31.911-15.254-32.583-15.254c0.826-0.825,112.667-9.463,166.4-98.31C419.37,278.279,424.743,292.927,417.451,302.932 z" }), /* @__PURE__ */ a.createElement("path", { fill: "#ff8ca5", d: "M62.565,302.932c32.211,44.193,80.705,72.823,134.571,87.345c3.396,0.916,6.999,0.754,10.3-0.463 c20.772-7.664,31.911-15.254,32.583-15.254c-0.828-0.828-112.665-9.458-166.4-98.31C60.646,278.279,55.273,292.927,62.565,302.932z" }), /* @__PURE__ */ a.createElement("path", { fill: "#9ceb63", d: "M433.464,393.091c-52.749,39.415-118.979,42.09-182.861,13.657 c-4.441-1.977-7.606-6.011-8.633-10.763c-1.552-7.18-1.884-14.238-1.973-21.326c0.172-0.345,9.566,5.934,26.76,12.89 c36.31,14.71,102.75,30.15,161.74-21.33C440.977,369.752,443.403,385.664,433.464,393.091z" }), /* @__PURE__ */ a.createElement("path", { fill: "#9ceb63", d: "M240.038,374.579c0,0.01-0.01,0.01-0.01,0.02s-0.01,0.03-0.01,0.05c0,0,0,0,0,0.01 c-0.01,0.03-0.01,0.06-0.02,0.1v0.04c-0.13,1.3,0.09,7.59-0.92,15.16c-0.01,0.04-0.01,0.08-0.02,0.12 c-0.26,1.91-0.59,3.91-1.03,5.92c-0.07,0.33-0.15,0.65-0.25,0.97c-1.23,4.33-4.28,7.95-8.41,9.79 c-63.06,28.05-129.47,26.21-182.79-13.63c-9.94-7.43-7.63-23.36,4.92-26.91c13.1,11.46,28.11,20.79,44.16,26.79 c19.78,7.48,34.99,8.98,53.83,8.68c34.33-0.55,60.1-11.03,90.51-27.13C240.008,374.56,240.018,374.569,240.038,374.579z" }), /* @__PURE__ */ a.createElement("path", { d: "M443.143,363.426c9.579-9.648,18.604-20.804,26.926-33.305c11.399-17.132,4.201-40.447-14.837-48.202 c-12.321-5.012-24.515-8.844-36.391-11.454c17.945-34.197,27.974-78.94,22.188-137.413c-1.925-19.503-20.802-33.354-40.394-28.53 c-17.952,4.421-34.806,10.063-50.093,16.768c-4.046,1.775-5.888,6.494-4.113,10.54c1.774,4.046,6.493,5.887,10.54,4.113 c14.45-6.338,30.429-11.682,47.492-15.885c9.885-2.435,19.599,4.434,20.607,14.573c9.088,90.121-21.147,164.341-99.823,205.213 c-3.921,2.037-5.448,6.866-3.411,10.787c2.043,3.933,6.879,5.442,10.787,3.411c27.191-14.125,56.267-35.849,77.701-68.994 c12.564,2.375,25.617,6.296,38.878,11.69c9.68,3.943,13.334,15.824,7.549,24.518c-10.205,15.33-21.482,28.43-33.516,38.936 c-49.396,43.107-111.979,41.39-169.834,12.419c56.638-56.971,92.247-132.34,77.074-212.524 c-8.101-42.81-30.305-85.119-65.997-125.754c-12.964-14.759-36.003-14.748-48.946-0.016 c-28.645,32.607-48.657,66.371-59.602,100.512c-21.999-13.018-47.7-23.197-76.569-30.307c-19.338-4.763-38.383,8.699-40.354,28.53 C26.197,262.501,90.89,324.677,147.416,354.042c3.92,2.036,8.75,0.51,10.787-3.411c2.037-3.921,0.51-8.75-3.411-10.787 c-52.141-27.086-111.791-84.677-99.863-205.213c1.007-10.132,10.713-17.01,20.606-14.574c31.115,7.663,58.223,19.013,80.571,33.735 c4.863,3.204,10.891,0.586,12.257-4.539c9.392-35.245,29.306-70.362,59.188-104.378c6.581-7.492,18.316-7.487,24.904,0.014 c128.735,146.565,37.449,269.122-12.476,318.519c-30.274-29.828-76.759-87.727-78.002-162.831 c-0.073-4.417-3.698-7.933-8.131-7.867c-4.417,0.073-7.939,3.714-7.867,8.131c1.382,83.483,54.096,146.516,85.999,177.099 c-0.353,20.737-7.099,36.575-20.104,47.086c-20.129,16.267-55.786,20.072-97.831,10.438c-19.181-4.396-48.632-19.874-85.688-1.511 c-5.361,2.657-11.689-0.859-12.186-6.844c-1.888-22.74,12.042-43.926,33.548-51.893c13.4,11.096,27.797,19.551,43.11,25.275 c20.238,7.653,36.036,9.525,56.788,9.196c15.85-0.254,30.814-2.572,45.747-7.085c4.229-1.278,6.622-5.743,5.343-9.972 c-1.278-4.229-5.744-6.622-9.972-5.344c-13.494,4.078-27.027,6.173-41.373,6.403c-17.347,0.275-31.911-0.993-50.901-8.174 c-31.69-11.847-56.387-35.98-75.211-64.258c-5.791-8.704-2.122-20.58,7.548-24.52c4.092-1.667,6.058-6.335,4.391-10.427 c-1.667-4.092-6.334-6.058-10.427-4.391c-19.062,7.765-26.214,31.095-14.832,48.202c8.365,12.566,17.352,23.674,26.917,33.31 C12.89,375.664-2.037,401.187,0.226,428.434c1.427,17.192,19.743,27.533,35.235,19.857c30.84-15.283,54.311-1.971,75.01,2.771 c36.708,8.411,82.166,10.086,111.461-13.59c14.777-11.943,23.305-28.715,25.489-49.937 c61.607,30.736,128.694,32.482,182.835-12.326c21.516,7.959,35.456,29.153,33.567,51.902c-0.493,5.939-6.786,9.519-12.186,6.844 c-30.339-15.034-55.535-7.379-73.932-1.791c-31.306,9.51-74.736,14.144-102.884-2.498c-3.803-2.248-8.709-0.989-10.958,2.815 c-2.249,3.803-0.989,8.709,2.815,10.958c29.214,17.272,69.817,15.19,102.844,7.622c20.72-4.747,44.177-18.05,75.01-2.771 c15.523,7.691,33.811-2.693,35.235-19.856C482.032,401.183,467.102,375.655,443.143,363.426z" })), Se = {
448
+ sm: 32,
449
+ md: 48,
450
+ lg: 64
451
+ };
452
+ function we({
453
+ size: e = "md",
454
+ variant: s = "light",
455
+ className: A = "",
456
+ style: w = {}
457
+ }) {
458
+ const x = Se[e], S = {
459
+ display: "inline-block",
460
+ cursor: "pointer",
461
+ transition: "all 250ms ease",
462
+ borderRadius: "50%",
463
+ ...s === "dark" && {
464
+ backgroundColor: "rgba(255, 255, 255, 0.05)",
465
+ padding: "8px"
466
+ },
467
+ ...w
468
+ };
469
+ return /* @__PURE__ */ P(
470
+ "a",
471
+ {
472
+ href: "https://getbodhi.app",
473
+ target: "_blank",
474
+ rel: "noopener noreferrer",
475
+ title: "Powered by Bodhi",
476
+ "aria-label": "Powered by Bodhi - Visit getbodhi.app",
477
+ className: A,
478
+ style: S,
479
+ onMouseEnter: (m) => {
480
+ m.currentTarget.style.transform = "scale(1.1)", m.currentTarget.style.boxShadow = "0 0 20px rgba(255, 164, 184, 0.6)";
481
+ },
482
+ onMouseLeave: (m) => {
483
+ m.currentTarget.style.transform = "scale(1)", m.currentTarget.style.boxShadow = "none";
484
+ },
485
+ children: /* @__PURE__ */ P(Ce, { width: x, height: x, style: { display: "block" } })
486
+ }
487
+ );
488
+ }
489
+ const Me = "production";
446
490
  export {
447
- me as BodhiProvider,
448
- z as BodhiReactContext,
491
+ we as BodhiBadge,
492
+ ye as BodhiProvider,
493
+ U as BodhiReactContext,
449
494
  ve as ClientCtxState,
450
- ae as INITIALIZING_CLIENT_CONTEXT_STATE,
451
- oe as INITIAL_CLIENT_CONTEXT_STATE,
452
- pe as REACT_CORE_BUILD_MODE,
453
- le as clientStateToContextState,
454
- Ae as createApiError,
455
- Oe as createOperationError,
456
- Le as isApiResultError,
457
- he as isApiResultOperationError,
458
- we as isApiResultSuccess,
459
- xe as isAuthError,
460
- Ie as isAuthLoading,
461
- _e as isAuthenticated,
462
- ce as isClientCtxInitialized,
463
- ue as isClientCtxInitializing,
464
- ie as isClientCtxNotInitialized,
465
- U as isClientCtxReady,
466
- Re as isClientReady,
467
- De as isDirectState,
468
- Me as isExtensionState,
469
- Ne as isOperationError,
470
- de as isOverallReady,
471
- Te as isWebUIClient,
472
- ge as useBodhi
495
+ ue as INITIALIZING_CLIENT_CONTEXT_STATE,
496
+ ie as INITIAL_CLIENT_CONTEXT_STATE,
497
+ Me as REACT_CORE_BUILD_MODE,
498
+ me as clientStateToContextState,
499
+ Le as createApiError,
500
+ be as createOperationError,
501
+ Ie as isApiResultError,
502
+ _e as isApiResultOperationError,
503
+ Re as isApiResultSuccess,
504
+ Te as isAuthError,
505
+ De as isAuthLoading,
506
+ Ne as isAuthenticated,
507
+ fe as isClientCtxInitialized,
508
+ de as isClientCtxInitializing,
509
+ le as isClientCtxNotInitialized,
510
+ V as isClientCtxReady,
511
+ ze as isClientReady,
512
+ ke as isDirectState,
513
+ Be as isExtensionState,
514
+ Pe as isOperationError,
515
+ pe as isOverallReady,
516
+ Ue as isWebUIClient,
517
+ Ae as useBodhi
473
518
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodhiapp/bodhi-js-react-core",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Core React bindings for Bodhi Browser SDK (dependency injection)",
5
5
  "type": "module",
6
6
  "main": "dist/bodhi-react-core.cjs.js",
@@ -42,7 +42,7 @@
42
42
  "typecheck": "tsc --noEmit"
43
43
  },
44
44
  "dependencies": {
45
- "@bodhiapp/bodhi-js-core": "0.0.11",
45
+ "@bodhiapp/bodhi-js-core": "0.0.13",
46
46
  "@bodhiapp/ts-client": "0.1.9"
47
47
  },
48
48
  "peerDependencies": {
@@ -62,6 +62,7 @@
62
62
  "tslib": "^2.6.2",
63
63
  "typescript": "^5.8.3",
64
64
  "vite": "^7.1.12",
65
- "vite-plugin-dts": "^4.5.4"
65
+ "vite-plugin-dts": "^4.5.4",
66
+ "vite-plugin-svgr": "^4.5.0"
66
67
  }
67
68
  }