module.exports=[55835,a=>{"use strict";function b(a){let b="";for(let c of a)b+=String.fromCharCode(c);return btoa(b).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function c(a){let c=new TextEncoder().encode(a);return b(new Uint8Array(await crypto.subtle.digest("SHA-256",c)))}let d={state:"oidc_state",nonce:"oidc_nonce",codeVerifier:"oidc_code_verifier",serverUrl:"oidc_server_url",redirectUri:"oidc_redirect_uri",issuer:"oidc_issuer"};a.s(["OIDC_SESSION_KEYS",0,d,"clearOidcSession",0,function(){for(let a of Object.values(d))sessionStorage.removeItem(a)},"generateCodeChallenge",0,c,"generateCodeVerifier",0,function(){return b(crypto.getRandomValues(new Uint8Array(32)))},"generateNonce",0,function(){return b(crypto.getRandomValues(new Uint8Array(16)))},"generateState",0,function(){return b(crypto.getRandomValues(new Uint8Array(16)))},"jsonToBase64url",0,function(a){let c=JSON.stringify(a);return b(new TextEncoder().encode(c))}])},877928,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(340695),e=a.i(180360),f=a.i(55835);a.s(["OidcSsoLoginSection",0,function({serverUrl:a,disabled:g,onError:h,onLoadingChange:i}){let[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(),[n,o]=(0,c.useState)(),[p,q]=(0,c.useState)([]),[r,s]=(0,c.useState)(!1),t=(0,c.useRef)("");async function u(){if(j&&n){if(!crypto?.subtle)return void h("Sign in with SSO requires a secure connection. Please access the app over HTTPS.");s(!0),i(!0);try{let b,c=await fetch(`/api/oidc-discovery?issuer=${encodeURIComponent(n)}`);if(c.ok){let a=await c.json();"string"==typeof a.authorization_endpoint&&(b=a.authorization_endpoint)}if(!b)throw Error("Could not determine the authorization endpoint from the OIDC discovery document. Please check that the issuer URL is correct in the OIDC plugin settings.");let d=(0,f.generateCodeVerifier)(),e=await (0,f.generateCodeChallenge)(d),g=(0,f.generateState)(),h=(0,f.generateNonce)(),i=`${window.location.origin}/auth/callback`;localStorage.setItem("bl_last_server",a.trim()),sessionStorage.setItem(f.OIDC_SESSION_KEYS.state,g),sessionStorage.setItem(f.OIDC_SESSION_KEYS.nonce,h),sessionStorage.setItem(f.OIDC_SESSION_KEYS.codeVerifier,d),sessionStorage.setItem(f.OIDC_SESSION_KEYS.serverUrl,a.trim()),sessionStorage.setItem(f.OIDC_SESSION_KEYS.redirectUri,i),sessionStorage.setItem(f.OIDC_SESSION_KEYS.issuer,n);let j=(p.length?p:["openid"]).join(" "),k=new URLSearchParams({response_type:"code",client_id:l??"",redirect_uri:i,scope:j,state:g,nonce:h,code_challenge:e,code_challenge_method:"S256"});window.location.href=`${b}?${k.toString()}`}catch(a){h(a instanceof Error?a.message:"SSO login failed"),s(!1),i(!1)}}}return(!a.trim()&&j&&k(!1),(0,c.useEffect)(()=>{let b=a.trim();if(!b)return;let c=setTimeout(async()=>{if(t.current!==b){t.current=b;try{let a=await (0,e.getOidcPublicConfig)(b);a.enabled?(k(!0),m(a.clientId??void 0),o(a.issuer??void 0),q(a.scopes??[])):k(!1)}catch{k(!1)}}},500);return()=>clearTimeout(c)},[a]),j)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"relative flex items-center gap-3 py-1",children:[(0,b.jsx)("div",{className:"flex-1 border-t border-border"}),(0,b.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 shrink-0",children:"or"}),(0,b.jsx)("div",{className:"flex-1 border-t border-border"})]}),(0,b.jsx)(d.Button,{type:"button",onClick:u,disabled:g||r,className:"w-full bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 border border-border gap-2",children:r?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"w-4 h-4 border-2 border-border border-t-transparent rounded-full animate-spin"}),"Redirecting…"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("svg",{className:"w-4 h-4 text-gray-500",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("circle",{cx:"7.5",cy:"15.5",r:"5.5"}),(0,b.jsx)("path",{d:"m21 2-9.6 9.6"}),(0,b.jsx)("path",{d:"m15.5 7.5 3 3L22 7l-3-3"})]}),"Sign in with SSO"]})})]}):null}])}];

//# sourceMappingURL=plugins_oidc_1lm74na._.js.map