randmarcomps 1.98.0 → 1.99.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.
@@ -45049,7 +45049,11 @@ function ProductCard({
45049
45049
  isSyncToShopifyActionLoading: p = !1
45050
45050
  }) {
45051
45051
  var W, G, K, J, ee, ne, ae, oe, se, le, ie, ue;
45052
- const [m, g] = useState(1), [b, _] = useState(null), [E, R] = useState(0), [S, C] = useState(!1), A = ((W = e == null ? void 0 : e.Distribution) == null ? void 0 : W.Cost) || 0, T = ((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] = useState(null), [N, D] = useState(!1);
45052
+ const [m, g] = useState(1), [b, _] = useState(null), [E, R] = useState(0), [S, C] = useState(!1), A = ((W = e == null ? void 0 : e.Distribution) == null ? void 0 : W.Cost) || 0, T = ((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;
45053
+ useEffect(() => {
45054
+ g(1), _(null), R(0), C(!1);
45055
+ }, [e == null ? void 0 : e.RandmarSKU]);
45056
+ const [I, O] = useState(null), [N, D] = useState(!1);
45053
45057
  useEffect(() => {
45054
45058
  const ce = async () => {
45055
45059
  if (e != null && e.ManufacturerId) {
@@ -849,6 +849,6 @@ Hook ${d} was either not provided or not a function.`)}return{name:reactHooksMod
849
849
  * limitations under the License.
850
850
  */class GoogleGenerativeAI{constructor(t){this.apiKey=t}getGenerativeModel(t,n){if(!t.model)throw new GoogleGenerativeAIError("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new GenerativeModel(this.apiKey,t,n)}getGenerativeModelFromCachedContent(t,n,i){if(!t.name)throw new GoogleGenerativeAIRequestInputError("Cached content must contain a `name` field.");if(!t.model)throw new GoogleGenerativeAIRequestInputError("Cached content must contain a `model` field.");const o=["model","systemInstruction"];for(const u of o)if(n!=null&&n[u]&&t[u]&&(n==null?void 0:n[u])!==t[u]){if(u==="model"){const d=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,f=t.model.startsWith("models/")?t.model.replace("models/",""):t.model;if(d===f)continue}throw new GoogleGenerativeAIRequestInputError(`Different value for "${u}" specified in modelParams (${n[u]}) and cachedContent (${t[u]})`)}const l=Object.assign(Object.assign({},n),{model:t.model,tools:t.tools,toolConfig:t.toolConfig,systemInstruction:t.systemInstruction,cachedContent:t});return new GenerativeModel(this.apiKey,l,i)}}async function fetchApiFunctions(){var e;try{const t=await fetch("https://api.randmar.io/swagger/V4/swagger.json");if(!t.ok)throw new Error("Failed to fetch Swagger spec");const n=await t.json(),i=[];for(const[o,l]of Object.entries(n.paths)){const u=["get","post","put","delete"];for(const d of u){const f=l[d];if(f&&f["x-allowed-for-chatbots"]===!0){const p=o.split("/").filter(Boolean);let m=`${d}_${p.slice(1).join("_")}`;m=m.replace(/[^a-zA-Z0-9_.-]/g,"_"),/^[a-zA-Z_]/.test(m)||(m="_"+m),m.length>60&&(m=m.substring(0,60));const g={},b=[],_=o.match(/\{([^}]+)\}/g)||[];_.forEach(S=>{const C=S.replace(/[{}]/g,"");g[C]={type:SchemaType.STRING,description:`The ${C} parameter`},b.push(C)}),(e=f.parameters)==null||e.forEach(S=>{S.in==="query"&&(g[S.name]={type:S.schema.type==="boolean"?SchemaType.BOOLEAN:SchemaType.STRING,description:S.description||`The ${S.name} parameter`},S.required&&b.push(S.name))}),(d==="post"||d==="put")&&f.requestBody&&(g.body={type:SchemaType.STRING,description:f.requestBody.description||"Request body content"},b.push("body"));const R={name:m,description:f.description?`${f.summary}
851
851
 
852
- ${f.description}`:f.summary||`${d.toUpperCase()} ${p[p.length-1]}`,parameters:{type:SchemaType.OBJECT,properties:g,required:b}},E=async S=>{var C,T,A,M;try{let I=`https://api.randmar.io${o}`;console.log(`[API Function] ${m} called with args:`,S),console.log(`[API Function] Original URL: ${I}`),console.log("[API Function] Path params:",_);const O=_.map(V=>V.replace(/[{}]/g,""));console.log("[API Function] Path parameter names:",O);const j={},N=((C=R.parameters)==null?void 0:C.properties)||{},D=Object.keys(N);console.log("[API Function] Parameter names from declaration:",D),O.forEach(V=>{const z=D.indexOf(V);z!==-1&&S[z]?(j[V]=S[z],console.log(`[API Function] Using arg for ${V}: ${S[z]}`)):(j[V]="",console.log(`[API Function] No value found for ${V}, using empty string`))}),O.forEach(V=>{const z=`{${V}}`;I.includes(z)&&(I=I.replace(z,j[V]),console.log(`[API Function] Replaced ${z} with ${j[V]}`))}),console.log(`[API Function] Final URL: ${I}`);const F=localStorage.getItem("access_token"),L={method:d.toUpperCase(),headers:{Authorization:F?`Bearer ${F}`:"","Content-Type":"application/json"}};if(d==="get"||d==="delete"){const V=[],z=((T=f.parameters)==null?void 0:T.filter(Q=>Q.in==="query"))||[],U=Object.keys(((A=R.parameters)==null?void 0:A.properties)||{});z.forEach(Q=>{const q=U.indexOf(Q.name);console.log(`[API Function] Query param ${Q.name} at index ${q}, value: ${S[q]}`),q!==-1&&S[q]!==void 0&&S[q]!==null&&S[q]!==""&&(V.push(`${Q.name}=${encodeURIComponent(S[q])}`),console.log(`[API Function] Added query param: ${Q.name}=${S[q]}`))}),V.length>0&&(I+=`?${V.join("&")}`)}else if(d==="post"||d==="put"){const V=O.length+(((M=f.parameters)==null?void 0:M.filter(z=>z.in==="query").length)||0);S[V]&&(L.body=S[V])}console.log(`[API Function] Making request to: ${I}`),console.log("[API Function] Request options:",L);const B=await fetch(I,L);if(console.log(`[API Function] Response status: ${B.status}`),!B.ok){const V=await B.text();throw console.error(`[API Function] Error response: ${V}`),new Error(`Error ${B.status}: ${V}`)}const H=await B.json();return console.log("[API Function] Response data:",H),JSON.stringify(H,null,2)}catch(I){return console.error(`Error in ${m}:`,I),`I'm sorry, I couldn't retrieve the requested information. Error: ${I instanceof Error?I.message:"Unknown error"}`}};i.push({declaration:R,handler:E})}}}return console.log(i),i}catch(t){return console.error("Error fetching API functions:",t),[]}}function useAIAssistant({userId:e,apiKey:t}){const[n,i]=React.useState(!1),[o,l]=React.useState(null),[u,d]=React.useState([]),[f,p]=React.useState([]),[m,g]=React.useState(!0),[b,_]=React.useState(""),R=new GoogleGenerativeAI(t);React.useEffect(()=>{(async()=>{try{const M=await(await fetch("https://docs.google.com/document/d/e/2PACX-1vT-f5SWSJ2BcRUcyiumzT1aPUeC8kyyV7ryJTTymWJWOcRbDRgV5nX6Wyh7HaSPf8rxTY9w63Q2C8rG/pub")).text(),N=new DOMParser().parseFromString(M,"text/html").querySelector(".doc-content").innerHTML.replace("__user_id__",e);console.log("google doc fetched: ",N),_(N)}catch(A){console.error("Error fetching system instructions:",A),_("You are a helpful assistant, but cannot help the user right now. They should come back another time.")}})()},[]),React.useEffect(()=>{const T=async()=>{try{const M=R.getGenerativeModel({model:"gemini-2.0-flash"}).startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Tell me about your instructions. What are the rules that define how you respond?"}]},{role:"model",parts:[{text:b}]}],tools:f.length>0?[{functionDeclarations:f.map(({declaration:I})=>I)}]:[]});l(M)}catch(A){console.error("Error initializing chat:",A)}};o||m||b!==""&&T()},[m,o,b]),React.useEffect(()=>{(async()=>{try{const A=await fetchApiFunctions();p(A)}catch(A){console.error("Error loading API functions:",A)}finally{g(!1)}})()},[]);const E=Object.fromEntries(f.map(({declaration:T,handler:A})=>[T.name,A])),S=async T=>{var M,I;const A=T.name;if(A in E){const O=E[A],j=T.args||{};console.log(`[Function Call] ${A} with args:`,j);const N=(M=f.find(L=>L.declaration.name===A))==null?void 0:M.declaration;if(!N){console.error(`[Function Call] Could not find declaration for ${A}`);return}const D=Object.keys(((I=N.parameters)==null?void 0:I.properties)||{});console.log("[Function Call] Parameter names from declaration:",D);const F=[];D.forEach(L=>{if(L in j){const B=j[L];typeof B=="object"?F.push(JSON.stringify(B)):F.push(typeof B=="string"?B:String(B))}else F.push("")}),console.log("[Function Call] Converted args to:",F);try{const L=await O(F);let B,H=null,V=!1;if(typeof L=="string"?B=L:(B=L.summary,H=L.component,V=!0),console.log(`[Function Response] ${A} returned:`,B),o){const z={functionResponse:{name:A,response:{content:B}}};if(V&&H){const q={role:"assistant",content:H,timestamp:new Date,isComponent:!0};d(W=>[...W,q])}const Q={role:"assistant",content:(await o.sendMessage([z])).response.text(),timestamp:new Date};d(q=>[...q,Q])}}catch(L){console.error("Error executing function:",L);const B={role:"assistant",content:"I encountered an error while processing your request. Please try again.",timestamp:new Date};d(H=>[...H,B])}}else console.error(`Function ${A} not found`)};return{handleSubmitToBot:async T=>{if(T.trim()&&!n&&o){const A={role:"user",content:T,timestamp:new Date};d(M=>[...M,A]),i(!0);try{const I=(await o.sendMessage(T.trim())).response,O=I.functionCalls();if(O&&O.length>0)for(const j of O)await S(j);else{const j={role:"assistant",content:I.text(),timestamp:new Date};d(N=>[...N,j])}}catch(M){console.error("Error sending message:",M);const I={role:"assistant",content:"I'm sorry, I encountered an error processing your request. Please try again later.",timestamp:new Date};d(O=>[...O,I])}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(""),[j,N]=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};H(K)},[f]);function H(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",H),G.start().catch(K=>console.error("Error connecting to SignalR hub:",K)),N(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 V=(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||!j||!p)return!1;const J=A.find(ee=>ee.conversationID===G);return J?(R([J.partner1,J.partner2]),K&&setTimeout(()=>V(K,[J.partner1,J.partner2],j),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()||!_||!j||V(E,_,j)};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 N=async()=>{try{const B=await fetch(g);if(B.ok){const V=(await B.text()).toLowerCase()==="true";return T(V),V}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 H=await B.blob();R(URL.createObjectURL(H))}}catch(B){console.error("Failed to load logo:",B)}finally{S(!1)}},F=async()=>{try{const B=await fetch(p);if(B.ok){const H=await B.text();M(H.toLowerCase()==="true")}}catch(B){console.error("Failed to check if video exists:",B),M(!1)}};(async()=>{await N()&&D(),F()})()},[e,m,g,p,d]);const j=()=>{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:j,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),[j,N]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){N(!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{N(!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)},H=()=>{if(m==null){g(1);return}g(m+1)},V=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:j?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
852
+ ${f.description}`:f.summary||`${d.toUpperCase()} ${p[p.length-1]}`,parameters:{type:SchemaType.OBJECT,properties:g,required:b}},E=async S=>{var C,T,A,M;try{let I=`https://api.randmar.io${o}`;console.log(`[API Function] ${m} called with args:`,S),console.log(`[API Function] Original URL: ${I}`),console.log("[API Function] Path params:",_);const O=_.map(V=>V.replace(/[{}]/g,""));console.log("[API Function] Path parameter names:",O);const j={},N=((C=R.parameters)==null?void 0:C.properties)||{},D=Object.keys(N);console.log("[API Function] Parameter names from declaration:",D),O.forEach(V=>{const z=D.indexOf(V);z!==-1&&S[z]?(j[V]=S[z],console.log(`[API Function] Using arg for ${V}: ${S[z]}`)):(j[V]="",console.log(`[API Function] No value found for ${V}, using empty string`))}),O.forEach(V=>{const z=`{${V}}`;I.includes(z)&&(I=I.replace(z,j[V]),console.log(`[API Function] Replaced ${z} with ${j[V]}`))}),console.log(`[API Function] Final URL: ${I}`);const F=localStorage.getItem("access_token"),L={method:d.toUpperCase(),headers:{Authorization:F?`Bearer ${F}`:"","Content-Type":"application/json"}};if(d==="get"||d==="delete"){const V=[],z=((T=f.parameters)==null?void 0:T.filter(Q=>Q.in==="query"))||[],U=Object.keys(((A=R.parameters)==null?void 0:A.properties)||{});z.forEach(Q=>{const q=U.indexOf(Q.name);console.log(`[API Function] Query param ${Q.name} at index ${q}, value: ${S[q]}`),q!==-1&&S[q]!==void 0&&S[q]!==null&&S[q]!==""&&(V.push(`${Q.name}=${encodeURIComponent(S[q])}`),console.log(`[API Function] Added query param: ${Q.name}=${S[q]}`))}),V.length>0&&(I+=`?${V.join("&")}`)}else if(d==="post"||d==="put"){const V=O.length+(((M=f.parameters)==null?void 0:M.filter(z=>z.in==="query").length)||0);S[V]&&(L.body=S[V])}console.log(`[API Function] Making request to: ${I}`),console.log("[API Function] Request options:",L);const B=await fetch(I,L);if(console.log(`[API Function] Response status: ${B.status}`),!B.ok){const V=await B.text();throw console.error(`[API Function] Error response: ${V}`),new Error(`Error ${B.status}: ${V}`)}const H=await B.json();return console.log("[API Function] Response data:",H),JSON.stringify(H,null,2)}catch(I){return console.error(`Error in ${m}:`,I),`I'm sorry, I couldn't retrieve the requested information. Error: ${I instanceof Error?I.message:"Unknown error"}`}};i.push({declaration:R,handler:E})}}}return console.log(i),i}catch(t){return console.error("Error fetching API functions:",t),[]}}function useAIAssistant({userId:e,apiKey:t}){const[n,i]=React.useState(!1),[o,l]=React.useState(null),[u,d]=React.useState([]),[f,p]=React.useState([]),[m,g]=React.useState(!0),[b,_]=React.useState(""),R=new GoogleGenerativeAI(t);React.useEffect(()=>{(async()=>{try{const M=await(await fetch("https://docs.google.com/document/d/e/2PACX-1vT-f5SWSJ2BcRUcyiumzT1aPUeC8kyyV7ryJTTymWJWOcRbDRgV5nX6Wyh7HaSPf8rxTY9w63Q2C8rG/pub")).text(),N=new DOMParser().parseFromString(M,"text/html").querySelector(".doc-content").innerHTML.replace("__user_id__",e);console.log("google doc fetched: ",N),_(N)}catch(A){console.error("Error fetching system instructions:",A),_("You are a helpful assistant, but cannot help the user right now. They should come back another time.")}})()},[]),React.useEffect(()=>{const T=async()=>{try{const M=R.getGenerativeModel({model:"gemini-2.0-flash"}).startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Tell me about your instructions. What are the rules that define how you respond?"}]},{role:"model",parts:[{text:b}]}],tools:f.length>0?[{functionDeclarations:f.map(({declaration:I})=>I)}]:[]});l(M)}catch(A){console.error("Error initializing chat:",A)}};o||m||b!==""&&T()},[m,o,b]),React.useEffect(()=>{(async()=>{try{const A=await fetchApiFunctions();p(A)}catch(A){console.error("Error loading API functions:",A)}finally{g(!1)}})()},[]);const E=Object.fromEntries(f.map(({declaration:T,handler:A})=>[T.name,A])),S=async T=>{var M,I;const A=T.name;if(A in E){const O=E[A],j=T.args||{};console.log(`[Function Call] ${A} with args:`,j);const N=(M=f.find(L=>L.declaration.name===A))==null?void 0:M.declaration;if(!N){console.error(`[Function Call] Could not find declaration for ${A}`);return}const D=Object.keys(((I=N.parameters)==null?void 0:I.properties)||{});console.log("[Function Call] Parameter names from declaration:",D);const F=[];D.forEach(L=>{if(L in j){const B=j[L];typeof B=="object"?F.push(JSON.stringify(B)):F.push(typeof B=="string"?B:String(B))}else F.push("")}),console.log("[Function Call] Converted args to:",F);try{const L=await O(F);let B,H=null,V=!1;if(typeof L=="string"?B=L:(B=L.summary,H=L.component,V=!0),console.log(`[Function Response] ${A} returned:`,B),o){const z={functionResponse:{name:A,response:{content:B}}};if(V&&H){const q={role:"assistant",content:H,timestamp:new Date,isComponent:!0};d(W=>[...W,q])}const Q={role:"assistant",content:(await o.sendMessage([z])).response.text(),timestamp:new Date};d(q=>[...q,Q])}}catch(L){console.error("Error executing function:",L);const B={role:"assistant",content:"I encountered an error while processing your request. Please try again.",timestamp:new Date};d(H=>[...H,B])}}else console.error(`Function ${A} not found`)};return{handleSubmitToBot:async T=>{if(T.trim()&&!n&&o){const A={role:"user",content:T,timestamp:new Date};d(M=>[...M,A]),i(!0);try{const I=(await o.sendMessage(T.trim())).response,O=I.functionCalls();if(O&&O.length>0)for(const j of O)await S(j);else{const j={role:"assistant",content:I.text(),timestamp:new Date};d(N=>[...N,j])}}catch(M){console.error("Error sending message:",M);const I={role:"assistant",content:"I'm sorry, I encountered an error processing your request. Please try again later.",timestamp:new Date};d(O=>[...O,I])}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(""),[j,N]=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};H(K)},[f]);function H(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",H),G.start().catch(K=>console.error("Error connecting to SignalR hub:",K)),N(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 V=(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||!j||!p)return!1;const J=A.find(ee=>ee.conversationID===G);return J?(R([J.partner1,J.partner2]),K&&setTimeout(()=>V(K,[J.partner1,J.partner2],j),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()||!_||!j||V(E,_,j)};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 N=async()=>{try{const B=await fetch(g);if(B.ok){const V=(await B.text()).toLowerCase()==="true";return T(V),V}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 H=await B.blob();R(URL.createObjectURL(H))}}catch(B){console.error("Failed to load logo:",B)}finally{S(!1)}},F=async()=>{try{const B=await fetch(p);if(B.ok){const H=await B.text();M(H.toLowerCase()==="true")}}catch(B){console.error("Failed to check if video exists:",B),M(!1)}};(async()=>{await N()&&D(),F()})()},[e,m,g,p,d]);const j=()=>{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:j,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;React.useEffect(()=>{g(1),_(null),E(0),C(!1)},[e==null?void 0:e.RandmarSKU]);const[I,O]=React.useState(null),[j,N]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){N(!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{N(!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)},H=()=>{if(m==null){g(1);return}g(m+1)},V=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:j?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
853
853
  ${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"}
854
854
  `,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:V,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:H,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]})]})]})})}function ManufacturerCard({manufacturer:e,goToManufacturerLink:t,actionItems:n=[],isLoading:i=!1}){var m;if(i)return jsxRuntime.jsxs(Card,{className:"w-full max-w-md overflow-hidden",children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.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(CardContent,{className:"pb-2",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",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const o=e.ManufacturerId||"N/A",l=e.PublicName||"N/A",u=[e.City,e.Province,e.Country].filter(Boolean),d=u.length>0?u.join(", "):"Location not provided",f=((m=e.Tags)==null?void 0:m.split(",").map(g=>g.trim()).filter(Boolean))||[],p=(g,b)=>{const _=g.icon,R=jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(_,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:g.label})]});return g.link?jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:g.link,children:R})},b):jsxRuntime.jsx(DropdownMenuItem,{onClick:g.onClick,children:R},b)};return jsxRuntime.jsxs(Card,{className:"w-full max-w-md overflow-hidden manufacturer-theme",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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx("img",{src:`https://api.randmar.io/V4/Partner/${o}/Account/Logo?width=64&height=64`,alt:`${l}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:o})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"}),e.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:e.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:d})]})]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[f.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((g,b)=>jsxRuntime.jsx(Badge,{children:g},b))}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:`flex pt-2 gap-2 ${n.length>0?"justify-between":"justify-end"}`,children:[n.length>0&&jsxRuntime.jsxs(DropdownMenu,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"text-primary",children:["Actions ",jsxRuntime.jsx(Ellipsis,{className:"ml-1 h-4 w-4"})]})}),jsxRuntime.jsx(DropdownMenuContent,{align:"start",children:n.map((g,b)=>p(g,b))})]}),jsxRuntime.jsx(Button,{className:"flex items-center gap-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:t,children:["Go to Manufacturer",jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]})})]})]})}function ResellerCard({reseller:e,goToResellerLink:t,actionItems:n=[],isLoading:i=!1}){if(i)return jsxRuntime.jsxs(Card,{className:"w-full max-w-md overflow-hidden",children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.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(CardContent,{className:"pb-2",children:jsxRuntime.jsx("div",{className:"flex flex-col space-y-2",children: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",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const o=e.ResellerId||"N/A",l=e.PublicName||"N/A",u=[e.City,e.Province,e.Country].filter(Boolean),d=u.length>0?u.join(", "):"Location not provided",f=(p,m)=>{const g=p.icon,b=jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(g,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:p.label})]});return p.link?jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:p.link,children:b})},m):jsxRuntime.jsx(DropdownMenuItem,{onClick:p.onClick,children:b},m)};return jsxRuntime.jsxs(Card,{className:"w-full max-w-md overflow-hidden reseller-theme",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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx("img",{src:`https://api.randmar.io/V4/Partner/${o}/Account/Logo?width=64&height=64`,alt:`${l}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Reseller"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:o})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"}),e.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:e.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:d})]})]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsx("div",{className:"flex flex-col space-y-2",children:jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]})]})})}),jsxRuntime.jsxs(CardFooter,{className:`flex pt-2 gap-2 ${n.length>0?"justify-between":"justify-end"}`,children:[n.length>0&&jsxRuntime.jsxs(DropdownMenu,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"text-primary",children:["Actions ",jsxRuntime.jsx(Ellipsis,{className:"ml-1 h-4 w-4"})]})}),jsxRuntime.jsx(DropdownMenuContent,{align:"start",children:n.map((p,m)=>f(p,m))})]}),jsxRuntime.jsx(Button,{className:"flex items-center gap-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:t,children:["Go to Reseller",jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]})})]})]})}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.ManufacturerCard=ManufacturerCard,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ResellerCard=ResellerCard,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"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.98.0",
4
+ "version": "1.99.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [