randmarcomps 1.188.0 → 1.190.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/dist/randmarcomps.js +71 -60
- package/dist/randmarcomps.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -50261,6 +50261,11 @@ function PartnerCard({
|
|
|
50261
50261
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-20 rounded-full" }),
|
|
50262
50262
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-16 rounded-full" })
|
|
50263
50263
|
] }),
|
|
50264
|
+
l && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
50265
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" }),
|
|
50266
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" }),
|
|
50267
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" })
|
|
50268
|
+
] }),
|
|
50264
50269
|
d && /* @__PURE__ */ jsx("div", { className: "p-3 bg-slate-50 rounded-md", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-2", children: [
|
|
50265
50270
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
50266
50271
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-20 mb-1" }),
|
|
@@ -50330,7 +50335,7 @@ function PartnerCard({
|
|
|
50330
50335
|
] }) })
|
|
50331
50336
|
] })
|
|
50332
50337
|
] }),
|
|
50333
|
-
/* @__PURE__ */ jsxs(CardFooter, { className: "px-6 py-4 flex justify-between gap-2", children: [
|
|
50338
|
+
/* @__PURE__ */ jsxs(CardFooter, { className: "px-6 py-4 flex justify-between gap-2 mt-auto", children: [
|
|
50334
50339
|
E && Q ? /* @__PURE__ */ jsxs(Dialog, { open: q, onOpenChange: z, children: [
|
|
50335
50340
|
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", className: "flex items-center gap-2", children: [
|
|
50336
50341
|
/* @__PURE__ */ jsx(Video, { className: "h-4 w-4" }),
|
|
@@ -59395,6 +59400,27 @@ Ir = new WeakMap(), Ut = new WeakMap(), Mr = new WeakMap(), Nr = new WeakMap(),
|
|
|
59395
59400
|
renderUnrecognized: () => null
|
|
59396
59401
|
});
|
|
59397
59402
|
var source_default = JsxParser;
|
|
59403
|
+
function useIntersectionObserver({
|
|
59404
|
+
elementRef: e,
|
|
59405
|
+
threshold: t = 0,
|
|
59406
|
+
rootMargin: n = "0px"
|
|
59407
|
+
}) {
|
|
59408
|
+
const [o, l] = useState(!1);
|
|
59409
|
+
return useEffect(() => {
|
|
59410
|
+
const d = new IntersectionObserver(
|
|
59411
|
+
([g]) => {
|
|
59412
|
+
l(g.isIntersecting);
|
|
59413
|
+
},
|
|
59414
|
+
{
|
|
59415
|
+
threshold: t,
|
|
59416
|
+
rootMargin: n
|
|
59417
|
+
}
|
|
59418
|
+
), f = e.current;
|
|
59419
|
+
return f && d.observe(f), () => {
|
|
59420
|
+
f && d.unobserve(f);
|
|
59421
|
+
};
|
|
59422
|
+
}, [e, t, n]), o;
|
|
59423
|
+
}
|
|
59398
59424
|
const imgSizeMap = {
|
|
59399
59425
|
sm: 100,
|
|
59400
59426
|
md: 200,
|
|
@@ -59402,39 +59428,46 @@ const imgSizeMap = {
|
|
|
59402
59428
|
xl: 400
|
|
59403
59429
|
};
|
|
59404
59430
|
function ProductImage({ randmarSKU: e, size: t = "md", alt: n, secondaryContent: o }) {
|
|
59405
|
-
const [l, d] = React.useState(!1), [f, g] = React.useState(!1), [b, _] = React.useState(!1), [S, C] = React.useState(!1), E = `https://api.randmar.io/Product/${e}/Video
|
|
59431
|
+
const [l, d] = React.useState(!1), [f, g] = React.useState(!1), [b, _] = React.useState(!1), [S, C] = React.useState(!1), [E, R] = React.useState(!1), M = `https://api.randmar.io/Product/${e}/Video`, I = useRef(null), A = useIntersectionObserver({
|
|
59432
|
+
elementRef: I,
|
|
59433
|
+
threshold: 0.1,
|
|
59434
|
+
// Element is considered visible when 10% is in viewport
|
|
59435
|
+
rootMargin: "100px"
|
|
59436
|
+
// Start loading a bit before it comes into view
|
|
59437
|
+
});
|
|
59406
59438
|
React.useEffect(() => {
|
|
59407
|
-
|
|
59439
|
+
const F = async () => {
|
|
59408
59440
|
try {
|
|
59409
|
-
const
|
|
59410
|
-
g(
|
|
59411
|
-
} catch (
|
|
59412
|
-
console.error("Error checking for video:",
|
|
59441
|
+
const te = await (await fetch(M + "/Exists")).json();
|
|
59442
|
+
g(te);
|
|
59443
|
+
} catch (V) {
|
|
59444
|
+
console.error("Error checking for video:", V), g(!1);
|
|
59413
59445
|
}
|
|
59414
|
-
}
|
|
59415
|
-
|
|
59416
|
-
|
|
59446
|
+
};
|
|
59447
|
+
A && !b && (_(!0), F());
|
|
59448
|
+
}, [e, M, A, b]);
|
|
59449
|
+
async function j() {
|
|
59417
59450
|
if (f) {
|
|
59418
|
-
|
|
59451
|
+
R(!0);
|
|
59419
59452
|
try {
|
|
59420
|
-
const
|
|
59421
|
-
|
|
59422
|
-
} catch (
|
|
59423
|
-
console.error("Error downloading video:",
|
|
59453
|
+
const V = await (await fetch(M)).blob(), te = window.URL.createObjectURL(V), ae = document.createElement("a");
|
|
59454
|
+
ae.href = te, ae.download = `${e || "product"}-video.mp4`, document.body.appendChild(ae), ae.click(), document.body.removeChild(ae), window.URL.revokeObjectURL(te);
|
|
59455
|
+
} catch (F) {
|
|
59456
|
+
console.error("Error downloading video:", F);
|
|
59424
59457
|
} finally {
|
|
59425
|
-
|
|
59458
|
+
R(!1);
|
|
59426
59459
|
}
|
|
59427
59460
|
}
|
|
59428
59461
|
}
|
|
59429
|
-
function
|
|
59430
|
-
navigator.clipboard.writeText(
|
|
59431
|
-
|
|
59462
|
+
function q() {
|
|
59463
|
+
navigator.clipboard.writeText(M), C(!0), setTimeout(() => {
|
|
59464
|
+
C(!1);
|
|
59432
59465
|
}, 2e3);
|
|
59433
59466
|
}
|
|
59434
|
-
function
|
|
59467
|
+
function z() {
|
|
59435
59468
|
d(!0);
|
|
59436
59469
|
}
|
|
59437
|
-
const
|
|
59470
|
+
const Q = imgSizeMap[t || "xl"];
|
|
59438
59471
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
59439
59472
|
/* @__PURE__ */ jsx(Dialog, { open: l, onOpenChange: d, children: /* @__PURE__ */ jsx(DialogContent, { className: "max-w-4xl p-0 overflow-hidden", children: o ? /* @__PURE__ */ jsxs("div", { className: "flex flex-row", children: [
|
|
59440
59473
|
/* @__PURE__ */ jsxs(
|
|
@@ -59446,7 +59479,7 @@ function ProductImage({ randmarSKU: e, size: t = "md", alt: n, secondaryContent:
|
|
|
59446
59479
|
muted: !0,
|
|
59447
59480
|
loop: !0,
|
|
59448
59481
|
children: [
|
|
59449
|
-
/* @__PURE__ */ jsx("source", { src:
|
|
59482
|
+
/* @__PURE__ */ jsx("source", { src: M, type: "video/mp4" }),
|
|
59450
59483
|
"Your browser does not support the video tag."
|
|
59451
59484
|
]
|
|
59452
59485
|
}
|
|
@@ -59454,7 +59487,7 @@ function ProductImage({ randmarSKU: e, size: t = "md", alt: n, secondaryContent:
|
|
|
59454
59487
|
/* @__PURE__ */ jsx("div", { className: "flex-grow min-w-[400px] h-[70vh] p-6", children: o })
|
|
59455
59488
|
] }) : /* @__PURE__ */ jsxs("div", { className: "w-full relative", children: [
|
|
59456
59489
|
/* @__PURE__ */ jsxs("video", { className: "w-full max-h-[720px] object-contain", controls: !0, autoPlay: !0, children: [
|
|
59457
|
-
/* @__PURE__ */ jsx("source", { src:
|
|
59490
|
+
/* @__PURE__ */ jsx("source", { src: M, type: "video/mp4" }),
|
|
59458
59491
|
"Your browser does not support the video tag."
|
|
59459
59492
|
] }),
|
|
59460
59493
|
/* @__PURE__ */ jsxs("div", { className: "absolute top-2 right-12 flex gap-1", children: [
|
|
@@ -59464,8 +59497,8 @@ function ProductImage({ randmarSKU: e, size: t = "md", alt: n, secondaryContent:
|
|
|
59464
59497
|
{
|
|
59465
59498
|
variant: "secondary",
|
|
59466
59499
|
size: "icon",
|
|
59467
|
-
onClick:
|
|
59468
|
-
children:
|
|
59500
|
+
onClick: q,
|
|
59501
|
+
children: S ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Copy, { className: "h-4 w-4" })
|
|
59469
59502
|
}
|
|
59470
59503
|
) }),
|
|
59471
59504
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: "Copy video link" }) })
|
|
@@ -59476,8 +59509,8 @@ function ProductImage({ randmarSKU: e, size: t = "md", alt: n, secondaryContent:
|
|
|
59476
59509
|
{
|
|
59477
59510
|
variant: "secondary",
|
|
59478
59511
|
size: "icon",
|
|
59479
|
-
onClick:
|
|
59480
|
-
disabled:
|
|
59512
|
+
onClick: j,
|
|
59513
|
+
disabled: E,
|
|
59481
59514
|
children: /* @__PURE__ */ jsx(Download, { className: "h-4 w-4" })
|
|
59482
59515
|
}
|
|
59483
59516
|
) }),
|
|
@@ -59485,16 +59518,16 @@ function ProductImage({ randmarSKU: e, size: t = "md", alt: n, secondaryContent:
|
|
|
59485
59518
|
] }) })
|
|
59486
59519
|
] })
|
|
59487
59520
|
] }) }) }),
|
|
59488
|
-
/* @__PURE__ */ jsxs("div", { className: "relative w-max h-max", children: [
|
|
59521
|
+
/* @__PURE__ */ jsxs("div", { className: "relative w-max h-max", ref: I, children: [
|
|
59489
59522
|
/* @__PURE__ */ jsx(
|
|
59490
59523
|
"img",
|
|
59491
59524
|
{
|
|
59492
59525
|
alt: n || `Product ${e}`,
|
|
59493
59526
|
className: `rounded-md ${f ? "cursor-pointer" : ""}`,
|
|
59494
|
-
onClick: f ?
|
|
59495
|
-
src: `https://api.randmar.io/Product/${e}/Image?width=${
|
|
59496
|
-
width:
|
|
59497
|
-
height:
|
|
59527
|
+
onClick: f ? z : void 0,
|
|
59528
|
+
src: `https://api.randmar.io/Product/${e}/Image?width=${Q * 1.5}&height=${Q * 1.5}`,
|
|
59529
|
+
width: Q,
|
|
59530
|
+
height: Q
|
|
59498
59531
|
}
|
|
59499
59532
|
),
|
|
59500
59533
|
f && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
|
|
@@ -59504,7 +59537,7 @@ function ProductImage({ randmarSKU: e, size: t = "md", alt: n, secondaryContent:
|
|
|
59504
59537
|
variant: "secondary",
|
|
59505
59538
|
size: "icon",
|
|
59506
59539
|
className: "absolute top-2 right-2",
|
|
59507
|
-
onClick:
|
|
59540
|
+
onClick: z,
|
|
59508
59541
|
children: /* @__PURE__ */ jsx(Play, { className: "h-4 w-4" })
|
|
59509
59542
|
}
|
|
59510
59543
|
) }),
|
|
@@ -59533,27 +59566,6 @@ const CountryFlag = ({ countryCode: e, className: t = "" }) => {
|
|
|
59533
59566
|
}
|
|
59534
59567
|
);
|
|
59535
59568
|
};
|
|
59536
|
-
function useIntersectionObserver({
|
|
59537
|
-
elementRef: e,
|
|
59538
|
-
threshold: t = 0,
|
|
59539
|
-
rootMargin: n = "0px"
|
|
59540
|
-
}) {
|
|
59541
|
-
const [o, l] = useState(!1);
|
|
59542
|
-
return useEffect(() => {
|
|
59543
|
-
const d = new IntersectionObserver(
|
|
59544
|
-
([g]) => {
|
|
59545
|
-
l(g.isIntersecting);
|
|
59546
|
-
},
|
|
59547
|
-
{
|
|
59548
|
-
threshold: t,
|
|
59549
|
-
rootMargin: n
|
|
59550
|
-
}
|
|
59551
|
-
), f = e.current;
|
|
59552
|
-
return f && d.observe(f), () => {
|
|
59553
|
-
f && d.unobserve(f);
|
|
59554
|
-
};
|
|
59555
|
-
}, [e, t, n]), o;
|
|
59556
|
-
}
|
|
59557
59569
|
function ProductCard({
|
|
59558
59570
|
item: e,
|
|
59559
59571
|
addToCart: t = !1,
|
|
@@ -59597,8 +59609,10 @@ function ProductCard({
|
|
|
59597
59609
|
}
|
|
59598
59610
|
}
|
|
59599
59611
|
};
|
|
59600
|
-
z && (e != null && e.ManufacturerId) && He();
|
|
59601
|
-
}, [e == null ? void 0 : e.ManufacturerId, z]), useEffect(() => {
|
|
59612
|
+
z && (e != null && e.ManufacturerId) && !te && He();
|
|
59613
|
+
}, [e == null ? void 0 : e.ManufacturerId, z, te]), useEffect(() => {
|
|
59614
|
+
ae(null);
|
|
59615
|
+
}, [e == null ? void 0 : e.ManufacturerId]), useEffect(() => {
|
|
59602
59616
|
var He;
|
|
59603
59617
|
if (e && l) {
|
|
59604
59618
|
const ot = (He = e.Opportunities) == null ? void 0 : He.find((Ye) => Ye.BidNumber == l);
|
|
@@ -59817,10 +59831,7 @@ function ProductCard({
|
|
|
59817
59831
|
] })
|
|
59818
59832
|
] })
|
|
59819
59833
|
] }),
|
|
59820
|
-
/* @__PURE__ */
|
|
59821
|
-
z && /* @__PURE__ */ jsx(ProductImage, { randmarSKU: e.RandmarSKU || "", alt: e.RandmarTitle || "" }),
|
|
59822
|
-
!z && /* @__PURE__ */ jsx("div", { className: "w-60 h-40 bg-gray-100 rounded-lg flex items-center justify-center", children: /* @__PURE__ */ jsx(Skeleton, { className: "w-full h-full rounded-lg" }) })
|
|
59823
|
-
] })
|
|
59834
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx(ProductImage, { randmarSKU: e.RandmarSKU || "", alt: e.RandmarTitle || "" }) })
|
|
59824
59835
|
] }),
|
|
59825
59836
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-6 mt-4", children: [
|
|
59826
59837
|
/* @__PURE__ */ jsx("div", { className: "flex flex-1", children: Ae && e.Distribution && /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
@@ -866,7 +866,7 @@ ${t}</tr>
|
|
|
866
866
|
`}tablecell(t){const n=this.parser.parseInline(t.tokens),o=t.header?"th":"td";return(t.align?`<${o} align="${t.align}">`:`<${o}>`)+n+`</${o}>
|
|
867
867
|
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${escape$2(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:o}){const l=this.parser.parseInline(o),d=cleanUrl(t);if(d===null)return l;t=d;let f='<a href="'+t+'"';return n&&(f+=' title="'+escape$2(n)+'"'),f+=">"+l+"</a>",f}image({href:t,title:n,text:o,tokens:l}){l&&(o=this.parser.parseInline(l,this.parser.textRenderer));const d=cleanUrl(t);if(d===null)return escape$2(o);t=d;let f=`<img src="${t}" alt="${o}"`;return n&&(f+=` title="${escape$2(n)}"`),f+=">",f}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:escape$2(t.text)}}class _TextRenderer{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class _Parser{constructor(t){Ft(this,"options");Ft(this,"renderer");Ft(this,"textRenderer");this.options=t||_defaults,this.options.renderer=this.options.renderer||new _Renderer,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _TextRenderer}static parse(t,n){return new _Parser(n).parse(t)}static parseInline(t,n){return new _Parser(n).parseInline(t)}parse(t,n=!0){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=g,S=this.options.extensions.renderers[_.type].call({parser:this},_);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(_.type)){o+=S||"";continue}}const b=g;switch(b.type){case"space":{o+=this.renderer.space(b);continue}case"hr":{o+=this.renderer.hr(b);continue}case"heading":{o+=this.renderer.heading(b);continue}case"code":{o+=this.renderer.code(b);continue}case"table":{o+=this.renderer.table(b);continue}case"blockquote":{o+=this.renderer.blockquote(b);continue}case"list":{o+=this.renderer.list(b);continue}case"html":{o+=this.renderer.html(b);continue}case"paragraph":{o+=this.renderer.paragraph(b);continue}case"text":{let _=b,S=this.renderer.text(_);for(;f+1<t.length&&t[f+1].type==="text";)_=t[++f],S+=`
|
|
868
868
|
`+this.renderer.text(_);n?o+=this.renderer.paragraph({type:"paragraph",raw:S,text:S,tokens:[{type:"text",raw:S,text:S,escaped:!0}]}):o+=S;continue}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}parseInline(t,n=this.renderer){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=this.options.extensions.renderers[g.type].call({parser:this},g);if(_!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(g.type)){o+=_||"";continue}}const b=g;switch(b.type){case"escape":{o+=n.text(b);break}case"html":{o+=n.html(b);break}case"link":{o+=n.link(b);break}case"image":{o+=n.image(b);break}case"strong":{o+=n.strong(b);break}case"em":{o+=n.em(b);break}case"codespan":{o+=n.codespan(b);break}case"br":{o+=n.br(b);break}case"del":{o+=n.del(b);break}case"text":{o+=n.text(b);break}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}}class _Hooks{constructor(t){Ft(this,"options");Ft(this,"block");this.options=t||_defaults}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?_Lexer.lex:_Lexer.lexInline}provideParser(){return this.block?_Parser.parse:_Parser.parseInline}}Ft(_Hooks,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class Marked{constructor(...t){Ft(this,"defaults",_getDefaults());Ft(this,"options",this.setOptions);Ft(this,"parse",this.parseMarkdown(!0));Ft(this,"parseInline",this.parseMarkdown(!1));Ft(this,"Parser",_Parser);Ft(this,"Renderer",_Renderer);Ft(this,"TextRenderer",_TextRenderer);Ft(this,"Lexer",_Lexer);Ft(this,"Tokenizer",_Tokenizer);Ft(this,"Hooks",_Hooks);this.use(...t)}walkTokens(t,n){var l,d;let o=[];for(const f of t)switch(o=o.concat(n.call(this,f)),f.type){case"table":{const g=f;for(const b of g.header)o=o.concat(this.walkTokens(b.tokens,n));for(const b of g.rows)for(const _ of b)o=o.concat(this.walkTokens(_.tokens,n));break}case"list":{const g=f;o=o.concat(this.walkTokens(g.items,n));break}default:{const g=f;(d=(l=this.defaults.extensions)==null?void 0:l.childTokens)!=null&&d[g.type]?this.defaults.extensions.childTokens[g.type].forEach(b=>{const _=g[b].flat(1/0);o=o.concat(this.walkTokens(_,n))}):g.tokens&&(o=o.concat(this.walkTokens(g.tokens,n)))}}return o}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(o=>{const l={...o};if(l.async=this.defaults.async||l.async||!1,o.extensions&&(o.extensions.forEach(d=>{if(!d.name)throw new Error("extension name required");if("renderer"in d){const f=n.renderers[d.name];f?n.renderers[d.name]=function(...g){let b=d.renderer.apply(this,g);return b===!1&&(b=f.apply(this,g)),b}:n.renderers[d.name]=d.renderer}if("tokenizer"in d){if(!d.level||d.level!=="block"&&d.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const f=n[d.level];f?f.unshift(d.tokenizer):n[d.level]=[d.tokenizer],d.start&&(d.level==="block"?n.startBlock?n.startBlock.push(d.start):n.startBlock=[d.start]:d.level==="inline"&&(n.startInline?n.startInline.push(d.start):n.startInline=[d.start]))}"childTokens"in d&&d.childTokens&&(n.childTokens[d.name]=d.childTokens)}),l.extensions=n),o.renderer){const d=this.defaults.renderer||new _Renderer(this.defaults);for(const f in o.renderer){if(!(f in d))throw new Error(`renderer '${f}' does not exist`);if(["options","parser"].includes(f))continue;const g=f,b=o.renderer[g],_=d[g];d[g]=(...S)=>{let R=b.apply(d,S);return R===!1&&(R=_.apply(d,S)),R||""}}l.renderer=d}if(o.tokenizer){const d=this.defaults.tokenizer||new _Tokenizer(this.defaults);for(const f in o.tokenizer){if(!(f in d))throw new Error(`tokenizer '${f}' does not exist`);if(["options","rules","lexer"].includes(f))continue;const g=f,b=o.tokenizer[g],_=d[g];d[g]=(...S)=>{let R=b.apply(d,S);return R===!1&&(R=_.apply(d,S)),R}}l.tokenizer=d}if(o.hooks){const d=this.defaults.hooks||new _Hooks;for(const f in o.hooks){if(!(f in d))throw new Error(`hook '${f}' does not exist`);if(["options","block"].includes(f))continue;const g=f,b=o.hooks[g],_=d[g];_Hooks.passThroughHooks.has(f)?d[g]=S=>{if(this.defaults.async)return Promise.resolve(b.call(d,S)).then(C=>_.call(d,C));const R=b.call(d,S);return _.call(d,R)}:d[g]=(...S)=>{let R=b.apply(d,S);return R===!1&&(R=_.apply(d,S)),R}}l.hooks=d}if(o.walkTokens){const d=this.defaults.walkTokens,f=o.walkTokens;l.walkTokens=function(g){let b=[];return b.push(f.call(this,g)),d&&(b=b.concat(d.call(this,g))),b}}this.defaults={...this.defaults,...l}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return _Lexer.lex(t,n??this.defaults)}parser(t,n){return _Parser.parse(t,n??this.defaults)}parseMarkdown(t){return(o,l)=>{const d={...l},f={...this.defaults,...d},g=this.onError(!!f.silent,!!f.async);if(this.defaults.async===!0&&d.async===!1)return g(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof o>"u"||o===null)return g(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return g(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));f.hooks&&(f.hooks.options=f,f.hooks.block=t);const b=f.hooks?f.hooks.provideLexer():t?_Lexer.lex:_Lexer.lexInline,_=f.hooks?f.hooks.provideParser():t?_Parser.parse:_Parser.parseInline;if(f.async)return Promise.resolve(f.hooks?f.hooks.preprocess(o):o).then(S=>b(S,f)).then(S=>f.hooks?f.hooks.processAllTokens(S):S).then(S=>f.walkTokens?Promise.all(this.walkTokens(S,f.walkTokens)).then(()=>S):S).then(S=>_(S,f)).then(S=>f.hooks?f.hooks.postprocess(S):S).catch(g);try{f.hooks&&(o=f.hooks.preprocess(o));let S=b(o,f);f.hooks&&(S=f.hooks.processAllTokens(S)),f.walkTokens&&this.walkTokens(S,f.walkTokens);let R=_(S,f);return f.hooks&&(R=f.hooks.postprocess(R)),R}catch(S){return g(S)}}}onError(t,n){return o=>{if(o.message+=`
|
|
869
|
-
Please report this to https://github.com/markedjs/marked.`,t){const l="<p>An error occurred:</p><pre>"+escape$2(o.message+"",!0)+"</pre>";return n?Promise.resolve(l):l}if(n)return Promise.reject(o);throw o}}}const markedInstance=new Marked;function marked(e,t){return markedInstance.parse(e,t)}marked.options=marked.setOptions=function(e){return markedInstance.setOptions(e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...e){return markedInstance.use(...e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(e,t){return markedInstance.walkTokens(e,t)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;const Card=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("rounded-md border bg-card text-card-foreground shadow-sm",e),...t}));Card.displayName="Card";const CardHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex flex-col space-y-1.5 p-6",e),...t}));CardHeader.displayName="CardHeader";const CardTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("font-semibold leading-none tracking-tight",e),...t}));CardTitle.displayName="CardTitle";const CardDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));CardDescription.displayName="CardDescription";const CardContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("p-6 pt-0",e),...t}));CardContent.displayName="CardContent";const CardFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex items-center p-6 pt-0",e),...t}));CardFooter.displayName="CardFooter";const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:t,size:n}),e),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function PartnerCard({account:e,action:t,loading:n=!1,className:o,withAbout:l=!1,withVoice:d=!0}){const[f,g]=React.useState(null),[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),[M,I]=React.useState(!0),[A,V]=React.useState(null),[q,z]=React.useState(!1),Q=React.useMemo(()=>e!=null&&e.ApplicationId?{videoUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Video`,videoExistsUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Video/Exists`,logoUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Logo?width=64&height=64`,logoExistsUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Logo/Exists`}:null,[e==null?void 0:e.ApplicationId]);React.useEffect(()=>{if(!Q||n)return;let j=!0;V(null);const te=async()=>{try{const se=await fetch(Q.logoExistsUrl);if(se.ok){const Ae=(await se.text()).toLowerCase()==="true";return j&&R(Ae),Ae}return!1}catch(se){return console.error("Failed to check if logo exists:",se),j&&R(!1),!1}},ae=async()=>{j&&_(!0);try{const se=await fetch(Q.logoUrl);if(se.ok){const ge=await se.blob();j&&(f&&URL.revokeObjectURL(f),g(URL.createObjectURL(ge)))}else throw new Error(`Failed to load logo: ${se.status}`)}catch(se){console.error("Failed to load logo:",se),j&&V("Failed to load partner logo")}finally{j&&_(!1)}},ie=async()=>{try{const se=await fetch(Q.videoExistsUrl);if(se.ok){const ge=await se.text();j&&E(ge.toLowerCase()==="true")}else throw new Error(`Failed to check video: ${se.status}`)}catch(se){console.error("Failed to check if video exists:",se),j&&E(!1)}};return(async()=>{await te()&&ae(),ie()})(),()=>{j=!1,f&&URL.revokeObjectURL(f)}},[Q,n]);const F=()=>{I(!1)};return n||!e?jsxRuntime.jsxs(Card,{className:o,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:o,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[S&&jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:b?jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"}):f&&jsxRuntime.jsx("img",{src:f,alt:`${e.PublicName}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Partner"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:e.ApplicationId})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"pb-2",children:[A&&jsxRuntime.jsx("div",{className:"text-red-500 mb-4 text-sm",role:"alert",children:A}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(e.IsManufacturer||e.IsReseller||e.IsSalesAgency)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.IsManufacturer&&jsxRuntime.jsx(Badge,{className:"manufacturer-theme",children:"Manufacturer"}),e.IsReseller&&jsxRuntime.jsx(Badge,{className:"reseller-theme",children:"Reseller"}),e.IsSalesAgency&&jsxRuntime.jsx(Badge,{children:"Agency"})]}),l&&e.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.About??""}}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.VoiceName??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.VoiceStyle??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.SceneName??"N/A"})]})]})})]})]}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2",children:[C&&Q?jsxRuntime.jsxs(Dialog,{open:q,onOpenChange:z,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[e.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[M&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:Q.videoUrl,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${e.PublicName}`,className:`w-full h-full object-cover ${M?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:F,onError:()=>I(!1)})]})]})]}):jsxRuntime.jsx("div",{}),t||jsxRuntime.jsxs(Button,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}const Textarea=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Textarea.displayName="Textarea";function ChatList({userId:e,chats:t,activeChat:n,onSelectChat:o,assistantChat:l}){return jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col min-h-full",children:[jsxRuntime.jsx("div",{className:"flex-grow",children:t.map(d=>{const f=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AvatarImage,{src:`https://api.randmar.io/v4/Partner/${d.partner1===e?d.partner2:d.partner1}/Account/Logo?height=72&width=72`,className:" object-contain "}),jsxRuntime.jsx(AvatarFallback,{children:jsxRuntime.jsx(Handshake,{className:"text-primary fill-white min-h-full"})})]});return display(d,n,o,f)})}),jsxRuntime.jsxs("div",{className:"mt-auto",children:[jsxRuntime.jsx(Separator$1,{className:"mb-1"}),display(l,n,o,jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"}))]})]})}function display(e,t,n,o){var l;return jsxRuntime.jsxs("button",{className:cn("w-full flex items-center p-2 rounded-md hover:bg-slate-100 transition-colors",(t==null?void 0:t.partner1)===e.partner1&&(t==null?void 0:t.partner2)===e.partner2&&"bg-slate-100"),onClick:()=>n([e.partner1,e.partner2]),children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:e.pending?jsxRuntime.jsx(MessageSquareLock,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}),jsxRuntime.jsxs("div",{className:"ml-2 text-left overflow-hidden",children:[jsxRuntime.jsx("div",{className:"font-medium text-sm truncate",children:e.name}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground truncate text-ellipsis",children:((l=e.messages.at(-1))==null?void 0:l.content)??""})]}),e.unread>0&&jsxRuntime.jsx("div",{className:"ml-auto bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center",children:e.unread})]},e.partner1+" and "+e.partner2)}var md5$1={exports:{}},crypt={exports:{}},hasRequiredCrypt;function requireCrypt(){return hasRequiredCrypt||(hasRequiredCrypt=1,function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(n,o){return n<<o|n>>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return t.rotl(n,8)&16711935|t.rotl(n,24)&4278255360;for(var o=0;o<n.length;o++)n[o]=t.endian(n[o]);return n},randomBytes:function(n){for(var o=[];n>0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],l=0,d=0;l<n.length;l++,d+=8)o[d>>>5]|=n[l]<<24-d%32;return o},wordsToBytes:function(n){for(var o=[],l=0;l<n.length*32;l+=8)o.push(n[l>>>5]>>>24-l%32&255);return o},bytesToHex:function(n){for(var o=[],l=0;l<n.length;l++)o.push((n[l]>>>4).toString(16)),o.push((n[l]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],l=0;l<n.length;l+=2)o.push(parseInt(n.substr(l,2),16));return o},bytesToBase64:function(n){for(var o=[],l=0;l<n.length;l+=3)for(var d=n[l]<<16|n[l+1]<<8|n[l+2],f=0;f<4;f++)l*8+f*6<=n.length*8?o.push(e.charAt(d>>>6*(3-f)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],l=0,d=0;l<n.length;d=++l%4)d!=0&&o.push((e.indexOf(n.charAt(l-1))&Math.pow(2,-2*d+8)-1)<<d*2|e.indexOf(n.charAt(l))>>>6-d*2);return o}};crypt.exports=t}()),crypt.exports}var charenc_1,hasRequiredCharenc;function requireCharenc(){if(hasRequiredCharenc)return charenc_1;hasRequiredCharenc=1;var e={utf8:{stringToBytes:function(t){return e.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(e.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var n=[],o=0;o<t.length;o++)n.push(t.charCodeAt(o)&255);return n},bytesToString:function(t){for(var n=[],o=0;o<t.length;o++)n.push(String.fromCharCode(t[o]));return n.join("")}}};return charenc_1=e,charenc_1}/*!
|
|
869
|
+
Please report this to https://github.com/markedjs/marked.`,t){const l="<p>An error occurred:</p><pre>"+escape$2(o.message+"",!0)+"</pre>";return n?Promise.resolve(l):l}if(n)return Promise.reject(o);throw o}}}const markedInstance=new Marked;function marked(e,t){return markedInstance.parse(e,t)}marked.options=marked.setOptions=function(e){return markedInstance.setOptions(e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...e){return markedInstance.use(...e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(e,t){return markedInstance.walkTokens(e,t)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;const Card=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("rounded-md border bg-card text-card-foreground shadow-sm",e),...t}));Card.displayName="Card";const CardHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex flex-col space-y-1.5 p-6",e),...t}));CardHeader.displayName="CardHeader";const CardTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("font-semibold leading-none tracking-tight",e),...t}));CardTitle.displayName="CardTitle";const CardDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));CardDescription.displayName="CardDescription";const CardContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("p-6 pt-0",e),...t}));CardContent.displayName="CardContent";const CardFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex items-center p-6 pt-0",e),...t}));CardFooter.displayName="CardFooter";const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:t,size:n}),e),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function PartnerCard({account:e,action:t,loading:n=!1,className:o,withAbout:l=!1,withVoice:d=!0}){const[f,g]=React.useState(null),[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),[M,I]=React.useState(!0),[A,V]=React.useState(null),[q,z]=React.useState(!1),Q=React.useMemo(()=>e!=null&&e.ApplicationId?{videoUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Video`,videoExistsUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Video/Exists`,logoUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Logo?width=64&height=64`,logoExistsUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Logo/Exists`}:null,[e==null?void 0:e.ApplicationId]);React.useEffect(()=>{if(!Q||n)return;let j=!0;V(null);const te=async()=>{try{const se=await fetch(Q.logoExistsUrl);if(se.ok){const Ae=(await se.text()).toLowerCase()==="true";return j&&R(Ae),Ae}return!1}catch(se){return console.error("Failed to check if logo exists:",se),j&&R(!1),!1}},ae=async()=>{j&&_(!0);try{const se=await fetch(Q.logoUrl);if(se.ok){const ge=await se.blob();j&&(f&&URL.revokeObjectURL(f),g(URL.createObjectURL(ge)))}else throw new Error(`Failed to load logo: ${se.status}`)}catch(se){console.error("Failed to load logo:",se),j&&V("Failed to load partner logo")}finally{j&&_(!1)}},ie=async()=>{try{const se=await fetch(Q.videoExistsUrl);if(se.ok){const ge=await se.text();j&&E(ge.toLowerCase()==="true")}else throw new Error(`Failed to check video: ${se.status}`)}catch(se){console.error("Failed to check if video exists:",se),j&&E(!1)}};return(async()=>{await te()&&ae(),ie()})(),()=>{j=!1,f&&URL.revokeObjectURL(f)}},[Q,n]);const F=()=>{I(!1)};return n||!e?jsxRuntime.jsxs(Card,{className:o,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),l&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"})]}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:o,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[S&&jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:b?jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"}):f&&jsxRuntime.jsx("img",{src:f,alt:`${e.PublicName}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Partner"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:e.ApplicationId})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"pb-2",children:[A&&jsxRuntime.jsx("div",{className:"text-red-500 mb-4 text-sm",role:"alert",children:A}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(e.IsManufacturer||e.IsReseller||e.IsSalesAgency)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.IsManufacturer&&jsxRuntime.jsx(Badge,{className:"manufacturer-theme",children:"Manufacturer"}),e.IsReseller&&jsxRuntime.jsx(Badge,{className:"reseller-theme",children:"Reseller"}),e.IsSalesAgency&&jsxRuntime.jsx(Badge,{children:"Agency"})]}),l&&e.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.About??""}}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.VoiceName??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.VoiceStyle??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.SceneName??"N/A"})]})]})})]})]}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[C&&Q?jsxRuntime.jsxs(Dialog,{open:q,onOpenChange:z,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[e.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[M&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:Q.videoUrl,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${e.PublicName}`,className:`w-full h-full object-cover ${M?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:F,onError:()=>I(!1)})]})]})]}):jsxRuntime.jsx("div",{}),t||jsxRuntime.jsxs(Button,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}const Textarea=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Textarea.displayName="Textarea";function ChatList({userId:e,chats:t,activeChat:n,onSelectChat:o,assistantChat:l}){return jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col min-h-full",children:[jsxRuntime.jsx("div",{className:"flex-grow",children:t.map(d=>{const f=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AvatarImage,{src:`https://api.randmar.io/v4/Partner/${d.partner1===e?d.partner2:d.partner1}/Account/Logo?height=72&width=72`,className:" object-contain "}),jsxRuntime.jsx(AvatarFallback,{children:jsxRuntime.jsx(Handshake,{className:"text-primary fill-white min-h-full"})})]});return display(d,n,o,f)})}),jsxRuntime.jsxs("div",{className:"mt-auto",children:[jsxRuntime.jsx(Separator$1,{className:"mb-1"}),display(l,n,o,jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"}))]})]})}function display(e,t,n,o){var l;return jsxRuntime.jsxs("button",{className:cn("w-full flex items-center p-2 rounded-md hover:bg-slate-100 transition-colors",(t==null?void 0:t.partner1)===e.partner1&&(t==null?void 0:t.partner2)===e.partner2&&"bg-slate-100"),onClick:()=>n([e.partner1,e.partner2]),children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:e.pending?jsxRuntime.jsx(MessageSquareLock,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}),jsxRuntime.jsxs("div",{className:"ml-2 text-left overflow-hidden",children:[jsxRuntime.jsx("div",{className:"font-medium text-sm truncate",children:e.name}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground truncate text-ellipsis",children:((l=e.messages.at(-1))==null?void 0:l.content)??""})]}),e.unread>0&&jsxRuntime.jsx("div",{className:"ml-auto bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center",children:e.unread})]},e.partner1+" and "+e.partner2)}var md5$1={exports:{}},crypt={exports:{}},hasRequiredCrypt;function requireCrypt(){return hasRequiredCrypt||(hasRequiredCrypt=1,function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(n,o){return n<<o|n>>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return t.rotl(n,8)&16711935|t.rotl(n,24)&4278255360;for(var o=0;o<n.length;o++)n[o]=t.endian(n[o]);return n},randomBytes:function(n){for(var o=[];n>0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],l=0,d=0;l<n.length;l++,d+=8)o[d>>>5]|=n[l]<<24-d%32;return o},wordsToBytes:function(n){for(var o=[],l=0;l<n.length*32;l+=8)o.push(n[l>>>5]>>>24-l%32&255);return o},bytesToHex:function(n){for(var o=[],l=0;l<n.length;l++)o.push((n[l]>>>4).toString(16)),o.push((n[l]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],l=0;l<n.length;l+=2)o.push(parseInt(n.substr(l,2),16));return o},bytesToBase64:function(n){for(var o=[],l=0;l<n.length;l+=3)for(var d=n[l]<<16|n[l+1]<<8|n[l+2],f=0;f<4;f++)l*8+f*6<=n.length*8?o.push(e.charAt(d>>>6*(3-f)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],l=0,d=0;l<n.length;d=++l%4)d!=0&&o.push((e.indexOf(n.charAt(l-1))&Math.pow(2,-2*d+8)-1)<<d*2|e.indexOf(n.charAt(l))>>>6-d*2);return o}};crypt.exports=t}()),crypt.exports}var charenc_1,hasRequiredCharenc;function requireCharenc(){if(hasRequiredCharenc)return charenc_1;hasRequiredCharenc=1;var e={utf8:{stringToBytes:function(t){return e.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(e.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var n=[],o=0;o<t.length;o++)n.push(t.charCodeAt(o)&255);return n},bytesToString:function(t){for(var n=[],o=0;o<t.length;o++)n.push(String.fromCharCode(t[o]));return n.join("")}}};return charenc_1=e,charenc_1}/*!
|
|
870
870
|
* Determine if an object is a Buffer
|
|
871
871
|
*
|
|
872
872
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
@@ -890,7 +890,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
|
|
|
890
890
|
`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},pp.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(types$1.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
891
891
|
`&&++this.pos;case`
|
|
892
892
|
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
893
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var d=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var f=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),e+=codePointToString(f),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$1,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx(),1),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);Ft(this,"ParsedChildren",null);pr(this,Ht,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[]}catch(f){return this.props.showWarnings&&console.warn(f),this.props.onError&&this.props.onError(f),this.props.renderError?this.props.renderError({error:String(f)}):null}return d.map(f=>qt(this,Rt).call(this,f)).filter(Boolean)});pr(this,Rt,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:qt(this,Rt).call(this,n.value,o);case"JSXElement":case"JSXFragment":return qt(this,xr).call(this,n,o);case"JSXExpressionContainer":return qt(this,Rt).call(this,n.expression,o);case"JSXText":const f=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:f},n.value);case"ArrayExpression":return n.elements.map(M=>qt(this,Rt).call(this,M,o));case"BinaryExpression":const g=qt(this,Rt).call(this,n.left,o),b=qt(this,Rt).call(this,n.right,o);let _;switch(n.operator){case"-":_=g-b;break;case"!=":_=g!=b;break;case"!==":_=g!==b;break;case"*":_=g*b;break;case"**":_=g**b;break;case"/":_=g/b;break;case"%":_=g%b;break;case"+":_=g+b;break;case"<":_=g<b;break;case"<=":_=g<=b;break;case"==":_=g==b;break;case"===":_=g===b;break;case">":_=g>b;break;case">=":_=g>=b;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(_);case"CallExpression":const S=qt(this,Rt).call(this,n.callee,o);if(S===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return S(...n.arguments.map(M=>qt(this,Rt).call(this,M,o)));case"ConditionalExpression":return qt(this,Rt).call(this,n.test,o)?qt(this,Rt).call(this,n.consequent,o):qt(this,Rt).call(this,n.alternate,o);case"ExpressionStatement":return qt(this,Rt).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const R=qt(this,Rt).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?qt(this,Rt).call(this,n.right,o):!1;case"MemberExpression":return qt(this,Er).call(this,n,o);case"ChainExpression":return qt(this,Zt).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(M=>{C[M.key.name||M.key.value]=qt(this,Rt).call(this,M.value,o)}),C;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((M,I)=>M.start<I.start?-1:1).map(M=>qt(this,Rt).call(this,M,o)).join("");case"UnaryExpression":const E=qt(this,Rt).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((d=(l=this.props).onError)==null||d.call(l,new Error("Async and generator arrow functions are not supported."))),(...M)=>{const I={...o};return n.params.forEach((A,V)=>{I[A.name]=M[V]}),qt(this,Rt).call(this,n.body,I)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});pr(this,Zt,(n,o)=>{try{return qt(this,Rt).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});pr(this,Er,(n,o)=>{const l=qt(this,Rt).call(this,n.object,o);let d;if(n.computed)d=qt(this,Rt).call(this,n.property,o);else if(n.property.type==="Identifier")d=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let f;try{f=l[d]}catch{this.props.onError(new Error(`The property '${d}' could not be resolved on the object '${l}'.`));return}return typeof f=="function"?f.bind(l):f});pr(this,dr,n=>n.type==="JSXIdentifier"?n.name:`${qt(this,dr).call(this,n.object)}.${qt(this,dr).call(this,n.property)}`);pr(this,xr,(n,o)=>{const{allowUnknownElements:l,components:d,componentsOnly:f,onError:g}=this.props,{children:b=[]}=n,_=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:S=[]}=_,R=n.type==="JSXElement"?qt(this,dr).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(z=>z instanceof RegExp?z:new RegExp(z,"i")),E=(this.props.blacklistedTags||[]).map(z=>z.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(z=>qt(this,xr).call(this,z,o));const M=R.trim().toLowerCase();if(E.indexOf(M)!==-1)return g(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(d,R)){if(f)return g(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!l&&document.createElement(R)instanceof HTMLUnknownElement)return g(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let I,A=n.type==="JSXElement"?resolvePath(d,R):React.Fragment;if(A||canHaveChildren(R)){if(I=b.map(Q=>qt(this,Rt).call(this,Q,o)),R.includes(".")){const F=R.split(".").reduce((j,te)=>j?j[te]:d==null?void 0:d[te],null);F&&(A=F)}!A&&!canHaveWhitespace(R)&&(I=I.filter(Q=>typeof Q!="string"||!/^\s*$/.test(Q)));const z=I.find(Q=>typeof Q=="function");I.length===0?I=void 0:z?I=z:I.length===1?[I]=I:I.length>1&&!this.props.disableKeyGeneration&&(I=I.map((Q,F)=>Q!=null&&Q.type&&!(Q!=null&&Q.key)?{...Q,key:Q.key||F}:Q))}const V={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(z=>{if(z.type==="JSXAttribute"){const Q=z.name.name,F=attributeNames_default[Q]||Q,j=qt(this,Rt).call(this,z,o);C.filter(ae=>ae.test(F)).length===0&&(V[F]=j)}else if(z.type==="JSXSpreadAttribute"&&z.argument.type==="Identifier"||z.argument.type==="MemberExpression"){const Q=qt(this,Rt).call(this,z.argument,o);typeof Q=="object"&&Object.keys(Q).forEach(F=>{const j=attributeNames_default[F]||F;C.filter(ae=>ae.test(j)).length===0&&(V[j]=Q[F])})}}),typeof V.style=="string"&&(V.style=parseStyle(V.style));const q=R.toLowerCase();return q==="option"&&(I=I.props.children),React.createElement(A||q,V,I)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=qt(this,Ht).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}Ht=new WeakMap,Rt=new WeakMap,Zt=new WeakMap,Er=new WeakMap,dr=new WeakMap,xr=new WeakMap,Ft(JsxParser,"displayName","JsxParser"),Ft(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:o}){const[l,d]=React__namespace.useState(!1),[f,g]=React__namespace.useState(!1),[b,_]=React__namespace.useState(!1),[S,R]=React__namespace.useState(!1),C=`https://api.randmar.io/Product/${e}/Video`;React__namespace.useEffect(()=>{(async()=>{try{const z=await(await fetch(C+"/Exists")).json();g(z)}catch(q){console.error("Error checking for video:",q),g(!1)}})()},[e,C]);async function E(){if(f){R(!0);try{const q=await(await fetch(C)).blob(),z=window.URL.createObjectURL(q),Q=document.createElement("a");Q.href=z,Q.download=`${e||"product"}-video.mp4`,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),window.URL.revokeObjectURL(z)}catch(V){console.error("Error downloading video:",V)}finally{R(!1)}}}function M(){navigator.clipboard.writeText(C),_(!0),setTimeout(()=>{_(!1)},2e3)}function I(){d(!0)}const A=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:l,onOpenChange:d,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:o?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:C,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:o})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:C,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:M,children:b?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:E,disabled:S,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${f?"cursor-pointer":""}`,onClick:f?I:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${A*1.5}&height=${A*1.5}`,width:A,height:A}),f&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:I,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}const CountryFlag=({countryCode:e,className:t=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function useIntersectionObserver({elementRef:e,threshold:t=0,rootMargin:n="0px"}){const[o,l]=React.useState(!1);return React.useEffect(()=>{const d=new IntersectionObserver(([g])=>{l(g.isIntersecting)},{threshold:t,rootMargin:n}),f=e.current;return f&&d.observe(f),()=>{f&&d.unobserve(f)}},[e,t,n]),o}function ProductCard({item:e,addToCart:t=!1,syncToShopify:n=!1,customAction:o=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:l="",viewProductLink:d,addToCartAction:f,isAddToCartActionLoading:g=!1,syncToShopifyAction:b,isSyncToShopifyActionLoading:_=!1}){var Ge,qe,Ke,Qe,We,nt,Xe,rt,Je,Ze,at;const[S,R]=React.useState(1),[C,E]=React.useState(null),[M,I]=React.useState(0),[A,V]=React.useState(!1),q=React.useRef(null),z=useIntersectionObserver({elementRef:q,threshold:.1,rootMargin:"100px"}),Q=((Ge=e==null?void 0:e.Distribution)==null?void 0:Ge.Cost)||0,F=((qe=e==null?void 0:e.Distribution)==null?void 0:qe.RegularPrice)||0,j=((Ke=e==null?void 0:e.Distribution)==null?void 0:Ke.Price)||0;React.useEffect(()=>{R(1),E(null),I(0),V(!1)},[e==null?void 0:e.RandmarSKU]);const[te,ae]=React.useState(null),[ie,oe]=React.useState(!1);React.useEffect(()=>{const He=async()=>{if(e!=null&&e.ManufacturerId){oe(!0);try{const st=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(st.ok){const Ye=await st.blob();ae(URL.createObjectURL(Ye))}}catch(st){console.error("Failed to load logo:",st)}finally{oe(!1)}}};z&&(e!=null&&e.ManufacturerId)&&He()},[e==null?void 0:e.ManufacturerId,z]),React.useEffect(()=>{var He;if(e&&l){const st=(He=e.Opportunities)==null?void 0:He.find(Ye=>Ye.BidNumber==l);st&&E(st)}},[e,l]),React.useEffect(()=>{if(!e)return;const He=C!=null&&C.Price?C.Price:j;I(F>0?Math.round((F-He)/F*100):0)},[e,C,j,F]),React.useEffect(()=>{g||R(1)},[g]);const se=He=>{if(He.Active!==!0)return!1;const st=new Date().toISOString().split("T")[0];return!(He.EndDate&&He.EndDate.split("T")[0]<st||He.StartDate&&He.StartDate.split("T")[0]>st)};if(!e)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const ge=(e==null?void 0:e.Opportunities)||[],Ae=ge.length>0,Ne=()=>{if(S==null){R(1);return}S>1&&R(S-1)},Be=()=>{if(S==null){R(1);return}R(S+1)},Fe=He=>{const st=Number.parseInt(He.target.value,10);if(!isNaN(st)&&st>0){R(st);return}R(void 0)},ze=()=>{(S==null||S<1)&&R(1)},Oe=((We=(Qe=e.Distribution)==null?void 0:Qe.Inventory)==null?void 0:We.reduce((He,st)=>He+(st.AvailableQuantity||0),0))||0,Ve=He=>{try{return new Date(He).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(st){return console.error(st),He.split("T")[0]||"N/A"}},Le=()=>{f&&f({quantity:S??1,bidNumber:(C==null?void 0:C.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",ref:q,children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:ie?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):z&&te&&jsxRuntime.jsx("img",{src:te||"/placeholder.svg",alt:e.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",e.AvailableToBuy?"Available":"Unavailable"]}),e.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(nt=e.ManufacturerCategory)!=null&&nt.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(Xe=e.ManufacturerCategory)!=null&&Xe.QualificationRequired?"Qualified Only":"Available to all"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UnitWeight?`${e.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MAP?"$"+e.MAP.toFixed(2):"N/A"})]}),e.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[z&&jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""}),!z&&jsxRuntime.jsx("div",{className:"w-60 h-40 bg-gray-100 rounded-lg flex items-center justify-center",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:Ae&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+ge.length+(ge.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:ge.map((He,st)=>{var Ye;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
893
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var d=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var f=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),e+=codePointToString(f),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$1,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx(),1),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);Ft(this,"ParsedChildren",null);pr(this,Ht,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[]}catch(f){return this.props.showWarnings&&console.warn(f),this.props.onError&&this.props.onError(f),this.props.renderError?this.props.renderError({error:String(f)}):null}return d.map(f=>qt(this,Rt).call(this,f)).filter(Boolean)});pr(this,Rt,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:qt(this,Rt).call(this,n.value,o);case"JSXElement":case"JSXFragment":return qt(this,xr).call(this,n,o);case"JSXExpressionContainer":return qt(this,Rt).call(this,n.expression,o);case"JSXText":const f=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:f},n.value);case"ArrayExpression":return n.elements.map(M=>qt(this,Rt).call(this,M,o));case"BinaryExpression":const g=qt(this,Rt).call(this,n.left,o),b=qt(this,Rt).call(this,n.right,o);let _;switch(n.operator){case"-":_=g-b;break;case"!=":_=g!=b;break;case"!==":_=g!==b;break;case"*":_=g*b;break;case"**":_=g**b;break;case"/":_=g/b;break;case"%":_=g%b;break;case"+":_=g+b;break;case"<":_=g<b;break;case"<=":_=g<=b;break;case"==":_=g==b;break;case"===":_=g===b;break;case">":_=g>b;break;case">=":_=g>=b;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(_);case"CallExpression":const S=qt(this,Rt).call(this,n.callee,o);if(S===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return S(...n.arguments.map(M=>qt(this,Rt).call(this,M,o)));case"ConditionalExpression":return qt(this,Rt).call(this,n.test,o)?qt(this,Rt).call(this,n.consequent,o):qt(this,Rt).call(this,n.alternate,o);case"ExpressionStatement":return qt(this,Rt).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const R=qt(this,Rt).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?qt(this,Rt).call(this,n.right,o):!1;case"MemberExpression":return qt(this,Er).call(this,n,o);case"ChainExpression":return qt(this,Zt).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(M=>{C[M.key.name||M.key.value]=qt(this,Rt).call(this,M.value,o)}),C;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((M,I)=>M.start<I.start?-1:1).map(M=>qt(this,Rt).call(this,M,o)).join("");case"UnaryExpression":const E=qt(this,Rt).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((d=(l=this.props).onError)==null||d.call(l,new Error("Async and generator arrow functions are not supported."))),(...M)=>{const I={...o};return n.params.forEach((A,V)=>{I[A.name]=M[V]}),qt(this,Rt).call(this,n.body,I)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});pr(this,Zt,(n,o)=>{try{return qt(this,Rt).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});pr(this,Er,(n,o)=>{const l=qt(this,Rt).call(this,n.object,o);let d;if(n.computed)d=qt(this,Rt).call(this,n.property,o);else if(n.property.type==="Identifier")d=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let f;try{f=l[d]}catch{this.props.onError(new Error(`The property '${d}' could not be resolved on the object '${l}'.`));return}return typeof f=="function"?f.bind(l):f});pr(this,dr,n=>n.type==="JSXIdentifier"?n.name:`${qt(this,dr).call(this,n.object)}.${qt(this,dr).call(this,n.property)}`);pr(this,xr,(n,o)=>{const{allowUnknownElements:l,components:d,componentsOnly:f,onError:g}=this.props,{children:b=[]}=n,_=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:S=[]}=_,R=n.type==="JSXElement"?qt(this,dr).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(z=>z instanceof RegExp?z:new RegExp(z,"i")),E=(this.props.blacklistedTags||[]).map(z=>z.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(z=>qt(this,xr).call(this,z,o));const M=R.trim().toLowerCase();if(E.indexOf(M)!==-1)return g(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(d,R)){if(f)return g(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!l&&document.createElement(R)instanceof HTMLUnknownElement)return g(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let I,A=n.type==="JSXElement"?resolvePath(d,R):React.Fragment;if(A||canHaveChildren(R)){if(I=b.map(Q=>qt(this,Rt).call(this,Q,o)),R.includes(".")){const F=R.split(".").reduce((j,te)=>j?j[te]:d==null?void 0:d[te],null);F&&(A=F)}!A&&!canHaveWhitespace(R)&&(I=I.filter(Q=>typeof Q!="string"||!/^\s*$/.test(Q)));const z=I.find(Q=>typeof Q=="function");I.length===0?I=void 0:z?I=z:I.length===1?[I]=I:I.length>1&&!this.props.disableKeyGeneration&&(I=I.map((Q,F)=>Q!=null&&Q.type&&!(Q!=null&&Q.key)?{...Q,key:Q.key||F}:Q))}const V={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(z=>{if(z.type==="JSXAttribute"){const Q=z.name.name,F=attributeNames_default[Q]||Q,j=qt(this,Rt).call(this,z,o);C.filter(ae=>ae.test(F)).length===0&&(V[F]=j)}else if(z.type==="JSXSpreadAttribute"&&z.argument.type==="Identifier"||z.argument.type==="MemberExpression"){const Q=qt(this,Rt).call(this,z.argument,o);typeof Q=="object"&&Object.keys(Q).forEach(F=>{const j=attributeNames_default[F]||F;C.filter(ae=>ae.test(j)).length===0&&(V[j]=Q[F])})}}),typeof V.style=="string"&&(V.style=parseStyle(V.style));const q=R.toLowerCase();return q==="option"&&(I=I.props.children),React.createElement(A||q,V,I)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=qt(this,Ht).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}Ht=new WeakMap,Rt=new WeakMap,Zt=new WeakMap,Er=new WeakMap,dr=new WeakMap,xr=new WeakMap,Ft(JsxParser,"displayName","JsxParser"),Ft(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;function useIntersectionObserver({elementRef:e,threshold:t=0,rootMargin:n="0px"}){const[o,l]=React.useState(!1);return React.useEffect(()=>{const d=new IntersectionObserver(([g])=>{l(g.isIntersecting)},{threshold:t,rootMargin:n}),f=e.current;return f&&d.observe(f),()=>{f&&d.unobserve(f)}},[e,t,n]),o}const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:o}){const[l,d]=React__namespace.useState(!1),[f,g]=React__namespace.useState(!1),[b,_]=React__namespace.useState(!1),[S,R]=React__namespace.useState(!1),[C,E]=React__namespace.useState(!1),M=`https://api.randmar.io/Product/${e}/Video`,I=React.useRef(null),A=useIntersectionObserver({elementRef:I,threshold:.1,rootMargin:"100px"});React__namespace.useEffect(()=>{const F=async()=>{try{const te=await(await fetch(M+"/Exists")).json();g(te)}catch(j){console.error("Error checking for video:",j),g(!1)}};A&&!b&&(_(!0),F())},[e,M,A,b]);async function V(){if(f){E(!0);try{const j=await(await fetch(M)).blob(),te=window.URL.createObjectURL(j),ae=document.createElement("a");ae.href=te,ae.download=`${e||"product"}-video.mp4`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae),window.URL.revokeObjectURL(te)}catch(F){console.error("Error downloading video:",F)}finally{E(!1)}}}function q(){navigator.clipboard.writeText(M),R(!0),setTimeout(()=>{R(!1)},2e3)}function z(){d(!0)}const Q=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:l,onOpenChange:d,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:o?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:M,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:o})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:M,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:q,children:S?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:V,disabled:C,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",ref:I,children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${f?"cursor-pointer":""}`,onClick:f?z:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${Q*1.5}&height=${Q*1.5}`,width:Q,height:Q}),f&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:z,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}const CountryFlag=({countryCode:e,className:t=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function ProductCard({item:e,addToCart:t=!1,syncToShopify:n=!1,customAction:o=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:l="",viewProductLink:d,addToCartAction:f,isAddToCartActionLoading:g=!1,syncToShopifyAction:b,isSyncToShopifyActionLoading:_=!1}){var Ge,qe,Ke,Qe,We,nt,Xe,rt,Je,Ze,at;const[S,R]=React.useState(1),[C,E]=React.useState(null),[M,I]=React.useState(0),[A,V]=React.useState(!1),q=React.useRef(null),z=useIntersectionObserver({elementRef:q,threshold:.1,rootMargin:"100px"}),Q=((Ge=e==null?void 0:e.Distribution)==null?void 0:Ge.Cost)||0,F=((qe=e==null?void 0:e.Distribution)==null?void 0:qe.RegularPrice)||0,j=((Ke=e==null?void 0:e.Distribution)==null?void 0:Ke.Price)||0;React.useEffect(()=>{R(1),E(null),I(0),V(!1)},[e==null?void 0:e.RandmarSKU]);const[te,ae]=React.useState(null),[ie,oe]=React.useState(!1);React.useEffect(()=>{const He=async()=>{if(e!=null&&e.ManufacturerId){oe(!0);try{const st=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(st.ok){const Ye=await st.blob();ae(URL.createObjectURL(Ye))}}catch(st){console.error("Failed to load logo:",st)}finally{oe(!1)}}};z&&(e!=null&&e.ManufacturerId)&&!te&&He()},[e==null?void 0:e.ManufacturerId,z,te]),React.useEffect(()=>{ae(null)},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var He;if(e&&l){const st=(He=e.Opportunities)==null?void 0:He.find(Ye=>Ye.BidNumber==l);st&&E(st)}},[e,l]),React.useEffect(()=>{if(!e)return;const He=C!=null&&C.Price?C.Price:j;I(F>0?Math.round((F-He)/F*100):0)},[e,C,j,F]),React.useEffect(()=>{g||R(1)},[g]);const se=He=>{if(He.Active!==!0)return!1;const st=new Date().toISOString().split("T")[0];return!(He.EndDate&&He.EndDate.split("T")[0]<st||He.StartDate&&He.StartDate.split("T")[0]>st)};if(!e)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const ge=(e==null?void 0:e.Opportunities)||[],Ae=ge.length>0,Ne=()=>{if(S==null){R(1);return}S>1&&R(S-1)},Be=()=>{if(S==null){R(1);return}R(S+1)},Fe=He=>{const st=Number.parseInt(He.target.value,10);if(!isNaN(st)&&st>0){R(st);return}R(void 0)},ze=()=>{(S==null||S<1)&&R(1)},Oe=((We=(Qe=e.Distribution)==null?void 0:Qe.Inventory)==null?void 0:We.reduce((He,st)=>He+(st.AvailableQuantity||0),0))||0,Ve=He=>{try{return new Date(He).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(st){return console.error(st),He.split("T")[0]||"N/A"}},Le=()=>{f&&f({quantity:S??1,bidNumber:(C==null?void 0:C.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",ref:q,children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:ie?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):z&&te&&jsxRuntime.jsx("img",{src:te||"/placeholder.svg",alt:e.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",e.AvailableToBuy?"Available":"Unavailable"]}),e.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(nt=e.ManufacturerCategory)!=null&&nt.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(Xe=e.ManufacturerCategory)!=null&&Xe.QualificationRequired?"Qualified Only":"Available to all"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UnitWeight?`${e.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MAP?"$"+e.MAP.toFixed(2):"N/A"})]}),e.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:Ae&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+ge.length+(ge.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:ge.map((He,st)=>{var Ye;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
894
894
|
${He.BidNumber==(C==null?void 0:C.BidNumber)?"cursor-pointer border-2 border-purple-900":se(He)?"hover:bg-purple-200 cursor-pointer":"!bg-neutral-50"}
|
|
895
895
|
`,onClick:()=>{se(He)&&E(He.BidNumber!=(C==null?void 0:C.BidNumber)?He:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:He.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[He.BidNumber," ",!se(He)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(Ye=He.Price)==null?void 0:Ye.toFixed(2)]}),He.Rebate&&He.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",He.Rebate.toFixed(2)]}),He.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",Ve(He.EndDate)]})]})]},st)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[d&&jsxRuntime.jsx(reactRouterDom.Link,{to:d,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((rt=e.Distribution)==null?void 0:rt.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsxs(Dialog,{open:A,onOpenChange:V,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:`flex items-center text-sm ${Oe>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),Oe>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Oe," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:e.Distribution.Inventory})]})]})})]})]}),e.Distribution&&jsxRuntime.jsxs("div",{className:"flex justify-between items-end mt-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-1 flex flex-col items-start gap-1",children:Q>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"Cost: $"}),Q.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"$"}),C?(Ze=(Je=e.Opportunities)==null?void 0:Je.find(He=>He.BidNumber==C.BidNumber))==null?void 0:Ze.Price:j.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]}),M>0&&jsxRuntime.jsxs("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:["$",F.toFixed(2)]})]}),M>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[M,"% OFF"]}),((at=e.InstantRebate)==null?void 0:at.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",e.InstantRebate.EndDate.split("T")[0]]}),(C==null?void 0:C.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",C.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 gap-2 ml-4",children:[typeof t<"u"&&t&&jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:Ne,disabled:typeof S<"u"&&(S<=1||!e.AvailableToBuy||g||!f),children:"-"}),jsxRuntime.jsx("input",{value:S,onChange:Fe,onBlur:ze,onClick:He=>He.currentTarget.select(),className:`w-12 text-center border-0 focus:ring-0 focus:outline-none ${!e.AvailableToBuy||g||!f?"text-gray-400":""}`,disabled:!e.AvailableToBuy||g||!f}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:Be,disabled:!e.AvailableToBuy||g||!f,children:"+"})]}),typeof t<"u"&&t&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap",onClick:Le,disabled:!e.AvailableToBuy||g||!f,children:g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})}),n&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:b,disabled:_||!b,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),o]})]})]})})}const complexComponents=[`----
|
|
896
896
|
PartnerCard: For data that fits this shape:
|