randmarcomps 1.578.0 → 1.579.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.
@@ -95965,22 +95965,20 @@ function ProductOverviewPage({
95965
95965
  zt && lt(zt);
95966
95966
  }
95967
95967
  }, [A, R, n, at, V?.IsManufacturer]);
95968
- const ft = R?.ManufacturerId !== e;
95969
- console.log("readonly", ft);
95970
- const pt = (R?.Receipts?.length ?? 0) > 0, mt = (R?.Logs?.length ?? 0) > 0, yt = !n && (f || A), dt = R?.Title || R?.RandmarTitle || R?.RandmarSKU || "Product", Ct = R?.VoiceoverCaption || "", Mt = typeof R?.MAP == "number" && R.MAP > 0 ? R.MAP : typeof R?.Distribution?.MAP == "number" && R.Distribution.MAP > 0 ? R.Distribution.MAP : null, Dt = typeof R?.MSRP == "number" && R.MSRP > 0 ? R.MSRP : typeof R?.Distribution?.MSRP == "number" && R.Distribution.MSRP > 0 ? R.Distribution.MSRP : null, Ft = a ? R?.Opportunities?.find(($t) => $t.BidNumber === a)?.Price : null, Ut = typeof Ft == "number" && Ft > 0 ? Ft : typeof R?.Distribution?.Price == "number" && R.Distribution.Price > 0 ? R.Distribution.Price : null, Rt = typeof Mt == "number" && typeof Ut == "number" ? Mt - Ut : null, Vt = typeof Rt == "number" && typeof Mt == "number" && Mt > 0 ? Math.round(Rt / Mt * 100) : null;
95968
+ const ft = (R?.Receipts?.length ?? 0) > 0, pt = (R?.Logs?.length ?? 0) > 0, mt = !n && (f || A), yt = R?.Title || R?.RandmarTitle || R?.RandmarSKU || "Product", dt = R?.VoiceoverCaption || "", Ct = typeof R?.MAP == "number" && R.MAP > 0 ? R.MAP : typeof R?.Distribution?.MAP == "number" && R.Distribution.MAP > 0 ? R.Distribution.MAP : null, Mt = typeof R?.MSRP == "number" && R.MSRP > 0 ? R.MSRP : typeof R?.Distribution?.MSRP == "number" && R.Distribution.MSRP > 0 ? R.Distribution.MSRP : null, Dt = a ? R?.Opportunities?.find(($t) => $t.BidNumber === a)?.Price : null, Ft = typeof Dt == "number" && Dt > 0 ? Dt : typeof R?.Distribution?.Price == "number" && R.Distribution.Price > 0 ? R.Distribution.Price : null, Ut = mt || typeof Ft == "number", Rt = typeof Ct == "number" && typeof Ft == "number" ? Ct - Ft : null, Vt = typeof Rt == "number" && typeof Ct == "number" && Ct > 0 ? Math.round(Rt / Ct * 100) : null;
95971
95969
  return /* @__PURE__ */ jsxs("div", { className: "@container", children: [
95972
95970
  /* @__PURE__ */ jsxs("div", { className: "grid gap-4 grid-cols-1 @md:grid-cols-3", children: [
95973
95971
  /* @__PURE__ */ jsxs(Card, { className: "@md:col-span-2", children: [
95974
95972
  /* @__PURE__ */ jsxs(CardHeader, { className: "space-y-2", children: [
95975
- /* @__PURE__ */ jsx(CardTitle, { className: "text-2xl font-semibold leading-tight", children: yt && !R ? /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-2/3" }) : dt }),
95976
- Ct ? /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: Ct }) : yt && !R ? /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4/5" }) : null
95973
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-2xl font-semibold leading-tight", children: mt && !R ? /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-2/3" }) : yt }),
95974
+ dt ? /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: dt }) : mt && !R ? /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4/5" }) : null
95977
95975
  ] }),
95978
95976
  /* @__PURE__ */ jsxs(CardContent, { className: "space-y-6", children: [
95979
95977
  /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4", children: [
95980
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 @sm:flex-row @sm:items-start @sm:justify-between", children: [
95978
+ Ut ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 @sm:flex-row @sm:items-start @sm:justify-between", children: [
95981
95979
  /* @__PURE__ */ jsxs("div", { children: [
95982
95980
  /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Your Price" }),
95983
- /* @__PURE__ */ jsx("div", { className: "mt-1 text-3xl font-semibold tracking-tight", children: typeof Ut == "number" ? formatMoney(Ut) : yt ? /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-40" }) : "—" })
95981
+ /* @__PURE__ */ jsx("div", { className: "mt-1 text-3xl font-semibold tracking-tight", children: typeof Ft == "number" ? formatMoney(Ft) : mt ? /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-40" }) : null })
95984
95982
  ] }),
95985
95983
  typeof Rt == "number" && typeof Vt == "number" ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start @sm:items-end", children: [
95986
95984
  /* @__PURE__ */ jsxs(
@@ -96000,8 +95998,8 @@ function ProductOverviewPage({
96000
95998
  ),
96001
95999
  /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: Rt >= 0 ? `${Vt}% margin vs MAP` : `${Math.abs(Vt)}% under MAP` })
96002
96000
  ] }) : null
96003
- ] }),
96004
- /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs("div", { className: "mt-5 grid grid-cols-1 gap-4 @sm:grid-cols-2", children: [
96001
+ ] }) : null,
96002
+ /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs("div", { className: `${Ut ? "mt-5" : "mt-0"} grid grid-cols-1 gap-4 @sm:grid-cols-2`, children: [
96005
96003
  /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 rounded-md border bg-background/50 p-3", children: [
96006
96004
  /* @__PURE__ */ jsxs("div", { children: [
96007
96005
  /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
@@ -96015,14 +96013,14 @@ function ProductOverviewPage({
96015
96013
  ) }),
96016
96014
  /* @__PURE__ */ jsx(TooltipContent, { children: "Minimum Advertised Price — the lowest price you can publicly advertise." })
96017
96015
  ] }) }),
96018
- /* @__PURE__ */ jsx("div", { className: "font-medium", children: typeof Mt == "number" ? formatMoney(Mt) : "—" })
96016
+ /* @__PURE__ */ jsx("div", { className: "font-medium", children: typeof Ct == "number" ? formatMoney(Ct) : "—" })
96019
96017
  ] }),
96020
- typeof Rt == "number" && typeof Ut == "number" && typeof Mt == "number" ? /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
96018
+ typeof Rt == "number" && typeof Ft == "number" && typeof Ct == "number" ? /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
96021
96019
  /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground", children: "Profit vs MAP" }),
96022
96020
  /* @__PURE__ */ jsxs("div", { className: "text-sm font-semibold", children: [
96023
- formatMoney(Mt),
96021
+ formatMoney(Ct),
96024
96022
  " - ",
96025
- formatMoney(Ut),
96023
+ formatMoney(Ft),
96026
96024
  " = ",
96027
96025
  formatMoney(Rt)
96028
96026
  ] })
@@ -96040,14 +96038,14 @@ function ProductOverviewPage({
96040
96038
  ) }),
96041
96039
  /* @__PURE__ */ jsx(TooltipContent, { children: "Manufacturer's Suggested Retail Price — a reference retail list price." })
96042
96040
  ] }) }),
96043
- /* @__PURE__ */ jsx("div", { className: "font-medium", children: typeof Dt == "number" ? formatMoney(Dt) : "—" })
96041
+ /* @__PURE__ */ jsx("div", { className: "font-medium", children: typeof Mt == "number" ? formatMoney(Mt) : "—" })
96044
96042
  ] }) })
96045
96043
  ] }) })
96046
96044
  ] }),
96047
96045
  R?.BodyHTML ? /* @__PURE__ */ jsx(
96048
96046
  "div",
96049
96047
  {
96050
- className: "prose prose-sm max-w-none",
96048
+ className: "prose prose-sm max-w-none leading-relaxed [&_p]:mb-4 [&_p:last-child]:mb-0",
96051
96049
  dangerouslySetInnerHTML: { __html: R.BodyHTML }
96052
96050
  }
96053
96051
  ) : /* @__PURE__ */ jsxs("div", { className: "text-sm text-muted-foreground", children: [
@@ -96139,7 +96137,7 @@ function ProductOverviewPage({
96139
96137
  {
96140
96138
  value: "warehouse-tab",
96141
96139
  className: "relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",
96142
- disabled: !pt && !mt,
96140
+ disabled: !ft && !pt,
96143
96141
  children: "Latest Warehouse Receiving"
96144
96142
  }
96145
96143
  )
@@ -96217,7 +96215,7 @@ function ProductOverviewPage({
96217
96215
  ] })
96218
96216
  ] }),
