import{a as d,f as u,i as Q,s as D}from"../chunks/3MMtouT7.js";import{c as v,g as e,r as c,t as U,p as be,v as Ce,d as g,q as Oe,N as De,z as J,b as t,w as x,s as b,$ as je,A as we}from"../chunks/Ce0VRwE1.js";import{e as xe,l as Le,s as W,i as $e,a as Je,B as F,I as ie,c as se,b as Me,d as Ee}from"../chunks/BTu-2gkj.js";import{h as Fe}from"../chunks/DFPEaIHz.js";import{A as Ge}from"../chunks/DzuS5Nbr.js";import{i as ze}from"../chunks/gQJcRhou.js";import"../chunks/BCwT4WOg.js";import{P as Ve}from"../chunks/pRcLbE0d.js";var He=u("<div><!></div>"),We=u("<div></div>");function Xe(h,o){var f=We();xe(f,21,()=>o.steps,$e,(s,w,l)=>{var S=He();let i;var I=v(S);Le(I,{get onclick(){return o.onhandleStepClick},get label(){return e(w).label},get icon(){return e(w).icon},stepIndex:l+1}),c(S),U(()=>i=W(S,1,"step-container svelte-vrgjs2",null,i,{"active-step":o.currentStepIndex===l,"completed-step":o.currentStepIndex>l})),d(s,S)}),c(f),U(()=>W(f,1,`container ${o.classes??""??""}`,"svelte-vrgjs2")),d(h,f)}var Ye=u('<div class="card-description svelte-qdre9c"> </div>'),Ze=u('<div class="card-header svelte-qdre9c"><div class="card-title svelte-qdre9c"> </div> <!></div>'),et=u('<div><!> <div class="card-content svelte-qdre9c"><!></div></div>');function G(h,o){be(o,!0);var f=et(),s=v(f);{var w=i=>{var I=Ze(),q=v(I),j=v(q,!0);c(q);var L=g(q,2);{var B=T=>{var M=Ye(),z=v(M,!0);c(M),U(()=>D(z,o.description)),d(T,M)};Q(L,T=>{typeof o.description=="string"&&o.description.length>0&&T(B)})}c(I),U(()=>D(j,o.title)),d(i,I)};Q(s,i=>{typeof o.title=="string"&&o.title.length>0&&i(w)})}var l=g(s,2),S=v(l);Je(S,()=>o.children),c(l),c(f),U(()=>W(f,1,`card ${o.classes??""??""}`,"svelte-qdre9c")),d(h,f),Ce()}function H(h){return h instanceof Error?h.message:typeof h=="string"?h:String(h)}function tt(){return Pe()!==null}async function rt(){const h=Pe();if(!h)throw new Error("Scanner not available");return h()}function Pe(){if(typeof window>"u")return null;const h=window.ShooterBridge?.scanner;if(h&&typeof h.scan=="function")return()=>h.scan();const o=window.ShooterNativeBridge?.scanner;return o&&typeof o.scan=="function"?()=>o.scan():null}const Se=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
  <polyline points="22 4 12 14.01 9 11.01"/>
</svg>
`,nt=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <polygon points="5 3 19 12 5 21 5 3"/>
</svg>
`,ke=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <circle cx="12" cy="12" r="10"/>
  <line x1="15" y1="9" x2="9" y2="15"/>
  <line x1="9" y1="9" x2="15" y2="15"/>
