import{Bt as e,Ct as t,F as n,H as r,L as i,N as a,Nt as o,Pt as s,R as c,T as l,Vt as u,X as d,bt as f,ft as p,mt as m,ot as h,pt as g,r as _,tt as v,ut as y,vt as b,z as x}from"../chunks/xY0c-UfG.js";import"../chunks/xihTtKlq.js";import{J as S,Y as C}from"../chunks/BW-sf0N4.js";import{t as w}from"../chunks/Y1ENS0GB.js";import{t as T}from"../chunks/Cvnwo5OO.js";var E=x(`<div class="consent-loading svelte-1lrmsz1" role="status" aria-live="polite"><div class="consent-spinner svelte-1lrmsz1"></div> <span class="sr-only svelte-1lrmsz1">Loading…</span></div>`),D=x(`<span class="logo-text svelte-1lrmsz1"> </span>`),O=x(`<span class="logo-text svelte-1lrmsz1"> </span>`),k=x(`<p class="muted center svelte-1lrmsz1">This page can’t be displayed in an embedded frame.</p>`),A=x(`<p class="muted center svelte-1lrmsz1"> </p>`),j=x(`<p class="muted svelte-1lrmsz1"><strong> </strong> </p> <div class="grant svelte-1lrmsz1">It will be able to read and edit entries in the collections you can access, acting as you.</div> <form method="POST" action="/oauth/authorize" class="actions svelte-1lrmsz1"><!> <!></form> <p class="who svelte-1lrmsz1"> </p>`,1),M=x(`<div class="consent-page svelte-1lrmsz1"><div class="consent-card svelte-1lrmsz1"><div class="logo svelte-1lrmsz1"><img class="logo-mark svelte-1lrmsz1" src="/studiograph-logomark.svg" alt="" width="64" height="64"/> <!></div> <!></div></div>`);function N(x,N){s(N,!0);let P=t(()=>w.workspaceName||`Studiograph`),F=f(`loading`),I=f(null),L=f(`Authorization expired`),R=f(`This request is no longer valid. Please reconnect from the app.`);function z(e){e===`invalid_request`?(b(L,`Couldn’t authorize`),b(R,`This request is no longer valid. Please reconnect from the app.`)):(b(L,`Authorization expired`),b(R,`This request expired before it was approved. Please reconnect from the app.`)),b(F,`error`)}_(async()=>{if(typeof window<`u`&&window.top!==window.self){b(F,`framed`);return}let e=new URLSearchParams(window.location.search).get(`error`);if(e){z(e);return}try{b(I,await C(`/api/oauth/consent-context`),!0),b(F,`ready`)}catch(e){if(e instanceof S&&e.status===401)return;z(null)}});var B=c();l(`1lrmsz1`,e=>{v(()=>{y.title=`Authorize · ${d(P)??``}`})});var V=g(B),H=e=>{i(e,E())},U=t=>{var o=M(),s=p(o),c=p(s),l=m(p(c),2),f=e=>{var t=D(),r=p(t);u(t),h(()=>n(r,`Authorize ${d(I).client_name??``}`)),i(e,t)},_=e=>{var t=O(),r=p(t,!0);u(t),h(()=>n(r,d(L))),i(e,t)};a(l,e=>{d(I)?e(f):d(F)===`error`&&e(_,1)}),u(c);var v=m(c,2),y=e=>{i(e,k())},b=e=>{var t=A(),r=p(t,!0);u(t),h(()=>n(r,d(R))),i(e,t)},x=t=>{var a=j(),o=g(a),s=p(o),c=p(s,!0);u(s);var l=m(s);u(o);var f=m(o,4),_=p(f);T(_,{variant:`outline`,type:`submit`,name:`decision`,value:`deny`,class:`action-btn`,children:(t,n)=>{e(),i(t,r(`Cancel`))},$$slots:{default:!0}}),T(m(_,2),{variant:`accent`,type:`submit`,name:`decision`,value:`allow`,class:`action-btn`,children:(t,n)=>{e(),i(t,r(`Allow`))},$$slots:{default:!0}}),u(f);var v=m(f,2),y=p(v);u(v),h(()=>{n(c,d(I).client_name),n(l,` wants to connect to your ${d(P)??``} studio via MCP.`),n(y,`Signed in as ${d(I).user_label??``}`)}),i(t,a)};a(v,e=>{d(F)===`framed`?e(y):d(F)===`error`?e(b,1):d(I)&&e(x,2)}),u(s),u(o),i(t,o)};a(V,e=>{d(F)===`loading`?e(H):e(U,-1)}),i(x,B),o()}export{N as component};