Pulse/frontend-modern/dist/assets/FirstRunSetup-wQBQ8FZA.js
2025-10-17 22:13:44 +00:00

19 lines
13 KiB
JavaScript

import{c as l,o as ve,S as U,t as m,i as s,a as b,b as N,d as j,e as R,m as V,f as _,s as D,g as we,h as $e,j as Se,k as _e}from"./index-cdElc049.js";var Ce=m('<div class=space-y-3><input type=password class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent"placeholder="Enter password (min 8 characters)"><input type=password class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent"placeholder="Confirm password">'),Pe=m('<div class="bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4"><p class="text-sm text-blue-700 dark:text-blue-300">A secure 16-character password will be generated for you. Make sure to save it when shown!'),Ae=m(`<div class=p-8><div class=space-y-6><div><label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Admin Username</label><input type=text class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent"placeholder=admin></div><div><label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Admin Password</label><div class="flex gap-2 mb-3"><button type=button>Generate Secure Password</button><button type=button>Set Custom Password</button></div></div><div><label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Theme Preference</label><div class="grid grid-cols-3 gap-2"><button type=button>System</button><button type=button>Light</button><button type=button>Dark</button></div><p class="text-xs text-gray-500 dark:text-gray-400 mt-2"></p></div><div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-4 space-y-2"><ul class="text-sm text-gray-600 dark:text-gray-400 space-y-1"><li class="flex items-start"><span class="text-green-500 mr-2">✓</span><span>Your admin account will be created</span></li><li class="flex items-start"><span class="text-green-500 mr-2">✓</span><span>An API token will be generated for automation</span></li><li class="flex items-start"><span class="text-green-500 mr-2">✓</span><span>All API endpoints will be protected</span></li><li class="flex items-start"><span class="text-green-500 mr-2">✓</span><span>You'll need to login to access the dashboard</span></li></ul></div><button type=button class="w-full py-3 px-4 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 text-white rounded-lg font-medium transition-colors disabled:cursor-not-allowed">`),Te=m(`<div class=p-8><div class="text-center mb-6"><div class="w-16 h-16 bg-green-100 dark:bg-green-900/50 rounded-full flex items-center justify-center mx-auto mb-4"><svg class="w-8 h-8 text-green-600 dark:text-green-400"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M5 13l4 4L19 7"></path></svg></div><p class="text-gray-600 dark:text-gray-400">Save your credentials now - they won't be shown again</p></div><div class=space-y-4><div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-4"><label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Username</label><div class="font-mono text-lg text-gray-900 dark:text-gray-100"></div></div><div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-4"><label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Password</label><div class="flex items-center justify-between"><code class="font-mono text-lg text-gray-900 dark:text-gray-100 break-all"></code><button type=button class="ml-2 p-2 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors"title="Copy password"></button></div></div><div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-4"><label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">API Token (for automation)</label><div class="flex items-center justify-between"><code class="font-mono text-sm text-gray-900 dark:text-gray-100 break-all"></code><button type=button class="ml-2 p-2 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors"title="Copy token"></button></div></div><div class="bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4"><p class="text-sm font-semibold text-amber-800 dark:text-amber-200 mb-1">⚠️ Important</p><p class="text-xs text-amber-700 dark:text-amber-300">These credentials will never be shown again. Save them in a password manager now!</p></div><div class="flex gap-3"><button type=button class="flex-1 py-3 px-4 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg font-medium transition-colors flex items-center justify-center gap-2"><svg class="w-5 h-5"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>Download Credentials</button><button type=button class="flex-1 py-3 px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors">Continue to Login`),Ee=m(`<div class="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4"><div class="w-full max-w-2xl"><div class="text-center mb-8"><div class="flex items-center justify-center gap-2 mb-4"><svg width=48 height=48 viewBox="0 0 256 256"xmlns=http://www.w3.org/2000/svg class=pulse-logo><title>Pulse Logo</title><circle class="pulse-bg fill-blue-600 dark:fill-blue-500"cx=128 cy=128 r=122></circle><circle class="pulse-ring fill-none stroke-white stroke-[14] opacity-[0.92]"cx=128 cy=128 r=84></circle><circle class="pulse-center fill-white dark:fill-[#dbeafe]"cx=128 cy=128 r=26></circle></svg><span class="text-4xl font-bold text-gray-800 dark:text-gray-100">Pulse</span></div><p class="text-gray-600 dark:text-gray-400">Let's set up your monitoring dashboard</p></div><div class="bg-white dark:bg-gray-800 rounded-xl shadow-2xl overflow-hidden">`),le=m('<svg class="w-5 h-5 text-green-600"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M5 13l4 4L19 7">'),oe=m('<svg class="w-5 h-5 text-gray-600 dark:text-gray-400"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3">');const Ie=()=>{const[O,ne]=l("admin"),[p,ie]=l(""),[Y,de]=l(""),[i,W]=l(!1),[ce,ge]=l(""),[,ue]=l(""),[q,J]=l(!1),[X,be]=l(!1),[Q,me]=l(""),[B,pe]=l(""),[C,ye]=l(""),[Z,ee]=l(null),[v,y]=l("system"),K=t=>{t==="light"?(document.documentElement.classList.remove("dark"),localStorage.setItem(U.DARK_MODE,"false")):t==="dark"?(document.documentElement.classList.add("dark"),localStorage.setItem(U.DARK_MODE,"true")):(localStorage.removeItem(U.DARK_MODE),window.matchMedia("(prefers-color-scheme: dark)").matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))};ve(()=>{const t=localStorage.getItem(U.DARK_MODE);t==="false"?(y("light"),document.documentElement.classList.remove("dark")):t==="true"?(y("dark"),document.documentElement.classList.add("dark")):(y("system"),window.matchMedia("(prefers-color-scheme: dark)").matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))});const xe=()=>{const t="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%";let r="";for(let a=0;a<16;a++)r+=t.charAt(Math.floor(Math.random()*t.length));return r},he=()=>{const t=new Uint8Array(24);return crypto.getRandomValues(t),Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")},ke=async()=>{if(i()){if(!p()){D("Please enter a password");return}if(p()!==Y()){D("Passwords do not match");return}if(p().length<8){D("Password must be at least 8 characters");return}}J(!0);const t=i()?p():xe();i()||ge(t);const r=he();ue(r);try{const a=await fetch("/api/security/quick-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:O(),password:t,apiToken:r})});if(!a.ok){const c=await a.text();throw new Error(c||"Failed to setup security")}if((await a.json()).skipped){window.location.reload();return}me(O()),pe(i()?p():ce()),ye(r);const d={id:"bootstrap-token",name:"Bootstrap token",prefix:r.slice(0,6),suffix:r.slice(-4),createdAt:new Date().toISOString()};we({token:r,record:d,source:"first-run",note:"Copy this bootstrap token now. It unlocks API access for agents and automations."}),be(!0),$e("Security configured successfully!")}catch(a){D(`Failed to setup security: ${a}`)}finally{J(!1)}},te=async t=>{const r=t==="password"?B():C();await Se(r)&&(ee(t),setTimeout(()=>ee(null),2e3))},fe=()=>{const t=`Pulse Security Credentials
========================
Generated: ${new Date().toISOString()}
Web Interface Login:
-------------------
URL: ${window.location.origin}
Username: ${Q()}
Password: ${B()}
API Access:
-----------
API Token: ${C()}
Example API Usage:
curl -H "X-API-Token: ${C()}" ${window.location.origin}/api/state
IMPORTANT: Keep these credentials secure!
`,r=new Blob([t],{type:"text/plain"}),a=URL.createObjectURL(r),o=document.createElement("a");o.href=a,o.download=`pulse-credentials-${Date.now()}.txt`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)};return(()=>{var t=Ee(),r=t.firstChild,a=r.firstChild,o=a.nextSibling;return s(o,b(j,{get when(){return!X()},get children(){var d=Ae(),c=d.firstChild,P=c.firstChild,H=P.firstChild,A=H.nextSibling,u=P.nextSibling,z=u.firstChild,G=z.nextSibling,x=G.firstChild,T=x.nextSibling,E=u.nextSibling,L=E.firstChild,w=L.nextSibling,h=w.firstChild,$=h.nextSibling,I=$.nextSibling,M=w.nextSibling,k=E.nextSibling,F=k.firstChild,S=k.nextSibling;return s(d,b(N,{title:"Initial security setup",size:"lg",class:"mb-6",titleClass:"text-gray-800 dark:text-gray-100"}),c),A.$$input=e=>ne(e.currentTarget.value),x.$$click=()=>W(!1),T.$$click=()=>W(!0),s(u,b(j,{get when(){return i()},get children(){var e=Ce(),g=e.firstChild,n=g.nextSibling;return g.$$input=f=>ie(f.currentTarget.value),n.$$input=f=>de(f.currentTarget.value),R(()=>g.value=p()),R(()=>n.value=Y()),e}}),null),s(u,b(j,{get when(){return!i()},get children(){return Pe()}}),null),h.$$click=()=>{y("system"),K("system")},$.$$click=()=>{y("light"),K("light")},I.$$click=()=>{y("dark"),K("dark")},s(M,(()=>{var e=V(()=>v()==="system");return()=>e()?"Using your operating system theme preference":`Using ${v()} mode`})()),s(k,b(N,{title:"What happens next",size:"sm",titleClass:"text-gray-800 dark:text-gray-200"}),F),S.$$click=ke,s(S,()=>q()?"Setting up...":"Complete Setup"),R(e=>{var g=`flex-1 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${i()?"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600":"bg-blue-600 text-white"}`,n=`flex-1 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${i()?"bg-blue-600 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600"}`,f=`py-2 px-4 rounded-lg text-sm font-medium transition-colors ${v()==="system"?"bg-blue-600 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600"}`,re=`py-2 px-4 rounded-lg text-sm font-medium transition-colors ${v()==="light"?"bg-blue-600 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600"}`,ae=`py-2 px-4 rounded-lg text-sm font-medium transition-colors ${v()==="dark"?"bg-blue-600 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600"}`,se=q();return g!==e.e&&_(x,e.e=g),n!==e.t&&_(T,e.t=n),f!==e.a&&_(h,e.a=f),re!==e.o&&_($,e.o=re),ae!==e.i&&_(I,e.i=ae),se!==e.n&&(S.disabled=e.n=se),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),R(()=>A.value=O()),d}}),null),s(o,b(j,{get when(){return X()},get children(){var d=Te(),c=d.firstChild,P=c.firstChild,H=P.nextSibling,A=c.nextSibling,u=A.firstChild,z=u.firstChild,G=z.nextSibling,x=u.nextSibling,T=x.firstChild,E=T.nextSibling,L=E.firstChild,w=L.nextSibling,h=x.nextSibling,$=h.firstChild,I=$.nextSibling,M=I.firstChild,k=M.nextSibling,F=h.nextSibling,S=F.nextSibling,e=S.firstChild,g=e.nextSibling;return s(c,b(N,{title:"Setup complete!",size:"lg",class:"mb-2",align:"center",titleClass:"text-gray-800 dark:text-gray-100"}),H),s(G,Q),s(L,B),w.$$click=()=>te("password"),s(w,(()=>{var n=V(()=>Z()==="password");return()=>n()?le():oe()})()),s(M,C),k.$$click=()=>te("token"),s(k,(()=>{var n=V(()=>Z()==="token");return()=>n()?le():oe()})()),e.$$click=fe,g.$$click=()=>window.location.reload(),d}}),null),t})()};_e(["input","click"]);export{Ie as FirstRunSetup};