import{r as t,e,h as o,g as n}from"./p-083180bf.js";import{k as s,f as i,n as l}from"./p-a7fc1e02.js";import{g as c,i as r}from"./p-d0993bb9.js";const u=class{constructor(o){t(this,o),this.initComplete=e(this,"initComplete",7),this.googleButtonDiv=null,l(this)}disconnectedCallback(){}connectedCallback(){if(!document.head.querySelector('script[src="https://accounts.google.com/gsi/client"]')){const t=document.createElement("script");t.src="https://accounts.google.com/gsi/client",t.async=!0,document.head.appendChild(t)}}render(){const{setGoogleButtonDiv:t}=r()?function(t){const[e,o]=s(!1),[n,l]=s(null);return i((()=>{const t=()=>{window.onGoogleLibraryLoad=null,o(!0)};window.google&&t(),window.onGoogleLibraryLoad=t}),[]),i((()=>{if(!n||!e)return;google.accounts.id.initialize({client_id:"PLACEHOLDER",cb:()=>{}}),google.accounts.id.renderButton(n,{theme:"outline",size:"large",text:t.text,click_listener:()=>{t.initComplete.emit({credential:null})}})}),[n,e]),{setGoogleButtonDiv:l}}(this):function(t){const[e,o]=s(!1),[n,l]=s(null),[r,u]=s(400);let a=null;const g=()=>{n&&u(n.clientWidth)};return i((()=>{if(!n)return;const t=new ResizeObserver((()=>{a&&clearTimeout(a),a=setTimeout((()=>{g()}),50)}));return t.observe(n),g(),()=>t.disconnect()}),[n]),i((()=>{const e=()=>{window.onGoogleLibraryLoad=null;const e=c();"SquatchPortal"===e.type&&(google.accounts.id.initialize({client_id:e.env.googleOAuthId,callback:e=>{t.initComplete.emit(e)}}),o(!0))};window.google&&e(),window.onGoogleLibraryLoad=e}),[]),i((()=>{n&&e&&google.accounts.id.renderButton(n,{theme:"outline",size:"large",text:t.text,height:40,width:r})}),[n,e,r]),{setGoogleButtonDiv:l}}(this);return o("div",{ref:t,style:{width:"100%"}})}get el(){return n(this)}};export{u as sqm_google_sign_in}