</svg>
`;var at=u('<meta name="description" content="Configure notification system settings"/>'),ot=u(`<!> <!> <p class="input-help svelte-1gp6n77">Find this in your <code class="svelte-1gp6n77">~/.shooter/.env</code> file. Run <code class="svelte-1gp6n77">shooter setup</code> to generate
            one.</p> <!> <p class="input-help svelte-1gp6n77">Optional — only needed for iOS/Android push notifications.</p>`,1),it=u("<!> Test Connection",1),st=u(`<p class="qr-description svelte-1gp6n77">Scan the QR code shown on your server's settings page to auto-configure the
                connection.</p> <!>`,1),ct=u('<p class="qr-server-url svelte-1gp6n77">Server: <code class="svelte-1gp6n77"> </code></p>'),lt=u('<div class="qr-container svelte-1gp6n77"><img alt="QR code for mobile app pairing" class="qr-image svelte-1gp6n77"/></div> <p class="qr-hint svelte-1gp6n77">Scan this QR code with the Shooter iOS or Android app to connect.</p> <!>',1),dt=u('<div class="qr-placeholder svelte-1gp6n77"><p class="qr-loading-text svelte-1gp6n77">Generating QR code...</p></div>'),vt=u('<p class="qr-error svelte-1gp6n77"> </p>'),ut=u(`<p class="qr-description svelte-1gp6n77">Generate a QR code containing your server URL and API key. Your mobile app can
                  scan it to auto-configure the connection.</p>`),gt=u("<!> <!>",1),ft=u('<div class="qr-section svelte-1gp6n77"><!></div>'),pt=u('<div class="provider-row svelte-1gp6n77"><!> <span class="provider-label svelte-1gp6n77"> </span> <span> </span></div>'),ht=u('<div class="active-provider svelte-1gp6n77">Active: <strong> </strong></div>'),mt=u('<div class="active-provider svelte-1gp6n77">Auto-detected from configured keys</div>'),yt=u('<p class="ai-help svelte-1gp6n77">Run <code class="svelte-1gp6n77">shooter setup</code> to configure AI providers for summaries.</p>'),_t=u('<div class="ai-providers svelte-1gp6n77"><!> <!></div>'),wt=u('<p class="danger-description svelte-1gp6n77">Clear all saved configuration data from this device.</p> <!>',1),St=u('<main class="main"><div class="settings-container svelte-1gp6n77"><div style="margin-bottom: var(--space-4);"><a href="/" class="back-link">← Back to Projects</a></div> <div class="page-header"><h1 class="page-title">Settings</h1> <p class="page-description">Configure your API credentials and notification preferences</p></div> <div class="settings-grid svelte-1gp6n77"><section class="settings-section svelte-1gp6n77"><!> <!> <div class="button-group svelte-1gp6n77"><!> <!></div></section> <aside class="settings-sidebar svelte-1gp6n77"><!> <!> <!> <!></aside></div></div></main>');function qt(h,o){be(o,!0);let f=b(""),s=b(""),w=b(""),l=b(""),S=b(!1),i=b(""),I=b(!1),q=b(""),j=b(""),L=b(!1),B=b(""),T=b(!1),M=b(!1),z=!1,V=b(!1);async function Re(){if(!e(s).trim()){t(B,"Save an API key first to generate a QR code");return}t(L,!0),t(B,""),t(q,""),t(j,"");try{const r=await fetch("/api/qr-config",{headers:{Authorization:`Bearer ${e(s).trim()}`}});if(!r.ok){const a=await r.json();t(B,a.error||"Failed to generate QR code",!0);return}const n=await r.json();t(q,n.dataUrl,!0),t(j,n.serverUrl,!0)}catch(r){t(B,`Network error: ${H(r)}`)}finally{t(L,!1)}}async function Ue(){t(V,!0),t(l,""),t(i,"");try{const r=await rt();try{const n=JSON.parse(r);typeof n.serverUrl=="string"&&n.serverUrl&&t(f,n.serverUrl,!0),typeof n.apiKey=="string"&&n.apiKey&&t(s,n.apiKey,!0),await Z();const a=e(i);a!=="error"&&a!=="warning"&&(t(l,"Configuration updated from QR code"),t(i,"success"))}catch{t(l,"Invalid QR code data"),t(i,"error")}}catch(r){const n=H(r);n!=="cancelled"&&(t(l,`Scanner error: ${n}`),t(i,"error"))}finally{t(V,!1)}}function X(){return typeof window>"u"?null:window.ShooterBridge?window.ShooterBridge:window.ShooterNativeBridge?window.ShooterNativeBridge:null}function Y(){return window.location.origin}function ce(){const r=X();if(r&&!z){t(I,!0);try{const n=JSON.parse(r.getConfig?.()??"{}");n.serverUrl&&t(f,n.serverUrl,!0),n.apiKey&&t(s,n.apiKey,!0);const a=r.getFcmToken?.();a&&t(w,a,!0),z=!0}catch{}}t(T,tt(),!0)}Oe(()=>{{const r=window.location.hash.slice(1);if(r){const n=new URLSearchParams(r),a=n.get("key"),p=n.get("url");a&&(t(s,a,!0),p&&t(f,p,!0),Z(),window.history.replaceState({},"",window.location.pathname))}if(!e(s))try{const n=localStorage.getItem("shooter_config");if(n){const a=JSON.parse(n);ze(a)?(a.apiKey&&t(s,a.apiKey,!0),a.deviceToken&&t(w,a.deviceToken,!0),a.serverUrl&&t(f,a.serverUrl,!0)):localStorage.removeItem("shooter_config")}}catch{}if(ce(),e(f)||t(f,Y(),!0),t(M,!0),!e(T)){const n=setInterval(()=>{ce(),e(T)&&clearInterval(n)},200);setTimeout(()=>{clearInterval(n)},3e3)}}});async function Z(){t(S,!0),t(l,""),t(i,"");try{const r=e(f).trim().replace(/\/+$/,"");localStorage.setItem("shooter_config",JSON.stringify({apiKey:e(s).trim(),deviceToken:e(w).trim(),lastUpdated:Date.now(),serverUrl:r||Y()}));const n=X();n&&n.saveConfig?.(JSON.stringify({apiKey:e(s).trim(),serverUrl:r||Y()})),(await fetch("/api/health")).ok?(t(l,"Configuration saved successfully"),t(i,"success")):(t(l,"Configuration saved but system health check failed"),t(i,"warning"))}catch(r){t(l,`Configuration failed: ${H(r)}`),t(i,"error")}t(S,!1)}async function Ie(){if(!e(s).trim()){t(l,"API key is required for testing"),t(i,"error");return}t(S,!0),t(l,""),t(i,"");try{const r={data:{source:"config-test",timestamp:Date.now()},message:`Configuration test at ${new Date().toLocaleTimeString()}`,title:"Configuration Test"};e(w).trim()&&(r.deviceToken=e(w).trim());const n=await fetch("/api/notify",{body:JSON.stringify(r),headers:{Authorization:`Bearer ${e(s)}`,"Content-Type":"application/json"},method:"POST"}),a=await n.json();n.ok?(t(l,"Test notification sent successfully"),t(i,"success")):(t(l,`Test failed: ${typeof a.error=="string"?a.error:"Unknown error"}`),t(i,"error"))}catch(r){t(l,`Network error: ${H(r)}`),t(i,"error")}t(S,!1)}function qe(){{localStorage.removeItem("shooter_config"),t(f,typeof window<"u"?window.location.origin:"",!0),t(s,""),t(w,""),t(l,"Configuration cleared"),t(i,"success");const r=X();r&&r.saveConfig?.(JSON.stringify({apiKey:"",serverUrl:""}))}}var ee=St();Fe("1gp6n77",r=>{var n=at();De(()=>{je.title="Settings - Shooter"}),d(r,n)});var le=v(ee),de=g(v(le),4),te=v(de),ve=v(te);G(ve,{title:"Server Configuration",description:"Configure server connection and credentials",children:(r,n)=>{var a=ot(),p=J(a);ie(p,{name:"serverUrl",label:"Server URL",dataType:"text",placeholder:"https://shooter.breezehq.dev",infoMessage:"Base URL of your Shooter server. Apps will reload with this URL on next launch.",get value(){return e(f)},set value(C){t(f,C,!0)}});var P=g(p,2);ie(P,{name:"apiKey",label:"API Key",dataType:"password",placeholder:"Enter your API key",infoMessage:"Required for sending notifications",get value(){return e(s)},set value(C){t(s,C,!0)}});var K=g(P,4);{let C=x(()=>e(I)?"Waiting for token...":"64-character hex string"),R=x(()=>e(I)&&e(w)?"Auto-detected from app":"Device token from app registration");ie(K,{name:"deviceToken",label:"Device Token",dataType:"text",get placeholder(){return e(C)},get infoMessage(){return e(R)},classes:"input-mono",get value(){return e(w)},set value(A){t(w,A,!0)}})}we(2),d(r,a)},$$slots:{default:!0}});var ue=g(ve,2);{var Te=r=>{const n=x(()=>e(i)==="success"?Se:e(i)==="error"?ke:Ge);{const a=P=>{se(P,{get svg(){return e(n)},classes:"icon-16"})};let p=x(()=>e(i)||"info");Me(r,{get text(){return e(l)},get classes(){return`banner-${e(p)??""}`},icon:a,$$slots:{icon:!0}})}};Q(ue,r=>{e(l)&&r(Te)})}var ge=g(ue,2),fe=v(ge);{let r=x(()=>e(S)||!e(s).trim());F(fe,{classes:"btn-secondary",onclick:Ie,get disabled(){return e(r)},children:(n,a)=>{var p=it(),P=J(p);{var K=C=>{se(C,{get svg(){return nt},classes:"icon-14"})};Q(P,C=>{e(S)||C(K)})}we(),d(n,p)},$$slots:{default:!0}})}var Ae=g(fe,2);{let r=x(()=>e(S)||!e(s).trim());F(Ae,{classes:"btn-primary",onclick:Z,get disabled(){return e(r)},get showLoader(){return e(S)},text:"Save Changes"})}c(ge),c(te);var pe=g(te,2),he=v(pe);G(he,{title:"Setup Guide",children:(r,n)=>{{let a=x(()=>e(s).trim()&&e(w).trim()?2:e(s).trim()?1:0);Xe(r,{steps:[{label:"Get API Key"},{label:"Find Device Token"},{label:"Test Connection"}],get currentStepIndex(){return e(a)},classes:"setup-stepper"})}},$$slots:{default:!0}});var me=g(he,2);{let r=x(()=>e(T)?"Scan a QR code to connect":"Scan to connect your mobile app");G(me,{title:"Mobile App Setup",get description(){return e(r)},children:(n,a)=>{var p=ft(),P=v(p);{var K=R=>{var A=st(),m=g(J(A),2);{let _=x(()=>e(V)?"Scanning...":"Scan QR Code");F(m,{classes:"btn-secondary btn-sm",onclick:Ue,get disabled(){return e(V)},get text(){return e(_)}})}d(R,A)},C=R=>{var A=gt(),m=J(A);{var _=y=>{var k=lt(),O=J(k),ne=v(O);c(O);var Ne=g(O,4);{var Qe=ae=>{var oe=ct(),_e=g(v(oe)),Ke=v(_e,!0);c(_e),c(oe),U(()=>D(Ke,e(j))),d(ae,oe)};Q(Ne,ae=>{e(j)&&ae(Qe)})}U(()=>Ee(ne,"src",e(q))),d(y,k)},N=y=>{var k=dt();d(y,k)},$=y=>{var k=vt(),O=v(k,!0);c(k),U(()=>D(O,e(B))),d(y,k)},E=y=>{var k=ut();d(y,k)};Q(m,y=>{e(q)?y(_):e(L)?y(N,1):e(B)?y($,2):y(E,-1)})}var re=g(m,2);{let y=x(()=>e(L)||!e(s).trim()),k=x(()=>e(q)?"Regenerate QR Code":"Generate QR Code");F(re,{classes:"btn-secondary btn-sm",onclick:Re,get disabled(){return e(y)},get text(){return e(k)}})}d(R,A)};Q(P,R=>{e(T)?R(K):R(C,-1)})}c(p),d(n,p)},$$slots:{default:!0}})}var ye=g(me,2);G(ye,{title:"AI Providers",description:"NeuroLink-powered summaries and AI features",children:(r,n)=>{var a=_t(),p=v(a);xe(p,17,()=>Ve,m=>m.id,(m,_)=>{var N=pt(),$=v(N);{let ne=x(()=>o.data.aiProviders[e(_).id]?Se:ke);se($,{get svg(){return e(ne)},classes:"icon-14"})}var E=g($,2),re=v(E,!0);c(E);var y=g(E,2);let k;var O=v(y,!0);c(y),c(N),U(()=>{D(re,e(_).label),k=W(y,1,"provider-status svelte-1gp6n77",null,k,{configured:o.data.aiProviders[e(_).id]}),D(O,o.data.aiProviders[e(_).id]?"configured":"not configured")}),d(m,N)});var P=g(p,2);{var K=m=>{var _=ht(),N=g(v(_)),$=v(N,!0);c(N),c(_),U(()=>D($,o.data.activeProvider)),d(m,_)},C=m=>{var _=mt();d(m,_)},R=x(()=>Object.values(o.data.aiProviders).some(Boolean)),A=m=>{var _=yt();d(m,_)};Q(P,m=>{o.data.activeProvider?m(K):e(R)?m(C,1):m(A,-1)})}c(a),d(r,a)},$$slots:{default:!0}});var Be=g(ye,2);G(Be,{title:"Danger Zone",children:(r,n)=>{var a=wt(),p=g(J(a),2);F(p,{classes:"btn-danger btn-sm",onclick:qe,text:"Clear Configuration"}),d(r,a)},$$slots:{default:!0}}),c(pe),c(de),c(le),c(ee),d(h,ee),Ce()}export{qt as component};
