import{s as e}from"./http-DKYHx80t.js";import{t}from"./select-CM1ofcjc.js";function n({stepUrl:e,labels:t}){return{progress:0,detail:t.preparing,error:null,running:!1,async run(){if(!this.running){this.running=!0,this.error=null;try{for(;;){let e=await this.step();if(!e.ok){this.error=e.error||t.failedTitle;break}if(typeof e.progress==`number`&&(this.progress=e.progress),e.detail&&(this.detail=e.detail),e.done){e.redirect&&window.location.assign(e.redirect);break}}}catch(e){this.error=e&&e.message?e.message:String(e)}finally{this.running=!1}}},async step(){let t=document.querySelector(`meta[name="csrf-token"]`)?.getAttribute(`content`)||``,n=await fetch(e,{method:`POST`,headers:{"X-CSRF-TOKEN":t,"X-Requested-With":`XMLHttpRequest`,Accept:`application/json`}});if(!n.ok){let e=`HTTP ${n.status}`;try{let t=await n.json();t&&t.error&&(e=t.error)}catch{}return{ok:!1,error:e}}return n.json()}}}function r({actionUrl:e,genericError:t}){return{submitting:!1,error:null,async submit(n){if(this.submitting)return;this.submitting=!0,this.error=null;let r=n.target,i=document.querySelector(`meta[name="csrf-token"]`)?.getAttribute(`content`)||``;try{let n=await fetch(e,{method:`POST`,headers:{"X-CSRF-TOKEN":i,"X-Requested-With":`XMLHttpRequest`,Accept:`application/json`},body:new FormData(r)}),a={};try{a=await n.json()}catch{}if(n.ok&&a.ok&&a.redirect){window.location.assign(a.redirect);return}this.error=a.error||t,this.submitting=!1}catch{this.error=t,this.submitting=!1}}}}e.data(`enhancedSelect`,t),e.data(`migrateRunner`,n),e.data(`installerDbForm`,r),window.Alpine=e,e.start();