UNPKG

@clerk/clerk-js

Version:
1 lines 1.59 kB
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["920"],{41491:function(e,t,n){n.r(t),n.d(t,{OneTap:()=>f});var o=n(79109),i=n(69144),a=n(11576),c=n(64204),l=n(24676);n(50725);var r=n(83799),u=n(2672);n(24152);var s=n(25758),d=n(12464);let p=(0,u.withCardStateProvider)(function(){let e=(0,r.cL)(),{user:t}=(0,r.aF)(),n=(0,a.useEnvironment)(),o=(0,i.useRef)(!1),{navigate:c}=(0,l.useRouter)(),u=(0,a.useGoogleOneTapContext)();async function p(t){o.current=!1;try{let n=await e.authenticateWithGoogleOneTap({token:t.credential});await e.handleGoogleOneTapCallback(n,u.generateCallbackUrls(window.location.href),c)}catch(e){console.error(e)}}let h=n.displayConfig.googleOneTapClientId,f=!(null==t?void 0:t.id)&&!!h;async function _(){let e=await (0,s.g)();return e.accounts.id.initialize({client_id:h,callback:p,itp_support:u.itpSupport,cancel_on_tap_outside:u.cancelOnTapOutside,auto_select:!1,use_fedcm_for_prompt:u.fedCmSupport}),e}let{data:g}=(0,d.ib)(f?_:void 0,"google-identity-services-script");return(0,i.useEffect)(()=>{!g||(null==t?void 0:t.id)||o.current||(g.accounts.id.prompt(t=>{"skipped"===t.getMomentType()&&e.closeGoogleOneTap()}),o.current=!0)},[e,g,null==t?void 0:t.id]),(0,i.useEffect)(()=>()=>{g&&o.current&&(o.current=!1,g.accounts.id.cancel())},[g]),null});function h(){return(0,o.tZ)(l.Route,{path:"one-tap",children:(0,o.tZ)(c.Flow.Root,{flow:"oneTap",children:(0,o.tZ)(l.Switch,{children:(0,o.tZ)(l.Route,{index:!0,children:(0,o.tZ)(p,{})})})})})}h.displayName="OneTap";let f=(0,a.withCoreSessionSwitchGuard)(h)}}]);