1import{r as e,R as E}from"./plan-Dx0rPacR.js";function G(o={}){const{nonce:c,onScriptLoadSuccess:i,onScriptLoadError:l}=o,[v,s]=e.useState(!1),u=e.useRef(i);u.current=i;const f=e.useRef(l);return f.current=l,e.useEffect(()=>{const t=document.createElement("script");return t.src="https://accounts.google.com/gsi/client",t.async=!0,t.defer=!0,t.nonce=c,t.onload=()=>{var n;s(!0),(n=u.current)===null||n===void 0||n.call(u)},t.onerror=()=>{var n;s(!1),(n=f.current)===null||n===void 0||n.call(f)},document.body.appendChild(t),()=>{document.body.removeChild(t)}},[c]),v}const C=e.createContext(null);function A({clientId:o,nonce:c,onScriptLoadSuccess:i,onScriptLoadError:l,children:v}){const s=G({nonce:c,onScriptLoadSuccess:i,onScriptLoadError:l}),u=e.useMemo(()=>({clientId:o,scriptLoadedSuccessfully:s}),[o,s]);return E.createElement(C.Provider,{value:u},v)}function x(){const o=e.useContext(C);if(!o)throw new Error("Google OAuth components must be used within GoogleOAuthProvider");return o}function k({flow:o="implicit",scope:c="",onSuccess:i,onError:l,onNonOAuthError:v,overrideScope:s,state:u,...f}){const{clientId:t,scriptLoadedSuccessfully:n}=x(),m=e.useRef(),g=e.useRef(i);g.current=i;const R=e.useRef(l);R.current=l;const h=e.useRef(v);h.current=v,e.useEffect(()=>{var r,a;if(!n)return;const b=o==="implicit"?"initTokenClient":"initCodeClient",w=(a=(r=window?.google)===null||r===void 0?void 0:r.accounts)===null||a===void 0?void 0:a.oauth2[b]({client_id:t,scope:s?c:`openid profile email ${c}`,callback:p=>{var d,S;if(p.error)return(d=R.current)===null||d===void 0?void 0:d.call(R,p);(S=g.current)===null||S===void 0||S.call(g,p)},error_callback:p=>{var d;(d=h.current)===null||d===void 0||d.call(h,p)},state:u,...f});m.current=w},[t,n,o,c,u]);const _=e.useCallback(r=>{var a;return(a=m.current)===null||a===void 0?void 0:a.requestAccessToken(r)},[]),L=e.useCallback(()=>{var r;return(r=m.current)===null||r===void 0?void 0:r.requestCode()},[]);return o==="implicit"?_:L}export{A as G,k as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.