import{$u as e,Ac as t,Bc as n,Cc as r,Dc as i,Ec as a,Fc as o,Gc as s,Hc as c,Ic as l,Lc as u,Mc as d,Nc as f,Oc as p,Pc as ee,Qu as m,Rc as h,Sc as g,Tc as _,Uc as v,Vc as y,Wc as te,_c as b,bc as x,gc as ne,hc as re,jc as S,kc as ie,nd as C,vc as ae,wc as oe,xc as se,yc as w,zc as ce}from"./messages-GNZRoNCJ.js";import{o as T}from"./auth-store-D6M2fL5v.js";import{t as le}from"./link-BzoLXRYo.js";import{i as E,r as ue,t as D}from"./button-CgehfZOz.js";import{n as de,r as fe,t as pe}from"./popover-CnFGTyhi.js";import{t as me}from"./createLucideIcon-ZOoxJGca.js";import{t as he}from"./check-Dk399u4y.js";import{t as ge}from"./chevron-down-BYS57rWz.js";import{t as _e}from"./circle-check-IaDmPO-c.js";import{n as O,t as ve}from"./copy-to-clipboard-CjEBFW-5.js";import{t as k}from"./eye-off-BajJjSPB.js";import{t as A}from"./eye-fodo-Mao.js";import{n as j,t as M}from"./theme-switch-CnUvKuRz.js";import{t as N}from"./loader-circle-BaCa54T8.js";import{t as P}from"./logo-dzDYxUEK.js";import{a as F,i as ye,o as be,r as xe,s as Se,t as Ce}from"./command-BVulVd11.js";import{t as we}from"./shield-check-CkFtGD8a.js";import{n as I}from"./dist-5drZch9N.js";import{c as L,n as R,s as Te}from"./zod-Ds1e9pAB.js";import{a as z,c as Ee,i as B,l as De,n as V,o as H,s as U,t as Oe}from"./form-CltVYR9l.js";import{t as W}from"./input-DVA35bJk.js";import{t as G}from"./badge-BPwdyK59.js";import{a as ke,i as Ae,n as je,r as Me,t as Ne}from"./card-CX4H25Jy.js";var Pe=me(`lock-keyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),Fe=C(ve(),1),K=C(e(),1),q=m(),Ie=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%&`,J=14,Y=20,Le={slow:400,medium:200,fast:80},X=e=>e[Math.floor(Math.random()*e.length)],Z=()=>Ie[Math.floor(Math.random()*41)];function Re({glitchColors:e=[`#2b4539`,`#61dca3`,`#61b3dc`],glitchSpeed:t=`medium`,centerVignette:n=!1,outerVignette:r=!0,smooth:i=!0,className:a}){let o=(0,K.useRef)(null),s=(0,K.useRef)(0),c=(0,K.useRef)([]),l=(0,K.useRef)(0),u=(0,K.useRef)(0),d=(0,K.useCallback)((t,n)=>{c.current=Array.from({length:t*n},()=>({char:Z(),color:X(e),opacity:Math.random()*.5+.1}))},[e]),f=(0,K.useCallback)(()=>{let e=o.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;t.clearRect(0,0,e.width,e.height),t.font=`${J}px monospace`;let n=c.current,r=l.current,i=u.current;for(let e=0;e{let t=c.current,n=t.length,r=Math.floor(n*.05);for(let a=0;a{let e=o.current;if(!e)return;let n=()=>{let t=e.parentElement;t&&(e.width=t.clientWidth,e.height=t.clientHeight,l.current=Math.ceil(e.width/Y),u.current=Math.ceil(e.height/Y),d(l.current,u.current),f())},r=new ResizeObserver(n);e.parentElement&&r.observe(e.parentElement),n();let i=setInterval(p,Le[t]);return()=>{r.disconnect(),clearInterval(i),cancelAnimationFrame(s.current)}},[p,f,d,t]),(0,q.jsxs)(`div`,{className:`absolute inset-0 overflow-hidden ${a??``}`,children:[(0,q.jsx)(`canvas`,{className:`absolute inset-0`,ref:o}),r&&(0,q.jsx)(`div`,{className:`absolute inset-0`,style:{background:`radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.85) 100%)`}}),n&&(0,q.jsx)(`div`,{className:`absolute inset-0`,style:{background:`radial-gradient(ellipse at center, rgba(0,0,0,0.6) 0%, transparent 70%)`}})]})}var Q=ue(`relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current`}},defaultVariants:{variant:`default`}});function ze({className:e,variant:t,...n}){return(0,q.jsx)(`div`,{className:E(Q({variant:t}),e),"data-slot":`alert`,role:`alert`,...n})}function Be({className:e,...t}){return(0,q.jsx)(`div`,{className:E(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),"data-slot":`alert-title`,...t})}function Ve({className:e,...t}){return(0,q.jsx)(`div`,{className:E(`col-start-2 grid justify-items-start gap-1 text-muted-foreground text-sm [&_p]:leading-relaxed`,e),"data-slot":`alert-description`,...t})}function He({value:e,onChange:t,options:n,placeholder:r=``,searchPlaceholder:i=`Search...`,emptyText:a=`No options found.`,className:o,disabled:s}){let[c,l]=(0,K.useState)(!1),u=n.map(e=>typeof e==`string`?{value:e,label:e}:e);return(0,q.jsxs)(pe,{onOpenChange:l,open:c,children:[(0,q.jsxs)(`div`,{className:E(`relative`,o),children:[(0,q.jsx)(W,{className:`pr-10`,disabled:s,onChange:e=>t(e.target.value),placeholder:r,value:e}),(0,q.jsx)(fe,{asChild:!0,children:(0,q.jsx)(D,{"aria-expanded":c,"aria-label":`Show options`,className:`absolute top-1/2 right-1 size-8 -translate-y-1/2`,disabled:s,size:`icon`,type:`button`,variant:`ghost`,children:(0,q.jsx)(ge,{className:`size-4`})})})]}),(0,q.jsx)(de,{align:`end`,className:`w-48 p-0`,children:(0,q.jsxs)(Ce,{children:[(0,q.jsx)(F,{placeholder:i}),(0,q.jsxs)(Se,{children:[(0,q.jsx)(xe,{children:a}),(0,q.jsx)(ye,{children:u.map(n=>(0,q.jsxs)(be,{onSelect:()=>{t(n.value),l(!1)},value:n.value,children:[(0,q.jsx)(he,{className:E(`size-4`,e===n.value?`opacity-100`:`opacity-0`)}),n.label??n.value]},n.value))})]})]})})]})}var Ue=[`0.0.0.0`,`127.0.0.1`,`localhost`];function We({form:e,loading:t,onSubmit:r,submitText:i}){return(0,q.jsx)(Oe,{...e,children:(0,q.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e.handleSubmit(r),children:[(0,q.jsx)(B,{control:e.control,name:`app_name`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:v()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`epusdt`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`app_uri`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsxs)(H,{children:[c(),` *`]}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`http://your-server-ip:8000`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsx)(B,{control:e.control,name:`http_bind_addr`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:y()}),(0,q.jsx)(V,{children:(0,q.jsx)(He,{onChange:e.onChange,options:Ue,placeholder:`0.0.0.0`,value:e.value??``})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`http_bind_port`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:n()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`8000`,type:`number`,...e,value:e.value??``})}),(0,q.jsx)(U,{})]})})]}),(0,q.jsx)(B,{control:e.control,name:`runtime_root_path`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:ce()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`./runtime`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`log_save_path`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:h()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`./logs`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsx)(B,{control:e.control,name:`order_expiration_time`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:u()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`10`,type:`number`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`order_notice_max_retry`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:l()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`1`,type:`number`,...e})}),(0,q.jsx)(U,{})]})})]}),(0,q.jsxs)(D,{className:`mt-2 w-full`,disabled:t,type:`submit`,children:[t?(0,q.jsx)(N,{className:`animate-spin`}):null,i]})]})})}function Ge({credentials:e,onCopy:t,onTogglePassword:n,showPassword:o}){return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`grid gap-4 rounded-2xl border border-emerald-500/20 bg-emerald-500/5 p-4 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-emerald-500/12 text-emerald-600 dark:text-emerald-400`,children:(0,q.jsx)(we,{className:`size-5`})}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`font-semibold text-base text-foreground`,children:i()}),e?(0,q.jsx)(G,{className:`rounded-md`,variant:`secondary`,children:_()}):null]}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm leading-6`,children:a()})]})]}),e?(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/85 p-4 shadow-sm`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(`p`,{className:`text-muted-foreground text-xs uppercase tracking-wide`,children:r()}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`min-w-0 flex-1 truncate font-medium text-base text-foreground`,children:e.username}),(0,q.jsxs)(D,{"aria-label":b(),className:`scale-95 rounded-full`,onClick:()=>t(e.username),size:`icon`,type:`button`,variant:`ghost`,children:[(0,q.jsx)(O,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:b()})]})]})]})}),(0,q.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/85 p-4 shadow-sm`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,q.jsx)(G,{className:`w-fit rounded-md border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-300`,variant:`outline`,children:se()}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`text-muted-foreground text-xs uppercase tracking-wide`,children:g()}),(0,q.jsxs)(G,{className:`rounded-md`,variant:`outline`,children:[(0,q.jsx)(Pe,{className:`size-3.5`}),ae()]})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`min-w-0 flex-1 break-all font-medium text-base text-foreground`,children:o?e.password:`•`.repeat(Math.max(e.password.length,10))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsxs)(D,{"aria-label":o?w():x(),className:`scale-95 rounded-full`,onClick:n,size:`icon`,type:`button`,variant:`ghost`,children:[o?(0,q.jsx)(k,{}):(0,q.jsx)(A,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:o?w():x()})]}),(0,q.jsxs)(D,{"aria-label":b(),className:`scale-95 rounded-full`,onClick:()=>t(e.password),size:`icon`,type:`button`,variant:`ghost`,children:[(0,q.jsx)(O,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:b()})]})]})]})]})})]}):null]}),(0,q.jsx)(D,{asChild:!0,className:`w-full`,type:`button`,children:(0,q.jsx)(le,{to:`/sign-in`,children:oe()})})]})}var Ke=Te({app_name:L().min(1,`App Name is required`),app_uri:L().min(1,`App URI is required`).url(`Must be a valid URL (e.g. http://your-server-ip:8000)`),http_bind_addr:L().min(1,`Bind address is required`),http_bind_port:R({error:`Port must be a number`}).int().min(1,`Port must be ≥ 1`).max(65535,`Port must be ≤ 65535`),runtime_root_path:L().min(1,`Runtime root path is required`),log_save_path:L().min(1,`Log save path is required`),order_expiration_time:R({error:`Must be a number`}).int().min(1,`Must be ≥ 1 minute`),order_notice_max_retry:R({error:`Must be a number`}).int().min(0,`Must be ≥ 0`)}),$={app_name:`epusdt`,app_uri:``,http_bind_addr:`0.0.0.0`,http_bind_port:8e3,runtime_root_path:`./runtime`,log_save_path:`./logs`,order_expiration_time:10,order_notice_max_retry:1};function qe(){let[e,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(!1),[a,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(null),[m,h]=(0,K.useState)(!1),g=De({resolver:Ee(Ke),defaultValues:$,mode:`onChange`});(0,K.useEffect)(()=>{let e=!0;async function t(){try{let{data:t}=await T.GET(`/api/install/defaults`);if(!(e&&t))return;let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==``&&e!=null));g.reset({...$,...n})}catch{}}return t().catch(()=>void 0),()=>{e=!1}},[g]);function _(e){if(!(0,Fe.default)(e)){I.error(re());return}I.success(ne())}async function v(e){n(!0),c(null);try{let{data:t,error:n,response:r}=await T.POST(`/api/install`,{body:e});if(!r.ok||n){c({variant:`destructive`,message:n?.error||S()});return}let a=null;try{let e=await T.GET(`/admin/api/v1/auth/init-password`);a={username:e.data?.data?.username?.trim()||`admin`,password:e.data?.data?.password?.trim()||``}}catch{a=null}i(!0),u(a),c({variant:`default`,message:t?.message||d()})}catch{c({variant:`destructive`,message:S()})}finally{n(!1)}}let y=o();return e&&(y=ee()),r&&(y=f()),(0,q.jsxs)(`div`,{className:`relative flex min-h-svh items-center justify-center px-4 py-10`,children:[(0,q.jsx)(Re,{centerVignette:!1,glitchColors:[`#3f3f46`,`#71717a`,`#a1a1aa`],glitchSpeed:`fast`,outerVignette:!1,smooth:!0}),(0,q.jsxs)(Ne,{className:`max-w-2xl border border-border/40 bg-card/55 shadow-xl backdrop-blur-xl`,children:[(0,q.jsxs)(Ae,{className:`space-y-6 border-border/40 border-b pb-8`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(P,{className:`size-10 shrink-0`}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`font-medium text-xl leading-tight`,children:`GMPay`}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-nowrap text-muted-foreground text-xs`,children:p()})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(j,{}),(0,q.jsx)(M,{})]})]}),r?null:(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(ke,{className:`text-2xl tracking-tight`,children:s()}),(0,q.jsx)(Me,{className:`max-w-xl text-sm leading-6`,children:te()})]})]}),(0,q.jsx)(je,{children:(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[a?(0,q.jsxs)(ze,{variant:a.variant,children:[a.variant===`default`?(0,q.jsx)(_e,{}):null,(0,q.jsx)(Be,{children:a.variant===`default`?t():ie()}),(0,q.jsx)(Ve,{children:a.message})]}):null,r?(0,q.jsx)(Ge,{credentials:l,onCopy:_,onTogglePassword:()=>h(e=>!e),showPassword:m}):(0,q.jsx)(We,{form:g,loading:e,onSubmit:v,submitText:y})]})})]})]})}var Je=qe;export{Je as component};