admesh-ui-sdk
Version:
Beautiful, modern React components for displaying AI-powered product recommendations with citation-based conversation ads, auto-triggered widgets, floating chat, conversational interfaces, persistent sidebar, and built-in tracking
453 lines (392 loc) • 85.4 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react");function Ne(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var K={exports:{}},Y={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ie;function _e(){if(ie)return Y;ie=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function s(d,n,a){var i=null;if(a!==void 0&&(i=""+a),n.key!==void 0&&(i=""+n.key),"key"in n){a={};for(var h in n)h!=="key"&&(a[h]=n[h])}else a=n;return n=a.ref,{$$typeof:t,type:d,key:i,ref:n!==void 0?n:null,props:a}}return Y.Fragment=r,Y.jsx=s,Y.jsxs=s,Y}var H={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var de;function Ce(){return de||(de=1,process.env.NODE_ENV!=="production"&&function(){function t(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===$?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case v:return"Fragment";case b:return"Profiler";case y:return"StrictMode";case C:return"Suspense";case S:return"SuspenseList";case R:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case u:return"Portal";case N:return(o.displayName||"Context")+".Provider";case _:return(o._context.displayName||"Context")+".Consumer";case L:var k=o.render;return o=o.displayName,o||(o=k.displayName||k.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case w:return k=o.displayName||null,k!==null?k:t(o.type)||"Memo";case M:k=o._payload,o=o._init;try{return t(o(k))}catch{}}return null}function r(o){return""+o}function s(o){try{r(o);var k=!1}catch{k=!0}if(k){k=console;var A=k.error,T=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return A.call(k,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),r(o)}}function d(o){if(o===v)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===M)return"<...>";try{var k=t(o);return k?"<"+k+">":"<...>"}catch{return"<...>"}}function n(){var o=P.A;return o===null?null:o.getOwner()}function a(){return Error("react-stack-top-frame")}function i(o){if(G.call(o,"key")){var k=Object.getOwnPropertyDescriptor(o,"key").get;if(k&&k.isReactWarning)return!1}return o.key!==void 0}function h(o,k){function A(){B||(B=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",k))}A.isReactWarning=!0,Object.defineProperty(o,"key",{get:A,configurable:!0})}function g(){var o=t(this.type);return F[o]||(F[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function x(o,k,A,T,V,W,X,Z){return A=W.ref,o={$$typeof:f,type:o,key:k,props:W,_owner:V},(A!==void 0?A:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:g}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function l(o,k,A,T,V,W,X,Z){var E=k.children;if(E!==void 0)if(T)if(Q(E)){for(T=0;T<E.length;T++)m(E[T]);Object.freeze&&Object.freeze(E)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(E);if(G.call(k,"key")){E=t(o);var U=Object.keys(k).filter(function(je){return je!=="key"});T=0<U.length?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}",oe[E+T]||(U=0<U.length?"{"+U.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,T,E,U,E),oe[E+T]=!0)}if(E=null,A!==void 0&&(s(A),E=""+A),i(k)&&(s(k.key),E=""+k.key),"key"in k){A={};for(var ee in k)ee!=="key"&&(A[ee]=k[ee])}else A=k;return E&&h(A,typeof o=="function"?o.displayName||o.name||"Unknown":o),x(o,E,W,V,n(),A,X,Z)}function m(o){typeof o=="object"&&o!==null&&o.$$typeof===f&&o._store&&(o._store.validated=1)}var c=p,f=Symbol.for("react.transitional.element"),u=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),N=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),P=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=Object.prototype.hasOwnProperty,Q=Array.isArray,I=console.createTask?console.createTask:function(){return null};c={"react-stack-bottom-frame":function(o){return o()}};var B,F={},z=c["react-stack-bottom-frame"].bind(c,a)(),J=I(d(a)),oe={};H.Fragment=v,H.jsx=function(o,k,A,T,V){var W=1e4>P.recentlyCreatedOwnerStacks++;return l(o,k,A,!1,T,V,W?Error("react-stack-top-frame"):z,W?I(d(o)):J)},H.jsxs=function(o,k,A,T,V){var W=1e4>P.recentlyCreatedOwnerStacks++;return l(o,k,A,!0,T,V,W?Error("react-stack-top-frame"):z,W?I(d(o)):J)}}()),H}var ce;function Me(){return ce||(ce=1,process.env.NODE_ENV==="production"?K.exports=_e():K.exports=Ce()),K.exports}var e=Me(),te={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/var he;function Ae(){return he||(he=1,function(t){(function(){var r={}.hasOwnProperty;function s(){for(var a="",i=0;i<arguments.length;i++){var h=arguments[i];h&&(a=n(a,d(h)))}return a}function d(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return s.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var i="";for(var h in a)r.call(a,h)&&a[h]&&(i=n(i,h));return i}function n(a,i){return i?a?a+" "+i:a+i:a}t.exports?(s.default=s,t.exports=s):window.classNames=s})()}(te)),te.exports}var Le=Ae();const j=Ne(Le),Se="https://api.useadmesh.com/track";let se={apiBaseUrl:Se,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const Te=t=>{se={...se,...t}},me=t=>{const[r,s]=p.useState(!1),[d,n]=p.useState(null),a=p.useMemo(()=>({...se,...t}),[t]),i=p.useCallback((m,c)=>{a.debug&&console.log(`[AdMesh Tracker] ${m}`,c)},[a.debug]),h=p.useCallback(async(m,c)=>{if(!a.enabled){i("Tracking disabled, skipping event",{eventType:m,data:c});return}if(!c.adId||!c.admeshLink){const y="Missing required tracking data: adId and admeshLink are required";i(y,c),n(y);return}s(!0),n(null);const f={event_type:m,ad_id:c.adId,admesh_link:c.admeshLink,product_id:c.productId,user_id:c.userId,session_id:c.sessionId,revenue:c.revenue,conversion_type:c.conversionType,metadata:c.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};i(`Sending ${m} event`,f);let u=null;for(let y=1;y<=(a.retryAttempts||3);y++)try{const b=await fetch(`${a.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!b.ok)throw new Error(`HTTP ${b.status}: ${b.statusText}`);const _=await b.json();i(`${m} event tracked successfully`,_),s(!1);return}catch(b){u=b,i(`Attempt ${y} failed for ${m} event`,b),y<(a.retryAttempts||3)&&await new Promise(_=>setTimeout(_,(a.retryDelay||1e3)*y))}const v=`Failed to track ${m} event after ${a.retryAttempts} attempts: ${u==null?void 0:u.message}`;i(v,u),n(v),s(!1)},[a,i]),g=p.useCallback(async m=>h("click",m),[h]),x=p.useCallback(async m=>h("view",m),[h]),l=p.useCallback(async m=>(!m.revenue&&!m.conversionType&&i("Warning: Conversion tracking without revenue or conversion type",m),h("conversion",m)),[h,i]);return{trackClick:g,trackView:x,trackConversion:l,isTracking:r,error:d}},Ee=(t,r,s)=>{try{const d=new URL(t);return d.searchParams.set("ad_id",r),d.searchParams.set("utm_source","admesh"),d.searchParams.set("utm_medium","recommendation"),s&&Object.entries(s).forEach(([n,a])=>{d.searchParams.set(n,a)}),d.toString()}catch(d){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",t,d),t}},Re=(t,r)=>({adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,...r}),D=({adId:t,admeshLink:r,productId:s,children:d,onClick:n,trackingData:a,className:i})=>{const{trackClick:h,trackView:g}=me(),x=p.useRef(null),l=p.useRef(!1);p.useEffect(()=>{if(!x.current||l.current)return;const c=new IntersectionObserver(f=>{f.forEach(u=>{u.isIntersecting&&!l.current&&(l.current=!0,g({adId:t,admeshLink:r,productId:s,...a}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return c.observe(x.current),()=>{c.disconnect()}},[t,r,s,a,g]);const m=p.useCallback(async c=>{try{await h({adId:t,admeshLink:r,productId:s,...a})}catch(v){console.error("Failed to track click:",v)}n&&n(),c.target.closest("a")||window.open(r,"_blank","noopener,noreferrer")},[t,r,s,a,h,n]);return e.jsx("div",{ref:x,className:i,onClick:m,style:{cursor:"pointer"},children:d})};D.displayName="AdMeshLinkTracker";const q=({recommendation:t,theme:r,showMatchScore:s=!0,showBadges:d=!0,onClick:n,className:a})=>{const i=p.useMemo(()=>{var f;const l=[];t.intent_match_score>=.8&&l.push("Top Match"),t.has_free_tier&&l.push("Free Tier"),t.trial_days&&t.trial_days>0&&l.push("Trial Available");const m=["ai","artificial intelligence","machine learning","ml","automation"];return(((f=t.keywords)==null?void 0:f.some(u=>m.some(v=>u.toLowerCase().includes(v))))||t.title.toLowerCase().includes("ai"))&&l.push("AI Powered"),l},[t]),h=Math.round(t.intent_match_score*100),g=j("admesh-component","admesh-card","relative p-3 sm:p-4 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow transition-shadow cursor-pointer",a),x=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor,"--admesh-primary-hover":r.accentColor+"dd"}:void 0;return e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,onClick:()=>n==null?void 0:n(t.ad_id,t.admesh_link),trackingData:{title:t.title,matchScore:t.intent_match_score},className:g,children:e.jsxs("div",{className:"h-full flex flex-col",style:x,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-2 mb-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 flex-1 min-w-0",children:[d&&i.includes("Top Match")&&e.jsx("span",{className:"text-xs font-semibold text-white bg-black px-2 py-0.5 rounded-full w-fit",children:"Top Match"}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:t.title})]}),e.jsx("div",{className:"flex gap-2 flex-shrink-0",children:e.jsxs("button",{className:"text-xs sm:text-sm px-2 py-1 rounded-full bg-black text-white hover:bg-gray-800 flex items-center",children:["Visit",e.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})})]}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-3",children:t.reason}),s&&typeof t.intent_match_score=="number"&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx("span",{className:"font-medium",children:"Match Score"}),e.jsxs("span",{className:"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",children:[h,"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-black h-1.5 transition-all duration-300 ease-out",style:{width:`${h}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-2",children:[t.pricing&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),t.pricing]}),t.has_free_tier&&e.jsxs("span",{className:"flex items-center px-1.5 py-0.5 bg-gray-100 dark:bg-gray-900/30 text-gray-700 dark:text-gray-400 rounded-full",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})}),"Free Tier"]}),t.trial_days&&t.trial_days>0&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),t.trial_days,"-day trial"]})]}),t.features&&t.features.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Features:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.features.map((l,m)=>e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 dark:bg-slate-700 text-gray-700 dark:text-gray-300",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),l]},m))})]}),t.integrations&&t.integrations.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Integrates with:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.integrations.map((l,m)=>e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-900/30 text-gray-700 dark:text-gray-300",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),l]},m))})]}),t.reviews_summary&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:t.reviews_summary}),e.jsx("div",{className:"flex justify-end mt-auto pt-2",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})})]})})};q.displayName="AdMeshProductCard";const ne=({recommendations:t,theme:r,maxProducts:s=3,showMatchScores:d=!0,showFeatures:n=!0,onProductClick:a,className:i})=>{const h=p.useMemo(()=>t.slice(0,s),[t,s]),g=j("admesh-component","admesh-compare-layout",i),x=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return h.length===0?e.jsx("div",{className:g,children:e.jsx("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"No products to compare"})})}):e.jsx("div",{className:g,style:x,"data-admesh-theme":r==null?void 0:r.mode,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("svg",{className:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200",children:"Smart Comparison"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[h.length," intelligent matches found"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map((l,m)=>e.jsxs(D,{adId:l.ad_id,admeshLink:l.admesh_link,productId:l.product_id,onClick:()=>a==null?void 0:a(l.ad_id,l.admesh_link),className:"relative p-4 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow transition-shadow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[m===0&&e.jsx("span",{className:"text-xs font-semibold text-white bg-black px-2 py-0.5 rounded-full",children:"Top Match"}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["#",m+1]})]}),d&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap",children:[Math.round(l.intent_match_score*100),"% match"]})]}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 mb-2",children:l.title}),d&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx("span",{children:"Match Score"}),e.jsxs("span",{className:"whitespace-nowrap",children:[Math.round(l.intent_match_score*100),"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-black h-1.5",style:{width:`${Math.round(l.intent_match_score*100)}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[l.pricing&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),l.pricing]}),l.has_free_tier&&e.jsxs("span",{className:"flex items-center px-1.5 py-0.5 bg-gray-100 dark:bg-gray-900/30 text-gray-700 dark:text-gray-400 rounded-full",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})}),"Free Tier"]}),l.trial_days&&l.trial_days>0&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),l.trial_days,"-day trial"]})]}),n&&l.features&&l.features.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Key Features:"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[l.features.slice(0,4).map((c,f)=>e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 dark:bg-slate-700 text-gray-700 dark:text-gray-300",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),c]},f)),(l.features.length||0)>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:["+",l.features.length-4," more"]})]})]}),e.jsxs("button",{className:"w-full text-xs px-3 py-2 rounded-lg bg-black text-white hover:bg-gray-800 flex items-center justify-center gap-1 mt-auto",children:["Visit Offer",e.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]},l.product_id||m))}),e.jsx("div",{className:"flex items-center justify-center mt-6 pt-4 border-t border-gray-200/50 dark:border-gray-700/50",children:e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx("svg",{className:"w-3 h-3 text-indigo-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),e.jsx("span",{className:"font-medium",children:"Powered by"}),e.jsx("span",{className:"font-semibold text-indigo-600 dark:text-indigo-400",children:"AdMesh"})]})})]})})};ne.displayName="AdMeshCompareTable";const Ie={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},ze={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},xe=({type:t,variant:r,size:s="md",className:d})=>{const n=r||Ie[t]||"secondary",a=ze[t],i=j("admesh-component","admesh-badge",`admesh-badge--${n}`,`admesh-badge--${s}`,d);return e.jsxs("span",{className:i,children:[a&&e.jsx("span",{className:"admesh-badge__icon",children:a}),e.jsx("span",{className:"admesh-badge__text",children:t})]})};xe.displayName="AdMeshBadge";const Pe=`
/* AdMesh UI SDK Scoped Styles - Smart Recommendations Design */
.admesh-component {
--admesh-primary: #6366f1;
--admesh-primary-hover: #4f46e5;
--admesh-secondary: #8b5cf6;
--admesh-accent: #06b6d4;
--admesh-background: #ffffff;
--admesh-surface: #ffffff;
--admesh-border: #e2e8f0;
--admesh-text: #0f172a;
--admesh-text-muted: #64748b;
--admesh-text-light: #94a3b8;
--admesh-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
--admesh-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--admesh-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
--admesh-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
--admesh-radius: 0.75rem;
--admesh-radius-sm: 0.375rem;
--admesh-radius-lg: 1rem;
--admesh-radius-xl: 1.5rem;
}
.admesh-component[data-admesh-theme="dark"] {
--admesh-background: #111827;
--admesh-surface: #1f2937;
--admesh-border: #374151;
--admesh-text: #f9fafb;
--admesh-text-muted: #9ca3af;
--admesh-text-light: #6b7280;
--admesh-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
--admesh-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
--admesh-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
--admesh-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
}
/* Layout Styles */
.admesh-layout {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
color: var(--admesh-text);
background-color: var(--admesh-background);
border-radius: var(--admesh-radius);
padding: 1.5rem;
box-shadow: var(--admesh-shadow);
border: 1px solid var(--admesh-border);
}
.admesh-layout__header {
margin-bottom: 1.5rem;
text-align: center;
}
.admesh-layout__title {
font-size: 1.25rem;
font-weight: 600;
color: var(--admesh-text);
margin-bottom: 0.5rem;
}
.admesh-layout__subtitle {
font-size: 0.875rem;
color: var(--admesh-text-muted);
}
.admesh-layout__cards-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1rem;
margin-bottom: 1.5rem;
}
.admesh-layout__more-indicator {
text-align: center;
padding: 1rem;
color: var(--admesh-text-muted);
font-size: 0.875rem;
}
.admesh-layout__empty {
text-align: center;
padding: 3rem 1rem;
}
.admesh-layout__empty-content h3 {
font-size: 1.125rem;
font-weight: 600;
color: var(--admesh-text-muted);
margin-bottom: 0.5rem;
}
.admesh-layout__empty-content p {
font-size: 0.875rem;
color: var(--admesh-text-muted);
}
/* Product Card Styles */
.admesh-product-card {
background-color: var(--admesh-surface);
border: 1px solid var(--admesh-border);
border-radius: var(--admesh-radius);
padding: 1.5rem;
transition: all 0.2s ease-in-out;
position: relative;
overflow: hidden;
}
.admesh-product-card:hover {
box-shadow: var(--admesh-shadow-lg);
transform: translateY(-2px);
border-color: var(--admesh-primary);
}
.admesh-product-card__header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 1rem;
}
.admesh-product-card__title {
font-size: 1.125rem;
font-weight: 600;
color: var(--admesh-text);
margin-bottom: 0.5rem;
line-height: 1.4;
}
.admesh-product-card__reason {
font-size: 0.875rem;
color: var(--admesh-text-muted);
line-height: 1.5;
margin-bottom: 1rem;
}
.admesh-product-card__match-score {
margin-bottom: 1rem;
}
.admesh-product-card__match-score-label {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.75rem;
color: var(--admesh-text-muted);
margin-bottom: 0.25rem;
}
.admesh-product-card__match-score-bar {
width: 100%;
height: 0.375rem;
background-color: var(--admesh-border);
border-radius: var(--admesh-radius-sm);
overflow: hidden;
}
.admesh-product-card__match-score-fill {
height: 100%;
background: linear-gradient(90deg, var(--admesh-primary), #8b5cf6);
border-radius: var(--admesh-radius-sm);
transition: width 0.3s ease-in-out;
}
.admesh-product-card__badges {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 1rem;
}
.admesh-product-card__badge {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
background-color: var(--admesh-primary);
color: white;
font-size: 0.75rem;
font-weight: 500;
border-radius: var(--admesh-radius-sm);
}
.admesh-product-card__badge--secondary {
background-color: var(--admesh-secondary);
}
.admesh-product-card__keywords {
display: flex;
flex-wrap: wrap;
gap: 0.25rem;
margin-bottom: 1rem;
}
.admesh-product-card__keyword {
padding: 0.125rem 0.375rem;
background-color: var(--admesh-border);
color: var(--admesh-text-muted);
font-size: 0.75rem;
border-radius: var(--admesh-radius-sm);
}
/* Dark mode specific enhancements */
.admesh-component[data-admesh-theme="dark"] .admesh-product-card__keyword {
background-color: #4b5563;
color: #d1d5db;
}
.admesh-component[data-admesh-theme="dark"] .admesh-product-card:hover {
border-color: var(--admesh-primary);
background-color: #374151;
}
.admesh-component[data-admesh-theme="dark"] .admesh-product-card__button:hover {
background: linear-gradient(90deg, var(--admesh-primary-hover), var(--admesh-primary));
}
.admesh-product-card__footer {
display: flex;
justify-content: flex-end;
margin-top: 1.5rem;
}
/* Mobile-specific sidebar improvements */
@media (max-width: 640px) {
.admesh-sidebar {
/* Ensure proper mobile viewport handling */
height: 100vh !important;
height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
max-height: 100vh !important;
max-height: 100dvh !important;
width: 100vw !important;
max-width: 90vw !important;
overflow: hidden !important;
}
.admesh-sidebar.relative {
height: 100% !important;
width: 100% !important;
max-width: 100% !important;
}
/* Improve touch scrolling */
.admesh-sidebar .overflow-y-auto {
-webkit-overflow-scrolling: touch !important;
overscroll-behavior: contain !important;
scroll-behavior: smooth !important;
}
/* Prevent body scroll when sidebar is open */
body:has(.admesh-sidebar[data-mobile-open="true"]) {
overflow: hidden !important;
position: fixed !important;
width: 100% !important;
}
}
/* Tablet improvements */
@media (min-width: 641px) and (max-width: 1024px) {
.admesh-sidebar {
max-width: 400px !important;
}
}
/* Mobile responsiveness improvements for all components */
@media (max-width: 640px) {
/* Product cards mobile optimization */
.admesh-card {
padding: 0.75rem !important;
margin-bottom: 0.75rem !important;
}
/* Inline recommendations mobile optimization */
.admesh-inline-recommendation {
padding: 0.5rem !important;
margin-bottom: 0.5rem !important;
}
/* Conversation summary mobile optimization */
.admesh-conversation-summary {
padding: 1rem !important;
}
/* Percentage text mobile improvements */
.admesh-component .text-xs {
font-size: 0.75rem !important;
line-height: 1rem !important;
}
.admesh-component .text-sm {
font-size: 0.875rem !important;
line-height: 1.25rem !important;
}
/* Button mobile improvements */
.admesh-component button {
padding: 0.375rem 0.75rem !important;
font-size: 0.75rem !important;
min-height: 2rem !important;
touch-action: manipulation !important;
}
/* Badge mobile improvements */
.admesh-component .rounded-full {
padding: 0.25rem 0.5rem !important;
font-size: 0.625rem !important;
line-height: 1rem !important;
}
/* Progress bar mobile improvements */
.admesh-component .bg-gray-200,
.admesh-component .bg-slate-600 {
height: 0.25rem !important;
}
/* Flex layout mobile improvements */
.admesh-component .flex {
flex-wrap: wrap !important;
}
.admesh-component .gap-2 {
gap: 0.375rem !important;
}
.admesh-component .gap-3 {
gap: 0.5rem !important;
}
}
.admesh-product-card__button {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.5rem;
background: linear-gradient(90deg, var(--admesh-primary), var(--admesh-primary-hover));
color: white;
font-size: 0.875rem;
font-weight: 500;
border: none;
border-radius: var(--admesh-radius);
cursor: pointer;
transition: all 0.2s ease-in-out;
text-decoration: none;
}
.admesh-product-card__button:hover {
transform: translateY(-1px);
box-shadow: var(--admesh-shadow-lg);
}
/* Utility Classes */
.admesh-text-xs { font-size: 0.75rem; }
.admesh-text-sm { font-size: 0.875rem; }
.admesh-text-base { font-size: 1rem; }
.admesh-text-lg { font-size: 1.125rem; }
.admesh-text-xl { font-size: 1.25rem; }
.admesh-font-medium { font-weight: 500; }
.admesh-font-semibold { font-weight: 600; }
.admesh-font-bold { font-weight: 700; }
.admesh-text-muted { color: var(--admesh-text-muted); }
/* Comparison Table Styles */
.admesh-compare-table {
width: 100%;
border-collapse: collapse;
background-color: var(--admesh-surface);
border: 1px solid var(--admesh-border);
border-radius: var(--admesh-radius);
overflow: hidden;
}
.admesh-compare-table th,
.admesh-compare-table td {
padding: 0.75rem;
text-align: left;
border-bottom: 1px solid var(--admesh-border);
}
.admesh-compare-table th {
background-color: var(--admesh-background);
font-weight: 600;
color: var(--admesh-text);
font-size: 0.875rem;
}
.admesh-compare-table td {
color: var(--admesh-text);
font-size: 0.875rem;
}
.admesh-compare-table tr:hover {
background-color: var(--admesh-border);
}
/* Dark mode table enhancements */
.admesh-component[data-admesh-theme="dark"] .admesh-compare-table th {
background-color: #374151;
}
.admesh-component[data-admesh-theme="dark"] .admesh-compare-table tr:hover {
background-color: #4b5563;
}
/* Responsive Design */
@media (max-width: 768px) {
.admesh-layout {
padding: 1rem;
}
.admesh-layout__cards-grid {
grid-template-columns: 1fr;
gap: 0.75rem;
}
.admesh-product-card {
padding: 1rem;
}
.admesh-compare-table {
font-size: 0.75rem;
}
.admesh-compare-table th,
.admesh-compare-table td {
padding: 0.5rem;
}
}
`;let re=!1;const ue=()=>{p.useEffect(()=>{if(re)return;const t=document.createElement("style");return t.id="admesh-ui-sdk-styles",t.textContent=Pe,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(t),re=!0),()=>{const r=document.getElementById("admesh-ui-sdk-styles");r&&document.head.contains(r)&&(document.head.removeChild(r),re=!1)}},[])},Be=(t,r,s)=>{if(!s&&r)switch(r){case"compare_products":return"compare";case"best_for_use_case":case"trial_demo":case"budget_conscious":return"cards";default:return"cards"}const d=t.length;if(d>=2&&d<=4){const n=t.some(i=>i.features&&i.features.length>0),a=t.some(i=>i.pricing);if(n||a)return"compare"}return"cards"},ge=({recommendations:t,intentType:r,theme:s,maxDisplayed:d=6,showMatchScores:n=!0,showFeatures:a=!0,autoLayout:i=!0,onProductClick:h,onTrackView:g,className:x})=>{ue();const l=p.useMemo(()=>t.slice(0,d),[t,d]),m=p.useMemo(()=>Be(l,r,i),[l,r,i]),c=j("admesh-component",x),f=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return l.length===0?e.jsx("div",{className:c,children:e.jsx("div",{className:"admesh-layout__empty",children:e.jsxs("div",{className:"admesh-layout__empty-content",children:[e.jsx("div",{className:"flex items-center justify-center mb-3",children:e.jsx("svg",{className:"w-8 h-8 text-indigo-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})})}),e.jsx("h3",{className:"admesh-text-lg admesh-font-semibold admesh-text-muted",children:"No smart recommendations found"}),e.jsx("p",{className:"admesh-text-sm admesh-text-muted",children:"Try refining your search or check back later for new matches."})]})})}):e.jsx("div",{className:c,style:f,"data-admesh-theme":s==null?void 0:s.mode,children:m==="compare"?e.jsx(ne,{recommendations:l,theme:s,maxProducts:Math.min(l.length,4),showMatchScores:n,showFeatures:a,onProductClick:h}):e.jsx("div",{className:"space-y-4",children:l.map((u,v)=>e.jsx(q,{recommendation:u,theme:s,showMatchScore:n,showBadges:!0,maxKeywords:3,onClick:h,onTrackView:g},u.product_id||u.ad_id||v))})})};ge.displayName="AdMeshLayout";const We=({recommendation:t,theme:r={mode:"light"},className:s="",onClick:d,showPoweredBy:n=!0,variation:a="question"})=>{const i=()=>{d==null||d(t.ad_id,t.admesh_link)},h=t.title,g=()=>{var x,l,m;if(a==="question")return`Looking for ${((l=(x=t.keywords)==null?void 0:x[0])==null?void 0:l.toLowerCase())||"solutions"} for your business? Try ${h}`;{const c=((m=t.reason)==null?void 0:m.split(".")[0])||"offering best solutions for your business";return`${h} is ${c.toLowerCase()}, visit`}};return e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,onClick:i,trackingData:{title:t.title,variation:a,component:"simple_ad"},className:`admesh-simple-ad ${s}`,children:e.jsxs("div",{"data-admesh-theme":r.mode,style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r.mode==="dark"?"#374151":"#e5e7eb"}`,backgroundColor:r.mode==="dark"?"#1f2937":"#ffffff",fontSize:"14px",lineHeight:"1.5",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[e.jsxs("div",{style:{marginBottom:n?"8px":"0"},children:[e.jsx("span",{style:{color:r.mode==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:g()}),e.jsx("span",{style:{color:r.accentColor||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:h})]}),n&&e.jsxs("div",{style:{fontSize:"11px",color:r.mode==="dark"?"#9ca3af":"#6b7280",textAlign:"right"},children:["powered by ",e.jsx("strong",{children:"AdMesh"})]})]})})},O=({recommendation:t,theme:r,compact:s=!1,showReason:d=!0,onClick:n,className:a})=>{const i=Math.round(t.intent_match_score*100),h=j("admesh-inline-recommendation","group cursor-pointer transition-all duration-200",{"p-2 sm:p-3 rounded-md bg-gray-50 dark:bg-slate-800/50 hover:bg-gray-100 dark:hover:bg-slate-800 border border-gray-200 dark:border-slate-700":!s,"p-1.5 sm:p-2 rounded hover:bg-gray-50 dark:hover:bg-slate-800/30":s},a),g=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,onClick:()=>n==null?void 0:n(t.ad_id,t.admesh_link),trackingData:{title:t.title,matchScore:t.intent_match_score},className:h,children:e.jsxs("div",{className:"flex items-start gap-3",style:g,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:t.intent_match_score>=.8?e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}):e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-2 mb-1 flex-col sm:flex-row",children:[e.jsx("h4",{className:j("font-medium transition-colors duration-200 flex-shrink-0","text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300","cursor-pointer hover:underline",s?"text-sm sm:text-base":"text-base sm:text-lg"),children:t.title}),t.intent_match_score>=.7&&e.jsxs("span",{className:j("inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium flex-shrink-0 whitespace-nowrap",t.intent_match_score>=.8?"bg-green-100 text-green-800 dark:bg-green-800/80 dark:text-green-100":"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"),children:[i,"% match"]})]}),d&&t.reason&&e.jsx("p",{className:j("text-gray-600 dark:text-gray-400 line-clamp-2",s?"text-xs":"text-sm"),children:t.reason}),!s&&t.keywords&&t.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[t.keywords.slice(0,3).map((x,l)=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800 dark:bg-slate-700 dark:text-gray-300",children:x},l)),t.keywords.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",t.keywords.length-3," more"]})]}),!s&&(t.has_free_tier||t.trial_days)&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.has_free_tier&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800 dark:bg-green-800/80 dark:text-green-100",children:"Free tier"}),t.trial_days&&t.trial_days>0&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",children:[t.trial_days,"-day trial"]})]})]}),e.jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})})},pe=({recommendations:t,conversationSummary:r,theme:s,showTopRecommendations:d=3,onRecommendationClick:n,onStartNewConversation:a,className:i})=>{const h=t.sort((l,m)=>m.intent_match_score-l.intent_match_score).slice(0,d),g=j("admesh-conversation-summary","bg-white dark:bg-black","rounded-lg border border-gray-200 dark:border-gray-800 p-4 sm:p-6","font-sans",i),x=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:g,style:x,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 bg-black dark:bg-white rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5 text-white dark:text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-black dark:text-white",children:"Conversation Summary"}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-300",children:"Here's what we discussed and found for you"})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:e.jsx("p",{className:"text-gray-800 dark:text-gray-200 leading-relaxed",children:r})})}),h.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("svg",{className:"w-5 h-5 text-black dark:text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("h4",{className:"font-medium text-black dark:text-white",children:"Top Recommendations"})]}),e.jsx("div",{className:"space-y-2",children:h.map((l,m)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-2 top-2 z-10",children:e.jsx("div",{className:j("w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold",m===0?"bg-black dark:bg-white text-white dark:text-black":m===1?"bg-gray-600 dark:bg-gray-400 text-white dark:text-black":"bg-gray-800 dark:bg-gray-200 text-white dark:text-black"),children:m+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(O,{recommendation:l,theme:s,compact:!0,showReason:!0,onClick:n})})]},l.ad_id||m))})]}),t.length>d&&e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-black dark:text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:[t.length-d," additional recommendation",t.length-d>1?"s":""," available"]})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a&&e.jsxs("button",{onClick:a,className:"flex-1 bg-black dark:bg-white hover:bg-gray-800 dark:hover:bg-gray-100 text-white dark:text-black font-medium py-2.5 px-4 rounded-lg transition-all duration-200 flex items-center justify-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),"Start New Conversation"]}),e.jsxs("button",{onClick:()=>{h.length>0&&(n==null||n(h[0].ad_id,h[0].admesh_link))},className:"flex-1 bg-white dark:bg-gray-900 hover:bg-gray-50 dark:hover:bg-gray-800 text-black dark:text-white font-medium py-2.5 px-4 rounded-lg border border-gray-300 dark:border-gray-600 transition-all duration-200 flex items-center justify-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})}),"View Top Pick"]})]}),e.jsx("div",{className:"flex justify-center mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"})})]})},ae=({recommendation:t,citationNumber:r,citationStyle:s="numbered",theme:d,showTooltip:n=!0,onClick:a,onHover:i,className:h})=>{const[g,x]=p.useState(!1),l=()=>{x(!0),i==null||i(t)},m=()=>{x(!1)},c=()=>{a==null||a(t.ad_id,t.admesh_link)},f=()=>{switch(s){case"bracketed":return`[${r}]`;case"superscript":return r.toString();case"numbered":default:return r.toString()}},u=j("admesh-citation-reference","inline-flex items-center justify-center","cursor-pointer transition-all duration-200","text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300","font-medium",{"w-5 h-5 bg-blue-100 dark:bg-blue-900/30 rounded-full text-xs border border-blue-300 dark:border-blue-700 hover:bg-blue-200 dark:hover:bg-blue-900/50":s==="numbered","px-1 text-sm hover:underline":s==="bracketed","text-xs align-super hover:underline":s==="superscript"},h),v=d!=null&&d.accentColor?{"--admesh-primary":d.accentColor}:void 0;return e.jsxs("span",{className:"relative inline-block",children:[e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,onClick:c,trackingData:{title:t.title,matchScore:t.intent_match_score,citationNumber:r,citationStyle:s},className:u,children:e.jsx("span",{style:v,"data-admesh-theme":d==null?void 0:d.mode,onMouseEnter:l,onMouseLeave:m,children:f()})}),n&&g&&e.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 z-50",children:e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-900 text-xs rounded-lg px-3 py-2 shadow-lg max-w-xs",children:[e.jsx("div",{className:"font-semibold mb-1",children:t.title}),t.reason&&e.jsx("div",{className:"text-gray-300 dark:text-gray-600 text-xs",children:t.reason.length>100?`${t.reason.substring(0,100)}...`:t.reason}),t.intent_match_score>=.7&&e.jsxs("div",{className:"text-green-400 dark:text-green-600 text-xs mt-1",children:[Math.round(t.intent_match_score*100),"% match"]}),e.jsx("div",{className:"text-gray-400 dark:text-gray-500 text-xs mt-1 italic",children:"Click to visit product page"}),e.jsx("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900 dark:border-t-gray-100"})]})})]})},fe=({recommendations:t,conversationText:r,theme:s,showCitationList:d=!0,citationStyle:n="numbered",onRecommendationClick:a,onCitationHover:i,className:h})=>{const[g,x]=p.useState(null),l=p.useMemo(()=>{if(!r||t.length===0)return{text:r,citationMap:new Map};let u=r;const v=new Map;return[...t].sort((b,_)=>_.intent_match_score-b.intent_match_score).forEach((b,_)=>{const N=_+1,L=b.title;v.set(N,b);const C=new RegExp(`\\b${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(C.test(u))u=u.replace(C,S=>`${S}{{CITATION_${N}}}`);else{const S=b.keywords||[];let w=!1;for(const M of S){const R=new RegExp(`\\b${M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(R.test(u)&&!w){u=u.replace(R,$=>(w=!0,`${$}{{CITATION_${N}}}`));break}}w||(u+=`{{CITATION_${N}}}`)}}),{text:u,citationMap:v}},[r,t]),m=()=>{const{text:u,citationMap:v}=l;return u.split(/(\{\{CITATION_\d+\}\})/).map((b,_)=>{const N=b.match(/\{\{CITATION_(\d+)\}\}/);if(N){const L=parseInt(N[1]),C=v.get(L);if(C)return e.jsx(ae,{recommendation:C,citationNumber:L,citationStyle:n,theme:s,showTooltip:!0,onClick:a,onHover:S=>{x(S),i==null||i(S)}},`citation-${L}-${_}`)}return e.jsx("span",{children:b},_)})},c=j("admesh-citation-unit","space-y-4",h),f=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:c,style:f,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:"admesh-citation-text text-gray-800 dark:text-gray-200 leading-relaxed",children:m()}),d&&t.length>0&&e.jsx("div",{className:"admesh-citation-list",children:e.jsxs("div",{className:"border-t border-gray-200 dark:border-slate-700 pt-4",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"References"]}),e.jsx("div",{className:"space-y-2",children:t.sort((u,v)=>v.intent_match_score-u.intent_match_score).map((u,v)=>e.jsxs("div",{className:j("flex items-start gap-3 p-2 rounded-lg transition-colors duration-200",{"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800":(g==null?void 0:g.ad_id)===u.ad_id,"hover:bg-gray-50 dark:hover:bg-slate-800/50":(g==null?void 0:g.ad_id)!==u.ad_id}),children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(ae,{recommendation:u,citationNumber:v+1,citationStyle:n,theme