1import{a as e}from"./rolldown-runtime-BEU_UCik.js";import{r as t}from"./vendor-auth-DAuWozuU.js";import{c as a}from"./vendor-react-IBcu1n3d.js";import{_ as r,h as s,m as i,t as o}from"./chunk-62JRHF6Z-D9puh-us.js";import{t as n}from"./index.esm-BEieHnny.js";import{_ as l,a as c,n as d}from"./vendor-query-Ct_3YD9H.js";import{n as u}from"./User-BzNI1SQp.js";import{t as h}from"./index.es-BTkwoywu.js";import{S as m,x}from"./regular-AT_GwMg_.js";import{t as p}from"./Paywall-B3Gj9JWr.js";import{t as b}from"./useScrollToTop-6I6osjaO.js";import{r as g}from"./StatusEventsContext-DFtWWkE4.js";import{n as f}from"./ThemeManager-ILkyB1Q0.js";import{B as y,Bt as j,K as v,L as k,N as w,R as N,S as _,W as M,b as C,d as S,f as A,fn as F,g as P,jt as I,m as O,mt as T,o as L,sn as $,yt as E}from"./solid-CGJw0jLI.js";import{_t as D,a as z,ht as U,k as R,lt as q,n as B,w as V}from"./free-solid-svg-icons-BD_SwYKY.js";import{t as W}from"./cn-rNX6jy_B.js";import{t as H}from"./Loading-XkN6_W9E.js";import{t as Q}from"./useProject-_1FGJNGu.js";import{_ as G}from"./vendor-charts-CIrZe8F2.js";import{d as K,l as Y,r as Z}
1from"./chartUtils-BgSJGHV9.js";import{t as X}from"./ChartDashboard-6nGBJd0Q.js";import{a as J}from"./tableUtils-Cx91YH8V.js";import{t as ee}from"./ErrorDisplay-CSn8m05Q.js";import{t as te}from"./ProjectInfoHeader-ByyklFgd.js";import{t as ae}from"./SlideInHeader-BJJLUhDd.js";import{t as re}from"./DataUnavailable-DDY0TBWz.js";import{a as se,c as ie,d as oe,i as ne,l as le,n as ce,o as de,r as ue,s as he,t as me,u as xe}from"./InterestCharts-CTh2QTl7.js";import{t as pe}from"./colors-CsbvIeof.js";import{a as be}from"./perplexity-CraboH6o.js";import{t as ge}from"./ExportQuestionsButton-LjEsI4ei.js";import{c as fe,d as ye,l as je,n as ve,s as ke,u as we}from"./VisibilityCards-BxQOs5iU.js";import{t as Ne}from"./WatchlistGuideLink-Cktuay-X.js";import{t as _e}from"./clusterService-COYmaiU2.js";var Me=e(t()),Ce=c();function Se({data:e,currentViz:t,category:a,setCategory:r,subcategory:s,setSubcategory:i}){const{category_ai_metrics:o,subcategory_ai_metrics:n}=e||{};let l="All"===a?o||{}:n?.[a]||{};"All"!==a&&o&&(l={[`${a}`]:o[a]||{},...l});const c=Object.keys(l||{}).sort((e,t)=>e===`${a}`?-1:t===`${a}`?1:e.localeCompare(t));return c&&0!==c.length?(0,Ce.jsx)("div",{className:"relative grid gap-2 px-4 pb-4 md:grid-cols-2 lg:grid-cols-3",children:c.map((e,t)=>{let o="--",n=0;const d=l[e];o=d?.overall_score_avg??"--","number"==typeof o&&(o=Math.round(o)),n=d?.delta_last??"--";const u="number"==typeof n&&n<0,m="number"==typeof n;return(0,Ce.jsxs)("button",{className:"relative overflow-hidden text-left rounded p-2 pr-4 pl-12 border border-black/10 dark:border-white/15 content-center cursor-pointer hover:bg-solar-100 dark:hover:bg-white/10 transition-all ease-in-out "+(s===e||a===e&&"All"===s?"bg-solar-100 dark:bg-white/10 border-solar-300 dark:border-white/25":""),onClick:()=>{return t=e,void("All"===a?r(t):t===a?r("All"):i(t===s?"All":t));var t},disabled:!1,children:[(0,Ce.jsx)("div",{className:"absolute top-0 left-0 bottom-0 w-8",style:"All"===e||e===a?{backgroundImage:"linear-gradient(to bottom, rgba(255, 115, 71, 1), rgba(231, 85, 195, 1))"}:{backgroundColor:pe[c[0],t-1]}}),(0,Ce.jsxs)("div",{className:"flex justify-center flex-col",children:[(0,Ce.jsx)("h3",{className:"",children:e}),(0,Ce.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Ce.jsxs)("span",{className:"text-2xl font-space font-bold",children:[o,"--"!==o?"%":""]}),m?(0,Ce.jsxs)("span",{className:"text-xs flex items-center "+(u?"text-red-500":"text-green-500"),children:[(0,Ce.jsx)(h,{icon:u?S:A,className:"mr-2"}),(0,Ce.jsxs)("span",{children:[Math.abs(n),"%"]})]}):(0,Ce.jsx)("span",{className:"text-xs text-gray-400 font-medium",children:"--"})]})]})]},e)})}):(0,Ce.jsx)(re,{title:`No ${"All"===a?"categories":"subcategories"} available.`,message:"We couldn't find any trend data for this selection.",icon:I})}function Ae({cluster:e,category:t,showAllOnly:a=!1}){const{theme:r}=f(),{category_ai_metrics:s,subcategory_ai_metrics:i}=e.ai_visibility_metrics||{};let o="All"===t?s:i?.[t];"All"!==t&&s?.[t]&&(o={[t]:s[t],...o||{}});const n=o||{},l=(0,Me.useMemo)(()=>{let r=Object.entries(n);return a&&(r=r.filter(([e])=>"All"===e)),r.map(([t,r])=>({name:a&&"All"===t&&(e?.model_name||e?.name)||t,trend:r.ai_visibility_score_trend||[],connectNulls:!0})).sort((e,a)=>e.name===t?-1:a.name===t?1:e.name.localeCompare(a.name))},[n,t,a,e]),c=l.some(e=>Array.isArray(e.trend)&&e.trend.length>0),d=l.every(e=>Array.isArray(e.trend)&&1===e.trend.length),u=Math.max(...l.map(e=>e.trend?.length||0)),h=u>1&&u<=5,m=(0,Me.useMemo)(()=>c?function(e,t,a={}){const{isSinglePointChart:r,isFewPoints:s,category:i,showAllOnly:o,clusterModelName:n}=a;return{gui:{layouts:[{rows:[{cells:[{id:"ai-visibility-line-cell"}]}]}]},components:[{type:"Highcharts",cell:"ai-visibility-line-cell",chartOptions:{chart:{type:r?"bar":"line",height:r?600:400,styledMode:!1},title:{text:null},subtitle:{text:null},xAxis:{categories:r?e.map(e=>e.name):e[0]?.trend.map(e=>e.date)||[],labels:{enabled:!0,formatter(){return r?this.value:Z(this.value)},style:{fontSize:"12px",fontFamily:"Karla, sans-serif",color:"dark"===t?"#FFFFFF":"#000000"}},gridLineWidth:1},yAxis:{title:{text:r?null:"AI Visibility Score",style:{fontSize:"18px",fontFamily:"Karla, sans-serif",fontWeight:600}},min:0,max:100,gridLineWidth:1,labels:{formatter(){return this.value+"%"},style:{fontSize:"14px",fontFamily:"Karla, sans-serif"}}},tooltip:{shared:!0,formatter(){const e=this.x,t=new Date(e),a=Number.isNaN(t.getTime())?e:t.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric",timeZone:"UTC"});let s=`<b>${r?this.x:a}</b><br/>`;
1return this.points.forEach(e=>{s+=`<span style="color:${e.color}">â</span> ${e.series.name}: <b>${Math.round(e.y)}%</b><br/>`}),s}},legend:{enabled:!1,layout:"horizontal",align:"center",verticalAlign:"top",floating:!1,itemStyle:{fontSize:"14px",fontFamily:"Karla, sans-serif",fontWeight:500}},plotOptions:{series:{marker:{enabled:s,radius:4,states:{hover:{enabled:!0,radius:6,lineWidth:3,lineColor:"dark"===t?"#020021":"#FFFFFF"}}},lineWidth:r?0:3,borderWidth:r?1:0,borderColor:"dark"===t?"#FFFFFF":"#0561B780",animation:!0,connectNulls:!0,pointPlacement:r||s?null:"on",linecap:"square",grouping:!r,dataLabels:{enabled:r,format:"{point.y:.1f}%",inside:!0,align:"right",style:{fontSize:"18px",fontFamily:"Space Grotesk, sans-serif",fontWeight:"bold",textOutline:"1px 1px 1px #020021",color:"white"}}}},colors:pe,series:e.map((e,t)=>{const a={clip:!1,name:e.name,connectNulls:!0,data:r?[{x:t,y:"number"==typeof e.trend[0]?.value?Number(e.trend[0].value.toFixed(2)):null}]:e.trend.map(e=>"number"==typeof e.value?Number(e.value.toFixed(2)):null)};return("All"===e.name||e.name===i||o&&e.name===n)&&(a.color={linearGradient:{x1:0,x2:1,y1:0,y2:0},stops:[[0,"rgba(255, 115, 71, 1)"],[1,"rgba(231, 85, 195, 1)"]]},a.lineColor="rgba(231, 85, 195, 0.8)",a.lineWidth=4,a.zIndex=10),a})}}]}}(l,r,{isSinglePointChart:d,isFewPoints:h,category:t,showAllOnly:a,clusterModelName:e?.model_name||e?.name}):null,[l,r,c,t,a,e]);return c?(0,Ce.jsx)(X,{config:m,id:"ai-visibility-line-container"}):(0,Ce.jsx)(re,{title:"No Metrics Available",message:"We couldn't find any trend data for this selection.",icon:k})}var Fe=async({queryKey:e,signal:t})=>{const[,a,r,s,i]=e,o={category_name:r};return s&&"All"!==s&&(o.subcategory_name=s),i&&(o.sort=i),be.getQuestionsList(a,o,t)};function Pe(e,t,a,r,{enabled:s=!0}={}){const{data:i,error:o,isPending:n,isFetching:c}=d({queryKey:["questions",e,t,a,r],queryFn:Fe,enabled:!!e&&s,staleTime:3e4,gcTime:3e5,refetchOnWindowFocus:!1,placeholderData:l});return{questions:i||[],loading:n&&!(!e||!s),isFetching:c,error:o??null}}var Ie=[{label:"AI Visibility (High to Low)",value:"ai_visibility"},{label:"AI Visibility (Low to High)",value:"ai_visibility_asc"},{label:"Biggest Gainers",value:"biggest_gainers"},{label:"Biggest Laggards",value:"biggest_laggards"}],Oe=e=>{if(null==e)return(0,Ce.jsxs)("div",{className:"min-w-[62px] flex justify-center items-center gap-1.5 px-2 py-1 bg-gray-500/10 rounded border border-gray-500/20 text-gray-500",title:"No Data",children:[(0,Ce.jsx)("span",{className:"text-xs font-bold font-mono",children:"--"}),(0,Ce.jsx)("span",{className:"sr-only",children:"No trend data available"})]});const t=Number(e);if(isNaN(t))return null;if(0===t)return(0,Ce.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-gray-500/10 rounded border border-gray-500/20 text-gray-400",title:"No Change",children:[(0,Ce.jsx)(h,{icon:j,className:"text-[10px]","aria-hidden":"true"}),(0,Ce.jsx)("span",{className:"text-xs font-bold font-mono",children:"0.00"}),(0,Ce.jsx)("span",{className:"sr-only",children:"No change in trend"})]});const a=t>0,r=a?"Increased by":"Decreased by",s=Math.abs(t).toFixed(2);return(0,Ce.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded border "+(a?"bg-green-500/10 border-green-500/20 text-green-400":"bg-red-500/10 border-red-500/20 text-red-400"),title:a?"Increased":"Decreased",children:[(0,Ce.jsx)(h,{icon:a?O:L,className:"text-[10px]","aria-hidden":"true"}),(0,Ce.jsx)("span",{className:"text-xs font-bold font-mono",children:s}),(0,Ce.jsxs)("span",{className:"sr-only",children:[r," ",s]})]})};function Te({uuid:e,category:t,subcategory:a,name:r}){const{is_internal:s}=u(),[i,n]=(0,Me.useState)("ai_visibility"),{questions:l,loading:c,error:d,isFetching:m}=Pe(e,t,a,i,{enabled:!!e}),[x,p]=(0,Me.useState)(!1),[b,g]=(0,Me.useState)(!1);if(c)return(0,Ce.jsxs)("div",{className:"p-4",role:"status","aria-live":"polite",children:[(0,Ce.jsxs)("h3",{className:"text-2xl font-bold mb-4",children:["All"!==a?a:t," Questions People Ask"]}),(0,Ce.jsxs)("div",{className:"p-8 dark:bg-[#050a24]/40 bg-white/40 border border-solar-200 dark:border-white/10 rounded-2xl backdrop-blur-sm text-center animate-pulse",children:[(0,Ce.jsx)("span",{className:"text-solar-600 dar
1k:text-blue-300 font-space tracking-widest text-sm uppercase",children:"Loading Questions..."}),(0,Ce.jsx)("span",{className:"sr-only",children:"Loading questions, please wait."})]})]});if(d)return(0,Ce.jsxs)("div",{role:"alert",className:"p-4 bg-red-900/20 border border-red-500/30 text-red-200 rounded-xl my-4",children:["Error loading questions: ",d.message]});if(0===l.length&&!c)return(0,Ce.jsx)(Ce.Fragment,{children:(0,Ce.jsxs)("div",{className:"p-4",children:[(0,Ce.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,Ce.jsxs)("h3",{className:"text-2xl font-bold",children:["All"!==a?a:"All"===t?null:t," ","Questions People Ask"]}),s&&(0,Ce.jsx)(ge,{uuid:e,type:"org_project",name:r,variant:"inline"})]}),(0,Ce.jsx)("div",{className:"p-8 dark:bg-[#050a24]/40 bg-white/40 border border-solar-200 dark:border-white/10 rounded-2xl backdrop-blur-sm text-center",children:(0,Ce.jsx)("span",{className:"text-gray-500 font-space tracking-widest text-xs uppercase",children:"All"===t?"Select a category to view popular questions":"No active questions found for this category"})})]})});const f=x?l:l.slice(0,10),j=l.length>10;return(0,Ce.jsxs)("section",{"aria-label":`${"All"!==a?a:t} Questions List`,children:[(0,Ce.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,Ce.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Ce.jsxs)("h3",{className:"text-xl md:text-2xl font-bold font-space text-deep-space dark:text-white",children:["All"!==a?a:t," Questions People Ask"]}),(0,Ce.jsxs)("div",{className:"text-[10px] font-bold text-solar-700 dark:text-blue-300 bg-solar-100 dark:bg-trusty-blue/20 border border-solar-200 dark:border-trusty-blue/40 px-3 py-1 rounded-full uppercase tracking-widest hidden sm:block",children:[l.length," Questions"]}),s&&(0,Ce.jsx)(ge,{uuid:e,type:"org_project",name:r,variant:"inline"})]}),(0,Ce.jsx)("div",{children:(0,Ce.jsxs)("button",{onClick:()=>g(!b),"aria-expanded":b,"aria-controls":"questions-filter-section","aria-label":b?"Hide sort options":"Show sort options",className:`\n flex items-center justify-center gap-2 h-9 px-4 md:h-10 md:px-5 rounded-full font-bold transition-all duration-300\n ${b?"bg-solar-600 dark:bg-trusty-blue/30 text-white shadow-sm border border-solar-600 dark:border-trusty-blue/50":"bg-white dark:bg-white/5 text-solar-700 dark:text-blue-300 border border-solar-200 dark:border-white/10 hover:border-solar-400 hover:bg-solar-50 dark:hover:border-white/20 shadow-sm"}\n `,children:[(0,Ce.jsx)("span",{className:"text-xs font-black uppercase tracking-widest hidden md:block",children:"Filter"}),(0,Ce.jsx)(h,{icon:C,"aria-hidden":"true"})]})})]}),(0,Ce.jsx)("div",{id:"questions-filter-section","aria-hidden":!b,className:"px-4 transition-all duration-300 ease-in-out overflow-hidden "+(b?"max-h-[300px] opacity-100 pb-4":"max-h-0 opacity-0"),children:(0,Ce.jsxs)("div",{className:"pt-2 pb-4",children:[(0,Ce.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,Ce.jsx)("div",{className:"h-[2px] w-8 bg-solar-400/40 dark:bg-trusty-blue/40 rounded-full"}),(0,Ce.jsx)("h4",{className:"text-[10px] font-bold text-slate-500 dark:text-gray-400 uppercase tracking-[0.2em]",children:"Sort By"})]}),(0,Ce.jsx)("div",{className:"flex items-center gap-1 w-fit p-1 rounded-xl bg-black/[0.04] dark:bg-white/[0.06] border border-solar-200 dark:border-white/10 relative z-10 overflow-x-auto hide-scrollbar",children:Ie.map(e=>{const t=i===e.value;return(0,Ce.jsxs)("label",{className:`\n flex flex-1 md:flex-none items-center justify-center gap-2 px-3 md:px-4 py-2 text-[10px] md:text-xs font-bold uppercase tracking-widest rounded-lg cursor-pointer transition-all duration-200 ease-out select-none whitespace-nowrap\n ${t?"bg-solar-600 text-white dark:bg-white/[0.12] dark:text-white shadow-sm shadow-solar-600/30 dark:shadow-black/20 hover:bg-solar-700 dark:hover:bg-white/[0.14] z-10":"text-deep-space/60 dark:text-white/50 hover:text-deep-space dark:hover:text-white hover:bg-black/[0.04] dark:hover:bg-white/[0.06] z-0"}\n `,children:[(0,Ce.jsx)("input",{type:"radio",name:"sort",value:e.value,checked:t,onChange:e=>n(e.target.value),className:"sr-only"}),t&&(0,Ce.jsx)(h,{icon:y,className:"text-[10px] dark:text-[#60a5fa]"}),(0,Ce.jsx)("span",{children:e.label})]},e.value)})})]})}),(0,Ce.jsx)("ul",{className:"p-4 flex flex-col gap-3 "+(m?"animate-pulse":""),children:f.map((t,r)=>(0,Ce.jsx)("li",{className:"group relative rounded-2xl bg-white dark:bg-white/5 border border-solar-200 dark:border-white/10 shadow-sm hover:shadow-md hover:border-solar-300 dark:hover:border-trusty-blue/30 dark:hover:bg-white/10 transition-all duration-300",children:(0,Ce.jsxs)(o,{to:`/project/ai-visibility/question/${e}/${t.uuid}`,className:"p-2 flex justify-between items-start gap-4",children:[(0,Ce.jsxs)("div",{className:"flex gap-4 items-start",children:[(0,Ce.jsx)("div",{className:"h-full min-w-[55px] p-1 aspect-[8/11] flex items-center justify-center rounded-lg bg-solar-100 dar
1k:bg-trusty-blue/20 text-solar-700 dark:text-blue-300 group-hover:bg-solar-600 dark:group-hover:bg-trusty-blue/40 group-hover:text-white transition-colors border border-solar-200 dark:border-trusty-blue/40 group-hover:border-solar-600 dark:group-hover:border-trusty-blue/60 text-base font-bold",children:t.ai_visibility_score?t.ai_visibility_score+"%":"N/A"}),(0,Ce.jsxs)("div",{children:[(0,Ce.jsx)("h4",{className:"text-lg font-medium text-deep-space dark:text-white/90 dark:group-hover:text-white transition-colors leading-tight",children:t.question}),"All"===a&&(0,Ce.jsx)("div",{className:"mt-2",children:(0,Ce.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[10px] font-bold uppercase tracking-widest bg-solar-50 dark:bg-trusty-blue/10 border border-solar-200 dark:border-trusty-blue/30 text-solar-600/60 dark:text-blue-400/60 group-hover:text-solar-700 dark:group-hover:text-blue-300 group-hover:bg-solar-100 dark:group-hover:bg-trusty-blue/20 transition-colors",children:t.subcategory_name||"--"})})]})]}),(0,Ce.jsxs)("div",{className:"flex flex-col items-end min-w-[80px]",children:[(0,Ce.jsxs)("span",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-widest mb-1 opacity-50 group-hover:opacity-100 transition-opacity",children:["AI Viz Trend",t.last_run_delta>=70?(0,Ce.jsx)(h,{icon:E,className:"text-red-500 ml-2","aria-hidden":"true"}):t.last_run_delta<=-30?(0,Ce.jsx)(h,{icon:$,className:"text-sky-400 ml-2","aria-hidden":"true"}):""]}),Oe(t.last_run_delta)]})]})},t.uuid||r))}),j&&(0,Ce.jsx)("div",{className:"flex justify-center p-4",children:(0,Ce.jsx)("button",{className:"px-6 py-2.5 bg-solar-600 dark:bg-trusty-blue/30 border border-solar-600 dark:border-trusty-blue/50 rounded-full text-xs text-white font-bold uppercase tracking-widest hover:bg-solar-700 dark:hover:bg-trusty-blue/40 hover:border-solar-700 dark:hover:border-trusty-blue/60 transition shadow-sm disabled:opacity-70 disabled:cursor-not-allowed flex items-center gap-2",onClick:()=>p(!x),"aria-expanded":x,"aria-controls":"questions-list",children:x?"Show Less":`Show ${l.length-10} More`})})]})}function Le({project:e,cluster:t,category:a,setCategory:r,subcategory:s,setSubcategory:i}){return t&&0!==Object.keys(t).length&&e&&0!==Object.keys(e).length?(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)(ae,{triggerId:"category-select-visibility",children:(0,Ce.jsx)(oe,{categoryGroups:t.category_groups||[],category:a,setCategory:r,subcategory:s,setSubcategory:i,hideCategory:!0})}),(0,Ce.jsx)("section",{id:"category-select-visibility",className:"bg-white dark:bg-[#050a24]/80 border border-black/5 dark:border-white/10 rounded-2xl shadow-sm dark:shadow-2xl dark:backdrop-blur-xl mb-4",children:(0,Ce.jsx)(oe,{categoryGroups:t.category_groups||[],category:a,setCategory:r,subcategory:s,setSubcategory:i,hideCategory:!0})}),(0,Ce.jsxs)("section",{className:"page-section-3",children:[(0,Ce.jsx)("h2",{className:"section-header-2",children:"All"===a?"Branded AI Visibility":`AI Visibility: ${a}`}),(0,Ce.jsx)(Se,{category:a,subcategory:s,setCategory:r,setSubcategory:i,data:t?.ai_visibility_metrics,currentViz:e?.ai_visibility_score}),(0,Ce.jsx)("div",{className:"flex flex-col",children:(0,Ce.jsx)("div",{className:"flex-1",children:(0,Ce.jsx)(Ae,{category:a,cluster:t})})})]}),(0,Ce.jsx)("section",{className:"page-section-3",children:(0,Ce.jsx)(Te,{uuid:e?.uuid,category:a,subcategory:s,name:e?.name})})]}):null}var $e={};!function e(t,a,r,s){var i=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),o="function"==typeof Path2D&&"function"==typeof DOMMatrix,n=function(){if(!t.OffscreenCanvas)return!1;try{var e=new OffscreenCanvas(1,1),a=e.getContext("2d");a.fillRect(0,0,1,1);var r=e.transferToImageBitmap();a.createPattern(r,"no-repeat")}catch(s){return!1}return!0}();function l(){}function c(e){var r=a.exports.Promise,s=void 0!==r?r:t.Promise;return"function"==typeof s?new s(e):(e(l,l),null)}var d,u,h,m,x,p,b,g,f,y,j,v=(d=n,u=new Map,{transform:function(e){if(d)return e;if(u.has(e))return u.get(e);var t=new OffscreenCanvas(e.width,e.height);return t.getContext("2d").drawImage(e,0,0),u.set(e,t),t},clear:function(){u.clear()}}),k=(x=Math.floor(1e3/60),p={},b=0,"function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(h=function(e){var t=Math.random();return p[t]=requestAnimationFrame(function a(r){b===r||b+x-1<r?(b=r,delete p[t],e()):p[t]=requestAnimationFrame(a)}),t},m=function(e){p[e]&&cancelAnimationFrame(p[e])}):(h=function(e){return setTimeout(e,x)},m=function(e){return clearTimeout(e)}),{frame:h,cancel:m}),w=(y={},function(){if(g)return g;if(!r&&i){var t=["var CONFETTI, SIZE = {}, module = {};","("+e.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {"," if (msg.data.options) {"," CONFETTI(msg.data.options).then(function () {"," if (msg.data.callback) {"," postMessage({ callback: msg.data.callback });"," }"," });"," } else if (msg.data.reset) {"," CONFETTI && CONFETTI.reset();"," } else if (msg.data.resize) {"," SIZE.width = msg.data.resize.width;"," SIZE.height = msg.data.resize.height;"," } else if (msg.data.canvas) {"," SIZE.width = msg.data.canvas.width;"," SIZE.height = msg.data.canvas.height;"," CONFETTI = module.exports.create(msg.data.canvas);"," }","}"].join("\n");try{g=new Worker(URL.createObjectURL(new Blob([t])))}catch(a){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("ð Could not load worker",a),null}!function(e){function t(t,a){e.postMessage({options:t||{},callback:a})}e.init=function(t){var a=t.transferControlToOffscreen();e.postMessage({canvas:a},[a])},e.fire=function(a,r,s){if(f)return t(a,null),f;var i=Math.random().toString(36).slice(2);return f=c(function(r){function o(t){t.data.callback===i&&(delete y[i],e.removeEventListener("message",o),f=null,v.clear(),s(),r())}e.addEventListener("message",o),t(a,i),y[i]=o.bind(null,{data:{callback:i}})})},e.reset=function(){for(var t in e.postMessage({reset:!0}),y)y[t](),delete y[t]}}(g)}return g}),N={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function _(e,t,a){return function(e,t){return t?t(e):e}(e&&null!=e[t]?e[t]:N[t],a)}function M(e){return e<0?0:Math.floor(e)}function C(e,t){return Math.floor(Math.random()*(t-e))+e}function S(e){return parseInt(e,16)}function A(e){return e.map(F)}function F(e){var t=String(e).replace(/[^0-9a-f]/gi,"");return t.length<6&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),{r:S(t.substring(0,2)),g:S(t.substring(2,4)),b:S(t.substring(4,6))}}function P(e){e.width=document.documentElement.clientWidth,e.height=document.documentElement.clientHeight}function I(e){var t=e.getBoundingClientRect();e.width=t.width,e.height=t.height}function O(e){var t=e.angle*(Math.PI/180),a=e.spread*(Math.PI/180);return{x:e.x,y:e.y,wobble:10*Math.random(),wobbleSpeed:Math.min(.11,.1*Math.random()+.05),velocity:.5*e.startVelocity+Math.random()*e.startVelocity,angle2D:-t+(.5*a-Math.random()*a),tiltAngle:(.5*Math.random()+.25)
1*Math.PI,color:e.color,shape:e.shape,tick:0,totalTicks:e.ticks,decay:e.decay,drift:e.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:3*e.gravity,ovalScalar:.6,scalar:e.scalar,flat:e.flat}}function T(e,t){t.x+=Math.cos(t.angle2D)*t.velocity+t.drift,t.y+=Math.sin(t.angle2D)*t.velocity+t.gravity,t.velocity*=t.decay,t.flat?(t.wobble=0,t.wobbleX=t.x+10*t.scalar,t.wobbleY=t.y+10*t.scalar,t.tiltSin=0,t.tiltCos=0,t.random=1):(t.wobble+=t.wobbleSpeed,t.wobbleX=t.x+10*t.scalar*Math.cos(t.wobble),t.wobbleY=t.y+10*t.scalar*Math.sin(t.wobble),t.tiltAngle+=.1,t.tiltSin=Math.sin(t.tiltAngle),t.tiltCos=Math.cos(t.tiltAngle),t.random=Math.random()+2);var a=t.tick++/t.totalTicks,r=t.x+t.random*t.tiltCos,s=t.y+t.random*t.tiltSin,i=t.wobbleX+t.random*t.tiltCos,n=t.wobbleY+t.random*t.tiltSin;if(e.fillStyle="rgba("+t.color.r+", "+t.color.g+", "+t.color.b+", "+(1-a)+")",e.beginPath(),o&&"path"===t.shape.type&&"string"==typeof t.shape.path&&Array.isArray(t.shape.matrix))e.fill(function(e,t,a,r,s,i,o){var n=new Path2D(e),l=new Path2D;l.addPath(n,new DOMMatrix(t));var c=new Path2D;return c.addPath(l,new DOMMatrix([Math.cos(o)*s,Math.sin(o)*s,-Math.sin(o)*i,Math.cos(o)*i,a,r])),c}(t.shape.path,t.shape.matrix,t.x,t.y,.1*Math.abs(i-r),.1*Math.abs(n-s),Math.PI/10*t.wobble));else if("bitmap"===t.shape.type){var l=Math.PI/10*t.wobble,c=.1*Math.abs(i-r),d=.1*Math.abs(n-s),u=t.shape.bitmap.width*t.scalar,h=t.shape.bitmap.height*t.scalar,m=new DOMMatrix([Math.cos(l)*c,Math.sin(l)*c,-Math.sin(l)*d,Math.cos(l)*d,t.x,t.y]);m.multiplySelf(new DOMMatrix(t.shape.matrix));var x=e.createPattern(v.transform(t.shape.bitmap),"no-repeat");x.setTransform(m),e.globalAlpha=1-a,e.fillStyle=x,e.fillRect(t.x-u/2,t.y-h/2,u,h),e.globalAlpha=1}else if("circle"===t.shape)e.ellipse?e.ellipse(t.x,t.y,Math.abs(i-r)*t.ovalScalar,Math.abs(n-s)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI):function(e,t,a,r,s,i,o,n,l){e.save(),e.translate(t,a),e.rotate(i),e.scale(r,s),e.arc(0,0,1,o,n,l),e.restore()}(e,t.x,t.y,Math.abs(i-r)*t.ovalScalar,Math.abs(n-s)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI);else if("star"===t.shape)for(var p=Math.PI/2*3,b=4*t.scalar,g=8*t.scalar,f=t.x,y=t.y,j=5,k=Math.PI/j;j--;)f=t.x+Math.cos(p)*g,y=t.y+Math.sin(p)*g,e.lineTo(f,y),p+=k,f=t.x+Math.cos(p)*b,y=t.y+Math.sin(p)*b,e.lineTo(f,y),p+=k;else e.moveTo(Math.floor(t.x),Math.floor(t.y)),e.lineTo(Math.floor(t.wobbleX),Math.floor(s)),e.lineTo(Math.floor(i),Math.floor(n)),e.lineTo(Math.floor(r),Math.floor(t.wobbleY));return e.closePath(),e.fill(),t.tick<t.totalTicks}function L(e,a){var o,n=!e,l=!!_(a||{},"resize"),d=!1,u=_(a,"disableForReducedMotion",Boolean),h=i&&_(a||{},"useWorker")?w():null,m=n?P:I,x=!(!e||!h)&&!!e.__confetti_initialized,p="function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion)").matches;function b(t,a,i){for(var n=_(t,"particleCount",M),l=_(t,"angle",Number),d=_(t,"spread",Number),u=_(t,"startVelocity",Number),h=_(t,"decay",Number),x=_(t,"gravity",Number),p=_(t,"drift",Number),b=_(t,"colors",A),g=_(t,"ticks",Number),f=_(t,"shapes"),y=_(t,"scalar"),j=!!_(t,"flat"),w=function(e){var t=_(e,"origin",Object);return t.x=_(t,"x",Number),t.y=_(t,"y",Number),t}(t),N=n,S=[],F=e.width*w.x,P=e.height*w.y;N--;)S.push(O({x:F,y:P,angle:l,spread:d,startVelocity:u,color:b[N%b.length],shape:f[C(0,f.length)],ticks:g,decay:h,gravity:x,drift:p,scalar:y,flat:j}));return o?o.addFettis(S):(o=function(e,t,a,i,o){var n,l,d=t.slice(),u=e.getContext("2d"),h=c(function(t){function c(){n=l=null,u.clearRect(0,0,i.width,i.height),v.clear(),o(),t()}n=k.frame(function t(){!r||i.width===s.width&&i.height===s.height||(i.width=e.width=s.width,i.height=e.height=s.height),i.width||i.height||(a(e),i.width=e.width,i.height=e.height),u.clearRect(0,0,i.width,i.height),(d=d.filter(function(e){return T(u,e)})).length?n=k.frame(t):c()}),l=c});return{addFettis:function(e){return d=d.concat(e),h},canvas:e,promise:h,reset:function(){n&&k.cancel(n),l&&l()}}}(e,S,m,a,i),o.promise)}function g(a){var r=u||_(a,"disableForReducedMotion",Boolean),s=_(a,"zIndex",Number);if(r&&p)return c(function(e){e()});n&&o?e=o.canvas:n&&!e&&(e=function(e){var t=document.createElement("canvas");return t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.pointerEvents="none",t.style.zIndex=e,t}(s),document.body.appendChild(e)),l&&!x&&m(e);var i={width:e.width,height:e.height};function g(){if(h){var t={getBoundingClientRect:function(){if(!n)return e.getBoundingClientRect()}};return m(t),void h.postMessage({resize:{width:t.width,height:t.height}})}i.width=i.height=null}function f(){o=null,l&&(d=!1,t.removeEventListener("resize",g)),n&&e&&(document.body.contains(e)&&document.body.removeChild(e),e=null,x=!1)}return h&&!x&&h.init(e),x=!0,h&&(e.__confetti_initialized=!0),l&&!d&&(d=!0,t.addEventListener("resize",g,!1)),h?h.fire(a,i,f):b(a,i,f)}return g.reset=function(){h&&h.reset(),o&&o.reset()},g}function $(){return j||(j=L(null,{useWorker:!0,resize:!0})),j}a.exports=function(){return $().apply(this,arguments)},a.exports.reset=function(){$().reset()},a.exports.create=L,a.exports.shapeFromPath=function(e){if(!o)throw new Error("path confetti are not supported in this browser");var t,a;"string"==typeof e?t=e:(t=e.path,a=e.matrix);var r=new Path2D(t),s=document.createElement("canvas").getContext("2d");if(!a){for(var i,n,l=1e3,c=l,d=l,u=0,h=0,m=0;m<l;m+=2)for(var x=0;x<l;x+=2)s.isPointInPath(r,m,x,"nonzero")&&(c=Math.min(c,m),d=Math.min(d,x),u=Math.max(u,m),h=Math.max(h,x));i=u-c,n=h-d;var p=Math.min(10/i,10/n);a=[p,0,0,p,-Math.round(i/2+c)*p,-Math.round(n/2+d)*p]}return{type:"path",path:t,matrix:a}},a.exports.shapeFromText=function(e){var t,a=1,r="#000000",s='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';"string"==typeof e?t=e:(t=e.text,a="scalar"in e?e.scalar:a,s="fontFamily"in e?e.fontFamily:s,r="color"in e?e.color:r);var i=10*a,o=i+"px "+s,n=new OffscreenCanvas(i,i),l=n.getContext("2d");l.font=o;var c=l.measureText(t),d=Math.ceil(c.actualBoundingBoxRight+c.actualBoundingBoxLeft),u=Math.ceil(c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),h=c.actualBoundingBoxLeft+2,m=c.actualBoundingBoxAscent+2;d+=4,u+=4,(l=(n=new OffscreenCanvas(d,u)).getContext("2d")).font=o,l.fillStyle=r,l.fillText(t,h,m);var x=1/a;return{type:"bitmap",bitmap:n.transferToImageBitmap(),matrix:[x,0,0,x,-d*x/2,-u*x/2]}}}(function(){return"undefined"!=typeof window?window:"undefined"!=typeof self?self:this||{}}(),$e,!1);var Ee=$e.exports,De=($e.exports.create,(e,t,a)=>{if(t)return"dark"===a?"#FFFFFF":"#000000";const r=e-1;return r<pe.length?pe[r]:`hsl(${47*r%360}, 70%, 50%)`});function ze({project_name:e,condition:t}){const{theme:a}=f(),{power_rankings:r}=t||{},s=(0,Me.useMemo)(()=>Object.entries(r||{}).sort((e,t)=>
1("number"==typeof e[1]?.rank?e[1].rank:Number.POSITIVE_INFINITY)-("number"==typeof t[1]?.rank?t[1].rank:Number.POSITIVE_INFINITY)),[r]);return 0===s.length?null:(0,Ce.jsx)("div",{className:"power-rankings-table p-4 pt-0 gap-4 text-xl columns-1 lg:columns-2 xl:columns-3 space-y-4",children:s.map(([t,r])=>{const{uuid:s,rank:i,data:n}=r||{};return(0,Ce.jsxs)(o,{to:`/project/${s}`,className:`relative grid grid-cols-[auto_1fr] gap-4 items-center rounded overflow-hidden border border-black/10 dark:border-white/15 ${t===e?"font-bold ring ring-deep-space/50 dark:ring-white/50":""} hover:bg-deep-space/10 dark:hover:bg-white/10 break-inside-avoid`,onMouseEnter:a=>{if(t===e){const e=a.clientX/window.innerWidth,t=a.clientY/window.innerHeight;Ee({origin:{x:e,y:t}})}},children:[(0,Ce.jsx)("div",{className:"min-w-14 grid place-content-center aspect-square font-mono font-bold text-center text-lg text-white",style:{backgroundColor:De(i,t===e,a),color:t===e&&"dark"===a?"#020021":"#FFFFFF",textShadow:t===e&&"dark"===a?"none":"-1px -1px 0 #020021, 1px -1px 0 #020021, -1px 1px 0 #020021, 1px 1px 0 #020021"},children:i}),(0,Ce.jsxs)("div",{className:"h-full flex items-center gap-2",children:[(0,Ce.jsx)("div",{className:"flex-1",children:t}),(0,Ce.jsx)("div",{className:"min-w-[75px] h-full p-1 text-2xl font-space font-bold border-l border-black/10 dark:border-white/15 rounded-r-sm text-center content-center bg-deep-space/10 dark:bg-white/10",style:{color:"dark"===a?"#FFFFFF":"#000000"},children:Array.isArray(n)&&n.length>0?Math.round(n[n.length-1]?.value??0)+"%":"N/A"})]})]},t)})})}function Ue({uuid:e,category:t,subcategory:a,name:r}){const{is_internal:i}=u(),{uuid:n}=s(),{questions:l,loading:c,error:d}=Pe(e,t,a,void 0,{enabled:!!e}),[h,m]=(0,Me.useState)(!1);if("All"===t)return null;if(c)return(0,Ce.jsxs)("div",{className:"p-4",role:"status","aria-live":"polite",children:[(0,Ce.jsxs)("h3",{className:"text-2xl font-bold mb-4",children:["All"!==a?a:t," Questions People Ask"]}),(0,Ce.jsxs)("div",{className:"p-8 bg-white/40 dark:bg-[#050a24]/40 border border-solar-200 dark:border-white/10 rounded-2xl backdrop-blur-sm text-center animate-pulse",children:[(0,Ce.jsx)("span",{className:"text-solar-600 dark:text-blue-300 font-space tracking-widest text-sm uppercase",children:"Loading Questions..."}),(0,Ce.jsx)("span",{className:"sr-only",children:"Loading questions, please wait."})]})]});if(d)return(0,Ce.jsxs)("div",{role:"alert",className:"p-4 bg-red-900/20 border border-red-500/30 text-red-200 rounded-xl my-4",children:["Error loading questions: ",d.message]});if(0===l.length)return(0,Ce.jsx)(Ce.Fragment,{children:(0,Ce.jsxs)("div",{className:"p-4",children:[(0,Ce.jsxs)("h3",{className:"text-2xl font-bold mb-4",children:["All"!==a?a:t," Questions People Ask"]}),(0,Ce.jsx)("div",{className:"p-8 bg-white/40 dark:bg-[#050a24]/40 border border-solar-200 dark:border-white/10 rounded-2xl backdrop-blur-sm text-center",children:(0,Ce.jsx)("span",{className:"text-gray-500 font-space tracking-widest text-xs uppercase",children:"No active questions found for this segment"})})]})});const x=h?l:l.slice(0,10),p=l.length>10;return(0,Ce.jsxs)("section",{"aria-label":`${"All"!==a?a:t} Questions List`,children:[(0,Ce.jsx)("div",{className:"flex items-center justify-between gap-2 p-4",children:(0,Ce.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Ce.jsxs)("h3",{className:"text-2xl font-bold font-space",children:["All"!==a?a:t," Questions People Ask"]}),(0,Ce.jsxs)("div",{className:"text-xs font-bold text-solar-700 dark:text-blue-300 bg-solar-100 dark:bg-trusty-blue/20 border border-solar-200 dark:border-trusty-blue/40 px-3 py-1 rounded-full uppercase tracking-widest",children:[l.length," Questions"]}),i&&(0,Ce.jsx)(ge,{uuid:e,type:"condition",name:r,variant:"inline"})]})}),(0,Ce.jsx)("ul",{className:"p-4 flex flex-col gap-3",children:x.map((e,t)=>(0,Ce.jsx)("li",{className:"group relative rounded-2xl bg-white dark:bg-white/5 border border-solar-200 dark:border-white/10 shadow-sm hover:shadow-md hover:border-solar-300 dark:hover:border-trusty-blue/30 dark:hover:bg-white/10 transition-all duration-300",children:(0,Ce.jsx)(o,{to:`/project/ai-visibility/question/${n}/${e.uuid}`,className:"p-4 flex justify-between items-start gap-4",children:(0,Ce.jsx)("div",{className:"flex gap-4 items-start",children:(0,Ce.jsxs)("div",{children:[(0,Ce.jsx)("h4",{className:"text-lg font-medium text-deep-space dark:text-white/90 dark:group-hover:text-white transition-colors leading-tight",children:e.question}),"All"===a&&(0,Ce.jsx)("div",{className:"mt-2",children:(0,Ce.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[10px] font-bold uppercase tracking-widest bg-solar-50 dark:bg-trusty-blue/10 border border-solar-200 dark:border-trusty-blue/30 text-solar-600/60 dark:text-blue-400/60 group-hover:text-solar-700 dark:group-hover:text-blue-300 group-hover:bg-solar-100 dar
1k:group-hover:bg-trusty-blue/20 transition-colors",children:e.subcategory_name||"--"})})]})})})},e.uuid||t))}),p&&(0,Ce.jsx)("div",{className:"flex justify-center p-4",children:(0,Ce.jsx)("button",{className:"px-6 py-2.5 bg-solar-600 dark:bg-trusty-blue/30 border border-solar-600 dark:border-trusty-blue/50 rounded-full text-xs text-white font-bold uppercase tracking-widest hover:bg-solar-700 dark:hover:bg-trusty-blue/40 hover:border-solar-700 dark:hover:border-trusty-blue/60 transition shadow-sm disabled:opacity-70 disabled:cursor-not-allowed flex items-center gap-2",onClick:()=>m(!h),"aria-expanded":h,"aria-controls":"questions-list",children:h?"Show Less":`Show ${l.length-10} More`})})]})}function Re({project:e}){const{sov_breakdown:t={},conditions:a=[]}=e||{},r=(0,Me.useMemo)(()=>{const t=a?.map(e=>e.name)||[];if(e?.primary_condition){const r=a?.find(t=>t.uuid===e.primary_condition);if(r)return[r.name,...t.filter(e=>e!==r.name)]}return t},[a,e]),[s,i]=(0,Me.useState)(r[0]||""),o=a?.find(e=>e.name===s)||a?.[0],[n,l]=(0,Me.useState)("Condition Awareness"),[c,d]=(0,Me.useState)("All"),u=Object.keys(t?.overall||{}).length;return(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)(ae,{triggerId:"category-select-power-rankings",children:(0,Ce.jsx)(oe,{categoryGroups:t?.category_groups,category:n,setCategory:l,subcategory:c,setSubcategory:d,hideCategory:!0,omitAllOption:!0})}),(0,Ce.jsx)("section",{id:"category-select-power-rankings",className:"bg-white dark:bg-[#050a24]/80 border border-black/5 dark:border-white/10 rounded-2xl shadow-sm dark:shadow-2xl dark:backdrop-blur-xl mb-6",children:(0,Ce.jsx)(oe,{categoryGroups:t?.category_groups,category:n,setCategory:l,subcategory:c,setSubcategory:d,hideCategory:!0,omitAllOption:!0})}),(0,Ce.jsxs)("section",{className:"page-section-3",children:[(0,Ce.jsxs)("h2",{className:"section-header-2 flex gap-1",children:[u>1?(0,Ce.jsxs)("div",{className:"relative",children:[(0,Ce.jsxs)("div",{className:"relative",children:[(0,Ce.jsx)("label",{htmlFor:"condition-list",className:"underline underline-offset-2 cursor-pointer",children:s}),(0,Ce.jsx)(h,{icon:w,className:"pointer-events-none absolute right-1/2 -bottom-[11px] -translate-y-1/2 text-sm"})]}),(0,Ce.jsx)("select",{className:"absolute inset-0 opacity-0 cursor-pointer",name:"condition-list",id:"condition-list",value:s,onChange:e=>i(e.target.value),children:r.map(e=>(0,Ce.jsx)("option",{value:e,children:e},e))})]}):s,"Â Categories"]}),(a||[]).filter(e=>e.name===s).flatMap(t=>(0,Ce.jsxs)("div",{className:"",children:[(0,Ce.jsx)(xe,{id:"power-rankings",data:t?.power_rankings,project_name:e?.name,title:`${t?.name||""} Visibility Power Rankings`,subtitle:"AI Visibility Power Rankings by Condition Over Time",yAxisTitle:"AI Visibility Score"}),(0,Ce.jsx)(ze,{project_name:e?.name,condition:t})]},`${t.name}-power-rankings`))]}),(0,Ce.jsx)("section",{className:"page-section-3",children:o&&(0,Ce.jsx)(Ue,{uuid:o.uuid,category:n,subcategory:c,name:o.name})})]})}var qe=e(a());function Be({isOpen:e,onClose:t,conditions:a,primaryUuid:r,buildHref:s}){const i=(0,Me.useRef)(null),n=(0,Me.useRef)(null);(0,Me.useLayoutEffect)(()=>{const t=i.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]);return(0,qe.createPortal)((0,Ce.jsx)("dialog",{ref:i,closedby:"any",onMouseDown:e=>{n.current=e.target},onClick:e=>{n.current===i.current&&e.target===i.current&&t()},onClose:t,"aria-labelledby":"condition-choice-title",className:"p-0 rounded-2xl border border-solar-200 dark:border-white/10 bg-white dark:bg-deep-space shadow-2xl backdrop:bg-black/50 max-w-md w-[calc(100%-2rem)]","data-testid":"condition-choice-dialog",children:(0,Ce.jsxs)("div",{className:"p-6",children:[(0,Ce.jsxs)("div",{className:"flex items-start justify-between gap-4 mb-1",children:[(0,Ce.jsx)("h3",{id:"condition-choice-title",className:"text-base font-bold font-space text-deep-space dark:text-white",children:"Which condition?"}),(0,Ce.jsx)("button",{type:"button",onClick:t,className:"h-7 w-7 shrink-0 rounded-md flex items-center justify-center text-deep-space/40 dark:text-white/40 hover:text-deep-space dark:hover:text-white hover:bg-solar-50 dark:hover:bg-trusty-blue/10 transition-colors","aria-label":"Close dialog","data-testid":"condition-choice-close",children:(0,Ce.jsx)(h,{icon:D})})]}),(0,Ce.jsx)("p",{className:"text-sm font-space text-deep-space/60 dar
1k:text-white/50",children:"This brand tracks more than one condition. Pick the one to add a watchlist group for."}),(0,Ce.jsx)("ul",{className:"mt-4 space-y-1",children:a.map(e=>(0,Ce.jsx)("li",{children:(0,Ce.jsxs)(o,{to:s(e.uuid),onClick:t,className:"group flex items-center gap-3 rounded-lg px-3 py-2.5 border border-transparent hover:border-solar-200 dark:hover:border-trusty-blue/30 hover:bg-solar-50 dark:hover:bg-trusty-blue/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-solar-400 dark:focus-visible:ring-trusty-blue transition-colors","data-testid":"condition-choice-option",children:[e.image?(0,Ce.jsx)("img",{src:e.image,alt:"",loading:"lazy",className:"h-9 w-9 shrink-0 rounded-lg object-cover bg-solar-50 dark:bg-white/5","data-testid":"condition-choice-image"}):(0,Ce.jsx)("span",{"aria-hidden":"true",className:"h-9 w-9 shrink-0 rounded-lg grid place-items-center bg-solar-50 dark:bg-white/5 text-sm font-bold font-space text-deep-space/40 dark:text-white/40","data-testid":"condition-choice-image-fallback",children:e.name?.charAt(0)?.toUpperCase()??"?"}),(0,Ce.jsxs)("span",{className:"flex-1 font-karla text-deep-space dark:text-white",children:[e.name,e.uuid===r&&(0,Ce.jsx)("span",{className:"ml-2 text-[10px] font-space font-bold uppercase tracking-widest text-solar-700 dark:text-blue-400",children:"Primary"})]}),(0,Ce.jsx)(h,{icon:B,className:"text-xs opacity-0 group-hover:opacity-60 group-focus-visible:opacity-60 transition-opacity text-deep-space dark:text-white","aria-hidden":"true"})]})},e.uuid))})]})}),document.body)}var Ve=e=>`color-mix(in srgb, #020021, #0561B7 ${e}%)`,We=[{min:0,bgLight:"#fff7ed",bgDark:Ve(8),text:"text-orange-700 dark:text-blue-300/60"},{min:5,bgLight:"#ffedd5",bgDark:Ve(15),text:"text-orange-700 dark:text-blue-300"},{min:15,bgLight:"#fed7aa",bgDark:Ve(25),text:"text-orange-800 dark:text-blue-200"},{min:30,bgLight:"#fdba74",bgDark:Ve(40),text:"text-orange-900 dark:text-blue-100"},{min:45,bgLight:"#fb923c",bgDark:Ve(55),text:"text-deep-space dark:text-white"},{min:60,bgLight:"#f97316",bgDark:Ve(70),text:"text-deep-space dark:text-white"},{min:75,bgLight:"#ea580c",bgDark:Ve(85),text:"text-deep-space dark:text-white"},{min:85,bgLight:"#dc2626",bgDark:Ve(100),text:"text-white"}],He=(e,t)=>`/watchlist/${e}${t?`?project=${t}`:""}`,Qe="font-semibold text-trusty-blue dark:text-blue-400 underline underline-offset-2 hover:text-solar-600 dark:hover:text-blue-300";function Ge({conditions:e,primaryUuid:t,orgProjectUuid:a,testId:r,children:s}){const[i,n]=(0,Me.useState)(!1);return 0===e.length?null:1===e.length?(0,Ce.jsx)(o,{to:He(e[0].uuid,a),className:Qe,"data-testid":r,children:s}):(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)("button",{type:"button",onClick:()=>n(!0),className:Qe,"data-testid":r,children:s}),(0,Ce.jsx)(Be,{isOpen:i,onClose:()=>n(!1),conditions:e,primaryUuid:t,buildHref:e=>He(e,a)})]})}var Ke=e=>({"--cell-bg-light":e.bgLight,"--cell-bg-dark":e.bgDark});function Ye({pct:e}){const t=(e=>{let t=We[0];for(const a of We)e>=a.min&&(t=a);return t})(e);return(0,Ce.jsx)("td",{className:"p-1",children:(0,Ce.jsxs)("div",{className:`summary-heat-cell rounded-lg px-3 py-2.5 text-center text-sm font-bold font-karla transition-colors ${t.text}`,style:Ke(t),"data-testid":"summary-heat-cell",children:[Math.round(e),"%"]})})}function Ze({group:e,columns:t,orgProjectUuid:a}){const r=Array.isArray(e?.metrics)?e.metrics:[],s=Math.max(0,...r.map(e=>e.questions_total??0)),i=new Map(r.map(e=>[e.assistant,e])),n=(e,a)=>(0,Ce.jsxs)("tr",{"data-testid":`summary-${a}-row`,children:["Mentions"===e&&(0,Ce.jsx)("td",{rowSpan:2,className:"p-1 align-middle","data-testid":"summary-prompts-tracked",children:(0,Ce.jsx)("div",{className:"rounded-xl border border-solar-100 dark:border-white/10 bg-solar-50/50 dark:bg-white/[0.04] px-3 py-4 text-center text-2xl font-bold font-space text-deep-space dark:text-white",children:s.toLocaleString()})}),(0,Ce.jsx)("th",{scope:"row",className:"p-1 pr-3 text-xs font-bold font-space uppercase tracking-widest text-deep-space/60 dark:text-white/50 whitespace-nowrap text-left",children:e}),t.map(e=>{const t=i.get(e.key);return t?(0,Ce.jsx)(Ye,{pct:t[a]??0},e.key):(0,Ce.jsx)("td",{className:"p-1 text-center text-sm text-deep-space/30 dark:text-white/30",children:"â"},e.key)})]});return(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)("tr",{children:(0,Ce.jsx)("td",{colSpan:t.length+2,className:"pt-5 pb-1 px-1 text-sm font-bold font-space uppercase tracking-widest text-deep-space dark:text-white","data-testid":"summary-group-name",children:e.group_uuid?(0,Ce.jsxs)(o,{to:ye({orgProjectUuid:a,groupUuid:e.group_uuid}
1),className:"group/link inline-flex items-center gap-1.5 rounded hover:text-solar-700 dark:hover:text-blue-300 hover:underline underline-offset-4 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solar-600 dark:focus-visible:outline-trusty-blue transition-colors",title:`View ${e.group_name} questions in Question Universe`,"data-testid":"summary-group-link",children:[e.group_name,(0,Ce.jsx)(h,{icon:z,className:"text-[9px] opacity-0 group-hover/link:opacity-60 group-focus-visible/link:opacity-60 transition-opacity","aria-hidden":"true"})]}):e.group_name})}),n("Mentions","mentions_pct"),n("Citations","citations_pct")]})}function Xe({conditions:e,primaryUuid:t,orgProjectUuid:a,canManageWatchlist:r}){const s=fe.map(e=>ke.get(e)??{key:e,label:we(e),icon:null}),i=e=>(0,Ce.jsxs)("tr",{children:["Mentions"===e&&(0,Ce.jsx)("td",{rowSpan:2,className:"p-1 align-middle",children:(0,Ce.jsx)("div",{className:"rounded-xl border border-dashed border-solar-100 dark:border-white/10 bg-solar-50/50 dark:bg-white/[0.04] px-3 py-4 text-center text-2xl font-bold font-space text-deep-space/60 dark:text-white/50",children:"--"})}),(0,Ce.jsx)("th",{scope:"row",className:"p-1 pr-3 text-xs font-bold font-space uppercase tracking-widest text-deep-space/60 dark:text-white/50 whitespace-nowrap text-left",children:e}),s.map(e=>(0,Ce.jsx)("td",{className:"p-1",children:(0,Ce.jsx)("div",{className:"rounded-lg h-9 bg-solar-50 dark:bg-white/[0.06]","aria-hidden":"true"})},e.key))]});return(0,Ce.jsxs)("div",{className:"space-y-2","data-testid":"summary-ghost-table",children:[(0,Ce.jsxs)("div",{children:[(0,Ce.jsx)("h3",{className:"text-2xl font-bold font-space text-deep-space dark:text-white",children:"Condition AI Visibility"}),(0,Ce.jsx)("p",{className:"mt-1 text-sm font-space text-deep-space/50 dark:text-white/50",children:"AI visibility across groups and models"})]}),(0,Ce.jsx)("div",{className:"overflow-x-auto rounded-2xl border border-dashed border-solar-200/70 dark:border-white/10 bg-white dark:bg-deep-space p-4",children:(0,Ce.jsxs)("table",{className:"w-full border-separate border-spacing-0",children:[(0,Ce.jsx)("thead",{children:(0,Ce.jsxs)("tr",{children:[(0,Ce.jsxs)("th",{scope:"col",className:"p-1 text-xs font-bold font-space uppercase tracking-widest text-deep-space/60 dark:text-white/50 text-center whitespace-nowrap",children:["Prompts",(0,Ce.jsx)("br",{}),"Tracked"]}),(0,Ce.jsx)("th",{scope:"col",className:"p-1 pr-3 text-xs font-bold font-space uppercase tracking-widest text-deep-space/60 dark:text-white/50 text-left",children:"Metric"}),s.map(e=>(0,Ce.jsx)("th",{scope:"col",className:"p-1 min-w-24",children:(0,Ce.jsxs)("div",{className:"flex items-center justify-center gap-1.5 text-sm font-semibold font-space text-deep-space dark:text-white",children:[e.icon&&(0,Ce.jsx)("img",{src:e.icon,alt:"",className:`w-5 h-5 shrink-0 grayscale opacity-60 ${e.iconClass??""}`}),(0,Ce.jsx)("span",{className:"whitespace-nowrap",children:e.label})]})},e.key))]})}),(0,Ce.jsx)("tbody",{children:[0,1].map(e=>(0,Ce.jsxs)(Me.Fragment,{children:[(0,Ce.jsx)("tr",{children:(0,Ce.jsx)("td",{colSpan:s.length+2,className:"pt-5 pb-1 px-1",children:(0,Ce.jsx)("div",{className:`h-3 ${0===e?"w-44":"w-32"} rounded bg-solar-100/70 dark:bg-white/10`,"aria-hidden":"true"})})}),i("Mentions"),i("Citations")]},e))})]})}),(0,Ce.jsxs)("p",{className:"text-sm font-space text-deep-space/70 dark:text-white/70",children:["Group-level visibility metrics will appear here once questions have been tracked.",r&&e.length>0&&(0,Ce.jsxs)(Ce.Fragment,{children:[" ","To start tracking, create a group on the"," ",(0,Ce.jsx)(Ge,{conditions:e,primaryUuid:t,orgProjectUuid:a,testId:"ghost-watchlist-link",children:"condition watchlist"}),".",(0,Ce.jsx)(Ne,{testId:"ghost-watchlist-guide-link"})]})]})]})}function Je({project:e,cluster:t}){const{uuid:a}=s(),{is_internal:r}=u(),i=!!r,{data:o,isLoading:n,error:l}=d({queryKey:["groupVisibility",a],queryFn:({signal:e})=>be.getGroupVisibility(a,e),enabled:!!a&&!!e&&!!t,staleTime:3e5});if(!t||0===Object.keys(t).length||!e||0===Object.keys(e).length)return null;if(n)return(0,Ce.jsxs)("section",{className:"py-16 text-center","data-testid":"summary-loading",children:[(0,Ce.jsx)(h,{icon:R,className:"text-solar-600 dar
1k:text-trusty-blue text-2xl animate-spin"}),(0,Ce.jsx)("p",{className:"mt-3 text-sm font-space text-deep-space/50 dark:text-white/50",children:"Loading visibility summaryâ¦"})]});if(l)return(0,Ce.jsxs)("section",{className:"py-16 text-center","data-testid":"summary-error",children:[(0,Ce.jsx)(h,{icon:U,className:"text-red-500 text-2xl"}),(0,Ce.jsx)("p",{className:"mt-3 text-sm font-space text-red-600 dark:text-red-400",children:"Failed to load the visibility summary. Please try again."})]});const c=(Array.isArray(o?.conditions)?o.conditions:[]).filter(e=>Array.isArray(e.groups)&&e.groups.length>0),m=(Array.isArray(e?.conditions)?e.conditions:[]).filter(e=>e?.uuid);if(0===c.length)return(0,Ce.jsxs)("section",{className:"space-y-8",children:[(0,Ce.jsx)(ve,{uuid:a}),(0,Ce.jsx)(Xe,{conditions:m,primaryUuid:e?.primary_condition,orgProjectUuid:a,canManageWatchlist:i})]});const x=new Set(c.flatMap(e=>e.groups.flatMap(e=>(Array.isArray(e?.metrics)?e.metrics:[]).map(e=>e?.assistant).filter(Boolean)))),p=je([...x]).map(e=>ke.get(e)??{key:e,label:we(e),icon:null});return(0,Ce.jsxs)("section",{className:"space-y-8","data-testid":"summary-tab",children:[(0,Ce.jsx)(ve,{uuid:a}),(0,Ce.jsxs)("div",{className:"space-y-4",children:[(0,Ce.jsx)("h3",{className:"text-2xl font-bold font-space text-deep-space dark:text-white",children:"Condition AI Visibility"}),(0,Ce.jsx)("p",{className:"text-sm font-space text-deep-space/50 dark:text-white/50",children:"AI visibility across groups and models"}),c.map(e=>(0,Ce.jsxs)("div",{className:"space-y-2",children:[c.length>1&&(0,Ce.jsx)("h4",{className:"text-lg font-bold font-space text-deep-space dark:text-white","data-testid":"summary-condition-name",children:e.condition_name}),(0,Ce.jsx)("div",{className:"overflow-x-auto rounded-2xl border border-solar-200 dark:border-white/10 bg-white dark:bg-deep-space p-4",children:(0,Ce.jsxs)("table",{className:"w-full border-separate border-spacing-0",children:[(0,Ce.jsx)("thead",{children:(0,Ce.jsxs)("tr",{children:[(0,Ce.jsxs)("th",{scope:"col",className:"p-1 text-xs font-bold font-space uppercase tracking-widest text-deep-space/60 dark:text-white/50 text-center whitespace-nowrap",children:["Prompts",(0,Ce.jsx)("br",{}),"Tracked"]}),(0,Ce.jsx)("th",{scope:"col",className:"p-1 pr-3 text-xs font-bold font-space uppercase tracking-widest text-deep-space/60 dark:text-white/50 text-left",children:"Metric"}),p.map(e=>(0,Ce.jsx)("th",{scope:"col",className:"p-1 min-w-24","data-testid":"summary-assistant-header",children:(0,Ce.jsxs)("div",{className:"flex items-center justify-center gap-1.5 text-sm font-semibold font-space text-deep-space dark:text-white",children:[e.icon&&(0,Ce.jsx)("img",{src:e.icon,alt:"",className:`w-5 h-5 shrink-0 ${e.iconClass??""}`}),(0,Ce.jsx)("span",{className:"whitespace-nowrap",children:e.label})]})},e.key))]})}),(0,Ce.jsx)("tbody",{children:e.groups.map(e=>(0,Ce.jsx)(Ze,{group:e,columns:p,orgProjectUuid:a},e.group_uuid??e.group_name))})]})})]},e.condition_name)),i&&m.length>0&&(0,Ce.jsxs)("p",{className:"text-sm font-space text-deep-space/70 dark:text-white/70",children:["To track additional prompts, create another group on the"," ",(0,Ce.jsx)(Ge,{conditions:m,primaryUuid:e?.primary_condition,orgProjectUuid:a,testId:"summary-watchlist-link",children:"condition watchlist"}),".",(0,Ce.jsx)(Ne,{testId:"summary-watchlist-guide-link"})]})]}),(0,Ce.jsxs)("div",{className:"flex flex-col md:flex-row gap-4 md:items-center md:justify-between",children:[(0,Ce.jsxs)("div",{className:"rounded-xl border border-solar-200 dark:border-white/10 p-4 w-fit","data-testid":"summary-legend",children:[(0,Ce.jsx)("p",{className:"text-xs font-bold font-space uppercase tracking-widest text-deep-space/60 dark:text-white/50 mb-2",children:"Relative Volume"}),(0,Ce.jsx)("div",{className:"flex items-center gap-1",children:We.map(e=>(0,Ce.jsx)("span",{className:"summary-heat-cell w-8 h-4 rounded",style:Ke(e)},e.min))}),(0,Ce.jsx)("p",{className:"mt-2 text-xs font-space text-deep-space/50 dark:text-white/50",children:"Darker = Higher volume / visibility â"})]}),(0,Ce.jsx)("p",{className:"text-xs font-space text-deep-space/50 dark:text-white/50 max-w-md",children:"Core metrics: Mentions (visibility) and Citations (source usage). Higher values indicate greater visibility or citation activity."})]})]})}var et=e(G());function tt({labels:e,colorMap:t,hidden:a,onToggle:r}){return(0,Ce.jsx)("div",{className:"inline-flex flex-wrap items-center justify-center gap-x-1 gap-y-1 px-1.5 py-1.5 rounded-2xl border border-black/10 dark:border-white/10 bg-white/50 dark:bg-[#050a24]/60 backdrop-blur-sm mx-auto",children:e.map(e=>(0,Ce.jsxs)("button",{type:"button",onClick:()=>r(e),className:W("flex items-center gap-1.5 text-sm font-medium font-karla cursor-pointer","rounded-xl px-3 py-1 transition-all duration-150","hover:bg-black/5 dark:hover:bg-white/10",a.has(e)&&"opacity-30 line-through"),children:[(0,Ce.jsx)("span",{className:"w-3 h-3 rounded-full inline-block shrink-0 dark:ring-1 dark:ring-white",style:{backgroundColor:t[e]}}),(0,Ce.jsx)("span",{className:"whitespace-nowrap",children:e})]},e))})}var at=(0,Me.memo)(({name:e,data:t,category:a,setCategory:r,subcategory:s,setSubcategory:i})=>{const{theme:o}=f(),{subcategory_bar_charts:n,subcategory_pie_charts:l}=t||{},c=(l?.[a]?.map(e=>e.name).filter(e=>"All"!==e&&"Category Total"!==e).sort((e,t)=>
1"All"===a?K.indexOf(e)-K.indexOf(t):e.localeCompare(t)))?.findIndex(e=>e===s),d="All"===a?"dark"===o?"#ff3c6d":"#ef4444":pe[c??0],u=(0,Me.useMemo)(()=>le(l,a),[l,a]),h="All"!==s?s:e,m=(0,Me.useMemo)(()=>ue(h,u,"#fed7aa","#c2410c",o,d),[u,o,h,d]),[x,p]=(0,Me.useState)(new Set),b=(0,Me.useCallback)(e=>{p(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a}),de({name:e})},[]),g=(0,Me.useMemo)(()=>n&&0!==Object.keys(n).length?function(e,t,a,r,s,i){const{isAll:o,xCategories:n,barSeries:l}=ne(t,s),c=l.sort((e,t)=>K.indexOf(e.name)-K.indexOf(t.name)).map(e=>({...e,color:i[e.name]??e.color,cursor:K.includes(e.name)?"pointer":"default",type:"column"})),d=c.find(t=>t.name===e),u=c.filter(t=>t.name!==e),h=d?{...d,type:"spline",color:i[e],marker:{enabled:!0,radius:3},enableMouseTracking:!0}:null,m=h?[...u,h]:u,x=n.map(e=>Y(e).month),p=n.map(e=>{const{month:t,year:a}=Y(e);return[t,a].filter(Boolean).join(" ")});return{gui:{layouts:[{rows:[{cells:[{id:"universe-bar-cell"}]}]}]},components:[{type:"Highcharts",cell:"universe-bar-cell",chartOptions:{chart:{height:400,marginTop:4,styledMode:!1,events:{load(){se.bar=this}}},title:{text:null},xAxis:{categories:x,labels:{enabled:!0}},yAxis:{min:0,title:{text:"Interest"},stackLabels:{enabled:!0,y:-4,style:{textOutline:"none",fontWeight:"bold"},formatter(){return J(this.total,0)}}},legend:{enabled:!1,itemStyle:{fontSize:"14px"}},tooltip:{formatter(){const e=`<span style="color:${this.color};">â </span>`,t=p[this.point?.index]??"";return`${t?`<b>${t}</b><br>`:""}${e}<b>${this.series.name}</b><br><b>Search Volume:</b> ${et.default.numberFormat(this.y,0)}`},useHTML:!0},plotOptions:{column:{stacking:"normal",stackLabels:{enabled:!0}},series:{animation:!1,events:{mouseOver(){"spline"!==this.type&&he(this.name,"bar","hover",!0)},mouseOut(){"spline"!==this.type&&he(this.name,"bar","",!0)},click(){if(!o||"spline"!==this.type&&K.includes(this.name))return o&&"function"==typeof a&&a(this.name),o||"function"!=typeof r||r(this.name),!1}}}},series:m}}]}}(e,n,r,i,a,m):null,[o,n,a,m,h]),y=(0,Me.useMemo)(()=>l&&0!==Object.keys(l).length?function(e,t,a,r,s,i){const o=ie(t),n=o?Object.entries(e).sort(([e],[t])=>K.indexOf(e)-K.indexOf(t)).map(([e,t])=>{const a=(t||[]).find(e=>"Category Total"===e.name);return a?{name:e,y:a.y??0,color:i[e],cursor:K.includes(e)?"pointer":"default"}:null}).filter(Boolean):(e[t]||[]).filter(e=>"Category Total"!==e.name).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({name:e.name,y:e.y??0,color:i[e.name],cursor:K.includes(e.name)?"pointer":"default"}));return{gui:{layouts:[{rows:[{cells:[{id:"universe-pie-cell"}]}]}]},components:[{type:"Highcharts",cell:"universe-pie-cell",chartOptions:{chart:{type:"pie",height:400,styledMode:!1,events:{load(){se.pie=this},mouseOut(){this.tooltip?.hide(0)}}},title:{text:null},tooltip:{borderRadius:6,style:{fontSize:"1rem"},formatter(){return`<b>${this.point.name}</b>: ${et.default.numberFormat(this.y,0)}</br>\n <b>Percentage:</b> ${et.default.numberFormat(this.percentage,2)}%`},outside:!0,useHTML:!0},legend:{enabled:!1},plotOptions:{series:{animation:!1,states:{inactive:{opacity:.25},hover:{halo:{size:0}}}},pie:{allowPointSelect:!0,showInLegend:!0,dataLabels:{enabled:!1},point:{events:{click(){if(!o||K.includes(this.name))return o&&"function"==typeof a&&a(this.name),o||"function"!=typeof r||r(this.name),!1},mouseOver(){this.series.chart.tooltip?.shared&&this.series.chart.tooltip.hide(0),he(this.name,"pie","hover")},mouseOut(){he(this.name,"pie","")}}}}},series:[{name:o?"Category Totals":t,type:"pie",data:n,dataLabels:{enabled:!1}}]}}]}}(l,a,r,i,0,m):null,[o,l,a,m,h]);return n&&0!==Object.keys(n).length&&l&&0!==Object.keys(l).length?(0,Ce.jsxs)("div",{className:"grid grid-cols-[25%_1fr] md:grid-cols-[35%_1fr] grid-rows-[auto_400px] overflow-hidden",children:[(0,Ce.jsx)("div",{className:"col-span-full text-center mb-4",children:(0,Ce.jsx)(tt,{labels:u,colorMap:m,hidden:x,onToggle:b})}),(0,Ce.jsx)(X,{className:"col-span-full lg:col-span-1",config:y,id:"cluster-feed-branded-pie-container"}),(0,Ce.jsx)(X,{className:"hidden lg:block",config:g,id:"cluster-feed-branded-bar-container"})]}):(0,Ce.jsx)("p",{className:"min-h-[450px] px-4 py-8 font-bold grid place-content-center",children:"Branded keyword data is not available."})});function rt({data:e,category:t,subcategory:a,projectName:r,organizationName:s}){if("All"===t)return null;if(!e||0===e.length)return(0,Ce.jsx)(re,{title:"No Observations",message:"There are no search observations available for this category yet."});const i=e.length>0&&"object"==typeof e[0]&&e[0].observation;return(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)("hr",{className:"grad-divider my-8"}),(0,Ce.jsxs)("section",{"aria-label":"Observations List",children:[(0,Ce.jsxs)("div",{className:"flex items-center justify-between px-4",children:[(0,Ce.jsx)("h3",{className:"text-2xl font-bold",children:"People Are Looking For"}),(0,Ce.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Ce.jsx)(it,{category:t,subcategory:a,projectName:r,organizationName:s}),(0,Ce.jsxs)("div",{className:"text-xs font-bold text-solar-700 dark:text-solar-300 bg-solar-100 dar
1k:bg-solar-900/30 border border-solar-200 dark:border-solar-700/40 px-3 py-1 rounded-full uppercase tracking-widest",children:[e.length," Observations"]})]})]}),(0,Ce.jsx)("ul",{className:"p-4 flex flex-col gap-3",children:e.map((e,t)=>{const a=i?e.observation:e,r=i?e.keywords:[];return(0,Ce.jsx)(st,{observation:a,keywords:r},`${a}-${t}`)})})]})]})}function st({observation:e,keywords:t}){const[a,r]=(0,Me.useState)(!1),s=t&&t.length>0,i=a?t:t.slice(0,5),n=t.length-5;return(0,Ce.jsx)("li",{className:"relative p-4 rounded-xl bg-white dark:bg-[#050a24]/40 border border-black/10 dark:border-white/10 transition-all duration-300 ease-in-out",children:(0,Ce.jsxs)("div",{className:"flex gap-4 items-start",children:[(0,Ce.jsx)("div",{className:"mt-1 w-8 h-8 shrink-0 flex items-center justify-center rounded-lg bg-solar-100 dark:bg-solar-900/30 text-solar-600 dark:text-solar-400 border border-solar-200 dark:border-solar-700/40",children:(0,Ce.jsx)(h,{icon:m,className:"text-sm","aria-hidden":"true"})}),(0,Ce.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Ce.jsx)("h4",{className:"text-lg font-medium text-deep-space dark:text-white/90 leading-relaxed",children:e}),s&&(0,Ce.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2 items-center",children:[i.map(e=>(0,Ce.jsxs)(o,{to:`/keyword-profile/${e.uuid}`,className:"group inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium bg-solar-50 dark:bg-solar-900/20 border border-solar-200 dark:border-solar-700/30 text-deep-space/70 dark:text-white/70 hover:bg-solar-100 dark:hover:bg-solar-900/40 hover:border-solar-300 transition-all duration-200",children:[(0,Ce.jsx)("span",{className:"truncate max-w-[200px]",children:e.value}),(0,Ce.jsx)("span",{className:"text-solar-600 dark:text-solar-400 font-semibold shrink-0",children:J(e.volume)})]},e.uuid)),!a&&n>0&&(0,Ce.jsxs)("button",{onClick:()=>r(!0),className:"inline-flex items-center gap-1 px-3 py-1 rounded-full text-xs font-semibold text-solar-700 dark:text-solar-300 bg-solar-50 dark:bg-solar-900/20 border border-solar-200 dark:border-solar-700/30 hover:bg-solar-100 dark:hover:bg-solar-900/40 transition-all duration-200 cursor-pointer",children:["+",n," more",(0,Ce.jsx)(h,{icon:M,className:"text-[10px]"})]}),a&&n>0&&(0,Ce.jsxs)("button",{onClick:()=>r(!1),className:"inline-flex items-center gap-1 px-3 py-1 rounded-full text-xs font-semibold text-solar-700 dark:text-solar-300 bg-solar-50 dark:bg-solar-900/20 border border-solar-200 dark:border-solar-700/30 hover:bg-solar-100 dark:hover:bg-solar-900/40 transition-all duration-200 cursor-pointer",children:["Show less",(0,Ce.jsx)(h,{icon:v,className:"text-[10px]"})]})]})]})]})})}function it({category:e,subcategory:t,projectName:a,organizationName:r}){const s=i(),o=new URLSearchParams;o.set("type","Brand Project"),r&&o.set("organization",r),a&&o.set("project",a),e&&o.set("category",e),t&&o.set("subcategory",t);return(0,Ce.jsxs)("button",{onClick:()=>{s(`/keyword-universe?${o.toString()}`)},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-solar-700 dark:text-solar-300 bg-solar-50 dark:bg-solar-900/20 border border-solar-200 dark:border-solar-700/30 hover:bg-solar-100 dark:hover:bg-solar-900/40 hover:border-solar-300 dark:hover:border-solar-700/50 transition-all duration-200 cursor-pointer",children:["Keyword Universe",(0,Ce.jsx)(h,{icon:P,className:"text-[10px]"})]})}function ot({data:e,category:t,project:a}){return e&&0!==e.length&&"All"!==t?(0,Ce.jsx)(Ce.Fragment,{children:(0,Ce.jsxs)("section",{"aria-label":"Recommendations List",children:[(0,Ce.jsxs)("div",{className:"flex items-center justify-between px-4 mt-8 mb-4",children:[(0,Ce.jsx)("h3",{className:"text-2xl font-bold",children:"Recommendations"}),(0,Ce.jsxs)("div",{className:"text-xs font-bold text-solar-700 dark:text-solar-300 bg-solar-100 dark:bg-solar-900/30 border border-solar-200 dark:border-solar-700/40 px-3 py-1 rounded-full uppercase tracking-widest",children:[e.length," Recommendations"]})]}),(0,Ce.jsx)("ul",{className:"p-4 pt-0 flex flex-col gap-3",children:e?.map((e,t)=>(0,Ce.jsx)("li",{className:"relative p-4 rounded-xl bg-white dark:bg-[#050a24]/40 border border-black/10 dark:border-white/10 transition-all duration-300 ease-in-out",children:(0,Ce.jsx)("div",{className:"flex justify-between items-start gap-4",children:(0,Ce.jsxs)("div",{className:"flex gap-4 items-start w-full",children:[(0,Ce.jsx)("div",{className:"mt-1 w-8 h-8 shrink-0 flex items-center justify-center rounded-lg bg-yellow-500/10 text-yellow-500 border border-yellow-500/20",children:(0,Ce.jsx)(h,{icon:x,className:"text-sm","aria-hidden":"true"})}),(0,Ce.jsxs)("div",{className:"w-full",children:[(0,Ce.jsx)("h4",{className:"text-lg font-medium text-deep-space dark:text-white/90 leading-relaxed mb-3",children:e?.text??""}),e.clusters?.length>0&&(0,Ce.jsx)("div",{className:"border-t border-deep-space/10 dar
1k:border-white/10 pt-3 mt-2",children:(0,Ce.jsx)("ul",{className:"grid gap-2",children:e.clusters?.map((e,t)=>(0,Ce.jsx)("li",{children:(0,Ce.jsxs)(o,{to:`/cluster/${a?.uuid}/${e?.uuid}/`,className:"flex items-center justify-between p-2 rounded bg-deep-space/5 dark:bg-white/5 hover:bg-deep-space/10 dark:hover:bg-white/10 transition-colors group",children:[(0,Ce.jsx)("span",{className:"font-medium",children:e.title}),(0,Ce.jsx)(h,{icon:V,className:"text-xs opacity-50 group-hover:opacity-100 transition-opacity"})]})},t))})})]})]})})},t))})]})}):null}var nt=["Awareness","Evaluation","Access & Affordability","Usage","Side Effects"];function lt({project:e,cluster:t,category:a,setCategory:r,subcategory:s,setSubcategory:i}){return t&&0!==Object.keys(t).length&&e&&0!==Object.keys(e).length?(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)(ae,{triggerId:"category-select-trends",children:(0,Ce.jsx)(oe,{categoryGroups:t.category_groups||[],category:a,setCategory:r,subcategory:s,setSubcategory:i,hideCategory:!0})}),(0,Ce.jsx)("section",{id:"category-select-trends",className:"bg-white dark:bg-[#050a24]/80 border border-black/5 dark:border-white/10 rounded-2xl shadow-sm dark:shadow-2xl dark:backdrop-blur-xl mb-6",children:(0,Ce.jsx)(oe,{categoryGroups:t.category_groups||[],category:a,setCategory:r,subcategory:s,setSubcategory:i,hideCategory:!0})}),(0,Ce.jsxs)("section",{className:"page-section-3",children:[(0,Ce.jsxs)("h2",{className:"section-header-2",children:[a," Interest"]}),(0,Ce.jsx)(at,{name:t.model_name||"",data:t.subcategory_charts_data||{},category:a,setCategory:r,subcategory:s,setSubcategory:i}),(0,Ce.jsx)(ce,{name:t.model_name||"",subcategory_search_trend:t.subcategory_charts_data?.subcategory_search_trend||{},subcategory_bar_charts:t.subcategory_charts_data?.subcategory_bar_charts||{},category:a,setCategory:r,subcategory:s,setSubcategory:i,showDivider:!0,showEmptyState:!1,categoryOrder:nt}),(0,Ce.jsx)(rt,{data:t.search_observations?.[a]||[],category:a,subcategory:s,projectName:e?.name,organizationName:e?.organization_name}),(0,Ce.jsx)(ot,{data:t.category_ai_rollup?.[a]?.recommendations||[],category:a,project:e})]})]}):null}var ct=["Condition Awareness","Symptoms","Diagnosis","Treatment","Living","Preventative"];function dt({project:e}){const{sov_breakdown:t,conditions:a}=e||{},r=[...a||[]];e.primary_condition&&r.sort((t,a)=>t.uuid===e.primary_condition?-1:a.uuid===e.primary_condition?1:0);const[s,i]=(0,Me.useState)("All"),[o,n]=(0,Me.useState)("All"),[l,c]=(0,Me.useState)(0),d=r[l];return d?(0,Ce.jsxs)("div",{children:[(0,Ce.jsx)("section",{id:"category-select-conditions",className:"bg-white dark:bg-[#050a24]/80 border border-black/5 dark:border-white/10 rounded-2xl shadow-sm dark:shadow-2xl dark:backdrop-blur-xl mb-4",children:(0,Ce.jsx)(oe,{categoryGroups:t?.category_groups,category:s,setCategory:i,subcategory:o,setSubcategory:n,hideCategory:!0})}),r.length>1?(0,Ce.jsx)("div",{className:"mb-2 flex gap-1 items-center text-2xl font-bold",children:(0,Ce.jsxs)("div",{className:"relative",children:[(0,Ce.jsxs)("div",{className:"relative",children:[(0,Ce.jsx)("label",{htmlFor:"condition-list",className:"underline underline-offset-2 cursor-pointer",children:d.name}),(0,Ce.jsx)(h,{icon:w,className:"pointer-events-none absolute right-1/2 -bottom-[11px] -translate-y-1/2 text-sm"})]}),(0,Ce.jsx)("select",{className:"absolute inset-0 opacity-0 cursor-pointer text-sm",name:"condition-list",id:"condition-list",value:l,onChange:e=>c(Number(e.target.value)),children:r.map((e,t)=>(0,Ce.jsx)("option",{className:"text-base",value:t,children:e.name},e.uuid))})]})}):(0,Ce.jsx)("h1",{className:"text-2xl font-bold mb-2",children:d.name}),(0,Ce.jsx)("p",{className:"text-lg mb-8",children:d?.condition_overview}),(0,Ce.jsx)(me,{name:d.name||"",data:d.subcategory_charts_data||{},category:s,setCategory:i,subcategory:o,setSubcategory:n}),(0,Ce.jsx)("hr",{className:"grad-divider my-8"}),(0,Ce.jsx)(ce,{name:d.name||"",subcategory_search_trend:d.subcategory_charts_data?.subcategory_search_trend||{},subcategory_bar_charts:d.subcategory_charts_data?.subcategory_bar_charts||{},category:s,setCategory:i,subcategory:o,setSubcategory:n,emptyStateClassName:"min-h-[450px] bg-white/25 dark:bg-black/25 grid place-items-center rounded",categoryOrder:ct})]}):(0,Ce.jsx)(re,{title:"Data Unavailable",message:"No conditions available.",icon:I})}var ut=({currentView:e,searchParams:t,setSearchParams:a,project:r})=>{const{is_internal:s}=u(),i=e=>
1{const r=new URLSearchParams(t);r.set("tab",e),a(r,{replace:!0})},o=r?.conditions?.length>0&&Object.keys(r?.sov_breakdown||{}).length>0,n="flex-1 md:flex-none flex items-center justify-center md:justify-start gap-2 px-2 md:px-4 py-2.5 text-sm font-medium font-space rounded-lg transition-all duration-200 ease-out text-deep-space/60 dark:text-white/50 hover:text-deep-space dark:hover:text-white hover:bg-black/[0.04] dark:hover:bg-white/[0.06] select-none whitespace-nowrap relative z-0 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-deep-space/60 dark:disabled:hover:bg-transparent dark:disabled:hover:text-white/50",l="bg-solar-600 text-white dark:bg-white/[0.12] dark:text-white shadow-sm shadow-solar-600/30 dark:shadow-black/20 hover:bg-solar-700 hover:text-white dark:hover:bg-white/[0.14] z-10 opacity-100 disabled:opacity-100",c="w-3.5 opacity-60",d="opacity-100 text-white dark:text-[#60a5fa]";return(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)("div",{className:"block md:hidden w-full",children:(0,Ce.jsxs)("select",{value:e,onChange:e=>i(e.target.value),className:"w-full p-4 border border-black/5 dark:border-white/10 rounded-xl text-lg font-space font-bold bg-white dark:bg-deep-space shadow-sm focus:ring-2 focus:ring-solar-400/50",children:[(0,Ce.jsx)("option",{value:"summary",children:"Summary"}),(0,Ce.jsx)("option",{value:"branded-visibility",children:"Visibility"}),(0,Ce.jsx)("option",{value:"trends",children:"Trends"}),o&&(0,Ce.jsx)("option",{value:"power-rankings",children:"Power Rankings"}),s&&(0,Ce.jsx)("option",{value:"conditions",children:"Conditions"})]})}),(0,Ce.jsxs)("div",{className:"hidden md:flex items-center gap-1 w-fit p-1 rounded-xl bg-black/[0.04] dark:bg-white/[0.06] border border-solar-200 dark:border-white/10 relative z-10",children:[(0,Ce.jsxs)("button",{onClick:()=>i("summary"),className:W(n,"summary"===e&&l),children:[(0,Ce.jsx)(h,{icon:N,className:W(c,"summary"===e&&d)}),(0,Ce.jsx)("span",{className:"flex items-center gap-2",children:"Summary"})]}),(0,Ce.jsxs)("button",{onClick:()=>i("branded-visibility"),className:W(n,"branded-visibility"===e&&l),children:[(0,Ce.jsx)(h,{icon:T,className:W(c,"branded-visibility"===e&&d)}),(0,Ce.jsx)("span",{className:"flex items-center gap-2",children:"Visibility"})]}),(0,Ce.jsxs)("button",{onClick:()=>i("trends"),className:W(n,"trends"===e&&l),children:[(0,Ce.jsx)(h,{icon:A,className:W(c,"trends"===e&&d)}),(0,Ce.jsx)("span",{className:"flex items-center gap-2",children:"Trends"})]}),(0,Ce.jsxs)("button",{onClick:()=>i("power-rankings"),className:W(n,"power-rankings"===e&&l),disabled:!o,title:o?"":"No Power Rankings data available",children:[(0,Ce.jsx)(h,{icon:_,className:W(c,"power-rankings"===e&&d)}),(0,Ce.jsx)("span",{className:"flex items-center gap-2",children:"Power Rankings"})]}),s&&(0,Ce.jsxs)("button",{onClick:()=>i("conditions"),className:W(n,"conditions"===e&&l),disabled:0===r?.conditions?.length,children:[(0,Ce.jsx)(h,{icon:F,className:W(c,"conditions"===e&&d)}),(0,Ce.jsxs)("span",{className:"flex items-center gap-2",children:["Conditions",(0,Ce.jsx)("span",{className:W("px-2 py-0.5 rounded-full text-xs font-karla font-bold bg-deep-space/10 dark:bg-white/10","conditions"===e&&"bg-white/20 text-white dark:bg-white/10 dark:text-white"),children:r?.conditions?.length||0})]})]})]})]})};function ht({state:e,startedAt:t,message:a}){return"processing"===e?(0,Ce.jsxs)("div",{role:"status","aria-live":"polite",className:"p-10 text-center border border-solar-200 dark:border-trusty-blue/20 rounded-2xl","data-testid":"scoring-status-processing",children:[(0,Ce.jsx)(h,{icon:q,className:"text-2xl text-solar-600 dark:text-trusty-blue animate-spin motion-reduce:animate-none"}),(0,Ce.jsx)("h3",{className:"mt-4 text-lg font-space font-bold text-deep-space dark:text-white",children:"Computing AI Visibility scores"}),(0,Ce.jsx)("p",{className:"mt-2 text-sm font-karla text-deep-space/60 dark:text-white/60 max-w-md mx-auto",children:"Scoring is running for this brand. Results will appear here automatically once it completes."}),t&&(0,Ce.jsxs)("p",{className:"mt-1 text-xs font-karla text-deep-space/60 dar
1k:text-white/60",children:["Started"," ",new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})]})]}):"failed"===e?(0,Ce.jsxs)("div",{className:"p-10 text-center border border-watermelon-500/30 rounded-2xl","data-testid":"scoring-status-failed",children:[(0,Ce.jsx)(h,{icon:U,className:"text-2xl text-watermelon-500"}),(0,Ce.jsx)("h3",{className:"mt-4 text-lg font-space font-bold text-deep-space dark:text-white",children:"Scoring did not complete"}),(0,Ce.jsx)("p",{className:"mt-2 text-sm font-karla text-deep-space/60 dark:text-white/60 max-w-md mx-auto",children:"The last AI Visibility scoring run failed. Scores will appear after the next successful run."}),a&&(0,Ce.jsx)("p",{className:"mt-1 text-xs font-karla text-rose-700 dark:text-watermelon-400 max-w-md mx-auto break-words",children:a})]}):null}var mt=async({queryKey:e,signal:t})=>{const[,a]=e;return _e.getCluster(a,t)},xt=(e,t=Date.now())=>{if(!e||"object"!=typeof e)return"none";if("In Progress"===e.status){const a=Date.parse(e.started_at??"");return Number.isFinite(a)&&t-a>144e5?"stale":"processing"}return"Failure"===e.status?"failed":"none"};function pt(e,{enabled:t=!0}={}){const{streamHealthy:a}=g(),{data:r,error:s,isPending:i,isFetching:o}=d({queryKey:["cluster",e],queryFn:mt,enabled:!!e&&t,staleTime:3e4,gcTime:3e5,refetchOnWindowFocus:!0,refetchInterval:e=>{return"processing"===xt(e.state.data?.ai_visibility_status)&&(t=e.state.data,!(Object.keys(t?.ai_visibility_metrics||{}).length>0&&Object.keys(t?.subcategory_charts_data||{}).length>0)&&(a?9e4:3e4));var t}});return{cluster:r,loading:i&&!(!e||!t),isFetching:o,error:s??null}}var bt=["summary","branded-visibility","trends"];function gt(){b();const e=u(),{uuid:t}=s(),{isLoading:a,is_internal:i,genti_role:o}=u(),[l,c]=r(),d=l.get("tab")||"summary",[h,m]=(0,Me.useState)(l.get("c")||"All"),[x,g]=(0,Me.useState)(l.get("s")||"All"),{cluster:f,loading:y,error:j}=pt(t),v=(0,Me.useRef)(t);(0,Me.useEffect)(()=>{v.current!==t&&(v.current=t,k("All"))},[t]);const k=(0,Me.useCallback)(e=>{m(e),g("All");const t=new URLSearchParams(l);e&&"All"!==e?t.set("c",e):t.delete("c"),t.delete("s"),c(t,{replace:!0})},[l,c]),w=(0,Me.useCallback)(e=>{g(e);const t=new URLSearchParams(l);e&&"All"!==e?t.set("s",e):t.delete("s"),c(t,{replace:!0})},[l,c]),N="Brand Project"===f?.model_type,{project:_,loading:M,error:C}=Q(t,{enabled:N});if(j||C)return(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)(n,{children:(0,Ce.jsx)("title",{children:"Cluster | Idea Evolver"})}),(0,Ce.jsx)("div",{className:"project-page page-base",children:(0,Ce.jsx)(ee,{error:j||C})})]});if(y||"Brand Project"===f?.model_type&&M||a)return(0,Ce.jsx)(H,{});const S=f&&(!f.ai_visibility_metrics||0===Object.keys(f.ai_visibility_metrics||{}).length&&!f.subcategory_charts_data||0===Object.keys(f.subcategory_charts_data||{}).length),A=S?xt(f?.ai_visibility_status):"none",F=("processing"===A||"failed"===A)&&bt.includes(d);return!e||0===Object.keys(e).length||"Client"!==o&&!1===(i??!1)?(0,Ce.jsx)("div",{className:"page-base",children:(0,Ce.jsxs)(p,{children:[(0,Ce.jsx)("h1",{className:"text-2xl mb-2",children:"Upgrade your plan to view this feed"}),S?(0,Ce.jsx)("p",{className:"text-center",children:"This is information is available to enterprise accounts only."}):(0,Ce.jsx)("p",{className:"text-center",children:"Your current free tier allows limited access. To view this cluster feed, please upgrade your subscription."})]})}):(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsxs)(n,{children:[(0,Ce.jsx)("title",{children:`${f?.model_name||""} | Idea Evolver`}),(0,Ce.jsx)("meta",{property:"og:title",content:`${f?.model_name||""} AI Visibility | Genti`})]}),(0,Ce.jsxs)("div",{className:"page-base cluster-feed space-y-4 md:space-y-8",children:[(0,Ce.jsx)(te,{project:_,linkToProjectPage:!0,showDropdown:!0}),(0,Ce.jsxs)("div",{className:"space-y-8",children:[(0,Ce.jsx)("h2",{className:"text-3xl md:text-3xl font-bold",children:"AI Visibility & Power Rankings"}),(0,Ce.jsx)(ut,{currentView:d,searchParams:l,setSearchParams:c,project:_}),F?(0,Ce.jsx)(ht,{state:A,startedAt:f?.ai_visibility_status?.started_at,message:f?.ai_visibility_status?.message}):(0,Ce.jsxs)(Ce.Fragment,{children:["summary"===d&&(0,Ce.jsx)(Je,{project:_,cluster:f}),"branded-visibility"===d&&(0,Ce.jsx)(Le,{project:_,cluster:f,category:h,setCategory:k,subcategory:x,setSubcategory:w}),"trends"===d&&(0,Ce.jsx)(lt,{project:_,cluster:f,category:h,setCategory:k,subcategory:x,setSubcategory:w}),Object.keys(_?.sov_breakdown||{}).length>0&&"power-rankings"===d&&(0,Ce.jsx)(Re,{project:_,category:h,setCategory:k,subcategory:x,setSubcategory:w}),"conditions"===d&&(0,Ce.jsx)(dt,{conditions:_?.conditions,project:_,cluster:f,category:h,setCategory:k,subcategory:x,setSubcategory:w})]})]})]})]})}export{gt 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.