1try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="05e665cb-c9e3-419e-a750-aa7b0cff4624",e._sentryDebugIdIdentifier="sentry-dbid-05e665cb-c9e3-419e-a750-aa7b0cff4624")}()}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1005],{7428:(e,t,a)=>{a.d(t,{v:()=>p});var s=a(95155),n=a(94514),r=a(65770),l=a(66088),i=a(22812),o=a(15335),c=a(67635),d=a(52656),x=a(87739),m=a(91337);let u={most_duplicates:"Most duplicates",newest:"Newest",oldest:"Oldest",longest_running:"Longest Running",ad_spend:"Estimated Ad Spend"},h={most_duplicates:"Most duplicates",newest:"Newest",oldest:"Oldest",longest_running:"Longest",ad_spend:"Ad Spend"};function p(e){let{value:t,triggerClassName:a,includeMostDuplicates:p}=e,f=(a,r)=>(0,s.jsxs)(x._2,{onSelect:()=>{e.includeMostDuplicates?e.onValueChange(a):"most_duplicates"!==a&&e.onValueChange(a)},className:(0,m.cn)("h-10 cursor-pointer gap-3 rounded-lg px-3 text-sm font-normal text-[#302e2c] focus:bg-[#f5f4f2] focus:text-[#1d1c1b]",t===a&&"bg-[#f5f4f2] font-medium text-[#1d1c1b]"),"data-sentry-element":"DropdownMenuItem","data-sentry-component":"renderItem","data-sentry-source-file":"AdSortMenu.tsx",children:[(0,s.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center text-[#696663]",children:r}),(0,s.jsx)("span",{className:"flex-1",children:u[a]}),t===a&&(0,s.jsx)(n.A,{className:"h-4 w-4 shrink-0 text-[#1d1c1b]"})]},a);return(0,s.jsxs)(x.rI,{"data-sentry-element":"DropdownMenu","data-sentry-component":"AdSortMenu","data-sentry-source-file":"AdSortMenu.tsx",children:[(0,s.jsx)(x.ty,{asChild:!0,"data-sentry-element":"DropdownMenuTrigger","data-sentry-source-file":"AdSortMenu.tsx",children:(0,s.jsxs)("button",{type:"button","aria-label":"Sort ads by ".concat(u[t]),className:(0,m.cn)("inline-flex h-9 shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-transparent bg-transparent px-3 text-sm font-medium text-[#4b5563] transition-colors hover:bg-[#f6f5f4] hover:text-[#111827] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#302e2c]/10 2xl:w-[160px] 2xl:justify-end","most_duplicates"===t&&"2xl:w-auto 2xl:min-w-[160px]",a),children:[(0,s.jsx)(r.A,{className:"h-4 w-4","data-sentry-element":"ArrowUpDown","data-sentry-source-file":"AdSortMenu.tsx"}),(0,s.jsxs)("span",{children:["Sort: ",h[t]]}),(0,s.jsx)(l.A,{className:"h-3.5 w-3.5","data-sentry-element":"ChevronDown","data-sentry-source-file":"AdSortMenu.tsx"})]})}),(0,s.jsxs)(x.SQ,{align:"end",sideOffset:6,className:"w-64 rounded-xl border-[#e7e5e1] p-2 shadow-[0_10px_30px_rgba(28,25,23,0.12)]","data-sentry-element":"DropdownMenuContent","data-sentry-source-file":"AdSortMenu.tsx",children:[(0,s.jsx)(x.lp,{className:"px-3 pb-1.5 pt-1 text-xs font-medium text-[#908c89]","data-sentry-element":"DropdownMenuLabel","data-sentry-source-file":"AdSortMenu.tsx",children:"Recommended"}),f("newest",(0,s.jsx)(i.A,{className:"h-[18px] w-[18px]"})),f("oldest",(0,s.jsx)(i.A,{className:"h-[18px] w-[18px]"})),f("longest_running",(0,s.jsx)(o.A,{className:"h-[18px] w-[18px]"})),p&&f("most_duplicates",(0,s.jsx)(c.A,{className:"h-[18px] w-[18px]"})),(0,s.jsxs)("div",{className:"my-2 flex items-center gap-2 px-2","aria-hidden":"true",children:[(0,s.jsx)("div",{className:"h-px flex-1 bg-[#eceae7]"}),(0,s.jsx)("span",{className:"rounded-full border border-[#e7e5e1] bg-[#faf9f8] px-2 py-0.5 text-[11px] font-medium text-[#77736f]",children:"EU/UK"}),(0,s.jsx)("div",{className:"h-px flex-1 bg-[#eceae7]"})]}),f("ad_spend",(0,s.jsx)(d.A,{className:"h-[18px] w-[18px]"}))]})]})}},11005:(e,t,a)=>{a.r(t),a.d(t,{BrandDetailPage:()=>eM});var s=a(95155),n=a(12115),r=a(80723),l=a(6296),i=a(66088),o=a(45005),c=a(22164),d=a(44071),x=a(67635),m=a(68822),u=a(6962),h=a(20232),p=a(61878),f=a(94928),g=a(17243),b=a(1945),v=a(86710),y=a(20702),j=a(29142),N=a(87739),w=a(31431),A=a(41641),k=a(21362),C=a(60285),S=a(91337);let _=e=>{let{className:t,...a}=e;return(0,s.jsx)("nav",{role:"navigation","aria-label":"pagination",className:(0,S.cn)("mx-auto flex w-full justify-center",t),...a,"data-sentry-component":"Pagination","data-sentry-source-file":"pagination.tsx"})};_.displayName="Pagination";let M=n.forwardRef((e,t)=>
1{let{className:a,...n}=e;return(0,s.jsx)("ul",{ref:t,className:(0,S.cn)("flex flex-row items-center gap-1",a),...n})});M.displayName="PaginationContent";let T=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)("li",{ref:t,className:(0,S.cn)("",a),...n})});T.displayName="PaginationItem";let B=e=>{let{className:t,isActive:a,size:n="icon",...r}=e;return(0,s.jsx)("a",{"aria-current":a?"page":void 0,className:(0,S.cn)((0,v.r)({variant:a?"outline":"ghost",size:n}),t),...r,"data-sentry-component":"PaginationLink","data-sentry-source-file":"pagination.tsx"})};B.displayName="PaginationLink";let F=e=>{let{className:t,...a}=e;return(0,s.jsxs)(B,{"aria-label":"Go to previous page",size:"default",className:(0,S.cn)("gap-1 pl-2.5",t),...a,"data-sentry-element":"PaginationLink","data-sentry-component":"PaginationPrevious","data-sentry-source-file":"pagination.tsx",children:[(0,s.jsx)(A.A,{className:"h-4 w-4","data-sentry-element":"ChevronLeft","data-sentry-source-file":"pagination.tsx"}),(0,s.jsx)("span",{children:"Previous"})]})};F.displayName="PaginationPrevious";let L=e=>{let{className:t,...a}=e;return(0,s.jsxs)(B,{"aria-label":"Go to next page",size:"default",className:(0,S.cn)("gap-1 pr-2.5",t),...a,"data-sentry-element":"PaginationLink","data-sentry-component":"PaginationNext","data-sentry-source-file":"pagination.tsx",children:[(0,s.jsx)("span",{children:"Next"}),(0,s.jsx)(k.A,{className:"h-4 w-4","data-sentry-element":"ChevronRight","data-sentry-source-file":"pagination.tsx"})]})};L.displayName="PaginationNext";let D=e=>{let{className:t,...a}=e;return(0,s.jsxs)("span",{"aria-hidden":!0,className:(0,S.cn)("flex h-9 w-9 items-center justify-center",t),...a,"data-sentry-component":"PaginationEllipsis","data-sentry-source-file":"pagination.tsx",children:[(0,s.jsx)(C.A,{className:"h-4 w-4","data-sentry-element":"MoreHorizontal","data-sentry-source-file":"pagination.tsx"}),(0,s.jsx)("span",{className:"sr-only",children:"More pages"})]})};D.displayName="PaginationEllipsis";var P=a(72320),E=a(12894),R=a(80947),I=a(1728),U=a(38567),O=a(28408),z=a(32539),G=a(59656),W=a(95543),H=a(77167),V=a(66261),$=a(57902),K=a(19915),X=a(28434),Q=a(72572),Y=a(84243),q=a(85318),Z=a(7428),J=a(61006),ee=a(47678),et=a(33210),ea=a(94514),es=a(92622),en=a(76648),er=a(47838),el=a(35525),ei=a(29983);let eo=[{value:"FACEBOOK",label:"Facebook"},{value:"INSTAGRAM",label:"Instagram"}],ec=[{value:"VIDEO",label:"Video"},{value:"DCO",label:"DCO"},{value:"IMAGE",label:"Image"},{value:"CAROUSEL",label:"Carousel"}],ed=ee.o.map(e=>{let{code:t,name:a}=e;return{value:t,label:a}}),ex=[...J.Q.map(e=>{let{code:t,name:a}=e;return{value:t,label:a}}),{value:"NO",label:"Norway"}].filter(e=>{let{value:t}=e;return["GB","DE","FR","IT","ES","NL","IE","PL","PT","SE","BE","AT","DK","FI","NO","CZ","RO","HU","GR","BG"].includes(t)}),em="relative inline-flex h-8 shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-transparent bg-transparent px-2.5 text-sm font-medium text-[#4b5563] transition-colors hover:bg-[#f6f5f4] hover:text-[#111827] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#302e2c]/10",eu="overflow-hidden rounded-2xl border-[#e7e5e1] bg-white p-0 shadow-[0_18px_50px_rgba(28,25,23,0.16)]",eh="h-9 rounded-none border-x-0 border-t-0 border-b border-[#d8d4cf] bg-transparent px-0 text-sm shadow-none [appearance:textfield] placeholder:text-[#aaa6a2] focus-visible:border-[#77736f] focus-visible:ring-0 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",ep="h-9 rounded-lg px-3 text-sm font-medium text-[#77736f] transition-colors hover:bg-[#f5f4f2] hover:text-[#1d1c1b]",ef="h-9 rounded-xl bg-[#1d1c1b] px-4 font-semibold text-white shadow-none hover:bg-[#302e2c]";function eg(e){let{count:t}=e;return(0,s.jsxs)("span",{className:"relative flex h-5 w-3 shrink-0 items-center justify-center","data-sentry-component":"TriggerIndicator","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsx)(i.A,{className:"h-3 w-3","data-sentry-element":"ChevronDown","data-sentry-source-file":"BrandAdsFilterBar.tsx"}),null!=t&&t>0&&(0,s.jsx)("span",{className:"absolute -right-2 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-[#ebe9e7] px-1 text-[10px] font-semibold leading-none text-[#4b5563] ring-2 ring-white",children:t>99?"99+":t})]})}function eb(e){let{label:t,values:a,options:r,onChange:l,searchable:i=!1}
1=e,[o,c]=(0,n.useState)(""),d=r.filter(e=>{let t=o.trim().toLowerCase();return!t||e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)}),x=e=>{l(a.includes(e)?a.filter(t=>t!==e):[...a,e])};return(0,s.jsxs)(el.AM,{onOpenChange:e=>{e||c("")},"data-sentry-element":"Popover","data-sentry-component":"MultiSelectFilter","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsx)(el.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:(0,s.jsxs)("button",{type:"button",className:em,children:[t,(0,s.jsx)(eg,{count:a.length,"data-sentry-element":"TriggerIndicator","data-sentry-source-file":"BrandAdsFilterBar.tsx"})]})}),(0,s.jsxs)(el.hl,{side:"bottom",align:"start",sideOffset:8,avoidCollisions:!1,className:"".concat(eu," w-64 max-h-[270px] max-w-[90vw] overflow-y-auto"),"data-sentry-element":"PopoverContent","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[a.length>0&&(0,s.jsx)("div",{className:"border-b border-[#eceae7] p-3",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(e=>{var t,a;return(0,s.jsxs)(w.E,{variant:"secondary",className:"gap-1 rounded-md bg-[#efedeb] font-medium text-[#585450]",children:[null!=(a=null==(t=r.find(t=>t.value===e))?void 0:t.label)?a:e,(0,s.jsx)(et.A,{className:"h-3 w-3 cursor-pointer",onClick:()=>x(e)})]},e)})})}),i&&(0,s.jsx)("div",{className:"p-3 pb-1",children:(0,s.jsx)(er.p,{value:o,onChange:e=>c(e.target.value),placeholder:"Search ".concat(t.toLowerCase(),"..."),className:"h-8 rounded-lg bg-[#fbfaf9] shadow-none"})}),(0,s.jsx)("div",{className:"max-h-72 overflow-y-auto p-2",children:d.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>x(e.value),className:"flex h-9 w-full items-center gap-2.5 rounded-md px-2 text-left text-sm font-medium text-[#4b4743] hover:bg-[#f6f5f4]",children:[(0,s.jsx)("span",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-[4px] border ".concat(a.includes(e.value)?"border-[#302e2c] bg-[#302e2c] text-white":"border-[#b8b4af] bg-white"),children:a.includes(e.value)&&(0,s.jsx)(ea.A,{className:"h-3 w-3 stroke-[2.5]"})}),(0,s.jsx)("span",{className:"flex-1",children:e.label})]},e.value))}),a.length>0&&(0,s.jsx)("div",{className:"border-t border-[#eceae7] bg-[#fcfbfa] p-2",children:(0,s.jsxs)("button",{type:"button",onClick:()=>l([]),className:"".concat(ep," w-full"),children:["Reset (",a.length,")"]})})]})]})}function ev(e){let{min:t,max:a,minLabel:n,maxLabel:r,prefix:l,onMinChange:i,onMaxChange:o}=e;return(0,s.jsxs)("div",{className:"grid grid-cols-[1fr_auto_1fr] items-end gap-3","data-sentry-component":"RangeFields","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"mb-2 block text-xs font-medium text-[#77736f]",children:n}),(0,s.jsxs)("div",{className:"relative",children:[l&&(0,s.jsx)("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 text-sm text-[#908c89]",children:l}),(0,s.jsx)(er.p,{type:"number",min:0,placeholder:"Min",value:t,onChange:e=>i(e.target.value),className:"".concat(eh," ").concat(l?"pl-4":""),"data-sentry-element":"Input","data-sentry-source-file":"BrandAdsFilterBar.tsx"})]})]}),(0,s.jsx)("span",{className:"pb-2.5 text-sm text-[#aaa6a2]",children:"â"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"mb-2 block text-xs font-medium text-[#77736f]",children:r}),(0,s.jsxs)("div",{className:"relative",children:[l&&(0,s.jsx)("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 text-sm text-[#908c89]",children:l}),(0,s.jsx)(er.p,{type:"number",min:0,placeholder:"Max",value:a,onChange:e=>o(e.target.value),className:"".concat(eh," ").concat(l?"pl-4":""),"data-sentry-element":"Input","data-sentry-source-file":"BrandAdsFilterBar.tsx"})]})]})]})}function ey(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=e?Number(e):null,n=t?Number(t):null,r=null!=s&&Number.isFinite(s)&&s>=a?s:null,l=null!=n&&Number.isFinite(n)&&n>=a?n:null;return null!=r&&null!=l&&r>l&&([r,l]=[l,r]),[r,l]}function ej(e){let{filters:t,onChange:a,onClear:r,resultCount:l}
1=e,[i,o]=(0,n.useState)(t.search),[c,d]=(0,n.useState)(!1),[m,u]=(0,n.useState)(!1),[h,f]=(0,n.useState)(""),[g,b]=(0,n.useState)(""),[y,j]=(0,n.useState)(!1),[N,w]=(0,n.useState)("spend"),[C,S]=(0,n.useState)(!1),[_,M]=(0,n.useState)(""),[T,B]=(0,n.useState)(""),[F,L]=(0,n.useState)(""),[D,P]=(0,n.useState)(""),[E,R]=(0,n.useState)([]),[I,U]=(0,n.useState)(!1),[O,z]=(0,n.useState)("menu"),[G,W]=(0,n.useState)(""),[H,V]=(0,n.useState)(""),[$,K]=(0,n.useState)("");(0,n.useEffect)(()=>o(t.search),[t.search]),(0,n.useEffect)(()=>{let e=i.trim();if(e.length>0&&e.length<3)return;let s=window.setTimeout(()=>{e!==t.search&&a({...t,search:e,associationType:null,associationValue:null})},350);return()=>window.clearTimeout(s)},[i,t,a]);let X=(e,s)=>a({...t,[e]:s}),Q=+(null!=t.creativeUsageMin||null!=t.creativeUsageMax)+ +(t.ctaTypes.length>0),Y=[t.hasEuMetrics,null!=t.euSpendMin||null!=t.euSpendMax,null!=t.euReachMin||null!=t.euReachMax,t.euMarkets.length>0].filter(Boolean).length,q=(0,n.useMemo)(()=>[t.platforms.length,t.formats.length,t.languages.length,"all"!==t.status,null!=t.runTimeMin||null!=t.runTimeMax,Q,Y,!!t.search].filter(Boolean).length,[t,Q,Y]),Z=null!=t.runTimeMin&&null!=t.runTimeMax?"".concat(t.runTimeMin,"-").concat(t.runTimeMax,"d"):null!=t.runTimeMin?"â¥".concat(t.runTimeMin,"d"):null!=t.runTimeMax?"â¤".concat(t.runTimeMax,"d"):"Run Time",J=null!=t.creativeUsageMin&&null!=t.creativeUsageMax?"".concat(t.creativeUsageMin,"-").concat(t.creativeUsageMax):null!=t.creativeUsageMin?"â¥".concat(t.creativeUsageMin):null!=t.creativeUsageMax?"â¤".concat(t.creativeUsageMax):null;return(0,s.jsxs)("div",{className:"border-t border-[#eae8e6] py-3","data-sentry-component":"BrandAdsFilterBar","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 2xl:grid 2xl:grid-cols-[minmax(0,1fr)_auto] 2xl:items-center 2xl:gap-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 2xl:min-w-0 2xl:flex-nowrap 2xl:overflow-x-auto 2xl:[scrollbar-width:none] 2xl:[&::-webkit-scrollbar]:hidden",children:[(0,s.jsx)(eb,{label:"Platform",values:t.platforms,options:eo,onChange:e=>X("platforms",e),"data-sentry-element":"MultiSelectFilter","data-sentry-source-file":"BrandAdsFilterBar.tsx"}),(0,s.jsx)(eb,{label:"Format",values:t.formats,options:ec,onChange:e=>X("formats",e),"data-sentry-element":"MultiSelectFilter","data-sentry-source-file":"BrandAdsFilterBar.tsx"}),(0,s.jsxs)(el.AM,{open:m,onOpenChange:u,"data-sentry-element":"Popover","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsx)(el.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:(0,s.jsxs)("button",{type:"button",className:em,children:["Status",(0,s.jsx)(eg,{count:+("all"!==t.status),"data-sentry-element":"TriggerIndicator","data-sentry-source-file":"BrandAdsFilterBar.tsx"})]})}),(0,s.jsx)(el.hl,{side:"bottom",align:"start",sideOffset:8,avoidCollisions:!1,className:"w-52 ".concat(eu),"data-sentry-element":"PopoverContent","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:(0,s.jsx)("div",{className:"p-2",children:[["all","All ads"],["active","Active"],["inactive","Inactive"]].map(e=>{let[a,n]=e;return(0,s.jsxs)("button",{type:"button",onClick:()=>{X("status",a),u(!1)},className:"flex h-9 w-full items-center gap-2.5 rounded-md px-2 text-sm font-medium text-[#4b4743] hover:bg-[#f6f5f4]",children:[(0,s.jsx)("span",{className:"h-2.5 w-2.5 rounded-full ".concat("active"===a?"bg-emerald-500":"inactive"===a?"bg-[#d6d3d1]":"bg-transparent")}),(0,s.jsx)("span",{className:"flex-1 text-left",children:n}),t.status===a&&(0,s.jsx)(ea.A,{className:"h-4 w-4"})]},a)})})})]}),(0,s.jsx)(eb,{label:"Language",values:t.languages,options:ed,onChange:e=>X("languages",e),"data-sentry-element":"MultiSelectFilter","data-sentry-source-file":"BrandAdsFilterBar.tsx"}),(0,s.jsxs)(el.AM,{open:c,onOpenChange:e=>{if(d(e),e){var a,s,n,r;f(null!=(n=null==(a=t.runTimeMin)?void 0:a.toString())?n:""),b(null!=(r=null==(s=t.runTimeMax)?void 0:s.toString())?r:"")}},"data-sentry-element":"Popover","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsx)(el.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:(0,s.jsxs)("button",{type:"button",className:em,children:[Z,(0,s.jsx)(eg,{c
1ount:+(null!=t.runTimeMin||null!=t.runTimeMax),"data-sentry-element":"TriggerIndicator","data-sentry-source-file":"BrandAdsFilterBar.tsx"})]})}),(0,s.jsxs)(el.hl,{side:"bottom",align:"start",sideOffset:8,avoidCollisions:!1,className:"w-[340px] max-w-[calc(100vw-2rem)] ".concat(eu),"data-sentry-element":"PopoverContent","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsxs)("div",{className:"px-5 pb-2 pt-4",children:[(0,s.jsx)("p",{className:"text-base font-semibold text-[#1d1c1b]",children:"Run Time"}),(0,s.jsx)("p",{className:"mt-0.5 text-xs font-medium text-[#908c89]",children:"Choose how long the ads have been running"})]}),(0,s.jsx)("div",{className:"px-5 pb-5 pt-3",children:(0,s.jsx)(ev,{min:h,max:g,minLabel:"Min days",maxLabel:"Max days",onMinChange:f,onMaxChange:b,"data-sentry-element":"RangeFields","data-sentry-source-file":"BrandAdsFilterBar.tsx"})}),(0,s.jsxs)("div",{className:"flex items-center justify-between border-t border-[#eceae7] bg-[#fcfbfa] px-4 py-3",children:[(0,s.jsx)("button",{type:"button",className:ep,onClick:()=>{a({...t,runTimeMin:null,runTimeMax:null}),d(!1)},children:"Clear"}),(0,s.jsx)(v.$,{size:"sm",className:ef,onClick:()=>{let[e,s]=ey(h,g,1);a({...t,runTimeMin:e,runTimeMax:s}),d(!1)},"data-sentry-element":"Button","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:"Apply Filter"})]})]})]}),(0,s.jsxs)(el.AM,{open:y,onOpenChange:e=>{if(j(e),e){var a,s,n,r,l,i,o,c;S(t.hasEuMetrics),M(null!=(l=null==(a=t.euSpendMin)?void 0:a.toString())?l:""),B(null!=(i=null==(s=t.euSpendMax)?void 0:s.toString())?i:""),L(null!=(o=null==(n=t.euReachMin)?void 0:n.toString())?o:""),P(null!=(c=null==(r=t.euReachMax)?void 0:r.toString())?c:""),R([...t.euMarkets])}},"data-sentry-element":"Popover","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsx)(el.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:(0,s.jsxs)("button",{type:"button",className:em,children:["Ad Spend",(0,s.jsx)(eg,{count:Y,"data-sentry-element":"TriggerIndicator","data-sentry-source-file":"BrandAdsFilterBar.tsx"})]})}),(0,s.jsxs)(el.hl,{side:"bottom",align:"end",sideOffset:8,avoidCollisions:!1,className:"w-[500px] max-w-[calc(100vw-3rem)] ".concat(eu),"data-sentry-element":"PopoverContent","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsxs)("div",{className:"flex h-12 items-center border-b border-[#eceae7] px-5",children:[(0,s.jsx)("p",{className:"text-base font-semibold text-[#1d1c1b]",children:"Ad Spend"}),(0,s.jsxs)("button",{type:"button","aria-pressed":C,onClick:()=>S(!C),className:"ml-auto flex items-center gap-2 rounded-lg px-2 py-1 text-xs font-semibold text-[#4b5563] hover:bg-[#f7f6f4]",children:["Only EU/UK Ads",(0,s.jsx)("span",{className:"relative h-5 w-9 rounded-full transition-colors ".concat(C?"bg-[#111827]":"bg-[#dedbd7]"),children:(0,s.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform ".concat(C?"translate-x-[18px]":"translate-x-0.5")})})]})]}),(0,s.jsxs)("div",{className:"grid h-[160px] grid-cols-[132px_minmax(0,1fr)]",children:[(0,s.jsxs)("div",{className:"border-r border-[#eceae7] bg-[#faf9f8] p-3",children:[(0,s.jsx)("p",{className:"mb-2 px-2 text-xs font-medium text-[#908c89]",children:"Filter by"}),[["spend","Estimated spend"],["reach","EU reach"],["markets","Markets"]].map(e=>{let[t,a]=e;return(0,s.jsx)("button",{type:"button",onClick:()=>w(t),className:"mb-1 flex h-10 w-full items-center rounded-lg px-3 text-left text-sm ".concat(N===t?"bg-[#f1f0ee] font-semibold text-[#1d1c1b]":"font-medium text-[#697386] hover:bg-[#f7f6f4]"),children:a},t)})]}),(0,s.jsxs)("div",{className:"p-4",children:["spend"===N&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"mb-3 text-sm font-medium text-[#4b4743]",children:"Estimated total spend"}),(0,s.jsx)(ev,{min:_,max:T,minLabel:"Minimum",maxLabel:"Maximum",prefix:"$",onMinChange:M,onMaxChange:B})]}),"reach"===N&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"mb-3 text-sm font-medium text-[#4b4743]",children:"EU/UK audie
1nce reach"}),(0,s.jsx)(ev,{min:F,max:D,minLabel:"Minimum",maxLabel:"Maximum",onMinChange:L,onMaxChange:P})]}),"markets"===N&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-3 text-sm font-medium text-[#4b4743]",children:"EU/UK target markets"}),(0,s.jsx)("p",{className:"mb-3 text-xs text-[#77736f]",children:"Match any selected location included by the advertiser, not actual delivery."}),(0,s.jsx)("div",{className:"grid max-h-28 grid-cols-2 gap-1 overflow-y-auto pr-1",children:ex.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>{var t;return t=e.value,void R(E.includes(t)?E.filter(e=>e!==t):[...E,t])},className:"flex h-8 items-center gap-2 rounded-md px-2 text-left text-xs font-medium text-[#4b4743] hover:bg-[#f6f5f4]",children:[(0,s.jsx)("span",{className:"flex h-4 w-4 items-center justify-center rounded border ".concat(E.includes(e.value)?"border-[#302e2c] bg-[#302e2c] text-white":"border-[#b8b4af]"),children:E.includes(e.value)&&(0,s.jsx)(ea.A,{className:"h-2.5 w-2.5"})}),e.label]},e.value))})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between border-t border-[#eceae7] bg-[#fcfbfa] px-4 py-2.5",children:[(0,s.jsx)("button",{type:"button",className:ep,onClick:()=>{a({...t,hasEuMetrics:!1,euSpendMin:null,euSpendMax:null,euReachMin:null,euReachMax:null,euMarkets:[]}),j(!1)},children:"Clear"}),(0,s.jsx)(v.$,{size:"sm",className:ef,onClick:()=>{let[e,s]=ey(_,T),[n,r]=ey(F,D);a({...t,hasEuMetrics:C,euSpendMin:e,euSpendMax:s,euReachMin:n,euReachMax:r,euMarkets:E}),j(!1)},"data-sentry-element":"Button","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:"Apply Filter"})]})]})]}),(0,s.jsxs)(el.AM,{open:I,onOpenChange:e=>{U(e),e||(z("menu"),K(""))},"data-sentry-element":"Popover","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:[(0,s.jsx)(el.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:(0,s.jsxs)("button",{type:"button",className:"".concat(em," !border-[#dedbd7] !bg-white px-3 shadow-[0_1px_2px_rgba(28,25,23,0.05)] hover:!border-[#d2cec9]"),children:[(0,s.jsx)(es.A,{className:"h-4 w-4","data-sentry-element":"Filter","data-sentry-source-file":"BrandAdsFilterBar.tsx"}
1),"Add filters",Q>0&&(0,s.jsx)("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-[#efedeb] px-1.5 text-[10px] font-semibold text-[#585450]",children:Q})]})}),(0,s.jsxs)(el.hl,{side:"bottom",align:"end",sideOffset:8,avoidCollisions:!1,className:"".concat(eu," ").concat("menu"===O?"w-[280px]":"cta"===O?"w-[340px]":"w-[320px]"," max-h-[280px] max-w-[calc(100vw-2rem)] overflow-y-auto"),"data-sentry-element":"PopoverContent","data-sentry-source-file":"BrandAdsFilterBar.tsx",children:["menu"===O&&(0,s.jsxs)("div",{className:"p-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{var e,a,s,n;W(null!=(s=null==(e=t.creativeUsageMin)?void 0:e.toString())?s:""),V(null!=(n=null==(a=t.creativeUsageMax)?void 0:a.toString())?n:""),z("creativeUsage")},className:"flex h-10 w-full items-center gap-2 rounded-md px-2 text-left text-[#302e2c] hover:bg-[#f6f5f4]",children:[(0,s.jsx)(x.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"flex-1 text-sm font-medium",children:"Creative usage"}),J&&(0,s.jsx)("span",{className:"rounded-md bg-[#efedeb] px-2 py-0.5 text-[11px] font-semibold text-[#696663]",children:J}),(0,s.jsx)(k.A,{className:"h-3.5 w-3.5 text-[#aaa6a2]"})]}),(0,s.jsx)("div",{className:"my-1 border-t border-[#efedea]"}),(0,s.jsxs)("button",{type:"button",onClick:()=>z("cta"),className:"flex h-10 w-full items-center gap-2 rounded-md px-2 text-left text-[#302e2c] hover:bg-[#f6f5f4]",children:[(0,s.jsx)(en.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"flex-1 text-sm font-medium",children:"CTA"}),t.ctaTypes.length>0&&(0,s.jsx)("span",{className:"rounded-md bg-[#efedeb] px-2 py-0.5 text-[11px] font-semibold text-[#696663]",children:t.ctaTypes.length}),(0,s.jsx)(k.A,{className:"h-3.5 w-3.5 text-[#aaa6a2]"})]})]}),"creativeUsage"===O&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex h-11 items-center gap-1 border-b border-[#eceae7] px-2.5",children:[(0,s.jsx)("button",{type:"button","aria-label":"Back to filters",onClick:()=>z("menu"),className:"flex h-8 w-8 items-center justify-center rounded-lg text-[#77736f] hover:bg-[#f5f4f2]",children:(0,s.jsx)(A.A,{className:"h-4 w-4"})}),(0,s.jsx)("p",{className:"text-[15px] font-semibold text-[#1d1c1b]",children:"Creative usage"})]}),(0,s.jsx)("div",{className:"px-4 py-4",children:(0,s.jsx)(ev,{min:G,max:H,minLabel:"Minimum",maxLabel:"Maximum",onMinChange:W,onMaxChange:V})}),(0,s.jsxs)("div",{className:"flex items-center justify-between border-t border-[#eceae7] bg-[#fcfbfa] px-3.5 py-2.5",children:[(0,s.jsx)("button",{type:"button",className:ep,onClick:()=>{a({...t,creativeUsageMin:null,creativeUsageMax:null}),z("menu")},children:"Clear"}),(0,s.jsx)(v.$,{size:"sm",className:"".concat(ef," !h-8 !rounded-lg"),onClick:()=>{let[e,s]=ey(G,H,1);a({...t,creativeUsageMin:e,creativeUsageMax:s}),U(!1),z("menu")},children:"Apply Filter"})]})]}),"cta"===O&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex h-11 items-center gap-1 border-b border-[#eceae7] px-2.5",children:[(0,s.jsx)("button",{type:"button","aria-label":"Back to filters",onClick:()=>z("menu"),className:"flex h-8 w-8 items-center justify-center rounded-lg text-[#77736f] hover:bg-[#f5f4f2]",children:(0,s.jsx)(A.A,{className:"h-4 w-4"})}),(0,s.jsx)("p",{className:"text-[15px] font-semibold text-[#1d1c1b]",children:"CTA"}),t.ctaTypes.length>0&&(0,s.jsxs)("span",{className:"ml-auto rounded-md bg-[#efedeb] px-2 py-0.5 text-[11px] font-semibold text-[#696663]",children:[t.ctaTypes.length," selected"]})]}),(0,s.jsxs)("div",{className:"p-2.5",children:[(0,s.jsx)(er.p,{value:$,onChange:e=>K(e.target.value),placeholder:"Search CTA types...",className:"mb-2 h-8 rounded-lg border-[#e7e5e1] bg-[#fbfaf9] shadow-none"}),(0,s.jsx)("div",{className:"max-h-[260px] overflow-y-auto pr-1",children:ei.t.filter(e=>
1{let[t,a]=e,s=$.trim().toLowerCase();return!s||t.toLowerCase().includes(s)||a.toLowerCase().includes(s)}).map(e=>{let[a,n]=e,r=t.ctaTypes.includes(a);return(0,s.jsxs)("button",{type:"button",onClick:()=>X("ctaTypes",r?t.ctaTypes.filter(e=>e!==a):[...t.ctaTypes,a]),className:"flex h-9 w-full items-center gap-2.5 rounded-md px-2 text-left hover:bg-[#f6f5f4]",children:[(0,s.jsx)("span",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-[4px] border ".concat(r?"border-[#302e2c] bg-[#302e2c] text-white":"border-[#b8b4af] bg-white"),children:r&&(0,s.jsx)(ea.A,{className:"h-3 w-3"})}),(0,s.jsx)("span",{className:"flex-1 text-sm font-medium text-[#4b4743]",children:n})]},a)})})]}),t.ctaTypes.length>0&&(0,s.jsx)("div",{className:"border-t border-[#eceae7] bg-[#fcfbfa] p-3",children:(0,s.jsxs)("button",{type:"button",className:"".concat(ep," w-full"),onClick:()=>X("ctaTypes",[]),children:["Clear CTA filter (",t.ctaTypes.length,")"]})})]})]})]})]}),(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsxs)("div",{className:"relative min-w-0 flex-1 2xl:w-[260px] 2xl:flex-none",children:[(0,s.jsx)(p.A,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-[#908c89]","data-sentry-element":"Search","data-sentry-source-file":"BrandAdsFilterBar.tsx"}),(0,s.jsx)(er.p,{value:i,onChange:e=>o(e.target.value),placeholder:"Search ads...",className:"".concat("h-10 rounded-xl border-[#e7e5e1] bg-[#fbfaf9] px-3.5 text-sm shadow-none placeholder:text-[#aaa6a2] focus-visible:border-[#a8a29e] focus-visible:ring-2 focus-visible:ring-[#302e2c]/10"," h-9 pl-9 pr-8"),"data-sentry-element":"Input","data-sentry-source-file":"BrandAdsFilterBar.tsx"}),i&&(0,s.jsx)("button",{type:"button",onClick:()=>o(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-[#908c89]",children:(0,s.jsx)(et.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("span",{className:"whitespace-nowrap text-xs text-[#908c89]",children:[l.toLocaleString()," ads"]}),q>0&&(0,s.jsx)("button",{type:"button",onClick:r,className:"h-8 rounded-lg px-2 text-xs font-medium text-[#77736f] hover:bg-[#f5f4f2]",children:"Clear"})]})]}),i.trim().length>0&&i.trim().length<3&&(0,s.jsx)("p",{className:"mt-1.5 text-xs font-medium text-amber-700",children:"Enter at least 3 characters to search."})]})}var eN=a(47432),ew=a(10744),eA=a(24097);function ek(e){let{className:t="h-3.5 w-3.5"}=e;return(0,s.jsxs)("svg",{viewBox:"0 0 16 16",className:t,fill:"none","aria-hidden":"true","data-sentry-element":"svg","data-sentry-component":"CreativeStackIcon","data-sentry-source-file":"BrandDetailPage.tsx",children:[(0,s.jsx)("rect",{x:"3.75",y:"2.25",width:"10",height:"8.5",rx:"1.85",stroke:"currentColor",strokeWidth:"1.15",opacity:"0.5",className:"transition-transform duration-150 group-hover/creative-stack:translate-x-[0.5px] group-hover/creative-stack:-translate-y-[0.5px]","data-sentry-element":"rect","data-sentry-source-file":"BrandDetailPage.tsx"}),(0,s.jsx)("rect",{x:"2.25",y:"5.25",width:"10",height:"8.5",rx:"1.85",stroke:"currentColor",strokeWidth:"1.25",className:"fill-white transition-colors duration-150 group-hover/creative-stack:fill-[#faf9f8]","data-sentry-element":"rect","data-sentry-source-file":"BrandDetailPage.tsx"}),(0,s.jsx)("path",{d:"M4.5 10.85h5.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",opacity:"0.5","data-sentry-element":"path","data-sentry-source-file":"BrandDetailPage.tsx"})]})}function eC(e){let t=null==e?"":String(e);return'"'.concat(t.replace(/"/g,'""'),'"')}async function eS(e){let t=[];for(let a=1;a<=1e3;a+=1){let s=await e(a,10);if(Array.isArray(s))return s;let n=s.items||[];if(t.push(...n),n.length<10)break}return t}function e_(e,t){if(t<=7)return Array.from({length:t},(e,t)=>t+1);let a=[];a.push(1);let s=e<t-2;e>3&&a.push("ellipsis");let n=Math.max(2,e-1),r=Math.min(t-1,e+1);for(let e=n;e<=r;e++)a.includes(e)||a.push(e);return s&&a.push("ellipsis"),a.includes(t)||a.push(t),a}function eM(e){var t;let{brand:a,onBack:A,initialTab:k="overview",initialTimeRange:C="30d"}=e,{permissions:S}=(0,ew.S)(),[J]=(0,eN.y4)(),ee=!(null==S?void 0:S.canExploreAds),[et,ea]=(0,n.use
1State)(k),[es,en]=(0,n.useState)(C),[er,el]=(0,n.useState)(null),[ei,eo]=(0,n.useState)(null),ec=(0,n.useRef)({}),[ed,ex]=(0,n.useState)(1),[em,eu]=(0,n.useState)("ads"),[eh,ep]=(0,n.useState)("desc"),[ef,eg]=(0,n.useState)(1),[eb,ev]=(0,n.useState)("ads"),[ey,eM]=(0,n.useState)("desc"),[eT,eB]=(0,n.useState)(1),[eF,eL]=(0,n.useState)("ads"),[eD,eP]=(0,n.useState)("desc"),[eE,eR]=(0,n.useState)(1),[eI,eU]=(0,n.useState)("ads"),[eO,ez]=(0,n.useState)("desc"),[eG,eW]=(0,n.useState)(!0),[eH,eV]=(0,n.useState)(!0),[e$,eK]=(0,n.useState)(!1),[eX,eQ]=(0,n.useState)(0),[eY,eq]=(0,n.useState)(!1),[eZ,eJ]=(0,n.useState)(!1),[e0,e1]=(0,n.useState)(!1),[e2,e5]=(0,n.useState)(null),[e3,e6]=(0,n.useState)([]),[e4,e8]=(0,n.useState)(0),[e7,e9]=(0,n.useState)(!0),[te,tt]=(0,n.useState)("newest"),[ta,ts]=(0,n.useState)(()=>({...V.G8})),tn=(0,n.useMemo)(()=>JSON.stringify(ta),[ta]),tr=(0,n.useRef)(null),{columnCount:tl,containerRef:ti}=function(){let[e,t]=(0,n.useState)(null),[a,s]=(0,n.useState)(4),r=(0,n.useCallback)(e=>{t(e)},[]);return(0,n.useEffect)(()=>{if(!e)return;let t=t=>{s(Math.max(1,Math.min(6,Math.floor((Math.max(null!=t?t:e.clientWidth,0)+16)/296))))};if(t(),"undefined"==typeof ResizeObserver){let e=()=>t();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}let a=new ResizeObserver(e=>{let[a]=e;t(a.contentRect.width)});return a.observe(e),()=>a.disconnect()},[e]),{columnCount:a,containerRef:r}}(),to=(0,n.useMemo)(()=>(function(e,t){let a=Math.max(1,t),s=Array.from({length:a},()=>[]);return e.forEach((e,t)=>{s[t%a].push(e)}),s})(e3.map((e,t)=>({ad:e,index:t})),tl),[e3,tl]),[tc,td]=(0,n.useState)([]),tx=(0,n.useRef)(null),tm=(0,n.useRef)(null),tu=(0,n.useRef)(0),th=(0,n.useRef)(!1),tp=(0,n.useRef)(null),tf=(0,n.useRef)(null),tg=(0,n.useRef)(null),tb=(0,n.useRef)(null),[tv,ty]=(0,n.useState)([]),[tj,tN]=(0,n.useState)(0),[tw,tA]=(0,n.useState)(1),[tk,tC]=(0,n.useState)(!1),[tS,t_]=(0,n.useState)([]),[tM,tT]=(0,n.useState)(0),[tB,tF]=(0,n.useState)(1),[tL,tD]=(0,n.useState)(null),[tP,tE]=(0,n.useState)(!1),[tR,tI]=(0,n.useState)([]),[tU,tO]=(0,n.useState)(0),[tz,tG]=(0,n.useState)(1),[tW,tH]=(0,n.useState)(!1),[tV,t$]=(0,n.useState)([]),[tK,tX]=(0,n.useState)(0),[tQ,tY]=(0,n.use
1State)(1),tq=(0,n.useRef)(null),tZ=(0,n.useRef)(null),tJ=(0,n.useRef)(null),t0=(0,n.useRef)(null),t1=(0,n.useRef)(null),[t2,t5]=(0,n.useState)(null),[t3,t6]=(0,n.useState)(!1),[t4,t8]=(0,n.useState)(null),[t7,t9]=(0,n.useState)(!1),ae=(0,n.useRef)(0),[at,aa]=(0,n.useState)(!1),[as,an]=(0,n.useState)("generic"),ar=e=>{an(e),aa(!0)};(0,n.useEffect)(()=>{if("overview"!==et)return;let e="7d"===es?7:"90d"===es?90:30*("all"!==es),t=[a.id,e].join(":");if(tf.current===t)return;let s=new AbortController;return eW(!0),(0,V.PY)(a.id,e,s.signal,ee).then(e=>{s.signal.aborted||(e5(e),tf.current=t)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to fetch overview:",e)}).finally(()=>{s.signal.aborted||(tg.current=t,eW(!1))}),()=>s.abort()},[et,a.id,es]),(0,n.useEffect)(()=>{var e;if("overview"!==et)return;let t="7d"===es?7:"90d"===es?90:"all"===es?void 0:30,s=null!=t?t:0,n=[a.id,s].join(":");if(tg.current!==n)return;let r=[a.id,null!=t?t:"all",te,tn].join(":");if(tb.current===r)return;let l=++tu.current,i=new AbortController;return null==(e=tp.current)||e.abort(),tp.current=null,th.current=!1,eV(!0),eK(!1),eq(!1),e6([]),e9(!0),e8(0),(0,V.uT)(a.id,{publicPreview:ee,limit:20,offset:0,dateRange:t,sortBy:te,filters:ta,signal:i.signal}).then(e=>{l===tu.current&&(e6(e.items),e8(e.total),e9(e.hasMore),tb.current=r)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||(console.error("Failed to fetch ads:",e),l!==tu.current||i.signal.aborted||eK(!0))}).finally(()=>{i.signal.aborted||l!==tu.current||eV(!1)}),()=>i.abort()},[et,a.id,es,te,ta,tn,eG,eX]);let al=(0,n.useCallback)(async()=>{if(e$||eH||th.current||eY||!e7)return;th.current=!0,eq(!0);let e=tu.current,t=new AbortController;tp.current=t;try{let s=e3.length,n="7d"===es?7:"90d"===es?90:"all"===es?void 0:30,r=await (0,V.uT)(a.id,{publicPreview:ee,limit:20,offset:s,dateRange:n,sortBy:te,filters:ta,signal:t.signal});if(e!==tu.current)return;r.items.length>0?(e6(e=>[...e,...r.items]),e9(r.hasMore)):e9(!1)}catch(a){if(a instanceof DOMException&&"AbortError"===a.name)return;console.error("Failed to load more ads:",a),e!==tu.current||t.signal.aborted||eK(!0)}finally{tp.current===t&&(tp.current=null,th.current=!1,e===tu.current&&eq(!1))}},[ta,e3.length,te,a.id,e7,eY,es,e$,eH]);(0,n.useEffect)(()=>{if("overview"!==et)return;let e=tx.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&e7&&!eY&&!eH&&al()},{threshold:.1,rootMargin:"100px",root:tm.current});return t.observe(e),()=>{t.disconnect()}},[et,e7,eY,eH,al]),(0,n.useEffect)(()=>{if("creative-tests"!==et)return;let e=a.id;if(tq.current===e)return;let t=!1;return eJ(!0),(0,V.PG)(a.id,ee).then(a=>{t||(td(a),tq.current=e)}).catch(e=>{t||console.error("Failed to fetch creative tests:",e)}).finally(()=>{t||eJ(!1)}),()=>{t=!0}},[et,a.id]),(0,n.useEffect)(()=>{if("landing-pages"!==et)return;let e="7d"===es?7:"90d"===es?90:30*("all"!==es),t=[a.id,e,ed,em,eh].join(":");if(tZ.current===t)return;let s=new AbortController;return e1(!0),(0,V.Ec)(a.id,e,ed,10,em,eh,s.signal,ee).then(e=>{s.signal.aborted||(ty(e.items),tN(e.total||0),tA(e.total_pages||1),tZ.current=t)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to fetch landing pages:",e)}).finally(()=>{s.signal.aborted||e1(!1)}),()=>s.abort()},[et,a.id,es,em,eh,ed]),(0,n.useEffect)(()=>{if("hooks"!==et)return;let e="7d"===es?7:"90d"===es?90:30*("all"!==es),t=[a.id,e,ef,eb,ey].join(":");if(tJ.current===t)return;let s=new AbortController,n=null;tC(!0);let r=async()=>{try{let l=await (0,V.hG)(a.id,e,ef,10,eb,ey,s.signal,ee);if(s.signal.aborted)return;if(l&&"status"in l&&!l.items){let e=l.status;tD(e),"pending"===e||"processing"===e?n=setTimeout(r,1e4):"completed"===e&&(n=setTimeout(r,1e3))}else l&&"items"in l&&(tD("completed"),t_(l.items),tT(l.total||0),tF(l.total_pages||1),tJ.current=t)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;console.error("Failed to fetch hooks:",e),tD("failed")}finally{s.signal.aborted||tC(!1)}};return r(),()=>{s.abort(),n&&clearTimeout(n)}},[et,a.id,es,eb,ey,ef]),(0,n.useEffect)(()=>
1{if("headline"!==et)return;let e="7d"===es?7:"90d"===es?90:30*("all"!==es),t=[a.id,e,eT,eF,eD].join(":");if(t0.current===t)return;let s=new AbortController;return tE(!0),(0,V.mE)(a.id,e,eT,10,eF,eD,s.signal,ee).then(e=>{s.signal.aborted||(tI(e.items),tO(e.total||0),tG(e.total_pages||1),t0.current=t)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to fetch headlines:",e)}).finally(()=>{s.signal.aborted||tE(!1)}),()=>s.abort()},[et,a.id,es,eF,eD,eT]),(0,n.useEffect)(()=>{if("ad-copy"!==et)return;let e="7d"===es?7:"90d"===es?90:30*("all"!==es),t=[a.id,e,eE,eI,eO].join(":");if(t1.current===t)return;let s=new AbortController;return tH(!0),(0,V.Xq)(a.id,e,eE,10,eI,eO,s.signal,ee).then(e=>{s.signal.aborted||(t$(e.items),tX(e.total||0),tY(e.total_pages||1),t1.current=t)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to fetch ad copies:",e)}).finally(()=>{s.signal.aborted||tH(!1)}),()=>s.abort()},[et,a.id,es,eI,eO,eE]);let ai=e2?(0,V.LV)(e2):{video:{count:0,percentage:0},image:{count:0,percentage:0},carousel:{count:0,percentage:0}},ao=null!=(t=null==e2?void 0:e2.active_ads)?t:null,ac=(null==e2?void 0:e2.total_ads)||0,ad=((null==e2?void 0:e2.landing_pages)||[]).slice(0,6).map((e,t)=>({id:t+1,url:e.path,fullUrl:e.full_url,ads:e.count,percentage:e.percentage})),ax=(null==e2?void 0:e2.timeline)||[],am=(0,n.useMemo)(()=>{let e=ax.length;if("all"===es&&e>100){if(0===ax.length)return[];let e=[],t=[],a=new Date(ax[0].rawDate);return ax.forEach((s,n)=>{let r=new Date(s.rawDate);if(7>Math.floor((r.getTime()-a.getTime())/864e5))t.push(s);else{if(t.length>0){let a=Math.round(t.reduce((e,t)=>e+t.ads,0)/t.length);e.push({...t[Math.floor(t.length/2)],ads:a})}t=[s],a=r}if(n===ax.length-1&&t.length>0){let a=Math.round(t.reduce((e,t)=>e+t.ads,0)/t.length);e.push({...t[Math.floor(t.length/2)],ads:a})}}),e}if("90d"===es&&e>60){if(0===ax.length)return[];let e=[];for(let t=0;t<ax.length;t+=3){let a=ax.slice(t,Math.min(t+3,ax.length)),s=Math.round(a.reduce((e,t)=>e+t.ads,0)/a.length);e.push({...a[Math.floor(a.length/2)],ads:s})}return e}return ax},[ax,es]),au=(e,t)=>{ts({...V.G8,search:t,searchMode:"exact",associationType:e,associationValue:t}),en("all"),ea("overview"),window.setTimeout(()=>{let e=tm.current,t=tr.current;e&&t&&e.scrollTo({top:Math.max(0,t.offsetTop-16),behavior:"smooth"})},100)},ah=e=>{navigator.clipboard.writeText(e),el(e),setTimeout(()=>el(null),2e3)},ap=async e=>{let t=++ae.current;t8(null),t9(!0),t6(!0);try{let a=await e();if(ae.current!==t)return;t8(a)}catch(e){if(ae.current!==t)return;console.error("Failed to fetch sample ad:",e),t6(!1),b.Ay.error("Failed to load ad details. Please try again.")}finally{ae.current===t&&t9(!1)}},af=()=>{switch(es){case"7d":return"Last 7 days";case"30d":default:return"Last 30 days";case"90d":return"Last 90 days";case"all":return"All time"}},ag=async e=>{if(t2)return;t5(e);let t=(()=>{switch(es){case"7d":return 7;case"30d":default:return 30;case"90d":return 90;case"all":return 0}})(),s="all"===es?"all-time":es,n=a.name.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff]+/g,"-").replace(/^-+|-+$/g,"")||"brand",r=function(){let e=new Date,t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(a,"-").concat(s)}();try{let c,d,x;if("landing-pages"===e){let e=await eS((e,s)=>(0,V.Ec)(a.id,t,e,s,em,eh,void 0,ee));c=["Landing Page URL","Active Ads","Total Ads","Percentage","Longest Running (Days)"],d=e.map(e=>[e.fullUrl||e.url,e.activeAds,e.totalAds,e.percentage,e.longestRunning]),x="".concat(n,"-landing-pages-").concat(s,"-").concat(r,".csv")}else if("ad-copy"===e){let e=await eS((e,s)=>(0,V.Xq)(a.id,t,e,s,eI,eO,void 0,ee));c=["Ad Copy","Active Ads","Total Ads","Longest Running (Days)","Status","Start Date","End Date"],d=e.map(e=>[e.copyText,e.activeAds,e.totalAds,e.longestRunning,e.activeAds>0?"Active":"Inactive",e.startDate,e.endDate]),x="".concat(n,"-ad-copy-").concat(s,"-").concat(r,".csv")}else{let e=await eS((e,s)=>(0,V.mE)(a.id,t,e,s,eF,eD,void 0,ee));c=["Headline","Active Ads","Total Ads","Longest Running (Days)","Status","Start Date","End Date"],d=e.map(e=>[e.headline,e.activeAds,e.totalAds,e.longestRunning,e.activeAds>
10?"Active":"Inactive",e.startDate,e.endDate]),x="".concat(n,"-headlines-").concat(s,"-").concat(r,".csv")}if(0===d.length)return void(0,b.Ay)("No data is available for the selected timeframe.");var l=x,i=c,o=d;let m=new Blob(["\uFEFF",[i,...o].map(e=>e.map(eC).join(",")).join("\r\n")],{type:"text/csv;charset=utf-8"}),u=URL.createObjectURL(m),h=document.createElement("a");h.href=u,h.download=l,h.style.display="none",document.body.appendChild(h),h.click(),h.remove(),URL.revokeObjectURL(u),b.Ay.success("".concat(d.length.toLocaleString()," rows exported"))}catch(t){console.error("Failed to export ".concat(e,":"),t),b.Ay.error("Export failed. Please try again.")}finally{t5(null)}};return(0,s.jsxs)("div",{className:"flex flex-col h-screen bg-white","data-sentry-component":"BrandDetailPage","data-sentry-source-file":"BrandDetailPage.tsx",children:[(0,s.jsxs)("main",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)("header",{className:"flex-shrink-0 bg-white border-b border-gray-200",children:(0,s.jsx)("div",{className:"px-6 py-5",children:(0,s.jsx)("div",{className:"flex items-center justify-between",children:(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(v.$,{variant:"ghost",size:"sm",onClick:A,className:"gap-2 -ml-2","data-sentry-element":"Button","data-sentry-source-file":"BrandDetailPage.tsx",children:(0,s.jsx)(r.A,{className:"w-4 h-4","data-sentry-element":"ArrowLeft","data-sentry-source-file":"BrandDetailPage.tsx"})}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-lg bg-white border border-gray-200 flex items-center justify-center overflow-hidden p-1.5",children:(0,s.jsx)(y.o,{src:a.logo,alt:a.name,className:"w-full h-full object-contain","data-sentry-element":"ImageWithFallback","data-sentry-source-file":"BrandDetailPage.tsx"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"font-semibold text-gray-900",children:a.name}),a.lastUpdated&&(0,s.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:["Updated ",a.lastUpdated]})]})]})]})})})}),(0,s.jsxs)(j.tU,{value:et,onValueChange:ea,className:"flex-1 flex flex-col min-h-0","data-sentry-element":"Tabs","data-sentry-source-file":"BrandDetailPage.tsx",children:[(0,s.jsxs)(j.j7,{className:"flex-shrink-0 w-full justify-start bg-transparent h-auto p-0 border-0 px-6 border-b border-gray-200","data-sentry-element":"TabsList","data-sentry-source-file":"BrandDetailPage.tsx",children:[(0,s.jsx)(j.Xi,{value:"overview",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-violet-600 data-[state=active]:bg-transparent data-[state=active]:text-gray-900 text-gray-600 px-0 py-3 mr-8 font-medium","data-sentry-element":"TabsTrigger","data-sentry-source-file":"BrandDetailPage.tsx",children:"Overview"}),(0,s.jsx)(j.Xi,{value:"creative-tests",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-violet-600 data-[state=active]:bg-transparent data-[state=active]:text-gray-900 text-gray-600 px-0 py-3 mr-8 font-medium","data-sentry-element":"TabsTrigger","data-sentry-source-file":"BrandDetailPage.tsx",children:"Creative Tests"}),(0,s.jsx)(j.Xi,{value:"landing-pages",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-violet-600 data-[state=active]:bg-transparent data-[state=active]:text-gray-900 text-gray-600 px-0 py-3 mr-8 font-medium","data-sentry-element":"TabsTrigger","data-sentry-source-file":"BrandDetailPage.tsx",children:"Landing Pages"}),(0,s.jsx)(j.Xi,{value:"hooks",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-violet-600 data-[state=active]:bg-transparent data-[state=active]:text-gray-900 text-gray-600 px-0 py-3 mr-8 font-medium","data-sentry-element":"TabsTrigger","data-sentry-source-file":"BrandDetailPage.tsx",children:"Hooks"}),(0,s.jsx)(j.Xi,{value:"ad-copy",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-violet-600 data-[state=active]:bg-transparent data-[state=active]:text-gray-900 text-gray-600 px-0 py-3 mr-8 font-medium","data-sentry-element":"TabsTrigger","data-sentry-source-file":"BrandDetailPage.tsx",children:"Ad Copy"}),(0,s.jsx)(j.Xi,{value:"headline",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-violet-600 data-[state=active]:bg-transparent data-[state=active]:text-gray-900 text-gray-600 px-0 py-3 mr-8 font-medium","data-sentry-element":"TabsTrigger","data-sentry-source-file":"BrandDetailPage.tsx",children:"Headline"})]}),"overview"===et&&eG?(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,s.jsx)(l.A,{className:"w-8 h-8 animate-spin text-violet-600"}),(0,s.jsx)("p",{className:"text-gray-500",children:"Loading brand data..."})]})}):(0,s.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,s.jsx)(j.av,{value:"overview",className:"m-0 flex-1 min-h-0 overflow-y-auto",ref:tm,children:(0,s.jsx)("div",{className:"px-6 py-6 bg-[#FAFAFA]",children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("div",{children:(0,s.jsxs)("p",{className:"text-gray-600",children:[(0,s.jsxs)("span",{className:"font-semibold text-gray-900",children:[(null==e2?void 0:e2.new_ads)||0," creatives"]})," started in ",af().toLowerCase(),(0,s.jsx)("span",{className:"text-green-600",children:null==ao?" \xb7 Active count not checked":" \xb7 ".concat(ao," currently active on Meta")})]})}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)(v.$,{variant:"outline",size:"sm",className:"gap-2",children:[af(),(0,s.jsx)(i.A,{className:"w-4 h-4"})]})}),(0,s.jsxs)(N.SQ,{align:"end",children:[(0,s.jsx)(N._2,{onClick:()=>en("7d"),children:"Last 7 days"}),(0,s.jsx)(N._2,{onClick:()=>en("30d"),children:"Last 30 days"}),(0,s.jsx)(N._2,{onClick:()=>en("90d"),children:"Last 90 days"}),(0,s.jsx)(N._2,{onClick:()=>en("all"),children:"All time"})]})]})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,s.jsxs)("div",{className:"bg-white border border-gray-100 rounded-xl p-5 overflow-visible",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 mb-4",children:[(0,s.jsx)(o.A,{className:"w-4 h-4 text-gray-400"}),(0,s.jsx)("h3",{className:"text-base text-gray-600",children:"Available Creatives - Media Mix"})]}),(0,s.jsxs)("div",{className:"relative flex justify-center items-center mb-6 overflow-visible",style:{height:"120px"},children:[(0,s.jsxs)("div",{className:"absolute left-1/2 transform -translate-x-1/2 text-center",style:{bottom:"-5px"},children:[(0,s.jsx)("div",{className:"text-5xl font-bold text-gray-900",children:ac}),(0,s.jsx)("div",{className:"text-sm text-gray-400 mt-1",children:"Creatives"})]}),(0,s.jsxs)("svg",{width:"240",height:"120",viewBox:"0 0 240 120",className:"absolute top-0",children:[(0,s.jsxs)("defs",{children:[(0,s.jsxs)("linearGradient",{id:"videoGradient",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:"#8b5cf6",stopOpacity:"1"}),(0,s.jsx)("stop",{offset:"100%",stopColor:"#a78bfa",stopOpacity:"1"})]}),(0,s.jsxs)("linearGradient",{id:"imageGradient",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:"#d8b4fe",stopOpacity:"1"}),(0,s.jsx)("stop",{offset:"100%",stopColor:"#e9d5ff",stopOpacity:"1"})]})]}),(0,s.jsx)("path",{d:"M 20 120 A 100 100 0 0 1 220 120",fill:"none",stroke:"#f3f4f6",strokeWidth:"20",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M 20 120 A 100 100 0 0 1 135 22",fill:"none",stroke:"url
1(#videoGradient)",strokeWidth:"20",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M 135 22 A 100 100 0 0 1 220 120",fill:"none",stroke:"url(#imageGradient)",strokeWidth:"20",strokeLinecap:"round"})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-violet-500"}),(0,s.jsx)("span",{className:"text-sm text-gray-500",children:"Videos"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-6",children:[(0,s.jsx)("span",{className:"text-sm text-gray-900 font-semibold",children:ai.video.count}),(0,s.jsxs)("span",{className:"text-sm text-gray-900 font-bold min-w-[45px] text-right",children:[ai.video.percentage,"%"]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-violet-300"}),(0,s.jsx)("span",{className:"text-sm text-gray-500",children:"Images"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-6",children:[(0,s.jsx)("span",{className:"text-sm text-gray-900 font-semibold",children:ai.image.count}),(0,s.jsxs)("span",{className:"text-sm text-gray-900 font-bold min-w-[45px] text-right",children:[ai.image.percentage,"%"]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-gray-300"}),(0,s.jsx)("span",{className:"text-sm text-gray-500",children:"Carousel"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-6",children:[(0,s.jsx)("span",{className:"text-sm text-gray-900 font-semibold",children:ai.carousel.count}),(0,s.jsxs)("span",{className:"text-sm text-gray-900 font-bold min-w-[45px] text-right",children:[ai.carousel.percentage,"%"]})]})]})]})]}),(0,s.jsxs)("div",{className:"bg-white border border-gray-100 rounded-xl p-5 flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 mb-6",children:[(0,s.jsx)(c.A,{className:"w-4 h-4 text-gray-400"}),(0,s.jsx)("h3",{className:"text-base text-gray-600",children:"Landing Pages"})]}),(0,s.jsx)("div",{className:"space-y-2 flex-1",children:ad.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-3 py-2 group",children:[(0,s.jsx)("a",{href:e.fullUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-gray-600 hover:text-violet-600 truncate flex-1 min-w-0 transition-colors",title:e.url,children:e.url}),(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-shrink-0",children:[(0,s.jsx)("span",{className:"text-sm text-gray-900 font-semibold",children:e.ads}),(0,s.jsxs)("span",{className:"text-sm text-gray-400 min-w-[38px] text-right",children:[e.percentage,"%"]})]})]},t))})]}),(0,s.jsxs)("div",{className:"bg-white border border-gray-100 rounded-xl p-5 flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 mb-6",children:[(0,s.jsx)(d.A,{className:"w-4 h-4 text-gray-400"}),(0,s.jsx)("h3",{className:"text-base text-gray-600",children:"Timeline"}),am.length>0&&"all"===es&&(0,s.jsxs)("span",{className:"text-xs text-gray-400",children:["(",new Date(am[0].rawDate).toLocaleDateString("en-US",{month:"short",year:"numeric"})," - ",new Date(am[am.length-1].rawDate).toLocaleDateString("en-US",{month:"short",year:"numeric"}),")"]})]}),(0,s.jsx)("div",{className:"flex-1",children:(0,s.jsx)(I.u,{width:"100%",height:"100%",children:(0,s.jsxs)(U.Q,{data:am,children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:"timelineGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"5%",stopColor:"#8b5cf6",stopOpacity:.3}),(0,s.jsx)("stop",{offset:"95%",stopColor:"#8b5cf6",stopOpacity:.05})]})}),(0,s.jsx)(O.d,{strokeDasharray:"3 3",stroke:"#f3f4f6",vertical:!1}),(0,s.jsx)(z.W,{dataKey:"rawDate",tick:{fontSize:11,fill:"#9ca3af"},stroke:"#f3f4f6",axisLine:!1,tickLine:!1,tickFormatter:e=>{let t=new Date(e);
1return"7d"===es?t.toLocaleString("en-US",{weekday:"short"}):"all"===es?t.toLocaleString("en-US",{month:"short",year:"2-digit"}):t.toLocaleString("en-US",{month:"short",day:"numeric"})},interval:(()=>{let e=am.length;return"7d"===es||e<=8?0:Math.ceil(e/8)-1})(),minTickGap:5}),(0,s.jsx)(G.h,{tick:{fontSize:11,fill:"#9ca3af"},stroke:"#f3f4f6",axisLine:!1,tickLine:!1}),(0,s.jsx)(W.m,{contentStyle:{backgroundColor:"white",border:"1px solid #f3f4f6",borderRadius:"8px",fontSize:"12px",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"},labelFormatter:e=>new Date(e).toLocaleString("en-US",{weekday:"long",month:"short",day:"numeric"})}),(0,s.jsx)(H.Gk,{type:"monotone",dataKey:"ads",stroke:"#8b5cf6",strokeWidth:2,fill:"url(#timelineGradient)",dot:{fill:"#8b5cf6",r:3,strokeWidth:0},activeDot:{r:5,fill:"#8b5cf6"}})]})})})]})]}),(0,s.jsxs)("div",{ref:e=>{tr.current=e,ti(e)},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("h3",{className:"text-base font-semibold",children:["Available Creatives ",eH||e$?"":"(".concat(e4,")")]}),(0,s.jsx)(Z.v,{value:te,onValueChange:tt,triggerClassName:"border-[#e7e5e1] bg-white hover:border-[#d8d5d1]"})]}),(0,s.jsx)("div",{className:"mb-4",children:(0,s.jsx)(ej,{filters:ta,onChange:ts,onClear:()=>ts({...V.G8}),resultCount:e4})}),e$&&(0,s.jsxs)("div",{role:"alert",className:"py-6 text-center text-sm text-gray-500",children:["Unable to load ads. ",(0,s.jsx)("button",{type:"button",className:"underline",onClick:()=>{tb.current=null,eQ(e=>e+1)},children:"Retry"})]}),eH?(0,s.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,s.jsx)(l.A,{className:"w-6 h-6 animate-spin text-violet-600"}),(0,s.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading ads..."})]}):(0,s.jsx)("div",{className:"grid items-start gap-4",style:{gridTemplateColumns:"repeat(".concat(tl,", minmax(0, 1fr))")},children:to.map((e,t)=>(0,s.jsx)("div",{className:"flex min-w-0 flex-col gap-4",children:e.map(e=>{var t,n,r;let{ad:l,index:i}=e,o="video"===l.media_type,d=l.title||"No title available",f=l.cta_text,g=function(e){if(!e)return"";try{let t=/^https?:\/\//i.test(e)?e:"https://".concat(e),a=new URL(t);return"".concat(a.hostname).concat("/"===a.pathname?"":a.pathname).replace(/^www\./,"")}catch(t){return e.replace(/^https?:\/\//i,"").replace(/^www\./,"")}}(l.link_url),v="carousel"===l.media_type?1:"image"===l.media_type?.8:9/16,j=null!=(t=ec.current[l.id])?t:v,w=l.media_url||l.fb_cdn_media_url,A=l.thumbnail_url||l.media_url||l.fb_cdn_thumb_url||l.fb_cdn_media_url,k=l.fb_cdn_thumb_url||l.fb_cdn_media_url,C=function(e){if(null==e||!Number.isFinite(e)||e<=0)return null;let t=Math.round(e),a=Math.floor(t/60);return"".concat(a,":").concat(String(t%60).padStart(2,"0"))}(l.video_length),S=null!=(n=l.creative_usage_count)?n:0,_=()=>{t8(l),t6(!0)};return(0,s.jsxs)("div",{className:"group w-full cursor-pointer overflow-visible rounded-xl bg-white text-[#1d1c1b] shadow-[0_1px_2px_rgba(0,0,0,0.05)] transition-shadow duration-100 hover:shadow-[0_1px_3px_rgba(0,0,0,0.06)] [border:0.5px_solid_rgba(234,232,230,0.7)]",role:"button",tabIndex:0,onClick:_,onKeyDown:e=>{e.target===e.currentTarget&&("Enter"===e.key||" "===e.key)&&(e.preventDefault(),_())},children:[(0,s.jsx)("div",{className:"pl-3 pr-2 pt-3 pb-0",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2",children:[(0,s.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[#eae8e6]/80 bg-white",children:(0,s.jsx)(y.o,{src:l.brand_logo||a.logo,alt:l.brand||a.name,className:"h-full w-full object-contain p-0.5",loading:i<5?"eager":"lazy"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 pt-px",children:[(0,s.jsx)("h3",{className:"truncate text-sm font-medium leading-[18px] text-[#1d1c1b]",children:l.brand||a.name}),(0,s.jsx)("div",{className:"flex min-w-0 items-center gap-1 text-[13px] font-medium leading-[17px]",children:null!=l.active_ads_count&&l.active_ads_count>0?(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full ".concat(l.is_active?"bg-[#16c766]":"bg-[#b7b3af]")}),(0,s.jsx)("span",{className:"shrink-0 font-semibold ".concat(l.is_active?"text-[#08a83f]":"text-[#908c89]"),children:null==(r=l.active_ads_count)?"â":new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(r)}),(0,s.jsx)("span",{className:"truncate font-normal text-[#908c89]",children:"active ads"})]}):(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-1 font-normal text-[#908c89]",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full ".concat(l.is_active?"bg-[#16c766]":"bg-[#b7b3af]")}),(0,s.jsx)("span",{className:"truncate",children:l.is_active?"Active":"Inactive"})]})})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex min-w-[24px] flex-col items-end text-[13px] leading-4 text-[#696663]",children:[(0,s.jsx)("div",{className:"flex h-4 items-center gap-1 font-medium",children:(0,s.jsxs)("span",{className:"group/creative-usage relative flex items-center gap-1 outline-none",tabIndex:0,"aria-describedby":"brand-creative-usage-tooltip-".concat(l.id),children:[(0,s.jsx)(x.A,{className:"h-3.5 w-3.5",
1strokeWidth:1.8}),(0,s.jsx)("span",{children:null!=S&&Number.isFinite(S)?S>=1e6?"".concat((S/1e6).toFixed(S>=1e7?0:1),"M"):S>=1e3?"".concat((S/1e3).toFixed(S>=1e4?0:1),"K"):Math.round(S).toLocaleString():"â"}),(0,s.jsxs)("span",{id:"brand-creative-usage-tooltip-".concat(l.id),role:"tooltip",className:"pointer-events-none invisible absolute bottom-full right-0 z-50 mb-2 w-max max-w-[220px] translate-y-1 rounded-lg bg-[#1d1c1b] px-3 py-2 text-left opacity-0 shadow-[0_6px_20px_rgba(0,0,0,0.18)] transition-all duration-150 group-hover/creative-usage:visible group-hover/creative-usage:translate-y-0 group-hover/creative-usage:opacity-100 group-focus-visible/creative-usage:visible group-focus-visible/creative-usage:translate-y-0 group-focus-visible/creative-usage:opacity-100",children:[(0,s.jsx)("span",{className:"block text-xs font-semibold leading-4 text-white",children:"Creative usage"}),(0,s.jsx)("span",{className:"mt-0.5 block whitespace-nowrap text-[11px] font-normal leading-4 text-white/70",children:1===S?"1 ad uses this creative and text":"".concat(S," ads use this creative and text")}),(0,s.jsx)("span",{className:"absolute -bottom-1 right-3 h-2 w-2 rotate-45 bg-[#1d1c1b]"})]})]})}),null!=l.runtime_days&&(0,s.jsxs)("span",{className:"flex items-center gap-1 font-medium text-[#696663]",title:"".concat(l.start_date||"Unknown"," - ").concat(l.is_active?"Present":l.end_date||"Ended"),children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full ".concat(l.is_active?"bg-[#16c766]":"bg-[#b7b3af]")}),l.runtime_days,"d"]})]}),(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)("button",{type:"button","aria-label":"More actions",className:"group/creative-stack relative h-7 w-7 shrink-0 rounded-[9px] bg-transparent text-[#827e7a] shadow-[0_0.5px_2px_rgba(0,0,0,0.055)] transition-all duration-150 hover:text-[#4f4b47] hover:shadow-[0_1.5px_4px_rgba(0,0,0,0.07)] active:scale-[0.97] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1d1c1b]/10",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("span",{className:"absolute inset-0 rounded-[9px] border border-[#e7e4e1] transition-colors duration-150 group-hover/creative-stack:border-[#d8d4d0]"}),(0,s.jsx)("span",{className:"absolute inset-px flex items-center justify-center rounded-[8px] bg-white transition-colors duration-150 group-hover/creative-stack:bg-[#faf9f8]",children:(0,s.jsx)(ek,{})})]})}),(0,s.jsxs)(N.SQ,{align:"end",alignOffset:-4,sideOffset:8,className:"w-[172px] rounded-[14px] border-[#ebe8e5] bg-white p-1.5 text-[#24211f] shadow-[0_2px_8px_rgba(20,18,16,0.05),0_18px_45px_rgba(20,18,16,0.11)] ring-1 ring-black/[0.025]",children:[(0,s.jsxs)(N._2,{className:"h-9 cursor-pointer gap-2.5 rounded-[9px] px-2.5 py-0 text-[13px] font-medium text-[#36322f] focus:bg-[#f6f4f2] focus:text-[#1f1c1a]",onClick:e=>{e.stopPropagation(),_()},children:[(0,s.jsx)(m.A,{className:"h-4 w-4 text-[#817c77]",strokeWidth:1.6}),"View ad details"]}),(0,s.jsxs)(N._2,{className:"h-9 cursor-pointer gap-2.5 rounded-[9px] px-2.5 py-0 text-[13px] font-medium text-[#36322f] focus:bg-[#f6f4f2] focus:text-[#1f1c1a]",onClick:e=>{e.stopPropagation();let t=w||A;t?window.open(t,"_blank","noopener,noreferrer"):b.Ay.error("No media available")},children:[(0,s.jsx)(u.A,{className:"h-4 w-4 text-[#817c77]",strokeWidth:1.6}),"Download media"]})]})]})]})]})}),null!=l.eu_total_reach&&l.eu_total_reach>0&&(0,s.jsx)("div",{className:"px-2 pt-2",children:(0,s.jsx)(K.Pf,{data:(0,X.L_)(l),cpm:J,startDate:l.start_date,endDate:l.end_date})}),(0,s.jsxs)("div",{className:"relative mx-1 mt-2 shrink-0 cursor-pointer overflow-hidden rounded-xl bg-[#f6f5f4]",style:{aspectRatio:"".concat(j)},onClick:e=>{e.stopPropagation(),ei!==l.id&&_()},children:[ei===l.id&&o&&w?(0,s.jsx)("video",{src:w,className:"h-full w-full object-contain",autoPlay:!0,controls:!0,playsInline:!0,onClick:e=>e.stopPropagation(),onEnded:()=>eo(null)}):A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute inset-0 animate-pulse bg-[#f6f5f4]","aria-hidden":"true"}),(0,s.jsx)(y.o,{src:A,fallbackSrc:k,alt:l.title||"".concat(l.brand||a.name," ad creative"),className:"relative z-10 h-full w-full object-contain",loading:i<5?"eager":"lazy",decoding:"async",onLoad:e=>{let t=e.currentTarget.previousElementSibling;t instanceof HTMLElement&&t.classList.add("hidden");
1let a=function(e){let{naturalWidth:t,naturalHeight:a}=e;return t<=0||a<=0?null:Math.min(1.2,Math.max(.56,t/a))}(e.currentTarget);if(null!=a){var s;ec.current[l.id]=a,null==(s=e.currentTarget.parentElement)||s.style.setProperty("aspect-ratio",String(a))}}})]}):(0,s.jsx)("div",{className:"flex h-full w-full items-center justify-center text-sm text-[#908c89]",children:"No media preview"}),C&&o&&ei!==l.id&&(0,s.jsx)("div",{className:"absolute bottom-2 right-2 z-20 rounded bg-black/80 px-1.5 py-0.5 text-xs leading-4 text-white",children:C}),o&&ei!==l.id&&w&&(0,s.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:e=>{e.stopPropagation(),eo(l.id)},children:(0,s.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-xl bg-black/55 text-white shadow-[0_2px_8px_rgba(0,0,0,0.18)] backdrop-blur-sm transition-colors hover:bg-black/70",children:(0,s.jsx)(h.A,{className:"ml-0.5 h-6 w-6",fill:"currentColor"})})})]}),l.primary_text&&!l.primary_text.includes("{{")&&(0,s.jsx)("div",{className:"px-3 pt-3 pb-1",children:(0,s.jsx)(q.n,{previewText:l.primary_text})}),(0,s.jsx)("div",{className:"cursor-pointer px-1 pt-2",children:(0,s.jsxs)("div",{className:"space-y-2 rounded-lg bg-[#fafaf9] px-3 py-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium leading-5 text-[#302e2c]",children:d}),f&&(0,s.jsx)("button",{type:"button",className:"ml-2 inline-flex h-6 shrink-0 items-center justify-center rounded-md px-2 text-sm font-medium leading-5 text-[#696663] transition-colors hover:bg-[#f1efed] hover:text-[#302e2c]",onClick:e=>{e.stopPropagation(),l.link_url&&window.open(l.link_url,"_blank","noopener,noreferrer")},children:f})]}),l.link_url&&g&&(0,s.jsxs)("button",{type:"button",className:"-mx-1.5 flex w-[calc(100%+12px)] items-center gap-1.5 rounded-md px-1.5 py-1 text-left transition-colors hover:bg-[#f1efed]",onClick:e=>{e.stopPropagation(),window.open(l.link_url,"_blank","noopener,noreferrer")},children:[(0,s.jsx)(p.A,{className:"h-3.5 w-3.5 shrink-0 text-[#908c89]"}),(0,s.jsx)("span",{className:"truncate text-sm font-medium leading-5 text-[#696663]",children:g}),(0,s.jsx)(c.A,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-[#908c89]"})]})]})}),(0,s.jsx)(Y.c,{onAccessDenied:ee?()=>ar("save"):void 0,adData:{external_id:l.ad_archive_id,brand:l.brand||a.name,image:A||void 0,description:l.primary_text||void 0,media_type:l.media_type,ad_data:{...l,_source:"brand-spy"}}})]},l.id)})},t))}),!e$&&!eH&&e7&&(0,s.jsx)("div",{ref:tx,className:"flex justify-center mt-6 py-8",children:eY&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-gray-500",children:[(0,s.jsx)(l.A,{className:"w-5 h-5 animate-spin"}),(0,s.jsx)("span",{children:"Loading more ads..."})]})}),!eH&&!e7&&e3.length>0&&(0,s.jsxs)("div",{className:"text-center mt-6 text-gray-500 text-sm",children:["All ",e4," available creatives loaded"]})]})]})})}),(0,s.jsx)(j.av,{value:"creative-tests",className:"m-0 flex-1 min-h-0 overflow-y-auto",children:(0,s.jsx)("div",{className:"px-6 py-6 bg-[#FAFAFA]",children:eZ?(0,s.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,s.jsx)(l.A,{className:"w-6 h-6 animate-spin text-violet-600"}),(0,s.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading creative tests..."})]}):(0,s.jsx)("div",{className:"space-y-3",children:(0,s.jsx)(P.nD,{type:"multiple",className:"space-y-3",children:tc.map((e,t)=>(0,s.jsxs)(P.As,{value:"item-".concat(t),className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[(0,s.jsx)(P.$m,{className:"px-5 py-4 hover:no-underline hover:bg-gray-50",children:(0,s.jsxs)("div",{className:"flex items-center justify-between w-full pr-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(e.activeAds>0?"bg-green-500":"bg-gray-300")}),(0,s.jsx)("span",{className:"text-sm font-medium text-gray-900",children:e.date})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)(w.E,{variant:"outline",className:"text-xs font-medium ".concat(e.activeAds>0?"bg-green-50 text-green-700 border-green-200":"bg-gray-50 text-gray-500 border-gray-200"),children:[e.activeAds," / ",e.totalAds," Ads Running"]}),e.hasWinner&&(0,s.jsxs)(w.E,{className:"bg-amber-50 text-amber-700 border-amber-200 text-xs font-medium flex items-center gap-1",children:[(0,s.jsx)(f.A,{className:"w-3 h-3"}),"Winner Identified"]})]})]})}),(0,s.jsx)(P.ub,{className:"px-5 pb-4 pt-2",children:(0,s.jsx)("div",{className:"space-y-2",children:e.ads.map(e=>{var t;let a=Math.min((null!=(t=e.days)?t:0)/30*100,100);return(0,s.jsxs)("div",{className:"flex items-center gap-3 py-2.5 px-3 rounded-lg transition-colors ".concat(e.isWinner?"bg-green-50":"hover:bg-gray-50"),children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded overflow-hidden flex-shrink-0 bg-gray-100",children:(0,s.jsx)("img",{src:e.image,alt:"Ad ".concat(e.id),className:"w-full h-full object-cover"})}),(0,s.jsx)("div",{className:"flex-shrink-0",children:"video"===e.type?(0,s.jsx)(o.A,{className:"w-4 h-4 text-gray-400"}):(0,s.jsx)(g.A,{className:"w-4 h-4 text-gray-400"})}),(0,s.jsx)("div",{className:"flex-shrink-0 min-w-[60px]",children:(0,s.jsx)("span",{className:"text-sm ".concat(e.isWinner?"font-semibold text-green-700":"text-gray-700"),children:null==e.days?"Duration unknown":"".concat(e.days," ").concat(1===e.days?"day":"days")})}
1),e.isWinner&&(0,s.jsxs)(w.E,{className:"flex-shrink-0 gap-1 border border-amber-200 bg-amber-50 text-xs font-medium text-amber-700",children:[(0,s.jsx)(f.A,{className:"h-3 w-3"}),"Winner"]}),e.isActive?(0,s.jsx)("div",{className:"flex-1 relative h-8 bg-gradient-to-r from-green-100 via-green-200 to-green-300 rounded overflow-hidden",children:(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-green-400 via-green-500 to-green-600",style:{width:"".concat(a,"%"),backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,.1) 10px, rgba(255,255,255,.1) 20px)"}})}):(0,s.jsx)("div",{className:"flex-1 relative h-8 bg-gray-100 rounded overflow-hidden",children:(0,s.jsx)("div",{className:"absolute inset-0 bg-gray-300",style:{width:"".concat(a,"%"),backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,.1) 10px, rgba(255,255,255,.1) 20px)"}})}),(0,s.jsxs)(v.$,{variant:"outline",size:"sm",className:"flex-shrink-0 text-xs h-8 px-3 gap-1.5 border-violet-200 text-violet-600 hover:bg-violet-50",onClick:()=>{ap(()=>(0,V.IO)(e.id,ee))},children:[(0,s.jsx)(c.A,{className:"w-3.5 h-3.5"}),"Ad Details"]})]},e.id)})})})]},t))})})})}),(0,s.jsx)(j.av,{value:"landing-pages",className:"m-0 flex-1 min-h-0 overflow-y-auto",children:(0,s.jsx)("div",{className:"px-6 py-6 bg-[#FAFAFA]",children:e0?(0,s.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,s.jsx)(l.A,{className:"w-6 h-6 animate-spin text-violet-600"}),(0,s.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading landing pages..."})]}):(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsx)($.OX,{title:"Landing pages",description:"Landing pages for ads that were live in selected timeframe",controls:(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)(v.$,{variant:"outline",size:"sm",className:"gap-2 bg-white",children:[af(),(0,s.jsx)(i.A,{className:"w-4 h-4"})]})}),(0,s.jsxs)(N.SQ,{align:"start",children:[(0,s.jsx)(N._2,{onClick:()=>en("7d"),children:"Last 7 days"}),(0,s.jsx)(N._2,{onClick:()=>en("30d"),children:"Last 30 days"}),(0,s.jsx)(N._2,{onClick:()=>en("90d"),children:"Last 90 days"}),(0,s.jsx)(N._2,{onClick:()=>en("all"),children:"All time"})]})]}),actions:(0,s.jsx)($.$z,{total:tj,isExporting:"landing-pages"===t2,disabled:0===tj||null!==t2,onClick:()=>ag("landing-pages")})}),(0,s.jsx)($.V8,{kind:"landing-pages",rows:tv.map(e=>({...e,text:e.url})),sortBy:em,sortOrder:eh,onSort:e=>{ep(em===e&&"desc"===eh?"asc":"desc"),eu(e),ex(1)},onCopy:ah,copiedText:er,onVisit:e=>window.open(e,"_blank","noopener,noreferrer"),onSeeAds:e=>au("landing_page",e.text)}),(0,s.jsx)(_,{children:(0,s.jsxs)(M,{children:[(0,s.jsx)(T,{children:(0,s.jsx)(F,{href:"#",onClick:e=>{e.preventDefault(),ed>1&&ex(ed-1)},className:1===ed?"pointer-events-none opacity-50":"cursor-pointer"})}),e_(ed,tw).map((e,t)=>"ellipsis"===e?(0,s.jsx)(T,{children:(0,s.jsx)(D,{})},"ellipsis-".concat(t)):(0,s.jsx)(T,{children:(0,s.jsx)(B,{href:"#",onClick:t=>{t.preventDefault(),ex(e)},isActive:ed===e,className:ed===e?"bg-violet-600 hover:bg-violet-700 text-white":"cursor-pointer",children:e})},e)),(0,s.jsx)(T,{children:(0,s.jsx)(L,{href:"#",onClick:e=>{e.preventDefault(),ed<tw&&ex(ed+1)},className:ed===tw?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})})}),(0,s.jsx)(j.av,{value:"hooks",className:"m-0 flex-1 min-h-0 overflow-y-auto",children:(0,s.jsx)("div",{className:"px-6 py-6 bg-[#FAFAFA]",children:tk?(0,s.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,s.jsx)(l.A,{className:"w-6 h-6 animate-spin text-violet-600"}),(0,s.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading hooks..."})]}):"pending"===tL||"processing"===tL?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[(0,s.jsx)(l.A,{className:"w-8 h-8 animate-spin text-violet-600"}),(0,s.jsxs)("div",{className:"text-center space-y-2",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"pending"===tL?"Starting Hook Analysis...":"Analyzing Video Hooks..."}),(0,s.jsx)("p",{className:"text-sm text-gray-500 max-w-md",children:"pending"===tL?"AI is preparing to extract spoken hooks from your video ads. This may take a few minutes.":"AI is extracting spoken hooks from video ads using Whisper transcription. This may take 10-20 minutes depending on the number of videos."}),(0,s.jsx)("p",{className:"text-xs text-gray-400 mt-4",children:"This page will automatically update when processing is complete."})]})]}):"failed"===tL?(0,s.jsx)("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:(0,s.jsxs)("div",{className:"text-center space-y-2",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-red-600",children:"Processing Failed"}),(0,s.jsx)("p",{className:"text-sm text-gray-500 max-w-md",children:"Hook processing failed. Please contact support if this issue persists."})]})}):(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold text-gray-900",children:"Hooks"}),(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)(v.$,{variant:"outline",size:"sm",className:"gap-2",children:[af(),(0,s.jsx)(i.A,{className:"w-4 h-4"})]})}),(0,s.jsxs)(N.SQ,{align:"start",children:[(0,s.jsx)(N._2,{onClick:()=>en("7d"),children:"Last 7 days"}),(0,s.jsx)(N._2,{onClick:()=>en("30d"),children:"Last 30 days"}),(0,s.jsx)(N._2,{onClick:()=>en("90d"),children:"Last 90 days"}),(0,s.jsx)(N._2,{onClick:()=>en("all"),children:"All time"})]})]})]}),(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Hooks for ads that were live in selected timeframe"})]}),(0,s.jsx)("div",{className:"bg-white rounded-lg",children:(0,s.jsxs)(E.XI,{children:[(0,s.jsx)(E.A0,{children:(0,s.jsxs)(E.Hj,{className:"hover:bg-transparent border-b border-gray-100",children:[(0,s.jsx)(E.nd,{className:"text-sm text-gray-500 font-medium",children:"Thumbnail"}),(0,s.jsx)(E.nd,{className:"text-sm text-gray-500 font-medium",children:"Hook Text"}),(0,s.jsx)(E.nd,{className:"text-sm text-gray-500 font-medium text-center w-24",children:(0,s.jsxs)(v.$,{variant:"ghost",size:"sm",className:"h-auto p-0 hover:bg-transparent text-sm text-gray-500 font-medium",onClick:()=>{"ads"===eb?eM("asc"===ey?"desc":"asc"):(ev("ads"),eM("desc")),eg(1)},children:["Ads"," ",(0,s.jsxs)("span",{className:"ml-[1px] inline-flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"inline-block border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-b-[5px] ".concat("ads"===eb&&"asc"===ey?"border-b-gray-900":"border-b-gray-400"),style:{width:0,height:0}}),(0,s.jsx)("span",{className:"inline-block border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-t-[5px] ".concat("ads"===eb&&"desc"===ey?"border-t-gray-900":"border-t-gray-400"),style:{width:0,height:0}})]})]})}),(0,s.jsx)(E.nd,{className:"text-sm text-gray-500 font-medium text-center w-32",children:(0,s.jsxs)(v.$,{variant:"ghost",size:"sm",className:"h-auto p-0 hover:bg-transparent text-sm text-gray-500 font-medium",onClick:()=>{"longest_running"===eb?eM("asc"===ey?"desc":"asc"):(ev("longest_running"),eM("desc")),eg(1)},children:["Longest Running"," ",(0,s.jsxs)("span",{className:"ml-[1px] inline-flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"inline-block border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-b-[5px] ".concat("longest_running"===eb&&"asc"===ey?"border-b-gray-900":"border-b-gray-400"),style:{width:0,height:0}}),(0,s.jsx)("span",{className:"inline-block border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-t-[5px] ".concat("longest_running"===eb&&"desc"===ey?"border-t-gray-900":"border-t-gray-400"),style:{width:0,height:0}})]})]})}),(0,s.jsx)(E.nd,{className:"text-sm text-gray-500 font-medium text-right w-40",children:"Action"})]})}),(0,s.jsx)(E.BF,{children:tS.map(e=>(0,s.jsxs)(E.Hj,{className:"hover:bg-gray-50 border-b border-gray-100",children:[(0,s.jsx)(E.nA,{className:"py-3",children:e.videoUrl?(0,s.jsxs)(R.jc,{openDelay:300,closeDelay:100,children:[(0,s.jsx)(R.d0,{asChild:!0,children:(0,s.jsx)("div",{className:"w-12 h-12 rounded overflow-hidden flex-shrink-0 bg-gray-100 cursor-pointer hover:ring-2 hover:ring-violet-400 transition-all",children:e.thumbnail?(0,s.jsx)("img",{src:e.thumbnail,alt:"Hook ".concat(e.id),className:"w-full h-full object-cover"}):(0,s.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-gray-200",children:(0,s.jsx)(h.A,{className:"w-6 h-6 text-gray-400"})})})}),(0,s.jsx)(R.Et,{className:"w-80 h-80 p-0 overflow-hidden border-2 border-gray-200",side:"right",sideOffset:10,children:(0,s.jsx)("video",{src:e.videoUrl,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,playsInl
1ine:!0,muted:!1,onPlay:e=>{let t=e.currentTarget;t.currentTime=0,t.play().catch(()=>{t.muted=!0,t.play()})}})})]}):e.thumbnail?(0,s.jsx)("div",{className:"w-12 h-12 rounded overflow-hidden flex-shrink-0 bg-gray-100",children:(0,s.jsx)("img",{src:e.thumbnail,alt:"Hook ".concat(e.id),className:"w-full h-full object-cover"})}):(0,s.jsx)("div",{className:"w-12 h-12 rounded overflow-hidden flex-shrink-0 bg-gray-100 flex items-center justify-center text-gray-400",children:(0,s.jsx)(g.A,{className:"w-6 h-6"})})}),(0,s.jsx)(E.nA,{className:"py-3 max-w-md",children:(0,s.jsx)("div",{className:"text-sm text-gray-900 font-normal truncate",title:e.hookText,children:e.hookText})}),(0,s.jsxs)(E.nA,{className:"text-sm text-gray-900 font-normal text-center py-3",children:[e.activeAds,"/",e.totalAds," active ads"]}),(0,s.jsx)(E.nA,{className:"text-sm text-gray-900 font-normal text-center py-3",children:null==e.longestRunning?"â":"".concat(e.longestRunning," days")}),(0,s.jsx)(E.nA,{className:"text-right",children:(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,s.jsx)("button",{className:"text-sm text-violet-600 hover:text-violet-700 transition-colors",onClick:()=>ah(e.hookText),children:er===e.hookText?"Copied!":"Copy"}),(0,s.jsx)("span",{className:"text-gray-300",children:"|"}),(0,s.jsx)("button",{className:"text-sm text-violet-600 hover:text-violet-700 transition-colors",onClick:()=>au("hook",e.hookText),children:"See ads"})]})})]},e.id))})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"text-sm text-gray-600",children:["Showing page ",ef," of ",tB]}),(0,s.jsx)(_,{children:(0,s.jsxs)(M,{children:[(0,s.jsx)(T,{children:(0,s.jsx)(F,{href:"#",onClick:e=>{e.preventDefault(),ef>1&&eg(ef-1)},className:1===ef?"pointer-events-none opacity-50":"cursor-pointer"})}),e_(ef,tB).map((e,t)=>"ellipsis"===e?(0,s.jsx)(T,{children:(0,s.jsx)(D,{})},"ellipsis-".concat(t)):(0,s.jsx)(T,{children:(0,s.jsx)(B,{href:"#",onClick:t=>{t.preventDefault(),eg(e)},isActive:ef===e,className:ef===e?"bg-violet-600 hover:bg-violet-700 text-white":"cursor-pointer",children:e})},e)),(0,s.jsx)(T,{children:(0,s.jsx)(L,{href:"#",onClick:e=>{e.preventDefault(),ef<tB&&eg(ef+1)},className:ef===tB?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})]})})}),(0,s.jsx)(j.av,{value:"ad-copy",className:"m-0 flex-1 min-h-0 overflow-y-auto",children:(0,s.jsx)("div",{className:"px-6 py-6 bg-[#FAFAFA]",children:tW?(0,s.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,s.jsx)(l.A,{className:"w-6 h-6 animate-spin text-violet-600"}),(0,s.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading ad copies..."})]}):(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsx)($.OX,{title:"Ad Copy",description:"Ad copies for ads that were live in selected timeframe",controls:(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)(v.$,{variant:"outline",size:"sm",className:"gap-2",children:[af(),(0,s.jsx)(i.A,{className:"w-4 h-4"})]})}),(0,s.jsxs)(N.SQ,{align:"start",children:[(0,s.jsx)(N._2,{onClick:()=>en("7d"),children:"Last 7 days"}),(0,s.jsx)(N._2,{onClick:()=>en("30d"),children:"Last 30 days"}),(0,s.jsx)(N._2,{onClick:()=>en("90d"),children:"Last 90 days"}),(0,s.jsx)(N._2,{onClick:()=>en("all"),children:"All time"})]})]}),actions:(0,s.jsx)($.$z,{total:tK,isExporting:"ad-copy"===t2,disabled:0===tK||null!==t2,onClick:()=>ag("ad-copy")})}),(0,s.jsx)($.V8,{kind:"ad-copy",rows:tV.map(e=>({...e,text:e.copyText})),sortBy:eI,sortOrder:eO,onSort:e=>{ez(eI===e&&"desc"===eO?"asc":"desc"),eU(e),eR(1)},onCopy:ah,copiedText:er,onVisit:e=>window.open(e,"_blank","noopener,noreferrer"),onSeeAds:e=>au("ad_copy",e.text)}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"text-sm text-gray-600",children:["Showing page ",eE," of ",tQ]}),(0,s.jsx)(_,{children:(0,s.jsxs)(M,{children:[(0,s.jsx)(T,{children:(0,s.jsx)(F,{href:"#",onClick:e=>{e.preventDefault(),eE>1&&eR(eE-1)},className:1===eE?"pointer-events-none opacity-50":"cursor-pointer"})}),e_(eE,tQ).map((e,t)=>"ellipsis"===e?(0,s.jsx)(T,{children:(0,s.jsx)(D,{})},"ellipsis-".concat(t)):(0,s.jsx)(T,{children:(0,s.jsx)(B,{href:"#",onClick:t=>{t.preventDefault(),eR(e)},isActive:eE===e,className:eE===e?"bg-violet-600 hover:bg-violet-700 text-white":"cursor-pointer",children:e})},e)),(0,s.jsx)(T,{children:(0,s.jsx)(L,{href:"#",onClick:e=>{e.preventDefault(),eE<tQ&&eR(eE+1)},className:eE===tQ?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})]})})}),(0,s.jsx)(j.av,{value:"headline",className:"m-0 flex-1 min-h-0 overflow-y-auto",children:(0,s.jsx)("div",{className:"px-6 py-6 bg-[#FAFAFA]",children:tP?(0,s.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,s.jsx)(l.A,{className:"w-6 h-6 animate-spin text-violet-600"}),(0,s.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading headlines..."})]}):(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsx)($.OX,{title:"Headline",description:"Headlines for ads that were live in selected timeframe",controls:(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)(v.$,{variant:"outline",size:"sm",className:"gap-2",children:[af(),(0,s.jsx)(i.A,{className:"w-4 h-4"})]})}),(0,s.jsxs)(N.SQ,{align:"start",children:[(0,s.jsx)(N._2,{onClick:()=>en("7d"),children:"Last 7 days"}),(0,s.jsx)(N._2,{onClick:()=>en("30d"),children:"Last 30 days"}),(0,s.jsx)(N._2,{onClick:()=>en("90d"),children:"Last 90 days"}),(0,s.jsx)(N._2,{onClick:()=>en("all"),children:"All time"})]})]}),actions:(0,s.jsx)($.$z,{total:tU,isExporting:"headline"===t2,disabled:0===tU||null!==t2,onClick:()=>ag("headline")})}),(0,s.jsx)($.V8,{kind:"headline",rows:tR.map(e=>({...e,text:e.headline})),sortBy:eF,sortOrder:eD,onSort:e=>{eP(eF===e&&"desc"===eD?"asc":"desc"),eL(e),eB(1)},onCopy:ah,copiedText:er,onVisit:e=>window.open(e,"_blank","noopener,noreferrer"),onSeeAds:e=>au("headline",e.text)}),(0,s.jsx)(_,{children:(0,s.jsxs)(M,{children:[(0,s.jsx)(T,{children:(0,s.jsx)(F,{href:"#",onClick:e=>{e.preventDefault(),eT>1&&eB(eT-1)},className:1===eT?"pointer-events-none opacity-50":"cursor-pointer"})}),e_(eT,tz).map((e,t)=>"ellipsis"===e?(0,s.jsx)(T,{children:(0,s.jsx)(D,{})},"ellipsis-".concat(t)):(0,s.jsx)(T,{children:(0,s.jsx)(B,{href:"#",onClick:t=>{t.preventDefault(),eB(e)},isActive:eT===e,className:eT===e?"bg-violet-600 hover:bg-violet-700 text-white":"cursor-pointer",children:e})},e)),(0,s.jsx)(T,{children:(0,s.jsx)(L,{href:"#",onClick:e=>{e.preventDefault(),eT<tz&&eB(eT+1)},className:eT===tz?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})})})]})]})]}),(0,s.jsx)(Q.a,{open:t3,onOpenChange:e=>{e?t6(!0):(ae.current+=1,t6(!1),t8(null),t9(!1))},ad:t4,isLoading:t7,source:"brand-spy",onAccessDenied:ee?ar:void 0,"data-sentry-element":"AdDetailModal","data-sentry-source-file":"BrandDetailPage.tsx"}),(0,s.jsx)(eA.A,{open:at,onOpenChange:aa,context:as,"data-sentry-element":"SubscriptionModal","data-sentry-source-file":"BrandDetailPage.tsx"})]})}},31431:(e,t,a)=>{a.d(t,{E:()=>i});var s=a(95155);a(12115);var n=a(18460),r=a(91337);let l=(0,n.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-gray-100 text-gray-700 hover:bg-gray-200",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function i(e){let{className:t,variant:a,...n}=e;return(0,s.jsx)("div",{className:(0,r.cn)(l({variant:a}),t),...n,"data-sentry-component":"Badge","data-sentry-source-file":"badge.tsx"})}},61006:(e,t,a)=>{a.d(t,{Q:()=>s});
1let s=[{code:"US",name:"United States"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"BE",name:"Belgium"},{code:"BG",name:"Bulgaria"},{code:"CA",name:"Canada"},{code:"HR",name:"Croatia"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czech Republic"},{code:"DK",name:"Denmark"},{code:"EE",name:"Estonia"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"DE",name:"Germany"},{code:"GR",name:"Greece"},{code:"GP",name:"Guadeloupe"},{code:"HU",name:"Hungary"},{code:"IE",name:"Ireland"},{code:"IT",name:"Italy"},{code:"LV",name:"Latvia"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MT",name:"Malta"},{code:"MQ",name:"Martinique"},{code:"YT",name:"Mayotte"},{code:"NL",name:"Netherlands"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"RO",name:"Romania"},{code:"RE",name:"R\xe9union"},{code:"MF",name:"Saint Martin (French part)"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"ES",name:"Spain"},{code:"SE",name:"Sweden"},{code:"GB",name:"United Kingdom"},{code:"AX",name:"\xc5land Islands"}]},72320:(e,t,a)=>{a.d(t,{$m:()=>c,As:()=>o,nD:()=>i,ub:()=>d});var s=a(95155);a(12115);var n=a(89372),r=a(66088),l=a(91337);function i(e){let{...t}=e;return(0,s.jsx)(n.bL,{"data-slot":"accordion",...t,"data-sentry-element":"AccordionPrimitive.Root","data-sentry-component":"Accordion","data-sentry-source-file":"accordion.tsx"})}function o(e){let{className:t,...a}=e;return(0,s.jsx)(n.q7,{"data-slot":"accordion-item",className:(0,l.cn)("border-b last:border-b-0",t),...a,"data-sentry-element":"AccordionPrimitive.Item","data-sentry-component":"AccordionItem","data-sentry-source-file":"accordion.tsx"})}function c(e){let{className:t,children:a,...i}=e;return(0,s.jsx)(n.Y9,{className:"flex","data-sentry-element":"AccordionPrimitive.Header","data-sentry-component":"AccordionTrigger","data-sentry-source-file":"accordion.tsx",children:(0,s.jsxs)(n.l9,{"data-slot":"accordion-trigger",className:(0,l.cn)("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",t),...i,"data-sentry-element":"AccordionPrimitive.Trigger","data-sentry-source-file":"accordion.tsx",children:[a,(0,s.jsx)(r.A,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200","data-sentry-element":"ChevronDownIcon","data-sentry-source-file":"accordion.tsx"})]})})}function d(e){let{className:t,children:a,...r}=e;return(0,s.jsx)(n.UC,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...r,"data-sentry-element":"AccordionPrimitive.Content","data-sentry-component":"AccordionContent","data-sentry-source-file":"accordion.tsx",children:(0,s.jsx)("div",{className:(0,l.cn)("pt-0 pb-4",t),children:a})})}}}]);
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.