1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[2624],{5949(e,s,a){a.d(s,{E:()=>o});var t=a(89379),i=a(53986),l=(a(65043),a(10917)),n=a(1089),r=a(70579);const d=["className","variant"],c=(0,l.F)("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function o(e){let{className:s,variant:a}=e,l=(0,i.A)(e,d);return(0,r.jsx)("div",(0,t.A)({className:(0,n.cn)(c({variant:a}),s)},l))}},13416(e,s,a){a.d(s,{T:()=>c});var t=a(89379),i=a(53986),l=a(65043),n=a(1089),r=a(70579);const d=["className"],c=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,d);return(0,r.jsx)("textarea",(0,t.A)({className:(0,n.cn)("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:s},l))});c.displayName="Textarea"},19690(e,s,a){a.d(s,{Xi:()=>m,av:()=>p,j7:()=>h,tU:()=>u});var t=a(89379),i=a(53986),l=a(65043),n=a(47127),r=a(1089),d=a(70579);const c=["className"],o=["className"],x=["className"],u=n.bL,h=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,c);return(0,d.jsx)(n.B8,(0,t.A)({ref:s,className:(0,r.cn)("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a)},l))});h.displayName=n.B8.displayName;const m=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,o);return(0,d.jsx)(n.l9,(0,t.A)({ref:s,className:(0,r.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",a)},l))});m.displayName=n.l9.displayName;const p=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,x);return(0,d.jsx)(n.UC,(0,t.A)({ref:s,className:(0,r.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a)},l))});p.displayName=n.UC.displayName},33340(e,s,a){a.d(s,{A0:()=>v,BF:()=>g,Hj:()=>b,XI:()=>j,nA:()=>N,nd:()=>f});var t=a(89379),i=a(53986),l=a(65043),n=a(1089),r=a(70579);const d=["className"],c=["className"],o=["className"],x=["className"],u=["className"],h=["className"],m=["className"],p=["className"],j=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,d);return(0,r.jsx)("div",{className:"relative w-full overflow-auto",children:(0,r.jsx)("table",(0,t.A)({ref:s,className:(0,n.cn)("w-full caption-bottom text-sm",a)},l))})});j.displayName="Table";const v=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,c);return(0,r.jsx)("thead",(0,t.A)({ref:s,className:(0,n.cn)("[&_tr]:border-b",a)},l))});v.displayName="TableHeader";const g=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,o);return(0,r.jsx)("tbody",(0,t.A)({ref:s,className:(0,n.cn)("[&_tr:last-child]:border-0",a)},l))});g.displayName="TableBody";l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,x);return(0,r.jsx)("tfoot",(0,t.A)({ref:s,className:(0,n.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a)},l))}).displayName="TableFooter";const b=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,u);return(0,r.jsx)("tr",(0,t.A)({ref:s,className:(0,n.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a)},l))});b.displayName="TableRow";const f=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,h);return(0,r.jsx)("th",(0,t.A)({ref:s,className:(0,n.cn)("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",a)},l))});f.displayName="TableHead";const N=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,m);return(0,r.jsx)("td",(0,t.A)({ref:s,className:(0,n.cn)("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",a)},l))});N.displayName="TableCell";l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,p);return(0,r.jsx)("caption",(0,t.A)({ref:s,className:(0,n.cn)("mt-4 text-sm text-muted-foreground",a)},l))}).displayName="TableCaption"},59938(e,s,a){a.d(s,{J:()=>u});var t=a(89379),i=a(53986),l=a(65043),n=a(65131),r=a(10917),d=a(1089),c=a(70579);const o=["className"],x=(0,r.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),u=l.forwardRef((e,s)=>{let{className:a}=e,l=(0,i.A)(e,o);return(0,c.jsx)(n.b,(0,t.A)({ref:s,className:(0,d.cn)(x(),a)},l))});u.displayName=n.b.displayName},82624(e,s,a){a.r(s),a.d(s,{default:()=>re});var t=a(89379),i=a(65043),l=a(45685),n=a(35016),r=a(4980),d=a(12420),c=a(87698),o=a(13390),x=a(92264),u=a(59938),h=a(13416),m=a(84370),p=a(91140),j=a(19690),v=a(33340),g=a(65598),b=a(5949),f=(a(51654),a(56328)),N=a(27033),y=a(22024),w=a(65469),_=a(37475),A=a(87800),k=a(36210),C=a(86376),z=a(33005
1),R=a(73062),F=a(70764),S=a(35087),B=a(41680),T=a(55731),U=a(77737),P=a(35327),$=a(84669),I=a(16388),L=a(70929),Z=a(65505),H=a(71360),E=a(50516),J=a(88693),M=a(39292),W=a(7365),q=a(42489),D=a(9855),V=a(44919),X=a(746),O=a(7118),K=a(40614),G=a(1089),Y=a(64702),Q=a(70579);const ee=()=>(0,Q.jsxs)(o.$,{variant:"destructive",size:"sm",onClick:()=>{try{throw new Error("This is a test error from Fantastic Forms!")}catch(e){c.Cp(e),f.oR.success("Test error sent to Sentry!")}},children:[(0,Q.jsx)(A.A,{className:"w-4 h-4 mr-2"}),"Test Sentry Error"]}),se=()=>{const[e,s]=i.useState(30),[a,t]=i.useState(!0),[l,n]=i.useState(null);i.useEffect(()=>{let s=!1;return t(!0),r.ic.getTrafficRevenue(e).then(e=>{s||n(e)}).catch(()=>{s||f.oR.error("Failed to load traffic data")}).finally(()=>{s||t(!1)}),()=>{s=!0}},[e]);const c=(null===l||void 0===l?void 0:l.kpis)||{},x=(null===l||void 0===l?void 0:l.sources)||[],u=(null===l||void 0===l?void 0:l.pages)||[],h=(null===l||void 0===l?void 0:l.keywords)||[],m=(null===l||void 0===l?void 0:l.utm_campaigns)||[],j=e=>"$".concat((e||0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})),g=e=>(e||0).toLocaleString("en-US");return(0,Q.jsxs)("div",{className:"space-y-6",children:[(0,Q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Q.jsxs)("div",{children:[(0,Q.jsx)("h3",{className:"text-lg font-semibold",children:"Traffic & Revenue"}),(0,Q.jsx)("p",{className:"text-xs text-zinc-500",children:"Pro upgrades ($99 plan) attributed to acquisition channels. Admin browsing is excluded automatically."})]}),(0,Q.jsx)("div",{className:"flex gap-1","data-testid":"traffic-range-tabs",children:[7,30,90,365].map(a=>(0,Q.jsx)(o.$,{variant:e===a?"default":"outline",size:"sm",onClick:()=>s(a),"data-testid":"traffic-range-".concat(a),children:365===a?"12mo":"".concat(a,"d")},a))})]}),a&&!l?(0,Q.jsx)("div",{className:"py-12 flex items-center justify-center",children:(0,Q.jsx)(y.A,{className:"w-6 h-6 animate-spin text-zinc-400"})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3","data-testid":"traffic-kpis",children:[(0,Q.jsx)(ae,{icon:(0,Q.jsx)(S.A,{className:"w-4 h-4"}),label:"Pageviews",value:g(c.total_pageviews)}),(0,Q.jsx)(ae,{icon:(0,Q.jsx)(T.A,{className:"w-4 h-4"}),label:"Unique sessions",value:g(c.unique_sessions)}),(0,Q.jsx)(ae,{icon:(0,Q.jsx)(I.A,{className:"w-4 h-4"}),label:"Pro accounts",value:g(c.total_conversions)}),(0,Q.jsx)(ae,{icon:(0,Q.jsx)(V.A,{className:"w-4 h-4"}),label:"CVR (Pro/session)",value:"".concat((c.conversion_rate||0).toFixed(2),"%")}),(0,Q.jsx)(ae,{icon:(0,Q.jsx)(R.A,{className:"w-4 h-4"}),label:"Revenue",value:j(c.total_revenue)}),(0,Q.jsx)(ae,{icon:(0,Q.jsx)(R.A,{className:"w-4 h-4"}),label:"ARPU",value:j(c.arpu)})]}),(0,Q.jsxs)(p.Zp,{children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsx)(p.ZB,{className:"text-base",children:"Trend over time"}),(0,Q.jsx)(p.BT,{children:"Daily pageviews, sessions, Pro upgrades, and revenue across the selected window. Click a metric chip to hide it."})]}),(0,Q.jsx)(p.Wu,{children:(0,Q.jsx)(d.A,{series:(null===l||void 0===l?void 0:l.series)||[]})})]}),(0,Q.jsxs)(p.Zp,{children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsx)(p.ZB,{className:"text-base",children:"Top sources"}),(0,Q.jsx)(p.BT,{children:"Acquisition channels \u2014 visits (pageview-side) and Pro upgrades attributed via first-touch UTM / referrer captured at signup."})]}),(0,Q.jsx)(p.Wu,{children:(0,Q.jsxs)(v.XI,{children:[(0,Q.jsx)(v.A0,{children:(0,Q.jsxs)(v.Hj,{children:[(0,Q.jsx)(v.nd,{children:"Source"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Visits"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Sessions"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Pro"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"CVR"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Revenue"})]})}),(0,Q.jsx)(v.BF,{children:0===x.length?(0,Q.jsx)(v.Hj,{children:(0,Q.jsx)(v.nA,{colSpan:6,className:"text-center text-sm text-zinc-500 py-8",children:"No traffic in this window yet \u2014 pageviews will appear once the migration is applied and visitors start landing on the marketing site."})}):x.map(e=>(0,Q.jsxs)(v.Hj,{"data-testid":"source-row-".concat(e.source),children:[(0,Q.jsx)(v.nA,{className:"font-medium",children:e.source}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums",children:g(e.visits)}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums text-zinc-500",children:g(e.unique_sessions)}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums",children:g(e.conversions)}),(0,Q.jsxs)(v.nA,{className:"text-right tabular-nums",children:[(e.conversion_rate||0).toFixed(2),"%"]}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums font-semibold",children:j(e.revenue)})]},e.source))})]})})]}
1),(0,Q.jsxs)(p.Zp,{children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsx)(p.ZB,{className:"text-base",children:"UTM campaigns"}),(0,Q.jsxs)(p.BT,{children:["Traffic and conversions from links tagged with ",(0,Q.jsx)("code",{className:"px-1 py-0.5 rounded bg-zinc-100 text-zinc-700 text-[11px]",children:"utm_source"}),". The branded \u201cmade with Fantastic Forms\u201d link on free-plan forms is tagged ",(0,Q.jsx)("code",{className:"px-1 py-0.5 rounded bg-zinc-100 text-zinc-700 text-[11px]",children:"user / referral / branded"}),"."]})]}),(0,Q.jsx)(p.Wu,{children:(0,Q.jsxs)(v.XI,{children:[(0,Q.jsx)(v.A0,{children:(0,Q.jsxs)(v.Hj,{children:[(0,Q.jsx)(v.nd,{children:"Source"}),(0,Q.jsx)(v.nd,{children:"Medium"}),(0,Q.jsx)(v.nd,{children:"Campaign"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Visits"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Sessions"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Pro"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"CVR"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Revenue"})]})}),(0,Q.jsx)(v.BF,{children:0===m.length?(0,Q.jsx)(v.Hj,{children:(0,Q.jsx)(v.nA,{colSpan:8,className:"text-center text-sm text-zinc-500 py-8",children:"No UTM-tagged traffic in this window yet. Branded back-links and paid campaigns will appear here as soon as visitors click through."})}):m.map((e,s)=>{const a="".concat(e.source,"|").concat(e.medium||"","|").concat(e.campaign||"");return(0,Q.jsxs)(v.Hj,{"data-testid":"utm-row-".concat(s),children:[(0,Q.jsx)(v.nA,{className:"font-medium",children:e.source}),(0,Q.jsx)(v.nA,{className:"text-zinc-500 text-sm",children:e.medium||(0,Q.jsx)("span",{className:"text-zinc-300",children:"\u2014"})}),(0,Q.jsx)(v.nA,{className:"text-zinc-500 text-sm",children:e.campaign||(0,Q.jsx)("span",{className:"text-zinc-300",children:"\u2014"})}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums",children:g(e.visits)}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums text-zinc-500",children:g(e.unique_sessions)}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums",children:g(e.conversions)}),(0,Q.jsxs)(v.nA,{className:"text-right tabular-nums",children:[(e.conversion_rate||0).toFixed(2),"%"]}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums font-semibold",children:j(e.revenue)})]},a)})})]})})]}),(0,Q.jsxs)(p.Zp,{children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsx)(p.ZB,{className:"text-base",children:"Top keywords"}),(0,Q.jsx)(p.BT,{children:'Search terms driving traffic \u2014 `utm_term` (paid ads) plus extracted `q=` from search-engine referrers. Modern Google strips the query for organic results, so opaque visits bucket as "(not provided)".'})]}),(0,Q.jsx)(p.Wu,{children:(0,Q.jsxs)(v.XI,{children:[(0,Q.jsx)(v.A0,{children:(0,Q.jsxs)(v.Hj,{children:[(0,Q.jsx)(v.nd,{children:"Keyword"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Visits"})]})}),(0,Q.jsx)(v.BF,{children:0===h.length?(0,Q.jsx)(v.Hj,{children:(0,Q.jsx)(v.nA,{colSpan:2,className:"text-center text-sm text-zinc-500 py-8",children:"No keyword data yet. Paid campaigns should pass `utm_term=\u2026` in their landing URL; organic search keywords appear when the referring engine forwards them."})}):h.map(e=>(0,Q.jsxs)(v.Hj,{"data-testid":"keyword-row-".concat(encodeURIComponent(e.keyword)),children:[(0,Q.jsx)(v.nA,{className:"font-medium",children:e.keyword}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums",children:g(e.visits)})]},e.keyword))})]})})]}),(0,Q.jsxs)(p.Zp,{children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsx)(p.ZB,{className:"text-base",children:"Top pages"}),(0,Q.jsx)(p.BT,{children:"Most-visited paths on the marketing surface."})]}),(0,Q.jsx)(p.Wu,{children:(0,Q.jsxs)(v.XI,{children:[(0,Q.jsx)(v.A0,{children:(0,Q.jsxs)(v.Hj,{children:[(0,Q.jsx)(v.nd,{children:"Path"}),(0,Q.jsx)(v.nd,{className:"text-right",children:"Visits"})]})}),(0,Q.jsx)(v.BF,{children:0===u.length?(0,Q.jsx)(v.Hj,{children:(0,Q.jsx)(v.nA,{colSpan:2,className:"text-center text-sm text-zinc-500 py-8",children:"No pageviews logged yet."})}):u.map(e=>(0,Q.jsxs)(v.Hj,{"data-testid":"page-row-".concat(encodeURIComponent(e.path)),children:[(0,Q.jsx)(v.nA,{className:"font-mono text-xs",children:e.path}),(0,Q.jsx)(v.nA,{className:"text-right tabular-nums",children:g(e.visits)})]},e.path))})]})})]})]})]})},ae=e=>{let{icon:s,label:a,value:t}=e;return(0,Q.jsx)(p.Zp,{children:(0,Q.jsxs)(p.Wu,{className:"p-4",children:[(0,Q.jsxs)("div",{className:"flex items-center gap-2 text-xs text-zinc-500 mb-1",children:[s,(0,Q.jsx)("span",{children:a})]}),(0,Q.jsx)("div",{className:"text-xl font-bold text-zinc-900 tabular-nums",children:t})]})})},te={title:"",slug:"",meta_description:"",featured_image_url:"",content:"",status:"draft"},ie=e=>e?String(e).toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,""):"",le=e=>{let{status:s}=e;const a={published:{label:"Published",cls:"bg-emerald-50 text-emerald-700 border-emerald-200"},draft:{label:"Draft",cls:"bg-amber-50 text-amber-700 border-amber-200"},archived:{label:"Archived",cls:"bg-zinc-100 text-zinc-600 border-zinc-200"}},t=a[s]||a.draft;return(0,Q.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-medium border ".concat(t.cls),children:t.label})},ne=()=>{const[e,s]=i.useState(!0),[a,l]=i.useState([]),[n,d]=i.useState(null),[c,j]=i.useState(!1),[b,N]=i.useState(null),[w,_]=i.useState(te),[A,C]=i.useState(!1),[z,R]=i.useState(!1),[S,B]=i.useState(null),[T,U]=i.useState(!1),P=i.useCallback(async()=>{s(!0);try{const e=await r.ic.listBlogPosts();l(e.posts||[]),d(e.warning||null)}catch(t){var e,a;d((null===t||void 0===t||null===(e=t.response)||void 0===e||null===(a=e.data)||void 0===a?void 0:a.detail)||"Failed to load posts"),l([])}finally{s(!1)}},[]);i.useEffect(()=>{P()},[P]);return(0,Q.jsxs)("div",{className:"space-y-4","data-testid":"blog-admin-panel",children:[(0,Q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Q.jsxs)("div",{children:[(0,Q.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,Q.jsx)(L.A,{className:"w-5 h-5 text-[#FF6B6B]"}),"Blog Posts"]}),(0,Q.jsxs)("p",{className:"text-xs text-zinc-500",children:["Manually-authored posts sit alongside RankLoop articles on the public ",(0,Q.jsx)("code",{className:"text-[11px] bg-zinc-100 px-1 rounded",children:"/blog"})," index."]})]}),(0,Q.jsxs)(o.$,{onClick:()=>{N(null),_(te),R(!1),j(!0)}
1,"data-testid":"blog-new-post-btn",className:"bg-[#FF6B6B] hover:bg-[#fe5050] text-white",children:[(0,Q.jsx)(H.A,{className:"w-4 h-4 mr-2"}),"New post"]})]}),n&&(0,Q.jsx)("div",{className:"border border-amber-200 bg-amber-50 text-amber-900 text-sm rounded-md px-3 py-2",children:n}),(0,Q.jsx)(p.Zp,{children:(0,Q.jsx)(p.Wu,{className:"p-0",children:e?(0,Q.jsx)("div",{className:"py-12 flex justify-center",children:(0,Q.jsx)(y.A,{className:"w-5 h-5 animate-spin text-zinc-400"})}):0===a.length?(0,Q.jsxs)("div",{className:"py-16 text-center text-zinc-500 text-sm","data-testid":"blog-empty-state",children:["No posts yet. Click ",(0,Q.jsx)("strong",{children:"New post"})," to write your first one."]}):(0,Q.jsxs)(v.XI,{children:[(0,Q.jsx)(v.A0,{children:(0,Q.jsxs)(v.Hj,{children:[(0,Q.jsx)(v.nd,{children:"Title"}),(0,Q.jsx)(v.nd,{className:"w-[110px]",children:"Status"}),(0,Q.jsx)(v.nd,{className:"w-[100px]",children:"Source"}),(0,Q.jsx)(v.nd,{className:"w-[150px]",children:"Updated"}),(0,Q.jsx)(v.nd,{className:"w-[260px] text-right",children:"Actions"})]})}),(0,Q.jsx)(v.BF,{children:a.map(e=>(0,Q.jsxs)(v.Hj,{"data-testid":"blog-row-".concat(e.id),children:[(0,Q.jsxs)(v.nA,{children:[(0,Q.jsx)("div",{className:"font-medium text-zinc-900 leading-tight",children:e.title}),(0,Q.jsxs)("div",{className:"text-xs text-zinc-400 truncate max-w-md",children:["/",e.slug]})]}),(0,Q.jsx)(v.nA,{children:(0,Q.jsx)(le,{status:e.status})}),(0,Q.jsx)(v.nA,{children:(0,Q.jsx)("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:e.source||"manual"})}),(0,Q.jsx)(v.nA,{className:"text-xs text-zinc-500",children:e.updated_at?(0,G.Yq)(e.updated_at):"\u2014"}),(0,Q.jsx)(v.nA,{className:"text-right",children:(0,Q.jsxs)("div",{className:"flex items-center justify-end gap-1",children:["published"===e.status&&(0,Q.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>window.open("/blog/".concat(e.slug),"_blank","noopener"),title:"View live","data-testid":"blog-view-".concat(e.id),children:(0,Q.jsx)(F.A,{className:"w-3.5 h-3.5"})}),(0,Q.jsxs)(o.$,{variant:"ghost",size:"sm",onClick:()=>(async e=>{const s="published"===e.status?"draft":"published";try{await r.ic.updateBlogPost(e.id,{status:s}),f.oR.success("published"===s?"Published":"Unpublished"),await P()}catch(i){var a,t;f.oR.error((null===i||void 0===i||null===(a=i.response)||void 0===a||null===(t=a.data)||void 0===t?void 0:t.detail)||"Failed to update status")}})(e),title:"published"===e.status?"Unpublish":"Publish","data-testid":"blog-toggle-".concat(e.id),children:["published"===e.status?(0,Q.jsx)(K.A,{className:"w-3.5 h-3.5"}):(0,Q.jsx)(k.A,{className:"w-3.5 h-3.5"}),(0,Q.jsx)("span",{className:"ml-1 text-xs",children:"published"===e.status?"Unpublish":"Publish"})]}),(0,Q.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>{return N(s=e),_({title:s.title||"",slug:s.slug||"",meta_description:s.meta_description||"",featured_image_url:s.featured_image_url||"",content:s.content||"",status:s.status||"draft"}),R(!0),void j(!0);var s},title:"Edit","data-testid":"blog-edit-".concat(e.id),children:(0,Q.jsx)(Z.A,{className:"w-3.5 h-3.5"})}),(0,Q.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>B(e),title:"Delete","data-testid":"blog-delete-".concat(e.id),className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:(0,Q.jsx)(D.A,{className:"w-3.5 h-3.5"})})]})})]},e.id))})]})})}),(0,Q.jsx)(g.lG,{open:c,onOpenChange:e=>{A||j(e)},children:(0,Q.jsxs)(g.Cf,{className:"max-w-5xl max-h-[90vh] overflow-y-auto","data-testid":"blog-editor-dialog",children:[(0,Q.jsxs)(g.c7,{children:[(0,Q.jsx)(g.L3,{children:b?"Edit post":"New post"}),(0,Q.jsx)(g.rr,{children:"Content is markdown \u2014 same renderer the public blog uses."})]}),(0,Q.jsxs)("div",{className:"space-y-4",children:[(0,Q.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,Q.jsxs)("div",{className:"space-y-1.5",children:[(0,Q.jsx)(u.J,{htmlFor:"blog-title",children:"Title"}),(0,Q.jsx)(x.p,{id:"blog-title",value:w.title,onChange:e=>{return s=e.target.value,void _(e=>(0,t.A)((0,t.A)({},e),{},{title:s,slug:z?e.slug:ie(s)}));var s},placeholder:"How we built our cascading-dropdown editor","data-testid":"blog-input-title"})]}),(0,Q.jsxs)("div",{className:"space-y-1.5",children:[(0,Q.jsx)(u.J,{htmlFor:"blog-slug",children:"Slug"}),(0,Q.jsx)(x.p,{id:"blog-slug",value:w.slug,onChange:e=>{return s=e.target.value,R(!0),void _(e=>(0,t.A)((0,t.A)({},e),{},{slug:ie(s)}));var s},placeholder:"how-we-built-cascading-dropdowns","data-testid":"blog-input-slug"}),(0,Q.jsxs)("p",{className:"text-[11px] text-zinc-400",children:["Public URL: ",(0,Q.jsxs)("code",{className:"bg-zinc-100 px-1 rounded",children:["/blog/",w.slug||"your-slug"]})]})]})]}),(0,Q.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,Q.jsxs)("div",{className:"space-y-1.5",children:[(0,Q.jsx)(u.J,{htmlFor:"blog-meta",children:"Meta description"}),(0,Q.jsx)(h.T,{id:"blog-meta",rows:2,value:w.meta_description,onChange:e=>_(s=>(0,t.A)((0,t.A)({},s),{},{meta_description:e.target.value})),placeholder:"One-sentence summary shown on the blog index and in search results.","data-testid":"blog-input-meta"})]}),(0,Q.jsxs)("div",{className:"space-y-1.5",children:[(0,Q.jsx)(u.J,{htmlFor:"blog-image",children:"Featured image URL"}),(0,Q.jsx)(x.p,{id:"blog-image",value:w.featured_image_url,onChange:e=>_(s=>(0,t.A)((0,t.A)({},s),{},{featured_image_url:e.target.value})),placeholder:"https://\u2026/cover.jpg","data-testid":"blog-input-image"})]})]}),(0,Q.jsxs)("div",{className:"space-y-1.5",children:[(0,Q.jsx)(u.J,{htmlFor:"blog-content",children:"Content (Markdown)"}),(0,Q.jsx)(h.T,{id:"blog-content",rows:20,value:w.content,onChange:e=>_(s=>(0,t.A)((0,t.A)({},s),{},{content:e.target.value})),placeholder:"# Heading\n\nWrite your post here\u2026",className:"font-mono text-sm","data-testid":"blog-input-content"})]}),(0,Q.jsxs)("div",{className:"space-y-1.5",children:[(0,Q.jsx)(u.J,{children:"Status"}),(0,Q.jsxs)(m.l6,{value:w.status,onValueChange:e=>_(s=>(0,t.A)((0,t.A)({},s),{},{status:e})),children:[(0,Q.jsx)(m.bq,{"data-testid":"blog-input-status",children:(0,Q.jsx)(m.yv,{})}),(0,Q.jsxs)(m.gC,{children:[(0,Q.jsx)(m.eb,{value:"draft",children:"Draft (hidden from /blog)"}),(0,Q.jsx)(m.eb,{value:"published",children:"Published (live on /blog)"}),(0,Q.jsx)(m.eb,{value:"archived",children:"Archived (hidden)"})]})]})]})]}),(0,Q.jsxs)(g.Es,{className:"gap-2",children:[(0,Q.jsx)(o.$,{variant:"outline",onClick:()=>j(!1),disabled:A,"data-testid":"blog-cancel",children:"Cancel"}),(0,Q.jsxs)(o.$,{onClick:async()=>
1{if(!w.title.trim())return void f.oR.error("Title is required");if(!w.content.trim())return void f.oR.error("Content is required");const e={title:w.title.trim(),slug:w.slug||ie(w.title),meta_description:w.meta_description||null,featured_image_url:w.featured_image_url||null,content:w.content,status:w.status};C(!0);try{b?(await r.ic.updateBlogPost(b.id,e),f.oR.success("Post updated")):(await r.ic.createBlogPost(e),f.oR.success("Post created")),j(!1),await P()}catch(t){var s,a;f.oR.error((null===t||void 0===t||null===(s=t.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.detail)||"Failed to save post")}finally{C(!1)}},disabled:A,className:"bg-[#FF6B6B] hover:bg-[#fe5050] text-white","data-testid":"blog-save",children:[A&&(0,Q.jsx)(y.A,{className:"w-4 h-4 mr-2 animate-spin"}),(0,Q.jsx)(J.A,{className:"w-4 h-4 mr-2"}),b?"Save changes":"Create post"]})]})]})}),(0,Q.jsx)(g.lG,{open:!!S,onOpenChange:e=>{e||T||B(null)},children:(0,Q.jsxs)(g.Cf,{"data-testid":"blog-delete-dialog",children:[(0,Q.jsxs)(g.c7,{children:[(0,Q.jsx)(g.L3,{children:"Delete this post?"}),(0,Q.jsxs)(g.rr,{children:[(0,Q.jsx)("strong",{children:null===S||void 0===S?void 0:S.title})," will be permanently removed. This cannot be undone."]})]}),(0,Q.jsxs)(g.Es,{className:"gap-2",children:[(0,Q.jsx)(o.$,{variant:"outline",onClick:()=>B(null),disabled:T,children:"Cancel"}),(0,Q.jsxs)(o.$,{onClick:async()=>{if(S){U(!0);try{await r.ic.deleteBlogPost(S.id),f.oR.success("Post deleted"),B(null),await P()}catch(a){var e,s;f.oR.error((null===a||void 0===a||null===(e=a.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to delete post")}finally{U(!1)}}},disabled:T,className:"bg-red-600 hover:bg-red-700 text-white","data-testid":"blog-delete-confirm",children:[T&&(0,Q.jsx)(y.A,{className:"w-4 h-4 mr-2 animate-spin"}),"Yes, delete"]})]})]})})]})},re=()=>{var e,s,a,d,c,h,m,A,k,R,F,I,Z,H,K,ae,te,ie,le,re;const{user:de,isAdmin:ce}=(0,n.As)(),oe=(0,l.Zp)(),[xe,ue]=(0,i.useState)(null),[he,me]=(0,i.useState)([]),[pe,je]=(0,i.useState)(!0),[ve,ge]=(0,i.useState)(""),[be,fe]=(0,i.useState)(null),[Ne,ye]=(0,i.useState)(null),[we,_e]=(0,i.useState)(null),[Ae,ke]=(0,i.useState)(null),[Ce,ze]=(0,i.useState)(!1),[Re,Fe]=(0,i.useState)(!1),[Se,Be]=(0,i.useState)({stripe_secret_key:"",stripe_publishable_key:"",resend_api_key:"",supabase_url:"",supabase_service_key:"",feedback_board_url:""}),[Te,Ue]=(0,i.useState)({head_code:"",body_code:"",footer_code:""}),[Pe,$e]=(0,i.useState)({site_title:"Fantastic Forms - Build Beautiful Forms",site_description:"Create stunning forms with conditional logic, file uploads, voice recordings, and more. Free form builder with premium features.",title_template:"%s | Fantastic Forms",meta_keywords:"form builder, survey, typeform alternative, tally alternative",og_image_url:"",twitter_handle:"",robots_txt:"User-agent: *\nAllow: /\nDisallow: /api/\nDisallow: /admin/\nSitemap: https://fantasticforms.com/sitemap.xml"}),[Ie,Le]=(0,i.useState)({free:{name:"Free",price:"$0",features:["Unlimited forms","Unlimited responses","1MB file uploads","Basic analytics"]},pro:{name:"Pro",price:"$99",billing:"Monthly",file_limit:"5MB",features:["Voice recordings","Remove branding","Custom roles","Priority support","Advanced analytics"]}});(0,i.useEffect)(()=>{ce?Ze():oe("/dashboard")},[ce,oe]);const Ze=async()=>{try{const[o,x,u,h,m]=await Promise.all([r.ic.getStats(),r.ic.getUsers(),r.ic.getSettings().catch(()=>null),r.ic.getIntegrationStatus().catch(()=>null),r.ic.getCredentials().catch(()=>null)]);var e,s,a,i,l,n,d,c;if(ue(o),me(x.users),_e(u),ke(h),m&&Be({stripe_secret_key:m.stripe_secret_key||"",stripe_publishable_key:m.stripe_publishable_key||"",resend_api_key:m.resend_api_key||"",supabase_url:m.supabase_url||"",supabase_anon_key:m.supabase_anon_key||"",supabase_publishable_key:m.supabase_publishable_key||"",supabase_secret_key:m.supabase_secret_key||"",feedback_board_url:m.feedback_board_url||""}),u)if(u.seo&&$e(e=>(0,t.A)((0,t.A)({},e),u.seo)),u.code_injection&&Ue(e=>(0,t.A)((0,t.A)({},e),u.code_injection)),u.plans)Le({free:{name:(null===(e=u.plans.free)||void 0===e?void 0:e.name)||"Free",price:(null===(s=u.plans.free)||void 0===s?void 0:s.price)||"$0",features:(null===(a=u.plans.free)||void 0===a?void 0:a.features)||["Unlimited forms","Unlimited responses","1MB file uploads","Basic analytics"]},pro:{name:(null===(i=u.plans.pro)||void 0===i?void 0:i.name)||"Pro",price:(null===(l=u.plans.pro)||void 0===l?void 0:l.price)||"$99",billing:(null===(n=u.plans.pro)||void 0===n?void 0:n.billing)||"Monthly",file_limit:(null===(d=u.plans.pro)||void 0===d?void 0:d.file_limit)||"5MB",features:(null===(c=u.plans.pro)||void 0===c?void 0:c.features)||["Voice recordings","Remove branding","Custom roles","Priority support","Advanced analytics"]}})}catch(o){f.oR.error("Failed to load admin data")}finally{je(!1)}},He=async e=>{if(window.confirm("Are you sure you want to ban this user?"))try{await r.ic.banUser(e),me(s=>s.map(s=>s.id===e?(0,t.A)((0,t.A)({},s),{},{status:"banned"}):s)),f.oR.success("User banned")}catch(i){var s,a;f.oR.error((null===(s=i.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.detail)||"Failed to ban user")}},Ee=async e=>{try{await r.ic.unbanUser(e),me(s=>s.map(s=>s.id===e?(0,t.A)((0,t.A)({},s),{},{status:"active"}):s)),f.oR.success("User unbanned")}catch(s){f.oR.error("Failed to unban user")}},Je=async e=>{if(window.confirm("Are you sure you want to delete this user? All their data will be permanently removed."))try{await r.ic.deleteUser(e),me(s=>s.filter(s=>s.id!==e)),fe(null),f.oR.success("User deleted")}catch(t){var s,a;f.oR.error((null===(s=t.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.detail)||"Failed to delete user")}},Me=he.filter(e=>{var s,a;return(null===(s=e.email)||void 0===s?void 0:s.toLowerCase().includes(ve.toLowerCase()))||(null===(a=e.name)||void 0===a?void 0:a.toLowerCase().includes(ve.toLowerCase()))});return pe?(0,Q.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-zinc-50",children:(0,Q.jsx)(Y.A,{size:48})}):(0,Q.jsxs)("div",{className:"min-h-screen bg-zinc-50","data-testid":"admin-page",children:[(0,Q.jsx)("header",{className:"bg-zinc-900 text-white",children:(0,Q.jsxs)("div",{className:"max-w-7xl mx-auto px-6 h-16 flex items-center justify-between",children:[(0,Q.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Q.jsx)(l.N_,{to:"/dashboard",className:"p-2 hover:bg-zinc-800 rounded-lg transition-colors",children:(0,Q.jsx)(w.A,{className:"w-5 h-5"})}),(0,Q.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Q.jsx)(q.A,{className:"w-5 h-5 text-[#FF6B6B]"}),(0,Q.jsx)("h1",{className:"font-semibold",children:"Admin Dashboard"})]})]}),(0,Q.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Q.jsx)(l.N_,{to:"/admin/audit-log","data-testid":"admin-audit-log-link",children:(0,Q.jsxs)(o.$,{variant:"ghost",size:"sm",className:"text-white hover:bg-zinc-800",children:[(0,Q.jsx)(q.A,{className:"w-4 h-4 mr-2"}),"Audit log"]})}),(0,Q.jsxs)(o.$,{variant:"ghost",size:"sm",onClick:Ze,className:"text-white hover:bg-zinc-800",children:[(0,Q.jsx)(E.A,{className:"w-4 h-4 mr-2"}),"Refresh"]})]})]})}),(0,Q.jsx)("main",{className:"max-w-7xl mx-auto px-6 py-8",children:(0,Q.jsxs)(j.tU,{defaultValue:"overview",className:"space-y-6",children:[(0,Q.jsxs)(j.j7,{children:[(0,Q.jsxs)(j.Xi,{value:"overview",children:[(0,Q.jsx)(N.A,{className:"w-4 h-4 mr-2"}),"Overview"]}),(0,Q.jsxs)(j.Xi,{value:"traffic-revenue","data-testid":"traffic-revenue-tab",children:[(0,Q.jsx)(V.A,{className:"w-4 h-4 mr-2"}),"Traffic & Revenue"]}),(0,Q.jsxs)(j.Xi,{value:"users",children:[(0,Q.jsx)(O.A,{className:"w-4 h-4 mr-2"}),"Users"]}),(0,Q.jsxs)(j.Xi,{value:"credentials","data-testid":"credentials-tab",children:[(0,Q.jsx)(U.A,{className:"w-4 h-4 mr-2"}),"Credentials"]}),(0,Q.jsxs)(j.Xi,{value:"code-injection",children:[(0,Q.jsx)(W.A,{className:"w-4 h-4 mr-2"}),"Code Injection"]}),(0,Q.jsxs)(j.Xi,{value:"blog","data-testid":"blog-tab",children:[(0,Q.jsx)(L.A,{className:"w-4 h-4 mr-2"}),"Blog"]})]}),(0,Q.jsxs)(j.av,{value:"overview",children:[(0,Q.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[(0,Q.jsx)(p.Zp,{children:(0,Q.jsxs)(p.Wu,{className:"p-6",children:[(0,Q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Total Users"}),(0,Q.jsx)("p",{className:"text-3xl font-bold",children:(null===xe||void 0===xe||null===(e=xe.users)||void 0===e?void 0:e.total)||0})]}),(0,Q.jsx)(O.A,{className:"w-10 h-10 text-zinc-300"})]}),(0,Q.jsxs)("div",{className:"mt-2 text-xs text-zinc-500",children:[(0,Q.jsxs)("span",{className:"text-green-600",children:[(null===xe||void 0===xe||null===(s=xe.users)||void 0===s?void 0:s.active)||0," active"]})," \xb7 ",(0,Q.jsxs)("span",{className:"text-red-600",children:[(null===xe||void 0===xe||null===(a=xe.users)||void 0===a?void 0:a.banned)||0," banned"]})]})]})}),(0,Q.jsx)(p.Zp,{children:(0,Q.jsxs)(p.Wu,{className:"p-6",children:[(0,Q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Paid Users"}),(0,Q.jsx)("p",{className:"text-3xl font-bold",children:(null===xe||void 0===xe||null===(d=xe.users)||void 0===d?void 0:d.paid)||0})]}),(0,Q.jsx)(C.A,{className:"w-10 h-10 text-zinc-300"})]}),(0,Q.jsxs)("div",{className:"mt-2 text-xs text-zinc-500",children:["$",99*((null===xe||void 0===xe||null===(c=xe.users)||void 0===c?void 0:c.paid)||0)," revenue"]})]})}),(0,Q.jsx)(p.Zp,{children:(0,Q.jsxs)(p.Wu,{className:"p-6",children:[(0,Q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Total Forms"}),(0,Q.jsx)("p",{className:"text-3xl font-bold",children:(null===xe||void 0===xe||null===(h=xe.forms)||void 0===h?void 0:h.total)||0})]}),(0,Q.jsx)(B.A,{className:"w-10 h-10 text-zinc-300"})]}),(0,Q.jsxs)("div",{className:"mt-2 text-xs text-zinc-500",children:[(null===xe||void 0===xe||null===(m=xe.forms)||void 0===m?void 0:m.published)||0," published"]})]})}),(0,Q.jsx)(p.Zp,{children:(0,Q.jsx)(p.Wu,{className:"p-6",children:(0,Q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Submissions"}),(0,Q.jsx)("p",{className:"text-3xl font-bold",children:(null===xe||void 0===xe||null===(A=xe.submissions)||void 0===A?void 0:A.total)||0})]}),(0,Q.jsx)(N.A,{className:"w-10 h-10 text-zinc-300"})]})})})]}
1),(0,Q.jsxs)(p.Zp,{className:"mt-4","data-testid":"admin-seo-utilities",children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsx)(p.ZB,{className:"text-base",children:"SEO utilities"}),(0,Q.jsx)(p.BT,{children:"Push every URL in the sitemap to Bing IndexNow. Search engines re-crawl within hours instead of days, so redeploys that change titles or meta descriptions ship to search results faster. Yandex, Naver and Seznam receive the same submission."})]}),(0,Q.jsx)(p.Wu,{children:(0,Q.jsx)(o.$,{onClick:async()=>{Fe(!0);try{var e;const s=await r.TC.submitSitemap(),a=null!==(e=null===s||void 0===s?void 0:s.total_urls)&&void 0!==e?e:0;if(Array.isArray(null===s||void 0===s?void 0:s.results)&&s.results.every(e=>e.ok))f.oR.success("Submitted ".concat(a," URLs to Bing IndexNow."));else{const e=((null===s||void 0===s?void 0:s.results)||[]).find(e=>!e.ok),t=(null===e||void 0===e?void 0:e.body)||"";t.includes("SiteVerificationNotCompleted")?f.oR.info("IndexNow queued ".concat(a," URLs but Bing is still verifying the site key. This is normal on the first submission and typically clears within a few hours (up to 24h). Retry then."),{duration:12e3}):f.oR.warning("IndexNow accepted ".concat(a," URLs but returned ").concat(null===e||void 0===e?void 0:e.status_code,". Response: ").concat(t||"(empty)"))}}catch(t){var s,a;f.oR.error((null===t||void 0===t||null===(s=t.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.detail)||(null===t||void 0===t?void 0:t.message)||"IndexNow submission failed")}finally{Fe(!1)}},disabled:Re,"data-testid":"admin-indexnow-submit-btn",className:"bg-zinc-900 hover:bg-zinc-800 text-white",children:Re?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y.A,{className:"w-4 h-4 mr-2 animate-spin"})," Submitting..."]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T.A,{className:"w-4 h-4 mr-2"})," Push all URLs to Bing (IndexNow)"]})})})]})]}),(0,Q.jsx)(j.av,{value:"traffic-revenue",children:(0,Q.jsx)(se,{})}),(0,Q.jsx)(j.av,{value:"users",children:(0,Q.jsxs)(p.Zp,{children:[(0,Q.jsx)(p.aR,{children:(0,Q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Q.jsx)(p.ZB,{children:"Users"}),(0,Q.jsxs)("div",{className:"relative w-64",children:[(0,Q.jsx)(M.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400"}),(0,Q.jsx)(x.p,{placeholder:"Search users...",value:ve,onChange:e=>ge(e.target.value),className:"pl-9","data-testid":"admin-search-input"})]})]})}),(0,Q.jsx)(p.Wu,{children:(0,Q.jsx)("div",{className:"overflow-x-auto",children:(0,Q.jsxs)(v.XI,{children:[(0,Q.jsx)(v.A0,{children:(0,Q.jsxs)(v.Hj,{children:[(0,Q.jsx)(v.nd,{children:"User"}),(0,Q.jsx)(v.nd,{children:"Plan"}),(0,Q.jsx)(v.nd,{children:"Status"}),(0,Q.jsx)(v.nd,{children:"Forms"}),(0,Q.jsx)(v.nd,{children:"Last Login"}),(0,Q.jsx)(v.nd,{children:"Device / IP"}),(0,Q.jsx)(v.nd,{children:"Actions"})]})}),(0,Q.jsx)(v.BF,{children:Me.map(e=>(0,Q.jsxs)(v.Hj,{"data-testid":"user-row-".concat(e.id),children:[(0,Q.jsx)(v.nA,{children:(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"font-medium",children:e.name}),(0,Q.jsx)("p",{className:"text-xs text-zinc-500",children:e.email})]})}),(0,Q.jsx)(v.nA,{children:(0,Q.jsx)(b.E,{variant:"paid"===e.plan?"default":"secondary",children:e.plan})}),(0,Q.jsx)(v.nA,{children:(0,Q.jsx)(b.E,{variant:"active"===e.status?"default":"destructive",className:"active"===e.status?"bg-green-100 text-green-800":"",children:e.status})}),(0,Q.jsx)(v.nA,{children:e.form_count||0}),(0,Q.jsx)(v.nA,{className:"text-zinc-500 text-sm",children:e.last_login?(0,G.r6)(e.last_login):"Never"}),(0,Q.jsx)(v.nA,{className:"text-zinc-500 text-sm",children:(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"capitalize",children:e.last_device||"-"}),(0,Q.jsx)("p",{className:"text-xs",children:e.last_ip||"-"})]})}),(0,Q.jsx)(v.nA,{children:(0,Q.jsxs)("div",{className:"flex items-center gap-1",children:[(0,Q.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>(async e=>{try{const s=await r.ic.getUser(e);ye(s),fe(e)}catch(s){f.oR.error("Failed to load user details")}})(e.id),children:(0,Q.jsx)(S.A,{className:"w-4 h-4"})}),"admin"!==e.role&&(0,Q.jsxs)(Q.Fragment,{children:["banned"===e.status?(0,Q.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>Ee(e.id),children:(0,Q.jsx)(X.A,{className:"w-4 h-4 text-green-600"})}):(0,Q.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>He(e.id),children:(0,Q.jsx)(_.A,{className:"w-4 h-4 text-yellow-600"})}),(0,Q.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>Je(e.id),children:(0,Q.jsx)(D.A,{className:"w-4 h-4 text-red-600"})})]})]})})]},e.id))})]})})})]})}),(0,Q.jsx)(j.av,{value:"credentials",children:(0,Q.jsx)("div",{className:"grid gap-6",children:(0,Q.jsxs)(p.Z
1p,{children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsxs)(p.ZB,{className:"flex items-center gap-2",children:[(0,Q.jsx)(U.A,{className:"w-5 h-5"}),"Integration Credentials"]}),(0,Q.jsx)(p.BT,{children:"Enter API keys and credentials for third-party services. These are securely stored and used for integrations."})]}),(0,Q.jsxs)(p.Wu,{className:"space-y-6",children:[(0,Q.jsxs)("div",{className:"p-4 border rounded-lg space-y-4",children:[(0,Q.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Q.jsx)(C.A,{className:"w-5 h-5 text-[#635BFF]"}),(0,Q.jsx)("h3",{className:"font-semibold",children:"Stripe (Payments)"}),(null===Ae||void 0===Ae||null===(k=Ae.stripe)||void 0===k?void 0:k.configured)&&(0,Q.jsx)(b.E,{className:"bg-green-100 text-green-800",children:"Configured"})]}),(0,Q.jsxs)("div",{className:"grid md:grid-cols-2 gap-4",children:[(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"stripe_secret",children:"Secret Key"}),(0,Q.jsx)(x.p,{id:"stripe_secret",type:"password",placeholder:"sk_live_...",value:Se.stripe_secret_key,onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{stripe_secret_key:e.target.value})),"data-testid":"stripe-secret-input"})]}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"stripe_publishable",children:"Publishable Key"}),(0,Q.jsx)(x.p,{id:"stripe_publishable",type:"text",placeholder:"pk_live_...",value:Se.stripe_publishable_key,onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{stripe_publishable_key:e.target.value})),"data-testid":"stripe-publishable-input"})]})]})]}),(0,Q.jsxs)("div",{className:"p-4 border rounded-lg space-y-4",children:[(0,Q.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Q.jsx)(P.A,{className:"w-5 h-5 text-blue-600"}),(0,Q.jsx)("h3",{className:"font-semibold",children:"Resend (Transactional Email)"}),(null===Ae||void 0===Ae||null===(R=Ae.resend)||void 0===R?void 0:R.configured)&&(0,Q.jsx)(b.E,{className:"bg-green-100 text-green-800",children:"Configured"})]}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"resend_key",children:"API Key"}),(0,Q.jsx)(x.p,{id:"resend_key",type:"password",placeholder:"re_...",value:Se.resend_api_key,onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{resend_api_key:e.target.value})),"data-testid":"resend-key-input"})]})]}),(0,Q.jsxs)("div",{className:"p-4 border rounded-lg space-y-4",children:[(0,Q.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Q.jsx)(z.A,{className:"w-5 h-5 text-emerald-600"}),(0,Q.jsx)("h3",{className:"font-semibold",children:"Supabase (Database, Auth & Storage)"}),(null===Ae||void 0===Ae||null===(F=Ae.supabase)||void 0===F?void 0:F.configured)&&(0,Q.jsx)(b.E,{className:"bg-green-100 text-green-800",children:"Configured"})]}),(0,Q.jsxs)("div",{className:"grid md:grid-cols-2 gap-4",children:[(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"supabase_url",children:"Project URL"}),(0,Q.jsx)(x.p,{id:"supabase_url",type:"text",placeholder:"https://xxx.supabase.co",value:Se.supabase_url||"",onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{supabase_url:e.target.value})),"data-testid":"supabase-url-input"})]}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"supabase_anon_key",children:"Anon Key"}),(0,Q.jsx)(x.p,{id:"supabase_anon_key",type:"password",placeholder:"eyJ...",value:Se.supabase_anon_key||"",onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{supabase_anon_key:e.target.value})),"data-testid":"supabase-anon-key-input"})]}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"supabase_publishable_key",children:"Publishable Key"}),(0,Q.jsx)(x.p,{id:"supabase_publishable_key",type:"text",placeholder:"sb_publishable_...",value:Se.supabase_publishable_key||"",onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{supabase_publishable_key:e.target.value})),"data-testid":"supabase-publishable-key-input"})]}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"supabase_secret_key",children:"Secret Key"}),(0,Q.jsx)(x.p,{id:"supabase_secret_key",type:"password",placeholder:"sb_secret_...",value:Se.supabase_secret_key||"",onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{supabase_secret_key:e.target.value})),"data-testid":"supabase-secret-key-input"})]})]})]}),(0,Q.jsxs)("div",{className:"p-4 border rounded-lg space-y-4",children:[(0,Q.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Q.jsx)($.A,{className:"w-5 h-5 text-blue-600"}),(0,Q.jsx)("h3",{className:"font-semibold",children:"Feedback Board"})]}),(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:'Link to an external feedback board (e.g., Canny, Featurebase). This will be used for the "Feedback" menu link.'}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{htmlFor:"feedback_url",children:"Feedback Board URL"}),(0,Q.jsx)(x.p,{id:"feedback_url",type:"url",placeholder:"https://yourcompany.canny.io or https://yourcompany.featurebase.app",value:Se.feedback_board_url||"",onChange:e=>Be(s=>(0,t.A)((0,t.A)({},s),{},{feedback_board_url:e.target.value})),"data-testid":"feedback-url-input"})]})]}),(0,Q.jsxs)(o.$,{onClick:async()=>{ze(!0);try{const e={};if(Object.entries(Se).forEach(s=>{let[a,t]=s;t&&t.trim()&&(e[a]=t.trim())}),0===Object.keys(e).length)return void f.oR.error("Please enter at least one credential");await r.ic.updateIntegrations(e),f.oR.success("Credentials saved successfully");const s=await r.ic.getIntegrationStatus();ke(s);const a=await r.ic.getCredentials();a&&Be({stripe_secret_key:a.stripe_secret_key||"",stripe_publishable_key:a.stripe_publishable_key||"",resend_api_key:a.resend_api_key||"",supabase_url:a.supabase_url||"",supabase_service_key:a.supabase_service_key||"",feedback_board_url:a.feedback_board_url||""})}catch(e){f.oR.error("Failed to save credentials")}finally{ze(!1)}},disabled:Ce,className:"w-full","data-testid":"save-credentials-btn",children:[Ce?(0,Q.jsx)(y.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,Q.jsx)(J.A,{className:"w-4 h-4 mr-2"}),"Save Credentials"]}
1),(0,Q.jsxs)("div",{className:"pt-6 border-t mt-6",children:[(0,Q.jsx)("h4",{className:"font-medium mb-2",children:"Error Tracking Test"}),(0,Q.jsx)("p",{className:"text-sm text-zinc-500 mb-3",children:"Click below to send a test error to Sentry and verify error tracking is working."}),(0,Q.jsx)(ee,{})]})]})]})})}),(0,Q.jsx)(j.av,{value:"code-injection",children:(0,Q.jsxs)(p.Zp,{children:[(0,Q.jsxs)(p.aR,{children:[(0,Q.jsx)(p.ZB,{children:"Code Injection"}),(0,Q.jsx)(p.BT,{children:"Add custom code to all forms and pages"})]}),(0,Q.jsxs)(p.Wu,{className:"space-y-6",children:[(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{children:"Header Code (before </head>)"}),(0,Q.jsx)("textarea",{className:"w-full h-40 font-mono text-sm p-3 border rounded-lg",placeholder:"\x3c!-- Add your header code here --\x3e\n\x3c!-- Google Analytics, Meta Pixel, etc. --\x3e",value:Te.head_code,onChange:e=>Ue(s=>(0,t.A)((0,t.A)({},s),{},{head_code:e.target.value}))}),(0,Q.jsx)("p",{className:"text-xs text-zinc-500",children:"This code will be added to the <head> section of all pages"})]}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{children:"Body Start Code (after <body>)"}),(0,Q.jsx)("textarea",{className:"w-full h-40 font-mono text-sm p-3 border rounded-lg",placeholder:"\x3c!-- Add your body start code here --\x3e\n\x3c!-- GTM noscript, etc. --\x3e",value:Te.body_code,onChange:e=>Ue(s=>(0,t.A)((0,t.A)({},s),{},{body_code:e.target.value}))})]}),(0,Q.jsxs)("div",{className:"space-y-2",children:[(0,Q.jsx)(u.J,{children:"Footer Code (before </body>)"}),(0,Q.jsx)("textarea",{className:"w-full h-40 font-mono text-sm p-3 border rounded-lg",placeholder:"\x3c!-- Add your footer code here --\x3e\n\x3c!-- Chat widgets, tracking scripts, etc. --\x3e",value:Te.footer_code,onChange:e=>Ue(s=>(0,t.A)((0,t.A)({},s),{},{footer_code:e.target.value}))})]}),(0,Q.jsxs)(o.$,{onClick:async()=>{ze(!0);try{await r.ic.updateSettings({code_injection:Te}),f.oR.success("Code injection settings saved")}catch(e){f.oR.error("Failed to save code injection settings")}finally{ze(!1)}},disabled:Ce,children:[Ce?(0,Q.jsx)(y.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,Q.jsx)(J.A,{className:"w-4 h-4 mr-2"}),"Save Code Injection"]})]})]})}),(0,Q.jsx)(j.av,{value:"blog",children:(0,Q.jsx)(ne,{})})]})}),(0,Q.jsx)(g.lG,{open:!!be,onOpenChange:()=>fe(null),children:(0,Q.jsxs)(g.Cf,{className:"max-w-2xl",children:[(0,Q.jsx)(g.c7,{children:(0,Q.jsx)(g.L3,{children:"User Details"})}),Ne&&(0,Q.jsxs)("div",{className:"space-y-6 py-4",children:[(0,Q.jsxs)("div",{className:"grid grid-cols-2 gap-4 p-4 bg-zinc-50 rounded-lg",children:[(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Name"}),(0,Q.jsx)("p",{className:"font-medium",children:null===(I=Ne.user)||void 0===I?void 0:I.name})]}),(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Email"}),(0,Q.jsx)("p",{className:"font-medium",children:null===(Z=Ne.user)||void 0===Z?void 0:Z.email})]}),(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Plan"}),(0,Q.jsx)("p",{className:"font-medium capitalize",children:null===(H=Ne.user)||void 0===H?void 0:H.plan})]}),(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Status"}),(0,Q.jsx)("p",{className:"font-medium capitalize",children:null===(K=Ne.user)||void 0===K?void 0:K.status})]}),(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Joined"}),(0,Q.jsx)("p",{className:"font-medium",children:(0,G.Yq)(null===(ae=Ne.user)||void 0===ae?void 0:ae.created_at)})]}),(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"text-sm text-zinc-500",children:"Total Submissions"}),(0,Q.jsx)("p",{className:"font-medium",children:Ne.total_submissions})]})]}),(0,Q.jsxs)("div",{children:[(0,Q.jsxs)("h4",{className:"font-semibold mb-3",children:["Forms (",(null===(te=Ne.forms)||void 0===te?void 0:te.length)||0,")"]}),(null===(ie=Ne.forms)||void 0===ie?void 0:ie.length)>0?(0,Q.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:Ne.forms.map(e=>(0,Q.jsx)("div",{className:"flex items-center justify-between p-3 bg-zinc-50 rounded-lg",children:(0,Q.jsxs)("div",{children:[(0,Q.jsx)("p",{className:"font-medium",children:e.title}),(0,Q.jsxs)("p",{className:"text-xs text-zinc-500",children:[e.submissions_count," submissions \xb7 ",e.status]})]})},e.id))}):(0,Q.jsx)("p",{className:"text-zinc-500 text-sm",children:"No forms created"})]}),(0,Q.jsxs)("div",{className:"flex gap-2 pt-4 border-t",children:[(0,Q.jsx)(o.$,{variant:"outline",onClick:()=>(async e=>{if(window.confirm("Clear all submissions for this user's forms?"))try{const s=await r.ic.clearSubmissions(e);f.oR.success(s.message)}catch(s){f.oR.error("Failed to clear submissions")}})(be),children:"Clear Submissions"}),"admin"!==(null===(le=Ne.user)||void 0===le?void 0:le.role)&&(0,Q.jsxs)(Q.Fragment,{children:["banned"===(null===(re=Ne.user)||void 0===re?void 0:re.status)?(0,Q.jsx)(o.$,{onClick:()=>Ee(be),children:"Unban User"}):(0,Q.jsx)(o.$,{variant:"destructive",onClick:()=>He(be),children:"Ban User"}),(0,Q.jsx)(o.$,{variant:"destructive",onClick:()=>Je(be),children:"Delete User"})]})]})]})]})})]})}}}]); 2//# sourceMappingURL=2624.818e6690.chunk.js.map
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.