import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_async.js";import*as e from"./svelte/svelte_internal_client.js";import"./i18n-CqG9A4Dp.js";import"./svelte/svelte_svelte.js";import{B as A}from"./BaseForm-Cq4NTR3O.js";import{BaseTextbox as q}from"./Index-CeuKWERY.js";import{B as E}from"./Button-BRi4buhz.js";import{B as G}from"./Index.svelte_svelte_type_style_lang-Du1gSE01.js";import{B as D}from"./ScrollFade-DGw40oqj.js";import"./svelte/svelte_store.js";import"./index-aMLoRFR_.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";import"./StreamingBar-Hli-vaRZ.js";import"./MarkdownCode-VTUoaX6K.js";import"./prism-python-BRxZ6l4O.js";import"./utils.svelte-kG009vb9.js";import"./Example-gF45j9DF.js";import"./Image-Bdf4wQSw.js";import"./ImagePreview-BMFpVSQw.js";import"./ShareButton-LQS1LEKZ.js";import"./FullscreenButton-C4AREqtB.js";var H=e.from_html('<p class="auth svelte-14xt79u"><!></p>'),I=e.from_html('<p class="auth svelte-14xt79u"> </p>'),J=e.from_html('<p class="creds svelte-14xt79u"> </p>'),K=e.from_html("<!> <!>",1),M=e.from_html('<h2 class="svelte-14xt79u"> </h2> <!> <!> <!> <!> <!>',1),N=e.from_html("<div><!></div>");function Te(F,i){e.push(i,!1);let p=e.prop(i,"root",12),m=e.prop(i,"auth_message",12),c=e.prop(i,"app_mode",12),f=e.prop(i,"space_id",12),a=e.prop(i,"i18n",12),_=e.mutable_source(""),u=e.mutable_source(""),$=e.mutable_source(!1);const v=async()=>{const r=new FormData;r.append("username",e.get(_)),r.append("password",e.get(u));const k=new URL("login",p().endsWith("/")?p():p()+"/").href;let n=await fetch(k,{method:"POST",body:r});n.status===400?(e.set($,!0),e.set(_,""),e.set(u,"")):n.status==200&&location.reload()};var L={get root(){return p()},set root(r){p(r),e.flush()},get auth_message(){return m()},set auth_message(r){m(r),e.flush()},get app_mode(){return c()},set app_mode(r){c(r),e.flush()},get space_id(){return f()},set space_id(r){f(r),e.flush()},get i18n(){return a()},set i18n(r){a(r),e.flush()}};e.init();var d=N();let w;var z=e.child(d);return G(z,{variant:"panel",min_width:480,children:(r,k)=>{var n=M(),g=e.first_child(n),C=e.child(g,!0);e.reset(g);var B=e.sibling(g,2);{var O=t=>{var s=H(),o=e.child(s);e.html(o,m),e.reset(s),e.append(t,s)};e.if(B,t=>{m()&&t(O)})}var y=e.sibling(B,2);{var R=t=>{var s=I(),o=e.child(s,!0);e.reset(s),e.template_effect(l=>e.set_text(o,l),[()=>(e.deep_read_state(a()),e.untrack(()=>a()("login.enable_cookies")))]),e.append(t,s)};e.if(y,t=>{f()&&t(R)})}var P=e.sibling(y,2);{var S=t=>{var s=J(),o=e.child(s,!0);e.reset(s),e.template_effect(l=>e.set_text(o,l),[()=>(e.deep_read_state(a()),e.untrack(()=>a()("login.incorrect_credentials")))]),e.append(t,s)};e.if(P,t=>{e.get($)&&t(S)})}var T=e.sibling(P,2);A(T,{children:(t,s)=>{var o=K(),l=e.first_child(o);D(l,{children:(h,j)=>{{let x=e.derived_safe_equal(()=>(e.deep_read_state(a()),e.untrack(()=>a()("login.username"))));q(h,{get label(){return e.get(x)},lines:1,show_label:!0,max_lines:1,onsubmit:v,get value(){return e.get(_)},set value(b){e.set(_,b)},$$legacy:!0})}},$$slots:{default:!0}});var W=e.sibling(l,2);D(W,{children:(h,j)=>{{let x=e.derived_safe_equal(()=>(e.deep_read_state(a()),e.untrack(()=>a()("login.password"))));q(h,{get label(){return e.get(x)},lines:1,show_label:!0,max_lines:1,type:"password",onsubmit:v,get value(){return e.get(u)},set value(b){e.set(u,b)},$$legacy:!0})}},$$slots:{default:!0}}),e.append(t,o)},$$slots:{default:!0}});var U=e.sibling(T,2);E(U,{size:"lg",variant:"primary",onclick:v,children:(t,s)=>{e.next();var o=e.text();e.template_effect(l=>e.set_text(o,l),[()=>(e.deep_read_state(a()),e.untrack(()=>a()("login.login")))]),e.append(t,o)},$$slots:{default:!0}}),e.template_effect(t=>e.set_text(C,t),[()=>(e.deep_read_state(a()),e.untrack(()=>a()("login.login")))]),e.append(r,n)},$$slots:{default:!0}}),e.reset(d),e.template_effect(()=>w=e.set_class(d,1,"wrap svelte-14xt79u",null,w,{"min-h-screen":c()})),e.append(F,d),e.pop(L)}export{Te as default};
