PageSourceSearch

https://trybrain.io/assets/index-C3AvIyP_.js

js trybrain.io collected 2026-09-24 15:04:20 UTC 3,475 bytes, 1 lines download raw bytes

1import{s as S}from"./index-DHwBXtP2.js";var T={version:"1.1.2"},I="authorization_response",k="/~oauth/initiate",L=["https://oauth.lovable.app","https://lovable.dev"],y="lovable://oauth-callback",R="http://127.0.0.1/iframe-oauth/callback",U=500,D=12e4;function M(e){let r;const t=new Promise(i=>{r=i}),n=i=>{if(!e.some(u=>i.origin===u))return;const c=i.data;!c||typeof c!="object"||c.type===I&&r(c.response)},l=()=>{window.removeEventListener("message",n)};return window.addEventListener("message",n),{cleanup:l,messagePromise:t}}function C(e){const r=window.screenX!==0||window.screenY!==0||!e,t=r?window.outerWidth*.5:window.screen.width*.5,n=r?window.outerHeight*.5:window.screen.height*.5,l=r?window.screenX+(window.outerWidth-t)/2:(window.screen.width-t)/2,i=r?window.screenY+(window.outerHeight-n)/2:(window.screen.height-n)/2;return{width:t,height:n,left:l,top:i}}function A(e,r){return e.state!==r?{error:new Error("State is invalid")}:e.error?e.error==="legacy_flow"?{error:new Error("This flow is not supported in Preview mode. Please open the app in a new tab to sign in.")}:{error:new Error(e.error_description??"Sign in failed")}:!e.access_token||!e.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:e.access_token,refresh_token:e.refresh_token},error:null}}function $(){const e=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}function V(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function B(e={}){const r=e.oauthBrokerUrl??k,t=e.supportedOAuthOrigins??L;async function n(l,i={}){let a=!1;try{a=window.self!==window.top}catch{a=!0}const c=navigator.userAgent,u=/LovableApp\//.test(c),h=!u&&/lovable/i.test(c),p=V();let f=i.redirect_uri??window.location.origin;u&&a?f=y:h&&a&&(f=R);const _=new URLSearchParams({...i.extraParams,provider:l,redirect_uri:f,state:p});if(!a)return window.location.href=`${r}?${_.toString()}`,{error:null,redirected:!0};!u&&!h&&_.set("response_mode","web_message");const v=`${r}?${_.toString()}`,b=h?[...t,window.location.origin]:t,{messagePromise:P,cleanup:g}=M(b);let w;if($())w=window.open(v,"_blank");else{const{width:o,height:d,left:s,top:E}=C(a);w=window.open(v,"oauth",`width=${o},height=${d},left=${s},top=${E}`)}if(!w&&(u||h)){let o;const d=new Promise((s,E)=>{o=setTimeout(()=>{E(new Error("OAuth timed out waiting for response"))},D)});try{const s=await Promise.race([P,d]);return A(s,p)}catch(s){return{error:s instanceof Error?s:new Error(String(s))}}finally{o&&clearTimeout(o),g()}}if(!w)return g(),{error:new Error("Popup was blocked")};let m;const O=new Promise((o,d)=>{m=setInterval(()=>{w.closed&&(clearInterval(m),d(new Error("Sign in was cancelled")))},U)});try{const o=await Promise.race([P,O]);return A(o,p)}catch(o){return{error:o instanceof Error?o:new Error(String(o))}}finally{clearInterval(m),g(),w?.close()}}return{signInWithOAuth:n}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=T.version);function F(e={}){return B(e)}const H=F(),x={auth:{signInWithOAuth:async(e,r)=>{const t=await H.signInWithOAuth(e,{redirect_uri:r?.redirect_uri,extraParams:{...r?.extraParams}});if(t.redirected||t.error)return t;try{await S.auth.setSession(t.tokens)}catch(n){return{error:n instanceof Error?n:new Error(String(n))}}return t}}};export{x as l};

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.