admesh-ui-sdk 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -273,5 +273,5 @@ React keys must be passed directly to JSX without using spread:
273
273
  padding: 1rem;
274
274
  }
275
275
  }
276
- `;let X=!1;const xe=()=>{m.useEffect(()=>{if(X)return;const r=document.createElement("style");return r.id="admesh-ui-sdk-styles",r.textContent=Ie,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(r),X=!0),()=>{const s=document.getElementById("admesh-ui-sdk-styles");s&&document.head.contains(s)&&(document.head.removeChild(s),X=!1)}},[])},Pe=(r,s,t)=>{if(!t&&s)switch(s){case"compare_products":return"compare";case"best_for_use_case":case"trial_demo":case"budget_conscious":return"cards";default:return"cards"}const c=r.length;if(c>=2&&c<=4){const o=r.some(d=>d.features&&d.features.length>0),a=r.some(d=>d.pricing);if(o||a)return"compare"}return"cards"},he=({recommendations:r,intentType:s,theme:t,maxDisplayed:c=6,showMatchScores:o=!0,showFeatures:a=!0,autoLayout:d=!0,onProductClick:u,onTrackView:b,className:g})=>{xe();const l=m.useMemo(()=>r.slice(0,c),[r,c]),x=m.useMemo(()=>Pe(l,s,d),[l,s,d]),i=v("admesh-component",g),k=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return l.length===0?e.jsx("div",{className:i,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:i,style:k,"data-admesh-theme":t==null?void 0:t.mode,children:x==="compare"?e.jsx(ee,{recommendations:l,theme:t,maxProducts:Math.min(l.length,4),showMatchScores:o,showFeatures:a,onProductClick:u}):e.jsx("div",{className:"space-y-4",children:l.map((h,w)=>e.jsx(H,{recommendation:h,theme:t,showMatchScore:o,showBadges:!0,maxKeywords:3,onClick:u,onTrackView:b},h.product_id||h.ad_id||w))})})};he.displayName="AdMeshLayout";const P=({recommendation:r,theme:s,compact:t=!1,showReason:c=!0,onClick:o,className:a})=>{const d=Math.round(r.intent_match_score*100),u=v("admesh-inline-recommendation","group cursor-pointer transition-all duration-200",{"p-2 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":!t,"p-1.5 rounded hover:bg-gray-50 dark:hover:bg-slate-800/30":t},a),b=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsx(D,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:()=>o==null?void 0:o(r.ad_id,r.admesh_link),trackingData:{title:r.title,matchScore:r.intent_match_score},className:u,children:e.jsxs("div",{className:"flex items-start gap-3",style:b,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.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-center gap-2 mb-1",children:[e.jsx("h4",{className:v("font-medium text-gray-900 dark:text-gray-100 truncate",t?"text-sm":"text-base"),children:r.title}),r.intent_match_score>=.7&&e.jsxs("span",{className:v("inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium",r.intent_match_score>=.8?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"),children:[d,"% match"]})]}),c&&r.reason&&e.jsx("p",{className:v("text-gray-600 dark:text-gray-400 line-clamp-2",t?"text-xs":"text-sm"),children:r.reason}),!t&&r.keywords&&r.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[r.keywords.slice(0,3).map((g,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:g},l)),r.keywords.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",r.keywords.length-3," more"]})]}),!t&&(r.has_free_tier||r.trial_days)&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[r.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-900/30 dark:text-green-400",children:"Free tier"}),r.trial_days&&r.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:[r.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"})})})]})})},me=({recommendations:r,conversationSummary:s,theme:t,showTopRecommendations:c=3,onRecommendationClick:o,onStartNewConversation:a,className:d})=>{const u=r.sort((l,x)=>x.intent_match_score-l.intent_match_score).slice(0,c),b=v("admesh-conversation-summary","bg-gradient-to-br from-slate-50 to-blue-50 dark:from-slate-900 dark:to-slate-800","rounded-lg border border-gray-200 dark:border-slate-700 p-6",d),g=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:b,style:g,"data-admesh-theme":t==null?void 0:t.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-10 h-10 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",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",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Conversation Summary"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Here's what we discussed and found for you"})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-4 border border-gray-100 dark:border-slate-700",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:s})})}),u.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-blue-600 dark:text-blue-400",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-gray-900 dark:text-gray-100",children:"Top Recommendations"})]}),e.jsx("div",{className:"space-y-2",children:u.map((l,x)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-2 top-2 z-10",children:e.jsx("div",{className:v("w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",x===0?"bg-yellow-500":x===1?"bg-gray-400":"bg-orange-400"),children:x+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(P,{recommendation:l,theme:t,compact:!1,showReason:!0,onClick:o})})]},l.ad_id||x))})]}),r.length>c&&e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",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-blue-800 dark:text-blue-300",children:[r.length-c," additional recommendation",r.length-c>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-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white 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:()=>{u.length>0&&(o==null||o(u[0].ad_id,u[0].admesh_link))},className:"flex-1 bg-white dark:bg-slate-800 hover:bg-gray-50 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-300 font-medium py-2.5 px-4 rounded-lg border border-gray-300 dark:border-slate-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-slate-700",children:e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"})})]})},ge=({recommendations:r,config:s,theme:t,conversationSummary:c,userQuery:o,sessionId:a,onRecommendationClick:d,onDismiss:u,className:b})=>{const[g,l]=m.useState(s.autoShow!==!1),[x,i]=m.useState(!1);if(m.useEffect(()=>{if(s.delayMs&&s.delayMs>0){const M=setTimeout(()=>{l(!0),i(!0)},s.delayMs);return()=>clearTimeout(M)}else i(!0)},[s.delayMs]),!g||r.length===0)return null;const k=s.maxRecommendations||3,h=r.slice(0,k),w=(M,N)=>{d==null||d(M,N)},f=()=>{l(!1),u==null||u()},y=()=>{switch(s.displayMode){case"summary":return c?e.jsx(me,{recommendations:h,conversationSummary:c,theme:t,showTopRecommendations:k,onRecommendationClick:w,onStartNewConversation:u}):null;case"inline":return e.jsx("div",{className:"space-y-2",children:h.map((M,N)=>e.jsx(P,{recommendation:M,theme:t,compact:!0,showReason:!0,onClick:w},M.ad_id||N))});case"minimal":return h.length>0?e.jsxs("div",{className:"admesh-minimal-unit",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[h.length," intelligent match",h.length>1?"es":""," found"]})]}),e.jsx(P,{recommendation:h[0],theme:t,compact:!0,showReason:!1,onClick:w}),h.length>1&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["+",h.length-1," more recommendation",h.length>2?"s":""]})]}):null;case"floating":return e.jsxs("div",{className:"admesh-floating-unit bg-white dark:bg-slate-800 rounded-lg shadow-lg border border-gray-200 dark:border-slate-700 p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:"Recommended for you"})]}),u&&e.jsx("button",{onClick:f,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Dismiss recommendations",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:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"space-y-2",children:h.map((M,N)=>e.jsx(P,{recommendation:M,theme:t,compact:!0,showReason:!1,onClick:w},M.ad_id||N))})]});default:return e.jsx("div",{className:"space-y-3",children:h.map((M,N)=>e.jsx(H,{recommendation:M,theme:t,showMatchScore:!1,showBadges:!0,onClick:w},M.ad_id||N))})}},R=v("admesh-conversational-unit","transition-all duration-300 ease-in-out",{"opacity-0 translate-y-2":!x,"opacity-100 translate-y-0":x,"fixed bottom-4 right-4 max-w-sm z-50":s.displayMode==="floating","my-3":s.displayMode==="inline","mt-4 pt-4 border-t border-gray-200 dark:border-slate-700":s.displayMode==="summary"},b),z=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:R,style:z,"data-admesh-theme":t==null?void 0:t.mode,"data-admesh-context":s.context,"data-session-id":a,children:[y(),s.showPoweredBy!==!1&&e.jsx("div",{className:"flex justify-end mt-2",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})})]})},fe=({title:r,theme:s,collapsible:t=!1,isCollapsed:c=!1,onToggle:o,onSearch:a,showSearch:d=!1,className:u})=>{const[b,g]=m.useState(""),[l,x]=m.useState(!1),i=f=>{const y=f.target.value;g(y),a==null||a(y)},k=()=>{g(""),a==null||a("")},h=v("admesh-sidebar-header","flex flex-col p-4 border-b border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",u),w=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:h,style:w,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate",children:r}),t&&e.jsx("button",{onClick:o,className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors flex-shrink-0",title:c?"Expand sidebar":"Collapse sidebar",children:e.jsx("svg",{className:v("w-4 h-4 text-gray-600 dark:text-gray-400 transition-transform duration-200",{"rotate-180":c}),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),d&&!c&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:v("relative flex items-center transition-all duration-200",{"ring-2 ring-blue-500 dark:ring-blue-400":l}),children:[e.jsx("div",{className:"absolute left-3 pointer-events-none",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:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("input",{type:"text",value:b,onChange:i,onFocus:()=>x(!0),onBlur:()=>x(!1),placeholder:"Search recommendations...",className:v("w-full pl-10 pr-10 py-2 text-sm bg-white dark:bg-slate-900 border border-gray-300 dark:border-slate-600 rounded-lg","placeholder-gray-400 dark:placeholder-gray-500 text-gray-900 dark:text-gray-100","focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200")}),b&&e.jsx("button",{onClick:k,className:"absolute right-3 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors",title:"Clear search",children:e.jsx("svg",{className:"w-3 h-3 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:"M6 18L18 6M6 6l12 12"})})})]}),b&&e.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Search results will be filtered in real-time"})]}),!c&&e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),e.jsx("span",{children:"Live recommendations"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3",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("span",{children:"AI-powered"})]})]})]})},pe=({recommendations:r,displayMode:s,theme:t,maxRecommendations:c,onRecommendationClick:o,className:a})=>{const[d,u]=m.useState(!1),[b,g]=m.useState("all"),l=c?r.slice(0,c):r,i=(()=>{switch(b){case"top":return l.filter(f=>f.intent_match_score>=.8).slice(0,5);case"recent":return l.slice(0,3);default:return l}})(),k=v("admesh-sidebar-content","flex flex-col h-full",a),h=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,w=()=>{if(i.length===0)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-slate-800 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 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:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"No recommendations found"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Try adjusting your search or filters"})]});switch(s){case"recommendations":return e.jsx("div",{className:"space-y-3",children:i.map((f,y)=>e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!0,onClick:o},f.ad_id||y))});case"history":return e.jsx("div",{className:"space-y-2",children:i.map((f,y)=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-800 transition-colors",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:f.title}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(f.intent_match_score*100),"% match"]})]})]},f.ad_id||y))});case"favorites":return e.jsx("div",{className:"space-y-3",children:i.slice(0,3).map((f,y)=>e.jsxs("div",{className:"relative",children:[e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!1,onClick:o}),e.jsx("button",{className:"absolute top-2 right-2 p-1 rounded-full hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",children:e.jsx("svg",{className:"w-3 h-3 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})]},f.ad_id||y))});case"mixed":return e.jsxs("div",{className:"space-y-4",children:[i[0]&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"Top Pick"}),e.jsx(H,{recommendation:i[0],theme:t,showMatchScore:!0,showBadges:!0,onClick:o,className:"text-xs"})]}),i.slice(1).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"More Options"}),e.jsx("div",{className:"space-y-2",children:i.slice(1,4).map((f,y)=>e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!1,onClick:o},f.ad_id||y))})]})]});default:return e.jsx("div",{className:"space-y-3",children:i.map((f,y)=>e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!0,onClick:o},f.ad_id||y))})}};return e.jsxs("div",{className:k,style:h,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsxs("div",{className:"flex border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900",children:[e.jsxs("button",{onClick:()=>g("all"),className:v("flex-1 px-3 py-2 text-xs font-medium transition-colors",b==="all"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:["All (",r.length,")"]}),e.jsx("button",{onClick:()=>g("top"),className:v("flex-1 px-3 py-2 text-xs font-medium transition-colors",b==="top"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Top"}),e.jsx("button",{onClick:()=>g("recent"),className:v("flex-1 px-3 py-2 text-xs font-medium transition-colors",b==="recent"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Recent"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w()}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",children:e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[i.length," recommendation",i.length!==1?"s":""]}),e.jsx("button",{onClick:()=>u(!d),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors",children:"Filters"})]})})]})},ze=({recommendations:r,config:s,theme:t,title:c="Recommendations",isOpen:o=!0,onToggle:a,onRecommendationClick:d,onSearch:u,onFilter:b,className:g})=>{const[l,x]=m.useState(s.defaultCollapsed||!1),[i,k]=m.useState(""),[h,w]=m.useState({});m.useEffect(()=>{if(s.autoRefresh&&s.refreshInterval){const j=setInterval(()=>{console.log("Auto-refreshing recommendations...")},s.refreshInterval);return()=>clearInterval(j)}},[s.autoRefresh,s.refreshInterval]);const f=m.useMemo(()=>{let j=[...r];if(i.trim()){const C=i.toLowerCase();j=j.filter(L=>{var T;return L.title.toLowerCase().includes(C)||L.reason.toLowerCase().includes(C)||((T=L.keywords)==null?void 0:T.some(O=>O.toLowerCase().includes(C)))})}return h.categories&&h.categories.length>0&&(j=j.filter(C=>{var L;return(L=C.categories)==null?void 0:L.some(T=>{var O;return(O=h.categories)==null?void 0:O.includes(T)})})),h.hasFreeTier&&(j=j.filter(C=>C.has_free_tier)),h.hasTrial&&(j=j.filter(C=>C.trial_days&&C.trial_days>0)),h.minMatchScore!==void 0&&(j=j.filter(C=>C.intent_match_score>=h.minMatchScore)),j.sort((C,L)=>L.intent_match_score-C.intent_match_score),s.maxRecommendations&&(j=j.slice(0,s.maxRecommendations)),j},[r,i,h,s.maxRecommendations]),y=()=>{s.collapsible&&(x(!l),a==null||a())},R=j=>{k(j),u==null||u(j)},M=v("admesh-sidebar","flex flex-col bg-white dark:bg-slate-900 border-gray-200 dark:border-slate-700 shadow-lg transition-all duration-300 ease-in-out",(()=>{switch(s.size){case"sm":return l?"w-12":"w-64";case"md":return l?"w-12":"w-80";case"lg":return l?"w-12":"w-96";case"xl":return l?"w-12":"w-[28rem]";default:return l?"w-12":"w-80"}})(),{"border-r":s.position==="left","border-l":s.position==="right","fixed top-0 bottom-0 z-50":!0,"left-0":s.position==="left","right-0":s.position==="right","transform -translate-x-full":s.position==="left"&&!o,"transform translate-x-full":s.position==="right"&&!o},g),N=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return!o&&!s.collapsible?null:e.jsxs(e.Fragment,{children:[o&&!l&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-40 lg:hidden",onClick:()=>a==null?void 0:a()}),e.jsxs("div",{className:M,style:N,"data-admesh-theme":t==null?void 0:t.mode,"data-sidebar-position":s.position,"data-sidebar-size":s.size,children:[s.showHeader!==!1&&e.jsx(fe,{title:c,theme:t,collapsible:s.collapsible,isCollapsed:l,onToggle:y,onSearch:s.showSearch?R:void 0,showSearch:s.showSearch&&!l}),!l&&e.jsx(pe,{recommendations:f,displayMode:s.displayMode,theme:t,maxRecommendations:s.maxRecommendations,onRecommendationClick:d,className:"flex-1 overflow-hidden"}),l&&s.collapsible&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-2",children:[e.jsx("button",{onClick:y,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",title:"Expand sidebar",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 5l7 7-7 7"})})}),e.jsx("div",{className:"mt-4 text-xs text-gray-500 dark:text-gray-400 transform -rotate-90 whitespace-nowrap",children:f.length})]}),!l&&e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700",children:e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 text-center",children:"Powered by AdMesh"})})]})]})},be=({message:r,theme:s,onRecommendationClick:t,className:c})=>{const o=r.role==="user",a=r.role==="assistant",d=v("admesh-chat-message","flex items-start gap-3",{"flex-row-reverse":o},c),u=v("max-w-xs lg:max-w-sm px-4 py-3 rounded-lg text-sm",{"bg-gradient-to-r from-blue-600 to-indigo-600 text-white":o,"bg-gray-100 dark:bg-slate-800 text-gray-900 dark:text-gray-100":a,"bg-yellow-100 dark:bg-yellow-900 text-yellow-900 dark:text-yellow-100":r.role==="system"}),b=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,g=l=>l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:d,style:b,"data-admesh-theme":s==null?void 0:s.mode,children:[!o&&e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 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"})})}),o&&e.jsx("div",{className:"w-8 h-8 bg-gray-300 dark:bg-slate-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),e.jsxs("div",{className:`flex flex-col ${o?"items-end":"items-start"} flex-1`,children:[e.jsx("div",{className:u,children:e.jsx("div",{className:"whitespace-pre-wrap break-words",children:r.content})}),e.jsx("div",{className:v("text-xs text-gray-500 dark:text-gray-400 mt-1",{"text-right":o}),children:g(r.timestamp)}),r.recommendations&&r.recommendations.length>0&&e.jsx("div",{className:"mt-3 w-full max-w-md",children:e.jsx(ge,{recommendations:r.recommendations,config:{displayMode:"inline",context:"chat",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:500},theme:s,onRecommendationClick:t})})]})]})},ye=({placeholder:r="Type your message...",disabled:s=!1,suggestions:t=[],theme:c,onSendMessage:o,className:a})=>{const[d,u]=m.useState(""),[b,g]=m.useState(!1),[l,x]=m.useState([]),i=m.useRef(null),k=N=>{const j=N.target.value;if(u(j),j.trim()&&t.length>0){const C=t.filter(L=>L.toLowerCase().includes(j.toLowerCase()));x(C),g(C.length>0)}else g(!1);i.current&&(i.current.style.height="auto",i.current.style.height=`${Math.min(i.current.scrollHeight,120)}px`)},h=N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),w())},w=()=>{const N=d.trim();N&&!s&&o&&(o(N),u(""),g(!1),i.current&&(i.current.style.height="auto"))},f=N=>{u(N),g(!1),i.current&&i.current.focus()},y=v("admesh-chat-input","relative",a),R=v("w-full resize-none rounded-lg border border-gray-300 dark:border-slate-600","bg-white dark:bg-slate-800 text-gray-900 dark:text-gray-100","placeholder-gray-500 dark:placeholder-gray-400","focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600","pr-12 pl-4 py-3 text-sm leading-5",{"opacity-50 cursor-not-allowed":s}),z=v("absolute right-2 bottom-2 p-2 rounded-lg transition-all duration-200","flex items-center justify-center",{"bg-blue-600 hover:bg-blue-700 text-white":d.trim()&&!s,"bg-gray-200 dark:bg-slate-700 text-gray-400 dark:text-gray-500 cursor-not-allowed":!d.trim()||s}),M=c!=null&&c.accentColor?{"--admesh-primary":c.accentColor}:void 0;return e.jsxs("div",{className:y,style:M,"data-admesh-theme":c==null?void 0:c.mode,children:[b&&l.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 rounded-lg shadow-lg max-h-40 overflow-y-auto z-10",children:l.slice(0,5).map((N,j)=>e.jsx("button",{onClick:()=>f(N),className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors first:rounded-t-lg last:rounded-b-lg",children:N},j))}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:i,value:d,onChange:k,onKeyDown:h,placeholder:r,disabled:s,rows:1,className:R,style:{minHeight:"44px",maxHeight:"120px"}}),e.jsx("button",{onClick:w,disabled:!d.trim()||s,className:z,"aria-label":"Send message",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:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Press Enter to send, Shift+Enter for new line"}),e.jsxs("span",{className:v("transition-opacity duration-200",{"opacity-0":d.length<100}),children:[d.length,"/500"]})]})]})},ve=({messages:r,config:s,theme:t,isLoading:c=!1,onSendMessage:o,onRecommendationClick:a,className:d})=>{const u=m.useRef(null),b=m.useRef(null);m.useEffect(()=>{u.current&&u.current.scrollIntoView({behavior:"smooth"})},[r]);const g=v("admesh-chat-interface","flex flex-col h-full bg-white dark:bg-slate-900",d),l=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,x=s.maxMessages?r.slice(-s.maxMessages):r;return e.jsxs("div",{className:g,style:l,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsx("div",{ref:b,className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600",children:x.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-blue-100 to-indigo-100 dark:from-blue-900 dark:to-indigo-900 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",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("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Welcome to AdMesh AI"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 max-w-xs",children:"Ask me anything about products, tools, or services. I'll provide personalized recommendations just for you!"})]}):e.jsxs(e.Fragment,{children:[x.map(i=>e.jsx(be,{message:i,theme:t,onRecommendationClick:a},i.id)),c&&s.enableTypingIndicator!==!1&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 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("div",{className:"bg-gray-100 dark:bg-slate-800 rounded-lg px-4 py-3 max-w-xs",children:e.jsxs("div",{className:"flex space-x-1",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]}),e.jsx("div",{ref:u})]})}),s.enableSuggestions&&s.suggestions&&s.suggestions.length>0&&r.length===0&&e.jsxs("div",{className:"px-4 pb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"Quick suggestions:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.suggestions.slice(0,3).map((i,k)=>e.jsx("button",{onClick:()=>o==null?void 0:o(i),className:"px-3 py-1.5 text-xs bg-gray-100 dark:bg-slate-800 hover:bg-gray-200 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-300 rounded-full transition-colors",children:i},k))})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-slate-700 p-4",children:e.jsx(ye,{placeholder:s.placeholder||"Ask me about products, tools, or services...",disabled:c,suggestions:s.suggestions,theme:t,onSendMessage:o})})]})},Oe=({config:r,theme:s,title:t="AI Assistant",subtitle:c="Get personalized recommendations",isOpen:o,onToggle:a,onSendMessage:d,onRecommendationClick:u,className:b})=>{const[g,l]=m.useState(r.autoOpen||!1),[x,i]=m.useState([]),[k,h]=m.useState(!1),[w,f]=m.useState(!1),y=o!==void 0?o:g;m.useEffect(()=>{if(r.showWelcomeMessage&&r.welcomeMessage&&x.length===0){const T={id:"welcome",role:"assistant",content:r.welcomeMessage,timestamp:new Date};i([T])}},[r.showWelcomeMessage,r.welcomeMessage,x.length]);const R=()=>{a?a():l(!g),f(!0)},z=async T=>{if(!d)return;const O={id:`user-${Date.now()}`,role:"user",content:T,timestamp:new Date};i(I=>[...I,O]),h(!0);try{const I=await d(T);i(W=>[...W,I])}catch(I){console.error("Error sending message:",I);const W={id:`error-${Date.now()}`,role:"assistant",content:"Sorry, I encountered an error. Please try again.",timestamp:new Date};i(Y=>[...Y,W])}finally{h(!1)}},M=()=>{switch(r.size){case"sm":return"w-80 h-96";case"md":return"w-96 h-[32rem]";case"lg":return"w-[28rem] h-[36rem]";case"xl":return"w-[32rem] h-[40rem]";default:return"w-96 h-[32rem]"}},j=v("admesh-floating-chat","fixed z-50 transition-all duration-300 ease-in-out",(()=>{switch(r.position){case"bottom-right":return"bottom-4 right-4";case"bottom-left":return"bottom-4 left-4";case"top-right":return"top-4 right-4";case"top-left":return"top-4 left-4";default:return"bottom-4 right-4"}})(),b),C=v("bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",M(),{"opacity-0 scale-95 pointer-events-none":!y,"opacity-100 scale-100":y}),L=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:j,style:L,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:C,children:y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gradient-to-r from-blue-600 to-indigo-600 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-white bg-opacity-20 rounded-full flex items-center justify-center",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 10V3L4 14h7v7l9-11h-7z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:t}),e.jsx("p",{className:"text-xs text-blue-100",children:c})]})]}),e.jsx("button",{onClick:R,className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Close chat",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:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx(ve,{messages:x,config:r,theme:s,isLoading:k,onSendMessage:z,onRecommendationClick:u,className:"h-full"})]})}),!y&&e.jsxs("button",{onClick:R,className:v("w-14 h-14 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700","text-white rounded-full shadow-lg hover:shadow-xl transition-all duration-200","flex items-center justify-center relative"),"aria-label":"Open chat",children:[e.jsx("svg",{className:"w-6 h-6",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"})}),!w&&e.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-pulse"})]}),y&&e.jsx("div",{className:"absolute bottom-2 right-2 text-xs text-gray-400 dark:text-gray-500 bg-white dark:bg-slate-900 px-2 py-1 rounded shadow-sm",children:"Powered by AdMesh"})]})},Be="0.2.1",We={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=ue;exports.AdMeshChatInput=ye;exports.AdMeshChatInterface=ve;exports.AdMeshChatMessage=be;exports.AdMeshCompareTable=ee;exports.AdMeshConversationSummary=me;exports.AdMeshConversationalUnit=ge;exports.AdMeshFloatingChat=Oe;exports.AdMeshInlineRecommendation=P;exports.AdMeshLayout=he;exports.AdMeshLinkTracker=D;exports.AdMeshProductCard=H;exports.AdMeshSidebar=ze;exports.AdMeshSidebarContent=pe;exports.AdMeshSidebarHeader=fe;exports.DEFAULT_CONFIG=We;exports.VERSION=Be;exports.buildAdMeshLink=Le;exports.extractTrackingData=Re;exports.setAdMeshTrackerConfig=Se;exports.useAdMeshStyles=xe;exports.useAdMeshTracker=ce;
276
+ `;let X=!1;const xe=()=>{m.useEffect(()=>{if(X)return;const r=document.createElement("style");return r.id="admesh-ui-sdk-styles",r.textContent=Ie,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(r),X=!0),()=>{const s=document.getElementById("admesh-ui-sdk-styles");s&&document.head.contains(s)&&(document.head.removeChild(s),X=!1)}},[])},Pe=(r,s,t)=>{if(!t&&s)switch(s){case"compare_products":return"compare";case"best_for_use_case":case"trial_demo":case"budget_conscious":return"cards";default:return"cards"}const c=r.length;if(c>=2&&c<=4){const o=r.some(d=>d.features&&d.features.length>0),a=r.some(d=>d.pricing);if(o||a)return"compare"}return"cards"},he=({recommendations:r,intentType:s,theme:t,maxDisplayed:c=6,showMatchScores:o=!0,showFeatures:a=!0,autoLayout:d=!0,onProductClick:u,onTrackView:b,className:g})=>{xe();const l=m.useMemo(()=>r.slice(0,c),[r,c]),x=m.useMemo(()=>Pe(l,s,d),[l,s,d]),i=v("admesh-component",g),k=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return l.length===0?e.jsx("div",{className:i,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:i,style:k,"data-admesh-theme":t==null?void 0:t.mode,children:x==="compare"?e.jsx(ee,{recommendations:l,theme:t,maxProducts:Math.min(l.length,4),showMatchScores:o,showFeatures:a,onProductClick:u}):e.jsx("div",{className:"space-y-4",children:l.map((h,w)=>e.jsx(H,{recommendation:h,theme:t,showMatchScore:o,showBadges:!0,maxKeywords:3,onClick:u,onTrackView:b},h.product_id||h.ad_id||w))})})};he.displayName="AdMeshLayout";const P=({recommendation:r,theme:s,compact:t=!1,showReason:c=!0,onClick:o,className:a})=>{const d=Math.round(r.intent_match_score*100),u=v("admesh-inline-recommendation","group cursor-pointer transition-all duration-200",{"p-2 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":!t,"p-1.5 rounded hover:bg-gray-50 dark:hover:bg-slate-800/30":t},a),b=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsx(D,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:()=>o==null?void 0:o(r.ad_id,r.admesh_link),trackingData:{title:r.title,matchScore:r.intent_match_score},className:u,children:e.jsxs("div",{className:"flex items-start gap-3",style:b,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.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-center gap-2 mb-1",children:[e.jsx("h4",{className:v("font-medium text-gray-900 dark:text-gray-100 truncate",t?"text-sm":"text-base"),children:r.title}),r.intent_match_score>=.7&&e.jsxs("span",{className:v("inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium",r.intent_match_score>=.8?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"),children:[d,"% match"]})]}),c&&r.reason&&e.jsx("p",{className:v("text-gray-600 dark:text-gray-400 line-clamp-2",t?"text-xs":"text-sm"),children:r.reason}),!t&&r.keywords&&r.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[r.keywords.slice(0,3).map((g,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:g},l)),r.keywords.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",r.keywords.length-3," more"]})]}),!t&&(r.has_free_tier||r.trial_days)&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[r.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-900/30 dark:text-green-400",children:"Free tier"}),r.trial_days&&r.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:[r.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"})})})]})})},me=({recommendations:r,conversationSummary:s,theme:t,showTopRecommendations:c=3,onRecommendationClick:o,onStartNewConversation:a,className:d})=>{const u=r.sort((l,x)=>x.intent_match_score-l.intent_match_score).slice(0,c),b=v("admesh-conversation-summary","bg-gradient-to-br from-slate-50 to-blue-50 dark:from-slate-900 dark:to-slate-800","rounded-lg border border-gray-200 dark:border-slate-700 p-6",d),g=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:b,style:g,"data-admesh-theme":t==null?void 0:t.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-10 h-10 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",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",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Conversation Summary"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Here's what we discussed and found for you"})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-4 border border-gray-100 dark:border-slate-700",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:s})})}),u.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-blue-600 dark:text-blue-400",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-gray-900 dark:text-gray-100",children:"Top Recommendations"})]}),e.jsx("div",{className:"space-y-2",children:u.map((l,x)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-2 top-2 z-10",children:e.jsx("div",{className:v("w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",x===0?"bg-yellow-500":x===1?"bg-gray-400":"bg-orange-400"),children:x+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(P,{recommendation:l,theme:t,compact:!1,showReason:!0,onClick:o})})]},l.ad_id||x))})]}),r.length>c&&e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",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-blue-800 dark:text-blue-300",children:[r.length-c," additional recommendation",r.length-c>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-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white 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:()=>{u.length>0&&(o==null||o(u[0].ad_id,u[0].admesh_link))},className:"flex-1 bg-white dark:bg-slate-800 hover:bg-gray-50 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-300 font-medium py-2.5 px-4 rounded-lg border border-gray-300 dark:border-slate-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-slate-700",children:e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"})})]})},ge=({recommendations:r,config:s,theme:t,conversationSummary:c,userQuery:o,sessionId:a,onRecommendationClick:d,onDismiss:u,className:b})=>{const[g,l]=m.useState(s.autoShow!==!1),[x,i]=m.useState(!1);if(m.useEffect(()=>{if(s.delayMs&&s.delayMs>0){const M=setTimeout(()=>{l(!0),i(!0)},s.delayMs);return()=>clearTimeout(M)}else i(!0)},[s.delayMs]),!g||r.length===0)return null;const k=s.maxRecommendations||3,h=r.slice(0,k),w=(M,N)=>{d==null||d(M,N)},f=()=>{l(!1),u==null||u()},y=()=>{switch(s.displayMode){case"summary":return c?e.jsx(me,{recommendations:h,conversationSummary:c,theme:t,showTopRecommendations:k,onRecommendationClick:w,onStartNewConversation:u}):null;case"inline":return e.jsx("div",{className:"space-y-2",children:h.map((M,N)=>e.jsx(P,{recommendation:M,theme:t,compact:!0,showReason:!0,onClick:w},M.ad_id||N))});case"minimal":return h.length>0?e.jsxs("div",{className:"admesh-minimal-unit",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[h.length," intelligent match",h.length>1?"es":""," found"]})]}),e.jsx(P,{recommendation:h[0],theme:t,compact:!0,showReason:!1,onClick:w}),h.length>1&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["+",h.length-1," more recommendation",h.length>2?"s":""]})]}):null;case"floating":return e.jsxs("div",{className:"admesh-floating-unit bg-white dark:bg-slate-800 rounded-lg shadow-lg border border-gray-200 dark:border-slate-700 p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:"Recommended for you"})]}),u&&e.jsx("button",{onClick:f,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Dismiss recommendations",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:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"space-y-2",children:h.map((M,N)=>e.jsx(P,{recommendation:M,theme:t,compact:!0,showReason:!1,onClick:w},M.ad_id||N))})]});default:return e.jsx("div",{className:"space-y-3",children:h.map((M,N)=>e.jsx(H,{recommendation:M,theme:t,showMatchScore:!1,showBadges:!0,onClick:w},M.ad_id||N))})}},R=v("admesh-conversational-unit","transition-all duration-300 ease-in-out",{"opacity-0 translate-y-2":!x,"opacity-100 translate-y-0":x,"fixed bottom-4 right-4 max-w-sm z-50":s.displayMode==="floating","my-3":s.displayMode==="inline","mt-4 pt-4 border-t border-gray-200 dark:border-slate-700":s.displayMode==="summary"},b),z=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:R,style:z,"data-admesh-theme":t==null?void 0:t.mode,"data-admesh-context":s.context,"data-session-id":a,children:[y(),s.showPoweredBy!==!1&&e.jsx("div",{className:"flex justify-end mt-2",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})})]})},fe=({title:r,theme:s,collapsible:t=!1,isCollapsed:c=!1,onToggle:o,onSearch:a,showSearch:d=!1,className:u})=>{const[b,g]=m.useState(""),[l,x]=m.useState(!1),i=f=>{const y=f.target.value;g(y),a==null||a(y)},k=()=>{g(""),a==null||a("")},h=v("admesh-sidebar-header","flex flex-col p-4 border-b border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",u),w=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:h,style:w,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate",children:r}),t&&e.jsx("button",{onClick:o,className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors flex-shrink-0",title:c?"Expand sidebar":"Collapse sidebar",children:e.jsx("svg",{className:v("w-4 h-4 text-gray-600 dark:text-gray-400 transition-transform duration-200",{"rotate-180":c}),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),d&&!c&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:v("relative flex items-center transition-all duration-200",{"ring-2 ring-blue-500 dark:ring-blue-400":l}),children:[e.jsx("div",{className:"absolute left-3 pointer-events-none",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:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("input",{type:"text",value:b,onChange:i,onFocus:()=>x(!0),onBlur:()=>x(!1),placeholder:"Search recommendations...",className:v("w-full pl-10 pr-10 py-2 text-sm bg-white dark:bg-slate-900 border border-gray-300 dark:border-slate-600 rounded-lg","placeholder-gray-400 dark:placeholder-gray-500 text-gray-900 dark:text-gray-100","focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200")}),b&&e.jsx("button",{onClick:k,className:"absolute right-3 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors",title:"Clear search",children:e.jsx("svg",{className:"w-3 h-3 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:"M6 18L18 6M6 6l12 12"})})})]}),b&&e.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Search results will be filtered in real-time"})]}),!c&&e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),e.jsx("span",{children:"Live recommendations"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3",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("span",{children:"AI-powered"})]})]})]})},pe=({recommendations:r,displayMode:s,theme:t,maxRecommendations:c,onRecommendationClick:o,className:a})=>{const[d,u]=m.useState(!1),[b,g]=m.useState("all"),l=c?r.slice(0,c):r,i=(()=>{switch(b){case"top":return l.filter(f=>f.intent_match_score>=.8).slice(0,5);case"recent":return l.slice(0,3);default:return l}})(),k=v("admesh-sidebar-content","flex flex-col h-full",a),h=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,w=()=>{if(i.length===0)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-slate-800 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 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:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"No recommendations found"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Try adjusting your search or filters"})]});switch(s){case"recommendations":return e.jsx("div",{className:"space-y-3",children:i.map((f,y)=>e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!0,onClick:o},f.ad_id||y))});case"history":return e.jsx("div",{className:"space-y-2",children:i.map((f,y)=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-800 transition-colors",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:f.title}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(f.intent_match_score*100),"% match"]})]})]},f.ad_id||y))});case"favorites":return e.jsx("div",{className:"space-y-3",children:i.slice(0,3).map((f,y)=>e.jsxs("div",{className:"relative",children:[e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!1,onClick:o}),e.jsx("button",{className:"absolute top-2 right-2 p-1 rounded-full hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",children:e.jsx("svg",{className:"w-3 h-3 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})]},f.ad_id||y))});case"mixed":return e.jsxs("div",{className:"space-y-4",children:[i[0]&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"Top Pick"}),e.jsx(H,{recommendation:i[0],theme:t,showMatchScore:!0,showBadges:!0,onClick:o,className:"text-xs"})]}),i.slice(1).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"More Options"}),e.jsx("div",{className:"space-y-2",children:i.slice(1,4).map((f,y)=>e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!1,onClick:o},f.ad_id||y))})]})]});default:return e.jsx("div",{className:"space-y-3",children:i.map((f,y)=>e.jsx(P,{recommendation:f,theme:t,compact:!0,showReason:!0,onClick:o},f.ad_id||y))})}};return e.jsxs("div",{className:k,style:h,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsxs("div",{className:"flex border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900",children:[e.jsxs("button",{onClick:()=>g("all"),className:v("flex-1 px-3 py-2 text-xs font-medium transition-colors",b==="all"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:["All (",r.length,")"]}),e.jsx("button",{onClick:()=>g("top"),className:v("flex-1 px-3 py-2 text-xs font-medium transition-colors",b==="top"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Top"}),e.jsx("button",{onClick:()=>g("recent"),className:v("flex-1 px-3 py-2 text-xs font-medium transition-colors",b==="recent"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Recent"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w()}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",children:e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[i.length," recommendation",i.length!==1?"s":""]}),e.jsx("button",{onClick:()=>u(!d),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors",children:"Filters"})]})})]})},ze=({recommendations:r,config:s,theme:t,title:c="Recommendations",isOpen:o=!0,onToggle:a,onRecommendationClick:d,onSearch:u,onFilter:b,className:g})=>{const[l,x]=m.useState(s.defaultCollapsed||!1),[i,k]=m.useState(""),[h,w]=m.useState({});m.useEffect(()=>{if(s.autoRefresh&&s.refreshInterval){const j=setInterval(()=>{console.log("Auto-refreshing recommendations...")},s.refreshInterval);return()=>clearInterval(j)}},[s.autoRefresh,s.refreshInterval]);const f=m.useMemo(()=>{let j=[...r];if(i.trim()){const C=i.toLowerCase();j=j.filter(L=>{var T;return L.title.toLowerCase().includes(C)||L.reason.toLowerCase().includes(C)||((T=L.keywords)==null?void 0:T.some(O=>O.toLowerCase().includes(C)))})}return h.categories&&h.categories.length>0&&(j=j.filter(C=>{var L;return(L=C.categories)==null?void 0:L.some(T=>{var O;return(O=h.categories)==null?void 0:O.includes(T)})})),h.hasFreeTier&&(j=j.filter(C=>C.has_free_tier)),h.hasTrial&&(j=j.filter(C=>C.trial_days&&C.trial_days>0)),h.minMatchScore!==void 0&&(j=j.filter(C=>C.intent_match_score>=h.minMatchScore)),j.sort((C,L)=>L.intent_match_score-C.intent_match_score),s.maxRecommendations&&(j=j.slice(0,s.maxRecommendations)),j},[r,i,h,s.maxRecommendations]),y=()=>{s.collapsible&&(x(!l),a==null||a())},R=j=>{k(j),u==null||u(j)},M=v("admesh-sidebar","flex flex-col bg-white dark:bg-slate-900 border-gray-200 dark:border-slate-700 shadow-lg transition-all duration-300 ease-in-out",(()=>{switch(s.size){case"sm":return l?"w-12":"w-64";case"md":return l?"w-12":"w-80";case"lg":return l?"w-12":"w-96";case"xl":return l?"w-12":"w-[28rem]";default:return l?"w-12":"w-80"}})(),{"border-r":s.position==="left","border-l":s.position==="right","fixed top-0 bottom-0 z-50":!0,"left-0":s.position==="left","right-0":s.position==="right","transform -translate-x-full":s.position==="left"&&!o,"transform translate-x-full":s.position==="right"&&!o},g),N=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return!o&&!s.collapsible?null:e.jsxs(e.Fragment,{children:[o&&!l&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-40 lg:hidden",onClick:()=>a==null?void 0:a()}),e.jsxs("div",{className:M,style:N,"data-admesh-theme":t==null?void 0:t.mode,"data-sidebar-position":s.position,"data-sidebar-size":s.size,children:[s.showHeader!==!1&&e.jsx(fe,{title:c,theme:t,collapsible:s.collapsible,isCollapsed:l,onToggle:y,onSearch:s.showSearch?R:void 0,showSearch:s.showSearch&&!l}),!l&&e.jsx(pe,{recommendations:f,displayMode:s.displayMode,theme:t,maxRecommendations:s.maxRecommendations,onRecommendationClick:d,className:"flex-1 overflow-hidden"}),l&&s.collapsible&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-2",children:[e.jsx("button",{onClick:y,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",title:"Expand sidebar",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 5l7 7-7 7"})})}),e.jsx("div",{className:"mt-4 text-xs text-gray-500 dark:text-gray-400 transform -rotate-90 whitespace-nowrap",children:f.length})]}),!l&&e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700",children:e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 text-center",children:"Powered by AdMesh"})})]})]})},be=({message:r,theme:s,onRecommendationClick:t,className:c})=>{const o=r.role==="user",a=r.role==="assistant",d=v("admesh-chat-message","flex items-start gap-3",{"flex-row-reverse":o},c),u=v("max-w-xs lg:max-w-sm px-4 py-3 rounded-lg text-sm",{"bg-gradient-to-r from-blue-600 to-indigo-600 text-white":o,"bg-gray-100 dark:bg-slate-800 text-gray-900 dark:text-gray-100":a,"bg-yellow-100 dark:bg-yellow-900 text-yellow-900 dark:text-yellow-100":r.role==="system"}),b=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,g=l=>l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:d,style:b,"data-admesh-theme":s==null?void 0:s.mode,children:[!o&&e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 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"})})}),o&&e.jsx("div",{className:"w-8 h-8 bg-gray-300 dark:bg-slate-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),e.jsxs("div",{className:`flex flex-col ${o?"items-end":"items-start"} flex-1`,children:[e.jsx("div",{className:u,children:e.jsx("div",{className:"whitespace-pre-wrap break-words",children:r.content})}),e.jsx("div",{className:v("text-xs text-gray-500 dark:text-gray-400 mt-1",{"text-right":o}),children:g(r.timestamp)}),r.recommendations&&r.recommendations.length>0&&e.jsxs("div",{className:"mt-3 w-full max-w-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",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.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[r.recommendations.length," recommendation",r.recommendations.length>1?"s":""," found"]})]}),e.jsx(ge,{recommendations:r.recommendations,config:{displayMode:"inline",context:"chat",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:300},theme:s,onRecommendationClick:t,className:"bg-gray-50 dark:bg-slate-800/50 rounded-lg p-3 border border-gray-200 dark:border-slate-700"})]})]})]})},ye=({placeholder:r="Type your message...",disabled:s=!1,suggestions:t=[],theme:c,onSendMessage:o,className:a})=>{const[d,u]=m.useState(""),[b,g]=m.useState(!1),[l,x]=m.useState([]),i=m.useRef(null),k=N=>{const j=N.target.value;if(u(j),j.trim()&&t.length>0){const C=t.filter(L=>L.toLowerCase().includes(j.toLowerCase()));x(C),g(C.length>0)}else g(!1);i.current&&(i.current.style.height="auto",i.current.style.height=`${Math.min(i.current.scrollHeight,120)}px`)},h=N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),w())},w=()=>{const N=d.trim();N&&!s&&o&&(o(N),u(""),g(!1),i.current&&(i.current.style.height="auto"))},f=N=>{u(N),g(!1),i.current&&i.current.focus()},y=v("admesh-chat-input","relative",a),R=v("w-full resize-none rounded-lg border border-gray-300 dark:border-slate-600","bg-white dark:bg-slate-800 text-gray-900 dark:text-gray-100","placeholder-gray-500 dark:placeholder-gray-400","focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600","pr-12 pl-4 py-3 text-sm leading-5",{"opacity-50 cursor-not-allowed":s}),z=v("absolute right-2 bottom-2 p-2 rounded-lg transition-all duration-200","flex items-center justify-center",{"bg-blue-600 hover:bg-blue-700 text-white":d.trim()&&!s,"bg-gray-200 dark:bg-slate-700 text-gray-400 dark:text-gray-500 cursor-not-allowed":!d.trim()||s}),M=c!=null&&c.accentColor?{"--admesh-primary":c.accentColor}:void 0;return e.jsxs("div",{className:y,style:M,"data-admesh-theme":c==null?void 0:c.mode,children:[b&&l.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 rounded-lg shadow-lg max-h-40 overflow-y-auto z-10",children:l.slice(0,5).map((N,j)=>e.jsx("button",{onClick:()=>f(N),className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors first:rounded-t-lg last:rounded-b-lg",children:N},j))}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:i,value:d,onChange:k,onKeyDown:h,placeholder:r,disabled:s,rows:1,className:R,style:{minHeight:"44px",maxHeight:"120px"}}),e.jsx("button",{onClick:w,disabled:!d.trim()||s,className:z,"aria-label":"Send message",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:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Press Enter to send, Shift+Enter for new line"}),e.jsxs("span",{className:v("transition-opacity duration-200",{"opacity-0":d.length<100}),children:[d.length,"/500"]})]})]})},ve=({messages:r,config:s,theme:t,isLoading:c=!1,onSendMessage:o,onRecommendationClick:a,className:d})=>{const u=m.useRef(null),b=m.useRef(null);m.useEffect(()=>{u.current&&u.current.scrollIntoView({behavior:"smooth"})},[r]);const g=v("admesh-chat-interface","flex flex-col h-full bg-white dark:bg-slate-900",d),l=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,x=s.maxMessages?r.slice(-s.maxMessages):r;return e.jsxs("div",{className:g,style:l,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsx("div",{ref:b,className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600",children:x.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-blue-100 to-indigo-100 dark:from-blue-900 dark:to-indigo-900 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",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("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Welcome to AdMesh AI"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 max-w-xs",children:"Ask me anything about products, tools, or services. I'll provide personalized recommendations just for you!"})]}):e.jsxs(e.Fragment,{children:[x.map(i=>e.jsx(be,{message:i,theme:t,onRecommendationClick:a},i.id)),c&&s.enableTypingIndicator!==!1&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 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("div",{className:"bg-gray-100 dark:bg-slate-800 rounded-lg px-4 py-3 max-w-xs",children:e.jsxs("div",{className:"flex space-x-1",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]}),e.jsx("div",{ref:u})]})}),s.enableSuggestions&&s.suggestions&&s.suggestions.length>0&&r.length===0&&e.jsxs("div",{className:"px-4 pb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"Quick suggestions:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.suggestions.slice(0,3).map((i,k)=>e.jsx("button",{onClick:()=>o==null?void 0:o(i),className:"px-3 py-1.5 text-xs bg-gray-100 dark:bg-slate-800 hover:bg-gray-200 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-300 rounded-full transition-colors",children:i},k))})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-slate-700 p-4",children:e.jsx(ye,{placeholder:s.placeholder||"Ask me about products, tools, or services...",disabled:c,suggestions:s.suggestions,theme:t,onSendMessage:o})})]})},Oe=({config:r,theme:s,title:t="AI Assistant",subtitle:c="Get personalized recommendations",isOpen:o,onToggle:a,onSendMessage:d,onRecommendationClick:u,className:b})=>{const[g,l]=m.useState(r.autoOpen||!1),[x,i]=m.useState([]),[k,h]=m.useState(!1),[w,f]=m.useState(!1),y=o!==void 0?o:g;m.useEffect(()=>{if(r.showWelcomeMessage&&r.welcomeMessage&&x.length===0){const T={id:"welcome",role:"assistant",content:r.welcomeMessage,timestamp:new Date};i([T])}},[r.showWelcomeMessage,r.welcomeMessage,x.length]);const R=()=>{a?a():l(!g),f(!0)},z=async T=>{if(!d)return;const O={id:`user-${Date.now()}`,role:"user",content:T,timestamp:new Date};i(I=>[...I,O]),h(!0);try{const I=await d(T);i(W=>[...W,I])}catch(I){console.error("Error sending message:",I);const W={id:`error-${Date.now()}`,role:"assistant",content:"Sorry, I encountered an error. Please try again.",timestamp:new Date};i(Y=>[...Y,W])}finally{h(!1)}},M=()=>{switch(r.size){case"sm":return"w-80 h-96";case"md":return"w-96 h-[32rem]";case"lg":return"w-[28rem] h-[36rem]";case"xl":return"w-[32rem] h-[40rem]";default:return"w-96 h-[32rem]"}},j=v("admesh-floating-chat","fixed z-50 transition-all duration-300 ease-in-out",(()=>{switch(r.position){case"bottom-right":return"bottom-4 right-4";case"bottom-left":return"bottom-4 left-4";case"top-right":return"top-4 right-4";case"top-left":return"top-4 left-4";default:return"bottom-4 right-4"}})(),b),C=v("bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",M(),{"opacity-0 scale-95 pointer-events-none":!y,"opacity-100 scale-100":y}),L=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:j,style:L,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:C,children:y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gradient-to-r from-blue-600 to-indigo-600 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-white bg-opacity-20 rounded-full flex items-center justify-center",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 10V3L4 14h7v7l9-11h-7z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:t}),e.jsx("p",{className:"text-xs text-blue-100",children:c})]})]}),e.jsx("button",{onClick:R,className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Close chat",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:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx(ve,{messages:x,config:r,theme:s,isLoading:k,onSendMessage:z,onRecommendationClick:u,className:"h-full"})]})}),!y&&e.jsxs("button",{onClick:R,className:v("w-14 h-14 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700","text-white rounded-full shadow-lg hover:shadow-xl transition-all duration-200","flex items-center justify-center relative"),"aria-label":"Open chat",children:[e.jsx("svg",{className:"w-6 h-6",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"})}),!w&&e.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-pulse"})]}),y&&e.jsx("div",{className:"absolute bottom-2 right-2 text-xs text-gray-400 dark:text-gray-500 bg-white dark:bg-slate-900 px-2 py-1 rounded shadow-sm",children:"Powered by AdMesh"})]})},Be="0.2.1",We={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=ue;exports.AdMeshChatInput=ye;exports.AdMeshChatInterface=ve;exports.AdMeshChatMessage=be;exports.AdMeshCompareTable=ee;exports.AdMeshConversationSummary=me;exports.AdMeshConversationalUnit=ge;exports.AdMeshFloatingChat=Oe;exports.AdMeshInlineRecommendation=P;exports.AdMeshLayout=he;exports.AdMeshLinkTracker=D;exports.AdMeshProductCard=H;exports.AdMeshSidebar=ze;exports.AdMeshSidebarContent=pe;exports.AdMeshSidebarHeader=fe;exports.DEFAULT_CONFIG=We;exports.VERSION=Be;exports.buildAdMeshLink=Le;exports.extractTrackingData=Re;exports.setAdMeshTrackerConfig=Se;exports.useAdMeshStyles=xe;exports.useAdMeshTracker=ce;
277
277
  //# sourceMappingURL=index.js.map