randmarcomps 1.94.0 → 1.95.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.d.ts
CHANGED
|
@@ -267,14 +267,14 @@ export declare interface PreloaderProps {
|
|
|
267
267
|
className?: string;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
export declare function ProductCard({ item, addToCart, syncToShopify, customAction, defaultOpportunityNumber,
|
|
270
|
+
export declare function ProductCard({ item, addToCart, syncToShopify, customAction, defaultOpportunityNumber, viewProductLink, addToCartAction, isAddToCartActionLoading, syncToShopifyAction, isSyncToShopifyActionLoading, }: ProductCardProps): JSX.Element;
|
|
271
271
|
|
|
272
272
|
export declare interface ProductCardProps {
|
|
273
273
|
item?: FlatProduct;
|
|
274
274
|
addToCart?: boolean;
|
|
275
275
|
syncToShopify?: boolean;
|
|
276
276
|
defaultOpportunityNumber?: string;
|
|
277
|
-
|
|
277
|
+
viewProductLink?: string;
|
|
278
278
|
addToCartAction?: (state: {
|
|
279
279
|
quantity: number;
|
|
280
280
|
bidNumber: string | null;
|
package/dist/randmarcomps.js
CHANGED
|
@@ -45028,7 +45028,7 @@ function ProductCard({
|
|
|
45028
45028
|
syncToShopify: n = !1,
|
|
45029
45029
|
customAction: i = /* @__PURE__ */ jsx(Fragment, {}),
|
|
45030
45030
|
defaultOpportunityNumber: o = "",
|
|
45031
|
-
|
|
45031
|
+
viewProductLink: l,
|
|
45032
45032
|
addToCartAction: u,
|
|
45033
45033
|
isAddToCartActionLoading: f = !1,
|
|
45034
45034
|
syncToShopifyAction: d,
|
|
@@ -45328,10 +45328,10 @@ function ProductCard({
|
|
|
45328
45328
|
}) })
|
|
45329
45329
|
] }) }),
|
|
45330
45330
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
45331
|
-
l && /* @__PURE__ */ jsxs(Button, { variant: "secondary",
|
|
45331
|
+
l && /* @__PURE__ */ jsx(Link, { to: l, children: /* @__PURE__ */ jsxs(Button, { variant: "secondary", children: [
|
|
45332
45332
|
/* @__PURE__ */ jsx(Eye, { className: "mr-2" }),
|
|
45333
45333
|
"View Product"
|
|
45334
|
-
] }),
|
|
45334
|
+
] }) }),
|
|
45335
45335
|
((se = e.Distribution) == null ? void 0 : se.Inventory) && /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsxs(Dialog, { open: S, onOpenChange: C, children: [
|
|
45336
45336
|
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
45337
45337
|
Button,
|
|
@@ -862,6 +862,6 @@ ${p.description}`:p.summary||`${f.toUpperCase()} ${m[m.length-1]}`,parameters:{t
|
|
|
862
862
|
DO NOT ask the user which ID to use. ALWAYS use "${e}" for ALL ID parameters - unless the user has asked for another one.
|
|
863
863
|
This is MANDATORY for ALL API function calls.
|
|
864
864
|
|
|
865
|
-
REPEAT: For ANY API function that requires an ID in the path, USE "${e}" as the value unless the user has given you another one.`,A=C.startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Please introduce yourself"}]},{role:"model",parts:[{text:T}]}],tools:f.length>0?[{functionDeclarations:f.map(({declaration:M})=>M)}]:[]});l(A)}catch(C){console.error("Error initializing chat:",C)}};o||m||S()},[m,o]),React.useEffect(()=>{(async()=>{try{const C=await fetchApiFunctions(e);p(C)}catch(C){console.error("Error loading API functions:",C)}finally{g(!1)}})()},[e]);const _=Object.fromEntries(f.map(({declaration:S,handler:C})=>[S.name,C])),R=async S=>{var T,A;const C=S.name;if(C in _){const M=_[C],I=S.args||{};console.log(`[Function Call] ${C} with args:`,I);const O=(T=f.find(D=>D.declaration.name===C))==null?void 0:T.declaration;if(!O){console.error(`[Function Call] Could not find declaration for ${C}`);return}const N=Object.keys(((A=O.parameters)==null?void 0:A.properties)||{});console.log("[Function Call] Parameter names from declaration:",N);const j=[];N.forEach(D=>{if(D.toLowerCase().includes("id")||D.toLowerCase().includes("reseller")||D.toLowerCase().includes("manufacturer")||D.toLowerCase().includes("partner")||D.toLowerCase().includes("application"))j.push("");else if(D in I){const L=I[D];typeof L=="object"?j.push(JSON.stringify(L)):j.push(typeof L=="string"?L:String(L))}else j.push("")}),console.log("[Function Call] Converted args to:",j);try{const D=await M(j);let F,L=null,B=!1;if(typeof D=="string"?F=D:(F=D.summary,L=D.component,B=!0),console.log(`[Function Response] ${C} returned:`,F),o){const V={functionResponse:{name:C,response:{content:F}}};if(B&&L){const U={role:"assistant",content:L,timestamp:new Date,isComponent:!0};d(Q=>[...Q,U])}const z={role:"assistant",content:(await o.sendMessage([V])).response.text(),timestamp:new Date};d(U=>[...U,z])}}catch(D){console.error("Error executing function:",D);const F={role:"assistant",content:"I encountered an error while processing your request. Please try again.",timestamp:new Date};d(L=>[...L,F])}}else console.error(`Function ${C} not found`)};return{handleSubmitToBot:async S=>{if(S.trim()&&!n&&o){const C={role:"user",content:S,timestamp:new Date};d(T=>[...T,C]),i(!0);try{const A=(await o.sendMessage(S.trim())).response,M=A.functionCalls();if(M&&M.length>0)for(const I of M)await R(I);else{const I={role:"assistant",content:A.text(),timestamp:new Date};d(O=>[...O,I])}}catch(T){console.error("Error sending message:",T);const A={role:"assistant",content:"I'm sorry, I encountered an error processing your request. Please try again later.",timestamp:new Date};d(M=>[...M,A])}finally{i(!1)}}},botMessages:u,botReady:!!o,isProcessingSubmission:n}}const ASSISTANT_ID="RandmarAIChatAssistant",ChatLayout=React.forwardRef(({userId:e,userName:t,apiKey:n,inputRef:i},o)=>{var Q,q,W;const{data:l}=useGetV4PartnerByApplicationIdBusinessDevelopmentConversationsQuery({applicationId:e}),[u]=useLazyGetV4PartnerByApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),{handleSubmitToBot:d,botMessages:f,botReady:p,isProcessingSubmission:m}=useAIAssistant({userId:e,apiKey:n});React.useEffect(()=>{if(!l)return;const G={partner1:[e,ASSISTANT_ID].sort()[0],partner2:[e,ASSISTANT_ID].sort()[1],name:"Randmar Assistant",unread:0,pending:!1,historyFetched:!0,messages:[],conversationID:-1},K=l.map(J=>{var ee;return{partner1:[J.Participant1,J.Participant2].sort()[0],partner2:[J.Participant1,J.Participant2].sort()[1],name:((ee=J.Participant)==null?void 0:ee.PublicName)??"missing public name",unread:0,pending:J.Status!="Approved",historyFetched:!1,messages:[],conversationID:J.ConversationId}});setTimeout(()=>{var J;return(J=L.current)==null?void 0:J.focus()},50),M([G,...K])},[l]);const[g,b]=React.useState("all"),[_,R]=React.useState([[e,ASSISTANT_ID].sort()[0],[e,ASSISTANT_ID].sort()[1]]),[E,S]=React.useState(""),[C,T]=React.useState(null),[A,M]=React.useState([]),[I,O]=React.useState(""),[N,j]=React.useState(null),D=React.useRef(null),F=React.useRef(null),L=i||F,B=A.filter(G=>{const K=G.name.toLowerCase().includes(I.toLowerCase());return g==="all"?K:g==="approved"?K&&!G.pending:g==="pending"?K&&G.pending:K});React.useEffect(()=>{const G=f.at(-1);if(!G||G.role!="assistant"||G.isComponent)return;const K={id:G.timestamp.toString(),fromPartnerID:ASSISTANT_ID,toPartnerID:e,senderName:"Assistant",timestamp:G.timestamp.getTime(),content:G.content};V(K)},[f]);function V(G){const K=[G.fromPartnerID,G.toPartnerID];K.sort(),M(J=>{let ee=!1,ne=!1;const ae=J.map(oe=>oe.partner1!==K[0]||oe.partner2!==K[1]||(ne=!0,oe.messages.findIndex(se=>se.id==G.id)!==-1)?oe:(ee=!0,{...oe,unread:oe.unread+1,messages:[...oe.messages,G]}));return!ne&&K[0]!==e&&K[1]!==e?(console.log("(bug) server sent a message to us by mistake."),ae):(ee&&T([K[0],K[1]]),ae)})}React.useEffect(()=>{const G=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return G.on("ReceiveMessage",V),G.start().catch(K=>console.error("Error connecting to SignalR hub:",K)),j(G),()=>{G&&G.stop()}},[e]),React.useEffect(()=>{(C==null?void 0:C[0])!==(_==null?void 0:_[0])||(C==null?void 0:C[1])!==(_==null?void 0:_[1])||(M(G=>G.map(K=>K.partner1===(_==null?void 0:_[0])&&K.partner2===(_==null?void 0:_[1])?{...K,unread:0}:K)),setTimeout(()=>{var G;return(G=D.current)==null?void 0:G.scrollIntoView({behavior:"smooth"})},50))},[C,_]),React.useEffect(()=>{var K;if(!_)return;const G=getActiveChatObject(A,_);G&&((K=L.current)==null||K.focus(),G.historyFetched?(M(J=>J.map(ee=>ee.partner1===_[0]&&ee.partner2===_[1]?{...ee,unread:0}:ee)),setTimeout(()=>{var J;return(J=D.current)==null?void 0:J.scrollIntoView({behavior:"smooth"})},50)):u({applicationId:e,conversationId:G.conversationID}).unwrap().then(J=>{const ee=J.map(ne=>({id:"history"+ne.MessageId,fromPartnerID:ne.SenderId,toPartnerID:ne.SenderId==_[0]?_[1]:_[0],senderName:ne.SenderName??"missing name",timestamp:new Date(ne.SentDate+"Z").getTime(),content:ne.Content??"no content"}));M(ne=>ne.map(ae=>ae.partner1===_[0]&&ae.partner2===_[1]?{...ae,messages:ee,historyFetched:!0}:ae)),setTimeout(()=>{var ne;return(ne=D.current)==null?void 0:ne.scrollIntoView({behavior:"smooth"})},100)}).catch(J=>{console.error("Error fetching conversation messages:",J)}))},[_,u,e]);const H=(G,K,J)=>{const ee={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:K[0]===e?K[1]:K[0],content:G,timestamp:Date.now()};M(ne=>ne.map(ae=>ae.partner1===K[0]&&ae.partner2===K[1]?{...ae,messages:[...ae.messages,ee]}:ae)),T([K[0],K[1]]),ee.toPartnerID==ASSISTANT_ID?d(ee.content):J.invoke("NewMessage",ee).catch(ne=>console.error("Error sending message:",ne)),S("")},z=(G,K)=>{if(!A.length||!N||!p)return!1;const J=A.find(ee=>ee.conversationID===G);return J?(R([J.partner1,J.partner2]),K&&setTimeout(()=>H(K,[J.partner1,J.partner2],N),100),!0):!1};if(React.useImperativeHandle(o,()=>({setActiveChatAndSendMessage:z})),!p)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"flex items-center justify-center p-8",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})})});const U=()=>{!E.trim()||!_||!N||H(E,_,N)};return jsxRuntime.jsxs("div",{className:"flex h-[80vh] overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"w-[260px] p-4 pt-3 flex flex-col border-r",children:[jsxRuntime.jsx("div",{className:"p-4 font-semibold border-b",children:"Communications"}),A.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Search,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx(Input,{placeholder:"Search chats...",className:"pl-8 h-9",value:I,onChange:G=>O(G.target.value)})]})}),jsxRuntime.jsx(Tabs,{value:g,onValueChange:b,className:"w-full mb-1",children:jsxRuntime.jsxs(TabsList,{className:"grid grid-cols-8 h-9 mx-2",children:[jsxRuntime.jsx(TabsTrigger,{value:"all",className:"text-xs col-span-2",children:"All"}),jsxRuntime.jsx(TabsTrigger,{value:"approved",className:"text-xs col-span-3",children:"Approved"}),jsxRuntime.jsx(TabsTrigger,{value:"pending",className:"text-xs col-span-3",children:"Pending"})]})})]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1",children:A.length&&jsxRuntime.jsx(ChatList,{userId:e,chats:B.filter(G=>G.partner1!=ASSISTANT_ID&&G.partner2!=ASSISTANT_ID),activeChat:getActiveChatObject(A,_)??null,onSelectChat:R,assistantChat:A.find(G=>G.partner1==ASSISTANT_ID||G.partner2==ASSISTANT_ID)})})]}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col",children:_?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:_[0]==ASSISTANT_ID||_[1]==ASSISTANT_ID?jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AvatarImage,{src:`https://api.randmar.io/v4/Partner/${_[0]===e?_[1]:_[0]}/Account/Logo?height=72&width=72`,className:" object-contain "}),jsxRuntime.jsx(AvatarFallback,{children:jsxRuntime.jsx(Handshake,{className:"text-primary fill-white min-h-full"})})]})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:(Q=getActiveChatObject(A,_))==null?void 0:Q.name}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"ml-auto hidden",children:jsxRuntime.jsx(EllipsisVertical,{className:"h-5 w-5"})})]}),(q=getActiveChatObject(A,_))!=null&&q.pending?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is still awaiting approval — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 p-4 bg-slate-50",children:[jsxRuntime.jsx(ChatMessages,{messages:((W=getActiveChatObject(A,_))==null?void 0:W.messages)??[],currentUserId:e,isWaitingForBot:m&&_&&(_[0]===ASSISTANT_ID||_[1]===ASSISTANT_ID)}),jsxRuntime.jsx("div",{ref:D})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t flex",children:[jsxRuntime.jsx(Input,{ref:L,placeholder:"Type a message...",value:E,onChange:G=>S(G.target.value),onKeyDown:G=>G.key==="Enter"&&U(),className:"flex-1"}),jsxRuntime.jsx(Button,{size:"icon",variant:"default",className:"ml-1",disabled:m,onClick:U,children:jsxRuntime.jsx(Send,{className:"h-4 w-4"})})]})]})]}):jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a chat to start messaging"})})]})});function getActiveChatObject(e,t){return e.find(n=>n.partner1==(t==null?void 0:t[0])&&n.partner2==(t==null?void 0:t[1]))}const Card=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("rounded-md border bg-card text-card-foreground shadow-sm",e),...t}));Card.displayName="Card";const CardHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex flex-col space-y-1.5 p-6",e),...t}));CardHeader.displayName="CardHeader";const CardTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("font-semibold leading-none tracking-tight",e),...t}));CardTitle.displayName="CardTitle";const CardDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));CardDescription.displayName="CardDescription";const CardContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("p-6 pt-0",e),...t}));CardContent.displayName="CardContent";const CardFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex items-center p-6 pt-0",e),...t}));CardFooter.displayName="CardFooter";function PartnerCard({id:e,name:t,about:n,voiceName:i,voiceStyle:o,sceneName:l,action:u,loading:d=!1}){const f=`https://api.randmar.io/V4/Partner/${e}/Account/Video`,p=`https://api.randmar.io/V4/Partner/${e}/Account/Video/Exists`,m=`https://api.randmar.io/V4/Partner/${e}/Account/Logo?width=64&height=64`,g=`https://api.randmar.io/V4/Partner/${e}/Account/Logo/Exists`,b=!!(i||o||l),[_,R]=React.useState(null),[E,S]=React.useState(!1),[C,T]=React.useState(!1),[A,M]=React.useState(!1),[I,O]=React.useState(!0);React.useEffect(()=>{if(!e||d)return;const j=async()=>{try{const B=await fetch(g);if(B.ok){const H=(await B.text()).toLowerCase()==="true";return T(H),H}return!1}catch(B){return console.error("Failed to check if logo exists:",B),T(!1),!1}},D=async()=>{S(!0);try{const B=await fetch(m);if(B.ok){const V=await B.blob();R(URL.createObjectURL(V))}}catch(B){console.error("Failed to load logo:",B)}finally{S(!1)}},F=async()=>{try{const B=await fetch(p);if(B.ok){const V=await B.text();M(V.toLowerCase()==="true")}}catch(B){console.error("Failed to check if video exists:",B),M(!1)}};(async()=>{await j()&&D(),F()})()},[e,m,g,p,d]);const N=()=>{O(!1)};return d?jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"})}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})]}),jsxRuntime.jsx("div",{className:"w-full sm:w-auto",children:jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-5/6"})]}),jsxRuntime.jsx("div",{className:"mt-4 p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]}),jsxRuntime.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsx("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full"})})})]})]})}):jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[C&&jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:E?jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"}):_&&jsxRuntime.jsx("img",{src:_||"/placeholder.svg",alt:`${t} logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t})]}),u&&jsxRuntime.jsx("div",{className:"w-full sm:w-auto",children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",children:[jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:n}}),b&&jsxRuntime.jsx("div",{className:"mt-4 p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[i&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:i})]}),o&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:o})]}),l&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:l})]})]})})]}),A&&jsxRuntime.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsxs("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:[I&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:f,controls:!0,preload:"auto",playsInline:!0,className:`w-full h-full object-contain ${I?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:N,onError:()=>O(!1)})]})})]})]})})}const Topbar=React.forwardRef(({onSignOut:e,handleValidSearch:t,rightMenu:n,searchPlaceholder:i},o)=>{const[l,u]=React.useState(""),d=reactRouterDom.useLocation(),{toast:f}=useToast();React.useEffect(()=>{const b=new URLSearchParams(d.search).get("q");b&&u(b)},[d.search]);const p=()=>{const g=l.trim();if(!g||g.length<2){f({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}t(g)},m=g=>{g.key==="Enter"&&p()};return jsxRuntime.jsxs("header",{className:"flex h-16 items-center gap-4 border-b sidebar-foreground bg-sidebar px-6 fixed top-0 right-0 z-50 lg:left-64 left-0 border-sidebar-border",children:[jsxRuntime.jsx(SidebarTrigger,{className:"lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-6 w-6"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-2 top-1/2 -translate-y-1/2",onClick:p,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:i??"Search...",className:"w-full pl-8 bg-white text-black",value:l,onChange:g=>u(g.target.value),onKeyDown:m,ref:o},"topbar-search")]})})}),n||jsxRuntime.jsx(jsxRuntime.Fragment,{}),e&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs(Button,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:e,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-sidebar-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})});Topbar.displayName="Topbar";const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:i,children:o,...l},u)=>jsxRuntime.jsxs("div",{ref:u,className:cn(badgeVariants({variant:t,size:n}),e),...l,children:[i&&jsxRuntime.jsx("span",{className:"mr-1",children:i}),o]}));Badge.displayName="Badge";const CountryFlag=({countryCode:e,className:t=""})=>{const[n,i]=React.useState(null),[o,l]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const d=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(d,{method:"HEAD"}).then(f=>{f.ok?(i(d),l(!1)):l(!0)}).catch(()=>{l(!0)})},[e]),o||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})},Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,withRandmarAssistant:i,chatUserName:o,chatApiKey:l},u)=>{const{appID:d}=reactRouterDom.useParams(),f=e.filter(b=>b.showInNav),p=React.useRef(null),m=React.useRef(null),g=React.useRef(null);return React.useImperativeHandle(u,()=>({setActiveChatAndSendMessage:(b,_)=>{var R;return(R=g.current)==null||R.click(),setTimeout(()=>{var E;(E=p.current)==null||E.focus(),m.current&&m.current.setActiveChatAndSendMessage(b,_)},100),!0}})),jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx("img",{src:"https://api.randmar.io/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsx(SidebarMenu,{children:f.map(b=>{const _=b.icon,R=`/${b.path.replace(":appID",d??"")}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:R,className:"transition-colors hover:bg-muted px-6",children:[_&&jsxRuntime.jsx(_,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:b.label})]})})},b.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[i===!0&&jsxRuntime.jsxs(Dialog,{children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:g,size:"lg",className:"collapse md:visible",onClick:()=>setTimeout(()=>{var b;return(b=p.current)==null?void 0:b.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(DialogContent,{className:"max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,children:jsxRuntime.jsx(ChatLayout,{ref:m,inputRef:p,userId:d??"2",userName:o??"Unknown user",apiKey:l??""})})]}),t]})]})}),Layout=React.forwardRef(({children:e,rightMenu:t,routes:n,footer:i,handleValidSearch:o,dashboardTitle:l,onSignOut:u,searchPlaceholder:d,withRandmarAssistant:f,chatUserName:p,chatApiKey:m,chatRef:g},b)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{routes:n,footer:i,dashboardTitle:l,withRandmarAssistant:f,chatUserName:p,chatApiKey:m,ref:g}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:b,onSignOut:u,rightMenu:t,handleValidSearch:o,searchPlaceholder:d}),jsxRuntime.jsx("main",{className:"flex-1 overflow-auto mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:i}){const[o,l]=React__namespace.useState(!1),[u,d]=React__namespace.useState(!1),[f,p]=React__namespace.useState(!1),[m,g]=React__namespace.useState(!1),b=`https://api.randmar.io/Product/${e}/Video`;React__namespace.useEffect(()=>{(async()=>{try{const A=await(await fetch(b+"/Exists")).json();d(A)}catch(T){console.error("Error checking for video:",T),d(!1)}})()},[e,b]);async function _(){if(u){g(!0);try{const T=await(await fetch(b)).blob(),A=window.URL.createObjectURL(T),M=document.createElement("a");M.href=A,M.download=`${e||"product"}-video.mp4`,document.body.appendChild(M),M.click(),document.body.removeChild(M),window.URL.revokeObjectURL(A)}catch(C){console.error("Error downloading video:",C)}finally{g(!1)}}}function R(){navigator.clipboard.writeText(b),p(!0),setTimeout(()=>{p(!1)},2e3)}function E(){l(!0)}const S=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:o,onOpenChange:l,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:i?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:b,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:i})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:b,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:R,children:f?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:_,disabled:m,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${u?"cursor-pointer":""}`,onClick:u?E:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${S*1.5}&height=${S*1.5}`,width:S,height:S}),u&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:E,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ProductCard({item:e,addToCart:t=!1,syncToShopify:n=!1,customAction:i=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:o="",viewProductAction:l,addToCartAction:u,isAddToCartActionLoading:d=!1,syncToShopifyAction:f,isSyncToShopifyActionLoading:p=!1}){var W,G,K,J,ee,ne,ae,oe,se,ce,ie,ue;const[m,g]=React.useState(1),[b,_]=React.useState(null),[R,E]=React.useState(0),[S,C]=React.useState(!1),T=((W=e==null?void 0:e.Distribution)==null?void 0:W.Cost)||0,A=((G=e==null?void 0:e.Distribution)==null?void 0:G.RegularPrice)||0,M=((K=e==null?void 0:e.Distribution)==null?void 0:K.Price)||0,[I,O]=React.useState(null),[N,j]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){j(!0);try{const Z=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(Z.ok){const fe=await Z.blob();O(URL.createObjectURL(fe))}}catch(Z){console.error("Failed to load logo:",Z)}finally{j(!1)}}};e!=null&&e.ManufacturerId&&le()},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var le;if(e&&o){const Z=(le=e.Opportunities)==null?void 0:le.find(fe=>fe.BidNumber==o);Z&&_(Z)}},[e,o]),React.useEffect(()=>{if(!e)return;const le=b!=null&&b.Price?b.Price:M;E(A>0?Math.round((A-le)/A*100):0)},[e,b,M,A]),React.useEffect(()=>{d||g(1)},[d]);const D=le=>{if(le.Active!==!0)return!1;const Z=new Date().toISOString().split("T")[0];return!(le.EndDate&&le.EndDate<Z||le.StartDate&&le.StartDate>Z)};if(!e)return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const F=(e==null?void 0:e.Opportunities)||[],L=F.length>0,B=()=>{if(m==null){g(1);return}m>1&&g(m-1)},V=()=>{if(m==null){g(1);return}g(m+1)},H=le=>{const Z=parseInt(le.target.value,10);if(!isNaN(Z)&&Z>0){g(Z);return}g(void 0)},z=()=>{(m==null||m<1)&&g(1)},U=((ee=(J=e.Distribution)==null?void 0:J.Inventory)==null?void 0:ee.reduce((le,Z)=>le+(Z.AvailableQuantity||0),0))||0,Q=le=>{try{return new Date(le).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(Z){return console.error(Z),le.split("T")[0]||"N/A"}},q=()=>{u&&u({quantity:m??1,bidNumber:(b==null?void 0:b.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:N?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):I&&jsxRuntime.jsx("img",{src:I||"/placeholder.svg",alt:e.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy===void 0?jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(ne=e.ManufacturerCategory)!=null&&ne.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(ae=e.ManufacturerCategory)!=null&&ae.QualificationRequired?"Qualification Enforced":"No Qualification Needed"]}):jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(oe=e.ManufacturerCategory)!=null&&oe.QualificationRequired?e.AvailableToBuy?"Qualified":"Not Qualified":"No Qualification Required"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UnitWeight?`${e.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MAP?"$"+e.MAP.toFixed(2):"N/A"})]}),e.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:L&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+F.length+(F.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:F.map((le,Z)=>{var fe;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
865
|
+
REPEAT: For ANY API function that requires an ID in the path, USE "${e}" as the value unless the user has given you another one.`,A=C.startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Please introduce yourself"}]},{role:"model",parts:[{text:T}]}],tools:f.length>0?[{functionDeclarations:f.map(({declaration:M})=>M)}]:[]});l(A)}catch(C){console.error("Error initializing chat:",C)}};o||m||S()},[m,o]),React.useEffect(()=>{(async()=>{try{const C=await fetchApiFunctions(e);p(C)}catch(C){console.error("Error loading API functions:",C)}finally{g(!1)}})()},[e]);const _=Object.fromEntries(f.map(({declaration:S,handler:C})=>[S.name,C])),R=async S=>{var T,A;const C=S.name;if(C in _){const M=_[C],I=S.args||{};console.log(`[Function Call] ${C} with args:`,I);const O=(T=f.find(D=>D.declaration.name===C))==null?void 0:T.declaration;if(!O){console.error(`[Function Call] Could not find declaration for ${C}`);return}const N=Object.keys(((A=O.parameters)==null?void 0:A.properties)||{});console.log("[Function Call] Parameter names from declaration:",N);const j=[];N.forEach(D=>{if(D.toLowerCase().includes("id")||D.toLowerCase().includes("reseller")||D.toLowerCase().includes("manufacturer")||D.toLowerCase().includes("partner")||D.toLowerCase().includes("application"))j.push("");else if(D in I){const L=I[D];typeof L=="object"?j.push(JSON.stringify(L)):j.push(typeof L=="string"?L:String(L))}else j.push("")}),console.log("[Function Call] Converted args to:",j);try{const D=await M(j);let F,L=null,B=!1;if(typeof D=="string"?F=D:(F=D.summary,L=D.component,B=!0),console.log(`[Function Response] ${C} returned:`,F),o){const V={functionResponse:{name:C,response:{content:F}}};if(B&&L){const U={role:"assistant",content:L,timestamp:new Date,isComponent:!0};d(Q=>[...Q,U])}const z={role:"assistant",content:(await o.sendMessage([V])).response.text(),timestamp:new Date};d(U=>[...U,z])}}catch(D){console.error("Error executing function:",D);const F={role:"assistant",content:"I encountered an error while processing your request. Please try again.",timestamp:new Date};d(L=>[...L,F])}}else console.error(`Function ${C} not found`)};return{handleSubmitToBot:async S=>{if(S.trim()&&!n&&o){const C={role:"user",content:S,timestamp:new Date};d(T=>[...T,C]),i(!0);try{const A=(await o.sendMessage(S.trim())).response,M=A.functionCalls();if(M&&M.length>0)for(const I of M)await R(I);else{const I={role:"assistant",content:A.text(),timestamp:new Date};d(O=>[...O,I])}}catch(T){console.error("Error sending message:",T);const A={role:"assistant",content:"I'm sorry, I encountered an error processing your request. Please try again later.",timestamp:new Date};d(M=>[...M,A])}finally{i(!1)}}},botMessages:u,botReady:!!o,isProcessingSubmission:n}}const ASSISTANT_ID="RandmarAIChatAssistant",ChatLayout=React.forwardRef(({userId:e,userName:t,apiKey:n,inputRef:i},o)=>{var Q,q,W;const{data:l}=useGetV4PartnerByApplicationIdBusinessDevelopmentConversationsQuery({applicationId:e}),[u]=useLazyGetV4PartnerByApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),{handleSubmitToBot:d,botMessages:f,botReady:p,isProcessingSubmission:m}=useAIAssistant({userId:e,apiKey:n});React.useEffect(()=>{if(!l)return;const G={partner1:[e,ASSISTANT_ID].sort()[0],partner2:[e,ASSISTANT_ID].sort()[1],name:"Randmar Assistant",unread:0,pending:!1,historyFetched:!0,messages:[],conversationID:-1},K=l.map(J=>{var ee;return{partner1:[J.Participant1,J.Participant2].sort()[0],partner2:[J.Participant1,J.Participant2].sort()[1],name:((ee=J.Participant)==null?void 0:ee.PublicName)??"missing public name",unread:0,pending:J.Status!="Approved",historyFetched:!1,messages:[],conversationID:J.ConversationId}});setTimeout(()=>{var J;return(J=L.current)==null?void 0:J.focus()},50),M([G,...K])},[l]);const[g,b]=React.useState("all"),[_,R]=React.useState([[e,ASSISTANT_ID].sort()[0],[e,ASSISTANT_ID].sort()[1]]),[E,S]=React.useState(""),[C,T]=React.useState(null),[A,M]=React.useState([]),[I,O]=React.useState(""),[N,j]=React.useState(null),D=React.useRef(null),F=React.useRef(null),L=i||F,B=A.filter(G=>{const K=G.name.toLowerCase().includes(I.toLowerCase());return g==="all"?K:g==="approved"?K&&!G.pending:g==="pending"?K&&G.pending:K});React.useEffect(()=>{const G=f.at(-1);if(!G||G.role!="assistant"||G.isComponent)return;const K={id:G.timestamp.toString(),fromPartnerID:ASSISTANT_ID,toPartnerID:e,senderName:"Assistant",timestamp:G.timestamp.getTime(),content:G.content};V(K)},[f]);function V(G){const K=[G.fromPartnerID,G.toPartnerID];K.sort(),M(J=>{let ee=!1,ne=!1;const ae=J.map(oe=>oe.partner1!==K[0]||oe.partner2!==K[1]||(ne=!0,oe.messages.findIndex(se=>se.id==G.id)!==-1)?oe:(ee=!0,{...oe,unread:oe.unread+1,messages:[...oe.messages,G]}));return!ne&&K[0]!==e&&K[1]!==e?(console.log("(bug) server sent a message to us by mistake."),ae):(ee&&T([K[0],K[1]]),ae)})}React.useEffect(()=>{const G=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return G.on("ReceiveMessage",V),G.start().catch(K=>console.error("Error connecting to SignalR hub:",K)),j(G),()=>{G&&G.stop()}},[e]),React.useEffect(()=>{(C==null?void 0:C[0])!==(_==null?void 0:_[0])||(C==null?void 0:C[1])!==(_==null?void 0:_[1])||(M(G=>G.map(K=>K.partner1===(_==null?void 0:_[0])&&K.partner2===(_==null?void 0:_[1])?{...K,unread:0}:K)),setTimeout(()=>{var G;return(G=D.current)==null?void 0:G.scrollIntoView({behavior:"smooth"})},50))},[C,_]),React.useEffect(()=>{var K;if(!_)return;const G=getActiveChatObject(A,_);G&&((K=L.current)==null||K.focus(),G.historyFetched?(M(J=>J.map(ee=>ee.partner1===_[0]&&ee.partner2===_[1]?{...ee,unread:0}:ee)),setTimeout(()=>{var J;return(J=D.current)==null?void 0:J.scrollIntoView({behavior:"smooth"})},50)):u({applicationId:e,conversationId:G.conversationID}).unwrap().then(J=>{const ee=J.map(ne=>({id:"history"+ne.MessageId,fromPartnerID:ne.SenderId,toPartnerID:ne.SenderId==_[0]?_[1]:_[0],senderName:ne.SenderName??"missing name",timestamp:new Date(ne.SentDate+"Z").getTime(),content:ne.Content??"no content"}));M(ne=>ne.map(ae=>ae.partner1===_[0]&&ae.partner2===_[1]?{...ae,messages:ee,historyFetched:!0}:ae)),setTimeout(()=>{var ne;return(ne=D.current)==null?void 0:ne.scrollIntoView({behavior:"smooth"})},100)}).catch(J=>{console.error("Error fetching conversation messages:",J)}))},[_,u,e]);const H=(G,K,J)=>{const ee={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:K[0]===e?K[1]:K[0],content:G,timestamp:Date.now()};M(ne=>ne.map(ae=>ae.partner1===K[0]&&ae.partner2===K[1]?{...ae,messages:[...ae.messages,ee]}:ae)),T([K[0],K[1]]),ee.toPartnerID==ASSISTANT_ID?d(ee.content):J.invoke("NewMessage",ee).catch(ne=>console.error("Error sending message:",ne)),S("")},z=(G,K)=>{if(!A.length||!N||!p)return!1;const J=A.find(ee=>ee.conversationID===G);return J?(R([J.partner1,J.partner2]),K&&setTimeout(()=>H(K,[J.partner1,J.partner2],N),100),!0):!1};if(React.useImperativeHandle(o,()=>({setActiveChatAndSendMessage:z})),!p)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"flex items-center justify-center p-8",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})})});const U=()=>{!E.trim()||!_||!N||H(E,_,N)};return jsxRuntime.jsxs("div",{className:"flex h-[80vh] overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"w-[260px] p-4 pt-3 flex flex-col border-r",children:[jsxRuntime.jsx("div",{className:"p-4 font-semibold border-b",children:"Communications"}),A.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Search,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx(Input,{placeholder:"Search chats...",className:"pl-8 h-9",value:I,onChange:G=>O(G.target.value)})]})}),jsxRuntime.jsx(Tabs,{value:g,onValueChange:b,className:"w-full mb-1",children:jsxRuntime.jsxs(TabsList,{className:"grid grid-cols-8 h-9 mx-2",children:[jsxRuntime.jsx(TabsTrigger,{value:"all",className:"text-xs col-span-2",children:"All"}),jsxRuntime.jsx(TabsTrigger,{value:"approved",className:"text-xs col-span-3",children:"Approved"}),jsxRuntime.jsx(TabsTrigger,{value:"pending",className:"text-xs col-span-3",children:"Pending"})]})})]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1",children:A.length&&jsxRuntime.jsx(ChatList,{userId:e,chats:B.filter(G=>G.partner1!=ASSISTANT_ID&&G.partner2!=ASSISTANT_ID),activeChat:getActiveChatObject(A,_)??null,onSelectChat:R,assistantChat:A.find(G=>G.partner1==ASSISTANT_ID||G.partner2==ASSISTANT_ID)})})]}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col",children:_?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:_[0]==ASSISTANT_ID||_[1]==ASSISTANT_ID?jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AvatarImage,{src:`https://api.randmar.io/v4/Partner/${_[0]===e?_[1]:_[0]}/Account/Logo?height=72&width=72`,className:" object-contain "}),jsxRuntime.jsx(AvatarFallback,{children:jsxRuntime.jsx(Handshake,{className:"text-primary fill-white min-h-full"})})]})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:(Q=getActiveChatObject(A,_))==null?void 0:Q.name}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"ml-auto hidden",children:jsxRuntime.jsx(EllipsisVertical,{className:"h-5 w-5"})})]}),(q=getActiveChatObject(A,_))!=null&&q.pending?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is still awaiting approval — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 p-4 bg-slate-50",children:[jsxRuntime.jsx(ChatMessages,{messages:((W=getActiveChatObject(A,_))==null?void 0:W.messages)??[],currentUserId:e,isWaitingForBot:m&&_&&(_[0]===ASSISTANT_ID||_[1]===ASSISTANT_ID)}),jsxRuntime.jsx("div",{ref:D})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t flex",children:[jsxRuntime.jsx(Input,{ref:L,placeholder:"Type a message...",value:E,onChange:G=>S(G.target.value),onKeyDown:G=>G.key==="Enter"&&U(),className:"flex-1"}),jsxRuntime.jsx(Button,{size:"icon",variant:"default",className:"ml-1",disabled:m,onClick:U,children:jsxRuntime.jsx(Send,{className:"h-4 w-4"})})]})]})]}):jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a chat to start messaging"})})]})});function getActiveChatObject(e,t){return e.find(n=>n.partner1==(t==null?void 0:t[0])&&n.partner2==(t==null?void 0:t[1]))}const Card=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("rounded-md border bg-card text-card-foreground shadow-sm",e),...t}));Card.displayName="Card";const CardHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex flex-col space-y-1.5 p-6",e),...t}));CardHeader.displayName="CardHeader";const CardTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("font-semibold leading-none tracking-tight",e),...t}));CardTitle.displayName="CardTitle";const CardDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));CardDescription.displayName="CardDescription";const CardContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("p-6 pt-0",e),...t}));CardContent.displayName="CardContent";const CardFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex items-center p-6 pt-0",e),...t}));CardFooter.displayName="CardFooter";function PartnerCard({id:e,name:t,about:n,voiceName:i,voiceStyle:o,sceneName:l,action:u,loading:d=!1}){const f=`https://api.randmar.io/V4/Partner/${e}/Account/Video`,p=`https://api.randmar.io/V4/Partner/${e}/Account/Video/Exists`,m=`https://api.randmar.io/V4/Partner/${e}/Account/Logo?width=64&height=64`,g=`https://api.randmar.io/V4/Partner/${e}/Account/Logo/Exists`,b=!!(i||o||l),[_,R]=React.useState(null),[E,S]=React.useState(!1),[C,T]=React.useState(!1),[A,M]=React.useState(!1),[I,O]=React.useState(!0);React.useEffect(()=>{if(!e||d)return;const j=async()=>{try{const B=await fetch(g);if(B.ok){const H=(await B.text()).toLowerCase()==="true";return T(H),H}return!1}catch(B){return console.error("Failed to check if logo exists:",B),T(!1),!1}},D=async()=>{S(!0);try{const B=await fetch(m);if(B.ok){const V=await B.blob();R(URL.createObjectURL(V))}}catch(B){console.error("Failed to load logo:",B)}finally{S(!1)}},F=async()=>{try{const B=await fetch(p);if(B.ok){const V=await B.text();M(V.toLowerCase()==="true")}}catch(B){console.error("Failed to check if video exists:",B),M(!1)}};(async()=>{await j()&&D(),F()})()},[e,m,g,p,d]);const N=()=>{O(!1)};return d?jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"})}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})]}),jsxRuntime.jsx("div",{className:"w-full sm:w-auto",children:jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-5/6"})]}),jsxRuntime.jsx("div",{className:"mt-4 p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]}),jsxRuntime.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsx("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full"})})})]})]})}):jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[C&&jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:E?jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"}):_&&jsxRuntime.jsx("img",{src:_||"/placeholder.svg",alt:`${t} logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t})]}),u&&jsxRuntime.jsx("div",{className:"w-full sm:w-auto",children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",children:[jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:n}}),b&&jsxRuntime.jsx("div",{className:"mt-4 p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[i&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:i})]}),o&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:o})]}),l&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:l})]})]})})]}),A&&jsxRuntime.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsxs("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:[I&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:f,controls:!0,preload:"auto",playsInline:!0,className:`w-full h-full object-contain ${I?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:N,onError:()=>O(!1)})]})})]})]})})}const Topbar=React.forwardRef(({onSignOut:e,handleValidSearch:t,rightMenu:n,searchPlaceholder:i},o)=>{const[l,u]=React.useState(""),d=reactRouterDom.useLocation(),{toast:f}=useToast();React.useEffect(()=>{const b=new URLSearchParams(d.search).get("q");b&&u(b)},[d.search]);const p=()=>{const g=l.trim();if(!g||g.length<2){f({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}t(g)},m=g=>{g.key==="Enter"&&p()};return jsxRuntime.jsxs("header",{className:"flex h-16 items-center gap-4 border-b sidebar-foreground bg-sidebar px-6 fixed top-0 right-0 z-50 lg:left-64 left-0 border-sidebar-border",children:[jsxRuntime.jsx(SidebarTrigger,{className:"lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-6 w-6"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-2 top-1/2 -translate-y-1/2",onClick:p,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:i??"Search...",className:"w-full pl-8 bg-white text-black",value:l,onChange:g=>u(g.target.value),onKeyDown:m,ref:o},"topbar-search")]})})}),n||jsxRuntime.jsx(jsxRuntime.Fragment,{}),e&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs(Button,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:e,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-sidebar-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})});Topbar.displayName="Topbar";const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:i,children:o,...l},u)=>jsxRuntime.jsxs("div",{ref:u,className:cn(badgeVariants({variant:t,size:n}),e),...l,children:[i&&jsxRuntime.jsx("span",{className:"mr-1",children:i}),o]}));Badge.displayName="Badge";const CountryFlag=({countryCode:e,className:t=""})=>{const[n,i]=React.useState(null),[o,l]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const d=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(d,{method:"HEAD"}).then(f=>{f.ok?(i(d),l(!1)):l(!0)}).catch(()=>{l(!0)})},[e]),o||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})},Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,withRandmarAssistant:i,chatUserName:o,chatApiKey:l},u)=>{const{appID:d}=reactRouterDom.useParams(),f=e.filter(b=>b.showInNav),p=React.useRef(null),m=React.useRef(null),g=React.useRef(null);return React.useImperativeHandle(u,()=>({setActiveChatAndSendMessage:(b,_)=>{var R;return(R=g.current)==null||R.click(),setTimeout(()=>{var E;(E=p.current)==null||E.focus(),m.current&&m.current.setActiveChatAndSendMessage(b,_)},100),!0}})),jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx("img",{src:"https://api.randmar.io/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsx(SidebarMenu,{children:f.map(b=>{const _=b.icon,R=`/${b.path.replace(":appID",d??"")}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:R,className:"transition-colors hover:bg-muted px-6",children:[_&&jsxRuntime.jsx(_,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:b.label})]})})},b.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[i===!0&&jsxRuntime.jsxs(Dialog,{children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:g,size:"lg",className:"collapse md:visible",onClick:()=>setTimeout(()=>{var b;return(b=p.current)==null?void 0:b.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(DialogContent,{className:"max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,children:jsxRuntime.jsx(ChatLayout,{ref:m,inputRef:p,userId:d??"2",userName:o??"Unknown user",apiKey:l??""})})]}),t]})]})}),Layout=React.forwardRef(({children:e,rightMenu:t,routes:n,footer:i,handleValidSearch:o,dashboardTitle:l,onSignOut:u,searchPlaceholder:d,withRandmarAssistant:f,chatUserName:p,chatApiKey:m,chatRef:g},b)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{routes:n,footer:i,dashboardTitle:l,withRandmarAssistant:f,chatUserName:p,chatApiKey:m,ref:g}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:b,onSignOut:u,rightMenu:t,handleValidSearch:o,searchPlaceholder:d}),jsxRuntime.jsx("main",{className:"flex-1 overflow-auto mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:i}){const[o,l]=React__namespace.useState(!1),[u,d]=React__namespace.useState(!1),[f,p]=React__namespace.useState(!1),[m,g]=React__namespace.useState(!1),b=`https://api.randmar.io/Product/${e}/Video`;React__namespace.useEffect(()=>{(async()=>{try{const A=await(await fetch(b+"/Exists")).json();d(A)}catch(T){console.error("Error checking for video:",T),d(!1)}})()},[e,b]);async function _(){if(u){g(!0);try{const T=await(await fetch(b)).blob(),A=window.URL.createObjectURL(T),M=document.createElement("a");M.href=A,M.download=`${e||"product"}-video.mp4`,document.body.appendChild(M),M.click(),document.body.removeChild(M),window.URL.revokeObjectURL(A)}catch(C){console.error("Error downloading video:",C)}finally{g(!1)}}}function R(){navigator.clipboard.writeText(b),p(!0),setTimeout(()=>{p(!1)},2e3)}function E(){l(!0)}const S=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:o,onOpenChange:l,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:i?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:b,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:i})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:b,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:R,children:f?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:_,disabled:m,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${u?"cursor-pointer":""}`,onClick:u?E:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${S*1.5}&height=${S*1.5}`,width:S,height:S}),u&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:E,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ProductCard({item:e,addToCart:t=!1,syncToShopify:n=!1,customAction:i=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:o="",viewProductLink:l,addToCartAction:u,isAddToCartActionLoading:d=!1,syncToShopifyAction:f,isSyncToShopifyActionLoading:p=!1}){var W,G,K,J,ee,ne,ae,oe,se,ce,ie,ue;const[m,g]=React.useState(1),[b,_]=React.useState(null),[R,E]=React.useState(0),[S,C]=React.useState(!1),T=((W=e==null?void 0:e.Distribution)==null?void 0:W.Cost)||0,A=((G=e==null?void 0:e.Distribution)==null?void 0:G.RegularPrice)||0,M=((K=e==null?void 0:e.Distribution)==null?void 0:K.Price)||0,[I,O]=React.useState(null),[N,j]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){j(!0);try{const Z=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(Z.ok){const fe=await Z.blob();O(URL.createObjectURL(fe))}}catch(Z){console.error("Failed to load logo:",Z)}finally{j(!1)}}};e!=null&&e.ManufacturerId&&le()},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var le;if(e&&o){const Z=(le=e.Opportunities)==null?void 0:le.find(fe=>fe.BidNumber==o);Z&&_(Z)}},[e,o]),React.useEffect(()=>{if(!e)return;const le=b!=null&&b.Price?b.Price:M;E(A>0?Math.round((A-le)/A*100):0)},[e,b,M,A]),React.useEffect(()=>{d||g(1)},[d]);const D=le=>{if(le.Active!==!0)return!1;const Z=new Date().toISOString().split("T")[0];return!(le.EndDate&&le.EndDate<Z||le.StartDate&&le.StartDate>Z)};if(!e)return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const F=(e==null?void 0:e.Opportunities)||[],L=F.length>0,B=()=>{if(m==null){g(1);return}m>1&&g(m-1)},V=()=>{if(m==null){g(1);return}g(m+1)},H=le=>{const Z=parseInt(le.target.value,10);if(!isNaN(Z)&&Z>0){g(Z);return}g(void 0)},z=()=>{(m==null||m<1)&&g(1)},U=((ee=(J=e.Distribution)==null?void 0:J.Inventory)==null?void 0:ee.reduce((le,Z)=>le+(Z.AvailableQuantity||0),0))||0,Q=le=>{try{return new Date(le).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(Z){return console.error(Z),le.split("T")[0]||"N/A"}},q=()=>{u&&u({quantity:m??1,bidNumber:(b==null?void 0:b.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:N?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):I&&jsxRuntime.jsx("img",{src:I||"/placeholder.svg",alt:e.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy===void 0?jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(ne=e.ManufacturerCategory)!=null&&ne.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(ae=e.ManufacturerCategory)!=null&&ae.QualificationRequired?"Qualification Enforced":"No Qualification Needed"]}):jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(oe=e.ManufacturerCategory)!=null&&oe.QualificationRequired?e.AvailableToBuy?"Qualified":"Not Qualified":"No Qualification Required"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UnitWeight?`${e.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MAP?"$"+e.MAP.toFixed(2):"N/A"})]}),e.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:L&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+F.length+(F.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:F.map((le,Z)=>{var fe;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
866
866
|
${le.BidNumber==(b==null?void 0:b.BidNumber)?"cursor-pointer border-2 border-purple-900":D(le)?"hover:bg-purple-200 cursor-pointer":"!bg-neutral-50"}
|
|
867
|
-
`,onClick:()=>{D(le)&&_(le.BidNumber!=(b==null?void 0:b.BidNumber)?le:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:le.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[le.BidNumber," ",!D(le)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(fe=le.Price)==null?void 0:fe.toFixed(2)]}),le.Rebate&&le.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",le.Rebate.toFixed(2)]}),le.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",Q(le.EndDate)]})]})]},Z)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[l&&jsxRuntime.jsxs(Button,{variant:"secondary",
|
|
867
|
+
`,onClick:()=>{D(le)&&_(le.BidNumber!=(b==null?void 0:b.BidNumber)?le:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:le.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[le.BidNumber," ",!D(le)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(fe=le.Price)==null?void 0:fe.toFixed(2)]}),le.Rebate&&le.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",le.Rebate.toFixed(2)]}),le.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",Q(le.EndDate)]})]})]},Z)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[l&&jsxRuntime.jsx(reactRouterDom.Link,{to:l,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((se=e.Distribution)==null?void 0:se.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:C,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:`flex items-center text-sm ${U>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),U>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[U," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:e.Distribution.Inventory})]})]})})]})]}),e.Distribution&&jsxRuntime.jsxs("div",{className:"flex justify-between items-end mt-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-1 flex flex-col items-start gap-1",children:T>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"Cost: $"}),T.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"$"}),b?(ie=(ce=e.Opportunities)==null?void 0:ce.find(le=>le.BidNumber==b.BidNumber))==null?void 0:ie.Price:M.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]}),R>0&&jsxRuntime.jsxs("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:["$",A.toFixed(2)]})]}),R>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[R,"% OFF"]}),((ue=e.InstantRebate)==null?void 0:ue.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",e.InstantRebate.EndDate.split("T")[0]]}),(b==null?void 0:b.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",b.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 gap-2 ml-4",children:[typeof t<"u"&&t&&jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:B,disabled:typeof m<"u"&&(m<=1||!e.AvailableToBuy||d||!u),children:"-"}),jsxRuntime.jsx("input",{value:m,onChange:H,onBlur:z,onClick:le=>le.currentTarget.select(),className:`w-12 text-center border-0 focus:ring-0 focus:outline-none ${!e.AvailableToBuy||d||!u?"text-gray-400":""}`,disabled:!e.AvailableToBuy||d||!u}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:V,disabled:!e.AvailableToBuy||d||!u,children:"+"})]}),typeof t<"u"&&t&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap",onClick:q,disabled:!e.AvailableToBuy||d||!u,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})}),n&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:f,disabled:p||!f,children:p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),i]})]})]})})}exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.CountryFlag=CountryFlag,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$1,exports.Layout=Layout,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Separator=Separator,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|