admesh-ui-sdk 0.3.1 → 0.4.0
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/CONVERSATIONAL_GUIDE.md +326 -0
- package/README.md +198 -5
- package/dist/index.d.ts +51 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +762 -433
- package/dist/index.mjs.map +1 -1
- package/examples/conversational-usage.jsx +248 -0
- package/package.json +9 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react");function fe(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var I={exports:{}},S={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var re;function pe(){if(re)return S;re=1;var r=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(u,o,n){var d=null;if(n!==void 0&&(d=""+n),o.key!==void 0&&(d=""+o.key),"key"in o){n={};for(var i in o)i!=="key"&&(n[i]=o[i])}else n=o;return o=n.ref,{$$typeof:r,type:u,key:d,ref:o!==void 0?o:null,props:n}}return S.Fragment=t,S.jsx=a,S.jsxs=a,S}var L={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var se;function ye(){return se||(se=1,process.env.NODE_ENV!=="production"&&function(){function r(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===he?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case v:return"Fragment";case N:return"Profiler";case w:return"StrictMode";case C:return"Suspense";case ce:return"SuspenseList";case me:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case x:return"Portal";case B:return(s.displayName||"Context")+".Provider";case E:return(s._context.displayName||"Context")+".Consumer";case _:var m=s.render;return s=s.displayName,s||(s=m.displayName||m.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ue:return m=s.displayName||null,m!==null?m:r(s.type)||"Memo";case G:m=s._payload,s=s._init;try{return r(s(m))}catch{}}return null}function t(s){return""+s}function a(s){try{t(s);var m=!1}catch{m=!0}if(m){m=console;var g=m.error,k=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return g.call(m,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",k),t(s)}}function u(s){if(s===v)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===G)return"<...>";try{var m=r(s);return m?"<"+m+">":"<...>"}catch{return"<...>"}}function o(){var s=V.A;return s===null?null:s.getOwner()}function n(){return Error("react-stack-top-frame")}function d(s){if(J.call(s,"key")){var m=Object.getOwnPropertyDescriptor(s,"key").get;if(m&&m.isReactWarning)return!1}return s.key!==void 0}function i(s,m){function g(){K||(K=!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)",m))}g.isReactWarning=!0,Object.defineProperty(s,"key",{get:g,configurable:!0})}function p(){var s=r(this.type);return X[s]||(X[s]=!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.")),s=this.props.ref,s!==void 0?s:null}function y(s,m,g,k,T,A,W,$){return g=A.ref,s={$$typeof:b,type:s,key:m,props:A,_owner:T},(g!==void 0?g:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:p}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function l(s,m,g,k,T,A,W,$){var j=m.children;if(j!==void 0)if(k)if(xe(j)){for(k=0;k<j.length;k++)c(j[k]);Object.freeze&&Object.freeze(j)}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 c(j);if(J.call(m,"key")){j=r(s);var R=Object.keys(m).filter(function(ge){return ge!=="key"});k=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",ee[j+k]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,k,j,R,j),ee[j+k]=!0)}if(j=null,g!==void 0&&(a(g),j=""+g),d(m)&&(a(m.key),j=""+m.key),"key"in m){g={};for(var U in m)U!=="key"&&(g[U]=m[U])}else g=m;return j&&i(g,typeof s=="function"?s.displayName||s.name||"Unknown":s),y(s,j,A,T,o(),g,W,$)}function c(s){typeof s=="object"&&s!==null&&s.$$typeof===b&&s._store&&(s._store.validated=1)}var h=f,b=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),B=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),ce=Symbol.for("react.suspense_list"),ue=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),me=Symbol.for("react.activity"),he=Symbol.for("react.client.reference"),V=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,xe=Array.isArray,F=console.createTask?console.createTask:function(){return null};h={"react-stack-bottom-frame":function(s){return s()}};var K,X={},Q=h["react-stack-bottom-frame"].bind(h,n)(),Z=F(u(n)),ee={};L.Fragment=v,L.jsx=function(s,m,g,k,T){var A=1e4>V.recentlyCreatedOwnerStacks++;return l(s,m,g,!1,k,T,A?Error("react-stack-top-frame"):Q,A?F(u(s)):Z)},L.jsxs=function(s,m,g,k,T){var A=1e4>V.recentlyCreatedOwnerStacks++;return l(s,m,g,!0,k,T,A?Error("react-stack-top-frame"):Q,A?F(u(s)):Z)}}()),L}var ae;function be(){return ae||(ae=1,process.env.NODE_ENV==="production"?I.exports=pe():I.exports=ye()),I.exports}var e=be(),Y={exports:{}};/*!
|
|
23
23
|
Copyright (c) 2018 Jed Watson.
|
|
24
24
|
Licensed under the MIT License (MIT), see
|
|
25
25
|
http://jedwatson.github.io/classnames
|
|
26
|
-
*/var ee;function ye(){return ee||(ee=1,function(a){(function(){var o={}.hasOwnProperty;function n(){for(var s="",d=0;d<arguments.length;d++){var u=arguments[d];u&&(s=l(s,m(u)))}return s}function m(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var d="";for(var u in s)o.call(s,u)&&s[u]&&(d=l(d,u));return d}function l(s,d){return d?s?s+" "+d:s+d:s}a.exports?(n.default=n,a.exports=n):window.classNames=n})()}(F)),F.exports}var ve=ye();const S=xe(ve),be="https://api.useadmesh.com/track";let B={apiBaseUrl:be,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const ke=a=>{B={...B,...a}},re=a=>{const[o,n]=f.useState(!1),[m,l]=f.useState(null),s={...B,...a},d=f.useCallback((c,h)=>{s.debug&&console.log(`[AdMesh Tracker] ${c}`,h)},[s.debug]),u=f.useCallback(async(c,h)=>{if(!s.enabled){d("Tracking disabled, skipping event",{eventType:c,data:h});return}if(!h.adId||!h.admeshLink){const j="Missing required tracking data: adId and admeshLink are required";d(j,h),l(j);return}n(!0),l(null);const v={event_type:c,ad_id:h.adId,admesh_link:h.admeshLink,product_id:h.productId,user_id:h.userId,session_id:h.sessionId,revenue:h.revenue,conversion_type:h.conversionType,metadata:h.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};d(`Sending ${c} event`,v);let g=null;for(let j=1;j<=(s.retryAttempts||3);j++)try{const N=await fetch(`${s.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)});if(!N.ok)throw new Error(`HTTP ${N.status}: ${N.statusText}`);const E=await N.json();d(`${c} event tracked successfully`,E),n(!1);return}catch(N){g=N,d(`Attempt ${j} failed for ${c} event`,N),j<(s.retryAttempts||3)&&await new Promise(E=>setTimeout(E,(s.retryDelay||1e3)*j))}const _=`Failed to track ${c} event after ${s.retryAttempts} attempts: ${g==null?void 0:g.message}`;d(_,g),l(_),n(!1)},[s,d]),b=f.useCallback(async c=>u("click",c),[u]),k=f.useCallback(async c=>u("view",c),[u]),t=f.useCallback(async c=>(!c.revenue&&!c.conversionType&&d("Warning: Conversion tracking without revenue or conversion type",c),u("conversion",c)),[u]);return{trackClick:b,trackView:k,trackConversion:t,isTracking:o,error:m}},_e=(a,o,n)=>{try{const m=new URL(a);return m.searchParams.set("ad_id",o),m.searchParams.set("utm_source","admesh"),m.searchParams.set("utm_medium","recommendation"),n&&Object.entries(n).forEach(([l,s])=>{m.searchParams.set(l,s)}),m.toString()}catch{return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",a),a}},je=(a,o)=>({adId:a.ad_id,admeshLink:a.admesh_link,productId:a.product_id,...o}),O=({adId:a,admeshLink:o,productId:n,children:m,onClick:l,trackingData:s,className:d})=>{const{trackClick:u,trackView:b}=re(),k=f.useRef(null),t=f.useRef(!1);f.useEffect(()=>{if(!k.current||t.current)return;const h=new IntersectionObserver(v=>{v.forEach(g=>{g.isIntersecting&&!t.current&&(t.current=!0,b({adId:a,admeshLink:o,productId:n,...s}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return h.observe(k.current),()=>{h.disconnect()}},[a,o,n,s,b]);const c=f.useCallback(async h=>{try{await u({adId:a,admeshLink:o,productId:n,...s})}catch(_){console.error("Failed to track click:",_)}l&&l(),h.target.closest("a")||window.open(o,"_blank","noopener,noreferrer")},[a,o,n,s,u,l]);return e.jsx("div",{ref:k,className:d,onClick:c,style:{cursor:"pointer"},children:m})};O.displayName="AdMeshLinkTracker";const W=({recommendation:a,theme:o,showMatchScore:n=!0,showBadges:m=!0,onClick:l,className:s})=>{const d=f.useMemo(()=>{var v;const t=[];a.intent_match_score>=.8&&t.push("Top Match"),a.has_free_tier&&t.push("Free Tier"),a.trial_days&&a.trial_days>0&&t.push("Trial Available");const c=["ai","artificial intelligence","machine learning","ml","automation"];return(((v=a.keywords)==null?void 0:v.some(g=>c.some(_=>g.toLowerCase().includes(_))))||a.title.toLowerCase().includes("ai"))&&t.push("AI Powered"),t},[a]),u=Math.round(a.intent_match_score*100),b=S("admesh-component","admesh-card","relative p-3 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow transition-shadow cursor-pointer",s),k=o!=null&&o.accentColor?{"--admesh-primary":o.accentColor,"--admesh-primary-hover":o.accentColor+"dd"}:void 0;return e.jsx(O,{adId:a.ad_id,admeshLink:a.admesh_link,productId:a.product_id,onClick:()=>l==null?void 0:l(a.ad_id,a.admesh_link),trackingData:{title:a.title,matchScore:a.intent_match_score},className:b,children:e.jsxs("div",{className:"h-full flex flex-col",style:k,"data-admesh-theme":o==null?void 0:o.mode,children:[e.jsx("div",{className:"flex justify-between items-start mb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&d.includes("Top Match")&&e.jsx("span",{className:"text-xs font-semibold text-white bg-black px-2 py-0.5 rounded-full",children:"Top Match"}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200",children:a.title}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{className:"text-xs 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:a.reason}),n&&typeof a.intent_match_score=="number"&&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:"Confidence"}),e.jsxs("span",{children:[u,"%"]})]}),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:`${u}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-2",children:[a.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"})}),a.pricing]}),a.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"]}),a.trial_days&&a.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"})}),a.trial_days,"-day trial"]})]}),a.features&&a.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:a.features.map((t,c)=>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"})}),t]},c))})]}),a.integrations&&a.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:a.integrations.map((t,c)=>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"})}),t]},c))})]}),a.reviews_summary&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:a.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"})})]})})};W.displayName="AdMeshProductCard";const Y=({recommendations:a,theme:o,maxProducts:n=3,showMatchScores:m=!0,showFeatures:l=!0,onProductClick:s,className:d})=>{const u=f.useMemo(()=>a.slice(0,n),[a,n]),b=S("admesh-component","admesh-compare-layout",d),k=o!=null&&o.accentColor?{"--admesh-primary":o.accentColor}:void 0;return u.length===0?e.jsx("div",{className:b,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:b,style:k,"data-admesh-theme":o==null?void 0:o.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:[u.length," intelligent matches found"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:u.map((t,c)=>e.jsxs(O,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,onClick:()=>s==null?void 0:s(t.ad_id,t.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:[c===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:["#",c+1]})]}),m&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(t.intent_match_score*100),"% match"]})]}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 mb-2",children:t.title}),m&&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:"Confidence"}),e.jsxs("span",{children:[Math.round(t.intent_match_score*100),"%"]})]}),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(t.intent_match_score*100)}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",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"]})]}),l&&t.features&&t.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:[t.features.slice(0,4).map((h,v)=>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"})}),h]},v)),(t.features.length||0)>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:["+",t.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"})})]})]},t.product_id||c))}),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"})]})})]})})};Y.displayName="AdMeshCompareTable";const we={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},Ne={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},ae=({type:a,variant:o,size:n="md",className:m})=>{const l=o||we[a]||"secondary",s=Ne[a],d=S("admesh-component","admesh-badge",`admesh-badge--${l}`,`admesh-badge--${n}`,m);return e.jsxs("span",{className:d,children:[s&&e.jsx("span",{className:"admesh-badge__icon",children:s}),e.jsx("span",{className:"admesh-badge__text",children:a})]})};ae.displayName="AdMeshBadge";const Te=`
|
|
26
|
+
*/var te;function ve(){return te||(te=1,function(r){(function(){var t={}.hasOwnProperty;function a(){for(var n="",d=0;d<arguments.length;d++){var i=arguments[d];i&&(n=o(n,u(i)))}return n}function u(n){if(typeof n=="string"||typeof n=="number")return n;if(typeof n!="object")return"";if(Array.isArray(n))return a.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var d="";for(var i in n)t.call(n,i)&&n[i]&&(d=o(d,i));return d}function o(n,d){return d?n?n+" "+d:n+d:n}r.exports?(a.default=a,r.exports=a):window.classNames=a})()}(Y)),Y.exports}var ke=ve();const M=fe(ke),je="https://api.useadmesh.com/track";let H={apiBaseUrl:je,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const _e=r=>{H={...H,...r}},ne=r=>{const[t,a]=f.useState(!1),[u,o]=f.useState(null),n={...H,...r},d=f.useCallback((c,h)=>{n.debug&&console.log(`[AdMesh Tracker] ${c}`,h)},[n.debug]),i=f.useCallback(async(c,h)=>{if(!n.enabled){d("Tracking disabled, skipping event",{eventType:c,data:h});return}if(!h.adId||!h.admeshLink){const w="Missing required tracking data: adId and admeshLink are required";d(w,h),o(w);return}a(!0),o(null);const b={event_type:c,ad_id:h.adId,admesh_link:h.admeshLink,product_id:h.productId,user_id:h.userId,session_id:h.sessionId,revenue:h.revenue,conversion_type:h.conversionType,metadata:h.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};d(`Sending ${c} event`,b);let x=null;for(let w=1;w<=(n.retryAttempts||3);w++)try{const N=await fetch(`${n.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!N.ok)throw new Error(`HTTP ${N.status}: ${N.statusText}`);const E=await N.json();d(`${c} event tracked successfully`,E),a(!1);return}catch(N){x=N,d(`Attempt ${w} failed for ${c} event`,N),w<(n.retryAttempts||3)&&await new Promise(E=>setTimeout(E,(n.retryDelay||1e3)*w))}const v=`Failed to track ${c} event after ${n.retryAttempts} attempts: ${x==null?void 0:x.message}`;d(v,x),o(v),a(!1)},[n,d]),p=f.useCallback(async c=>i("click",c),[i]),y=f.useCallback(async c=>i("view",c),[i]),l=f.useCallback(async c=>(!c.revenue&&!c.conversionType&&d("Warning: Conversion tracking without revenue or conversion type",c),i("conversion",c)),[i]);return{trackClick:p,trackView:y,trackConversion:l,isTracking:t,error:u}},we=(r,t,a)=>{try{const u=new URL(r);return u.searchParams.set("ad_id",t),u.searchParams.set("utm_source","admesh"),u.searchParams.set("utm_medium","recommendation"),a&&Object.entries(a).forEach(([o,n])=>{u.searchParams.set(o,n)}),u.toString()}catch{return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",r),r}},Ne=(r,t)=>({adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,...t}),O=({adId:r,admeshLink:t,productId:a,children:u,onClick:o,trackingData:n,className:d})=>{const{trackClick:i,trackView:p}=ne(),y=f.useRef(null),l=f.useRef(!1);f.useEffect(()=>{if(!y.current||l.current)return;const h=new IntersectionObserver(b=>{b.forEach(x=>{x.isIntersecting&&!l.current&&(l.current=!0,p({adId:r,admeshLink:t,productId:a,...n}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return h.observe(y.current),()=>{h.disconnect()}},[r,t,a,n,p]);const c=f.useCallback(async h=>{try{await i({adId:r,admeshLink:t,productId:a,...n})}catch(v){console.error("Failed to track click:",v)}o&&o(),h.target.closest("a")||window.open(t,"_blank","noopener,noreferrer")},[r,t,a,n,i,o]);return e.jsx("div",{ref:y,className:d,onClick:c,style:{cursor:"pointer"},children:u})};O.displayName="AdMeshLinkTracker";const z=({recommendation:r,theme:t,showMatchScore:a=!0,showBadges:u=!0,onClick:o,className:n})=>{const d=f.useMemo(()=>{var b;const l=[];r.intent_match_score>=.8&&l.push("Top Match"),r.has_free_tier&&l.push("Free Tier"),r.trial_days&&r.trial_days>0&&l.push("Trial Available");const c=["ai","artificial intelligence","machine learning","ml","automation"];return(((b=r.keywords)==null?void 0:b.some(x=>c.some(v=>x.toLowerCase().includes(v))))||r.title.toLowerCase().includes("ai"))&&l.push("AI Powered"),l},[r]),i=Math.round(r.intent_match_score*100),p=M("admesh-component","admesh-card","relative p-3 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow transition-shadow cursor-pointer",n),y=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor,"--admesh-primary-hover":t.accentColor+"dd"}:void 0;return e.jsx(O,{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:p,children:e.jsxs("div",{className:"h-full flex flex-col",style:y,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsx("div",{className:"flex justify-between items-start mb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[u&&d.includes("Top Match")&&e.jsx("span",{className:"text-xs font-semibold text-white bg-black px-2 py-0.5 rounded-full",children:"Top Match"}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200",children:r.title}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{className:"text-xs 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:r.reason}),a&&typeof r.intent_match_score=="number"&&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:"Confidence"}),e.jsxs("span",{children:[i,"%"]})]}),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:`${i}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-2",children:[r.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"})}),r.pricing]}),r.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"]}),r.trial_days&&r.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"})}),r.trial_days,"-day trial"]})]}),r.features&&r.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:r.features.map((l,c)=>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]},c))})]}),r.integrations&&r.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:r.integrations.map((l,c)=>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]},c))})]}),r.reviews_summary&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:r.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"})})]})})};z.displayName="AdMeshProductCard";const q=({recommendations:r,theme:t,maxProducts:a=3,showMatchScores:u=!0,showFeatures:o=!0,onProductClick:n,className:d})=>{const i=f.useMemo(()=>r.slice(0,a),[r,a]),p=M("admesh-component","admesh-compare-layout",d),y=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return i.length===0?e.jsx("div",{className:p,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:p,style:y,"data-admesh-theme":t==null?void 0:t.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:[i.length," intelligent matches found"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:i.map((l,c)=>e.jsxs(O,{adId:l.ad_id,admeshLink:l.admesh_link,productId:l.product_id,onClick:()=>n==null?void 0:n(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:[c===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:["#",c+1]})]}),u&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",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}),u&&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:"Confidence"}),e.jsxs("span",{children:[Math.round(l.intent_match_score*100),"%"]})]}),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"]})]}),o&&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((h,b)=>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"})}),h]},b)),(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||c))}),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"})]})})]})})};q.displayName="AdMeshCompareTable";const Me={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},Ae={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},le=({type:r,variant:t,size:a="md",className:u})=>{const o=t||Me[r]||"secondary",n=Ae[r],d=M("admesh-component","admesh-badge",`admesh-badge--${o}`,`admesh-badge--${a}`,u);return e.jsxs("span",{className:d,children:[n&&e.jsx("span",{className:"admesh-badge__icon",children:n}),e.jsx("span",{className:"admesh-badge__text",children:r})]})};le.displayName="AdMeshBadge";const Ce=`
|
|
27
27
|
/* AdMesh UI SDK Scoped Styles - Smart Recommendations Design */
|
|
28
28
|
.admesh-component {
|
|
29
29
|
--admesh-primary: #6366f1;
|
|
@@ -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 V=!1;const se=()=>{f.useEffect(()=>{if(V)return;const a=document.createElement("style");return a.id="admesh-ui-sdk-styles",a.textContent=Te,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(a),V=!0),()=>{const o=document.getElementById("admesh-ui-sdk-styles");o&&document.head.contains(o)&&(document.head.removeChild(o),V=!1)}},[])},Ae=(a,o,n)=>{if(!n&&o)switch(o){case"compare_products":return"compare";case"best_for_use_case":case"trial_demo":case"budget_conscious":return"cards";default:return"cards"}const m=a.length;if(m>=2&&m<=4){const l=a.some(d=>d.features&&d.features.length>0),s=a.some(d=>d.pricing);if(l||s)return"compare"}return"cards"},te=({recommendations:a,intentType:o,theme:n,maxDisplayed:m=6,showMatchScores:l=!0,showFeatures:s=!0,autoLayout:d=!0,onProductClick:u,onTrackView:b,className:k})=>{se();const t=f.useMemo(()=>a.slice(0,m),[a,m]),c=f.useMemo(()=>Ae(t,o,d),[t,o,d]),h=S("admesh-component","admesh-layout",`admesh-layout--${c}`,{[`admesh-layout--${n==null?void 0:n.mode}`]:n==null?void 0:n.mode},k),v=n!=null&&n.accentColor?{"--admesh-primary":n.accentColor}:void 0;return t.length===0?e.jsx("div",{className:h,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:h,style:v,"data-admesh-theme":n==null?void 0:n.mode,children:c==="compare"?e.jsx(Y,{recommendations:t,theme:n,maxProducts:Math.min(t.length,4),showMatchScores:l,showFeatures:s,onProductClick:u}):e.jsxs("div",{className:"admesh-layout__cards-container",children:[e.jsx("div",{className:"admesh-layout__header",children:e.jsxs("p",{className:"admesh-layout__subtitle admesh-text-sm admesh-text-muted",children:[t.length," intelligent match",t.length!==1?"es":""," found"]})}),e.jsx("div",{className:"space-y-4",children:t.map((g,_)=>e.jsx(W,{recommendation:g,theme:n,showMatchScore:l,showBadges:!0,maxKeywords:3,onClick:u,onTrackView:b},g.product_id||g.ad_id||_))}),a.length>m&&e.jsx("div",{className:"admesh-layout__more-indicator",children:e.jsxs("p",{className:"admesh-text-sm admesh-text-muted",children:["Showing ",m," of ",a.length," smart recommendations"]})})]})})};te.displayName="AdMeshLayout";const Ee="0.2.1",Me={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=ae;exports.AdMeshCompareTable=Y;exports.AdMeshLayout=te;exports.AdMeshLinkTracker=O;exports.AdMeshProductCard=W;exports.DEFAULT_CONFIG=Me;exports.VERSION=Ee;exports.buildAdMeshLink=_e;exports.extractTrackingData=je;exports.setAdMeshTrackerConfig=ke;exports.useAdMeshStyles=se;exports.useAdMeshTracker=re;
|
|
276
|
+
`;let D=!1;const de=()=>{f.useEffect(()=>{if(D)return;const r=document.createElement("style");return r.id="admesh-ui-sdk-styles",r.textContent=Ce,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(r),D=!0),()=>{const t=document.getElementById("admesh-ui-sdk-styles");t&&document.head.contains(t)&&(document.head.removeChild(t),D=!1)}},[])},Te=(r,t,a)=>{if(!a&&t)switch(t){case"compare_products":return"compare";case"best_for_use_case":case"trial_demo":case"budget_conscious":return"cards";default:return"cards"}const u=r.length;if(u>=2&&u<=4){const o=r.some(d=>d.features&&d.features.length>0),n=r.some(d=>d.pricing);if(o||n)return"compare"}return"cards"},oe=({recommendations:r,intentType:t,theme:a,maxDisplayed:u=6,showMatchScores:o=!0,showFeatures:n=!0,autoLayout:d=!0,onProductClick:i,onTrackView:p,className:y})=>{de();const l=f.useMemo(()=>r.slice(0,u),[r,u]),c=f.useMemo(()=>Te(l,t,d),[l,t,d]),h=M("admesh-component",y),b=a!=null&&a.accentColor?{"--admesh-primary":a.accentColor}:void 0;return l.length===0?e.jsx("div",{className:h,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:h,style:b,"data-admesh-theme":a==null?void 0:a.mode,children:c==="compare"?e.jsx(q,{recommendations:l,theme:a,maxProducts:Math.min(l.length,4),showMatchScores:o,showFeatures:n,onProductClick:i}):e.jsx("div",{className:"space-y-4",children:l.map((x,v)=>e.jsx(z,{recommendation:x,theme:a,showMatchScore:o,showBadges:!0,maxKeywords:3,onClick:i,onTrackView:p},x.product_id||x.ad_id||v))})})};oe.displayName="AdMeshLayout";const P=({recommendation:r,theme:t,compact:a=!1,showReason:u=!0,onClick:o,className:n})=>{const d=Math.round(r.intent_match_score*100),i=M("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":!a,"p-1.5 rounded hover:bg-gray-50 dark:hover:bg-slate-800/30":a},n),p=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsx(O,{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:i,children:e.jsxs("div",{className:"flex items-start gap-3",style:p,"data-admesh-theme":t==null?void 0:t.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:M("font-medium text-gray-900 dark:text-gray-100 truncate",a?"text-sm":"text-base"),children:r.title}),r.intent_match_score>=.7&&e.jsxs("span",{className:M("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"]})]}),u&&r.reason&&e.jsx("p",{className:M("text-gray-600 dark:text-gray-400 line-clamp-2",a?"text-xs":"text-sm"),children:r.reason}),!a&&r.keywords&&r.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[r.keywords.slice(0,3).map((y,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:y},l)),r.keywords.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",r.keywords.length-3," more"]})]}),!a&&(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"})})})]})})},ie=({recommendations:r,conversationSummary:t,theme:a,showTopRecommendations:u=3,onRecommendationClick:o,onStartNewConversation:n,className:d})=>{const i=r.sort((l,c)=>c.intent_match_score-l.intent_match_score).slice(0,u),p=M("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),y=a!=null&&a.accentColor?{"--admesh-primary":a.accentColor}:void 0;return e.jsxs("div",{className:p,style:y,"data-admesh-theme":a==null?void 0:a.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:t})})}),i.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:i.map((l,c)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-2 top-2 z-10",children:e.jsx("div",{className:M("w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",c===0?"bg-yellow-500":c===1?"bg-gray-400":"bg-orange-400"),children:c+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(P,{recommendation:l,theme:a,compact:!1,showReason:!0,onClick:o})})]},l.ad_id||c))})]}),r.length>u&&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-u," additional recommendation",r.length-u>1?"s":""," available"]})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[n&&e.jsxs("button",{onClick:n,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:()=>{i.length>0&&(o==null||o(i[0].ad_id,i[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"})})]})},Ee=({recommendations:r,config:t,theme:a,conversationSummary:u,userQuery:o,sessionId:n,onRecommendationClick:d,onDismiss:i,className:p})=>{const[y,l]=f.useState(t.autoShow!==!1),[c,h]=f.useState(!1);if(f.useEffect(()=>{if(t.delayMs&&t.delayMs>0){const _=setTimeout(()=>{l(!0),h(!0)},t.delayMs);return()=>clearTimeout(_)}else h(!0)},[t.delayMs]),!y||r.length===0)return null;const b=t.maxRecommendations||3,x=r.slice(0,b),v=(_,C)=>{d==null||d(_,C)},w=()=>{l(!1),i==null||i()},N=()=>{switch(t.displayMode){case"summary":return u?e.jsx(ie,{recommendations:x,conversationSummary:u,theme:a,showTopRecommendations:b,onRecommendationClick:v,onStartNewConversation:i}):null;case"inline":return e.jsx("div",{className:"space-y-2",children:x.map((_,C)=>e.jsx(P,{recommendation:_,theme:a,compact:!0,showReason:!0,onClick:v},_.ad_id||C))});case"minimal":return x.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:[x.length," intelligent match",x.length>1?"es":""," found"]})]}),e.jsx(P,{recommendation:x[0],theme:a,compact:!0,showReason:!1,onClick:v}),x.length>1&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["+",x.length-1," more recommendation",x.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"})]}),i&&e.jsx("button",{onClick:w,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:x.map((_,C)=>e.jsx(P,{recommendation:_,theme:a,compact:!0,showReason:!1,onClick:v},_.ad_id||C))})]});default:return e.jsx("div",{className:"space-y-3",children:x.map((_,C)=>e.jsx(z,{recommendation:_,theme:a,showMatchScore:!1,showBadges:!0,onClick:v},_.ad_id||C))})}},E=M("admesh-conversational-unit","transition-all duration-300 ease-in-out",{"opacity-0 translate-y-2":!c,"opacity-100 translate-y-0":c,"fixed bottom-4 right-4 max-w-sm z-50":t.displayMode==="floating","my-3":t.displayMode==="inline","mt-4 pt-4 border-t border-gray-200 dark:border-slate-700":t.displayMode==="summary"},p),B=a!=null&&a.accentColor?{"--admesh-primary":a.accentColor}:void 0;return e.jsxs("div",{className:E,style:B,"data-admesh-theme":a==null?void 0:a.mode,"data-admesh-context":t.context,"data-session-id":n,children:[N(),t.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"})})]})},Re="0.2.1",Se={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=le;exports.AdMeshCompareTable=q;exports.AdMeshConversationSummary=ie;exports.AdMeshConversationalUnit=Ee;exports.AdMeshInlineRecommendation=P;exports.AdMeshLayout=oe;exports.AdMeshLinkTracker=O;exports.AdMeshProductCard=z;exports.DEFAULT_CONFIG=Se;exports.VERSION=Re;exports.buildAdMeshLink=we;exports.extractTrackingData=Ne;exports.setAdMeshTrackerConfig=_e;exports.useAdMeshStyles=de;exports.useAdMeshTracker=ne;
|
|
277
277
|
//# sourceMappingURL=index.js.map
|