1import{r as d,j as e,l as ye,u as je,k as ve}from"./vendor-react-DgB3iddG.js";import{d as F}from"./vendor-mui-dates-KAGm-C0e.js";import{r as ie}from"./relativeTime-CxkCVA_Y.js";import{u as Ne}from"./usePageTitle-DrV3LWkF.js";import{L as we}from"./Loader-CS_NcaeR.js";import{B as E}from"./Button-Db-HvAAM.js";import{S as _e,a as ke,b as Se,c as Ce,d as J}from"./Select-70f5R9tb.js";import{e as Y,d as A,T as V,L as O,R as oe,t as I,a as $}from"./index-BsRQWV7N.js";import{C as T,c as P,a as Te,b as Pe}from"./Card-Cw165hpS.js";import{S as Ae}from"./settings-yWqZPF4C.js";import{M as ce}from"./mouse-pointer-click-CmWi-HZu.js";import{G as X}from"./globe-CnwG3Yxz.js";import{C as Ie}from"./ColorPicker-DsR4V7KY.js";import{P as Le}from"./palette-GLMlif8X.js";import{M as Ee}from"./message-circle-BrUoq2LQ.js";import{U as de}from"./user-BSW88z6a.js";import{I as ee}from"./image-TQq6EuBL.js";import{a as Me,P as Re,S as $e}from"./square-code-BpKbCrBS.js";import{C as Be}from"./chevrons-up-down-rIbGivHO.js";import{X as q}from"./x-DWKg9FV8.js";import{S as ue}from"./search-ZjzgN1r7.js";import{C as K}from"./check-DYtTEDZg.js";import{A as De}from"./arrow-down-right-BC3-H-rW.js";import{A as Fe}from"./arrow-up-right-CMFlUzg7.js";import{a as Oe,A as Ue}from"./arrow-up-CrIJ9bue.js";import{R as ze}from"./repeat-2kJNHiP9.js";import{L as He}from"./layers-IMX1YlSc.js";import{S as Ve}from"./smartphone-Cx049nuU.js";import{M as We}from"./message-square-D7Ghlg3r.js";import{U as Ge}from"./users-C-8OuGS6.js";import{C as Ye}from"./clock-a58MzTpI.js";import{W as Xe}from"./webhook-D5JN-nqC.js";import{U as me}from"./upload-ChxJlI8S.js";import{S as xe}from"./sparkles-CclfS-zl.js";import{C as U}from"./copy-DBlEVzEc.js";import{D as qe}from"./download-HJSAkqxn.js";import{C as Ke}from"./circle-alert--s34Tx7J.js";import{C as Qe}from"./ConfirmationModal-C-Mdj4uA.js";import{D as Ze,S as Je}from"./shopping-bag-BOWAI7_f.js";import{T as W}from"./trash-2-De6jbET0.js";import{E as et}from"./eye-DERChyZO.js";import{T as tt}from"./trending-up-DIKUtlYZ.js";import{C as at}from"./code-Kq9tq5Ic.js";import{I as st}from"./info-BHJQcz8S.js";import{A as rt}from"./arrow-left-DjjddyBh.js";import{H as lt}from"./hash-BnfmGt8P.js";import"./vendor-radix-Cc5wg9nu.js";import"./chevron-down-C2bolbZ7.js";import"./chevron-up-daRQHEXm.js";import"./vendor-realtime-BWTNjo9H.js";import"./Input-9YFrCCg-.js";import"./Dialog-BHIUuuFq.js";/** 2 * @license lucide-react v0.554.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 nt=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],it=Y("arrow-down-left",nt);/** 7 * @license lucide-react v0.554.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 ot=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],ct=Y("arrow-up-left",ot);/** 12 * @license lucide-react v0.554.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const dt=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ut=Y("badge-check",dt),mt={active:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",paused:"bg-amber-500/10 text-amber-600 border-amber-500/20"},xt="bg-muted text-muted-foreground border-border",te="flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm r
16ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 focus-visible:border-primary transition-all";function pt({proof:t,onUpdate:a}){const[l,s]=d.useState(()=>(t.domain_whitelist||[]).join(` 17`)),r=o=>{const c=o.split(` 18`).map(i=>i.trim()).filter(Boolean);a({domain_whitelist:c})};return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(T,{className:"border-l-[3px] border-l-primary overflow-hidden",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(Ae,{className:"w-4 h-4 text-primary"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Proof Settings"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Name"}),e.jsx("input",{defaultValue:t.name,onBlur:o=>{o.target.value!==t.name&&a({name:o.target.value})},className:te})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Status"}),e.jsx("div",{children:e.jsx("span",{className:`inline-flex items-center px-3.5 py-1.5 rounded-lg text-xs font-semibold uppercase tracking-wider border ${mt[t.status]||xt}`,children:t.status})}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Use the status selector in the header to change this."})]})]})}),e.jsx(T,{className:"border-l-[3px] border-l-blue-500 overflow-hidden",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-blue-500/10",children:e.jsx(ce,{className:"w-4 h-4 text-blue-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Click Behavior"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Click URL"}),e.jsx("input",{type:"url",defaultValue:t.click_url||"",onBlur:o=>a({click_url:o.target.value||null}),placeholder:"https://example.com/landing-page",className:te}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"When set, clicking the notification opens this URL and counts a click."})]}),e.jsx(G,{checked:t.click_open_new_tab??!0,onChange:o=>a({click_open_new_tab:o}),label:"Open in new tab"}),e.jsx(G,{checked:t.closeable??!0,onChange:o=>a({closeable:o}),label:"Show close (X) button"}),e.jsx(G,{checked:t.branding_enabled??!0,onChange:o=>a({branding_enabled:o}),label:"Show 'by PageDock' badge"})]})}),e.jsx(T,{className:"border-l-[3px] border-l-teal-500 overflow-hidden lg:col-span-2",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-teal-500/10",children:e.jsx(X,{className:"w-4 h-4 text-teal-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Domain Whitelist"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:l,onChange:o=>s(o.target.value),onBlur:()=>r(l),rows:6,placeholder:`example.com 19shop.example.com`,className:"flex w-full rounded-xl border border-input bg-background px-4 py-3 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 focus-visible:border-primary transition-all resize-none font-mono"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"One domain per line. Leave empty to allow the widget on any domain."})]})]})})]})}function G({checked:t,onChange:a,label:l}){return e.jsxs("div",{className:"flex items-center gap-3 py-1",children:[e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:!!t,onChange:s=>a(s.target.checked)}),e.jsx("div",{className:"w-9 h-5 bg-muted rounded-full peer peer-checked:bg-primary after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:after:translate-x-full"})]}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:l})]})}function ft({theme:t,isSelected:a,onClick:l}){const s=String(t.colors.bg||"").includes("gradient");return e.jsxs("button",{type:"button",onClick:l,className:A("w-full rounded-xl border-2 p-3 transition-all text-left flex flex-col gap-3",a?"border-primary ring-2 ring-primary/30 bg-primary/5":"border-border hover:border-primary/40 bg-card"),children:[e.jsxs("div",{className:"rounded-lg p-3 flex items-center gap-2 overflow-hidden",style:{background:t.colors.bg,color:t.colors.text,border:`1px solid ${t.colors.border}`,minHeight:56},children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0",style:{background:t.colors.accent,color:ht(t.colors.accent)},children:"JM"}),e.jsxs("div",{className:"text-[11px] leading-tight flex-1 min-w-0",children:[e.jsx("div",{style:{fontWeight:700},className:"truncate",children:"John M."}),e.jsx("div",{style:{opacity:.75},className:"truncate",children:"just purchased"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:t.name}),e.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mt-0.5",children:[t.category,s?" · gradient":""]})]})]})}function ht(t){const a=String(t).match(/#([0-9a-f]{6})/i);if(!a)return"#ffffff";const l=parseInt(a[1].slice(0,2),16),s=parseInt(a[1].slice(2,4),16),r=parseInt(a[1].slice(4,6),16),o=i=>{const u=i/255;return u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)};return .2126*o(l)+.7152*o(s)+.0722*o(r)>.55?"#1f2937":"#ffffff"}const pe=[{id:"clean_white",name:"Clean White",category:"default",colors:{bg:"#ffffff",text:"#0f172a",accent:"#2563eb",border:"#e2e8f0",surface:"#f8fafc"},default_avatar_style:"initials"},{id:"midnight",name:"Midnight",category:"default",colors:{bg:"#0f172a",text:"#ffffff",accent:"#3b82f6",border:"#1e293b",surface:"#1e293b"},default_avatar_style:"initials"},{id:"slate",name:"Slate",category:"default",colors:{bg:"#475569",text:"#ffffff",accent:"#fbbf24",border:"#334155",surface:"#334155"},default_avatar_style:"initials"},{id:"mint",name:"Mint",category:"default",colors:{bg:"#ecfdf5",text:"#064e3b",accent:"#059669",border:"#a7f3d0",
19surface:"#d1fae5"},default_avatar_style:"initials"},{id:"sunset_blaze",name:"Sunset Blaze",category:"modern",colors:{bg:"linear-gradient(135deg, #f97316 0%, #ec4899 50%, #8b5cf6 100%)",text:"#ffffff",accent:"#fef3c7",border:"rgba(255, 255, 255, 0.2)",surface:"rgba(255, 255, 255, 0.12)"},default_avatar_style:"initials"},{id:"aurora",name:"Aurora",category:"modern",colors:{bg:"linear-gradient(135deg, #06b6d4 0%, #8b5cf6 50%, #ec4899 100%)",text:"#ffffff",accent:"#fef9c3",border:"rgba(255, 255, 255, 0.18)",surface:"rgba(255, 255, 255, 0.12)"},default_avatar_style:"initials"},{id:"deep_ocean",name:"Deep Ocean",category:"modern",colors:{bg:"linear-gradient(180deg, #0c4a6e 0%, #0e7490 100%)",text:"#ecfeff",accent:"#67e8f9",border:"rgba(103, 232, 249, 0.25)",surface:"rgba(0, 0, 0, 0.18)"},default_avatar_style:"initials"},{id:"electric_violet",name:"Electric Violet",category:"modern",colors:{bg:"linear-gradient(135deg, #7c3aed 0%, #d946ef 100%)",text:"#ffffff",accent:"#a3e635",border:"rgba(163, 230, 53, 0.4)",surface:"rgba(0, 0, 0, 0.18)"},default_avatar_style:"initials"},{id:"map_mini",name:"Map Mini",category:"map",colors:{bg:"#ffffff",text:"#0f172a",accent:"#10b981",border:"#e2e8f0",surface:"#f1f5f9"},default_avatar_style:"map"},{id:"map_glass",name:"Map Glass",category:"map",colors:{bg:"rgba(15, 23, 42, 0.92)",text:"#ffffff",accent:"#22d3ee",border:"rgba(255, 255, 255, 0.12)",surface:"rgba(255, 255, 255, 0.08)"},default_avatar_style:"map"},{id:"map_ribbon",name:"Map Ribbon",category:"map",colors:{bg:"#ffffff",text:"#1f2937",accent:"#f97316",border:"#e2e8f0",surface:"#fef3c7"},default_avatar_style:"map"},{id:"pin_spot",name:"Pin Spot",category:"map",colors:{bg:"#1c1917",text:"#fafaf9",accent:"#fbbf24",border:"#292524",surface:"#292524"},default_avatar_style:"map"},{id:"bubble",name:"Bubble",category:"compact",colors:{bg:"#0f172a",text:"#ffffff",accent:"#a3e635",border:"#1e293b",surface:"#1e293b"},default_avatar_style:"initials"},{id:"toast_top",name:"Toast Top",category:"compact",colors:{bg:"#ffffff",text:"#0f172a",accent:"#3b82f6",border:"#cbd5e1",surface:"#f8fafc"},default_avatar_style:"initials"}],H=Object.fromEntries(pe.map(t=>[t.id,t]));function gt(t,a){const l=H[t]||H.clean_white;return{...l,colors:{...l.colors,...a||{}}}}const bt=[{key:"bg",label:"Background"},{key:"text",label:"Text"},{key:"accent",label:"Accent"},{key:"border",label:"Border"},{key:"surface",label:"Surface"}],yt=[{value:"initials",label:"Initials",desc:"Colored circle with the buyer's initials",Icon:de},{value:"map",label:"Country Map",desc:"Stylized world map with a pin at their country",Icon:ee},{value:"url",label:"Image URL",desc:"Use the avatar_url provided per record",Icon:ee}],jt=[{value:"rounded",label:"Rounded",desc:"Soft 14px corners (default)"},{value:"chat_bubble",label:"Chat Bubble",desc:"Heavily rounded with a left tail"},{value:"squircle",label:"Squircle",desc:"iOS-style super rounded square"},{value:"pill",label:"Pill",desc:"Fully pill-shaped, single line"},{value:"sharp",label:"Sharp",desc:"Crisp 4px corners, professional"},{value:"ticket",label:"Ticket",desc:"Square with a perforated edge"},{value:"floating",label:"Floating",desc:"No border, soft elevated shadow"},{value:"glass",label:"Glass",desc:"Translucent frosted glassmorphism"}];function vt({value:t,selected:a}){const l=a?"hsl(var(--primary))":"hsl(var(--muted-foreground))",s=a?"rgba(var(--primary-rgb, 124 58 237) / 0.10)":"hsl(var(--muted))",r={width:64,height:26,background:s,border:`1.5px solid ${l}`,position:"relative",opacity:.9};switch(t){case"rounded":return e.jsx("div",{style:{...r,borderRadius:8}});case"chat_bubble":return e.jsx("div",{style:{...r,borderRadius:12},children:e.jsx("div",{style:{position:"absolute",left:-6,bottom:4,width:0,height:0,borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:`6px solid ${l}`}})});case"squircle":return e.jsx("div",{style:{...r,borderRadius:14}});case"pill":return e.jsx("div",{style:{...r,borderRadius:999}});case"sharp":return e.jsx("div",{style:{...r,borderRadius:2}});case"ticket":return e.jsx("div",{style:{...r,borderRadius:0},children:e.jsx("div",{style:{position:"absolute",top:3,bottom:3,left:18,width:0,borderLeft:`1.5px dashed ${l}`,opacity:.6}})});case"floating":return e.jsx("div",{style:{width:64,height:26,background:s,borderRadius:10,border:"none",boxShadow:`0 4px 10px ${l.includes("hsl")?"rgba(0,0,0,0.20)":l}`,opacity:.9}});case"glass":return e.jsx("div",{style:{width:64,height:26,background:"linear-gradient(135deg, rgba(255,255,255,0.45), rgba(255,255,255,0.10))",border:`1px solid ${l}`,borderRadius:10,backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",opacity:.9}});default:return e.jsx("div",{style:{...r,borderRadius:8}})}}function Nt({proof:t,onUpdate:a}){const l=t.theme_overrides||{},s=H[t.theme_key]||H.clean_white,r=(c,i)=>a({theme_overrides:{...l,[c]:i}}),o=["default","modern","map","compact"].map(c=>({cat:c,themes:pe.filter(i=>i.category===c)}));return e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{className:"border-l-[3px] border-l-primary overflow-hidden",children:e.jsxs(P,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(Le,{className:"w-4 h-4 text-primary"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Theme"})]}),o.map(({cat:c,themes:i})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:c}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:i.map(u=>e.jsx(ft,{theme:u,isSelected:t.theme_key===u.id,onClick:()=>a({theme_key:u.id,theme_overrides:null,avatar_style:u.default_avatar_style})},u.id))})]},c))]})}),e.jsx(T,{className:"border-l-[3px] border-l-pink-500",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-pink-500/10",children:e.jsx(Ee,{className:"w-4 h-4 text-pink-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Bubble Style"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Shape and surface treatment of the proof card. Independent of the color theme."}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:jt.map(({value:c,label:i,desc:u})=>{const m=(t.bubble_style||"rounded")===c;return e.jsxs("button",{type:"button",onClick:()=>a({bubble_style:c}
19),className:A("flex flex-col items-center gap-2.5 p-3 rounded-xl border-2 transition-all text-center h-full",m?"border-primary ring-2 ring-primary/30 bg-primary/5":"border-border hover:border-primary/40"),children:[e.jsx("div",{className:"h-7 flex items-center justify-center",children:e.jsx(vt,{value:c,selected:m})}),e.jsxs("div",{className:"flex flex-col items-center gap-0.5 min-h-[42px] justify-start",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground leading-tight",children:i}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:u})]})]},c)})})]})}),e.jsx(T,{className:"border-l-[3px] border-l-violet-500",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-violet-500/10",children:e.jsx(de,{className:"w-4 h-4 text-violet-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Avatar Style"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:yt.map(({value:c,label:i,desc:u,Icon:m})=>{const g=(t.avatar_style||"initials")===c;return e.jsxs("button",{type:"button",onClick:()=>a({avatar_style:c}),className:A("flex flex-col items-center gap-2 p-3 rounded-xl border-2 transition-all text-center",g?"border-primary ring-2 ring-primary/30 bg-primary/5":"border-border hover:border-primary/40"),children:[e.jsx(m,{className:A("w-5 h-5",g?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:i}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:u})]},c)})})]})}),e.jsx(T,{children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-violet-500/10",children:e.jsx(Me,{className:"w-4 h-4 text-violet-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Customize Colors"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Override individual colors from the selected theme."}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:bt.map(({key:c,label:i},u)=>{const m=s.colors[c],h=l[c]||m,k=typeof h=="string"&&h.startsWith("#"),b=(u+1)%3===0;return k?e.jsx(Ie,{label:i,value:h,onChange:y=>r(c,y),align:b?"right":"left"},c):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:i}),e.jsx(V,{title:"Gradient",description:h,children:e.jsx("div",{className:"h-10 rounded-lg border border-border cursor-help",style:{background:h}})}),e.jsx("button",{type:"button",onClick:()=>r(c,"#3b82f6"),className:"text-[10px] text-muted-foreground hover:text-primary transition-colors",children:"Replace gradient with solid color â"})]},c)})})]})})]})}const fe={US:{name:"United States",flag:"ðºð¸",lat:39.8,lng:-98.5},CA:{name:"Canada",flag:"ð¨ð¦",lat:56,lng:-106},MX:{name:"Mexico",flag:"ð²ð½",lat:23.6,lng:-102.5},BR:{name:"Brazil",flag:"ð§ð·",lat:-14.2,lng:-51.9},AR:{name:"Argentina",flag:"ð¦ð·",lat:-38.4,lng:-63.6},CL:{name:"Chile",flag:"ð¨ð±",lat:-35.7,lng:-71.5},CO:{name:"Colombia",flag:"ð¨ð´",lat:4.6,lng:-74.3},PE:{name:"Peru",flag:"ðµðª",lat:-9.2,lng:-75},GB:{name:"United Kingdom",flag:"ð¬ð§",lat:55.4,lng:-3.4},IE:{name:"Ireland",flag:"ð®ðª",lat:53.4,lng:-8.2},FR:{name:"France",flag:"ð«ð·",lat:46.6,lng:2.2},DE:{name:"Germany",flag:"ð©ðª",lat:51.2,lng:10.5},IT:{name:"Italy",flag:"ð®ð¹",lat:41.9,lng:12.6},ES:{name:"Spain",flag:"ðªð¸",lat:40.5,lng:-3.7},PT:{name:"Portugal",flag:"ðµð¹",lat:39.4,lng:-8.2},NL:{name:"Netherlands",flag:"ð³ð±",lat:52.1,lng:5.3},BE:{name:"Belgium",flag:"ð§ðª",lat:50.5,lng:4.5},CH:{name:"Switzerland",flag:"ð¨ð",lat:46.8,lng:8.2},AT:{name:"Austria",flag:"ð¦ð¹",lat:47.5,lng:14.6},SE:{name:"Sweden",flag:"ð¸ðª",lat:60.1,lng:18.6},NO:{name:"Norway",flag:"ð³ð´",lat:60.5,lng:8.5},DK:{name:"Denmark",flag:"ð©ð°",lat:56.3,lng:9.5},FI:{name:"Finland",flag:"ð«ð®",lat:61.9,lng:25.7},IS:{name:"Iceland",flag:"ð®ð¸",lat:64.9,lng:-19},PL:{name:"Poland",flag:"ðµð±",lat:51.9,lng:19.1}
19,CZ:{name:"Czechia",flag:"ð¨ð¿",lat:49.8,lng:15.5},HU:{name:"Hungary",flag:"ððº",lat:47.2,lng:19.5},RO:{name:"Romania",flag:"ð·ð´",lat:45.9,lng:24.9},GR:{name:"Greece",flag:"ð¬ð·",lat:39.1,lng:21.8},TR:{name:"Turkey",flag:"ð¹ð·",lat:38.9,lng:35.2},RU:{name:"Russia",flag:"ð·ðº",lat:61.5,lng:105.3},UA:{name:"Ukraine",flag:"ðºð¦",lat:48.4,lng:31.2},AE:{name:"UAE",flag:"ð¦ðª",lat:23.4,lng:53.8},SA:{name:"Saudi Arabia",flag:"ð¸ð¦",lat:23.9,lng:45.1},IL:{name:"Israel",flag:"ð®ð±",lat:31,lng:34.9},EG:{name:"Egypt",flag:"ðªð¬",lat:26.8,lng:30.8},ZA:{name:"South Africa",flag:"ð¿ð¦",lat:-30.6,lng:22.9},NG:{name:"Nigeria",flag:"ð³ð¬",lat:9.1,lng:8.7},KE:{name:"Kenya",flag:"ð°ðª",lat:-0,lng:37.9},IN:{name:"India",flag:"ð®ð³",lat:20.6,lng:78.9},PK:{name:"Pakistan",flag:"ðµð°",lat:30.4,lng:69.3},BD:{name:"Bangladesh",flag:"ð§ð©",lat:23.7,lng:90.4},CN:{name:"China",flag:"ð¨ð³",lat:35.9,lng:104.2},JP:{name:"Japan",flag:"ð¯ðµ",lat:36.2,lng:138.3},KR:{name:"South Korea",flag:"ð°ð·",lat:35.9,lng:127.8},TW:{name:"Taiwan",flag:"ð¹ð¼",lat:23.7,lng:121},HK:{name:"Hong Kong",flag:"ðð°",lat:22.3,lng:114.2},SG:{name:"Singapore",flag:"ð¸ð¬",lat:1.4,lng:103.8},MY:{name:"Malaysia",flag:"ð²ð¾",lat:4.2,lng:101.9},TH:{name:"Thailand",flag:"ð¹ð",lat:15.9,lng:100.9},VN:{name:"Vietnam",flag:"ð»ð³",lat:14.1,lng:108.3},PH:{name:"Philippines",flag:"ðµð",lat:12.9,lng:121.8},ID:{name:"Indonesia",flag:"ð®ð©",lat:-.8,lng:113.9},AU:{name:"Australia",flag:"ð¦ðº",lat:-25.3,lng:133.8},NZ:{name:"New Zealand",flag:"ð³ð¿",lat:-40.9,lng:174.9}};function wt(t){return t&&fe[String(t).toUpperCase()]||null}const _t=Object.entries(fe).map(([t,a])=>({code:t,name:a.name,flag:a.flag,lat:a.lat,lng:a.lng}));function Q({value:t=[],onChange:a,placeholder:l="Pick countriesâ¦",align:s="left",label:r,maxHeight:o=320}){var M,p;const[c,i]=d.useState(!1),[u,m]=d.useState(""),[g,h]=d.useState(0),k=d.useRef(null),b=d.useRef(null),y=d.useRef([]),j=d.useMemo(()=>new Set((Array.isArray(t)?t:[]).map(n=>String(n).toUpperCase())),[t]),w=d.useMemo(()=>[..._t].sort((n,x)=>n.name.localeCompare(x.name)),[]),f=d.useMemo(()=>{const n=u.trim().toLowerCase();return n?w.filter(x=>x.name.toLowerCase().includes(n)||x.code.toLowerCase().includes(n)):w},[w,u]);d.useEffect(()=>{const n=x=>{k.current&&!k.current.contains(x.target)&&i(!1)};return c&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[c]),d.useEffect(()=>{if(!c)return;m(""),h(0);const n=setTimeout(()=>{var x;return(x=b.current)==null?void 0:x.focus()},0);return()=>clearTimeout(n)},[c]),d.useEffect(()=>{if(!c)return;const n=y.current[g];n&&n.scrollIntoView({block:"nearest"})},[g,c]);const v=d.useCallback(n=>{const x=String(n).toUpperCase(),N=j.has(x)?Array.from(j).filter(R=>R!==x):[...Array.from(j),x];a==null||a(N)},[j,a]),_=()=>a==null?void 0:a(f.map(n=>n.code)),L=()=>a==null?void 0:a([]),C=n=>{n.key==="ArrowDown"?(n.preventDefault(),h(x=>Math.min(x+1,f.length-1))):n.key==="ArrowUp"?(n.preventDefault(),h(x=>Math.max(x-1,0))):n.key==="Enter"?(n.preventDefault(),f[g]&&v(f[g].code)):n.key==="Escape"&&(n.preventDefault(),i(!1))},S=j.size===0?l:j.size===1?`${((M=w.find(n=>n.code===Array.from(j)[0]))==null?void 0:M.flag)||""} ${((p=w.find(n=>n.code===Array.from(j)[0]))==null?void 0:p.name)||""}`:`${j.size} countries selected`;return e.jsxs("div",{className:"relative",ref:k,children:[r&&e.jsx("label",{className:"text-xs font-medium text-foreground mb-1.5 block",children:r}),e.jsxs("button",{type:"button",onClick:()=>i(n=>!n),className:A("flex h-11 w-full items-center justify-between rounded-xl border border-input bg-background px-4 py-2 text-sm transition-all hover:border-primary/40 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary",j.size===0&&"text-muted-foreground"),children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(X,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate text-foreground",children:S})]}),e.jsx(Be,{className:"w-4 h-4 text-muted-foreground shrink-0"})]}),j.size>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[Array.from(j).slice(0,12).map(n=>{const x=w.find(N=>N.code===n);return x?e.jsx(V,{title:x.name,description:`ISO country code: ${x.code}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-secondary text-foreground border border-border
19cursor-help",children:[e.jsx("span",{children:x.flag}),e.jsx("span",{children:x.code}),e.jsx("button",{type:"button",onClick:()=>v(n),className:"opacity-60 hover:opacity-100",children:e.jsx(q,{className:"w-3 h-3"})})]})},n):null}),j.size>12&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",j.size-12," more"]})]}),c&&e.jsxs("div",{className:A("absolute z-50 mt-2 w-full min-w-[300px] rounded-xl border border-border bg-card shadow-xl overflow-hidden",s==="right"?"right-0 left-auto":"left-0 right-auto"),children:[e.jsx("div",{className:"p-2 border-b border-border",children:e.jsxs("div",{className:"relative",children:[e.jsx(ue,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"}),e.jsx("input",{ref:b,type:"text",value:u,onChange:n=>{m(n.target.value),h(0)},onKeyDown:C,placeholder:"Search country...",className:"w-full pl-8 pr-3 py-2 text-sm rounded-lg bg-background border border-input focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"})]})}),e.jsxs("div",{className:"px-2 py-1.5 border-b border-border flex items-center justify-between text-[11px]",children:[e.jsxs("button",{type:"button",onClick:_,className:"text-primary hover:underline",children:["Select all ",f.length>0?`(${f.length})`:""]}),e.jsx("button",{type:"button",onClick:L,className:"text-muted-foreground hover:text-foreground",children:"Clear"})]}),e.jsx("div",{className:"overflow-y-auto py-1",style:{maxHeight:o},children:f.length===0?e.jsxs("div",{className:"px-3 py-6 text-sm text-center text-muted-foreground",children:['No country matches "',u,'"']}):f.map((n,x)=>{const N=j.has(n.code);return e.jsxs("button",{ref:R=>{y.current[x]=R},type:"button",onClick:()=>v(n.code),onMouseEnter:()=>h(x),className:A("w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors",x===g?"bg-primary/10":"",N&&"font-semibold"),children:[e.jsx("span",{className:"text-base leading-none",children:n.flag}),e.jsx("span",{className:"flex-1 truncate text-foreground",children:n.name}),e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:n.code}),e.jsx(K,{className:A("w-3.5 h-3.5 shrink-0",N?"text-primary opacity-100":"opacity-0")})]},n.code)})})]})]})}const z="flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 focus-visible:border-primary",kt=[{value:"bottom_left",label:"Bottom Left",Icon:it},{value:"bottom_right",label:"Bottom Right",Icon:De},{value:"top_left",label:"Top Left",Icon:ct},{value:"top_right",label:"Top Right",Icon:Fe},{value:"bottom_center",label:"Bottom Center",Icon:Oe},{value:"top_center",label:"Top Center",Icon:Ue},{value:"inline",label:"Inline",Icon:$e}],St=["slide_up","slide_down","slide_left","slide_right","fade","bounce","none"],Ct=[{value:"sequential",label:"Sequential"},{value:"random",label:"Random"},{value:"random_no_repeat",label:"Random (no repeat)"}],Tt=["all","desktop_only","mobile_only"];function Pt({proof:t,onUpdate:a}){const[l,s]=d.useState((t.url_include_patterns||[]).join(` 20`)),[r,o]=d.useState((t.url_exclude_patterns||[]).join(` 21`)),c=(i,u)=>{const m=u.split(` 22`).map(g=>g.trim()).filter(Boolean);a({[i]:m})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{className:"border-l-[3px] border-l-primary",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(Re,{className:"w-4 h-4 text-primary"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Position"})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:kt.map(({value:i,label:u,Icon:m})=>{const g=t.position===i;return e.jsxs("button",{type:"button",onClick:()=>a({position:i}),className:A("flex flex-col items-center gap-2 p-3 rounded-xl border-2 transition-all",g?"border-primary ring-2 ring-primary/30 bg-primary/5":"border-border hover:border-primary/40"),children:[e.jsx(m,{className:A("w-5 h-5",g?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:u})]},i)})})]})}),e.jsx(T,{className:"border-l-[3px] border-l-blue-500",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-blue-500/10",children:e.jsx(ze,{className:"w-4 h-4 text-blue-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Animation & Timing"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Enter animation"}),e.jsx("select",{value:t.enter_animation||"slide_up",onChange:i=>a({enter_animation:i.target.value}),className:z,children:St.map(i=>e.jsx("option",{value:i,children:i.replace("_"," ")},i))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Cycle mode"}),e.jsx("select",{value:t.cycle_mode||"sequential",onChange:i=>a({cycle_mode:i.target.value}),className:z,children:Ct.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]}),e.jsx(D,{label:"Start delay (s)",value:t.start_delay_seconds??3,min:0,max:60,onChange:i=>a({start_delay_seconds:i})}),e.jsx(D,{label:"Display (s)",value:t.display_seconds??6,min:1,max:60,onChange:i=>a({display_seconds:i})}),e.jsx(D,{label:"Gap (s)",value:t.gap_seconds??4,min:0,max:120,onChange:i=>a({gap_seconds:i})}),e.jsx(D,{label:"Max shows / session",value:t.max_shows_per_session??0,min:0,max:1e3,onChange:i=>a({max_shows_per_session:i}),hint:"0 = no limit"})]})]})}),e.jsx(T,{className:"border-l-[3px] border-l-amber-500",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-amber-500/10",children:e.jsx(He,{className:"w-4 h-4 text-amber-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Stacking"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 items-start",children:e.jsx(D,{label:"Z-Index",value:t.z_index??1037,min:0,max:2147483647,onChange:i=>a({z_index:i}),hint:"Default 1037. Raise this if your site has fixed headers, cookie banners, or chat widgets that overlap the popup."})})]})}),e.jsx(T,{className:"border-l-[3px] border-l-emerald-500",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-emerald-500/10",children:e.jsx(Ve,{className:"w-4 h-4 text-emerald-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Targeting"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Device visibility"}),e.jsx("select",{value:t.device_visibility||"all",onChange:i=>a({device_visibility:i.target.value}),className:z,children:Tt.map(i=>e.jsx("option",{value:i,children:i.replace("_"," ")},i))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Q,{label:"Show only to visitors from",value:t.country_filter||[],onChange:i=>a({country_filter:i}),placeholder:"All countries"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground inline-flex items-center gap-1",children:[e.jsx(X,{className:"w-3 h-3"})," Best-effort detected from the visitor's Accept-Language header."]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Show only on URLs matching"}
22),e.jsx("textarea",{value:l,onChange:i=>s(i.target.value),onBlur:()=>c("url_include_patterns",l),rows:3,placeholder:"/pricing\\n/checkout/*",className:"flex w-full rounded-xl border border-input bg-background px-4 py-2 text-sm font-mono resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Hide on URLs matching"}),e.jsx("textarea",{value:r,onChange:i=>o(i.target.value),onBlur:()=>c("url_exclude_patterns",r),rows:3,placeholder:"/admin*\\n/account*",className:"flex w-full rounded-xl border border-input bg-background px-4 py-2 text-sm font-mono resize-none"})]})]})]})})]})}function D({label:t,value:a,min:l,max:s,onChange:r,hint:o}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:t}),e.jsx("input",{type:"number",min:l,max:s,defaultValue:a,onBlur:c=>r(parseInt(c.target.value)||0),className:z}),o&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:o})]})}const B="flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 focus-visible:border-primary",At=["{name}","{city}","{country}","{state}","{product}","{price}","{time_ago}"],It=[{value:"first_initial_last",label:"First name + last initial (John H.)"},{value:"full",label:"Full name (John Hancock)"},{value:"initials_only",label:"Initials only (J.H.)"},{value:"first_only",label:"First name only (John)"}],Lt=[{value:"city_country",label:"City, Country"},{value:"city_state",label:"City, State"},{value:"city_only",label:"City only"},{value:"country_only",label:"Country only"},{value:"hidden",label:"Hidden"}],Et=[{value:"relative",label:'Relative ("5 min ago")'},{value:"absolute",label:"Absolute timestamp"},{value:"hidden",label:"Hidden"}];function Mt({proof:t,onUpdate:a}){const l=s=>{const r=t.message_template||"";a({message_template:r+(r.endsWith(" ")||r===""?"":" ")+s})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{className:"border-l-[3px] border-l-primary",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(We,{className:"w-4 h-4 text-primary"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Message Template"})]}),e.jsx("textarea",{value:t.message_template||"",onChange:s=>a({message_template:s.target.value}),rows:3,className:"flex w-full rounded-xl border border-input bg-background px-4 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 focus-visible:border-primary resize-none font-mono",placeholder:"{name} from {city}, {country}<br>just purchased {product}"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-secondary px-1 py-0.5 rounded",children:"<br>"})," to break a line, and ",e.jsx("code",{className:"bg-secondary px-1 py-0.5 rounded",children:"<strong>"})," / ",e.jsx("code",{className:"bg-secondary px-1 py-0.5 rounded",children:"<em>"})," for emphasis. Buyer values are HTML-escaped automatically."]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider self-center mr-1",children:"Placeholders"}),At.map(s=>e.jsx("button",{type:"button",onClick:()=>l(s),className:"text-xs px-2 py-1 rounded-md border border-dashed border-border hover:border-primary/40 hover:bg-primary/5 hover:text-primary transition-colors font-mono",children:s},s))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Default product name"}),e.jsx("input",{defaultValue:t.default_product_name||"",onBlur:s=>a({default_product_name:s.target.value||null}),placeholder:"e.g. Pro Plan",className:B}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Used when ","{product}"," is in the template but the record has no product_name."]})]})]})}),e.jsx(T,{className:"border-l-[3px] border-l-blue-500",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-blue-500/10",children:e.jsx(Ge,{className:"w-4 h-4 text-blue-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Display Format"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Name format"}),e.jsx("select",{value:t.name_format||"first_initial_last",onCh
22ange:s=>a({name_format:s.target.value}),className:B,children:It.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Location format"}),e.jsx("select",{value:t.location_format||"city_country",onChange:s=>a({location_format:s.target.value}),className:B,children:Lt.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Timestamp"}),e.jsx("select",{value:t.timestamp_format||"relative",onChange:s=>a({timestamp_format:s.target.value}),className:B,children:Et.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]})]})}),e.jsx(T,{className:"border-l-[3px] border-l-emerald-500",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-emerald-500/10",children:e.jsx(Ye,{className:"w-4 h-4 text-emerald-600"})}),e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Live Counter"})]}),e.jsx(Rt,{checked:t.live_counter_enabled??!1,onChange:s=>a({live_counter_enabled:s}),label:"Show 'X people viewing now' under the message"}),t.live_counter_enabled&&e.jsx("div",{className:"space-y-3 pl-1 border-l-2 border-emerald-500/20 ml-1",children:e.jsxs("div",{className:"pl-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Min"}),e.jsx("input",{type:"number",min:0,max:9999,defaultValue:t.live_counter_min??15,onBlur:s=>a({live_counter_min:parseInt(s.target.value)||0}),className:B})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Max"}),e.jsx("input",{type:"number",min:0,max:9999,defaultValue:t.live_counter_max??50,onBlur:s=>a({live_counter_max:parseInt(s.target.value)||0}),className:B})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Template"}),e.jsx("input",{defaultValue:t.live_counter_template||"{n} people viewing this offer",onBlur:s=>a({live_counter_template:s.target.value}),className:B}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Use ","{n}"," for the random number."]})]})]})})]})})]})}function Rt({checked:t,onChange:a,label:l}){return e.jsxs("div",{className:"flex items-center gap-3 py-1",children:[e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:!!t,onChange:s=>a(s.target.checked)}),e.jsx("div",{className:"w-9 h-5 bg-muted rounded-full peer peer-checked:bg-primary after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:after:translate-x-full"})]}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:l})]})}const $t=[{id:"api",label:"Public API",Icon:Xe},{id:"csv",label:"CSV Import",Icon:me},{id:"ai",label:"Generate with AI",Icon:xe}];function Bt({proof:t,onRecordsChanged:a}){const[l,s]=d.useState("api");return e.jsx("div",{className:"space-y-6",children:e.jsx(T,{className:"border-l-[3px] border-l-primary",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsx("div",{className:"flex gap-1 bg-secondary/50 p-1 rounded-xl w-fit",children:$t.map(({id:r,label:o,Icon:c})=>e.jsxs("button",{type:"button",onClick:()=>s(r),className:A("px-3 py-1.5 rounded-lg text-xs font-medium inline-flex items-center gap-2 transition-all",l===r?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(c,{className:"w-3.5 h-3.5"}),o]},r))}),l==="api"&&e.jsx(Dt,{proof:t}),l==="csv"&&e.jsx(Ft,{proof:t,onRecordsChanged:a}),l==="ai"&&e.jsx(Ot,{proof:t,onRecordsChanged:a})]})})})}function Dt({proof:t}){const a="https://app.pagedock.ai/api".replace(/\/$/,"")||`${window.location.origin}/api`,l=`${a}/pp-ingest/${t.api_key}
22/record`,[s,r]=d.useState("curl"),[o,c]=d.useState(!1),[i,u]=d.useState(t.api_key),m=`${a}/pp-ingest/${i}/record`,g={curl:`curl -X POST "${m}" \\ 23 -H "Content-Type: application/json" \\ 24 -d '{ 25 "name": "John H.", 26 "city": "Austin", 27 "country": "US", 28 "product_name": "Pro Plan" 29 }'`,node:`await fetch("${m}", { 30 method: "POST", 31 headers: { "Content-Type": "application/json" }, 32 body: JSON.stringify({ 33 name: "John H.", 34 city: "Austin", 35 country: "US", 36 product_name: "Pro Plan", 37 }), 38})`,python:`import requests 39 40requests.post( 41 "${m}", 42 json={ 43 "name": "John H.", 44 "city": "Austin", 45 "country": "US", 46 "product_name": "Pro Plan", 47 }, 48)`,php:`Http::post('${m}', [ 49 'name' => 'John H.', 50 'city' => 'Austin', 51 'country' => 'US', 52 'product_name' => 'Pro Plan', 53]);`},h=(b,y="Copied!")=>{navigator.clipboard.writeText(b).catch(()=>{}),I.success(y)},k=async()=>{if(confirm("Regenerate the API key? Any system using the current key will stop working until updated.")){c(!0);try{const b=await $.post(`/purchase-proofs/${t.id}/regenerate-api-key`);u(b.api_key),I.success("API key regenerated")}catch{I.error("Failed to regenerate API key")}finally{c(!1)}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"POST to this endpoint from your backend whenever a real purchase happens. Records appear in the widget within seconds. No CORS, no widget tokens â server to server only."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Endpoint"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 rounded-lg bg-secondary text-foreground text-xs font-mono break-all",children:l}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>h(l,"URL copied!"),children:e.jsx(U,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"API key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 rounded-lg bg-secondary text-foreground text-xs font-mono break-all",children:i}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>h(i,"API key copied!"),children:e.jsx(U,{className:"w-3.5 h-3.5"})}),e.jsx(E,{variant:"outline",size:"sm",onClick:k,disabled:o,children:o?e.jsx(O,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(oe,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Anyone with this key can post records. Keep it server-side."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Sample request"}),e.jsx("div",{className:"flex gap-1 bg-secondary/50 p-0.5 rounded-lg",children:["curl","node","python","php"].map(b=>e.jsx("button",{type:"button",onClick:()=>r(b),className:A("px-2.5 py-1 rounded text-[11px] font-medium uppercase",s===b?"bg-card text-foreground shadow-sm":"text-muted-foreground"),children:b},b))})]}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-secondary rounded-lg p-3 pr-12 text-xs font-mono text-foreground overflow-x-auto whitespace-pre",children:g[s]}),e.jsx(E,{variant:"ghost",size:"icon",className:"absolute top-1.5 right-1.5 h-7 w-7",onClick:()=>h(g[s]),children:e.jsx(U,{className:"w-3.5 h-3.5"})})]})]}),e.jsx("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-3",children:e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:"Required fields:"})," ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"name"}),", ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"city"}),", ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"country"})," (ISO alpha-2). Optional: ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"state"}),", ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"product_name"}),", ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"price"}),", ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"avatar_url"}),", ",e.jsx("code",{className:"bg-blue-500/10 px-1 rounded",children:"occurred_at"})," (ISO8601)."]})})]})}function Ft({proof:t,onRecordsChanged:a}){var f;
53const l=d.useRef(null),[s,r]=d.useState(!1),[o,c]=d.useState(null),[i,u]=d.useState(["US","GB","CA","AU","DE"]),[m,g]=d.useState(""),[h,k]=d.useState("last_24h"),[b,y]=d.useState(!0),j=()=>{const v=["name,city,country,state,product_name,price,occurred_at","Sarah M.,Austin,US,TX,Pro Plan,$49,2026-04-18T08:00:00Z","Hugo M.,Paris,FR,,Annual Pass,â¬39,","Yui T.,Tokyo,JP,,Lifetime,,"].join(` 54`),_=new Blob([v],{type:"text/csv"}),L=URL.createObjectURL(_),C=document.createElement("a");C.href=L,C.download="purchase-proof-sample.csv",C.click(),URL.revokeObjectURL(L)},w=async v=>{if(v){r(!0),c(null);try{const _=new FormData;_.append("file",v),i.forEach(C=>_.append("fallback_countries[]",C)),m.split(",").map(C=>C.trim()).filter(Boolean).forEach(C=>_.append("fallback_products[]",C)),_.append("time_window",h),_.append("deduplicate",b?"1":"0");const L=await $.post(`/purchase-proofs/${t.id}/import-csv`,_);c(L),a==null||a(),I.success(`Imported ${L.imported} records`)}catch(_){I.error(_.message||"Import failed")}finally{r(!1),l.current&&(l.current.value="")}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Import a list of buyers from a spreadsheet. Required column: ",e.jsx("code",{className:"text-xs bg-secondary px-1 py-0.5 rounded",children:"name"}),". Other columns are optional and fall back to the pools below when missing."]}),e.jsxs(E,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(qe,{className:"w-3.5 h-3.5 mr-1.5"})," Download sample CSV"]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-xl bg-secondary/40 border border-border/50",children:[e.jsx("div",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:"Fallbacks for missing columns"}),e.jsx(Q,{label:"Fallback country pool (used when CSV row has no country)",value:i,onChange:u}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Fallback product names (comma-separated)"}),e.jsx("input",{value:m,onChange:v=>g(v.target.value),placeholder:"Pro Plan, Lite Plan, Annual Pass",className:"flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Distribute timestamps over"}),e.jsxs("select",{value:h,onChange:v=>k(v.target.value),className:"flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm",children:[e.jsx("option",{value:"last_hour",children:"Last hour"}),e.jsx("option",{value:"last_24h",children:"Last 24 hours"}),e.jsx("option",{value:"last_7d",children:"Last 7 days"}),e.jsx("option",{value:"last_30d",children:"Last 30 days"})]})]}),e.jsxs("label",{className:"inline-flex items-center gap-2 mt-7",children:[e.jsx("input",{type:"checkbox",checked:b,onChange:v=>y(v.target.checked),className:"h-4 w-4 rounded border-input text-primary"}),e.jsx("span",{className:"text-xs",children:"Skip duplicates (same name+city within 1h)"})]})]})]}),e.jsxs("div",{className:"rounded-2xl border-2 border-dashed border-border p-6 flex flex-col items-center gap-3",children:[e.jsx(me,{className:"w-6 h-6 text-muted-foreground"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Drop a CSV here or click to upload"}),e.jsx("input",{ref:l,type:"file",accept:".csv,.txt",onChange:v=>{var _;return w((_=v.target.files)==null?void 0:_[0])},className:"hidden"}),e.jsx(E,{onClick:()=>{var v;return(v=l.current)==null?void 0:v.click()},disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploadingâ¦"]}):"Choose CSV file"})]}),o&&e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-700 dark:text-emerald-300 mb-1",children:[e.jsx(K,{className:"w-4 h-4"})," ",o.imported," records imported"]}),(o.skipped_invalid>0||o.skipped_duplicate>0)&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Skipped: ",o.skipped_invali
54d," invalid, ",o.skipped_duplicate," duplicate"]}),((f=o.errors)==null?void 0:f.length)>0&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs cursor-pointer text-muted-foreground hover:text-foreground",children:"View errors"}),e.jsx("ul",{className:"text-[10px] font-mono mt-1 space-y-0.5",children:o.errors.map((v,_)=>e.jsxs("li",{className:"flex items-start gap-1",children:[e.jsx(Ke,{className:"w-3 h-3 mt-0.5 text-amber-500 shrink-0"}),v]},_))})]})]})]})}function Ot({proof:t,onRecordsChanged:a}){const[l,s]=d.useState(20),[r,o]=d.useState(["US","GB","CA","AU","DE"]),[c,i]=d.useState(""),[u,m]=d.useState("last_24h"),[g,h]=d.useState(""),[k,b]=d.useState("append"),[y,j]=d.useState(!1),w=async()=>{if(r.length===0){I.error("Pick at least one country");return}j(!0);try{const f=await $.post(`/purchase-proofs/${t.id}/generate-fake`,{count:l,countries:r,products:c.split(",").map(v=>v.trim()).filter(Boolean),time_window:u,tone_hint:g||void 0,mode:k});I.success(`Generated ${f.inserted} records`),a==null||a()}catch(f){I.error(f.message||"Generation failed")}finally{j(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate sample buyer records using AI. Names are matched to each country's culture and timestamps are spread realistically across your chosen window. Falls back to a built-in offline library if no AI model is configured."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Number of records"}),e.jsx("input",{type:"number",min:1,max:200,value:l,onChange:f=>s(Math.max(1,Math.min(200,parseInt(f.target.value)||1))),className:"flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Distribute timestamps over"}),e.jsxs("select",{value:u,onChange:f=>m(f.target.value),className:"flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm",children:[e.jsx("option",{value:"last_hour",children:"Last hour"}),e.jsx("option",{value:"last_24h",children:"Last 24 hours"}),e.jsx("option",{value:"last_7d",children:"Last 7 days"}),e.jsx("option",{value:"last_30d",children:"Last 30 days"})]})]})]}),e.jsx(Q,{label:"Countries to generate buyers from",value:r,onChange:o}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Product names to randomly assign (comma-separated)"}),e.jsx("input",{value:c,onChange:f=>i(f.target.value),placeholder:t.default_product_name?`${t.default_product_name}, â¦`:"Pro Plan, Annual Pass, Lifetime",className:"flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"If empty, the bar's default product name is used."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Tone hint ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx("input",{value:g,onChange:f=>h(f.target.value),placeholder:"premium SaaS buyers, urgent Black Friday shoppers, â¦",className:"flex h-11 w-full rounded-xl border border-input bg-background px-4 py-2 text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Mode"}),e.jsx("div",{className:"flex gap-2",children:[{v:"append",l:"Append to existing"},{v:"replace",l:"Replace all existing"}].map(f=>e.jsx("button",{type:"button",onClick:()=>b(f.v),className:A("flex-1 px-3 py-2 rounded-lg border text-xs font-medium transition-all",k===f.v?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/40"),children:f.l},f.v))})]}),e.jsx(E,{onClick:w,disabled:y,className:"w-full",children:y?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Generatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Generate ",l," records"]})})]})}F.extend(ie);const Ut={api:"bg-blue-500/10 text-blue-600 border-blue-500/20",csv:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",ai:"bg-fuchsia-500/10 text-fuchsia-600 border-fuchsia-500/20",manual:"bg-amber-500/10 text-amber-600 border-amber-500/20"};function zt({proof:t,onRecordsDeleted:a,onRecordsCleared:l,onRecordAdded:s}
54){const[r,o]=d.useState([]),[c,i]=d.useState(!0),[u,m]=d.useState(""),[g,h]=d.useState(""),[k,b]=d.useState(!1),[y,j]=d.useState([]),w=d.useRef(0),f=d.useCallback(async(p={})=>{const n=++w.current;try{i(!0);const x=new URLSearchParams,N=(p.search??u).trim(),R=p.source??g;N&&x.set("search",N),R&&x.set("source",R),x.set("per_page","50");const be=await $.get(`/purchase-proofs/${t.id}/records?${x.toString()}`);if(n!==w.current)return;o(be.data||[])}catch{n===w.current&&I.error("Failed to load records")}finally{n===w.current&&i(!1)}},[t.id,u,g]),v=d.useRef(null);d.useEffect(()=>(v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{f()},300),()=>{v.current&&clearTimeout(v.current)}),[u]),d.useEffect(()=>{f()},[g]),d.useEffect(()=>{f()},[t.id]);const _=async p=>{const n=r.find(N=>N.id===p);if(!n)return;const x=r;o(N=>N.filter(R=>R.id!==p)),a==null||a([p]);try{await $.delete(`/purchase-proofs/${t.id}/records/${p}`)}catch{o(x),s==null||s(n),I.error("Delete failed â restored")}},L=async()=>{if(y.length===0)return;const p=y,n=r.filter(N=>p.includes(N.id)),x=r;o(N=>N.filter(R=>!p.includes(R.id))),j([]),a==null||a(p);try{await $.post(`/purchase-proofs/${t.id}/records/bulk-delete`,{ids:p})}catch{o(x),n.forEach(N=>s==null?void 0:s(N)),I.error("Bulk delete failed â restored")}},C=async()=>{b(!1);const p=r;o([]),j([]),l==null||l();try{await $.delete(`/purchase-proofs/${t.id}/records`)}catch{o(p),p.forEach(n=>s==null?void 0:s(n)),I.error("Clear failed â restored")}},S=p=>{j(n=>n.includes(p)?n.filter(x=>x!==p):[...n,p])},M=r.length>0&&y.length===r.length;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{className:"border-l-[3px] border-l-primary",children:e.jsxs(P,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(Ze,{className:"w-4 h-4 text-primary"})}),e.jsxs("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:["Records (",r.length,")"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(ue,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"}),e.jsx("input",{value:u,onChange:p=>m(p.target.value),placeholder:"Search name, city, productâ¦",className:"w-full pl-8 pr-3 py-2 text-sm rounded-lg bg-background border border-input"})]}),e.jsxs("select",{value:g,onChange:p=>h(p.target.value),className:"text-sm rounded-lg bg-background border border-input px-3 py-2",children:[e.jsx("option",{value:"",children:"All sources"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"csv",children:"CSV"}),e.jsx("option",{value:"ai",children:"AI"}),e.jsx("option",{value:"manual",children:"Manual"})]}),e.jsx(E,{variant:"outline",size:"sm",onClick:f,disabled:c,children:c?e.jsx(O,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(oe,{className:"w-3.5 h-3.5"})})]}),y.length>0&&e.jsxs("div",{className:"flex items-center justify-between bg-secondary/40 rounded-lg p-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[y.length," selected"]}),e.jsxs(E,{variant:"destructive",size:"sm",onClick:L,children:[e.jsx(W,{className:"w-3.5 h-3.5 mr-1.5"}),"Delete selected"]})]}),c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(O,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):r.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground text-sm",children:"No records yet. Add some via the Data Source tab (API, CSV, or Generate with AI)."}):e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-secondary/50 text-[11px] uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left",children:e.jsx("input",{type:"checkbox",checked:M,onChange:()=>j(M?[]:r.map(p=>
54p.id)),className:"h-4 w-4 rounded border-input"})}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Name"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Location"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Product"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"When"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Source"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:r.map(p=>e.jsxs("tr",{className:"border-t border-border hover:bg-secondary/30",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx("input",{type:"checkbox",checked:y.includes(p.id),onChange:()=>S(p.id),className:"h-4 w-4 rounded border-input"})}),e.jsx("td",{className:"px-3 py-2 font-medium",children:p.name}),e.jsxs("td",{className:"px-3 py-2 text-muted-foreground",children:[p.city,p.country?`, ${p.country}`:""]}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:p.product_name||"â"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground tabular-nums",children:p.occurred_at?e.jsx(V,{title:"Occurred at",description:p.occurred_at,children:e.jsx("span",{className:"cursor-help",children:F(p.occurred_at).fromNow()})}):"â"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase border ${Ut[p.source]||""}`,children:p.source})}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx(E,{variant:"ghost",size:"icon",className:"h-7 w-7 hover:bg-destructive/10 hover:text-destructive",onClick:()=>_(p.id),children:e.jsx(W,{className:"w-3.5 h-3.5"})})})]},p.id))})]})}),r.length>0&&e.jsx("div",{className:"pt-2",children:e.jsxs(E,{variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-destructive hover:text-destructive",children:[e.jsx(W,{className:"w-3.5 h-3.5 mr-1.5"})," Clear all records"]})})]})}),e.jsx(Qe,{isOpen:k,title:"Clear all records?",description:"All records for this purchase proof will be permanently deleted. The proof itself stays.",confirmLabel:"Clear all",variant:"destructive",onConfirm:C,onCancel:()=>b(!1)})]})}function Ht({proof:t}){const a=t.impressions_count||0,l=t.clicks_count||0,s=t.dismissals_count||0,r=a>0?(l/a*100).toFixed(2):"0.00",o=[{label:"Impressions",value:a,Icon:et,color:"text-blue-600",bg:"bg-blue-500/10"},{label:"Clicks",value:l,Icon:ce,color:"text-emerald-600",bg:"bg-emerald-500/10"},{label:"Dismissals",value:s,Icon:q,color:"text-amber-600",bg:"bg-amber-500/10"},{label:"CTR",value:`${r}%`,Icon:tt,color:"text-fuchsia-600",bg:"bg-fuchsia-500/10"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:o.map(({label:c,value:i,Icon:u,color:m,bg:g})=>e.jsx(T,{children:e.jsxs(P,{className:"p-5 space-y-2",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center ${g}`,children:e.jsx(u,{className:`w-4 h-4 ${m}`})}),e.jsx("div",{className:"text-2xl font-bold tabular-nums",children:i}),e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:c})]})},c))}),e.jsx(T,{children:e.jsx(P,{className:"p-5 text-sm text-muted-foreground",children:"Detailed timeline charts (impressions per day, geo breakdown) will appear here in a follow-up. Counters above update in real time as the widget tracks events."})})]})}function Vt({proof:t}){const[a,l]=d.useState(!1),r=`<script src="${"https://app.pagedock.ai/api".replace("/api","")||window.location.origin}/pp/widget.js" data-token="${t.embed_token}" async defer><\/script>`,o=()=>{navigator.clipboard.writeText(r).catch(()=>{}),l(!0),I.success("Embed code copied!"),setTimeout(()=>l(!1),2e3)};return e.jsx("div",{className:"space-y-6",children:e.jsxs(T,{children:[e.jsx(Te,{children:e.jsxs(Pe,{className:"text-base flex items-center gap-2",children:[e.jsx(at,{className:"w-5 h-5 text-primary"}),"Embed Code"]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Paste this snippet right before the closing ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-secondary text-xs",children:"</body>"})," ","tag of any page where you want the purchase notifications to appear. Loads asynchronously and respects your domain whitelist."]}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-secondary rounded-xl p-4 pr-24 text-xs font-mono text-foreground overflow-x-auto whitespace-pre-wrap break-all border border-border",children:r}),e.jsx(E,{size:"sm",variant:"outline",className:"absolute top-2 right-2 h-8",onClick:o,children:a?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"w-3.5 h-3.5 mr-1 text-emerald-600"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-3.5 h-3.5 mr-1"})," Copy"]})})]}),e.jsx("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-4",children:e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:"Embed Token:"})," ",e.jsx("code",{className:"bg-blue-500/10 px-1.5 py-0.5 rounded",children:t.embed_token})]})}),e.jsx("div",{className:"p-3 rounded-xl bg-secondary/50",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"The script is small (~80 KB gzipped), runs in a Shadow DOM so your page styles don't leak in, and only fetches records for this proof. Notifications appear on a 60-second cycle by default â adjust on the Display tab."})})]})]})})}function Wt({country:t,size:a=50,landColor:l="#cbd5e1",waterColor:s="#e2e8f0",pinColor:r="#10b981",pinSha
54dowColor:o="rgba(0,0,0,0.35)",rounded:c=!0}){const i=wt(t),u=100,m=60,g=(i==null?void 0:i.lng)??0,h=(i==null?void 0:i.lat)??0,k=(g+180)/360*u,b=(90-h)/180*m;return e.jsxs("svg",{viewBox:`0 0 ${u} ${m}`,width:a,height:a,style:{display:"block",borderRadius:c?"50%":"8px",background:s,overflow:"hidden"},xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{width:u,height:m,fill:s}),e.jsxs("g",{fill:l,children:[e.jsx("path",{d:"M5 12 Q14 6 24 9 Q31 11 30 18 L26 26 Q21 30 14 28 Q8 26 6 21 Z"}),e.jsx("path",{d:"M22 32 Q27 30 30 35 L29 46 Q26 53 23 50 Q19 46 21 39 Z"}),e.jsx("path",{d:"M48 22 Q54 19 58 24 L57 38 Q53 46 49 41 Q46 35 47 28 Z"}),e.jsx("path",{d:"M44 14 Q50 11 56 14 L55 21 Q50 23 46 21 Z"}),e.jsx("path",{d:"M55 14 Q72 8 86 14 Q90 20 84 26 L74 28 Q66 26 60 22 Q57 18 55 16 Z"}),e.jsx("path",{d:"M68 26 Q72 27 73 32 L70 36 Q66 35 65 30 Z"}),e.jsx("path",{d:"M82 42 Q90 40 92 46 L89 50 Q83 50 80 46 Z"})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("ellipse",{cx:k,cy:b+3.4,rx:2.6,ry:.9,fill:o}),e.jsx("circle",{cx:k,cy:b,r:2.6,fill:r,stroke:"#ffffff",strokeWidth:.8}),e.jsx("circle",{cx:k,cy:b,r:1,fill:"#ffffff",opacity:.9})]})]})}function Gt({record:t,style:a="initials",colorSeed:l="name_hash",accentColor:s="#3b82f6",size:r=44,rounded:o=!0}){if(a==="url"&&(t!=null&&t.avatar_url))return e.jsx("img",{src:t.avatar_url,alt:"",width:r,height:r,style:{width:r,height:r,borderRadius:o?"50%":"8px",objectFit:"cover",display:"block"},onError:u=>{u.currentTarget.style.display="none"}});if(a==="map")return e.jsx(Wt,{country:t==null?void 0:t.country,size:r,pinColor:s,rounded:o});const c=((t==null?void 0:t.name)||"?").split(/\s+/).filter(Boolean).slice(0,2).map(u=>{var m;return((m=u[0])==null?void 0:m.toUpperCase())||""}).join("")||"?",i=l==="theme_accent"?s:Yt((t==null?void 0:t.name)||"");return e.jsx("div",{style:{width:r,height:r,borderRadius:o?"50%":"8px",background:i,color:Xt(i),display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(11,Math.round(r*.36)),fontWeight:700,letterSpacing:"0.02em",textTransform:"uppercase",fontVariantNumeric:"tabular-nums",userSelect:"none"},children:c})}function Yt(t){let a=0;for(let s=0;s<t.length;s++)a=a*31+t.charCodeAt(s)|0;return`hsl(${Math.abs(a)%360}, 60%, 55%)`}function Xt(t){let a=99,l=99,s=99;const r=String(t).match(/^#([0-9a-f]{6})$/i),o=String(t).match(/^hsl\(\s*(\d+)\s*,\s*\d+%?\s*,\s*(\d+)%?/i);if(r)a=parseInt(r[1].slice(0,2),16),l=parseInt(r[1].slice(2,4),16),s=parseInt(r[1].slice(4,6),16);else if(o)return parseInt(o[2],10)>60?"#1f2937":"#ffffff";const c=u=>{const m=u/255;return m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4)};return .2126*c(a)+.7152*c(l)+.0722*c(s)>.55?"#1f2937":"#ffffff"}function qt(){var l;const t="https://pagedock.ai";if(typeof window>"u")return t;const a=(((l=window.location)==null?void 0:l.hostname)||"").replace(/^www\./i,"");return a?`${t}?ref=${encodeURIComponent(a)}`:t}function Z(t,a){if(typeof t!="string")return a;const l=t.trim();if(l.startsWith("#"))return l;const s=l.match(/#[0-9a-fA-F]{6}/);if(s)return s[0];const r=l.match(/rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i);if(r){const o=c=>Number(c).toString(16).padStart(2,"0");return`#${o(r[1])}${o(r[2])}${o(r[3])}`}return a}function Kt(t,a){const l=Z(t,"#ffffff"),r=he(a)?"#ffffff":"#000000";return`color-mix(in srgb, ${l} 35%, ${r} 65%)`}function Qt(t){return he(t)?"rgba(0, 0, 0, 0.10)":"rgba(255, 255, 255, 0.18)"}function he(t){const a=Z(t,"#000000"),l=parseInt(a.slice(1,3),16),s=parseInt(a.slice(3,5),16),r=parseInt(a.slice(5,7),16),o=i=>{const u=i/255;return u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)};return .2126*o(l)+.7152*o(s)+.0722*o(r)<.5}function ae({record:t,proof:a,onDismiss:l,onClick:s,showDismiss:r=!0,showBranding:o}){const c=d.useRef(null),i=Jt(a,t,c);if(!a)return null;const u=a.theme_key||"clean_white",m=gt(u,a.theme_overrides),g=a.avatar_style||m.default_avatar_style||"initials",h=a.avatar_color_seed||"name_hash",k=(o??a.branding_enabled)!==!1,b=u==="bubble"?"pill":"rounded",y=a.bubble_style||b,j=y==="pill",w=k&&!j,f=(()=>{switch(y){case"chat_bubble":return{borderRadius:22};case"squircle":return{borderRadius:26};case"pill":return{borderRadius:999};case"sharp":return{borderRadius:4};case"ticket":return{borderRadius:0,boxShadow:"0 10px 28px rgba(0,0,0,0.22)"};case"floating":return{border:"none",borderRadius:16,boxShadow:"0 18px 44px rgba(0,0,0,0.22)"};case"glass":return{borderRadius:16,background:Kt(m.colors.bg,m.colors.text),backdropFilter:"blur(14px) saturate(140%)",WebkitBackdropFilter:"blur(14px) saturate(140%)",border:`1px solid ${Qt(m.colors.text)}`};case"rounded":default:return{borderRadius:14}}})(),v={background:m.colors.bg,color:m.colors.text,border:`1px solid ${m.colors.border}`,boxShadow:"0 14px 36px rgba(0, 0, 0, 0.18)",padding:j?"8px 16px":w?"12px 12px 18px 12px":"12px",...y==="ticket"&&!j&&{padding:w?"12px 12px 18px 22px":"12px 12px 12px 22px"},minWidth:j?"auto":280,maxWidth:380,display:"flex",alignItems:"center",gap:12,position:"relative",overflow:"visible",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:13,lineHeight:1.35,cursor:a.click_url?"pointer":"default",...u==="map_ribbon"&&{borderLeft:`4px solid ${m.colors.accent}`},...u==="toast_top"&&{minWidth:320,padding:w?"10px 14px 16px 14px":"10px 14px",borderRadius:"10px"},...f},_=(t==null?void 0:t.message)||(a.message_template?Zt(a.message_template,t,a):`${(t==null?void 0:t.name)||""} just purchased`),L=j?24:44,C=e.jsxs(e.Fragment,{children:[!j&&e.jsx(Gt,{record:t,style:g,colorSeed:h,accentColor:m.colors.accent,size:L,rounded:!["map_ribbon","pin_spot"].includes(u)}),e.jsxs("div",{style:{flex:"1 1 auto",minWidth:0},children:[e.jsx("div",{style:{fontWeight:600},dangerouslySetInnerHTML:{__html:_}}
54),a.timestamp_format!=="hidden"&&(t==null?void 0:t.time_ago_text)&&e.jsx("div",{style:{fontSize:11,opacity:.65,marginTop:2},children:t.time_ago_text}),a.live_counter_enabled&&i&&e.jsxs("div",{style:{fontSize:11,opacity:.9,marginTop:4,color:m.colors.accent,display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:m.colors.accent,boxShadow:`0 0 0 0 ${m.colors.accent}`,animation:"pdockProofPulse 1.6s ease-in-out infinite"}}),e.jsx("span",{children:i})]})]}),w&&e.jsxs("a",{href:qt(),target:"_blank",rel:"noopener noreferrer",title:"Verified by PageDock",onClick:S=>S.stopPropagation(),onMouseEnter:S=>{S.currentTarget.style.opacity="1"},onMouseLeave:S=>{S.currentTarget.style.opacity="0.9"},style:{position:"absolute",bottom:2,right:y==="squircle"||y==="chat_bubble"?15:8,display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,letterSpacing:"0.02em",lineHeight:1,color:m.colors.accent,opacity:.9,textDecoration:"none",cursor:"pointer",transition:"opacity 0.15s ease",whiteSpace:"nowrap"},children:[e.jsx(ut,{style:{width:12,height:12,flexShrink:0},"aria-hidden":!0}),"Verified by"," ",e.jsx("span",{style:{fontWeight:800},children:"PageDock"})]}),y==="chat_bubble"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"absolute",left:-10,top:"50%",marginTop:-10,width:0,height:0,borderTop:"10px solid transparent",borderBottom:"10px solid transparent",borderRight:`10px solid ${m.colors.border}`,pointerEvents:"none"},"aria-hidden":!0}),e.jsx("div",{style:{position:"absolute",left:-8,top:"50%",marginTop:-9,width:0,height:0,borderTop:"9px solid transparent",borderBottom:"9px solid transparent",borderRight:`9px solid ${Z(m.colors.bg,m.colors.border)}`,pointerEvents:"none"},"aria-hidden":!0})]}),y==="ticket"&&!j&&e.jsx("div",{style:{position:"absolute",top:8,bottom:8,left:14,width:0,borderLeft:`1.5px dashed ${m.colors.border}`,opacity:.7,pointerEvents:"none"},"aria-hidden":!0})]});return e.jsxs("div",{ref:c,style:v,onClick:S=>{S.target.closest("[data-proof-dismiss]")||s==null||s(S)},children:[C,r&&a.closeable!==!1&&(()=>{let S,M;return y==="pill"?(S="50%",M=14):y==="squircle"?(S=w?6:4,M=12):(S=w?4:0,M=w?6:2),e.jsx("button",{"data-proof-dismiss":!0,type:"button",onClick:p=>{p.stopPropagation(),l==null||l()},"aria-label":"Dismiss",style:{position:"absolute",top:S,right:M,width:18,height:18,transform:y==="pill"?"translateY(-50%)":void 0,background:"transparent",border:"none",color:m.colors.text,opacity:.5,cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(q,{style:{width:14,height:14}})})})()]})}function Zt(t,a,l){if(!a)return t;const s=r=>String(r??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'");return String(t).replaceAll("{name}",s(a.name)).replaceAll("{city}",s(a.city)).replaceAll("{country}",s(a.country)).replaceAll("{state}",s(a.state)).replaceAll("{product}",s(a.product_name||(l==null?void 0:l.default_product_name)||"")).replaceAll("{price}",s(a.price)).replaceAll("{time_ago}",s(a.time_ago_text||"just now"))}function Jt(t,a,l){d.useEffect(()=>{if(!(t!=null&&t.live_counter_enabled))return;const o=l==null?void 0:l.current;if(!o)return;const c=o.getRootNode(),i=c.head||c;if(!i||i.querySelector("style[data-pdock-proof-pulse]"))return;const u=(c.ownerDocument||document).createElement("style");u.setAttribute("data-pdock-proof-pulse","true"),u.textContent=`@keyframes pdockProofPulse { 55 0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; } 56 70% { box-shadow: 0 0 0 6px rgba(0,0,0,0); opacity: 0.6; } 57 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); opacity: 1; } 58 }`,i.appendChild(u)},[t==null?void 0:t.live_counter_enabled,l]);const[s,r]=d.useState(0);return d.useEffect(()=>{if(!(t!=null&&t.live_counter_enabled))return;const o=setInterval(()=>r(c=>c+1),12e3);return()=>clearInterval(o)},[t==null?void 0:t.live_counter_enabled]),d.useMemo(()=>{if(!(t!=null&&t.live_counter_enabled))return null;const o=Math.max(0,Number(t.live_counter_min??15)|0),c=Math.max(o,Number(t.live_counter_max??50)|0),i=o===c?o:Math.floor(o+Math.random()*(c-o+1));return String(t.live_counter_template||"{n} people viewing this offer").replace("{n}",String(i))},[t==null?void 0:t.live_counter_enabled,t==null?void 0:t.live_counter_min,t==null?void 0:t.live_counter_max,t==null?void 0:t.live_counter_template,a,s])}const ea=0,ta=2e3,aa=[{name:"Sarah M.",city:"New York",country:"US",product_name:"Pro Plan",time_ago_text:"2 min ago"},{name:"Hugo M.",city:"Paris",country:"FR",product_name:"Annual Pass",time_ago_text:"5 min ago"},{name:"Yui T.",city:"Tokyo",country:"JP",product_name:"Lifetime",time_ago_text:"7 min ago"},{name:"Liam B.",city:"Toronto",country:"CA",product_name:"Pro Plan",time_ago_text:"11 min ago"},{name:"LucÃa R.",city:"Madrid",country:"ES",product_name:"Starter",time_ago_text:"15 min ago"}],se={bottom_left:{left:16,bottom:16,transform:"translateZ(0)"},bottom_right:{right:16,bottom:16,transform:"translateZ(0)"},bottom_center:{left:"50%",bottom:16,transform:"translateX(-50%)"},top_left:{left:16,top:16,transform:"translateZ(0)"},top_right:{right:16,top:16,transform:"translateZ(0)"},top_center:{left:"50%",top:16,transform:"translateX(-50%)"},inline:{position:"static",transform:"none"}},sa={slide_up:"pdockProofSlideUp",slide_down:"pdockProofSlideDown",slide_left:"pdockProofSlideLeft",slide_right:"pdockProofSlideRight",fade:"pdockProofFade",bounce:"pdockProofBounce",none:null};let re=!1;function ra(){if(re||typeof document>"u")return;const t=document.createElement("style");t.setAttribute("data-pdock-proof-keyframes","true"),t.textContent=` 59 @keyframes pdockProofSlideUp { from { opacity: 0; transform: translateY(20px) translateX(var(--pdock-x, 0)); } to { opacity: 1; transform: translateY(0) translateX(var(--pdock-x, 0)); } } 60 @keyframes pdockProofSlideDown { from { opacity: 0; transform: translateY(-20px) translateX(var(--pdock-x, 0)); } to { opacity: 1; transform: translateY(0) translateX(var(--pdock-x, 0)); } } 61 @keyframes pdockProofSlideLeft { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(var(--pdock-x, 0)); } } 62 @keyframes pdockProofSlideRight { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(var(--pdock-x, 0)); } } 63 @keyframes pdockProofFade { from { opacity: 0; } to { opacity: 1; } } 64 @keyframes pdockProofBounce { 65 /* Modern spring entrance with per-segment easing + scale 66 wobble. Kept in lockstep with the embed widget 67 (purchase-proof-widget/Widget.jsx). See the comment 68 there for the full design rationale. */ 69 0% { opacity: 0; transform: translateY(60px) translateX(var(--pdock-x, 0)) scale(0.86); animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); } 70 38% { opacity: 1; transform: translateY(-26px) translateX(var(--pdock-x, 0)) scale(1.06); animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53); } 71 55% { opacity: 1; transform: translateY(12px) translateX(var(--pdock-x, 0)) scale(0.97); animation-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1); } 72 70% { opacity: 1; transform: translateY(-9px) translateX(var(--pdock-x, 0)) scale(1.02); animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53); } 73 82% { opacity: 1; transform: translateY(4px) translateX(var(--pdock-x, 0)) scale(0.99); animation-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1); } 74 92% { opacity: 1; transform: translateY(-2px) translateX(var(--pdock-x, 0)) scale(1); animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53); } 75 100% { opacity: 1; transform: translateY(0) translateX(var(--pdock-x, 0)) scale(1); } 76 } 77 `,document.head.appendChild(t),re=!0}function la({proof:t,records:a}){d.useEffect(()=>{ra()},[]);const l=d.useMemo(()=>(a&&a.length?a:aa).slice(0,50),[a]),[s,r]=d.useState(0),[o,c]=d.use
77State(!1),i=d.useRef(!1);if(i.current=o,d.useEffect(()=>{if(!t||l.length===0)return;let b=!1;const y=Math.max(1,t.display_seconds||6)*1e3,j=()=>{b||(c(!0),setTimeout(()=>{b||(c(!1),setTimeout(()=>{b||(r(f=>na(f,l.length,t.cycle_mode)),j())},ta))},y))},w=setTimeout(j,ea);return()=>{b=!0,clearTimeout(w)}},[t==null?void 0:t.display_seconds,t==null?void 0:t.cycle_mode,l.length]),!t)return null;const u=t.position||"bottom_left",m=se[u]||se.bottom_left,g=sa[t.enter_animation||"slide_up"],h=u.endsWith("center")?"-50%":"0",k=u==="inline";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-muted/20 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border bg-muted/40",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-rose-400/80"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/80"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-emerald-400/80"}),e.jsx("div",{className:"ml-3 text-[11px] text-muted-foreground font-mono",children:"your-site.com"})]}),e.jsxs("div",{className:"relative bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-900 dark:to-slate-950",
77style:{height:380,overflow:"hidden"},children:[e.jsxs("div",{className:"absolute inset-0 p-6 opacity-40",children:[e.jsx("div",{className:"h-3 w-2/3 rounded bg-slate-300 dark:bg-slate-700 mb-2"}),e.jsx("div",{className:"h-3 w-1/2 rounded bg-slate-300 dark:bg-slate-700 mb-6"}),e.jsx("div",{className:"h-2 w-full rounded bg-slate-200 dark:bg-slate-800 mb-2"}),e.jsx("div",{className:"h-2 w-full rounded bg-slate-200 dark:bg-slate-800 mb-2"}),e.jsx("div",{className:"h-2 w-3/4 rounded bg-slate-200 dark:bg-slate-800 mb-6"}),e.jsx("div",{className:"h-32 w-full rounded-lg bg-slate-200 dark:bg-slate-800"})]}),(()=>{const b=t.enter_animation==="bounce",y=g?b?`${g} 1.15s linear`:`${g} 0.85s cubic-bezier(0.16, 1, 0.3, 1)`:void 0;return k?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6",children:o&&l[s]&&e.jsx("div",{style:{animation:y},children:e.jsx(ae,{record:l[s],proof:t})},`${s}-${o}`)}):o&&l[s]&&e.jsx("div",{style:{position:"absolute",...m,"--pdock-x":h,animation:y?`${y} both`:void 0},children:e.jsx(ae,{record:l[s],proof:t})},`${s}-${o}`)})()]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground inline-flex items-center gap-1.5 px-1",children:[e.jsx(st,{className:"w-3 h-3 shrink-0 opacity-70"}),e.jsx("span",{children:"Live preview won't show the actual gap so you can see the proof in action faster."})]})]})}function na(t,a,l){if(a<=1)return 0;if(l==="random"||l==="random_no_repeat"){let s=t;for(let r=0;r<4&&s===t;r++)s=Math.floor(Math.random()*a);return s}return(t+1)%a}F.extend(ie);const ge=[{id:"general",label:"General"},{id:"theme",label:"Theme"},{id:"display",label:"Display"},{id:"content",label:"Content"},{id:"data-source",label:"Data Source"},{id:"records",label:"Records"},{id:"analytics",label:"Analytics"},{id:"embed",label:"Embed & Test"}],le=ge.map(t=>t.id),ne="general";function ls(){const{id:t}=ye(),a=je(),[l,s]=ve(),[r,o]=d.useState(null),[c,i]=d.useState(!0),[u,m]=d.useState([]),g=(()=>{const n=l.get("tab");return n&&le.includes(n)?n:ne})(),[h,k]=d.useState(g),[b,y]=d.useState(!1);d.useEffect(()=>{const n=l.get("tab");n&&le.includes(n)&&n!==h&&k(n)},[l]);const j=d.useCallback(n=>{k(n);const x=new URLSearchParams(l);n===ne?x.delete("tab"):x.set("tab",n),s(x,{replace:!0})},[l,s]);Ne((r==null?void 0:r.name)||"Purchase Proof");const w=d.useCallback(async()=>{try{i(!0),$.invalidateCache(`/purchase-proofs/${t}`);const n=await $.get(`/purchase-proofs/${t}`);o(n)}catch{I.error("Failed to load purchase proof"),a("/dashboard/conversion-tools?tab=purchase-proof")}finally{i(!1)}},[t,a]),f=d.useCallback(async()=>{try{const n=await $.get(`/purchase-proofs/${t}/records?per_page=20`);m(Array.isArray(n==null?void 0:n.data)?n.data:[])}catch{m([])}},[t]);d.useEffect(()=>{w()},[w]),d.useEffect(()=>{f()},[f]);const v=d.useRef({}),_=d.useRef(null),L=350,C=d.useCallback(()=>{if(Object.keys(v.current).length===0)return;const n=v.current;v.current={},_.current=null,y(!0),$.put(`/purchase-proofs/${t}`,n).then(x=>{x&&typeof x=="object"&&o(N=>N&&{...N,updated_at:x.updated_at??N.updated_at})}).catch(x=>{I.error(x.message||"Failed to save"),w()}).finally(()=>y(!1))},[t,w]),S=n=>{const x={...n,updated_at:new Date().toISOString()};o(N=>({...N,...x})),v.current={...v.current,...n},_.current&&clearTimeout(_.current),_.current=setTimeout(C,L)};if(d.useEffect(()=>{_.current&&(clearTimeout(_.current),C())},[h]),d.useEffect(()=>()=>{_.current&&(clearTimeout(_.current),C())},[C]),c||!r)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(we,{text:"Loading...",size:"lg"})});const M=e.jsxs("div",{className:"min-w-0",children:[h==="general"&&e.jsx(pt,{proof:r,onUpdate:S,saving:b}),h==="theme"&&e.jsx(Nt,{proof:r,onUpdate:S}),h==="display"&&e.jsx(Pt,{proof:r,onUpdate:S}),h==="content"&&e.jsx(Mt,{proof:r,onUpdate:S}),h==="data-source"&&e.jsx(Bt,{proof:r,onUpdate:S,onRecordsChanged:f}),h==="records"&&e.jsx(zt,{proof:r,onUpdate:S,onRecordsDeleted:n=>{const x=new Set(n);m(N=>N.filter(R=>!x.has(R.id))),o(N=>N&&{...N,records_count:Math.max(0,(N.records_count||0)-n.length)})},onRecordsCleared:()=>{m([]),o(n=>n&&{...n,records_count:0})},onRecordAdded:n=>{m(x=>[n,...x].slice(0,20)),o(x=>x&&{...x,records_count:(x.records_count||0)+1})}}),h==="analytics"&&e.jsx(Ht,{proof:r}),h==="embed"&&e.jsx(Vt,{proof:r})]}),p=e.jsx(la,{proof:r,records:u});return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-4",children:[e.jsx(E,{variant:"ghost",size:"icon",className:"rounded-xl flex-shrink-0",onClick:()=>a("/dashboard/conversion-tools?tab=purchase-proof"),children:e.jsx(rt,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 bg-fuchsia-500/10",children:e.jsx(Je,{className:"w-5 h-5 text-fuchsia-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-lg sm:text-xl font-bold text-foreground truncate",children:r.name}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[e.jsx(lt,{className:"w-3.5 h-3.5 opacity-70","aria-hidden":!0}),t]}),r.created_at&&e.jsx(V,{title:"Created",description:F(r.created_at).format("MMMM D, YYYY h:mm A"),children:e.jsxs("span",{className:"cursor-help",children:["Created ",F(r.created_at).fromNow()]})})]})]})]}),e.jsxs(_e,{value:r.status,onValueChange:n=>S({status:n}),children:[e.jsx(ke,{className:A("w-[150px] h-9 text-xs font-semibold uppercase tracking-wide gap-2",r.status==="active"?"border-emerald-500/30 text-emerald-600":r.status==="paused"?"border-amber-500/30 text-amber-600":"text-muted-foreground"),children:e.jsx(Se,{})}),e.jsxs(Ce,{children:[e.jsx(J,{value:"active",children:"Active"}),e.jsx(J,{value:"paused",children:"Paused"})]})]})]}),e.jsx("div",{className:"flex gap-1 bg-secondary/50 p-1 rounded-xl overflow-x-auto",children:ge.map(n=>e.jsx("button",{type:"button",onClick:()=>j(n.id),className:A("px-4 py-2 rounded-lg text-sm font-medium transition-all whitespace-nowrap",h===n.id?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:n.label},n.id))}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[M,e.jsx("div",{className:"xl:sticky xl:top-6 self-start min-w-0",children:p})]})]})}export{ls 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.