PageSourceSearch

https://ultimatenexus.ai/assets/CompetitiveIntelligencePage-Gp8zaxcL.js

js ultimatenexus.ai collected 2026-10-05 13:11:29 UTC 17,821 bytes, 1 lines download raw bytes

1import{j as e,L as U,r as o}from"./vendor-DG5Dz7Ik.js";import{a as A,b as T,d as G,c as W,z as k}from"./view-analytics-BkPD6vG9.js";import V from"./CompetitiveCommandCenter-Do0t-xT0.js";import"./pdf-vendor-BQyayL6K.js";import"./socket-vendor-DENoLIvz.js";import"./auth-vendor-CeReGQmr.js";function L(s){if(!s.trim())throw new Error("Select a business first.");return`?projectId=${encodeURIComponent(s)}`}async function z(s){return L(s.projectId),T("/v1/competitive-intelligence/competitors",s)}async function J(s){return(await A(`/v1/competitive-intelligence/competitors${L(s)}`)).competitors}async function Q(s){return G(`/v1/competitive-intelligence/competitors/${encodeURIComponent(s)}`)}async function _(s){return(await A(`/v1/competitive-intelligence/competitors/${encodeURIComponent(s)}/ads`)).ads}async function H(s){return T(`/v1/competitive-intelligence/competitors/${encodeURIComponent(s)}/refresh`,{})}async function K(s){return(await A(`/v1/competitive-intelligence/alerts${L(s)}`)).alerts}async function X(s){return A(`/v1/competitive-intelligence/dashboard/stats${L(s)}`)}function M(s){return A(`/v1/competitive-intelligence/competitors/${encodeURIComponent(s)}/source-monitoring`)}function Y(s,c){return W(`/v1/competitive-intelligence/competitors/${encodeURIComponent(s)}/source-monitoring`,c)}function Z(s,c,h){return A(`/v1/competitive-intelligence/competitors/${encodeURIComponent(s)}/source-comparison${L(c)}${h?`&alertId=${encodeURIComponent(h)}`:""}`)}const $="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500 disabled:opacity-50",w="mt-1 w-full rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] px-3 py-2 text-[var(--color-text-primary)]";function ee({competitor:s,onMonitoringChanged:c}){const[h,i]=o.useState(!1),[v,p]=o.useState(!1),[g,d]=o.useState(null),[l,j]=o.useState(null),[u,m]=o.useState([]),[r,f]=o.useState({researchProjectId:"",url:s.domain?`https://${s.domain}`:"",sourceType:"web",enabled:!0,permitted:!1}),y=async()=>{i(!0),p(!0),d(null);try{const[a,x]=await Promise.all([M(s.id),A("/v1/research/projects")]);j(a),m(x),c(a),a.config&&f(a.config)}catch(a){d(k(a))}finally{p(!1)}},C=async a=>{a.preventDefault(),p(!0),d(null);try{const x=await Y(s.id,r);j(x),c(x)}catch(x){d(k(x))}finally{p(!1)}};return h?e.jsxs("form",{onSubmit:C,className:"space-y-3 rounded-lg border p-3",children:[e.jsx("h4",{className:"font-medium",children:"Permitted public source"}),e.jsx("p",{className:"text-sm",children:"Only this competitor’s saved website domain can be monitored. Organic social timelines and private/login-only sources are not supported. No response is sent automatically by this setting."}),e.jsxs("label",{className:"block text-sm",children:["Evidence research project",e.jsxs("select",{required:!0,className:w,value:r.researchProjectId,onChange:a=>f({...r,researchProjectId:a.target.value}),children:[e.jsx("option",{value:"",children:"Choose a research project"}),u.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),u.length===0&&!v&&e.jsx(U,{to:"/market-research",className:"text-sm underline",children:"Create a research project first"}),e.jsxs("label",{className:"block text-sm",children:["Public source URL",e.jsx("input",{required:!0,type:"url",className:w,value:r.url,onChange:a=>f({...r,url:a.target.value})})]}),e.jsxs("label",{className:"block text-sm",children:["Source type",e.jsxs("select",{className:w,value:r.sourceType,onChange:a=>f({...r,sourceType:a.target.value}),children:[e.jsx("option",{value:"web",children:"Public website"}),e.jsx("option",{value:"rss",children:"RSS / Atom feed"})]})]}),e.jsxs("label",{className:"block text-sm",children:[e.jsx("input",{type:"checkbox",checked:r.permitted,onChange:a=>f({...r,permitted:a.target.checked})})," I have permission to monitor this public source."]}),e.jsxs("label",{className:"block text-sm",children:[e.jsx("input",{type:"checkbox",checked:r.enabled,onChange:a=>f({...r,enabled:a.target.checked})})," Enable scheduled source monitoring"]}),e.jsx("button",{className:$,disabled:v,children:"Save monitoring settings"}),e.jsx("button",{type:"button",className:"ml-3 underline text-sm",onClick:()=>i(!1),children:"Close"}),(l==null?void 0:l.config)&&e.jsxs("p",{role:"status",className:"text-sm",children:["Saved: ",l.config.enabled?"enabled":"paused",". Use Collect latest observations to collect now."]}),(l==null?void 0:l.observation)&&e.jsxs("p",{className:"text-sm",children:["Latest source attempt: ",l.observation.status," · ",l.observation.comparison??"Comparison unavailable"," · ",l.observation.title," · ",new Date(l.observation.observedAt).toLocaleStr
1ing()]}),(l==null?void 0:l.collection)&&e.jsxs("div",{className:"text-sm",children:[e.jsxs("p",{children:["Latest collection attempt: ",new Date(l.collection.attemptedAt).toLocaleString()]}),l.collection.sources.map(a=>e.jsxs("p",{children:[a.platform,": ",a.status,a.message?` — ${a.message}`:""]},a.platform))]}),g&&e.jsx("p",{role:"alert",className:"text-sm text-[var(--color-error)]",children:g})]}):e.jsx("button",{className:"underline text-sm",onClick:()=>void y(),children:"Configure permitted website / RSS monitoring"})}function B({competitorId:s,projectId:c,alertId:h}){const[i,v]=o.useState(null),[p,g]=o.useState(!1),[d,l]=o.useState(null),j=async()=>{g(!0),l(null);try{v(await Z(s,c,h))}catch(u){v(null),l(k(u))}finally{g(!1)}};return e.jsxs("section",{className:"space-y-2 text-sm","aria-label":"Saved public source comparison",children:[e.jsx("button",{type:"button",className:"underline",disabled:p,onClick:()=>void j(),children:p?"Loading saved evidence…":"View saved before / after evidence"}),d&&e.jsx("p",{role:"alert",children:d}),i&&e.jsxs("div",{className:"rounded-lg border border-[var(--color-border-default)] p-3 space-y-3",children:[e.jsxs("p",{role:"status",children:["Source comparison: ",i.status==="baseline"?"Baseline — no previous comparable observation":i.status==="unchanged"?"Unchanged retained text":i.status==="changed"?"Changed retained text":"Unavailable"]}),i.reason&&e.jsx("p",{children:i.reason}),i.truncated&&e.jsx("p",{children:"Excerpts are truncated; this is not a complete page diff."}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:["previous","current"].map(u=>{const m=i[u];return m&&e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h4",{className:"font-medium",children:[u==="previous"?"Before":"After"," · saved observation"]}),e.jsx("p",{children:e.jsx("time",{dateTime:m.observedAt,children:new Date(m.observedAt).toLocaleString()})}),e.jsxs("p",{className:"break-all",children:["Source: ",m.sourceId," · ",m.url]}),e.jsx("pre",{className:"mt-2 whitespace-pre-wrap break-words font-sans",children:m.excerpt})]},u)})}),e.jsx("p",{className:"text-xs",children:"Stored observations only: viewing does not fetch pages, spend AI credits, or execute a response. Text differences do not establish business impact."})]})]})}function se({competitor:s,onChanged:c}){var R,D;const[h,i]=o.useState(null),[v,p]=o.useState(!1),[g,d]=o.useState(null),[l,j]=o.useState(!1),[u,m]=o.useState(null),[r,f]=o.useState(null),[y,C]=o.useState(null);o.useEffect(()=>{let n=!1;return C(null),M(s.id).then(b=>{n||f(b)}).catch(b=>{n||C(k(b))}),()=>{n=!0}},[s]);const a=((R=r==null?void 0:r.collection)==null?void 0:R.sources)??[],x=s.isActive?y?"Source readiness unavailable":r?a.length?a.some(n=>n.status==="unavailable")?"Collection unavailable or incomplete":a.some(n=>n.status==="partial")?"Partial source coverage":"Last collection completed":"No collection verified":"Checking source readiness":"Monitoring paused",I=async n=>{var b;p(!0),d(null),m(null);try{if(n==="ads"&&i(await _(s.id)),n==="refresh"){const N=await H(s.id);m(`Collection ${N.status}: ${N.newAds} newly observed ads, ${N.updatedAds} updated ads. ${((b=N.errors)==null?void 0:b.join(" · "))??""}`),i(null),c()}n==="remove"&&(await Q(s.id),c())}catch(N){d(k(N))}finally{p(!1)}};return e.jsxs("article",{className:"rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-[var(--color-text-primary)]",children:s.name}),e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)] break-all",children:s.domain||"No website recorded"})]}),e.jsx("span",{className:"text-xs text-[var(--color-text-secondary)]",children:x})]}),e.jsxs("p",{className:"text-sm text-[var(--color-text-secondary)]",children:[s.adCount??"—"," recorded ads · ",s.alertCount??"—"," alerts · Last collection: ",s.lastFetchedAt?new Date(s.lastFetchedAt).toLocaleString():"Not collected yet"]}),!s.metaPageId&&!s.googleAdvId&&e.jsx("p",{className:"text-sm text-[var(--color-warning)]",children:"Ad collection needs a Meta page ID or Google advertiser ID. A website alone does not connect an ad library."}),e.jsxs("div",{className:"text-xs text-[var(--color-text-secondary)]",children:[e.jsxs("p",{children:["Scheduling requested: ",s.isActive?"yes":"no",". Worker availability is not verified by this 
1setting."]}),(r==null?void 0:r.collection)&&e.jsxs("p",{children:["Latest attempt: ",new Date(r.collection.attemptedAt).toLocaleString()]}),a.map(n=>e.jsxs("p",{children:[n.platform,": ",n.status,n.message?` — ${n.message}`:""]},n.platform)),(r==null?void 0:r.observation)&&e.jsxs("p",{children:["Public source comparison: ",r.observation.comparison??"not recorded",". Evidence source: ",r.observation.sourceId,"."]}),y&&e.jsx("p",{role:"alert",children:y})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{className:$,disabled:v,onClick:()=>void I("ads"),children:"View recorded ads"}),e.jsx("button",{className:$,disabled:v||!s.isActive,onClick:()=>void I("refresh"),children:"Collect latest observations"}),e.jsx("button",{className:"px-3 py-2 text-sm text-[var(--color-error)]",disabled:v,onClick:()=>j(!0),children:"Remove competitor"})]}),e.jsx(ee,{competitor:s,onMonitoringChanged:f}),e.jsx(B,{competitorId:s.id,projectId:s.projectId},`${(D=r==null?void 0:r.observation)==null?void 0:D.sourceId}:${JSON.stringify(r==null?void 0:r.config)}:${s.lastFetchedAt}`),l&&e.jsxs("div",{className:"rounded-lg border border-red-700 p-3 text-sm",children:[e.jsxs("p",{children:["Remove ",s.name," and its tracked data?"]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{className:$,disabled:v,onClick:()=>void I("remove"),children:"Confirm removal"}),e.jsx("button",{className:"px-3 py-2",onClick:()=>j(!1),children:"Cancel"})]})]}),g&&e.jsx("p",{role:"alert",className:"text-sm text-[var(--color-error)]",children:g}),u&&e.jsx("p",{role:"status",className:"text-sm text-[var(--color-text-secondary)]",children:u}),h&&e.jsxs("div",{className:"space-y-2 border-t border-[var(--color-border-default)] pt-3",children:[e.jsx("h4",{className:"font-medium",children:"Recorded ads"}),h.length===0?e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:"No ads recorded. Check the advertiser IDs and collect ads when a provider is configured."}):h.map(n=>{var b;return e.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-surface)] p-3",children:[e.jsxs("p",{className:"text-xs text-[var(--color-text-secondary)]",children:[n.platform," · Provider ID ",n.externalAdId," · ",n.isActive?"Active when last collected":"Inactive"," · First observed ",new Date(n.firstSeen).toLocaleDateString()," · Last observed ",new Date(n.lastSeen).toLocaleString()]}),e.jsx("p",{className:"text-sm mt-1",children:n.textContent||"No ad text supplied by the source."}),((b=n.adSnapshotUrl)==null?void 0:b.startsWith("https://"))&&e.jsx("a",{className:"text-sm underline",href:n.adSnapshotUrl,target:"_blank",rel:"noopener noreferrer",children:"Open provider evidence"})]},n.id)})]})]})}function te({projectId:s}){const[c,h]=o.useState("competitors"),[i,v]=o.useState([]),[p,g]=o.useState([]),[d,l]=o.useState(null),[j,u]=o.useState(!0),[m,r]=o.useState(null),[f,y]=o.useState(0),[C,a]=o.use
1State(!1),[x,I]=o.useState(""),[R,D]=o.useState(""),[n,b]=o.useState(""),[N,E]=o.useState(""),P=o.useCallback(()=>y(t=>t+1),[]);o.useEffect(()=>{let t=!1;return u(!0),r(null),Promise.all([J(s),K(s),X(s)]).then(([S,F,q])=>{t||(v(S),g(F),l(q))}).catch(S=>{t||r(k(S))}).finally(()=>{t||u(!1)}),()=>{t=!0}},[s,f]);const O=async t=>{if(t.preventDefault(),!(!s||!x.trim())){a(!0),r(null);try{await z({projectId:s,name:x.trim(),domain:R.trim()?new URL(R.trim()).hostname:void 0,metaPageId:n.trim()||void 0,googleAdvId:N.trim()||void 0}),I(""),D(""),b(""),E(""),P()}catch(S){r(k(S))}finally{a(!1)}}};return e.jsxs("div",{className:"p-4 sm:p-6 max-w-6xl mx-auto space-y-6 text-[var(--color-text-primary)]",children:[e.jsxs("header",{children:[e.jsx("p",{className:"text-sm text-[var(--color-info)]",children:"Business tool · Research"}),e.jsx("h1",{className:"text-2xl font-bold mt-1",children:"Competitor research"}),e.jsx("p",{className:"mt-2 text-[var(--color-text-secondary)]",children:"Track competitors for this business and review collected ads, alerts, and comparison notes. Results depend on available source data, not estimated traffic or invented threat scores."})]}),m&&e.jsxs("div",{role:"alert",className:"rounded-lg border border-red-700 p-4 text-[var(--color-error)]",children:[m," ",e.jsx("button",{className:"underline ml-2",onClick:P,children:"Retry"})]}),d&&e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[["Competitors",d.totalCompetitors],["Recorded ads",d.totalAdsTracked],["New ads in 7 days",d.newAdsLast7Days],["Unread alerts",d.unreadAlerts]].map(([t,S])=>e.jsxs("div",{className:"rounded-xl border border-[var(--color-border-default)] p-4",children:[e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:t}),e.jsx("p",{className:"mt-1 text-2xl font-semibold",children:S})]},t))}),e.jsx("nav",{className:"flex flex-wrap gap-2","aria-label":"Competitor research views",children:["competitors","alerts","analysis"].map(t=>e.jsx("button",{onClick:()=>h(t),"aria-pressed":c===t,className:c===t?$:"rounded-lg px-4 py-2 text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-surface)]",children:t==="competitors"?"Track competitors":t==="alerts"?"Collected alerts":"Comparison notes"},t))}),c==="competitors"&&e.jsxs(e.Fragment,{children:[e.jsxs("form",{onSubmit:O,className:"rounded-xl border border-[var(--color-border-default)] p-4 space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Add a competitor"}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"text-sm",children:["Name",e.jsx("input",{required:!0,value:x,onChange:t=>I(t.target.value),className:w})]}),e.jsxs("label",{className:"text-sm",children:["Website (optional)",e.jsx("input",{type:"url",placeholder:"https://example.com",value:R,onChange:t=>D(t.target.value),className:w})]}),e.jsxs("label",{className:"text-sm",children:["Meta page ID (optional)",e.jsx("input",{value:n,onChange:t=>b(t.target.value),className:w})]}),e.jsxs("label",{className:"text-sm",children:["Google advertiser ID (optional)",e.jsx("input",{value:N,onChange:t=>E(t.target.value),className:w})]})]}),e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:"To collect ads, supply an advertiser ID for a configured ad-library provider. Adding a name does not start a campaign or spend money."}),e.jsx("button",{className:$,disabled:C||!x.trim(),children:C?"Saving…":"Track competitor"})]}),j?e.jsx("p",{role:"status",children:"Loading competitor research…"}):!m&&i.length===0?e.jsx("p",{className:"rounded-xl border border-dashed border-[var(--color-border-default)] p-6 text-[var(--color-text-secondary)]",children:"No competitors tracked for this business. Add the first one above."}):i.map(t=>e.jsx(se,{competitor:t,onChanged:P},t.id))]}),c==="alerts"&&e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Collected alerts"}),e.jsx("button",{className:"underline text-sm",onClick:P,children:"Refresh"})]}),j?e.jsx("p",{role:"status",children:"Loading alerts…"}):!m&&p.length===0?e.jsx("p",{className:"text-[var(--color-text-secondary)]",children:"No alerts recorded for this business. This is not evidence that c
1ompetitors have made no changes."}):p.map(t=>e.jsxs("article",{className:"rounded-xl border border-[var(--color-border-default)] p-4",children:[e.jsxs("p",{className:"text-xs text-[var(--color-text-secondary)]",children:[t.competitorName||"Tracked competitor"," · ",t.severity," · ",new Date(t.createdAt).toLocaleDateString()]}),e.jsx("h3",{className:"font-medium mt-1",children:t.title}),e.jsx("p",{className:"text-sm mt-1 text-[var(--color-text-secondary)]",children:t.description}),e.jsx(B,{competitorId:t.competitorId,projectId:s,alertId:t.id}),e.jsx(U,{className:"inline-block mt-3 underline text-sm",to:`/mission-control?tab=plans&projectId=${encodeURIComponent(s)}&competitorAlertId=${encodeURIComponent(t.id)}`,children:"Propose a scoped response plan"}),e.jsx("p",{className:"text-xs mt-1",children:"No response is executed by opening this proposal. Native plan approval and current policy apply."})]},t.id))]}),c==="analysis"&&e.jsx(V,{projectId:s})]})}function ie({projectId:s}){return s?e.jsx(te,{projectId:s},s):e.jsxs("section",{className:"p-6 text-[var(--color-text-primary)]",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Competitor research"}),e.jsx("p",{className:"mt-2",children:"Select a business before tracking its competitors."}),e.jsx(U,{to:"/dashboard",className:"inline-block mt-4 underline",children:"Choose a business"})]})}export{ie 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.