randmarcomps 1.455.0 → 1.457.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 +19 -13
- package/dist/randmarcomps.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -59692,7 +59692,10 @@ function ChatMessages({ messages: t, appID: e, botStatus: n, isAssistantChat: o
|
|
|
59692
59692
|
] }) }, d.id);
|
|
59693
59693
|
}),
|
|
59694
59694
|
n !== "" && /* @__PURE__ */ jsx(SkeletonMessage, { botStatus: n }),
|
|
59695
|
-
t.length === 0 && !o && /* @__PURE__ */
|
|
59695
|
+
t.length === 0 && !o && /* @__PURE__ */ jsxs("div", { className: "mt-1 text-xl", children: [
|
|
59696
|
+
/* @__PURE__ */ jsx(Send, { className: "w-full h-32" }),
|
|
59697
|
+
/* @__PURE__ */ jsx("p", { className: "text-center", children: "No messages yet... Say hello!" })
|
|
59698
|
+
] }),
|
|
59696
59699
|
t.length === 0 && n === "" && o && /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
|
|
59697
59700
|
/* @__PURE__ */ jsx("p", { children: "The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers." }),
|
|
59698
59701
|
/* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("strong", { children: 'Try it now, type "my open orders"!' }) })
|
|
@@ -59730,7 +59733,7 @@ function ChatMainArea({
|
|
|
59730
59733
|
] }),
|
|
59731
59734
|
e != null && e.pending && e.partner1 == n ? /* @__PURE__ */ jsx("p", { className: "mt-8 p-2 mx-auto", children: "This conversation is awaiting approval by the other party — please check back later." }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
59732
59735
|
/* @__PURE__ */ jsxs(ScrollArea, { className: "flex-1 pl-2 pr-2 bg-slate-50", children: [
|
|
59733
|
-
/* @__PURE__ */ jsx(
|
|
59736
|
+
/* @__PURE__ */ jsx("div", { className: (e == null ? void 0 : e.messages) === null ? " opacity-0" : "", children: /* @__PURE__ */ jsx(
|
|
59734
59737
|
ChatMessages,
|
|
59735
59738
|
{
|
|
59736
59739
|
messages: (e == null ? void 0 : e.messages) ?? [],
|
|
@@ -59738,7 +59741,7 @@ function ChatMainArea({
|
|
|
59738
59741
|
isAssistantChat: !1,
|
|
59739
59742
|
botStatus: ""
|
|
59740
59743
|
}
|
|
59741
|
-
),
|
|
59744
|
+
) }),
|
|
59742
59745
|
/* @__PURE__ */ jsx("div", { ref: o })
|
|
59743
59746
|
] }),
|
|
59744
59747
|
/* @__PURE__ */ jsxs("div", { className: "p-4 border-t border-r flex", children: [
|
|
@@ -59884,7 +59887,7 @@ function ChatLayout({ appID: t, inputRef: e, className: n }) {
|
|
|
59884
59887
|
name: ((We = Mt.Participant) == null ? void 0 : We.PublicName) ?? "missing public name",
|
|
59885
59888
|
unread: (It == null ? void 0 : It.unread) ?? 0,
|
|
59886
59889
|
pending: Mt.Status !== "Approved",
|
|
59887
|
-
messages: (It == null ? void 0 : It.messages) ??
|
|
59890
|
+
messages: (It == null ? void 0 : It.messages) ?? null,
|
|
59888
59891
|
conversationID: Mt.ConversationId,
|
|
59889
59892
|
lastMessageTime: Mt.LastMessageTime ?? null
|
|
59890
59893
|
};
|
|
@@ -59912,13 +59915,15 @@ function ChatLayout({ appID: t, inputRef: e, className: n }) {
|
|
|
59912
59915
|
return;
|
|
59913
59916
|
}
|
|
59914
59917
|
se((It) => It.map((We) => {
|
|
59915
|
-
if (!ct(Mt, We)
|
|
59916
|
-
|
|
59917
|
-
|
|
59918
|
-
|
|
59919
|
-
|
|
59920
|
-
|
|
59921
|
-
|
|
59918
|
+
if (!ct(Mt, We)) return We;
|
|
59919
|
+
const Ye = We.messages ?? [];
|
|
59920
|
+
if (Ye.some((pt) => pt.id === Mt.id)) return We;
|
|
59921
|
+
let nt = 1;
|
|
59922
|
+
const ut = document.activeElement && document.activeElement === Le.current;
|
|
59923
|
+
return (V == null ? void 0 : V[0]) == We.partner1 && V[1] == We.partner2 && ut && (ut && (nt = 0, Qe()), setTimeout(() => {
|
|
59924
|
+
var pt;
|
|
59925
|
+
return (pt = Ne.current) == null ? void 0 : pt.scrollIntoView({ behavior: "smooth" });
|
|
59926
|
+
}, 50)), { ...We, pending: !1, unread: We.unread + nt, messages: [...Ye, Mt] };
|
|
59922
59927
|
}).sort(sortChats));
|
|
59923
59928
|
}), console.log("need refetch:", Ct), Ct && d(), Ve([]);
|
|
59924
59929
|
}, [Fe, Ve, se, j, V]), useEffect(() => {
|
|
@@ -65081,9 +65086,10 @@ $10 with opportunities under $1,000` : t === "D" ? "$15 under $1,500" : t === "E
|
|
|
65081
65086
|
Commercial: "commercial",
|
|
65082
65087
|
Basics: "cws",
|
|
65083
65088
|
Novexco: "novexco",
|
|
65089
|
+
COOPSCO: "coopsco",
|
|
65084
65090
|
"Jean Coutu": "jeancoutu",
|
|
65085
65091
|
Exclusive: "exclusive"
|
|
65086
|
-
}[Ne] || "", R = (Ne) => Ne && { A: "free", B: "fixed", C: "dropshipped", D: "under1500", E: "fullcharges" }[Ne] || "", A = (Ne) => Ne && { 1: "exclusive", 2: "ecommerce", 3: "commercial", 4: "buyinggroup", 5: "cost" }[Ne] || "", [M, I] = useState(E((n == null ? void 0 : n.Priority) ?? "")), [O, F] = useState(R((n == null ? void 0 : n.ShippingProfile) ?? "")), [z, Q] = useState(A(n == null ? void 0 : n.PriceProfile)), V = (Ne) => ({ starter: "Starter", ecommerce: "E-Commerce", commercial: "Commercial", cws: "Basics", novexco: "Novexco", jeancoutu: "Jean Coutu", exclusive: "Exclusive" })[Ne] || Ne, j = (Ne) => ({ free: "A", fixed: "B", dropshipped: "C", under1500: "D", fullcharges: "E" })[Ne] || Ne, te = (Ne) => ({ exclusive: "1", ecommerce: "2", commercial: "3", buyinggroup: "4", cost: "5" })[Ne] || Ne;
|
|
65092
|
+
}[Ne] || "", R = (Ne) => Ne && { A: "free", B: "fixed", C: "dropshipped", D: "under1500", E: "fullcharges" }[Ne] || "", A = (Ne) => Ne && { 1: "exclusive", 2: "ecommerce", 3: "commercial", 4: "buyinggroup", 5: "cost" }[Ne] || "", [M, I] = useState(E((n == null ? void 0 : n.Priority) ?? "")), [O, F] = useState(R((n == null ? void 0 : n.ShippingProfile) ?? "")), [z, Q] = useState(A(n == null ? void 0 : n.PriceProfile)), V = (Ne) => ({ starter: "Starter", ecommerce: "E-Commerce", commercial: "Commercial", cws: "Basics", novexco: "Novexco", coopsco: "COOPSCO", jeancoutu: "Jean Coutu", exclusive: "Exclusive" })[Ne] || Ne, j = (Ne) => ({ free: "A", fixed: "B", dropshipped: "C", under1500: "D", fullcharges: "E" })[Ne] || Ne, te = (Ne) => ({ exclusive: "1", ecommerce: "2", commercial: "3", buyinggroup: "4", cost: "5" })[Ne] || Ne;
|
|
65087
65093
|
useEffect(() => {
|
|
65088
65094
|
I(E((n == null ? void 0 : n.Priority) ?? "")), F(R((n == null ? void 0 : n.ShippingProfile) ?? "")), Q(A(n == null ? void 0 : n.PriceProfile));
|
|
65089
65095
|
}, [n]);
|
|
@@ -65219,7 +65225,7 @@ $10 with opportunities under $1,000` : t === "D" ? "$15 under $1,500" : t === "E
|
|
|
65219
65225
|
/* @__PURE__ */ jsx(CardContent, { className: "pt-2 px-4 pb-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
65220
65226
|
/* @__PURE__ */ jsxs("div", { className: "bg-muted/30 p-2 rounded-lg", children: [
|
|
65221
65227
|
/* @__PURE__ */ jsx(Label$2, { className: "block mb-1 text-xs font-medium", children: "Priority" }),
|
|
65222
|
-
/* @__PURE__ */ jsx(RadioGroup$1, { value: M, onValueChange: ae, className: "grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1", children: [{ value: "starter", label: "Starter" }, { value: "ecommerce", label: "E-Commerce" }, { value: "commercial", label: "Commercial" }, { value: "cws", label: "CWS (Basics)" }, { value: "novexco", label: "Novexco" }, { value: "jeancoutu", label: "Jean Coutu" }, { value: "exclusive", label: "Exclusive" }].map((Ne) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
65228
|
+
/* @__PURE__ */ jsx(RadioGroup$1, { value: M, onValueChange: ae, className: "grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1", children: [{ value: "starter", label: "Starter" }, { value: "ecommerce", label: "E-Commerce" }, { value: "commercial", label: "Commercial" }, { value: "cws", label: "CWS (Basics)" }, { value: "novexco", label: "Novexco" }, { value: "coopsco", label: "COOPSCO" }, { value: "jeancoutu", label: "Jean Coutu" }, { value: "exclusive", label: "Exclusive" }].map((Ne) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
65223
65229
|
/* @__PURE__ */ jsx(RadioGroupItem, { value: Ne.value, id: `priority-${Ne.value}`, className: "h-6 w-6 scale-50" }),
|
|
65224
65230
|
/* @__PURE__ */ jsx(Label$2, { htmlFor: `priority-${Ne.value}`, className: "cursor-pointer text-xs", children: Ne.label })
|
|
65225
65231
|
] }, Ne.value)) })
|
|
@@ -1135,7 +1135,7 @@ ${t}</tr>
|
|
|
1135
1135
|
`}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>${escape2(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const o=this.parser.parseInline(n),l=cleanUrl(t);if(l===null)return o;t=l;let d='<a href="'+t+'"';return e&&(d+=' title="'+escape2(e)+'"'),d+=">"+o+"</a>",d}image({href:t,title:e,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));const l=cleanUrl(t);if(l===null)return escape2(n);t=l;let d=`<img src="${t}" alt="${n}"`;return e&&(d+=` title="${escape2(e)}"`),d+=">",d}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:escape2(t.text)}},_TextRenderer=class{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""}},_Parser=class yr{constructor(e){Zt(this,"options");Zt(this,"renderer");Zt(this,"textRenderer");this.options=e||_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(e,n){return new yr(n).parse(e)}static parseInline(e,n){return new yr(n).parseInline(e)}parse(e,n=!0){var l,d;let o="";for(let f=0;f<e.length;f++){const g=e[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<e.length&&e[f+1].type==="text";)_=e[++f],S+=`
|
|
1136
1136
|
`+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(e,n=this.renderer){var l,d;let o="";for(let f=0;f<e.length;f++){const g=e[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}},_Hooks=(on=class{constructor(t){Zt(this,"options");Zt(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}},Zt(on,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),on),Marked=class{constructor(...t){Zt(this,"defaults",_getDefaults());Zt(this,"options",this.setOptions);Zt(this,"parse",this.parseMarkdown(!0));Zt(this,"parseInline",this.parseMarkdown(!1));Zt(this,"Parser",_Parser);Zt(this,"Renderer",_Renderer);Zt(this,"TextRenderer",_TextRenderer);Zt(this,"Lexer",_Lexer);Zt(this,"Tokenizer",_Tokenizer);Zt(this,"Hooks",_Hooks);this.use(...t)}walkTokens(t,e){var o,l;let n=[];for(const d of t)switch(n=n.concat(e.call(this,d)),d.type){case"table":{const f=d;for(const g of f.header)n=n.concat(this.walkTokens(g.tokens,e));for(const g of f.rows)for(const b of g)n=n.concat(this.walkTokens(b.tokens,e));break}case"list":{const f=d;n=n.concat(this.walkTokens(f.items,e));break}default:{const f=d;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[f.type]?this.defaults.extensions.childTokens[f.type].forEach(g=>{const b=f[g].flat(1/0);n=n.concat(this.walkTokens(b,e))}):f.tokens&&(n=n.concat(this.walkTokens(f.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const d=e.renderers[l.name];d?e.renderers[l.name]=function(...f){let g=l.renderer.apply(this,f);return g===!1&&(g=d.apply(this,f)),g}:e.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const d=e[l.level];d?d.unshift(l.tokenizer):e[l.level]=[l.tokenizer],l.start&&(l.level==="block"?e.startBlock?e.startBlock.push(l.start):e.startBlock=[l.start]:l.level==="inline"&&(e.startInline?e.startInline.push(l.start):e.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(e.childTokens[l.name]=l.childTokens)}),o.extensions=e),n.renderer){const l=this.defaults.renderer||new _Renderer(this.defaults);for(const d in n.renderer){if(!(d in l))throw new Error(`renderer '${d}' does not exist`);if(["options","parser"].includes(d))continue;const f=d,g=n.renderer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new _Tokenizer(this.defaults);for(const d in n.tokenizer){if(!(d in l))throw new Error(`tokenizer '${d}' does not exist`);if(["options","rules","lexer"].includes(d))continue;const f=d,g=n.tokenizer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new _Hooks;for(const d in n.hooks){if(!(d in l))throw new Error(`hook '${d}' does not exist`);if(["options","block"].includes(d))continue;const f=d,g=n.hooks[f],b=l[f];_Hooks.passThroughHooks.has(d)?l[f]=_=>{if(this.defaults.async)return Promise.resolve(g.call(l,_)).then(R=>b.call(l,R));const S=g.call(l,_);return b.call(l,S)}:l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.hooks=l}if(n.walkTokens){const l=this.defaults.walkTokens,d=n.walkTokens;o.walkTokens=function(f){let g=[];return g.push(d.call(this,f)),l&&(g=g.concat(l.call(this,f))),g}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return _Lexer.lex(t,e??this.defaults)}parser(t,e){return _Parser.parse(t,e??this.defaults)}parseMarkdown(t){return(n,o)=>{const l={...o},d={...this.defaults,...l},f=this.onError(!!d.silent,!!d.async);if(this.defaults.async===!0&&l.async===!1)return f(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 n>"u"||n===null)return f(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return f(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));d.hooks&&(d.hooks.options=d,d.hooks.block=t);const g=d.hooks?d.hooks.provideLexer():t?_Lexer.lex:_Lexer.lexInline,b=d.hooks?d.hooks.provideParser():t?_Parser.parse:_Parser.parseInline;if(d.async)return Promise.resolve(d.hooks?d.hooks.preprocess(n):n).then(_=>g(_,d)).then(_=>d.hooks?d.hooks.processAllTokens(_):_).then(_=>d.walkTokens?Promise.all(this.walkTokens(_,d.walkTokens)).then(()=>_):_).then(_=>b(_,d)).then(_=>d.hooks?d.hooks.postprocess(_):_).catch(f);try{d.hooks&&(n=d.hooks.preprocess(n));let _=g(n,d);d.hooks&&(_=d.hooks.processAllTokens(_)),d.walkTokens&&this.walkTokens(_,d.walkTokens);let S=b(_,d);return d.hooks&&(S=d.hooks.postprocess(S)),S}catch(_){return f(_)}}}onError(t,e){return n=>{if(n.message+=`
|
|
1137
1137
|
Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(t,e){return markedInstance.parse(t,e)}marked.options=marked.setOptions=function(t){return markedInstance.setOptions(t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...t){return markedInstance.use(...t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(t,e){return markedInstance.walkTokens(t,e)},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;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries,setPrototypeOf,isFrozen,getPrototypeOf,getOwnPropertyDescriptor}=Object;let{freeze,seal,create}=Object,{apply:apply$1,construct}=typeof Reflect<"u"&&Reflect;freeze||(freeze=function(e){return e}),seal||(seal=function(e){return e}),apply$1||(apply$1=function(e,n){for(var o=arguments.length,l=new Array(o>2?o-2:0),d=2;d<o;d++)l[d-2]=arguments[d];return e.apply(n,l)}),construct||(construct=function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return new e(...o)});const arrayForEach=unapply(Array.prototype.forEach),arrayLastIndexOf=unapply(Array.prototype.lastIndexOf),arrayPop=unapply(Array.prototype.pop),arrayPush=unapply(Array.prototype.push),arraySplice=unapply(Array.prototype.splice),stringToLowerCase=unapply(String.prototype.toLowerCase),stringToString=unapply(String.prototype.toString),stringMatch=unapply(String.prototype.match),stringReplace=unapply(String.prototype.replace),stringIndexOf=unapply(String.prototype.indexOf),stringTrim=unapply(String.prototype.trim),objectHasOwnProperty=unapply(Object.prototype.hasOwnProperty),regExpTest=unapply(RegExp.prototype.test),typeErrorCreate=unconstruct(TypeError);function unapply(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return apply$1(t,e,o)}}function unconstruct(t){return function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return construct(t,n)}}function addToSet(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:stringToLowerCase;setPrototypeOf&&setPrototypeOf(t,null);let o=e.length;for(;o--;){let l=e[o];if(typeof l=="string"){const d=n(l);d!==l&&(isFrozen(e)||(e[o]=d),l=d)}t[l]=!0}return t}function cleanArray(t){for(let e=0;e<t.length;e++)objectHasOwnProperty(t,e)||(t[e]=null);return t}function clone(t){const e=create(null);for(const[n,o]of entries(t))objectHasOwnProperty(t,n)&&(Array.isArray(o)?e[n]=cleanArray(o):o&&typeof o=="object"&&o.constructor===Object?e[n]=clone(o):e[n]=o);return e}function lookupGetter(t,e){for(;t!==null;){const o=getOwnPropertyDescriptor(t,e);if(o){if(o.get)return unapply(o.get);if(typeof o.value=="function")return unapply(o.value)}t=getPrototypeOf(t)}function n(){return null}return n}const html$1=freeze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),svg$1=freeze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),svgFilters=freeze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),svgDisallowed=freeze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mathMl$1=freeze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),mathMlDisallowed=freeze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),text$1=freeze(["#text"]),html=freeze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),svg=freeze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mathMl=freeze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),xml=freeze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),MUSTACHE_EXPR=seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ERB_EXPR=seal(/<%[\w\W]*|[\w\W]*%>/gm),TMPLIT_EXPR=seal(/\$\{[\w\W]*/gm),DATA_ATTR=seal(/^data-[\-\w.\u00B7-\uFFFF]+$/),ARIA_ATTR=seal(/^aria-[\-\w]+$/),IS_ALLOWED_URI=seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IS_SCRIPT_OR_DATA=seal(/^(?:\w+script|data):/i),ATTR_WHITESPACE=seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),DOCTYPE_NAME=seal(/^html$/i),CUSTOM_ELEMENT=seal(/^[a-z][.\w]*(-[.\w]+)+$/i);var EXPRESSIONS=Object.freeze({__proto__:null,ARIA_ATTR,ATTR_WHITESPACE,CUSTOM_ELEMENT,DATA_ATTR,DOCTYPE_NAME,ERB_EXPR,IS_ALLOWED_URI,IS_SCRIPT_OR_DATA,MUSTACHE_EXPR,TMPLIT_EXPR});const NODE_TYPE={element:1,text:3,progressingInstruction:7,comment:8,document:9},getGlobal=function t(){return typeof window>"u"?null:window},_createTrustedTypesPolicy=function t(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(o=n.getAttribute(l));const d="dompurify"+(o?"#"+o:"");try{return e.createPolicy(d,{createHTML(f){return f},createScriptURL(f){return f}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},_createHooksMap=function t(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function createDOMPurify(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:getGlobal();const e=Yt=>createDOMPurify(Yt);if(e.version="3.3.0",e.removed=[],!t||!t.document||t.document.nodeType!==NODE_TYPE.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const o=n,l=o.currentScript,{DocumentFragment:d,HTMLTemplateElement:f,Node:g,Element:b,NodeFilter:_,NamedNodeMap:S=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:R,DOMParser:C,trustedTypes:E}=t,A=b.prototype,M=lookupGetter(A,"cloneNode"),I=lookupGetter(A,"remove"),j=lookupGetter(A,"nextSibling"),F=lookupGetter(A,"childNodes"),z=lookupGetter(A,"parentNode");if(typeof f=="function"){const Yt=n.createElement("template");Yt.content&&Yt.content.ownerDocument&&(n=Yt.content.ownerDocument)}let Q,O="";const{implementation:V,createNodeIterator:te,createDocumentFragment:ne,getElementsByTagName:ae}=n,{importNode:$e}=o;let ge=_createHooksMap();e.isSupported=typeof entries=="function"&&typeof z=="function"&&V&&V.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:se,ERB_EXPR:je,TMPLIT_EXPR:Ae,DATA_ATTR:Ne,ARIA_ATTR:Ve,IS_SCRIPT_OR_DATA:Fe,ATTR_WHITESPACE:Oe,CUSTOM_ELEMENT:Be}=EXPRESSIONS;let{IS_ALLOWED_URI:Ue}=EXPRESSIONS,ze=null;const He=addToSet({},[...html$1,...svg$1,...svgFilters,...mathMl$1,...text$1]);let Qe=null;const et=addToSet({},[...html,...svg,...mathMl,...xml]);let Je=Object.seal(create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ze=null,Ke=null;const at=Object.seal(create(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let nt=!0,st=!0,lt=!1,Ge=!0,Ct=!1,tt=!0,yt=!1,ct=!1,Rt=!1,Mt=!1,It=!1,We=!1,Ye=!0,rt=!1;const ut="user-content-";let pt=!0,ft=!1,mt={},Ut=null;const Wt=addToSet({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let sn=null;const pn=addToSet({},["audio","video","img","source","image","track"]);let qt=null;const Tn=addToSet({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vn="http://www.w3.org/1998/Math/MathML",Sn="http://www.w3.org/2000/svg",yn="http://www.w3.org/1999/xhtml";let Rn=yn,jn=!1,Nn=null;const Qt=addToSet({},[vn,Sn,yn],stringToString);let en=addToSet({},["mi","mo","mn","ms","mtext"]),Kt=addToSet({},["annotation-xml"]);const Jt=addToSet({},["title","style","font","a","script"]);let dn=null;const Vt=["application/xhtml+xml","text/html"],Gn="text/html";let hn=null,$n=null;const On=n.createElement("form"),Pn=function(it){return it instanceof RegExp||it instanceof Function},Xn=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!($n&&$n===it)){if((!it||typeof it!="object")&&(it={}),it=clone(it),dn=Vt.indexOf(it.PARSER_MEDIA_TYPE)===-1?Gn:it.PARSER_MEDIA_TYPE,hn=dn==="application/xhtml+xml"?stringToString:stringToLowerCase,ze=objectHasOwnProperty(it,"ALLOWED_TAGS")?addToSet({},it.ALLOWED_TAGS,hn):He,Qe=objectHasOwnProperty(it,"ALLOWED_ATTR")?addToSet({},it.ALLOWED_ATTR,hn):et,Nn=objectHasOwnProperty(it,"ALLOWED_NAMESPACES")?addToSet({},it.ALLOWED_NAMESPACES,stringToString):Qt,qt=objectHasOwnProperty(it,"ADD_URI_SAFE_ATTR")?addToSet(clone(Tn),it.ADD_URI_SAFE_ATTR,hn):Tn,sn=objectHasOwnProperty(it,"ADD_DATA_URI_TAGS")?addToSet(clone(pn),it.ADD_DATA_URI_TAGS,hn):pn,Ut=objectHasOwnProperty(it,"FORBID_CONTENTS")?addToSet({},it.FORBID_CONTENTS,hn):Wt,Ze=objectHasOwnProperty(it,"FORBID_TAGS")?addToSet({},it.FORBID_TAGS,hn):clone({}),Ke=objectHasOwnProperty(it,"FORBID_ATTR")?addToSet({},it.FORBID_ATTR,hn):clone({}),mt=objectHasOwnProperty(it,"USE_PROFILES")?it.USE_PROFILES:!1,nt=it.ALLOW_ARIA_ATTR!==!1,st=it.ALLOW_DATA_ATTR!==!1,lt=it.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=it.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ct=it.SAFE_FOR_TEMPLATES||!1,tt=it.SAFE_FOR_XML!==!1,yt=it.WHOLE_DOCUMENT||!1,Mt=it.RETURN_DOM||!1,It=it.RETURN_DOM_FRAGMENT||!1,We=it.RETURN_TRUSTED_TYPE||!1,Rt=it.FORCE_BODY||!1,Ye=it.SANITIZE_DOM!==!1,rt=it.SANITIZE_NAMED_PROPS||!1,pt=it.KEEP_CONTENT!==!1,ft=it.IN_PLACE||!1,Ue=it.ALLOWED_URI_REGEXP||IS_ALLOWED_URI,Rn=it.NAMESPACE||yn,en=it.MATHML_TEXT_INTEGRATION_POINTS||en,Kt=it.HTML_INTEGRATION_POINTS||Kt,Je=it.CUSTOM_ELEMENT_HANDLING||{},it.CUSTOM_ELEMENT_HANDLING&&Pn(it.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Je.tagNameCheck=it.CUSTOM_ELEMENT_HANDLING.tagNameCheck),it.CUSTOM_ELEMENT_HANDLING&&Pn(it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Je.attributeNameCheck=it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),it.CUSTOM_ELEMENT_HANDLING&&typeof it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ct&&(st=!1),It&&(Mt=!0),mt&&(ze=addToSet({},text$1),Qe=[],mt.html===!0&&(addToSet(ze,html$1),addToSet(Qe,html)),mt.svg===!0&&(addToSet(ze,svg$1),addToSet(Qe,svg),addToSet(Qe,xml)),mt.svgFilters===!0&&(addToSet(ze,svgFilters),addToSet(Qe,svg),addToSet(Qe,xml)),mt.mathMl===!0&&(addToSet(ze,mathMl$1),addToSet(Qe,mathMl),addToSet(Qe,xml))),it.ADD_TAGS&&(typeof it.ADD_TAGS=="function"?at.tagCheck=it.ADD_TAGS:(ze===He&&(ze=clone(ze)),addToSet(ze,it.ADD_TAGS,hn))),it.ADD_ATTR&&(typeof it.ADD_ATTR=="function"?at.attributeCheck=it.ADD_ATTR:(Qe===et&&(Qe=clone(Qe)),addToSet(Qe,it.ADD_ATTR,hn))),it.ADD_URI_SAFE_ATTR&&addToSet(qt,it.ADD_URI_SAFE_ATTR,hn),it.FORBID_CONTENTS&&(Ut===Wt&&(Ut=clone(Ut)),addToSet(Ut,it.FORBID_CONTENTS,hn)),pt&&(ze["#text"]=!0),yt&&addToSet(ze,["html","head","body"]),ze.table&&(addToSet(ze,["tbody"]),delete Ze.tbody),it.TRUSTED_TYPES_POLICY){if(typeof it.TRUSTED_TYPES_POLICY.createHTML!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof it.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Q=it.TRUSTED_TYPES_POLICY,O=Q.createHTML("")}else Q===void 0&&(Q=_createTrustedTypesPolicy(E,l)),Q!==null&&typeof O=="string"&&(O=Q.createHTML(""));freeze&&freeze(it),$n=it}},Bn=addToSet({},[...svg$1,...svgFilters,...svgDisallowed]),Ln=addToSet({},[...mathMl$1,...mathMlDisallowed]),ar=function(it){let $t=z(it);(!$t||!$t.tagName)&&($t={namespaceURI:Rn,tagName:"template"});const zt=stringToLowerCase(it.tagName),fn=stringToLowerCase($t.tagName);return Nn[it.namespaceURI]?it.namespaceURI===Sn?$t.namespaceURI===yn?zt==="svg":$t.namespaceURI===vn?zt==="svg"&&(fn==="annotation-xml"||en[fn]):!!Bn[zt]:it.namespaceURI===vn?$t.namespaceURI===yn?zt==="math":$t.namespaceURI===Sn?zt==="math"&&Kt[fn]:!!Ln[zt]:it.namespaceURI===yn?$t.namespaceURI===Sn&&!Kt[fn]||$t.namespaceURI===vn&&!en[fn]?!1:!Ln[zt]&&(Jt[zt]||!Bn[zt]):!!(dn==="application/xhtml+xml"&&Nn[it.namespaceURI]):!1},Cn=function(it){arrayPush(e.removed,{element:it});try{z(it).removeChild(it)}catch{I(it)}},Dn=function(it,$t){try{arrayPush(e.removed,{attribute:$t.getAttributeNode(it),from:$t})}catch{arrayPush(e.removed,{attribute:null,from:$t})}if($t.removeAttribute(it),it==="is")if(Mt||It)try{Cn($t)}catch{}else try{$t.setAttribute(it,"")}catch{}},Qn=function(it){let $t=null,zt=null;if(Rt)it="<remove></remove>"+it;else{const mn=stringMatch(it,/^[\r\n\t ]+/);zt=mn&&mn[0]}dn==="application/xhtml+xml"&&Rn===yn&&(it='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+it+"</body></html>");const fn=Q?Q.createHTML(it):it;if(Rn===yn)try{$t=new C().parseFromString(fn,dn)}catch{}if(!$t||!$t.documentElement){$t=V.createDocument(Rn,"template",null);try{$t.documentElement.innerHTML=jn?O:fn}catch{}}const xn=$t.body||$t.documentElement;return it&&zt&&xn.insertBefore(n.createTextNode(zt),xn.childNodes[0]||null),Rn===yn?ae.call($t,yt?"html":"body")[0]:yt?$t.documentElement:xn},Zn=function(it){return te.call(it.ownerDocument||it,it,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},zn=function(it){return it instanceof R&&(typeof it.nodeName!="string"||typeof it.textContent!="string"||typeof it.removeChild!="function"||!(it.attributes instanceof S)||typeof it.removeAttribute!="function"||typeof it.setAttribute!="function"||typeof it.namespaceURI!="string"||typeof it.insertBefore!="function"||typeof it.hasChildNodes!="function")},sr=function(it){return typeof g=="function"&&it instanceof g};function kn(Yt,it,$t){arrayForEach(Yt,zt=>{zt.call(e,it,$t,$n)})}const or=function(it){let $t=null;if(kn(ge.beforeSanitizeElements,it,null),zn(it))return Cn(it),!0;const zt=hn(it.nodeName);if(kn(ge.uponSanitizeElement,it,{tagName:zt,allowedTags:ze}),tt&&it.hasChildNodes()&&!sr(it.firstElementChild)&®ExpTest(/<[/\w!]/g,it.innerHTML)&®ExpTest(/<[/\w!]/g,it.textContent)||it.nodeType===NODE_TYPE.progressingInstruction||tt&&it.nodeType===NODE_TYPE.comment&®ExpTest(/<[/\w]/g,it.data))return Cn(it),!0;if(!(at.tagCheck instanceof Function&&at.tagCheck(zt))&&(!ze[zt]||Ze[zt])){if(!Ze[zt]&&er(zt)&&(Je.tagNameCheck instanceof RegExp&®ExpTest(Je.tagNameCheck,zt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(zt)))return!1;if(pt&&!Ut[zt]){const fn=z(it)||it.parentNode,xn=F(it)||it.childNodes;if(xn&&fn){const mn=xn.length;for(let _n=mn-1;_n>=0;--_n){const An=M(xn[_n],!0);An.__removalCount=(it.__removalCount||0)+1,fn.insertBefore(An,j(it))}}}return Cn(it),!0}return it instanceof b&&!ar(it)||(zt==="noscript"||zt==="noembed"||zt==="noframes")&®ExpTest(/<\/no(script|embed|frames)/i,it.innerHTML)?(Cn(it),!0):(Ct&&it.nodeType===NODE_TYPE.text&&($t=it.textContent,arrayForEach([se,je,Ae],fn=>{$t=stringReplace($t,fn," ")}),it.textContent!==$t&&(arrayPush(e.removed,{element:it.cloneNode()}),it.textContent=$t)),kn(ge.afterSanitizeElements,it,null),!1)},lr=function(it,$t,zt){if(Ye&&($t==="id"||$t==="name")&&(zt in n||zt in On))return!1;if(!(st&&!Ke[$t]&®ExpTest(Ne,$t))){if(!(nt&®ExpTest(Ve,$t))){if(!(at.attributeCheck instanceof Function&&at.attributeCheck($t,it))){if(!Qe[$t]||Ke[$t]){if(!(er(it)&&(Je.tagNameCheck instanceof RegExp&®ExpTest(Je.tagNameCheck,it)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(it))&&(Je.attributeNameCheck instanceof RegExp&®ExpTest(Je.attributeNameCheck,$t)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck($t,it))||$t==="is"&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&®ExpTest(Je.tagNameCheck,zt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(zt))))return!1}else if(!qt[$t]){if(!regExpTest(Ue,stringReplace(zt,Oe,""))){if(!(($t==="src"||$t==="xlink:href"||$t==="href")&&it!=="script"&&stringIndexOf(zt,"data:")===0&&sn[it])){if(!(lt&&!regExpTest(Fe,stringReplace(zt,Oe,"")))){if(zt)return!1}}}}}}}return!0},er=function(it){return it!=="annotation-xml"&&stringMatch(it,Be)},tr=function(it){kn(ge.beforeSanitizeAttributes,it,null);const{attributes:$t}=it;if(!$t||zn(it))return;const zt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Qe,forceKeepAttr:void 0};let fn=$t.length;for(;fn--;){const xn=$t[fn],{name:mn,namespaceURI:_n,value:An}=xn,Fn=hn(mn),Ht=An;let gn=mn==="value"?Ht:stringTrim(Ht);if(zt.attrName=Fn,zt.attrValue=gn,zt.keepAttr=!0,zt.forceKeepAttr=void 0,kn(ge.uponSanitizeAttribute,it,zt),gn=zt.attrValue,rt&&(Fn==="id"||Fn==="name")&&(Dn(mn,it),gn=ut+gn),tt&®ExpTest(/((--!?|])>)|<\/(style|title|textarea)/i,gn)){Dn(mn,it);continue}if(Fn==="attributename"&&stringMatch(gn,"href")){Dn(mn,it);continue}if(zt.forceKeepAttr)continue;if(!zt.keepAttr){Dn(mn,it);continue}if(!Ge&®ExpTest(/\/>/i,gn)){Dn(mn,it);continue}Ct&&arrayForEach([se,je,Ae],ur=>{gn=stringReplace(gn,ur," ")});const wn=hn(it.nodeName);if(!lr(wn,Fn,gn)){Dn(mn,it);continue}if(Q&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!_n)switch(E.getAttributeType(wn,Fn)){case"TrustedHTML":{gn=Q.createHTML(gn);break}case"TrustedScriptURL":{gn=Q.createScriptURL(gn);break}}if(gn!==Ht)try{_n?it.setAttributeNS(_n,mn,gn):it.setAttribute(mn,gn),zn(it)?Cn(it):arrayPop(e.removed)}catch{Dn(mn,it)}}kn(ge.afterSanitizeAttributes,it,null)},cr=function Yt(it){let $t=null;const zt=Zn(it);for(kn(ge.beforeSanitizeShadowDOM,it,null);$t=zt.nextNode();)kn(ge.uponSanitizeShadowNode,$t,null),or($t),tr($t),$t.content instanceof d&&Yt($t.content);kn(ge.afterSanitizeShadowDOM,it,null)};return e.sanitize=function(Yt){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$t=null,zt=null,fn=null,xn=null;if(jn=!Yt,jn&&(Yt="<!-->"),typeof Yt!="string"&&!sr(Yt))if(typeof Yt.toString=="function"){if(Yt=Yt.toString(),typeof Yt!="string")throw typeErrorCreate("dirty is not a string, aborting")}else throw typeErrorCreate("toString is not a function");if(!e.isSupported)return Yt;if(ct||Xn(it),e.removed=[],typeof Yt=="string"&&(ft=!1),ft){if(Yt.nodeName){const An=hn(Yt.nodeName);if(!ze[An]||Ze[An])throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place")}}else if(Yt instanceof g)$t=Qn("<!---->"),zt=$t.ownerDocument.importNode(Yt,!0),zt.nodeType===NODE_TYPE.element&&zt.nodeName==="BODY"||zt.nodeName==="HTML"?$t=zt:$t.appendChild(zt);else{if(!Mt&&!Ct&&!yt&&Yt.indexOf("<")===-1)return Q&&We?Q.createHTML(Yt):Yt;if($t=Qn(Yt),!$t)return Mt?null:We?O:""}$t&&Rt&&Cn($t.firstChild);const mn=Zn(ft?Yt:$t);for(;fn=mn.nextNode();)or(fn),tr(fn),fn.content instanceof d&&cr(fn.content);if(ft)return Yt;if(Mt){if(It)for(xn=ne.call($t.ownerDocument);$t.firstChild;)xn.appendChild($t.firstChild);else xn=$t;return(Qe.shadowroot||Qe.shadowrootmode)&&(xn=$e.call(o,xn,!0)),xn}let _n=yt?$t.outerHTML:$t.innerHTML;return yt&&ze["!doctype"]&&$t.ownerDocument&&$t.ownerDocument.doctype&&$t.ownerDocument.doctype.name&®ExpTest(DOCTYPE_NAME,$t.ownerDocument.doctype.name)&&(_n="<!DOCTYPE "+$t.ownerDocument.doctype.name+`>
|
|
1138
|
-
`+_n),Ct&&arrayForEach([se,je,Ae],An=>{_n=stringReplace(_n,An," ")}),Q&&We?Q.createHTML(_n):_n},e.setConfig=function(){let Yt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xn(Yt),ct=!0},e.clearConfig=function(){$n=null,ct=!1},e.isValidAttribute=function(Yt,it,$t){$n||Xn({});const zt=hn(Yt),fn=hn(it);return lr(zt,fn,$t)},e.addHook=function(Yt,it){typeof it=="function"&&arrayPush(ge[Yt],it)},e.removeHook=function(Yt,it){if(it!==void 0){const $t=arrayLastIndexOf(ge[Yt],it);return $t===-1?void 0:arraySplice(ge[Yt],$t,1)[0]}return arrayPop(ge[Yt])},e.removeHooks=function(Yt){ge[Yt]=[]},e.removeAllHooks=function(){ge=_createHooksMap()},e}var purify=createDOMPurify();function markdownToSafeHTML(t){const e=marked(t,{async:!1});return purify.sanitize(e,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:t}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:t})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:t,appID:e,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of t){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[t.map(d=>{var g;const f=d.fromPartnerID===e;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),t.length===0&&!o&&jsxRuntime.jsx("div",{className:"text-center text-muted-foreground py-8",children:"No messages yet"}),t.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:t,...e},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",t),ref:n,...e}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:t,activeChatObj:e,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:t[0]===n?t[1]:t[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:e==null?void 0:e.name})]}),e!=null&&e.pending&&e.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx(ChatMessages,{messages:(e==null?void 0:e.messages)??[],appID:n,isAssistantChat:!1,botStatus:""}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(e==null?void 0:e.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:e!=null&&e.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:e==null?void 0:e.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:e!=null&&e.pending?"collapse":"ml-2 h-8 w-8",disabled:e==null?void 0:e.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:t,appID:e,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=t?[t.partner1,t.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${e}/Partner/${(d==null?void 0:d[0])===e?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((t==null?void 0:t.messages)??[]).length<1,onClick:()=>n(t.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),jsxRuntime.jsx("p",{className:"font-light",children:"Members of this conversation will show up here."}),jsxRuntime.jsx(LinkSection,{appID:e,activeChatObj:t})]})})}const LinkSection=({appID:t,activeChatObj:e})=>{const[n,o]=React.useState(!1),{data:l,isLoading:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID},{skip:!(e!=null&&e.conversationID)});console.log(l);const[f]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[g]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[d?jsxRuntime.jsx("p",{children:"Loading links..."}):(l==null?void 0:l.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,l==null?void 0:l.map(b=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:b.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:b.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>g({routeApplicationId:t,linkId:b.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},b.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:e===void 0,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:b=>{b.preventDefault();const _=document.getElementById("link-title").value,S=document.getElementById("link-url").value;f({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID,createLinkRequest:{Title:_,Url:S}}),o(!1)},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Add Link"})]})]})]})]})},UserSetupForm=t=>{const[e]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),e({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:t.appID,partnerId:"2"})}),e({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(t,e)=>t.unread>0&&e.unread===0?-1:e.unread>0&&t.unread===0?1:t.name.localeCompare(e.name);function ChatLayout({appID:t,inputRef:e,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:t}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[F]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[z,Q]=React.useState(!1);React.useEffect(()=>{l&&(se(ct=>{const Rt=l.map(Mt=>{var We;const It=ct.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((We=Mt.Participant)==null?void 0:We.PublicName)??"missing public name",unread:(It==null?void 0:It.unread)??0,pending:Mt.Status!=="Approved",messages:(It==null?void 0:It.messages)??[],conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return Rt.sort(sortChats),Rt}),g(!0),setTimeout(()=>{var ct;return(ct=Be.current)==null?void 0:ct.focus()},50))},[l,t]);const[O,V]=React.useState(void 0),[te,ne]=React.useState(""),[ae,$e]=React.useState(null),[ge,se]=React.useState([]),[je,Ae]=React.useState(null),Ne=React.useRef(null),Ve=React.useRef(null),[Fe,Oe]=React.useState([]),Be=e||Ve,Ue=React.useRef(null),{toast:ze}=useToast(),He=()=>ge.find(ct=>ct.partner1===(O==null?void 0:O[0])&&ct.partner2===(O==null?void 0:O[1]));function Qe(){const ct=He();ct&&I({routeApplicationId:t,conversationId:ct.conversationID})}const et=ct=>Oe(Rt=>[...Rt,ct]);React.useEffect(()=>{if(Fe.length==0)return;console.log(Fe.length,"unprocessedMessages detected");const ct=(Mt,It)=>It.partner1===Mt.toPartnerID&&It.partner2===Mt.fromPartnerID||It.partner2===Mt.toPartnerID&&It.partner1===Mt.fromPartnerID;let Rt=!1;Fe.forEach(Mt=>{if(!ge.some(It=>ct(Mt,It))){console.log("message received for unknown convo ID - need to refetch!"),Rt=!0;return}se(It=>It.map(We=>{if(!ct(Mt,We)||We.messages.some(ut=>ut.id===Mt.id))return We;let Ye=1;const rt=document.activeElement&&document.activeElement===Be.current;return(O==null?void 0:O[0])==We.partner1&&O[1]==We.partner2&&rt&&(rt&&(Ye=0,Qe()),setTimeout(()=>{var ut;return(ut=Ne.current)==null?void 0:ut.scrollIntoView({behavior:"smooth"})},50)),{...We,pending:!1,unread:We.unread+Ye,messages:[...We.messages,Mt]}}).sort(sortChats))}),console.log("need refetch:",Rt),Rt&&d(),Oe([])},[Fe,Oe,se,V,O]),React.useEffect(()=>{const ct=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":t}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return ct.on("ReceiveMessage",et),ct.start().catch(Rt=>console.error("Error connecting to SignalR hub:",Rt)),Ae(ct),()=>{ct&&ct.stop()}},[t]),React.useEffect(()=>{var Rt;!O||!He()||((Rt=Be.current)==null||Rt.focus(),setTimeout(()=>{var Mt;return(Mt=Ne.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[O]),React.useEffect(()=>{if(!O)return;const ct=He();ct&&ct.conversationID!==-1&&(async()=>{var Rt;try{const It=((Rt=(await j({routeApplicationId:t,conversationId:ct.conversationID})).data)==null?void 0:Rt.map(We=>({id:"history"+We.MessageId,fromPartnerID:We.SenderId,toPartnerID:We.SenderId==ct.partner1?ct.partner2:ct.partner1,senderName:We.SenderName??"missing name",timestamp:new Date(We.SentDate+"Z").getTime(),content:We.Content??"no content"})))??[];se(We=>We.map(Ye=>Ye.conversationID===ct.conversationID?{...Ye,messages:It}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[O,j,t]),React.useEffect(()=>{if(!O)return;const ct=He();if(!ct)return;const Rt=document.activeElement&&document.activeElement===Be.current;ct.unread>0&&Rt&&(Qe(),se(Mt=>Mt.map(It=>It.partner1===O[0]&&It.partner2===O[1]?{...It,unread:0}:It)))},[O,ge]);const{sendMessage:Je}=useChat(),Ze=React.useCallback(ct=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(ct,null,2)}`)},[Je]),Ke=React.useCallback(async()=>{if(O)try{Q(!0);const ct=await R({applicationId:t}),Rt=O[0]===t?O[1]:O[0],Mt=await F({routeApplicationId:t,partnerId:Rt,withSpecification:!0}),It=buildPartnershipAssistantPrompt(ct.data,Mt.data);It?Je(It):ze({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(ct){console.error("Error preparing partnership analysis:",ct),ze({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{Q(!1)}},[O,R,F,Je,ze,t]);React.useEffect(()=>{o(ge.some(ct=>ct.unread>0))},[ge,o]);const at=(ct,Rt)=>{Rt=Rt.replace(/\n/g,`
|
|
1138
|
+
`+_n),Ct&&arrayForEach([se,je,Ae],An=>{_n=stringReplace(_n,An," ")}),Q&&We?Q.createHTML(_n):_n},e.setConfig=function(){let Yt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xn(Yt),ct=!0},e.clearConfig=function(){$n=null,ct=!1},e.isValidAttribute=function(Yt,it,$t){$n||Xn({});const zt=hn(Yt),fn=hn(it);return lr(zt,fn,$t)},e.addHook=function(Yt,it){typeof it=="function"&&arrayPush(ge[Yt],it)},e.removeHook=function(Yt,it){if(it!==void 0){const $t=arrayLastIndexOf(ge[Yt],it);return $t===-1?void 0:arraySplice(ge[Yt],$t,1)[0]}return arrayPop(ge[Yt])},e.removeHooks=function(Yt){ge[Yt]=[]},e.removeAllHooks=function(){ge=_createHooksMap()},e}var purify=createDOMPurify();function markdownToSafeHTML(t){const e=marked(t,{async:!1});return purify.sanitize(e,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:t}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:t})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:t,appID:e,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of t){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[t.map(d=>{var g;const f=d.fromPartnerID===e;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),t.length===0&&!o&&jsxRuntime.jsxs("div",{className:"mt-1 text-xl",children:[jsxRuntime.jsx(Send,{className:"w-full h-32"}),jsxRuntime.jsx("p",{className:"text-center",children:"No messages yet... Say hello!"})]}),t.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:t,...e},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",t),ref:n,...e}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:t,activeChatObj:e,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:t[0]===n?t[1]:t[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:e==null?void 0:e.name})]}),e!=null&&e.pending&&e.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx("div",{className:(e==null?void 0:e.messages)===null?" opacity-0":"",children:jsxRuntime.jsx(ChatMessages,{messages:(e==null?void 0:e.messages)??[],appID:n,isAssistantChat:!1,botStatus:""})}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(e==null?void 0:e.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:e!=null&&e.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:e==null?void 0:e.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:e!=null&&e.pending?"collapse":"ml-2 h-8 w-8",disabled:e==null?void 0:e.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:t,appID:e,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=t?[t.partner1,t.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${e}/Partner/${(d==null?void 0:d[0])===e?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((t==null?void 0:t.messages)??[]).length<1,onClick:()=>n(t.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),jsxRuntime.jsx("p",{className:"font-light",children:"Members of this conversation will show up here."}),jsxRuntime.jsx(LinkSection,{appID:e,activeChatObj:t})]})})}const LinkSection=({appID:t,activeChatObj:e})=>{const[n,o]=React.useState(!1),{data:l,isLoading:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID},{skip:!(e!=null&&e.conversationID)});console.log(l);const[f]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[g]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[d?jsxRuntime.jsx("p",{children:"Loading links..."}):(l==null?void 0:l.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,l==null?void 0:l.map(b=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:b.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:b.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>g({routeApplicationId:t,linkId:b.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},b.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:e===void 0,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:b=>{b.preventDefault();const _=document.getElementById("link-title").value,S=document.getElementById("link-url").value;f({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID,createLinkRequest:{Title:_,Url:S}}),o(!1)},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Add Link"})]})]})]})]})},UserSetupForm=t=>{const[e]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),e({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:t.appID,partnerId:"2"})}),e({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(t,e)=>t.unread>0&&e.unread===0?-1:e.unread>0&&t.unread===0?1:t.name.localeCompare(e.name);function ChatLayout({appID:t,inputRef:e,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:t}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[F]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[z,Q]=React.useState(!1);React.useEffect(()=>{l&&(se(ct=>{const Rt=l.map(Mt=>{var We;const It=ct.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((We=Mt.Participant)==null?void 0:We.PublicName)??"missing public name",unread:(It==null?void 0:It.unread)??0,pending:Mt.Status!=="Approved",messages:(It==null?void 0:It.messages)??null,conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return Rt.sort(sortChats),Rt}),g(!0),setTimeout(()=>{var ct;return(ct=Be.current)==null?void 0:ct.focus()},50))},[l,t]);const[O,V]=React.useState(void 0),[te,ne]=React.useState(""),[ae,$e]=React.useState(null),[ge,se]=React.useState([]),[je,Ae]=React.useState(null),Ne=React.useRef(null),Ve=React.useRef(null),[Fe,Oe]=React.useState([]),Be=e||Ve,Ue=React.useRef(null),{toast:ze}=useToast(),He=()=>ge.find(ct=>ct.partner1===(O==null?void 0:O[0])&&ct.partner2===(O==null?void 0:O[1]));function Qe(){const ct=He();ct&&I({routeApplicationId:t,conversationId:ct.conversationID})}const et=ct=>Oe(Rt=>[...Rt,ct]);React.useEffect(()=>{if(Fe.length==0)return;console.log(Fe.length,"unprocessedMessages detected");const ct=(Mt,It)=>It.partner1===Mt.toPartnerID&&It.partner2===Mt.fromPartnerID||It.partner2===Mt.toPartnerID&&It.partner1===Mt.fromPartnerID;let Rt=!1;Fe.forEach(Mt=>{if(!ge.some(It=>ct(Mt,It))){console.log("message received for unknown convo ID - need to refetch!"),Rt=!0;return}se(It=>It.map(We=>{if(!ct(Mt,We))return We;const Ye=We.messages??[];if(Ye.some(pt=>pt.id===Mt.id))return We;let rt=1;const ut=document.activeElement&&document.activeElement===Be.current;return(O==null?void 0:O[0])==We.partner1&&O[1]==We.partner2&&ut&&(ut&&(rt=0,Qe()),setTimeout(()=>{var pt;return(pt=Ne.current)==null?void 0:pt.scrollIntoView({behavior:"smooth"})},50)),{...We,pending:!1,unread:We.unread+rt,messages:[...Ye,Mt]}}).sort(sortChats))}),console.log("need refetch:",Rt),Rt&&d(),Oe([])},[Fe,Oe,se,V,O]),React.useEffect(()=>{const ct=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":t}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return ct.on("ReceiveMessage",et),ct.start().catch(Rt=>console.error("Error connecting to SignalR hub:",Rt)),Ae(ct),()=>{ct&&ct.stop()}},[t]),React.useEffect(()=>{var Rt;!O||!He()||((Rt=Be.current)==null||Rt.focus(),setTimeout(()=>{var Mt;return(Mt=Ne.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[O]),React.useEffect(()=>{if(!O)return;const ct=He();ct&&ct.conversationID!==-1&&(async()=>{var Rt;try{const It=((Rt=(await j({routeApplicationId:t,conversationId:ct.conversationID})).data)==null?void 0:Rt.map(We=>({id:"history"+We.MessageId,fromPartnerID:We.SenderId,toPartnerID:We.SenderId==ct.partner1?ct.partner2:ct.partner1,senderName:We.SenderName??"missing name",timestamp:new Date(We.SentDate+"Z").getTime(),content:We.Content??"no content"})))??[];se(We=>We.map(Ye=>Ye.conversationID===ct.conversationID?{...Ye,messages:It}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[O,j,t]),React.useEffect(()=>{if(!O)return;const ct=He();if(!ct)return;const Rt=document.activeElement&&document.activeElement===Be.current;ct.unread>0&&Rt&&(Qe(),se(Mt=>Mt.map(It=>It.partner1===O[0]&&It.partner2===O[1]?{...It,unread:0}:It)))},[O,ge]);const{sendMessage:Je}=useChat(),Ze=React.useCallback(ct=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(ct,null,2)}`)},[Je]),Ke=React.useCallback(async()=>{if(O)try{Q(!0);const ct=await R({applicationId:t}),Rt=O[0]===t?O[1]:O[0],Mt=await F({routeApplicationId:t,partnerId:Rt,withSpecification:!0}),It=buildPartnershipAssistantPrompt(ct.data,Mt.data);It?Je(It):ze({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(ct){console.error("Error preparing partnership analysis:",ct),ze({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{Q(!1)}},[O,R,F,Je,ze,t]);React.useEffect(()=>{o(ge.some(ct=>ct.unread>0))},[ge,o]);const at=(ct,Rt)=>{Rt=Rt.replace(/\n/g,`
|
|
1139
1139
|
`),console.log("doSend",Rt),console.log("target",ct);const Mt={id:crypto.randomUUID(),senderName:(lt==null?void 0:lt.Name)??(lt==null?void 0:lt.EmailAddress)??"User",fromPartnerID:t,toPartnerID:ct.partner1===t?ct.partner2:ct.partner1,content:Rt,timestamp:Date.now()};et(Mt),je.invoke("NewMessage",Mt).catch(It=>console.error("Error sending message:",It)),ne(""),Ue.current&&(Ue.current.value="")},nt=()=>{let ct=te.trim();!yt||!ct||!O||!je||(yt.unread>0&&(Qe(),se(Rt=>Rt.map(Mt=>Mt.partner1===O[0]&&Mt.partner2===O[1]?{...Mt,unread:0}:Mt))),at(yt,ct))},st=(ct,Rt)=>$e([ct,Rt]);React.useEffect(()=>{if(ae===null)return;const ct=ge.find(Mt=>Mt.conversationID===ae[0]);if(!ct||(V([ct.partner1,ct.partner2]),!je))return;const Rt=ae[1];$e(null),Rt&&at(ct,Rt)},[ae,ge,V,je]);const{data:lt,isLoading:Ge}=useGetV4UserQuery();if(!f||Ge)return jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"});if(!(lt!=null&<.Name))return jsxRuntime.jsx(UserSetupForm,{appID:(lt==null?void 0:lt.ApplicationId)??""});const Ct=async()=>{var ct,Rt,Mt,It,We;S.current&&(S.current.disabled=!0),A(!0);try{const Ye=await R({applicationId:t}),rt=((ct=Ye.data)==null?void 0:ct.About)??"a new business venture",ut=[];(Rt=Ye.data)!=null&&Rt.IsManufacturer&&ut.push("Manufacturer"),(Mt=Ye.data)!=null&&Mt.IsReseller&&ut.push("Reseller"),(It=Ye.data)!=null&&It.IsSalesAgency&&ut.push("Sales Agency");const ft=`
|
|
1140
1140
|
Your task is to draft a ready-to-send opening message from a user to the Randmar team.
|
|
1141
1141
|
|
|
@@ -1173,7 +1173,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
1173
1173
|
|
|
1174
1174
|
Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:t,value:e,...n},o)=>jsxRuntime.jsx(Root$2,{ref:o,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})}));Progress.displayName=Root$2.displayName;function ManufacturerInventoryFinanceCard({manufacturer:t,isLoading:e}){const{data:n,isLoading:o,isFetching:l}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(t==null?void 0:t.ManufacturerId)??""},{skip:!(t!=null&&t.ManufacturerId)}),d=(t==null?void 0:t.DefaultMaxInventoryValue)??0,f=(n||[]).reduce((_,S)=>_+(S.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100);return e||o||l?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[d!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(g)})]})]}),d!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[b,"%"]}),b>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:b,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:t,isLoading:e}){const n=(t==null?void 0:t.CreditLimit)??0,o=(t==null?void 0:t.OutstandingBalance)??0,l=n-o,d=Math.round(o/n*100);return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${l>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(l)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function SalesChartCard({statistics:t,loading:e=!1,mode:n="month",chartHeight:o=300,className:l,size:d="default"}){return e?jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:o},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),d==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:t,mode:n,chartHeight:o,size:d})})]})}function ManufacturerOverviewPage({applicationId:t,readonly:e,withReports:n,manufacturer:o,userEmail:l}){const{data:d,isLoading:f,isError:g}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:t,withSpecification:!0},{skip:!!o}),[b,_]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),S=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,M)=>{_(I=>{var j;return((j=I[A])==null?void 0:j.hasUnsavedChanges)!==M.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,M.hasUnsavedChanges),{...I,[A]:M}):I})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(S),E=o??d;return jsxRuntime.jsxs("div",{className:"@container",children:[g?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:E==null?void 0:E.FiscalYearMonthStart,salesData:E==null?void 0:E.SalesData,isLoading:f}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(E==null?void 0:E.SalesStatistics)??[],loading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:E??{},onSave:()=>{},loading:f,readonly:e}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("publicInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:E,readonly:e,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("billingInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("qualifications",{hasUnsavedChanges:A})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}function ManufacturerCategories({categories:t,activeCategory:e,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsxs("div",{className:"flex gap-2 items-baseline",children:[jsxRuntime.jsx("p",{children:"Category filter:"}),t.map(o=>jsxRuntime.jsxs(Button$1,{onClick:()=>n(o.CategoryCode??""),variant:e===o.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[o.CategoryName??"Undefined",o.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${e!==o.CategoryCode?"text-red-500":""}`})]},o.CategoryCode))]})})})}function CategoryStats(t){const{data:e,isLoading:n,isFetching:o}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t.appID,manufacturerId:t.manufID,categoryCode:t.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:t.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(e==null?void 0:e.SalesStatistics)??[],loading:n||o,chartHeight:300})]})})})}function ManufacturerCategoriesStats(t){return(t.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:t.appID,manufID:t.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${t.manufID}-${n.CategoryCode}`))}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:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:t="N/A",niche:e="N/A",productsNumber:n=0,autoreorder:o=!1,starred:l=!1,isLoading:d=!1,children:f}){return d?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[f,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),l?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:o?"default":"secondary",className:cn("text-xs",o?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:o?"Enabled":"Disabled"})]})]})]})]})})}function createSlot$1(t){const e=createSlotClone$1(t),n=React__namespace.forwardRef((o,l)=>{const{children:d,...f}=o,g=React__namespace.Children.toArray(d),b=g.find(isSlottable$1);if(b){const _=b.props.children,S=g.map(R=>R===b?React__namespace.Children.count(_)>1?React__namespace.Children.only(null):React__namespace.isValidElement(_)?_.props.children:null:R);return jsxRuntime.jsx(e,{...f,ref:l,children:React__namespace.isValidElement(_)?React__namespace.cloneElement(_,void 0,S):null})}return jsxRuntime.jsx(e,{...f,ref:l,children:d})});return n.displayName=`${t}.Slot`,n}function createSlotClone$1(t){const e=React__namespace.forwardRef((n,o)=>{const{children:l,...d}=n;if(React__namespace.isValidElement(l)){const f=getElementRef$1(l),g=mergeProps$1(d,l.props);return l.type!==React__namespace.Fragment&&(g.ref=o?composeRefs(o,f):f),React__namespace.cloneElement(l,g)}return React__namespace.Children.count(l)>1?React__namespace.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var SLOTTABLE_IDENTIFIER$2=Symbol("radix.slottable");function isSlottable$1(t){return React__namespace.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===SLOTTABLE_IDENTIFIER$2}function mergeProps$1(t,e){const n={...e};for(const o in e){const l=t[o],d=e[o];/^on[A-Z]/.test(o)?l&&d?n[o]=(...g)=>{const b=d(...g);return l(...g),b}:l&&(n[o]=l):o==="style"?n[o]={...l,...d}:o==="className"&&(n[o]=[l,d].filter(Boolean).join(" "))}return{...t,...n}}function getElementRef$1(t){var o,l;let e=(o=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(l=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:l.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection$1,useCollection$1,createCollectionScope$1]=createCollection(SELECT_NAME),[createSelectContext]=createContextScope$2(SELECT_NAME,[createCollectionScope$1,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$2=t=>{const{__scopeSelect:e,children:n,open:o,defaultOpen:l,onOpenChange:d,value:f,defaultValue:g,onValueChange:b,dir:_,name:S,autoComplete:R,disabled:C,required:E,form:A}=t,M=usePopperScope$1(e),[I,j]=React__namespace.useState(null),[F,z]=React__namespace.useState(null),[Q,O]=React__namespace.useState(!1),V=useDirection(_),[te,ne]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:SELECT_NAME}),[ae,$e]=useControllableState({prop:f,defaultProp:g,onChange:b,caller:SELECT_NAME}),ge=React__namespace.useRef(null),se=I?A||!!I.closest("form"):!0,[je,Ae]=React__namespace.useState(new Set),Ne=Array.from(je).map(Ve=>Ve.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...M,children:jsxRuntime.jsxs(SelectProvider,{required:E,scope:e,trigger:I,onTriggerChange:j,valueNode:F,onValueNodeChange:z,valueNodeHasChildren:Q,onValueNodeHasChildrenChange:O,contentId:useId(),value:ae,onValueChange:$e,open:te,onOpenChange:ne,dir:V,triggerPointerDownPosRef:ge,disabled:C,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:e,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:t.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Ve=>{Ae(Fe=>new Set(Fe).add(Ve))},[]),onNativeOptionRemove:React__namespace.useCallback(Ve=>{Ae(Fe=>{const Oe=new Set(Fe);return Oe.delete(Ve),Oe})},[]),children:n})}),se?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:E,tabIndex:-1,name:S,autoComplete:R,value:ae,onChange:Ve=>$e(Ve.target.value),disabled:C,form:A,children:[ae===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(je)]},Ne):null]})})};Select$2.displayName=SELECT_NAME;var TRIGGER_NAME$5="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:o=!1,...l}=t,d=usePopperScope$1(n),f=useSelectContext(TRIGGER_NAME$5,n),g=f.disabled||o,b=useComposedRefs(e,f.onTriggerChange),_=useCollection$1(n),S=React__namespace.useRef("touch"),[R,C,E]=useTypeaheadSearch(M=>{const I=_().filter(z=>!z.disabled),j=I.find(z=>z.value===f.value),F=findNextItem(I,M,j);F!==void 0&&f.onValueChange(F.value)}),A=M=>{g||(f.onOpenChange(!0),E()),M&&(f.triggerPointerDownPosRef.current={x:Math.round(M.pageX),y:Math.round(M.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":shouldShowPlaceholder(f.value)?"":void 0,...l,ref:b,onClick:composeEventHandlers(l.onClick,M=>{M.currentTarget.focus(),S.current!=="mouse"&&A(M)}),onPointerDown:composeEventHandlers(l.onPointerDown,M=>{S.current=M.pointerType;const I=M.target;I.hasPointerCapture(M.pointerId)&&I.releasePointerCapture(M.pointerId),M.button===0&&M.ctrlKey===!1&&M.pointerType==="mouse"&&(A(M),M.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,M=>{const I=R.current!=="";!(M.ctrlKey||M.altKey||M.metaKey)&&M.key.length===1&&C(M.key),!(I&&M.key===" ")&&OPEN_KEYS.includes(M.key)&&(A(),M.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$5;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,className:o,style:l,children:d,placeholder:f="",...g}=t,b=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:_}=b,S=d!==void 0,R=useComposedRefs(e,b.onValueNodeChange);return useLayoutEffect2(()=>{_(S)},[_,S]),jsxRuntime.jsx(Primitive$4.span,{...g,ref:R,style:{pointerEvents:"none"},children:shouldShowPlaceholder(b.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f}):d})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,children:o,...l}=t;return jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...l,ref:e,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=t=>jsxRuntime.jsx(Portal$5,{asChild:!0,...t});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$4="SelectContent",SelectContent$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContext(CONTENT_NAME$4,t.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const d=o;return d?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:t.__scopeSelect,children:jsxRuntime.jsx(Collection$1.Slot,{scope:t.__scopeSelect,children:jsxRuntime.jsx("div",{children:t.children})})}),d):null}return jsxRuntime.jsx(SelectContentImpl,{...t,ref:e})});SelectContent$1.displayName=CONTENT_NAME$4;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$4),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot$1("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:d,onPointerDownOutside:f,side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I,...j}=t,F=useSelectContext(CONTENT_NAME$4,n),[z,Q]=React__namespace.useState(null),[O,V]=React__namespace.useState(null),te=useComposedRefs(e,Ke=>Q(Ke)),[ne,ae]=React__namespace.useState(null),[$e,ge]=React__namespace.useState(null),se=useCollection$1(n),[je,Ae]=React__namespace.useState(!1),Ne=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(z)return hideOthers(z)},[z]),useFocusGuards();const Ve=React__namespace.useCallback(Ke=>{const[at,...nt]=se().map(Ge=>Ge.ref.current),[st]=nt.slice(-1),lt=document.activeElement;for(const Ge of Ke)if(Ge===lt||(Ge==null||Ge.scrollIntoView({block:"nearest"}),Ge===at&&O&&(O.scrollTop=0),Ge===st&&O&&(O.scrollTop=O.scrollHeight),Ge==null||Ge.focus(),document.activeElement!==lt))return},[se,O]),Fe=React__namespace.useCallback(()=>Ve([ne,z]),[Ve,ne,z]);React__namespace.useEffect(()=>{je&&Fe()},[je,Fe]);const{onOpenChange:Oe,triggerPointerDownPosRef:Be}=F;React__namespace.useEffect(()=>{if(z){let Ke={x:0,y:0};const at=st=>{var lt,Ge;Ke={x:Math.abs(Math.round(st.pageX)-(((lt=Be.current)==null?void 0:lt.x)??0)),y:Math.abs(Math.round(st.pageY)-(((Ge=Be.current)==null?void 0:Ge.y)??0))}},nt=st=>{Ke.x<=10&&Ke.y<=10?st.preventDefault():z.contains(st.target)||Oe(!1),document.removeEventListener("pointermove",at),Be.current=null};return Be.current!==null&&(document.addEventListener("pointermove",at),document.addEventListener("pointerup",nt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",at),document.removeEventListener("pointerup",nt,{capture:!0})}}},[z,Oe,Be]),React__namespace.useEffect(()=>{const Ke=()=>Oe(!1);return window.addEventListener("blur",Ke),window.addEventListener("resize",Ke),()=>{window.removeEventListener("blur",Ke),window.removeEventListener("resize",Ke)}},[Oe]);const[Ue,ze]=useTypeaheadSearch(Ke=>{const at=se().filter(lt=>!lt.disabled),nt=at.find(lt=>lt.ref.current===document.activeElement),st=findNextItem(at,Ke,nt);st&&setTimeout(()=>st.ref.current.focus())}),He=React__namespace.useCallback((Ke,at,nt)=>{const st=!Ne.current&&!nt;(F.value!==void 0&&F.value===at||st)&&(ae(Ke),st&&(Ne.current=!0))},[F.value]),Qe=React__namespace.useCallback(()=>z==null?void 0:z.focus(),[z]),et=React__namespace.useCallback((Ke,at,nt)=>{const st=!Ne.current&&!nt;(F.value!==void 0&&F.value===at||st)&&ge(Ke)},[F.value]),Je=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,Ze=Je===SelectPopperPosition?{side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:z,viewport:O,onViewportChange:V,itemRefCallback:He,selectedItem:ne,onItemLeave:Qe,itemTextRefCallback:et,focusSelectedItem:Fe,selectedItemText:$e,position:o,isPositioned:je,searchRef:Ue,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:F.open,onMountAutoFocus:Ke=>{Ke.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,Ke=>{var at;(at=F.trigger)==null||at.focus({preventScroll:!0}),Ke.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:Ke=>Ke.preventDefault(),onDismiss:()=>F.onOpenChange(!1),children:jsxRuntime.jsx(Je,{role:"listbox",id:F.contentId,"data-state":F.open?"open":"closed",dir:F.dir,onContextMenu:Ke=>Ke.preventDefault(),...j,...Ze,onPlaced:()=>Ae(!0),ref:te,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:composeEventHandlers(j.onKeyDown,Ke=>{const at=Ke.ctrlKey||Ke.altKey||Ke.metaKey;if(Ke.key==="Tab"&&Ke.preventDefault(),!at&&Ke.key.length===1&&ze(Ke.key),["ArrowUp","ArrowDown","Home","End"].includes(Ke.key)){let st=se().filter(lt=>!lt.disabled).map(lt=>lt.ref.current);if(["ArrowUp","End"].includes(Ke.key)&&(st=st.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ke.key)){const lt=Ke.target,Ge=st.indexOf(lt);st=st.slice(Ge+1)}setTimeout(()=>Ve(st)),Ke.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:o,...l}=t,d=useSelectContext(CONTENT_NAME$4,n),f=useSelectContentContext(CONTENT_NAME$4,n),[g,b]=React__namespace.useState(null),[_,S]=React__namespace.useState(null),R=useComposedRefs(e,te=>S(te)),C=useCollection$1(n),E=React__namespace.useRef(!1),A=React__namespace.useRef(!0),{viewport:M,selectedItem:I,selectedItemText:j,focusSelectedItem:F}=f,z=React__namespace.useCallback(()=>{if(d.trigger&&d.valueNode&&g&&_&&M&&I&&j){const te=d.trigger.getBoundingClientRect(),ne=_.getBoundingClientRect(),ae=d.valueNode.getBoundingClientRect(),$e=j.getBoundingClientRect();if(d.dir!=="rtl"){const lt=$e.left-ne.left,Ge=ae.left-lt,Ct=te.left-Ge,tt=te.width+Ct,yt=Math.max(tt,ne.width),ct=window.innerWidth-CONTENT_MARGIN,Rt=clamp(Ge,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,ct-yt)]);g.style.minWidth=tt+"px",g.style.left=Rt+"px"}else{const lt=ne.right-$e.right,Ge=window.innerWidth-ae.right-lt,Ct=window.innerWidth-te.right-Ge,tt=te.width+Ct,yt=Math.max(tt,ne.width),ct=window.innerWidth-CONTENT_MARGIN,Rt=clamp(Ge,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,ct-yt)]);g.style.minWidth=tt+"px",g.style.right=Rt+"px"}const ge=C(),se=window.innerHeight-CONTENT_MARGIN*2,je=M.scrollHeight,Ae=window.getComputedStyle(_),Ne=parseInt(Ae.borderTopWidth,10),Ve=parseInt(Ae.paddingTop,10),Fe=parseInt(Ae.borderBottomWidth,10),Oe=parseInt(Ae.paddingBottom,10),Be=Ne+Ve+je+Oe+Fe,Ue=Math.min(I.offsetHeight*5,Be),ze=window.getComputedStyle(M),He=parseInt(ze.paddingTop,10),Qe=parseInt(ze.paddingBottom,10),et=te.top+te.height/2-CONTENT_MARGIN,Je=se-et,Ze=I.offsetHeight/2,Ke=I.offsetTop+Ze,at=Ne+Ve+Ke,nt=Be-at;if(at<=et){const lt=ge.length>0&&I===ge[ge.length-1].ref.current;g.style.bottom="0px";const Ge=_.clientHeight-M.offsetTop-M.offsetHeight,Ct=Math.max(Je,Ze+(lt?Qe:0)+Ge+Fe),tt=at+Ct;g.style.height=tt+"px"}else{const lt=ge.length>0&&I===ge[0].ref.current;g.style.top="0px";const Ct=Math.max(et,Ne+M.offsetTop+(lt?He:0)+Ze)+nt;g.style.height=Ct+"px",M.scrollTop=at-et+M.offsetTop}g.style.margin=`${CONTENT_MARGIN}px 0`,g.style.minHeight=Ue+"px",g.style.maxHeight=se+"px",o==null||o(),requestAnimationFrame(()=>E.current=!0)}},[C,d.trigger,d.valueNode,g,_,M,I,j,d.dir,o]);useLayoutEffect2(()=>z(),[z]);const[Q,O]=React__namespace.useState();useLayoutEffect2(()=>{_&&O(window.getComputedStyle(_).zIndex)},[_]);const V=React__namespace.useCallback(te=>{te&&A.current===!0&&(z(),F==null||F(),A.current=!1)},[z,F]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:V,children:jsxRuntime.jsx("div",{ref:b,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:jsxRuntime.jsx(Primitive$4.div,{...l,ref:R,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...d}=t,f=usePopperScope$1(n);return jsxRuntime.jsx(Content$2,{...f,...d,ref:e,align:o,collisionPadding:l,style:{boxSizing:"border-box",...d.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME$4,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:o,...l}=t,d=useSelectContentContext(VIEWPORT_NAME,n),f=useSelectViewportContext(VIEWPORT_NAME,n),g=useComposedRefs(e,d.onViewportChange),b=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),jsxRuntime.jsx(Collection$1.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,_=>{const S=_.currentTarget,{contentWrapper:R,shouldExpandOnScrollRef:C}=f;if(C!=null&&C.current&&R){const E=Math.abs(b.current-S.scrollTop);if(E>0){const A=window.innerHeight-CONTENT_MARGIN*2,M=parseFloat(R.style.minHeight),I=parseFloat(R.style.height),j=Math.max(M,I);if(j<A){const F=j+E,z=Math.min(A,F),Q=F-z;R.style.height=z+"px",R.style.bottom==="0px"&&(S.scrollTop=Q>0?Q:0,R.style.justifyContent="flex-end")}}}b.current=S.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive$4.div,{role:"group","aria-labelledby":l,...o,ref:e})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive$4.div,{id:l.id,...o,ref:e})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME$1="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME$1),SelectItem$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,value:o,disabled:l=!1,textValue:d,...f}=t,g=useSelectContext(ITEM_NAME$1,n),b=useSelectContentContext(ITEM_NAME$1,n),_=g.value===o,[S,R]=React__namespace.useState(d??""),[C,E]=React__namespace.useState(!1),A=useComposedRefs(e,F=>{var z;return(z=b.itemRefCallback)==null?void 0:z.call(b,F,o,l)}),M=useId(),I=React__namespace.useRef("touch"),j=()=>{l||(g.onValueChange(o),g.onOpenChange(!1))};if(o==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:o,disabled:l,textId:M,isSelected:_,onItemTextChange:React__namespace.useCallback(F=>{R(z=>z||((F==null?void 0:F.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection$1.ItemSlot,{scope:n,value:o,disabled:l,textValue:S,children:jsxRuntime.jsx(Primitive$4.div,{role:"option","aria-labelledby":M,"data-highlighted":C?"":void 0,"aria-selected":_&&C,"data-state":_?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...f,ref:A,onFocus:composeEventHandlers(f.onFocus,()=>E(!0)),onBlur:composeEventHandlers(f.onBlur,()=>E(!1)),onClick:composeEventHandlers(f.onClick,()=>{I.current!=="mouse"&&j()}),onPointerUp:composeEventHandlers(f.onPointerUp,()=>{I.current==="mouse"&&j()}),onPointerDown:composeEventHandlers(f.onPointerDown,F=>{I.current=F.pointerType}),onPointerMove:composeEventHandlers(f.onPointerMove,F=>{var z;I.current=F.pointerType,l?(z=b.onItemLeave)==null||z.call(b):I.current==="mouse"&&F.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(f.onPointerLeave,F=>{var z;F.currentTarget===document.activeElement&&((z=b.onItemLeave)==null||z.call(b))}),onKeyDown:composeEventHandlers(f.onKeyDown,F=>{var Q;((Q=b.searchRef)==null?void 0:Q.current)!==""&&F.key===" "||(SELECTION_KEYS.includes(F.key)&&j(),F.key===" "&&F.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME$1;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,className:o,style:l,...d}=t,f=useSelectContext(ITEM_TEXT_NAME,n),g=useSelectContentContext(ITEM_TEXT_NAME,n),b=useSelectItemContext(ITEM_TEXT_NAME,n),_=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[S,R]=React__namespace.useState(null),C=useComposedRefs(e,j=>R(j),b.onItemTextChange,j=>{var F;return(F=g.itemTextRefCallback)==null?void 0:F.call(g,j,b.value,b.disabled)}),E=S==null?void 0:S.textContent,A=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:b.value,disabled:b.disabled,children:E},b.value),[b.disabled,b.value,E]),{onNativeOptionAdd:M,onNativeOptionRemove:I}=_;return useLayoutEffect2(()=>(M(A),()=>I(A)),[M,I,A]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:b.textId,...d,ref:C}),b.isSelected&&f.valueNode&&!f.valueNodeHasChildren?ReactDOM__namespace.createPortal(d.children,f.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...o,ref:e}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,t.__scopeSelect),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,t.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(e,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollTop>0;d(_)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...t,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop-b.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,t.__scopeSelect),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,t.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(e,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollHeight-b.clientHeight,S=Math.ceil(b.scrollTop)<_;d(S)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...t,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop+b.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=t,d=useSelectContentContext("SelectScrollButton",n),f=React__namespace.useRef(null),g=useCollection$1(n),b=React__namespace.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return React__namespace.useEffect(()=>()=>b(),[b]),useLayoutEffect2(()=>{var S;const _=g().find(R=>R.ref.current===document.activeElement);(S=_==null?void 0:_.ref.current)==null||S.scrollIntoView({block:"nearest"})},[g]),jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...l,ref:e,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var _;(_=d.onItemLeave)==null||_.call(d),f.current===null&&(f.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{b()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t;return jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...o,ref:e})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=usePopperScope$1(n),d=useSelectContext(ARROW_NAME$1,n),f=useSelectContentContext(ARROW_NAME$1,n);return d.open&&f.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:e}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:t,value:e,...n},o)=>{const l=React__namespace.useRef(null),d=useComposedRefs(o,l),f=usePrevious(e);return React__namespace.useEffect(()=>{const g=l.current;if(!g)return;const b=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(b,"value").set;if(f!==e&&S){const R=new Event("change",{bubbles:!0});S.call(g,e),g.dispatchEvent(R)}},[f,e]),jsxRuntime.jsx(Primitive$4.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:d,defaultValue:e})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(t){return t===""||t===void 0}function useTypeaheadSearch(t){const e=useCallbackRef$1(t),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(f=>{const g=n.current+f;e(g),(function b(_){n.current=_,window.clearTimeout(o.current),_!==""&&(o.current=window.setTimeout(()=>b(""),1e3))})(g)},[e]),d=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,d]}function findNextItem(t,e,n){const l=e.length>1&&Array.from(e).every(_=>_===e[0])?e[0]:e,d=n?t.indexOf(n):-1;let f=wrapArray(t,Math.max(d,0));l.length===1&&(f=f.filter(_=>_!==n));const b=f.find(_=>_.textValue.toLowerCase().startsWith(l.toLowerCase()));return b!==n?b:void 0}function wrapArray(t,e){return t.map((n,o)=>t[(e+o)%t.length])}var Root2$3=Select$2,Trigger$2=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$3=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$2=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select$1=Root2$3,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:t,children:e,...n},o)=>jsxRuntime.jsxs(Trigger$2,{ref:o,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$2.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",t),...e,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",t),...e,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:t,children:e,position:n="popper",...o},l)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$3,{ref:l,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...o,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$3.displayName;const SelectLabel=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",t),...e}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:t,children:e,...n},o)=>jsxRuntime.jsxs(Item$2,{ref:o,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:e})]}));SelectItem.displayName=Item$2.displayName;const SelectSeparator=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",t),...e}));SelectSeparator.displayName=Separator.displayName;function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var z,Q,O,V,te;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((Q=(z=e.Categories)==null?void 0:z[0])==null?void 0:Q.CategoryCode)||""),[f,g]=React.useState(!1),[b,_]=React.useState(!1),[S,R]=React.useState("percentile"),{toast:C}=useToast(),{data:E,isLoading:A,isFetching:M}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),I=async()=>{try{g(!0),_(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&C({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(ne){console.error("Error syncing to Shopify:",ne),C({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},j=()=>{var ne,ae;return((ae=(ne=e.Categories)==null?void 0:ne.find($e=>$e.CategoryCode===l))==null?void 0:ae.CategoryName)||l},F=React.useMemo(()=>E!=null&&E.Products?[...E.Products].sort((ne,ae)=>S==="price-asc"?(ne.MAP??0)-(ae.MAP??0):S==="price-desc"?(ae.MAP??0)-(ne.MAP??0):S==="name"?(ne.Title??"").localeCompare(ae.Title??""):S==="percentile"?(ae.OverallPercentileRank??0)-(ne.OverallPercentileRank??0):0):[],[E==null?void 0:E.Products,S]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:j(),niche:(E==null?void 0:E.Niche)||"",productsNumber:((O=E==null?void 0:E.Products)==null?void 0:O.length)||0,autoreorder:(E==null?void 0:E.AutoReorder)||!1,starred:(E==null?void 0:E.Starred)||!1,isLoading:A||M,children:n&&((V=e.Categories)==null?void 0:V.findIndex(ne=>ne.AvailableToBuy))!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",disabled:f,onClick:()=>_(!0),children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(te=e.Categories)==null?void 0:te.find(ne=>ne.CategoryCode===l)].filter(Boolean),manufID:e.ManufacturerId,appID:t}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(E==null?void 0:E.ActiveOrderDetails)??void 0,loading:A||M})]})]}),jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),jsxRuntime.jsxs("div",{className:"flex justify-between items-center mt-7 mb-4",children:[jsxRuntime.jsx("h4",{className:"text-xl md:text-2xl text-foreground font-bold",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Sort by:"}),jsxRuntime.jsxs(Select$1,{value:S,onValueChange:R,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[220px]",children:jsxRuntime.jsx(SelectValue,{})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"price-asc",children:"MAP: Low to High"}),jsxRuntime.jsx(SelectItem,{value:"price-desc",children:"MAP: High to Low"}),jsxRuntime.jsx(SelectItem,{value:"name",children:"Name"}),jsxRuntime.jsx(SelectItem,{value:"percentile",children:"Best Selling"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:A||M?Array.from({length:4}).map((ne,ae)=>jsxRuntime.jsx(ProductCard,{},ae)):F.length>0?F.map(ne=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:ne,viewProductLink:`/${t}/Product/${ne.RandmarSKU}`,shopifyHostname:n},ne.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:b,onOpenChange:_,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',j(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:I,disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:t,partnerId:e,userEmail:n,shopifyHostName:o,isSuperAdmin:l}){var F,z,Q;const{data:d}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t}),{data:f,isLoading:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),{toast:_}=useToast(),[S]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[R,C]=React.useState(!1),[E,A]=React.useState(!1),M=async()=>{try{C(!0),A(!1),await S({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&_({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(O){console.error("Error syncing to Shopify:",O),_({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{C(!1)}},I=()=>f!=null&&f.Manufacturer?"products":f!=null&&f.Reseller?"reseller-overview":"",j=usePartnershipAssistantPrompt(d,f);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:f,loading:g||b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((f==null?void 0:f.Manufacturer)||g||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:f==null?void 0:f.Manufacturer,loading:g||b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:f==null?void 0:f.Manufacturer}),o&&((z=(F=f==null?void 0:f.Manufacturer)==null?void 0:F.Categories)==null?void 0:z.findIndex(O=>O.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',(Q=f==null?void 0:f.Manufacturer)==null?void 0:Q.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:M,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:f==null?void 0:f.Reseller,loading:g||b})]})]}),((f==null?void 0:f.Reseller)||(f==null?void 0:f.Manufacturer))&&!g&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:I(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:f.ApplicationId||"",reseller:f==null?void 0:f.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:f==null?void 0:f.Manufacturer,applicationId:t,userEmail:n})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:f.Manufacturer,shopifyHostName:o})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:j,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(g||b)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:t,appID:e,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),_=React.useMemo(()=>({publicEmail:t.PublicEmail??"",contactName:t.ContactName??"",phone:t.Phone??"",website:t.Website??""}),[t]),{register:S,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:M}}=useForm({defaultValues:_}),I=E(),j=React.useCallback(()=>g?JSON.stringify(I)!==JSON.stringify(g):!1,[I,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{t&&Object.keys(t).length>0&&(C(_),b(_))},[t,C,_]);const F=async Q=>{let O=!0,V=!1;const te=Object.keys(Q).map(ne=>({key:ne,keyApi:ne.charAt(0).toUpperCase()+ne.slice(1)}));for(const ne of te){const ae=Q[ne.key],$e=t[ne.keyApi];if(ae!==$e&&ae!==void 0){V=!0;try{await f({applicationId:e,fieldName:ne.keyApi,newValue:String(ae)}).unwrap()||(O=!1)}catch(ge){console.error(`Error updating ${ne.keyApi}:`,ge),O=!1}}}O&&V?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...Q}),l&&l(!1)):O||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},z=Q=>!Q||Q.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(z(E("contactName"))||z(E("publicEmail"))||z(E("website"))||z(E("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:R(F),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:o,...S("contactName",{}),className:A.contactName||z(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:o,...S("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||z(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:o,...S("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||z(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:o,...S("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||z(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:M||o,className:o?"hidden":"",children:M?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o,userEmail:l,isSuperAdmin:d}){const{toast:f}=useToast(),{Statement:g,CreditLimit:b}=e,[_,S]=React.useState(!1),[R,C]=React.useState(!1),[E,A]=React.useState(!1),[M,I]=React.useState(!1),[j,F]=React.useState(l||""),[z,Q]=React.useState(!1),[O,V]=React.useState((b==null?void 0:b.toString())||""),[te,{isLoading:ne}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),ae=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:b||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),d&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{Q(!0),V((b==null?void 0:b.toString())||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[$e]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),ge=async Ne=>{Ne?S(!0):C(!0);try{const Fe=(await $e({routeResellerId:t,documentNumber:`ST${t}`})).data;if(!Fe)throw new Error("No data received for download.");if(Ne)window.open(Fe);else{const Oe=document.createElement("a");Oe.href=Fe,Oe.download=`ST${t}.pdf`,document.body.appendChild(Oe),Oe.click(),Oe.remove()}f({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Ve){console.error("Download Error:",Ve),f({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{Ne?S(!1):C(!1)}},[se]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),je=async()=>{if(!j||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j)){f({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}A(!0);try{await se({routeResellerId:t,emailAddress:j}).unwrap(),f({title:"Success",description:`Statement sent to ${j} successfully.`,variant:"success"}),I(!1)}catch(Ve){console.error("Send Email Error:",Ve),f({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{A(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},Ne))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(Ne=>jsxRuntime.jsx("div",{className:Ne===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},Ne))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const Ae=!o;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:ae.slice(0,3).map((Ne,Ve)=>jsxRuntime.jsx(BillingItem,{icon:Ne.icon,label:Ne.label,value:Ne.value},Ve))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:ae.slice(3).map((Ne,Ve)=>jsxRuntime.jsx("div",{className:Ve===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:Ne.icon,label:Ne.label,value:Ne.value})},Ve))})]}),Ae&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>ge(!0),disabled:_,children:_?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>ge(!1),disabled:R,children:R?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>I(!0),disabled:E,children:E?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:M,onOpenChange:I,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:j,onChange:Ne=>F(Ne.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:je,disabled:E||!j,children:E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:z,onOpenChange:Q,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:O,onChange:Ne=>V(Ne.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const Ne=Number(O);if(isNaN(Ne)){f({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await te({applicationId:t,newValue:Ne}).unwrap(),Q(!1),f({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Ve){console.error("Update Credit Limit Error:",Ve),f({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:ne,children:ne?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:t,label:e,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(t,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:t,setOpen:e,tier:n,onTierChange:o,isLoading:l}){const d=()=>{e(!1)};return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=t=>t===1?"The Best":t===2?"Fixed 12.5% GP on all items":t===3?"Advantageous":t===4?"Buying Group":t===5?"Cost":t,getShippingText=t=>t==="A"?"Free or Custom":t==="B"?"Fixed $10 anywhere":t==="C"?`Free shipping on $150+ orders to your location,
|
|
1175
1175
|
$15 for drop shipped orders under $1,500,
|
|
1176
|
-
$10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=Ne=>Ne&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Ne]||"",E=Ne=>Ne&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Ne]||"",A=Ne=>Ne&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Ne]||"",[M,I]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,F]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),O=Ne=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Ne]||Ne,V=Ne=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Ne]||Ne,te=Ne=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Ne]||Ne;React.useEffect(()=>{I(C((n==null?void 0:n.Priority)??"")),F(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(Ne,Ve,Fe,Oe)=>{try{(await S({applicationId:o,fieldName:Ne,newValue:Ve})).error?d({title:"Error",description:Oe,variant:"destructive"}):d({title:"Success",description:Fe,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},ae=async Ne=>{I(Ne);const Ve=O(Ne);ne("Priority",Ve,`Priority updated to ${Ve}`,"Failed to update priority")},$e=async Ne=>{F(Ne);const Ve=V(Ne);ne("ShippingProfile",Ve,`Shipping profile updated to ${Ve}`,"Failed to update shipping profile")},ge=async Ne=>{Q(Ne);const Ve=te(Ne);ne("PriceProfile",Ve,`Pricing profile updated to ${Ve}`,"Failed to update pricing profile")},se=async()=>{try{const Ne=await S({applicationId:o,fieldName:"Tier",newValue:b});Ne.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Ne.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},je=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],Ae=Ne=>{_(Ne),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Ne))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:e,className:e?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),je.map(Ne=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Ne.enabled,onClick:()=>Ae(Ne.name),children:Ne.name},Ne.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:se}),t&&!e&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:M,onValueChange:ae,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ne.value,id:`priority-${Ne.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Ne.value}`,className:"cursor-pointer text-xs",children:Ne.label})]},Ne.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:$e,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ne.value,id:`shipping-${Ne.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Ne.value}`,className:"cursor-pointer text-xs",children:Ne.label})]},Ne.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:z,onValueChange:ge,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ne.value,id:`pricing-${Ne.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Ne.value}`,className:"cursor-pointer text-xs",children:Ne.label})]},Ne.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(M=>M.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(M=>M.DocumentType==="Shipment"))||[],l=n.filter(M=>M.WarehouseCode!=="3PLE"),d=l.reduce((M,I)=>M+(I.Quantity??0),0),f=l.reduce((M,I)=>M+(I.ExtendedPrice??0),0),g=n.filter(M=>M.WarehouseCode==="3PLE"),b=g.reduce((M,I)=>M+(I.Quantity??0),0),_=g.reduce((M,I)=>M+(I.ExtendedPrice??0),0),S=o.reduce((M,I)=>M+(I.Quantity??0),0),R=o.reduce((M,I)=>M+(I.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},M))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:M.name}),jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(M.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:M.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:M.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},M.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:M}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[I,j]=React.useState(null),[F,z]=React.useState(e),[Q,O]=React.useState(!1),[V,te]=React.useState("all"),{data:ne,isLoading:ae}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),$e=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],ge=async Ae=>{j(Ae),Ae.id==="Products"&&te("all"),O(!0)},se=async()=>{if(!(!I||!n))try{switch(I.id){case"Products":{const Ae={routeResellerId:n,emailAddress:F};V&&V!=="all"&&(Ae.manufacturerId=V),await S(Ae).unwrap();break}case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:F}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:F}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:F}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:F}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:F}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${I.title} will be sent to ${F} shortly.`,variant:"success"}),O(!1)}catch(Ae){console.error("Error requesting report:",Ae),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},je=_||R||g||d||M||E;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},Ne))]},Ae))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:$e.map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Ae.name}),Ae.reports.map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Ne.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Ne.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ne.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>ge(Ne),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Ne.id))]},Ae.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:O,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",I==null?void 0:I.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:F,onChange:Ae=>z(Ae.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(I==null?void 0:I.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:V,onChange:Ae=>te(Ae.target.value),disabled:ae,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!ae&&Array.isArray(ne)&&ne.slice().sort((Ae,Ne)=>(Ae.PublicName||Ae.Name||"").localeCompare(Ne.PublicName||Ne.Name||"")).map(Ae=>Ae!=null&&Ae.ManufacturerId?jsxRuntime.jsx("option",{value:Ae.ManufacturerId,children:(Ae.PublicName||Ae.Name||Ae.ManufacturerId)+(Ae.OpenToWork?" (Open to Work)":"")},Ae.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:se,disabled:!F||je,children:je?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:t,mode:e="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),_=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!t){f([]);return}let S=[];if(e==="week"){const R=new Map;t.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const M=parseInt(E.substring(0,4),10),I=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),F=new Date(M,I,j),z=new Date(F);z.setDate(F.getDate()-F.getDay());const Q=`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`,O=R.get(Q)||{price:0,quantity:0};O.price+=C.ExtendedPrice||0,O.quantity+=C.Quantity||0,R.set(Q,O)}}),S=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),M=`${C}-${(E+1).toString().padStart(2,"0")}`,I=Array.from({length:12},(F,z)=>{const Q=new Date(C,E-(11-z),1);return`${Q.getFullYear()}-${(Q.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(I.map(F=>[F,{price:0,quantity:0}]));if(t.forEach(F=>{const z=String(F.Day??0);if(z.length!==8)return;const Q=`${z.substring(0,4)}-${z.substring(4,6)}`;j[Q]&&(j[Q].price+=F.ExtendedPrice??0,j[Q].quantity+=F.Quantity??0)}),S=I.map(F=>{const z=j[F],[Q,O]=F.split("-").map(Number);return{date:new Date(Q,O-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:z.price,unitsSold:z.quantity}}),g){const F=j[M];if(F&&F.price>0&&A>0){const z=new Date(C,E+1,0).getDate();if(A<z){const Q=F.price/A,O=F.quantity/A,V=Q*z,te=O*z,ne=S[S.length-1];ne&&(ne.dollarVolume=V,ne.unitsSold=te)}}}}f(S)},[t,e,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:d,series:_,height:n,size:l}),l==="default"&&e==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:t,applicationId:e,publicName:n,name:o,location:l,link:d,linkNewTab:f=!0,children:g}){const[b,_]=React.useState(!1),S=C=>{C.preventDefault(),C.stopPropagation(),navigator.clipboard.writeText(e),_(!0),setTimeout(()=>_(!1),2e3)},R=jsxRuntime.jsxs(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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:e,width:48,height:48},`partner_logo_${e}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:t}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:S,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:e}),b?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),o&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:o}),l&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:l})]})]}),g&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:g})]});return d?jsxRuntime.jsx(reactRouterDom.Link,{to:d,target:f?"_blank":"_self",children:R}):R}function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1,appID:f}){var Q,O,V;const{toast:g}=useToast(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[S,R]=React.useState(!1),[C,E]=React.useState(""),{data:A}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:f||""},{skip:!f}),M=A==null?void 0:A.IsReseller;if(d||!t)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(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.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const I=[t.City,t.Province,t.Country].filter(Boolean),j=I.length>0?I.join(", "):"",F=((Q=t.Tags)==null?void 0:Q.split(",").map(te=>te.trim()).filter(Boolean))||[],z=async()=>{if(!(!(t!=null&&t.ManufacturerId)||!f||!C))try{await b({routeResellerId:f,emailAddress:C,manufacturerId:t.ManufacturerId}).unwrap(),g({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${C} shortly.`,variant:"success"}),R(!1)}catch(te){console.error("Error requesting product list:",te),g({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:t.ManufacturerId,publicName:t.PublicName,name:t.Name,location:j,link:e,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((O=t.Qualification)!=null&&O.QualificationId)&&((V=t.Qualification)==null?void 0:V.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||F.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),F.map((te,ne)=>jsxRuntime.jsx(Badge,{variant:"outline",children:te},ne))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Website})]}),t.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.CurrencyCode})]})]})]}),t.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||t.PublicResourcesLink||M&&f&&t.ManufacturerId)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,M&&f&&t.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>R(!0),disabled:_,children:_?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),t.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:t.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]}),jsxRuntime.jsx(Dialog,{open:S,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:C,onChange:te=>E(te.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:z,disabled:!C||_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:t,randmarSku:e,inventory:n,buttonSize:o="default"}){var $e;const l=React.useRef(null),d=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:f}=useToast(),[g,b]=React.useState(!1),[_,S]=React.useState(!1),[R,C]=React.useState(!1),{data:E,isLoading:A,isFetching:M}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!d}),{data:I,isLoading:j,isFetching:F}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!!n||!d}),[z]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),Q=n??(($e=I==null?void 0:I.Distribution)==null?void 0:$e.Inventory);React.useEffect(()=>{b(!1)},[e]);const{inventoryQuantity:O,totalIncomingQuantity:V}=React.useMemo(()=>{if(!Q||Q.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const ge=Q.reduce((je,Ae)=>je+(Ae.AvailableQuantity||0),0),se=Q.reduce((je,Ae)=>je+(Ae.PurchaseOrderQuantity||0),0);return{inventoryQuantity:ge,totalIncomingQuantity:se}},[Q]);if(A||M||j||F)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-36 rounded-md"})});const ne=()=>{R||!(E!=null&&E.IsReseller)||(C(!0),z({routeResellerId:t??"",randmarSku:e??""}).then(ge=>{ge.error||ge.data===!1?f({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):f({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),S(!1)}).catch(ge=>{console.error(ge),f({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{C(!1)}))};if(!Q)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:o,variant:"outline",className:"text-sm",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(E!=null&&E.IsReseller&&O<=0&&V<=0)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:_,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:"text-sm reseller-theme text-primary",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),disabled:R,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ne,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const ae=O<=0&&V>0;return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:g,onOpenChange:b,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:`text-sm ${ae?"manufacturer-theme text-primary":O>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),ae?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(V)," Incoming"]}):O>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(O)," 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:Q})]})]})})}function OrdersCard({applicationId:t,orders:e=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/GeneralDocument/${g.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:g.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:g})=>g.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Product/${g.original.MPN}`,className:"font-medium text-primary hover:underline",children:g.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",g.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:g})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:t,randmarSku:g.original.RandmarSKU??"",buttonSize:"sm"})})}],[t]),d=React.useMemo(()=>{const g={};if(e){const b=Array.from(new Set(e.map(A=>A.WarehouseCode).filter(A=>A!=null)));g.WarehouseCode=b;const _=Array.from(new Set(e.map(A=>A.ShipToName).filter(A=>A!=null)));g.ShipToName=_;const S=Array.from(new Set(e.map(A=>A.DocumentNumber).filter(A=>A!=null)));g.DocumentNumber=S;const R=Array.from(new Set(e.map(A=>A.OrderNumber).filter(A=>A!=null)));g.OrderNumber=R;const C=Array.from(new Set(e.map(A=>A.PONumber).filter(A=>A!=null)));g.PONumber=C;const E=Array.from(new Set(e.map(A=>A.MPN).filter(A=>A!=null)));g.MPN=E}return g},[e]),f=e||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){var F,z,Q,O;const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((V,te)=>{S(ne=>{var ae;return((ae=ne[V])==null?void 0:ae.hasUnsavedChanges)!==te.hasUnsavedChanges?{...ne,[V]:te}:ne})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,M=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,I=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),M&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o,isSuperAdmin:l}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:V=>C("publicInfo",{hasUnsavedChanges:V})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||I.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((V,te)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},te)):I.map(V=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:V,link:`https://dashboard.randmar.io/${t}/Partner/${V.ManufacturerId}`},V.ManufacturerId))})})]}):j.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),(((F=A==null?void 0:A.Opportunities)==null?void 0:F.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),(((z=A==null?void 0:A.ActiveOrderDetails)==null?void 0:z.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),(((Q=A==null?void 0:A.CompletedOrderDetails)==null?void 0:Q.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),(((O=A==null?void 0:A.Returns)==null?void 0:O.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
|
|
1176
|
+
$10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=Ne=>Ne&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Ne]||"",E=Ne=>Ne&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Ne]||"",A=Ne=>Ne&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Ne]||"",[M,I]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,F]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),O=Ne=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Ne]||Ne,V=Ne=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Ne]||Ne,te=Ne=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Ne]||Ne;React.useEffect(()=>{I(C((n==null?void 0:n.Priority)??"")),F(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(Ne,Ve,Fe,Oe)=>{try{(await S({applicationId:o,fieldName:Ne,newValue:Ve})).error?d({title:"Error",description:Oe,variant:"destructive"}):d({title:"Success",description:Fe,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},ae=async Ne=>{I(Ne);const Ve=O(Ne);ne("Priority",Ve,`Priority updated to ${Ve}`,"Failed to update priority")},$e=async Ne=>{F(Ne);const Ve=V(Ne);ne("ShippingProfile",Ve,`Shipping profile updated to ${Ve}`,"Failed to update shipping profile")},ge=async Ne=>{Q(Ne);const Ve=te(Ne);ne("PriceProfile",Ve,`Pricing profile updated to ${Ve}`,"Failed to update pricing profile")},se=async()=>{try{const Ne=await S({applicationId:o,fieldName:"Tier",newValue:b});Ne.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Ne.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},je=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],Ae=Ne=>{_(Ne),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Ne))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:e,className:e?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),je.map(Ne=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Ne.enabled,onClick:()=>Ae(Ne.name),children:Ne.name},Ne.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:se}),t&&!e&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:M,onValueChange:ae,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ne.value,id:`priority-${Ne.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Ne.value}`,className:"cursor-pointer text-xs",children:Ne.label})]},Ne.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:$e,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ne.value,id:`shipping-${Ne.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Ne.value}`,className:"cursor-pointer text-xs",children:Ne.label})]},Ne.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:z,onValueChange:ge,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ne.value,id:`pricing-${Ne.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Ne.value}`,className:"cursor-pointer text-xs",children:Ne.label})]},Ne.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(M=>M.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(M=>M.DocumentType==="Shipment"))||[],l=n.filter(M=>M.WarehouseCode!=="3PLE"),d=l.reduce((M,I)=>M+(I.Quantity??0),0),f=l.reduce((M,I)=>M+(I.ExtendedPrice??0),0),g=n.filter(M=>M.WarehouseCode==="3PLE"),b=g.reduce((M,I)=>M+(I.Quantity??0),0),_=g.reduce((M,I)=>M+(I.ExtendedPrice??0),0),S=o.reduce((M,I)=>M+(I.Quantity??0),0),R=o.reduce((M,I)=>M+(I.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},M))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:M.name}),jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(M.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:M.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:M.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},M.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:M}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[I,j]=React.useState(null),[F,z]=React.useState(e),[Q,O]=React.useState(!1),[V,te]=React.useState("all"),{data:ne,isLoading:ae}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),$e=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],ge=async Ae=>{j(Ae),Ae.id==="Products"&&te("all"),O(!0)},se=async()=>{if(!(!I||!n))try{switch(I.id){case"Products":{const Ae={routeResellerId:n,emailAddress:F};V&&V!=="all"&&(Ae.manufacturerId=V),await S(Ae).unwrap();break}case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:F}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:F}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:F}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:F}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:F}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${I.title} will be sent to ${F} shortly.`,variant:"success"}),O(!1)}catch(Ae){console.error("Error requesting report:",Ae),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},je=_||R||g||d||M||E;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},Ne))]},Ae))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:$e.map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Ae.name}),Ae.reports.map(Ne=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Ne.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Ne.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ne.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>ge(Ne),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Ne.id))]},Ae.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:O,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",I==null?void 0:I.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:F,onChange:Ae=>z(Ae.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(I==null?void 0:I.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:V,onChange:Ae=>te(Ae.target.value),disabled:ae,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!ae&&Array.isArray(ne)&&ne.slice().sort((Ae,Ne)=>(Ae.PublicName||Ae.Name||"").localeCompare(Ne.PublicName||Ne.Name||"")).map(Ae=>Ae!=null&&Ae.ManufacturerId?jsxRuntime.jsx("option",{value:Ae.ManufacturerId,children:(Ae.PublicName||Ae.Name||Ae.ManufacturerId)+(Ae.OpenToWork?" (Open to Work)":"")},Ae.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:se,disabled:!F||je,children:je?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:t,mode:e="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),_=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!t){f([]);return}let S=[];if(e==="week"){const R=new Map;t.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const M=parseInt(E.substring(0,4),10),I=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),F=new Date(M,I,j),z=new Date(F);z.setDate(F.getDate()-F.getDay());const Q=`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`,O=R.get(Q)||{price:0,quantity:0};O.price+=C.ExtendedPrice||0,O.quantity+=C.Quantity||0,R.set(Q,O)}}),S=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),M=`${C}-${(E+1).toString().padStart(2,"0")}`,I=Array.from({length:12},(F,z)=>{const Q=new Date(C,E-(11-z),1);return`${Q.getFullYear()}-${(Q.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(I.map(F=>[F,{price:0,quantity:0}]));if(t.forEach(F=>{const z=String(F.Day??0);if(z.length!==8)return;const Q=`${z.substring(0,4)}-${z.substring(4,6)}`;j[Q]&&(j[Q].price+=F.ExtendedPrice??0,j[Q].quantity+=F.Quantity??0)}),S=I.map(F=>{const z=j[F],[Q,O]=F.split("-").map(Number);return{date:new Date(Q,O-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:z.price,unitsSold:z.quantity}}),g){const F=j[M];if(F&&F.price>0&&A>0){const z=new Date(C,E+1,0).getDate();if(A<z){const Q=F.price/A,O=F.quantity/A,V=Q*z,te=O*z,ne=S[S.length-1];ne&&(ne.dollarVolume=V,ne.unitsSold=te)}}}}f(S)},[t,e,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:d,series:_,height:n,size:l}),l==="default"&&e==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:t,applicationId:e,publicName:n,name:o,location:l,link:d,linkNewTab:f=!0,children:g}){const[b,_]=React.useState(!1),S=C=>{C.preventDefault(),C.stopPropagation(),navigator.clipboard.writeText(e),_(!0),setTimeout(()=>_(!1),2e3)},R=jsxRuntime.jsxs(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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:e,width:48,height:48},`partner_logo_${e}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:t}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:S,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:e}),b?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),o&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:o}),l&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:l})]})]}),g&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:g})]});return d?jsxRuntime.jsx(reactRouterDom.Link,{to:d,target:f?"_blank":"_self",children:R}):R}function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1,appID:f}){var Q,O,V;const{toast:g}=useToast(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[S,R]=React.useState(!1),[C,E]=React.useState(""),{data:A}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:f||""},{skip:!f}),M=A==null?void 0:A.IsReseller;if(d||!t)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(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.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const I=[t.City,t.Province,t.Country].filter(Boolean),j=I.length>0?I.join(", "):"",F=((Q=t.Tags)==null?void 0:Q.split(",").map(te=>te.trim()).filter(Boolean))||[],z=async()=>{if(!(!(t!=null&&t.ManufacturerId)||!f||!C))try{await b({routeResellerId:f,emailAddress:C,manufacturerId:t.ManufacturerId}).unwrap(),g({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${C} shortly.`,variant:"success"}),R(!1)}catch(te){console.error("Error requesting product list:",te),g({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:t.ManufacturerId,publicName:t.PublicName,name:t.Name,location:j,link:e,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((O=t.Qualification)!=null&&O.QualificationId)&&((V=t.Qualification)==null?void 0:V.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||F.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),F.map((te,ne)=>jsxRuntime.jsx(Badge,{variant:"outline",children:te},ne))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Website})]}),t.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.CurrencyCode})]})]})]}),t.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||t.PublicResourcesLink||M&&f&&t.ManufacturerId)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,M&&f&&t.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>R(!0),disabled:_,children:_?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),t.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:t.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]}),jsxRuntime.jsx(Dialog,{open:S,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:C,onChange:te=>E(te.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:z,disabled:!C||_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:t,randmarSku:e,inventory:n,buttonSize:o="default"}){var $e;const l=React.useRef(null),d=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:f}=useToast(),[g,b]=React.useState(!1),[_,S]=React.useState(!1),[R,C]=React.useState(!1),{data:E,isLoading:A,isFetching:M}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!d}),{data:I,isLoading:j,isFetching:F}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!!n||!d}),[z]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),Q=n??(($e=I==null?void 0:I.Distribution)==null?void 0:$e.Inventory);React.useEffect(()=>{b(!1)},[e]);const{inventoryQuantity:O,totalIncomingQuantity:V}=React.useMemo(()=>{if(!Q||Q.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const ge=Q.reduce((je,Ae)=>je+(Ae.AvailableQuantity||0),0),se=Q.reduce((je,Ae)=>je+(Ae.PurchaseOrderQuantity||0),0);return{inventoryQuantity:ge,totalIncomingQuantity:se}},[Q]);if(A||M||j||F)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-36 rounded-md"})});const ne=()=>{R||!(E!=null&&E.IsReseller)||(C(!0),z({routeResellerId:t??"",randmarSku:e??""}).then(ge=>{ge.error||ge.data===!1?f({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):f({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),S(!1)}).catch(ge=>{console.error(ge),f({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{C(!1)}))};if(!Q)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:o,variant:"outline",className:"text-sm",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(E!=null&&E.IsReseller&&O<=0&&V<=0)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:_,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:"text-sm reseller-theme text-primary",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),disabled:R,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ne,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const ae=O<=0&&V>0;return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:g,onOpenChange:b,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:`text-sm ${ae?"manufacturer-theme text-primary":O>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),ae?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(V)," Incoming"]}):O>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(O)," 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:Q})]})]})})}function OrdersCard({applicationId:t,orders:e=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/GeneralDocument/${g.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:g.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:g})=>g.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Product/${g.original.MPN}`,className:"font-medium text-primary hover:underline",children:g.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",g.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:g})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:t,randmarSku:g.original.RandmarSKU??"",buttonSize:"sm"})})}],[t]),d=React.useMemo(()=>{const g={};if(e){const b=Array.from(new Set(e.map(A=>A.WarehouseCode).filter(A=>A!=null)));g.WarehouseCode=b;const _=Array.from(new Set(e.map(A=>A.ShipToName).filter(A=>A!=null)));g.ShipToName=_;const S=Array.from(new Set(e.map(A=>A.DocumentNumber).filter(A=>A!=null)));g.DocumentNumber=S;const R=Array.from(new Set(e.map(A=>A.OrderNumber).filter(A=>A!=null)));g.OrderNumber=R;const C=Array.from(new Set(e.map(A=>A.PONumber).filter(A=>A!=null)));g.PONumber=C;const E=Array.from(new Set(e.map(A=>A.MPN).filter(A=>A!=null)));g.MPN=E}return g},[e]),f=e||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){var F,z,Q,O;const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((V,te)=>{S(ne=>{var ae;return((ae=ne[V])==null?void 0:ae.hasUnsavedChanges)!==te.hasUnsavedChanges?{...ne,[V]:te}:ne})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,M=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,I=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),M&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o,isSuperAdmin:l}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:V=>C("publicInfo",{hasUnsavedChanges:V})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||I.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((V,te)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},te)):I.map(V=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:V,link:`https://dashboard.randmar.io/${t}/Partner/${V.ManufacturerId}`},V.ManufacturerId))})})]}):j.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),(((F=A==null?void 0:A.Opportunities)==null?void 0:F.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),(((z=A==null?void 0:A.ActiveOrderDetails)==null?void 0:z.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),(((Q=A==null?void 0:A.CompletedOrderDetails)==null?void 0:Q.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),(((O=A==null?void 0:A.Returns)==null?void 0:O.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
|
|
1177
1177
|
* table-core
|
|
1178
1178
|
*
|
|
1179
1179
|
* Copyright (c) TanStack
|