import{C as e,D as t,E as n,G as r,L as i,Q as ee,R as a,W as o,Z as s,_ as te,a as c,b as l,et as u,k as d,m as f,o as p,r as m,u as h,v as g,w as _,x as v}from"./app-ae3zsclI.js";import{t as y}from"./i18n-M94zPSoE.js";import{t as b}from"./AdminLayout-pwaHvhjy.js";import{t as x}from"./UploadButton-CM8RsiK_.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=d({__name:`Pwa`,props:{values:{},icons:{},push:{}},setup(d){let q=d,J=p(),Y=l(()=>J.props.flash?.status),X=c({short_name:q.values.short_name,banner:q.values.banner});function Z(){X.post(`/admin/pwa`,{preserveScroll:!0})}let Q=c({icon:null});function re(e){Q.icon=e,Q.post(`/admin/pwa/icon`,{preserveScroll:!0,forceFormData:!0})}let $=c({});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(c,l)=>(i(),_(g,null,[t(s(m),{title:s(y)(`Admin · PWA`)},null,8,[`title`]),t(b,null,{title:o(()=>[n(u(s(y)(`Progressive Web App`)),1)]),subtitle:o(()=>[n(u(s(y)(`Install experience, icons & push`)),1)]),default:o(()=>[Y.value?(i(),_(`div`,S,u(Y.value),1)):e(``,!0),v(`div`,C,[v(`section`,w,[v(`h3`,T,u(s(y)(`Install settings`)),1),v(`form`,{class:`space-y-5`,onSubmit:te(Z,[`prevent`])},[v(`div`,null,[v(`label`,E,u(s(y)(`App short name (home-screen label)`)),1),r(v(`input`,{"onUpdate:modelValue":l[0]||=e=>s(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,s(X).short_name]])]),v(`label`,D,[r(v(`input`,{"onUpdate:modelValue":l[1]||=e=>s(X).banner=e,type:`checkbox`,class:`rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500`},null,512),[[h,s(X).banner]]),v(`span`,O,u(s(y)(`Show the “install app” banner on supported devices`)),1)]),v(`button`,{type:`submit`,disabled:s(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`},u(s(y)(`Save`)),9,k)],32),v(`p`,A,[n(u(s(y)(`The theme color comes from the brand color in`))+` `,1),v(`strong`,null,u(s(y)(`Theme`)),1),l[2]||=n(`.`,-1)])]),v(`section`,j,[v(`h3`,M,u(s(y)(`App icons`)),1),v(`p`,N,u(s(y)(`Upload one square image — every PWA/favicon size is generated automatically (WebP/PNG).`)),1),v(`div`,P,[(i(!0),_(g,null,a(d.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,[t(x,{uploading:s(Q).processing,label:s(y)(`Choose app icon`),accept:`image/png,image/jpeg,image/webp`,onFile:re},null,8,[`uploading`,`label`])])])]),v(`section`,I,[v(`h3`,L,u(s(y)(`Push notification keys (VAPID)`)),1),v(`p`,R,u(s(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:ee([`h-2 w-2 rounded-full`,d.push.configured?`bg-emerald-500`:`bg-amber-500`])},null,2),v(`span`,V,u(d.push.configured?s(y)(`Push keys are configured`):s(y)(`No push keys yet`)),1)]),d.push.publicKey?(i(),_(`span`,H,u(s(y)(`Public key`))+`: `+u(d.push.publicKey),1)):e(``,!0),v(`span`,U,u(s(y)(`{n} device(s) subscribed`,{n:d.push.subscriptions})),1)]),v(`div`,W,[v(`button`,{type:`button`,disabled:s($).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},u(s($).processing?s(y)(`Generating…`):d.push.configured?s(y)(`Regenerate push keys`):s(y)(`Generate push keys`)),9,G),v(`p`,K,u(s(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};