1import{u as L,T as A,ax as N,d as z,r as p,c as D,o as B,e as a,k as d,x as _,g as e,t as o,i as s,$ as I,F as f,j as S,bh as m,m as l,N as R,bQ as U,A as V,D as n,ag as T}from"./index-HRqdy4hL.js";import{P as Y}from"./PageHeader-B6gPy57v.js";import{H as q}from"./HelpTip-_yHQmHFB.js";/* empty css */const O={class:"flex h-full flex-col"},W={class:"text-xl font-semibold flex items-center"},M={class:"text-sm text-muted-foreground"},Q={class:"flex-1 overflow-auto p-4 sm:p-6 space-y-4"},G={id:"tour-trk-pushsetup",class:"rounded-lg border border-border bg-card p-4"},J={class:"text-sm text-muted-foreground"},K={key:0,class:"p-12 text-center text-muted-foreground",role:"status"},X={key:1,role:"alert",class:"rounded-lg border border-destructive/30 bg-destructive/10 p-4 flex items-start gap-3"},Z={class:"flex-1 text-sm"},ee={class:"font-medium text-card-foreground"},te={class:"text-muted-foreground mt-0.5"},se={key:2,class:"rounded-lg border border-amber-500/40 bg-amber-500/10 p-4 text-sm",role:"status"},oe={class:"rounded-lg border border-border bg-card p-4"},re={class:"text-sm font-semibold mb-1"},ae={class:"text-xs text-muted-foreground mb-3"},de=["aria-label"],ne=["aria-checked"],ie={class:"block text-sm font-medium"},le={class:"block text-xs text-muted-foreground mt-0.5"},ce=["aria-checked"],ue={class:"block text-sm font-medium"},pe={class:"block text-xs text-muted-foreground mt-0.5"},he={class:"rounded-lg border border-border bg-card p-4"},_e={class:"flex items-center gap-2 mb-2"},me={class:"text-sm font-semibold"},be={class:"text-sm text-muted-foreground mb-3"},fe={class:"flex flex-wrap items-center gap-3"},xe=["href"],ge={class:"text-xs text-muted-foreground"},ve={class:"rounded bg-muted px-1.5 py-0.5 font-mono"},ye={class:"rounded-lg border border-border bg-card p-4"},ke={class:"flex items-center gap-2 mb-2"},we={class:"text-sm font-semibold"},Ce={key:0,class:"text-sm text-muted-foreground"},Pe={class:"text-sm text-muted-foreground mb-3"},$e=["href"],De={id:"tour-trk-pushsetup-embed",class:"rounded-lg border border-border bg-card p-4"},Se={class:"flex items-center gap-2 mb-2"},Te={class:"text-sm font-semibold"},He={class:"text-sm text-muted-foreground mb-3"},je={key:0,class:"rounded-md border border-dashed border-border p-6 text-center",role:"status"},Ee={class:"text-sm font-medium"},Fe={class:"text-xs text-muted-foreground mt-1 mb-3"},Le={key:1,class:"space-y-3"},Ae={class:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 mb-2"},Ne={class:"text-sm font-medium"},ze={class:"text-xs text-muted-foreground ml-2"},Be={class:"text-xs text-muted-foreground tabular-nums"},Ie={class:"flex items-stretch gap-2"},Re={class:"flex-1 overflow-x-auto rounded bg-muted px-3 py-2 text-xs font-mono leading-relaxed"},Ue=["aria-label","onClick"],Ve={class:"rounded-lg border border-border bg-card p-4"},Ye={class:"text-sm font-semibold mb-2"},qe={class:"flex flex-wrap gap-2"},k="/push-subscriber-sw.js",Oe="/push-collector.js",Xe={__name:"PushSetup",setup(We){const{t}=L(),H=A(),{copy:j}=N(),w=t("tracker.push_setup_help","Wire the web-push opt-in collector onto your landing pages. Host the service worker on your site, add the collector embed for each Push adzone, and visitors can opt in to notifications. Choose to load the collector from us or host it yourself.");z([{id:"tour-trk-pushsetup",title:t("tracker.push_setup_title","Push setup"),description:w,side:"bottom"},{id:"tour-trk-pushsetup-embed",title:t("tracker.push_setup_embed_title","Embed code"),description:t("tracker.push_setup_embed_tour","Copy the script for each Push adzone onto the landing pages where the opt-in prompt should appear."),side:"top"}]);const g=p(!1),v=p(!1),h=p(""),b=p(k),C=p(0),y=p([]),c=p("remote"),E=D(()=>h.value?`https://${h.value}/push/sw.go`:""),F=D(()=>h.value?`https://${h.value}/push/collector.go`:"");function P(u){let r;return c.value==="selfhost"?r=`${Oe}?spaceid=${u.id}&origin=https://${u.domain}`:r=`https://${u.domain}/push/collector.go?spaceid=${u.id}`,b.value&&b.value!==k&&(r+=`&sw=${b.value}`),`<script src="${r}"><\/script>`}async function $(){g.value=!0,v.value=!1;try{const{data:u}=await U.pushSetup(),r=u.data||{};h.value=r.ad_domain||"",b.value=r.sw_path||k,C.value=r.subscriber_active||0,y.value=r.adzones||[]}catch{v.value=!0,H.error(t("tracker.push_setup_load_failed","Failed to load pu
1sh setup."))}finally{g.value=!1}}return B($),(u,r)=>{const x=V("router-link");return n(),a("div",O,[d(Y,null,{left:_(()=>[e("h1",W,[l(o(s(t)("tracker.push_setup_title","Push setup"))+" ",1),d(q,{text:s(w)},null,8,["text"])])]),right:_(()=>[e("span",M,o(s(T)(C.value))+" "+o(s(t)("tracker.push_setup_active_subs","active subscribers")),1)]),_:1}),e("div",Q,[e("div",G,[e("p",J,o(s(t)("tracker.push_setup_intro","The push collector captures web-push opt-ins on your landing pages. Two small files do the work â a service worker hosted on your site, and a collector script that shows the opt-in prompt. Set both up once per site, then add the embed code to your pages.")),1)]),g.value?(n(),a("div",K,o(s(t)("global.loading","Loadingâ¦")),1)):v.value?(n(),a("div",X,[d(s(I),{class:"h-5 w-5 text-destructive flex-shrink-0 mt-0.5","aria-hidden":"true"}),e("div",Z,[e("p",ee,o(s(t)("tracker.push_setup_load_error_title","Failed to load push setup")),1),e("p",te,o(s(t)("tracker.push_setup_load_error_desc","Your ad domain and adzones did not load. Check your connection and try again.")),1),e("button",{type:"button",class:"ui-btn-primary mt-3 inline-flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",onClick:$},o(s(t)("global.retry","Retry")),1)])])):h.value?(n(),a(f,{key:3},[e("div",oe,[e("h2",re,o(s(t)("tracker.push_setup_method_title","How the collector loads")),1),e("p",ae,o(s(t)("tracker.push_setup_method_hint","Choose how the collector script reaches your pages. You can switch any time â only the embed code below changes.")),1),e("div",{class:"flex flex-col sm:flex-row gap-2",role:"radiogroup","aria-label":s(t)("tracker.push_setup_method_title","How the collector loads")},[e("button",{type:"button",role:"radio","aria-checked":c.value==="remote",class:S(["flex-1 text-start rounded-lg border p-3 transition",c.value==="remote"?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:bg-muted"]),onClick:r[0]||(r[0]=i=>c.value="remote")},[e("span",ie,o(s(t)("tracker.push_setup_method_remote","Load from us")),1),e("span",le,o(s(t)("tracker.push_setup_method_remote_desc","A single script tag â quickest to set up.")),1)],10,ne),e("button",{type:"button",role:"radio","aria-checked":c.value==="selfhost",class:S(["flex-1 text-start rounded-lg border p-3 transition",c.value==="selfhost"?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:bg-muted"]),onClick:r[1]||(r[1]=i=>c.value="selfhost")},[e("span",ue,o(s(t)("tracker.push_setup_method_selfhost","Self-hosted")),1),e("span",pe,o(s(t)("tracker.push_setup_method_selfhost_desc","Host the script on your own site â keeps working when visitors run ad blockers.")),1)],10,ce)],8,de)]),e("div",he,[e("div",_e,[r[2]||(r[2]=e("span",{class:"inline-flex items-center justify-center w-6 h-6 rounded-full bg-primary/10 text-primary text-xs font-semibold"},"1",-1)),e("h2",me,o(s(t)("tracker.push_setup_sw_title","Service worker")),1)]),e("p",be,o(s(t)("tracker.push_setup_sw_body","Download this file and host it at the root of each site where you run the collector. It must sit on the same host visitors opt in on â a service worker is same-origin only, so a file on one subdomain does not cover another.")),1),e("div",fe,[e("a",{href:E.value,target:"_blank",rel:"noopener",class:"inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground hover:bg-primary/90"},[d(m,{name:"arrow-down-tray",class:"w-4 h-4","aria-hidden":"true"}),l(" "+o(s(t)("tracker.push_setup_sw_download","Download service worker")),1)],8,xe),e("span",ge,[l(o(s(t)("tracker.push_setup_sw_host_at","Host it at your site root as"))+" ",1),e("code",ve,o(b.value),1)])])]),e("div",ye,[e("div",ke,[r[3]||(r[3]=e("span",{class:"inline-flex items-center justify-center w-6 h-6 rounded-full bg-primary/10 text-primary text-xs font-semibold"},"2",-1)),e("h2",we,o(s(t)("tracker.push_setup_collector_title","Collector script")),1)]),c.value==="remote"?(n(),a("p",Ce,o(s(t)("tracker.push_setup_collector_remote_body","Nothing to host â the collector loads straight from our servers. Continue to step 3.")),1)):(n(),a(f,{key:1},[e("p",Pe,o(s(t)("tracker.push_setup_collector_selfhost_body","Download this file and host it anywhere on your own site. The embed in step 3 passes our server address as an origin parameter, so captured opt-ins still reach us.")),1),e("a",{href:F.value,target:"_blank",rel:"noopener",class:"inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground hover:bg-primary/90"},[d(m,{name:"arrow-down-tray",class:"w-4 h-4","aria-hidden":"true"}),l(" "+o(s(t)("tracker.push_setup_collector_download","Download collector script")),1)],8,$e)],64))]),e("div",De,[e
1("div",Se,[r[4]||(r[4]=e("span",{class:"inline-flex items-center justify-center w-6 h-6 rounded-full bg-primary/10 text-primary text-xs font-semibold"},"3",-1)),e("h2",Te,o(s(t)("tracker.push_setup_embed_title","Embed code")),1)]),e("p",He,o(s(t)("tracker.push_setup_embed_body","Add the script for each Push adzone to the landing pages where visitors should see the opt-in prompt.")),1),y.value.length===0?(n(),a("div",je,[e("p",Ee,o(s(t)("tracker.push_setup_empty","You don't have a Push adzone yet.")),1),e("p",Fe,o(s(t)("tracker.push_setup_empty_hint","Create one to start collecting web-push opt-ins.")),1),d(x,{to:"/publisher/adzones/new",class:"inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground hover:bg-primary/90"},{default:_(()=>[l(o(s(t)("tracker.push_setup_create_adzone","Create a Push adzone")),1)]),_:1})])):(n(),a("ul",Le,[(n(!0),a(f,null,R(y.value,i=>(n(),a("li",{key:i.id,class:"rounded-md border border-border p-3"},[e("div",Ae,[e("div",null,[e("span",Ne,o(i.name||"#"+i.id),1),e("span",ze,o(s(t)("tracker.push_setup_zone_site","Site"))+": "+o(i.site_name||"â"),1)]),e("span",Be,[l(o(s(t)("tracker.push_setup_zone_subs","{n} subscribers",{n:s(T)(i.subscribers)}))+" · ",1),i.last_optin?(n(),a(f,{key:0},[l(o(s(t)("tracker.push_setup_zone_last","last opt-in {date}",{date:i.last_optin})),1)],64)):(n(),a(f,{key:1},[l(o(s(t)("tracker.push_setup_zone_never","no opt-ins yet")),1)],64))])]),e("div",Ie,[e("pre",Re,o(P(i)),1),e("button",{type:"button",class:"flex-none inline-flex items-center justify-center rounded border border-border px-3 min-h-[44px] hover:bg-muted","aria-label":s(t)("tracker.push_setup_copy","Copy embed code"),onClick:Me=>s(j)(P(i))},[d(m,{name:"clipboard",class:"w-4 h-4","aria-hidden":"true"})],8,Ue)])]))),128))]))]),e("div",Ve,[e("h2",Ye,o(s(t)("tracker.push_setup_related","Related")),1),e("div",qe,[d(x,{to:"/publisher/push-subscribers",class:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-2 text-sm hover:bg-muted"},{default:_(()=>[d(m,{name:"bell",class:"w-4 h-4","aria-hidden":"true"}),l(" "+o(s(t)("tracker.push_subs_title","Push subscribers")),1)]),_:1}),d(x,{to:"/publisher/push-campaigns",class:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-2 text-sm hover:bg-muted"},{default:_(()=>[d(m,{name:"paper-airplane",class:"w-4 h-4","aria-hidden":"true"}),l(" "+o(s(t)("tracker.push_camp_title","Push campaigns")),1)]),_:1}),d(x,{to:"/publisher/push-stats",class:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-2 text-sm hover:bg-muted"},{default:_(()=>[d(m,{name:"chart-bar-square",class:"w-4 h-4","aria-hidden":"true"}),l(" "+o(s(t)("tracker.push_stats_title","Push stats")),1)]),_:1})])])],64)):(n(),a("div",se,o(s(t)("tracker.push_setup_no_domain","No ad domain is configured for this account yet, so the setup links cannot be built. Please contact support.")),1))])])}}};export{Xe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.