96219
96217
  /* @__PURE__ */ jsx(TabsContent, { value: "warehouse-tab", children: /* @__PURE__ */ jsxs("div", { className: "mt-4 grid grid-cols-1 gap-4 @md:grid-cols-2", children: [
96220
- pt && /* @__PURE__ */ jsxs(Card, { className: `w-full ${mt ? "" : "@md:col-span-2"}`, children: [
96218
+ ft && /* @__PURE__ */ jsxs(Card, { className: `w-full ${pt ? "" : "@md:col-span-2"}`, children: [
96221
96219
  /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Receipts" }) }),
96222
96220
  /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(
96223
96221
  ReceiptsTable,
@@ -96228,7 +96226,7 @@ function ProductOverviewPage({
96228
96226
  }
96229
96227
  ) })
96230
96228
  ] }),
96231
- mt && /* @__PURE__ */ jsxs(Card, { className: `w-full ${pt ? "" : "@md:col-span-2"}`, children: [
96229
+ pt && /* @__PURE__ */ jsxs(Card, { className: `w-full ${ft ? "" : "@md:col-span-2"}`, children: [
96232
96230
  /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Logs" }) }),
96233
96231
  /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(LogsTable, { logs: R?.Logs, loading: A }) })
96234
96232
  ] })
@@ -756,7 +756,7 @@ ${V.slice(f+2)}`,R+=1;else break}t.push({indent:f,number:parseInt(c,10),content:
756
756
  .ProseMirror p {
757
757
  margin-bottom: 0.5em;
758
758
  }
759
- `;function RichTextEditor({id:e,name:t,value:n,onChange:s,placeholder:a,className:o,...l}){const[c,d]=React.useState(!1),f=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[index_default,index_default$1],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:e??"",name:t??""}},onUpdate:({editor:ct})=>{const pt=ct.getHTML();s({target:{id:e,name:t,value:pt}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const A=React.useCallback(ct=>{if(R)if(R.chain().focus(),ct==="paragraph")R.chain().setParagraph().run();else{const pt=Number.parseInt(ct.slice(1));R.chain().setHeading({level:pt}).run()}},[R]),V=React.useCallback(ct=>{if(R)switch(R.chain().focus(),ct){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),at=React.useCallback(()=>{d(ct=>!ct)},[]),lt=React.useCallback(ct=>{const pt=ct.target.value;R&&R.commands.setContent(pt),s({target:{id:e,name:t,value:pt}})},[s,R,e,t]),ot=React.useCallback(()=>{!c&&R&&R.commands.focus()},[c,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",o),onClick:ot,...l,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select$1,{onValueChange:A,disabled:c,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(ct=>jsxRuntime.jsx(SelectItem,{value:ct.value,children:ct.label},ct.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(ct=>jsxRuntime.jsxs(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:()=>V(ct),className:R.isActive(ct)?"bg-muted":"",disabled:c,children:[ct==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),ct==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),ct==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),ct==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),ct==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),ct==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},ct)),jsxRuntime.jsx(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:at,className:c?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:c?jsxRuntime.jsx(Textarea,{ref:f,id:e,name:t,value:R.getHTML(),onChange:lt,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",o),placeholder:a}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function ReceiptsTable({applicationId:e,receipts:t=null,loading:n=!1}){const s=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:l})=>l.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:l})=>formatYYYYMMDDIntToDateString(l.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptNumber",header:"Number",cell:({row:l})=>l.original.ReceiptNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${l.original.ReceiptNumber}`,className:"font-medium text-primary hover:underline",children:l.original.ReceiptNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Receipt ",l.original.ReceiptNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:l})=>l.original.Quantity??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:l})=>l.original.UnitPrice?formatMoney(l.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0}],[]),a=React.useMemo(()=>{const l={};if(t){const c=Array.from(new Set(t.map(f=>f.Location).filter(f=>f!=null)));l.Location=c;const d=Array.from(new Set(t.map(f=>formatYYYYMMDDIntToDateString(f.ReceiptDate)).filter(f=>f!=="—"&&f!=="Invalid Date"))).sort((f,S)=>new Date(S).getTime()-new Date(f).getTime());l.ReceiptDate=d}return l},[t]),o=t||[];return jsxRuntime.jsx(DataTable,{columns:s,data:o,uniqueValues:a,loading:n,tableClass:"bg-card text-card-foreground",initialSort:[{id:"ReceiptDate",desc:!0}]})}const formatDate$1=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"Invalid Date":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}},getStatusVariant=e=>{const t=e?.toLowerCase()||"";return t.includes("accepted")?"success":t.includes("error")||t.includes("rejected")?"destructive":"neutral"};function ReturnsTable({applicationId:e,returns:t=null,loading:n=!1}){const s=React.useMemo(()=>[{accessorKey:"ReturnNumber1",header:"RMA Number",cell:({row:l})=>{const c=l.original.ReturnNumber1||l.original.ReturnNumber;return c?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Return/${c}`,className:"font-medium text-primary hover:underline",children:c})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for return ",c]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestDate",header:"Request Date",cell:({row:l})=>formatDate$1(l.original.RequestDate),enableSorting:!0},{accessorKey:"InvoiceNumber",header:"Invoice Number",cell:({row:l})=>{const c=l.original.InvoiceNumber;return c?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${c}`,className:"text-blue-600 hover:underline",children:c})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for invoice ",c]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:l})=>l.original.Quantity??"0",enableSorting:!0},{accessorKey:"ReasonForReturn",header:"Return Reason",cell:({row:l})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:l.original.ReasonForReturn??"—"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"Status",header:"Status",cell:({row:l})=>{const c=l.original.Status,d=getStatusVariant(c);let f="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return d==="success"?f="border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400":d==="destructive"&&(f="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"),c?jsxRuntime.jsx(Badge,{variant:"outline",className:`${f} font-medium`,children:c}):"—"},enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseLocation",header:"Warehouse",cell:({row:l})=>l.original.WarehouseLocation??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"LastUpdatedDate",header:"Last Update",cell:({row:l})=>formatDate$1(l.original.LastUpdatedDate)!=="N/A"?formatDate$1(l.original.LastUpdatedDate):"—",enableSorting:!0}],[e]),a=React.useMemo(()=>{const l={};if(t){const c=Array.from(new Set(t.map(S=>S.Status).filter(Boolean)));l.Status=c;const d=Array.from(new Set(t.map(S=>S.ReasonForReturn).filter(Boolean)));l.ReasonForReturn=d;const f=Array.from(new Set(t.map(S=>S.WarehouseLocation).filter(Boolean)));l.WarehouseLocation=f}return l},[t]),o=React.useMemo(()=>t?[...t].sort((c,d)=>(d.ReturnNumber1||d.ReturnNumber||"").localeCompare(c.ReturnNumber1||c.ReturnNumber||"")):[],[t]);return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:s,data:o,uniqueValues:a})})]})}function PurchaseOrdersTable({applicationId:e,purchaseOrders:t=null,loading:n=!1}){const[s,a]=React.useState([]),[o]=usePostV4ManufacturerByRouteManufacturerIdPurchaseOrderAndPurchaseOrderNumberEditItemRandmarSkuMutation(),{toast:l}=useToast();React.useEffect(()=>{a(t||[])},[t]);const c=React.useMemo(()=>[{accessorKey:"PurchaseOrderNumber",header:"Number",cell:({row:f})=>f.original.PurchaseOrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${f.original.PurchaseOrderNumber}`,className:"font-medium text-primary hover:underline",children:f.original.PurchaseOrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Purchase Order ",f.original.PurchaseOrderNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PurchaseOrderDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.PurchaseOrderDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:f})=>f.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PartNumber",header:"Part Number",cell:({row:f})=>f.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${f.original.RandmarSKU}`,className:"font-medium text-primary hover:underline",children:f.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Product ",f.original.RandmarSKU]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:f})=>f.original.QuantityOrdered??0,enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,A]=React.useState(!1),V=S.original,at=()=>{A(!0),o({routeManufacturerId:e,purchaseOrderNumber:V.PurchaseOrderNumber??"",randmarSku:V.RandmarSKU??"",quantity:0}).then(()=>{a(lt=>lt.filter(ot=>!(ot.PurchaseOrderNumber===ot.PurchaseOrderNumber&&ot.MPN===ot.MPN))),l({variant:"success",title:"Success",description:`Part ${V.MPN} has been successfully deleted from Purchase Order ${V.PurchaseOrderNumber}.`})}).catch(lt=>{console.error(lt),A(!0),l({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to delete part ",jsxRuntime.jsx("strong",{children:V.MPN})," from Purchase Order ",jsxRuntime.jsx("strong",{children:V.PurchaseOrderNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:at,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),d=React.useMemo(()=>{const f={};return s&&(f.PurchaseOrderNumber=Array.from(new Set(s.map(S=>S.PurchaseOrderNumber).filter(S=>S!=null))),f.PurchaseOrderDate=Array.from(new Set(s.map(S=>S.PurchaseOrderDate).filter(S=>S!=null).map(String))),f.Location=Array.from(new Set(s.map(S=>S.Location).filter(S=>S!=null))),f.PartNumber=Array.from(new Set(s.map(S=>S.MPN).filter(S=>S!=null))),f.QuantityOrdered=Array.from(new Set(s.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),f.UnitPrice=Array.from(new Set(s.map(S=>S.UnitPrice).filter(S=>S!=null).map(String)))),f},[s]);return jsxRuntime.jsx(DataTable,{columns:c,data:s,uniqueValues:d,loading:n,tableClass:"bg-card text-card-foreground"})}function RequisitionsTable({applicationId:e,requisitions:t=null,loading:n=!1}){const[s,a]=React.useState([]),[o]=useDeleteV4ManufacturerByRouteManufacturerIdRequisitionAndRequisitionNumberMutation(),{toast:l}=useToast();React.useEffect(()=>{a(t||[])},[t]);const c=React.useMemo(()=>[{accessorKey:"RequisitionNumber",header:"Number",cell:({row:f})=>f.original.RequisitionNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${f.original.RequisitionNumber}`,className:"font-medium text-primary hover:underline",children:f.original.RequisitionNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Draft Purchase ",f.original.RequisitionNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequisitionDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.RequisitionDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:f})=>f.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:f})=>f.original.QuantityOrdered??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOutstanding",header:"Quantity Outstanding",cell:({row:f})=>f.original.QuantityOutstanding??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityReceived",header:"Quantity Received",cell:({row:f})=>f.original.QuantityReceived??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"SubTotal",header:"Sub Total",cell:({row:f})=>f.original.SubTotal?formatMoney(f.original.SubTotal):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestedBy",header:"Requestor",cell:({row:f})=>f.original.RequestedBy??"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,A]=React.useState(!1),V=S.original,at=()=>{A(!0),o({routeManufacturerId:e,requisitionNumber:V.RequisitionNumber??""}).then(()=>{a(lt=>lt.filter(ot=>ot.RequisitionNumber!==ot.RequisitionNumber)),l({variant:"success",title:"Success",description:`Draft Purchase ${V.RequisitionNumber} has been successfully cancelled.`})}).catch(lt=>{console.error(lt),A(!0),l({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancelling"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Cancel"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to cancel Draft Purchase ",jsxRuntime.jsx("strong",{children:V.RequisitionNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:at,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),d=React.useMemo(()=>{const f={};return s&&(f.RequisitionNumber=Array.from(new Set(s.map(S=>S.RequisitionNumber).filter(S=>S!=null))),f.RequisitionDate=Array.from(new Set(s.map(S=>S.RequisitionDate).filter(S=>S!=null).map(String))),f.QuantityOrdered=Array.from(new Set(s.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),f.QuantityOutstanding=Array.from(new Set(s.map(S=>S.QuantityOutstanding).filter(S=>S!=null).map(String))),f.QuantityReceived=Array.from(new Set(s.map(S=>S.QuantityReceived).filter(S=>S!=null).map(String))),f.Location=Array.from(new Set(s.map(S=>S.Location).filter(S=>S!=null))),f.RequestedBy=Array.from(new Set(s.map(S=>S.RequestedBy).filter(S=>S!=null))),f.SubTotal=Array.from(new Set(s.map(S=>S.SubTotal).filter(S=>S!=null).map(String)))),f},[s]);return jsxRuntime.jsx(DataTable,{columns:c,data:s,uniqueValues:d,loading:n,tableClass:"bg-card text-card-foreground"})}const dateTimeFormatter=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});function parseAssumedLocalDateTime(e){if(!e)return null;const t=e.trim();if(!t)return null;if(/[zZ]$/.test(t)||/[+-]\d{2}:?\d{2}$/.test(t)){const ct=new Date(t);return Number.isNaN(ct.getTime())?null:ct}const s=t.replace(" ","T"),[a,o]=s.split("T");if(!a)return null;const[l,c,d]=a.split("-"),f=Number.parseInt(l??"",10),S=Number.parseInt(c??"",10),R=Number.parseInt(d??"",10);if(!Number.isFinite(f)||!Number.isFinite(S)||!Number.isFinite(R))return null;let A=0,V=0,at=0,lt=0;if(o){const ct=o.trim(),[pt,ft,mt]=ct.split(":");if(A=Number.parseInt(pt??"0",10),V=Number.parseInt(ft??"0",10),mt){const[yt,dt]=mt.split(".");at=Number.parseInt(yt??"0",10),dt&&(lt=Number.parseInt(dt.slice(0,3).padEnd(3,"0"),10))}}if(!Number.isFinite(A)||!Number.isFinite(V)||!Number.isFinite(at)||!Number.isFinite(lt))return null;const ot=new Date(f,S-1,R,A,V,at,lt);return Number.isNaN(ot.getTime())||ot.getFullYear()!==f||ot.getMonth()!==S-1||ot.getDate()!==R?null:ot}function formatDateTimeLocal(e){const t=parseAssumedLocalDateTime(e);return t?dateTimeFormatter.format(t):"—"}function LogsTable({logs:e=null,loading:t=!1}){const n=React.useMemo(()=>[{accessorKey:"DateTime",header:"Date & Time",cell:({row:s})=>formatDateTimeLocal(s.original.DateTime),enableSorting:!0,enableFiltering:!1,sortingFn:(s,a,o)=>{const l=parseAssumedLocalDateTime(s.getValue(o)),c=parseAssumedLocalDateTime(a.getValue(o)),d=l?l.getTime():Number.NEGATIVE_INFINITY,f=c?c.getTime():Number.NEGATIVE_INFINITY;return d===f?0:d>f?1:-1}},{accessorKey:"Message",header:"Message",cell:({row:s})=>jsxRuntime.jsx("span",{className:"whitespace-pre-wrap break-words",children:s.original.Message??"—"}),enableSorting:!0,enableFiltering:!0}],[]);return jsxRuntime.jsx(DataTable,{columns:n,data:e||[],uniqueValues:{},loading:t,tableClass:"bg-card text-card-foreground",initialSort:[{id:"DateTime",desc:!0}]})}function ProductOverviewPage({applicationId:e,sku:t,product:n,productDefaultOpportunityNumber:s="",productOnAddToCart:a,productAddingToCart:o=!1,productShopifyHostname:l,productCustomAction:c=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const{data:d,isLoading:f}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!1},{skip:!!n||!e||!t}),{data:S,isLoading:R}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!0},{skip:!!n||!e||!t}),A=n??S??d,{data:V}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),[at,lt]=React.useState("stats-tab"),[ot,ct]=React.useState(!1);React.useEffect(()=>{if(!n&&R){ct(!1);return}const Vt=(A?.Receipts?.length??0)>0,Ht=(A?.Logs?.length??0)>0,Kt={"stats-tab":(A?.SalesStatistics?.length??0)<=0,"inventory-tab":(A?.Distribution?.Inventory?.length??0)<=0,"opportunities-tab":(A?.Opportunities?.length??0)<=0,"active-orders-tab":(A?.ActiveOrderDetails?.length??0)<=0,"completed-orders-tab":(A?.CompletedOrderDetails?.length??0)<=0,"returns-tab":(A?.Returns?.length??0)<=0,"purchase-orders-tab":!V?.IsManufacturer||(A?.PurchaseOrders?.length??0)<=0&&(A?.Requisitions?.length??0)<=0,"warehouse-tab":!Vt&&!Ht},Jt=Object.values(Kt).some(zt=>!zt);if(ct(Jt),Jt&&Kt[at]){const zt=Object.keys(Kt).find(qt=>!Kt[qt]);zt&&lt(zt)}},[R,A,n,at,V?.IsManufacturer]);const pt=A?.ManufacturerId!==e;console.log("readonly",pt);const ft=(A?.Receipts?.length??0)>0,mt=(A?.Logs?.length??0)>0,yt=!n&&(f||R),dt=A?.Title||A?.RandmarTitle||A?.RandmarSKU||"Product",Rt=A?.VoiceoverCaption||"",Mt=typeof A?.MAP=="number"&&A.MAP>0?A.MAP:typeof A?.Distribution?.MAP=="number"&&A.Distribution.MAP>0?A.Distribution.MAP:null,Dt=typeof A?.MSRP=="number"&&A.MSRP>0?A.MSRP:typeof A?.Distribution?.MSRP=="number"&&A.Distribution.MSRP>0?A.Distribution.MSRP:null,Ft=s?A?.Opportunities?.find(Vt=>Vt.BidNumber===s)?.Price:null,Ut=typeof Ft=="number"&&Ft>0?Ft:typeof A?.Distribution?.Price=="number"&&A.Distribution.Price>0?A.Distribution.Price:null,Ct=typeof Mt=="number"&&typeof Ut=="number"?Mt-Ut:null,$t=typeof Ct=="number"&&typeof Mt=="number"&&Mt>0?Math.round(Ct/Mt*100):null;return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @md:grid-cols-3",children:[jsxRuntime.jsxs(Card,{className:"@md:col-span-2",children:[jsxRuntime.jsxs(CardHeader,{className:"space-y-2",children:[jsxRuntime.jsx(CardTitle,{className:"text-2xl font-semibold leading-tight",children:yt&&!A?jsxRuntime.jsx(Skeleton,{className:"h-7 w-2/3"}):dt}),Rt?jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:Rt}):yt&&!A?jsxRuntime.jsx(Skeleton,{className:"h-4 w-4/5"}):null]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 @sm:flex-row @sm:items-start @sm:justify-between",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Your Price"}),jsxRuntime.jsx("div",{className:"mt-1 text-3xl font-semibold tracking-tight",children:typeof Ut=="number"?formatMoney(Ut):yt?jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"}):"—"})]}),typeof Ct=="number"&&typeof $t=="number"?jsxRuntime.jsxs("div",{className:"flex flex-col items-start @sm:items-end",children:[jsxRuntime.jsxs(Badge,{variant:"outline",className:["rounded-full px-3 py-1.5 text-sm font-semibold",Ct>=0?"border-emerald-200 bg-emerald-50 text-emerald-800 hover:bg-emerald-50":"border-rose-200 bg-rose-50 text-rose-800 hover:bg-rose-50"].join(" "),children:[Ct>=0?"Potential Profit":"Below MAP",": ",formatMoney(Math.abs(Ct))]}),jsxRuntime.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:Ct>=0?`${$t}% margin vs MAP`:`${Math.abs($t)}% under MAP`})]}):null]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs("div",{className:"mt-5 grid grid-cols-1 gap-4 @sm:grid-cols-2",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border bg-background/50 p-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"cursor-help bg-transparent p-0 underline decoration-dotted underline-offset-4",children:"MAP"})}),jsxRuntime.jsx(TooltipContent,{children:"Minimum Advertised Price — the lowest price you can publicly advertise."})]})}),jsxRuntime.jsx("div",{className:"font-medium",children:typeof Mt=="number"?formatMoney(Mt):"—"})]}),typeof Ct=="number"&&typeof Ut=="number"&&typeof Mt=="number"?jsxRuntime.jsxs("div",{className:"text-right",children:[jsxRuntime.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Profit vs MAP"}),jsxRuntime.jsxs("div",{className:"text-sm font-semibold",children:[formatMoney(Mt)," - ",formatMoney(Ut)," = ",formatMoney(Ct)]})]}):null]}),jsxRuntime.jsx("div",{className:"flex items-start justify-between gap-4 rounded-md border bg-background/50 p-3",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"cursor-help bg-transparent p-0 underline decoration-dotted underline-offset-4",children:"MSRP"})}),jsxRuntime.jsx(TooltipContent,{children:"Manufacturer's Suggested Retail Price — a reference retail list price."})]})}),jsxRuntime.jsx("div",{className:"font-medium",children:typeof Dt=="number"?formatMoney(Dt):"—"})]})})]})})]}),A?.BodyHTML?jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:A.BodyHTML}}):jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:[jsxRuntime.jsx(Info,{className:"h-4 w-4 inline mr-2"}),"No product description available."]})]})]}),jsxRuntime.jsx("div",{className:"self-start @md:sticky @md:top-4",children:jsxRuntime.jsx(ProductCard,{applicationId:e,product:A,defaultOpportunityNumber:s,onAddToCart:a,addingToCart:o,shopifyHostname:l,customAction:c})})]}),jsxRuntime.jsx("div",{className:"my-4",children:f||R?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):ot&&jsxRuntime.jsxs(Tabs,{value:at,onValueChange:lt,children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.SalesStatistics?.length??0)<=0,children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"inventory-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.Distribution?.Inventory?.length??0)<=0,children:"Inventory"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.Opportunities?.length??0)<=0,children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"active-orders-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.ActiveOrderDetails?.length??0)<=0,children:"Active Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"completed-orders-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.CompletedOrderDetails?.length??0)<=0,children:"Completed Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"returns-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.Returns?.length??0)<=0,children:"Returns"}),jsxRuntime.jsx(TabsTrigger,{value:"purchase-orders-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!V?.IsManufacturer||(A?.PurchaseOrders?.length??0)<=0&&(A?.Requisitions?.length??0)<=0,children:"Purchase Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!ft&&!mt,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChartCard,{statistics:A?.SalesStatistics??[],loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"inventory-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ProductInventoryGrid,{inventory:A?.Distribution?.Inventory??[],className:"bg-card text-card-foreground"})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:A?.Opportunities,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"active-orders-tab",children:(A?.ActiveOrderDetails?.length??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:A?.ActiveOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"completed-orders-tab",children:(A?.CompletedOrderDetails?.length??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:A?.CompletedOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"returns-tab",children:(A?.Returns?.length??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:A?.Returns,loading:R})})}),jsxRuntime.jsxs(TabsContent,{value:"purchase-orders-tab",children:[(A?.PurchaseOrders?.length??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Purchase Orders"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(PurchaseOrdersTable,{applicationId:e,purchaseOrders:A?.PurchaseOrders,loading:R})})]}),(A?.Requisitions?.length??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Draft Purchases"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(RequisitionsTable,{applicationId:e,requisitions:A?.Requisitions,loading:R})})]})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse-tab",children:jsxRuntime.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 @md:grid-cols-2",children:[ft&&jsxRuntime.jsxs(Card,{className:`w-full ${mt?"":"@md:col-span-2"}`,children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Receipts"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(ReceiptsTable,{applicationId:e,receipts:A?.Receipts,loading:R})})]}),mt&&jsxRuntime.jsxs(Card,{className:`w-full ${ft?"":"@md:col-span-2"}`,children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Logs"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(LogsTable,{logs:A?.Logs,loading:R})})]})]})})]})})]})}const colClasses={base:{1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6"},sm:{1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},md:{1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4",5:"md:grid-cols-5",6:"md:grid-cols-6"},lg:{1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4",5:"lg:grid-cols-5",6:"lg:grid-cols-6"},xl:{1:"xl:grid-cols-1",2:"xl:grid-cols-2",3:"xl:grid-cols-3",4:"xl:grid-cols-4",5:"xl:grid-cols-5",6:"xl:grid-cols-6"}},buildGridClassName=e=>{const t={base:1,md:2,...e};return["grid","gap-4",t.base?colClasses.base[t.base]:"",t.sm?colClasses.sm[t.sm]:"",t.md?colClasses.md[t.md]:"",t.lg?colClasses.lg[t.lg]:"",t.xl?colClasses.xl[t.xl]:""].filter(Boolean).join(" ")},SearchPageGrid=({results:e,groupBy:t,renderItem:n})=>{const s=t(e);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:Object.entries(s).map(([a,o])=>{const{items:l,gridCols:c}=o;if(l.length===0)return null;const d=buildGridClassName(c);return jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold tracking-tight mb-4",children:a}),jsxRuntime.jsx("div",{className:d,children:l.map((f,S)=>n(f,S))})]},a)})})},SearchPage=({query:e,results:t,isLoading:n,children:s})=>n?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-center py-24",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e&&t.length===0?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-start pt-16",children:jsxRuntime.jsx(Card,{className:"w-full max-w-lg",children:jsxRuntime.jsxs(CardHeader,{className:"text-center items-center",children:[jsxRuntime.jsx("div",{className:"rounded-full border bg-muted p-3 mb-4",children:jsxRuntime.jsx(SearchX,{className:"h-8 w-8 text-muted-foreground"})}),jsxRuntime.jsx(CardTitle,{children:"No Results Found"}),jsxRuntime.jsxs(CardDescription,{children:['Your search for "',e,'" did not return any results. Please try a different search term.']})]})})}):t.length>0?jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-8",children:jsxRuntime.jsx("div",{className:"col-span-3",children:s})}):null;var COLLAPSIBLE_NAME="Collapsible",[createCollapsibleContext,createCollapsibleScope]=createContextScope$2(COLLAPSIBLE_NAME),[CollapsibleProvider,useCollapsibleContext]=createCollapsibleContext(COLLAPSIBLE_NAME),Collapsible=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:a,disabled:o,onOpenChange:l,...c}=e,[d,f]=useControllableState({prop:s,defaultProp:a??!1,onChange:l,caller:COLLAPSIBLE_NAME});return jsxRuntime.jsx(CollapsibleProvider,{scope:n,disabled:o,contentId:useId$1(),open:d,onOpenToggle:React__namespace.useCallback(()=>f(S=>!S),[f]),children:jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(d),"data-disabled":o?"":void 0,...c,ref:t})})});Collapsible.displayName=COLLAPSIBLE_NAME;var TRIGGER_NAME$1="CollapsibleTrigger",CollapsibleTrigger=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,a=useCollapsibleContext(TRIGGER_NAME$1,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":getState$1(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...s,ref:t,onClick:composeEventHandlers(e.onClick,a.onOpenToggle)})});CollapsibleTrigger.displayName=TRIGGER_NAME$1;var CONTENT_NAME$1="CollapsibleContent",CollapsibleContent=React__namespace.forwardRef((e,t)=>{const{forceMount:n,...s}=e,a=useCollapsibleContext(CONTENT_NAME$1,e.__scopeCollapsible);return jsxRuntime.jsx(Presence,{present:n||a.open,children:({present:o})=>jsxRuntime.jsx(CollapsibleContentImpl,{...s,ref:t,present:o})})});CollapsibleContent.displayName=CONTENT_NAME$1;var CollapsibleContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:a,...o}=e,l=useCollapsibleContext(CONTENT_NAME$1,n),[c,d]=React__namespace.useState(s),f=React__namespace.useRef(null),S=useComposedRefs(t,f),R=React__namespace.useRef(0),A=R.current,V=React__namespace.useRef(0),at=V.current,lt=l.open||c,ot=React__namespace.useRef(lt),ct=React__namespace.useRef(void 0);return React__namespace.useEffect(()=>{const pt=requestAnimationFrame(()=>ot.current=!1);return()=>cancelAnimationFrame(pt)},[]),useLayoutEffect2(()=>{const pt=f.current;if(pt){ct.current=ct.current||{transitionDuration:pt.style.transitionDuration,animationName:pt.style.animationName},pt.style.transitionDuration="0s",pt.style.animationName="none";const ft=pt.getBoundingClientRect();R.current=ft.height,V.current=ft.width,ot.current||(pt.style.transitionDuration=ct.current.transitionDuration,pt.style.animationName=ct.current.animationName),d(s)}},[l.open,s]),jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!lt,...o,ref:S,style:{"--radix-collapsible-content-height":A?`${A}px`:void 0,"--radix-collapsible-content-width":at?`${at}px`:void 0,...e.style},children:lt&&a})});function getState$1(e){return e?"open":"closed"}var Root$1=Collapsible,Trigger=CollapsibleTrigger,Content=CollapsibleContent,ACCORDION_NAME="Accordion",ACCORDION_KEYS=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Collection,useCollection,createCollectionScope]=createCollection(ACCORDION_NAME),[createAccordionContext]=createContextScope$2(ACCORDION_NAME,[createCollectionScope,createCollapsibleScope]),useCollapsibleScope=createCollapsibleScope(),Accordion$1=React.forwardRef((e,t)=>{const{type:n,...s}=e,a=s,o=s;return jsxRuntime.jsx(Collection.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?jsxRuntime.jsx(AccordionImplMultiple,{...o,ref:t}):jsxRuntime.jsx(AccordionImplSingle,{...a,ref:t})})});Accordion$1.displayName=ACCORDION_NAME;var[AccordionValueProvider,useAccordionValueContext]=createAccordionContext(ACCORDION_NAME),[AccordionCollapsibleProvider,useAccordionCollapsibleContext]=createAccordionContext(ACCORDION_NAME,{collapsible:!1}),AccordionImplSingle=React.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:a=()=>{},collapsible:o=!1,...l}=e,[c,d]=useControllableState({prop:n,defaultProp:s??"",onChange:a,caller:ACCORDION_NAME});return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:React.useMemo(()=>c?[c]:[],[c]),onItemOpen:d,onItemClose:React.useCallback(()=>o&&d(""),[o,d]),children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:o,children:jsxRuntime.jsx(AccordionImpl,{...l,ref:t})})})}),AccordionImplMultiple=React.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:a=()=>{},...o}=e,[l,c]=useControllableState({prop:n,defaultProp:s??[],onChange:a,caller:ACCORDION_NAME}),d=React.useCallback(S=>c((R=[])=>[...R,S]),[c]),f=React.useCallback(S=>c((R=[])=>R.filter(A=>A!==S)),[c]);return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:l,onItemOpen:d,onItemClose:f,children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:!0,children:jsxRuntime.jsx(AccordionImpl,{...o,ref:t})})})}),[AccordionImplProvider,useAccordionContext]=createAccordionContext(ACCORDION_NAME),AccordionImpl=React.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=e,c=React.useRef(null),d=useComposedRefs(c,t),f=useCollection(n),R=useDirection(a)==="ltr",A=composeEventHandlers(e.onKeyDown,V=>{if(!ACCORDION_KEYS.includes(V.key))return;const at=V.target,lt=f().filter(Mt=>!Mt.ref.current?.disabled),ot=lt.findIndex(Mt=>Mt.ref.current===at),ct=lt.length;if(ot===-1)return;V.preventDefault();let pt=ot;const ft=0,mt=ct-1,yt=()=>{pt=ot+1,pt>mt&&(pt=ft)},dt=()=>{pt=ot-1,pt<ft&&(pt=mt)};switch(V.key){case"Home":pt=ft;break;case"End":pt=mt;break;case"ArrowRight":o==="horizontal"&&(R?yt():dt());break;case"ArrowDown":o==="vertical"&&yt();break;case"ArrowLeft":o==="horizontal"&&(R?dt():yt());break;case"ArrowUp":o==="vertical"&&dt();break}const Rt=pt%ct;lt[Rt].ref.current?.focus()});return jsxRuntime.jsx(AccordionImplProvider,{scope:n,disabled:s,direction:a,orientation:o,children:jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{...l,"data-orientation":o,ref:d,onKeyDown:s?void 0:A})})})}),ITEM_NAME="AccordionItem",[AccordionItemProvider,useAccordionItemContext]=createAccordionContext(ITEM_NAME),AccordionItem$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,value:s,...a}=e,o=useAccordionContext(ITEM_NAME,n),l=useAccordionValueContext(ITEM_NAME,n),c=useCollapsibleScope(n),d=useId$1(),f=s&&l.value.includes(s)||!1,S=o.disabled||e.disabled;return jsxRuntime.jsx(AccordionItemProvider,{scope:n,open:f,disabled:S,triggerId:d,children:jsxRuntime.jsx(Root$1,{"data-orientation":o.orientation,"data-state":getState(f),...c,...a,ref:t,disabled:S,open:f,onOpenChange:R=>{R?l.onItemOpen(s):l.onItemClose(s)}})})});AccordionItem$1.displayName=ITEM_NAME;var HEADER_NAME="AccordionHeader",AccordionHeader=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,a=useAccordionContext(ACCORDION_NAME,n),o=useAccordionItemContext(HEADER_NAME,n);return jsxRuntime.jsx(Primitive$4.h3,{"data-orientation":a.orientation,"data-state":getState(o.open),"data-disabled":o.disabled?"":void 0,...s,ref:t})});AccordionHeader.displayName=HEADER_NAME;var TRIGGER_NAME="AccordionTrigger",AccordionTrigger$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,a=useAccordionContext(ACCORDION_NAME,n),o=useAccordionItemContext(TRIGGER_NAME,n),l=useAccordionCollapsibleContext(TRIGGER_NAME,n),c=useCollapsibleScope(n);return jsxRuntime.jsx(Collection.ItemSlot,{scope:n,children:jsxRuntime.jsx(Trigger,{"aria-disabled":o.open&&!l.collapsible||void 0,"data-orientation":a.orientation,id:o.triggerId,...c,...s,ref:t})})});AccordionTrigger$1.displayName=TRIGGER_NAME;var CONTENT_NAME="AccordionContent",AccordionContent$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,a=useAccordionContext(ACCORDION_NAME,n),o=useAccordionItemContext(CONTENT_NAME,n),l=useCollapsibleScope(n);return jsxRuntime.jsx(Content,{role:"region","aria-labelledby":o.triggerId,"data-orientation":a.orientation,...l,...s,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});AccordionContent$1.displayName=CONTENT_NAME;function getState(e){return e?"open":"closed"}var Root2=Accordion$1,Item=AccordionItem$1,Header=AccordionHeader,Trigger2=AccordionTrigger$1,Content2=AccordionContent$1;const Accordion=Root2,AccordionItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Item,{ref:n,className:cn("border-b",e),...t}));AccordionItem.displayName="AccordionItem";const AccordionTrigger=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsx(Header,{className:"flex",children:jsxRuntime.jsxs(Trigger2,{ref:s,className:cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));AccordionTrigger.displayName=Trigger2.displayName;const AccordionContent=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsx(Content2,{ref:s,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:jsxRuntime.jsx("div",{className:cn("pb-4 pt-0",e),children:t})}));AccordionContent.displayName=Content2.displayName;function AssistantInsight({applicationId:e,prompt:t,smartAndSlow:n=!1,thinkingPlaceholderText:s="Thinking...",withCard:a=!0}){const[o]=usePostV4PartnerByApplicationIdGenerationRandmarAssistantMutation(),[l,c]=React.useState(null),[d,f]=React.useState(!1),[S,R]=React.useState(null),A=React.useRef(0),V=React.useRef(null);React.useEffect(()=>{if(V.current?.abort(),V.current=null,!t){c(null),f(!1),R(null);return}if(!e){c(null),f(!1),R("applicationId is required.");return}const ct=`Analyze the following prompt and Provide a helpful, concise response formatted in simple HTML.
759
+ `;function RichTextEditor({id:e,name:t,value:n,onChange:s,placeholder:a,className:o,...l}){const[c,d]=React.useState(!1),f=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[index_default,index_default$1],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:e??"",name:t??""}},onUpdate:({editor:ct})=>{const pt=ct.getHTML();s({target:{id:e,name:t,value:pt}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const A=React.useCallback(ct=>{if(R)if(R.chain().focus(),ct==="paragraph")R.chain().setParagraph().run();else{const pt=Number.parseInt(ct.slice(1));R.chain().setHeading({level:pt}).run()}},[R]),V=React.useCallback(ct=>{if(R)switch(R.chain().focus(),ct){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),at=React.useCallback(()=>{d(ct=>!ct)},[]),lt=React.useCallback(ct=>{const pt=ct.target.value;R&&R.commands.setContent(pt),s({target:{id:e,name:t,value:pt}})},[s,R,e,t]),ot=React.useCallback(()=>{!c&&R&&R.commands.focus()},[c,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",o),onClick:ot,...l,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select$1,{onValueChange:A,disabled:c,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(ct=>jsxRuntime.jsx(SelectItem,{value:ct.value,children:ct.label},ct.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(ct=>jsxRuntime.jsxs(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:()=>V(ct),className:R.isActive(ct)?"bg-muted":"",disabled:c,children:[ct==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),ct==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),ct==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),ct==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),ct==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),ct==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},ct)),jsxRuntime.jsx(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:at,className:c?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:c?jsxRuntime.jsx(Textarea,{ref:f,id:e,name:t,value:R.getHTML(),onChange:lt,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",o),placeholder:a}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function ReceiptsTable({applicationId:e,receipts:t=null,loading:n=!1}){const s=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:l})=>l.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:l})=>formatYYYYMMDDIntToDateString(l.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptNumber",header:"Number",cell:({row:l})=>l.original.ReceiptNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${l.original.ReceiptNumber}`,className:"font-medium text-primary hover:underline",children:l.original.ReceiptNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Receipt ",l.original.ReceiptNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:l})=>l.original.Quantity??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:l})=>l.original.UnitPrice?formatMoney(l.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0}],[]),a=React.useMemo(()=>{const l={};if(t){const c=Array.from(new Set(t.map(f=>f.Location).filter(f=>f!=null)));l.Location=c;const d=Array.from(new Set(t.map(f=>formatYYYYMMDDIntToDateString(f.ReceiptDate)).filter(f=>f!=="—"&&f!=="Invalid Date"))).sort((f,S)=>new Date(S).getTime()-new Date(f).getTime());l.ReceiptDate=d}return l},[t]),o=t||[];return jsxRuntime.jsx(DataTable,{columns:s,data:o,uniqueValues:a,loading:n,tableClass:"bg-card text-card-foreground",initialSort:[{id:"ReceiptDate",desc:!0}]})}const formatDate$1=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"Invalid Date":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}},getStatusVariant=e=>{const t=e?.toLowerCase()||"";return t.includes("accepted")?"success":t.includes("error")||t.includes("rejected")?"destructive":"neutral"};function ReturnsTable({applicationId:e,returns:t=null,loading:n=!1}){const s=React.useMemo(()=>[{accessorKey:"ReturnNumber1",header:"RMA Number",cell:({row:l})=>{const c=l.original.ReturnNumber1||l.original.ReturnNumber;return c?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Return/${c}`,className:"font-medium text-primary hover:underline",children:c})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for return ",c]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestDate",header:"Request Date",cell:({row:l})=>formatDate$1(l.original.RequestDate),enableSorting:!0},{accessorKey:"InvoiceNumber",header:"Invoice Number",cell:({row:l})=>{const c=l.original.InvoiceNumber;return c?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${c}`,className:"text-blue-600 hover:underline",children:c})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for invoice ",c]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:l})=>l.original.Quantity??"0",enableSorting:!0},{accessorKey:"ReasonForReturn",header:"Return Reason",cell:({row:l})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:l.original.ReasonForReturn??"—"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"Status",header:"Status",cell:({row:l})=>{const c=l.original.Status,d=getStatusVariant(c);let f="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return d==="success"?f="border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400":d==="destructive"&&(f="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"),c?jsxRuntime.jsx(Badge,{variant:"outline",className:`${f} font-medium`,children:c}):"—"},enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseLocation",header:"Warehouse",cell:({row:l})=>l.original.WarehouseLocation??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"LastUpdatedDate",header:"Last Update",cell:({row:l})=>formatDate$1(l.original.LastUpdatedDate)!=="N/A"?formatDate$1(l.original.LastUpdatedDate):"—",enableSorting:!0}],[e]),a=React.useMemo(()=>{const l={};if(t){const c=Array.from(new Set(t.map(S=>S.Status).filter(Boolean)));l.Status=c;const d=Array.from(new Set(t.map(S=>S.ReasonForReturn).filter(Boolean)));l.ReasonForReturn=d;const f=Array.from(new Set(t.map(S=>S.WarehouseLocation).filter(Boolean)));l.WarehouseLocation=f}return l},[t]),o=React.useMemo(()=>t?[...t].sort((c,d)=>(d.ReturnNumber1||d.ReturnNumber||"").localeCompare(c.ReturnNumber1||c.ReturnNumber||"")):[],[t]);return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:s,data:o,uniqueValues:a})})]})}function PurchaseOrdersTable({applicationId:e,purchaseOrders:t=null,loading:n=!1}){const[s,a]=React.useState([]),[o]=usePostV4ManufacturerByRouteManufacturerIdPurchaseOrderAndPurchaseOrderNumberEditItemRandmarSkuMutation(),{toast:l}=useToast();React.useEffect(()=>{a(t||[])},[t]);const c=React.useMemo(()=>[{accessorKey:"PurchaseOrderNumber",header:"Number",cell:({row:f})=>f.original.PurchaseOrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${f.original.PurchaseOrderNumber}`,className:"font-medium text-primary hover:underline",children:f.original.PurchaseOrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Purchase Order ",f.original.PurchaseOrderNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PurchaseOrderDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.PurchaseOrderDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:f})=>f.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PartNumber",header:"Part Number",cell:({row:f})=>f.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${f.original.RandmarSKU}`,className:"font-medium text-primary hover:underline",children:f.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Product ",f.original.RandmarSKU]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:f})=>f.original.QuantityOrdered??0,enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,A]=React.useState(!1),V=S.original,at=()=>{A(!0),o({routeManufacturerId:e,purchaseOrderNumber:V.PurchaseOrderNumber??"",randmarSku:V.RandmarSKU??"",quantity:0}).then(()=>{a(lt=>lt.filter(ot=>!(ot.PurchaseOrderNumber===ot.PurchaseOrderNumber&&ot.MPN===ot.MPN))),l({variant:"success",title:"Success",description:`Part ${V.MPN} has been successfully deleted from Purchase Order ${V.PurchaseOrderNumber}.`})}).catch(lt=>{console.error(lt),A(!0),l({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to delete part ",jsxRuntime.jsx("strong",{children:V.MPN})," from Purchase Order ",jsxRuntime.jsx("strong",{children:V.PurchaseOrderNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:at,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),d=React.useMemo(()=>{const f={};return s&&(f.PurchaseOrderNumber=Array.from(new Set(s.map(S=>S.PurchaseOrderNumber).filter(S=>S!=null))),f.PurchaseOrderDate=Array.from(new Set(s.map(S=>S.PurchaseOrderDate).filter(S=>S!=null).map(String))),f.Location=Array.from(new Set(s.map(S=>S.Location).filter(S=>S!=null))),f.PartNumber=Array.from(new Set(s.map(S=>S.MPN).filter(S=>S!=null))),f.QuantityOrdered=Array.from(new Set(s.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),f.UnitPrice=Array.from(new Set(s.map(S=>S.UnitPrice).filter(S=>S!=null).map(String)))),f},[s]);return jsxRuntime.jsx(DataTable,{columns:c,data:s,uniqueValues:d,loading:n,tableClass:"bg-card text-card-foreground"})}function RequisitionsTable({applicationId:e,requisitions:t=null,loading:n=!1}){const[s,a]=React.useState([]),[o]=useDeleteV4ManufacturerByRouteManufacturerIdRequisitionAndRequisitionNumberMutation(),{toast:l}=useToast();React.useEffect(()=>{a(t||[])},[t]);const c=React.useMemo(()=>[{accessorKey:"RequisitionNumber",header:"Number",cell:({row:f})=>f.original.RequisitionNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${f.original.RequisitionNumber}`,className:"font-medium text-primary hover:underline",children:f.original.RequisitionNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Draft Purchase ",f.original.RequisitionNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequisitionDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.RequisitionDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:f})=>f.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:f})=>f.original.QuantityOrdered??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOutstanding",header:"Quantity Outstanding",cell:({row:f})=>f.original.QuantityOutstanding??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityReceived",header:"Quantity Received",cell:({row:f})=>f.original.QuantityReceived??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"SubTotal",header:"Sub Total",cell:({row:f})=>f.original.SubTotal?formatMoney(f.original.SubTotal):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestedBy",header:"Requestor",cell:({row:f})=>f.original.RequestedBy??"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,A]=React.useState(!1),V=S.original,at=()=>{A(!0),o({routeManufacturerId:e,requisitionNumber:V.RequisitionNumber??""}).then(()=>{a(lt=>lt.filter(ot=>ot.RequisitionNumber!==ot.RequisitionNumber)),l({variant:"success",title:"Success",description:`Draft Purchase ${V.RequisitionNumber} has been successfully cancelled.`})}).catch(lt=>{console.error(lt),A(!0),l({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancelling"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Cancel"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to cancel Draft Purchase ",jsxRuntime.jsx("strong",{children:V.RequisitionNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:at,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),d=React.useMemo(()=>{const f={};return s&&(f.RequisitionNumber=Array.from(new Set(s.map(S=>S.RequisitionNumber).filter(S=>S!=null))),f.RequisitionDate=Array.from(new Set(s.map(S=>S.RequisitionDate).filter(S=>S!=null).map(String))),f.QuantityOrdered=Array.from(new Set(s.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),f.QuantityOutstanding=Array.from(new Set(s.map(S=>S.QuantityOutstanding).filter(S=>S!=null).map(String))),f.QuantityReceived=Array.from(new Set(s.map(S=>S.QuantityReceived).filter(S=>S!=null).map(String))),f.Location=Array.from(new Set(s.map(S=>S.Location).filter(S=>S!=null))),f.RequestedBy=Array.from(new Set(s.map(S=>S.RequestedBy).filter(S=>S!=null))),f.SubTotal=Array.from(new Set(s.map(S=>S.SubTotal).filter(S=>S!=null).map(String)))),f},[s]);return jsxRuntime.jsx(DataTable,{columns:c,data:s,uniqueValues:d,loading:n,tableClass:"bg-card text-card-foreground"})}const dateTimeFormatter=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});function parseAssumedLocalDateTime(e){if(!e)return null;const t=e.trim();if(!t)return null;if(/[zZ]$/.test(t)||/[+-]\d{2}:?\d{2}$/.test(t)){const ct=new Date(t);return Number.isNaN(ct.getTime())?null:ct}const s=t.replace(" ","T"),[a,o]=s.split("T");if(!a)return null;const[l,c,d]=a.split("-"),f=Number.parseInt(l??"",10),S=Number.parseInt(c??"",10),R=Number.parseInt(d??"",10);if(!Number.isFinite(f)||!Number.isFinite(S)||!Number.isFinite(R))return null;let A=0,V=0,at=0,lt=0;if(o){const ct=o.trim(),[pt,ft,mt]=ct.split(":");if(A=Number.parseInt(pt??"0",10),V=Number.parseInt(ft??"0",10),mt){const[yt,dt]=mt.split(".");at=Number.parseInt(yt??"0",10),dt&&(lt=Number.parseInt(dt.slice(0,3).padEnd(3,"0"),10))}}if(!Number.isFinite(A)||!Number.isFinite(V)||!Number.isFinite(at)||!Number.isFinite(lt))return null;const ot=new Date(f,S-1,R,A,V,at,lt);return Number.isNaN(ot.getTime())||ot.getFullYear()!==f||ot.getMonth()!==S-1||ot.getDate()!==R?null:ot}function formatDateTimeLocal(e){const t=parseAssumedLocalDateTime(e);return t?dateTimeFormatter.format(t):"—"}function LogsTable({logs:e=null,loading:t=!1}){const n=React.useMemo(()=>[{accessorKey:"DateTime",header:"Date & Time",cell:({row:s})=>formatDateTimeLocal(s.original.DateTime),enableSorting:!0,enableFiltering:!1,sortingFn:(s,a,o)=>{const l=parseAssumedLocalDateTime(s.getValue(o)),c=parseAssumedLocalDateTime(a.getValue(o)),d=l?l.getTime():Number.NEGATIVE_INFINITY,f=c?c.getTime():Number.NEGATIVE_INFINITY;return d===f?0:d>f?1:-1}},{accessorKey:"Message",header:"Message",cell:({row:s})=>jsxRuntime.jsx("span",{className:"whitespace-pre-wrap break-words",children:s.original.Message??"—"}),enableSorting:!0,enableFiltering:!0}],[]);return jsxRuntime.jsx(DataTable,{columns:n,data:e||[],uniqueValues:{},loading:t,tableClass:"bg-card text-card-foreground",initialSort:[{id:"DateTime",desc:!0}]})}function ProductOverviewPage({applicationId:e,sku:t,product:n,productDefaultOpportunityNumber:s="",productOnAddToCart:a,productAddingToCart:o=!1,productShopifyHostname:l,productCustomAction:c=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const{data:d,isLoading:f}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!1},{skip:!!n||!e||!t}),{data:S,isLoading:R}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!0},{skip:!!n||!e||!t}),A=n??S??d,{data:V}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),[at,lt]=React.useState("stats-tab"),[ot,ct]=React.useState(!1);React.useEffect(()=>{if(!n&&R){ct(!1);return}const Vt=(A?.Receipts?.length??0)>0,Ht=(A?.Logs?.length??0)>0,Kt={"stats-tab":(A?.SalesStatistics?.length??0)<=0,"inventory-tab":(A?.Distribution?.Inventory?.length??0)<=0,"opportunities-tab":(A?.Opportunities?.length??0)<=0,"active-orders-tab":(A?.ActiveOrderDetails?.length??0)<=0,"completed-orders-tab":(A?.CompletedOrderDetails?.length??0)<=0,"returns-tab":(A?.Returns?.length??0)<=0,"purchase-orders-tab":!V?.IsManufacturer||(A?.PurchaseOrders?.length??0)<=0&&(A?.Requisitions?.length??0)<=0,"warehouse-tab":!Vt&&!Ht},Jt=Object.values(Kt).some(zt=>!zt);if(ct(Jt),Jt&&Kt[at]){const zt=Object.keys(Kt).find(qt=>!Kt[qt]);zt&&lt(zt)}},[R,A,n,at,V?.IsManufacturer]);const pt=(A?.Receipts?.length??0)>0,ft=(A?.Logs?.length??0)>0,mt=!n&&(f||R),yt=A?.Title||A?.RandmarTitle||A?.RandmarSKU||"Product",dt=A?.VoiceoverCaption||"",Rt=typeof A?.MAP=="number"&&A.MAP>0?A.MAP:typeof A?.Distribution?.MAP=="number"&&A.Distribution.MAP>0?A.Distribution.MAP:null,Mt=typeof A?.MSRP=="number"&&A.MSRP>0?A.MSRP:typeof A?.Distribution?.MSRP=="number"&&A.Distribution.MSRP>0?A.Distribution.MSRP:null,Dt=s?A?.Opportunities?.find(Vt=>Vt.BidNumber===s)?.Price:null,Ft=typeof Dt=="number"&&Dt>0?Dt:typeof A?.Distribution?.Price=="number"&&A.Distribution.Price>0?A.Distribution.Price:null,Ut=mt||typeof Ft=="number",Ct=typeof Rt=="number"&&typeof Ft=="number"?Rt-Ft:null,$t=typeof Ct=="number"&&typeof Rt=="number"&&Rt>0?Math.round(Ct/Rt*100):null;return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @md:grid-cols-3",children:[jsxRuntime.jsxs(Card,{className:"@md:col-span-2",children:[jsxRuntime.jsxs(CardHeader,{className:"space-y-2",children:[jsxRuntime.jsx(CardTitle,{className:"text-2xl font-semibold leading-tight",children:mt&&!A?jsxRuntime.jsx(Skeleton,{className:"h-7 w-2/3"}):yt}),dt?jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:dt}):mt&&!A?jsxRuntime.jsx(Skeleton,{className:"h-4 w-4/5"}):null]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[Ut?jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 @sm:flex-row @sm:items-start @sm:justify-between",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Your Price"}),jsxRuntime.jsx("div",{className:"mt-1 text-3xl font-semibold tracking-tight",children:typeof Ft=="number"?formatMoney(Ft):mt?jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"}):null})]}),typeof Ct=="number"&&typeof $t=="number"?jsxRuntime.jsxs("div",{className:"flex flex-col items-start @sm:items-end",children:[jsxRuntime.jsxs(Badge,{variant:"outline",className:["rounded-full px-3 py-1.5 text-sm font-semibold",Ct>=0?"border-emerald-200 bg-emerald-50 text-emerald-800 hover:bg-emerald-50":"border-rose-200 bg-rose-50 text-rose-800 hover:bg-rose-50"].join(" "),children:[Ct>=0?"Potential Profit":"Below MAP",": ",formatMoney(Math.abs(Ct))]}),jsxRuntime.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:Ct>=0?`${$t}% margin vs MAP`:`${Math.abs($t)}% under MAP`})]}):null]}):null,jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs("div",{className:`${Ut?"mt-5":"mt-0"} grid grid-cols-1 gap-4 @sm:grid-cols-2`,children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border bg-background/50 p-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"cursor-help bg-transparent p-0 underline decoration-dotted underline-offset-4",children:"MAP"})}),jsxRuntime.jsx(TooltipContent,{children:"Minimum Advertised Price — the lowest price you can publicly advertise."})]})}),jsxRuntime.jsx("div",{className:"font-medium",children:typeof Rt=="number"?formatMoney(Rt):"—"})]}),typeof Ct=="number"&&typeof Ft=="number"&&typeof Rt=="number"?jsxRuntime.jsxs("div",{className:"text-right",children:[jsxRuntime.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Profit vs MAP"}),jsxRuntime.jsxs("div",{className:"text-sm font-semibold",children:[formatMoney(Rt)," - ",formatMoney(Ft)," = ",formatMoney(Ct)]})]}):null]}),jsxRuntime.jsx("div",{className:"flex items-start justify-between gap-4 rounded-md border bg-background/50 p-3",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"cursor-help bg-transparent p-0 underline decoration-dotted underline-offset-4",children:"MSRP"})}),jsxRuntime.jsx(TooltipContent,{children:"Manufacturer's Suggested Retail Price — a reference retail list price."})]})}),jsxRuntime.jsx("div",{className:"font-medium",children:typeof Mt=="number"?formatMoney(Mt):"—"})]})})]})})]}),A?.BodyHTML?jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none leading-relaxed [&_p]:mb-4 [&_p:last-child]:mb-0",dangerouslySetInnerHTML:{__html:A.BodyHTML}}):jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:[jsxRuntime.jsx(Info,{className:"h-4 w-4 inline mr-2"}),"No product description available."]})]})]}),jsxRuntime.jsx("div",{className:"self-start @md:sticky @md:top-4",children:jsxRuntime.jsx(ProductCard,{applicationId:e,product:A,defaultOpportunityNumber:s,onAddToCart:a,addingToCart:o,shopifyHostname:l,customAction:c})})]}),jsxRuntime.jsx("div",{className:"my-4",children:f||R?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):ot&&jsxRuntime.jsxs(Tabs,{value:at,onValueChange:lt,children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.SalesStatistics?.length??0)<=0,children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"inventory-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.Distribution?.Inventory?.length??0)<=0,children:"Inventory"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.Opportunities?.length??0)<=0,children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"active-orders-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.ActiveOrderDetails?.length??0)<=0,children:"Active Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"completed-orders-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.CompletedOrderDetails?.length??0)<=0,children:"Completed Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"returns-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:(A?.Returns?.length??0)<=0,children:"Returns"}),jsxRuntime.jsx(TabsTrigger,{value:"purchase-orders-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!V?.IsManufacturer||(A?.PurchaseOrders?.length??0)<=0&&(A?.Requisitions?.length??0)<=0,children:"Purchase Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse-tab",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!pt&&!ft,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChartCard,{statistics:A?.SalesStatistics??[],loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"inventory-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ProductInventoryGrid,{inventory:A?.Distribution?.Inventory??[],className:"bg-card text-card-foreground"})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:A?.Opportunities,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"active-orders-tab",children:(A?.ActiveOrderDetails?.length??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:A?.ActiveOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"completed-orders-tab",children:(A?.CompletedOrderDetails?.length??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:A?.CompletedOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"returns-tab",children:(A?.Returns?.length??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:A?.Returns,loading:R})})}),jsxRuntime.jsxs(TabsContent,{value:"purchase-orders-tab",children:[(A?.PurchaseOrders?.length??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Purchase Orders"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(PurchaseOrdersTable,{applicationId:e,purchaseOrders:A?.PurchaseOrders,loading:R})})]}),(A?.Requisitions?.length??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Draft Purchases"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(RequisitionsTable,{applicationId:e,requisitions:A?.Requisitions,loading:R})})]})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse-tab",children:jsxRuntime.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 @md:grid-cols-2",children:[pt&&jsxRuntime.jsxs(Card,{className:`w-full ${ft?"":"@md:col-span-2"}`,children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Receipts"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(ReceiptsTable,{applicationId:e,receipts:A?.Receipts,loading:R})})]}),ft&&jsxRuntime.jsxs(Card,{className:`w-full ${pt?"":"@md:col-span-2"}`,children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Logs"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(LogsTable,{logs:A?.Logs,loading:R})})]})]})})]})})]})}const colClasses={base:{1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6"},sm:{1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},md:{1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4",5:"md:grid-cols-5",6:"md:grid-cols-6"},lg:{1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4",5:"lg:grid-cols-5",6:"lg:grid-cols-6"},xl:{1:"xl:grid-cols-1",2:"xl:grid-cols-2",3:"xl:grid-cols-3",4:"xl:grid-cols-4",5:"xl:grid-cols-5",6:"xl:grid-cols-6"}},buildGridClassName=e=>{const t={base:1,md:2,...e};return["grid","gap-4",t.base?colClasses.base[t.base]:"",t.sm?colClasses.sm[t.sm]:"",t.md?colClasses.md[t.md]:"",t.lg?colClasses.lg[t.lg]:"",t.xl?colClasses.xl[t.xl]:""].filter(Boolean).join(" ")},SearchPageGrid=({results:e,groupBy:t,renderItem:n})=>{const s=t(e);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:Object.entries(s).map(([a,o])=>{const{items:l,gridCols:c}=o;if(l.length===0)return null;const d=buildGridClassName(c);return jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold tracking-tight mb-4",children:a}),jsxRuntime.jsx("div",{className:d,children:l.map((f,S)=>n(f,S))})]},a)})})},SearchPage=({query:e,results:t,isLoading:n,children:s})=>n?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-center py-24",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e&&t.length===0?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-start pt-16",children:jsxRuntime.jsx(Card,{className:"w-full max-w-lg",children:jsxRuntime.jsxs(CardHeader,{className:"text-center items-center",children:[jsxRuntime.jsx("div",{className:"rounded-full border bg-muted p-3 mb-4",children:jsxRuntime.jsx(SearchX,{className:"h-8 w-8 text-muted-foreground"})}),jsxRuntime.jsx(CardTitle,{children:"No Results Found"}),jsxRuntime.jsxs(CardDescription,{children:['Your search for "',e,'" did not return any results. Please try a different search term.']})]})})}):t.length>0?jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-8",children:jsxRuntime.jsx("div",{className:"col-span-3",children:s})}):null;var COLLAPSIBLE_NAME="Collapsible",[createCollapsibleContext,createCollapsibleScope]=createContextScope$2(COLLAPSIBLE_NAME),[CollapsibleProvider,useCollapsibleContext]=createCollapsibleContext(COLLAPSIBLE_NAME),Collapsible=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:a,disabled:o,onOpenChange:l,...c}=e,[d,f]=useControllableState({prop:s,defaultProp:a??!1,onChange:l,caller:COLLAPSIBLE_NAME});return jsxRuntime.jsx(CollapsibleProvider,{scope:n,disabled:o,contentId:useId$1(),open:d,onOpenToggle:React__namespace.useCallback(()=>f(S=>!S),[f]),children:jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(d),"data-disabled":o?"":void 0,...c,ref:t})})});Collapsible.displayName=COLLAPSIBLE_NAME;var TRIGGER_NAME$1="CollapsibleTrigger",CollapsibleTrigger=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,a=useCollapsibleContext(TRIGGER_NAME$1,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":getState$1(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...s,ref:t,onClick:composeEventHandlers(e.onClick,a.onOpenToggle)})});CollapsibleTrigger.displayName=TRIGGER_NAME$1;var CONTENT_NAME$1="CollapsibleContent",CollapsibleContent=React__namespace.forwardRef((e,t)=>{const{forceMount:n,...s}=e,a=useCollapsibleContext(CONTENT_NAME$1,e.__scopeCollapsible);return jsxRuntime.jsx(Presence,{present:n||a.open,children:({present:o})=>jsxRuntime.jsx(CollapsibleContentImpl,{...s,ref:t,present:o})})});CollapsibleContent.displayName=CONTENT_NAME$1;var CollapsibleContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:a,...o}=e,l=useCollapsibleContext(CONTENT_NAME$1,n),[c,d]=React__namespace.useState(s),f=React__namespace.useRef(null),S=useComposedRefs(t,f),R=React__namespace.useRef(0),A=R.current,V=React__namespace.useRef(0),at=V.current,lt=l.open||c,ot=React__namespace.useRef(lt),ct=React__namespace.useRef(void 0);return React__namespace.useEffect(()=>{const pt=requestAnimationFrame(()=>ot.current=!1);return()=>cancelAnimationFrame(pt)},[]),useLayoutEffect2(()=>{const pt=f.current;if(pt){ct.current=ct.current||{transitionDuration:pt.style.transitionDuration,animationName:pt.style.animationName},pt.style.transitionDuration="0s",pt.style.animationName="none";const ft=pt.getBoundingClientRect();R.current=ft.height,V.current=ft.width,ot.current||(pt.style.transitionDuration=ct.current.transitionDuration,pt.style.animationName=ct.current.animationName),d(s)}},[l.open,s]),jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!lt,...o,ref:S,style:{"--radix-collapsible-content-height":A?`${A}px`:void 0,"--radix-collapsible-content-width":at?`${at}px`:void 0,...e.style},children:lt&&a})});function getState$1(e){return e?"open":"closed"}var Root$1=Collapsible,Trigger=CollapsibleTrigger,Content=CollapsibleContent,ACCORDION_NAME="Accordion",ACCORDION_KEYS=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Collection,useCollection,createCollectionScope]=createCollection(ACCORDION_NAME),[createAccordionContext]=createContextScope$2(ACCORDION_NAME,[createCollectionScope,createCollapsibleScope]),useCollapsibleScope=createCollapsibleScope(),Accordion$1=React.forwardRef((e,t)=>{const{type:n,...s}=e,a=s,o=s;return jsxRuntime.jsx(Collection.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?jsxRuntime.jsx(AccordionImplMultiple,{...o,ref:t}):jsxRuntime.jsx(AccordionImplSingle,{...a,ref:t})})});Accordion$1.displayName=ACCORDION_NAME;var[AccordionValueProvider,useAccordionValueContext]=createAccordionContext(ACCORDION_NAME),[AccordionCollapsibleProvider,useAccordionCollapsibleContext]=createAccordionContext(ACCORDION_NAME,{collapsible:!1}),AccordionImplSingle=React.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:a=()=>{},collapsible:o=!1,...l}=e,[c,d]=useControllableState({prop:n,defaultProp:s??"",onChange:a,caller:ACCORDION_NAME});return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:React.useMemo(()=>c?[c]:[],[c]),onItemOpen:d,onItemClose:React.useCallback(()=>o&&d(""),[o,d]),children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:o,children:jsxRuntime.jsx(AccordionImpl,{...l,ref:t})})})}),AccordionImplMultiple=React.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:a=()=>{},...o}=e,[l,c]=useControllableState({prop:n,defaultProp:s??[],onChange:a,caller:ACCORDION_NAME}),d=React.useCallback(S=>c((R=[])=>[...R,S]),[c]),f=React.useCallback(S=>c((R=[])=>R.filter(A=>A!==S)),[c]);return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:l,onItemOpen:d,onItemClose:f,children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:!0,children:jsxRuntime.jsx(AccordionImpl,{...o,ref:t})})})}),[AccordionImplProvider,useAccordionContext]=createAccordionContext(ACCORDION_NAME),AccordionImpl=React.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=e,c=React.useRef(null),d=useComposedRefs(c,t),f=useCollection(n),R=useDirection(a)==="ltr",A=composeEventHandlers(e.onKeyDown,V=>{if(!ACCORDION_KEYS.includes(V.key))return;const at=V.target,lt=f().filter(Mt=>!Mt.ref.current?.disabled),ot=lt.findIndex(Mt=>Mt.ref.current===at),ct=lt.length;if(ot===-1)return;V.preventDefault();let pt=ot;const ft=0,mt=ct-1,yt=()=>{pt=ot+1,pt>mt&&(pt=ft)},dt=()=>{pt=ot-1,pt<ft&&(pt=mt)};switch(V.key){case"Home":pt=ft;break;case"End":pt=mt;break;case"ArrowRight":o==="horizontal"&&(R?yt():dt());break;case"ArrowDown":o==="vertical"&&yt();break;case"ArrowLeft":o==="horizontal"&&(R?dt():yt());break;case"ArrowUp":o==="vertical"&&dt();break}const Rt=pt%ct;lt[Rt].ref.current?.focus()});return jsxRuntime.jsx(AccordionImplProvider,{scope:n,disabled:s,direction:a,orientation:o,children:jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{...l,"data-orientation":o,ref:d,onKeyDown:s?void 0:A})})})}),ITEM_NAME="AccordionItem",[AccordionItemProvider,useAccordionItemContext]=createAccordionContext(ITEM_NAME),AccordionItem$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,value:s,...a}=e,o=useAccordionContext(ITEM_NAME,n),l=useAccordionValueContext(ITEM_NAME,n),c=useCollapsibleScope(n),d=useId$1(),f=s&&l.value.includes(s)||!1,S=o.disabled||e.disabled;return jsxRuntime.jsx(AccordionItemProvider,{scope:n,open:f,disabled:S,triggerId:d,children:jsxRuntime.jsx(Root$1,{"data-orientation":o.orientation,"data-state":getState(f),...c,...a,ref:t,disabled:S,open:f,onOpenChange:R=>{R?l.onItemOpen(s):l.onItemClose(s)}})})});AccordionItem$1.displayName=ITEM_NAME;var HEADER_NAME="AccordionHeader",AccordionHeader=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,a=useAccordionContext(ACCORDION_NAME,n),o=useAccordionItemContext(HEADER_NAME,n);return jsxRuntime.jsx(Primitive$4.h3,{"data-orientation":a.orientation,"data-state":getState(o.open),"data-disabled":o.disabled?"":void 0,...s,ref:t})});AccordionHeader.displayName=HEADER_NAME;var TRIGGER_NAME="AccordionTrigger",AccordionTrigger$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,a=useAccordionContext(ACCORDION_NAME,n),o=useAccordionItemContext(TRIGGER_NAME,n),l=useAccordionCollapsibleContext(TRIGGER_NAME,n),c=useCollapsibleScope(n);return jsxRuntime.jsx(Collection.ItemSlot,{scope:n,children:jsxRuntime.jsx(Trigger,{"aria-disabled":o.open&&!l.collapsible||void 0,"data-orientation":a.orientation,id:o.triggerId,...c,...s,ref:t})})});AccordionTrigger$1.displayName=TRIGGER_NAME;var CONTENT_NAME="AccordionContent",AccordionContent$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,a=useAccordionContext(ACCORDION_NAME,n),o=useAccordionItemContext(CONTENT_NAME,n),l=useCollapsibleScope(n);return jsxRuntime.jsx(Content,{role:"region","aria-labelledby":o.triggerId,"data-orientation":a.orientation,...l,...s,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});AccordionContent$1.displayName=CONTENT_NAME;function getState(e){return e?"open":"closed"}var Root2=Accordion$1,Item=AccordionItem$1,Header=AccordionHeader,Trigger2=AccordionTrigger$1,Content2=AccordionContent$1;const Accordion=Root2,AccordionItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Item,{ref:n,className:cn("border-b",e),...t}));AccordionItem.displayName="AccordionItem";const AccordionTrigger=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsx(Header,{className:"flex",children:jsxRuntime.jsxs(Trigger2,{ref:s,className:cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));AccordionTrigger.displayName=Trigger2.displayName;const AccordionContent=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsx(Content2,{ref:s,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:jsxRuntime.jsx("div",{className:cn("pb-4 pt-0",e),children:t})}));AccordionContent.displayName=Content2.displayName;function AssistantInsight({applicationId:e,prompt:t,smartAndSlow:n=!1,thinkingPlaceholderText:s="Thinking...",withCard:a=!0}){const[o]=usePostV4PartnerByApplicationIdGenerationRandmarAssistantMutation(),[l,c]=React.useState(null),[d,f]=React.useState(!1),[S,R]=React.useState(null),A=React.useRef(0),V=React.useRef(null);React.useEffect(()=>{if(V.current?.abort(),V.current=null,!t){c(null),f(!1),R(null);return}if(!e){c(null),f(!1),R("applicationId is required.");return}const ct=`Analyze the following prompt and Provide a helpful, concise response formatted in simple HTML.
760
760
  - Use <p> tags for paragraphs.
761
761
  - Use <strong> for emphasis.
762
762
  - You can also use ordered (<ol>) and unordered (<ul>) lists with list items (<li>).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.578.0",
4
+ "version": "1.579.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [