1import{d as N,j as e}from"./react-vendor-BYeqKmV6.js";import{$ as ee,aE as v,aD as h,a1 as S,p as J,B as m,X as ce,d as K,e as de,f as oe,i as he,j as me,g as xe,F as ue}from"./index-C5_t1zCf.js";import{C as R,d as w,e as O,b as q,a as U}from"./card-CpuziIzR.js";import{I as u}from"./input-D3p5gISb.js";import{L as ge}from"./label-BjIbRJ8Q.js";import{S as je}from"./switch-B53bNUYL.js";import{T as A,d as T,e as o,c as i,a as L,b as a}from"./table-BVyRy5sJ.js";import{A as pe,c as ve,f as Ne,g as fe,d as ke,e as Ce,b as be,a as ye}from"./alert-dialog-CcIHKvQp.js";import{M as Pe}from"./mouse-pointer-click-CKZn9uA5.js";import{C as V}from"./chart-column-DoFtPw3F.js";import{W as Se}from"./wallet-BlWRIx4g.js";import{L as b}from"./loader-circle-KzlnbA1r.js";import{R as Ae}from"./refresh-cw-D7dqK49T.js";import{S as Te}from"./save-ecYo9HXq.js";import{P as Le}from"./pencil-LImiI67o.js";import{T as Me}from"./trash-2-DlOR620m.js";import"./ui-vendor-FeF8SYpf.js";import"./data-vendor-JFafzwTy.js";/** 2 * @license lucide-react v0.542.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Re=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Ue=ee("qr-code",Re);/** 7 * @license lucide-react v0.542.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const De=[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]],$e=ee("user-round-check",De),H={name:"",code:"",targetPath:"/pricing",source:"",medium:"",campaign:"",content:"",term:"",notes:""};function Ee(){return typeof window>"u"?"":window.location.origin}function M(t){return new URL(`/r/${encodeURIComponent(t.code)}`,Ee()).toString()}function Ie(t){return`https://api.qrserver.com/v1/create-qr-code/?size=320x320&data=${encodeURIComponent(t)}`}function Fe(t){return{name:t.name,code:t.code,targetPath:t.targetPath,source:t.source??"",medium:t.medium??"",campaign:t.campaign??"",content:t.content??"",term:t.term??"",notes:t.notes??""}}function ts(){const t=v.useUtils(),{data:l,isLoading:f,isFetching:k,refetch:D}=v.adminAttribution.list.useQuery(void 0,{retry:!1}),{data:n,isLoading:r,refetch:se}=v.adminAttribution.aiOverview.useQuery(void 0,{retry:!1}),$=v.adminAttribution.create.useMutation({onSuccess:async s=>{await t.adminAttribution.list.invalidate(),h.success(`Short link created: ${s.code}`),G(H)},onError:s=>h.error(S(s))}),B=v.adminAttribution.setActive.useMutation({onSuccess:async()=>{await t.adminAttribution.list.invalidate(),h.success("Short link status updated")},onError:s=>h.error(S(s))}),E=v.adminAttribution.update.useMutation({onSuccess:async()=>{await t.adminAttribution.list.invalidate(),h.success("Short link saved"),F(null)},onError:s=>h.error(S(s))}),_=v.adminAttribution.delete.useMutation({onSuccess:async()=>{await t.adminAttribution.list.invalidate(),h.success("Short link deleted"),Q(null)},onError:s=>h.error(S(s))}),[c,G]=N.useState(H),[I,F]=N.useState(null),[d,W]=N.useState(H),[g,X]=N.useState(null),[C,Q]=N.useState(null),z=l??[],j=n??{sources:[],landingPages:[],conversionPages:[]},P=N.useMemo(()=>z.reduce((s,p)=>(s.clicks+=p.clickCount,s.logins+=p.loginCount,s.paidUsers+=p.paidUserCount,s.revenue+=p.paidAmount,s),{clicks:0,logins:0,paidUsers:0,revenue:0}),[z]),te=()=>{$.mutate({name:c.name,code:c.code||void 0,targetPath:c.targetPath,source:c.source||void 0,medium:c.medium||void 0,campaign:c.campaign||void 0,content:c.content||void 0,term:c.term||void 0,notes:c.notes||void 0})},ae=s=>{F(s.id),W(Fe(s))},ie=()=>{I&&E.mutate({id:I,name:d.name,targetPath:d.targetPath,source:d.source||void 0,medium:d.medium||void 0,campaign:d.campaign||void 0,content:d.content||void 0,term:d.term||void 0,notes:d.notes||void 0})},Y=async s=>{await navigator.clipboard.writeText(M(s)),h.success("Short link copied")}
11,ne=g?Ie(M(g)):"";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Short Link Platform"}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Generate short links, edit link information, delete unused links, and track clicks, logins, payments, and revenue."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(y,{icon:Pe,label:"Total Clicks",value:P.clicks.toLocaleString()}),e.jsx(y,{icon:$e,label:"Tracked Logins",value:P.logins.toLocaleString()}),e.jsx(y,{icon:V,label:"Paid Users",value:P.paidUsers.toLocaleString()}),e.jsx(y,{icon:Se,label:"Revenue",value:`$${P.revenue.toFixed(2)}`})]}),e.jsxs(R,{children:[e.jsxs(w,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"Create Short Link"]}),e.jsx(q,{children:"Create a short link that redirects through `/r/:code`, supports QR code scanning, and keeps attribution tracking."})]}),e.jsxs(U,{className:"space-y-4",children:[e.jsx(Z,{form:c,setForm:G,showCode:!0}),e.jsxs(m,{onClick:te,disabled:$.isPending||!c.name.trim()||!c.targetPath.trim(),className:"gap-2",children:[$.isPending?e.jsx(b,{className:"h-4 w-4 animate-spin"}):e.jsx(J,{className:"h-4 w-4"}),"Create Short Link"]})]})]}),e.jsxs(R,{children:[e.jsxs(w,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(O,{children:"Link Stats"}),e.jsx(q,{children:"Each short link supports copy, QR code, edit/save, delete, and full funnel metrics."})]}),e.jsx(m,{variant:"outline",size:"sm",onClick:()=>{D(),se()},disabled:k,children:e.jsx(Ae,{className:`h-4 w-4 ${k?"animate-spin":""}`})})]}),e.jsx(U,{children:f?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(A,{children:[e.jsx(T,{children:e.jsxs(o,{children:[e.jsx(i,{children:"Name"}),e.jsx(i,{children:"Short Link"}),e.jsx(i,{className:"text-right",children:"Clicks"}),e.jsx(i,{className:"text-right",children:"Logins"}),e.jsx(i,{className:"text-right",children:"Paid"}),e.jsx(i,{className:"text-right",children:"Revenue"}),e.jsx(i,{children:"Status"}),e.jsx(i,{className:"text-right",children:"Actions"})]})}),e.jsx(L,{children:z.map(s=>{const p=I===s.id,re=M(s);return e.jsxs(o,{children:[e.jsx(a,{className:"min-w-[240px] align-top",children:p?e.jsxs("div",{className:"space-y-3",children:[e.jsx(Z,{form:d,setForm:W,showCode:!1,compact:!0}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(m,{size:"sm",onClick:ie,disabled:E.isPending||!d.name.trim()||!d.targetPath.trim(),className:"gap-1.5",children:[E.isPending?e.jsx(b,{className:"h-4 w-4 animate-spin"}):e.jsx(Te,{className:"h-4 w-4"}),"Save"]}),e.jsxs(m,{variant:"outline",size:"sm",onClick:()=>F(null),className:"gap-1.5",children:[e.jsx(ce,{className:"h-4 w-4"}),"Cancel"]})]})]}):e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.targetPath})]})}),e.jsx(a,{className:"align-top",children:e.jsx("div",{className:"max-w-[320px] truncate rounded-md bg-muted px-3 py-2 font-mono text-xs",children:re})}),e.jsx(a,{className:"text-right align-top",children:s.clickCount}),e.jsx(a,{className:"text-right align-top",children:s.loginCount}),e.jsx(a,{className:"text-right align-top",children:s.paidUserCount}),e.jsxs(a,{className:"text-right align-top",children:["$",s.paidAmount.toFixed(2)]}),e.jsx(a,{className:"align-top",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{checked:s.isActive===1,onCheckedChange:le=>B.mutate({id:s.id,isActive:le}),disabled:B.isPending}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.isActive===1?"Active":"Paused"})]})}),e.jsx(a,{className:"align-top",children:e.jsx("div",{className:"flex justify-end gap-2",children:p?null:e.jsxs(e.Fragment,{children:[e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>void Y(s),className:"gap-1.5",children:[e.jsx(K,{className:"h-4 w-4"}),"Copy"]}),e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>X(s),className:"gap-1.5",children:[e.jsx(Ue,{className:"h-4 w-4"}),"QR"]}),e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>ae(s),className:"gap-1.5",children:[e.jsx(Le,{className:"h-4 w-4"}),"Edit"]}),e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>Q(s),className:"gap-1.5 text-destructive hover:text-destructive",children:[e.jsx(Me,{className:"h-4 w-4"}),"Delete"]})]})})})]},s.id)})})]})})]}),e.jsxs(R,{children:[e.jsxs(w,{children:[e.jsx(O,{children:"AI Referrer Attribution"}),e.jsx(q,{children:"This view isolates AI-source traffic captured inside the short
11-link and attribution pipeline. It groups visits from ChatGPT, Perplexity, Gemini, and Claude by source, landing page, and paid target page."})]}),e.jsx(U,{className:"space-y-6",children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:j.sources.map(s=>e.jsx(y,{icon:V,label:`${s.source} revenue`,value:`$${s.revenue.toFixed(2)}`},s.source))}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Source Summary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Revenue-first view of observed AI referrers."})]}),e.jsxs(A,{children:[e.jsx(T,{children:e.jsxs(o,{children:[e.jsx(i,{children:"Source"}),e.jsx(i,{className:"text-right",children:"Clicks"}),e.jsx(i,{className:"text-right",children:"Logins"}),e.jsx(i,{className:"text-right",children:"Paid Users"}),e.jsx(i,{className:"text-right",children:"Revenue"})]})}),e.jsx(L,{children:j.sources.length===0?e.jsx(o,{children:e.jsx(a,{colSpan:5,className:"text-center text-muted-foreground",children:"No AI referrer traffic has been captured yet."})}):j.sources.map(s=>e.jsxs(o,{children:[e.jsx(a,{className:"font-medium",children:s.source}),e.jsx(a,{className:"text-right",children:s.clicks}),e.jsx(a,{className:"text-right",children:s.logins}),e.jsx(a,{className:"text-right",children:s.paidUsers}),e.jsxs(a,{className:"text-right",children:["$",s.revenue.toFixed(2)]})]},s.source))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Top Landing Pages"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Entry pages that AI referrer visitors hit first."})]}),e.jsxs(A,{children:[e.jsx(T,{children:e.jsxs(o,{children:[e.jsx(i,{children:"Source"}),e.jsx(i,{children:"Landing Page"}),e.jsx(i,{className:"text-right",children:"Clicks"}),e.jsx(i,{className:"text-right",children:"Logins"}),e.jsx(i,{className:"text-right",children:"Paid Users"}),e.jsx(i,{className:"text-right",children:"Revenue"})]})}),e.jsx(L,{children:j.landingPages.length===0?e.jsx(o,{children:e.jsx(a,{colSpan:6,className:"text-center text-muted-foreground",children:"No AI landing-page data yet."})}):j.landingPages.slice(0,12).map(s=>e.jsxs(o,{children:[e.jsx(a,{className:"font-medium",children:s.source}),e.jsx(a,{className:"font-mono text-xs",children:s.landingPath}),e.jsx(a,{className:"text-right",children:s.clicks}),e.jsx(a,{className:"text-right",children:s.logins}),e.jsx(a,{className:"text-right",children:s.paidUsers}),e.jsxs(a,{className:"text-right",children:["$",s.revenue.toFixed(2)]})]},`${s.source}-${s.landingPath}`))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Top Conversion Pages"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Target pages tied to attributed payments from AI referrers."})]}),e.jsxs(A,{children:[e.jsx(T,{children:e.jsxs(o,{children:[e.jsx(i,{children:"Source"}),e.jsx(i,{children:"Target Page"}),e.jsx(i,{className:"text-right",children:"Paid Users"}),e.jsx(i,{className:"text-right",children:"Payments"}),e.jsx(i,{className:"text-right",children:"Revenue"})]})}),e.jsx(L,{children:j.conversionPages.length===0?e.jsx(o,{children:e.jsx(a,{colSpan:5,className:"text-center text-muted-foreground",children:"No AI conversion-page data yet."})}):j.conversionPages.slice(0,12).map(s=>e.jsxs(o,{children:[e.jsx(a,{className:"font-medium",children:s.source}),e.jsx(a,{className:"font-mono text-xs",children:s.targetPath}),e.jsx(a,{className:"text-right",children:s.paidUsers}),e.jsx(a,{className:"text-right",children:s.paymentCount}),e.jsxs(a,{className:"text-right",children:["$",s.revenue.toFixed(2)]})]},`${s.source}-${s.targetPath}`))})]})]})]})})]}),e.jsx(de,{open:!!g,onOpenChange:s=>!s&&X(null),children:e.jsxs(oe,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:"Short Link QR Code"}),e.jsx(xe,{children:"Scan to open the short link redirect. This QR code points to the short URL, not the long target URL."})]}),g?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-center rounded-xl border bg-white p-4",children:e.jsx("img",{src:ne,alt:`QR code for ${g.name}`,className:"h-72 w-72"})}),e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-xs break-all",children:M(g)}),e.jsxs(m,{onClick:()=>void Y(g),className:"w-full gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"Copy Short Link"]})]}):null]})}),e.jsx(pe,{open:!!C,onOpenChange:s=>!s&&Q(null),children:e.jsxs(ve,{children:[e.jsxs(Ne,{children:[e.jsx(fe,{children:"Delete this short link?"}),e.jsx(ke,{children:C?`This will delete "${C.name}" and remove it from the short link platform list.`:""})]}),e.jsxs(Ce,{children:[e.jsx(be,{children:"Cancel"}),e.jsx(ye,{onClick:s=>{s.preventDefault(),C&&_.mutate({id:C.id})},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:_.isPending?e.jsx(b,{className:"h-4 w-4 animate-spin"}):"Delete"})]})]})})]})}function Z({form:t,setForm:l,showCode:f,compact:k=!1}){const D=k?"grid gap-3 md:grid-cols-2":"grid gap-4 md:grid-cols-2";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:D,children:[e.jsx(x,{label:"Display Name",children:e.jsx(u,{value:t.name,onChange:n=>l(r=>({...r,name:n.target.value})),placeholder:"kuma's youtube"})}),f?e.jsx(x,{label:"Short Code",children:e.jsx(u,{value:t.code,onChange:n=>l(r=>({...r,code:n.target.value})),placeholder:"kumajiang"})}):null,e.jsx(x,{label:"Target Path",children:e.jsx(u,{value:t.targetPath,onChange:n=>l(r=>({...r,targetPath:n.target.value})),placeholder:"/landing"})}),e.jsx(x,{label:"UTM Source",children:e.jsx(u,{value:t.source,onCh
11ange:n=>l(r=>({...r,source:n.target.value})),placeholder:"youtube"})}),e.jsx(x,{label:"UTM Medium",children:e.jsx(u,{value:t.medium,onChange:n=>l(r=>({...r,medium:n.target.value})),placeholder:"creator"})}),e.jsx(x,{label:"UTM Campaign",children:e.jsx(u,{value:t.campaign,onChange:n=>l(r=>({...r,campaign:n.target.value})),placeholder:"koc-campaign"})}),e.jsx(x,{label:"UTM Content",children:e.jsx(u,{value:t.content,onChange:n=>l(r=>({...r,content:n.target.value})),placeholder:"video-1"})}),e.jsx(x,{label:"UTM Term",children:e.jsx(u,{value:t.term,onChange:n=>l(r=>({...r,term:n.target.value})),placeholder:"upgrade"})})]}),e.jsx(x,{label:"Notes",children:e.jsx(ue,{value:t.notes,onChange:n=>l(r=>({...r,notes:n.target.value})),rows:k?2:3,placeholder:"Optional notes"})})]})}function x({label:t,children:l}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:t}),l]})}function y({icon:t,label:l,value:f}){return e.jsx(R,{children:e.jsx(U,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-lg bg-primary/10 p-2",children:e.jsx(t,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l})]})]})})})}export{ts 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.