import{$ as e,C as t,D as n,E as r,I as i,L as ee,O as a,U as o,W as s,X as c,Z as te,_ as l,a as u,b as d,m as f,o as p,r as m,u as h,v as g,w as _,x as v}from"./app-QN0AU_xH.js";import{t as y}from"./i18n-Q2D3wWEQ.js";import{t as b}from"./AdminLayout-CZ2d25FZ.js";import{t as x}from"./UploadButton-sOlMy0lX.js";var S={key:0,class:`mb-5 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-300`},C={class:`grid gap-6 lg:grid-cols-2`},w={class:`rounded-2xl border border-line bg-surface p-6`},T={class:`mb-4 text-sm font-bold text-ink`},E={class:`block text-sm font-medium text-ink-2`},D={class:`flex items-center gap-3`},O={class:`text-sm text-ink-2`},k=[`disabled`],A={class:`mt-4 text-xs text-ink-muted`},j={class:`rounded-2xl border border-line bg-surface p-6`},M={class:`mb-1 text-sm font-bold text-ink`},N={class:`mb-4 text-xs text-ink-muted`},P={class:`flex flex-wrap items-center gap-3`},ne=[`src`],F={class:`mt-4`},I={class:`mt-6 rounded-2xl border border-line bg-surface p-6`},L={class:`text-sm font-bold text-ink`},R={class:`mt-1 text-xs text-ink-muted`},z={class:`mt-4 flex flex-wrap items-center gap-x-6 gap-y-2 text-sm`},B={class:`flex items-center gap-2`},V={class:`text-ink-2`},H={key:0,class:`font-mono text-xs text-ink-muted`},U={class:`text-ink-muted`},W={class:`mt-4`},G=[`disabled`],K={class:`mt-2 text-xs text-amber-500`},q=a({__name:`Pwa`,props:{values:{},icons:{},push:{}},setup(a){let q=a,J=p(),Y=d(()=>J.props.flash?.status),X=u({short_name:q.values.short_name,banner:q.values.banner});function Z(){X.post(`/admin/pwa`,{preserveScroll:!0})}let Q=u({icon:null});function re(e){Q.icon=e,Q.post(`/admin/pwa/icon`,{preserveScroll:!0,forceFormData:!0})}let $=u({});function ie(){let e=q.push.configured?y(`Generate new push keys? Every member with push enabled will need to turn it back on. Use this only if push is broken.`):y(`Generate push notification keys now?`);confirm(e)&&$.post(`/admin/pwa/vapid`,{preserveScroll:!0})}return(u,d)=>(i(),_(g,null,[n(c(m),{title:c(y)(`Admin · PWA`)},null,8,[`title`]),n(b,null,{title:o(()=>[r(e(c(y)(`Progressive Web App`)),1)]),subtitle:o(()=>[r(e(c(y)(`Install experience, icons & push`)),1)]),default:o(()=>[Y.value?(i(),_(`div`,S,e(Y.value),1)):t(``,!0),v(`div`,C,[v(`section`,w,[v(`h3`,T,e(c(y)(`Install settings`)),1),v(`form`,{class:`space-y-5`,onSubmit:l(Z,[`prevent`])},[v(`div`,null,[v(`label`,E,e(c(y)(`App short name (home-screen label)`)),1),s(v(`input`,{"onUpdate:modelValue":d[0]||=e=>c(X).short_name=e,type:`text`,maxlength:`30`,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-ink focus:border-indigo-500 focus:ring-indigo-500`},null,512),[[f,c(X).short_name]])]),v(`label`,D,[s(v(`input`,{"onUpdate:modelValue":d[1]||=e=>c(X).banner=e,type:`checkbox`,class:`rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500`},null,512),[[h,c(X).banner]]),v(`span`,O,e(c(y)(`Show the “install app” banner on supported devices`)),1)]),v(`button`,{type:`submit`,disabled:c(X).processing,class:`rounded-lg bg-indigo-500 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-600 disabled:opacity-60`},e(c(y)(`Save`)),9,k)],32),v(`p`,A,[r(e(c(y)(`The theme color comes from the brand color in`))+` `,1),v(`strong`,null,e(c(y)(`Theme`)),1),d[2]||=r(`.`,-1)])]),v(`section`,j,[v(`h3`,M,e(c(y)(`App icons`)),1),v(`p`,N,e(c(y)(`Upload one square image — every PWA/favicon size is generated automatically (WebP/PNG).`)),1),v(`div`,P,[(i(!0),_(g,null,ee(a.icons,e=>(i(),_(`img`,{key:e,src:e,class:`h-12 w-12 rounded-lg border border-line`,alt:``},null,8,ne))),128))]),v(`div`,F,[n(x,{uploading:c(Q).processing,label:c(y)(`Choose app icon`),accept:`image/png,image/jpeg,image/webp`,onFile:re},null,8,[`uploading`,`label`])])])]),v(`section`,I,[v(`h3`,L,e(c(y)(`Push notification keys (VAPID)`)),1),v(`p`,R,e(c(y)(`VAPID keys sign browser push notifications. They normally come from your server config — regenerate them here only if push has stopped working (e.g. corrupted keys).`)),1),v(`div`,z,[v(`span`,B,[v(`span`,{class:te([`h-2 w-2 rounded-full`,a.push.configured?`bg-emerald-500`:`bg-amber-500`])},null,2),v(`span`,V,e(a.push.configured?c(y)(`Push keys are configured`):c(y)(`No push keys yet`)),1)]),a.push.publicKey?(i(),_(`span`,H,e(c(y)(`Public key`))+`: `+e(a.push.publicKey),1)):t(``,!0),v(`span`,U,e(c(y)(`{n} device(s) subscribed`,{n:a.push.subscriptions})),1)]),v(`div`,W,[v(`button`,{type:`button`,disabled:c($).processing,class:`rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm font-semibold text-ink hover:bg-appbg disabled:opacity-60`,onClick:ie},e(c($).processing?c(y)(`Generating…`):a.push.configured?c(y)(`Regenerate push keys`):c(y)(`Generate push keys`)),9,G),v(`p`,K,e(c(y)(`Heads up: regenerating invalidates every existing subscription — members will have to re-enable push on their devices.`)),1)])])]),_:1})],64))}});export{q as default};