randmarcomps 1.512.0 → 1.514.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/randmarcomps.js
CHANGED
|
@@ -60751,14 +60751,14 @@ function ManufacturerInventoryFinanceCard({
|
|
|
60751
60751
|
isLoading: t
|
|
60752
60752
|
}) {
|
|
60753
60753
|
const {
|
|
60754
|
-
data: n,
|
|
60754
|
+
data: n = [],
|
|
60755
60755
|
isLoading: a,
|
|
60756
60756
|
isFetching: s
|
|
60757
60757
|
} = useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({
|
|
60758
60758
|
routeManufacturerId: (e == null ? void 0 : e.ManufacturerId) ?? ""
|
|
60759
60759
|
}, {
|
|
60760
60760
|
skip: !(e != null && e.ManufacturerId)
|
|
60761
|
-
}), o = (e == null ? void 0 : e.DefaultMaxInventoryValue) ?? 0, l =
|
|
60761
|
+
}), o = (e == null ? void 0 : e.DefaultMaxInventoryValue) ?? 0, l = n.reduce((g, A) => g + (A.InventoryValue || 0), 0), c = o - l, f = o > 0 ? Math.round(l / o * 100) : 0;
|
|
60762
60762
|
return t || a || s ? /* @__PURE__ */ jsxs(Card, { children: [
|
|
60763
60763
|
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
60764
60764
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-3/4" }),
|
|
@@ -60810,7 +60810,7 @@ function ManufacturerInventoryFinanceCard({
|
|
|
60810
60810
|
/* @__PURE__ */ jsx(
|
|
60811
60811
|
"span",
|
|
60812
60812
|
{
|
|
60813
|
-
className: `font-bold ${c >= 0 ? "text-emerald-600
|
|
60813
|
+
className: `font-bold ${c >= 0 ? "text-emerald-600" : "text-red-600"}`,
|
|
60814
60814
|
children: formatMoney(c)
|
|
60815
60815
|
}
|
|
60816
60816
|
)
|
|
@@ -75478,7 +75478,7 @@ const useConfig = () => {
|
|
|
75478
75478
|
"div",
|
|
75479
75479
|
{
|
|
75480
75480
|
"data-thin": !0,
|
|
75481
|
-
className: "flex h-full basis-[
|
|
75481
|
+
className: "flex h-full basis-[300px] shrink-0 border-l sm:basis-[300px] lg:basis-[300px]",
|
|
75482
75482
|
children: /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-col rounded-r-lg border-r bg-slate-50 text-slate-800", children: [
|
|
75483
75483
|
/* @__PURE__ */ jsxs("div", { className: "p-4 space-y-4 border-b border-slate-200/80", children: [
|
|
75484
75484
|
/* @__PURE__ */ jsxs("h4", { className: "flex items-center text-xs font-semibold tracking-wider text-slate-500 uppercase", children: [
|
|
@@ -1260,7 +1260,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let a="<p>An error
|
|
|
1260
1260
|
- less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
|
|
1261
1261
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
1262
1262
|
|
|
1263
|
-
Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:e,value:t,...n},s)=>jsxRuntime.jsx(Root$2,{ref:s,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Progress.displayName=Root$2.displayName;function ManufacturerInventoryFinanceCard({manufacturer:e,isLoading:t}){const{data:n,isLoading:s,isFetching:a}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(e==null?void 0:e.ManufacturerId)??""},{skip:!(e!=null&&e.ManufacturerId)}),o=(e==null?void 0:e.DefaultMaxInventoryValue)??0,l=(n||[]).reduce((g,R)=>g+(R.InventoryValue||0),0),c=o-l,f=Math.round(l/o*100);return t||s||a?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[o!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(l)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${c>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(c)})]})]}),o!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[f,"%"]}),f>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:f>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:f,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:e,isLoading:t}){const n=(e==null?void 0:e.CreditLimit)??0,s=(e==null?void 0:e.OutstandingBalance)??0,a=n-s,o=Math.round(s/n*100);return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(s)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${a>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(a)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[o,"%"]}),o>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:o>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:o,className:"h-2"})]})]})]})}function SalesChartCard({statistics:e,loading:t=!1,mode:n="month",chartHeight:s=300,className:a,size:o="default"}){return t?jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:s},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),o==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:e,mode:n,chartHeight:s,size:o})})]})}function ManufacturerOverviewPage({applicationId:e,readonly:t,withReports:n,manufacturer:s,userEmail:a}){const{data:o,isLoading:l,isError:c}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:e,withSpecification:!0},{skip:!!s}),[f,g]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>t?!1:f.publicInfo.hasUnsavedChanges||f.qualifications.hasUnsavedChanges||f.billingInfo.hasUnsavedChanges,[t,f]),A=React.useCallback((Ye,nt)=>{g(et=>{var rt;return((rt=et[Ye])==null?void 0:rt.hasUnsavedChanges)!==nt.hasUnsavedChanges?(console.log(`Updating form state for ${Ye}:`,nt.hasUnsavedChanges),{...et,[Ye]:nt}):et})},[]),{NavigationGuardDialog:V}=useRouterNavigationGuard(R),Ve=s??o;return jsxRuntime.jsxs("div",{className:"@container",children:[c?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:Ve==null?void 0:Ve.FiscalYearMonthStart,salesData:Ve==null?void 0:Ve.SalesData,isLoading:l}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(Ve==null?void 0:Ve.SalesStatistics)??[],loading:l}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",activeOrders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:Ve??{},onSave:()=>{},loading:l,readonly:t}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("publicInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:Ve,readonly:t,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("billingInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("qualifications",{hasUnsavedChanges:Ye})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",userEmail:a,isLoading:l})]}),jsxRuntime.jsx(V,{})]})}function ManufacturerCategories({categories:e,activeCategory:t,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsxs("div",{className:"flex gap-2 items-baseline",children:[jsxRuntime.jsx("p",{children:"Category filter:"}),e.map(s=>jsxRuntime.jsxs(Button$1,{onClick:()=>n(s.CategoryCode??""),variant:t===s.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[s.CategoryName??"Undefined",s.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${t!==s.CategoryCode?"text-red-500":""}`})]},s.CategoryCode))]})})})}function CategoryStats(e){const{data:t,isLoading:n,isFetching:s}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e.appID,manufacturerId:e.manufID,categoryCode:e.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:e.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(t==null?void 0:t.SalesStatistics)??[],loading:n||s,chartHeight:300})]})})})}function ManufacturerCategoriesStats(e){return(e.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:e.appID,manufID:e.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${e.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:s,children:a,...o},l)=>jsxRuntime.jsxs("div",{ref:l,className:cn(badgeVariants({variant:t,size:n}),e),...o,children:[s&&jsxRuntime.jsx("span",{className:"mr-1",children:s}),a]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:e="N/A",niche:t="N/A",productsNumber:n=0,autoreorder:s=!1,starred:a=!1,isLoading:o=!1,children:l}){return o?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[l,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),a?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:s?"default":"secondary",className:cn("text-xs",s?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:s?"Enabled":"Disabled"})]})]})]})]})})}function createSlot$1(e){const t=createSlotClone$1(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),f=c.find(isSlottable$1);if(f){const g=f.props.children,R=c.map(A=>A===f?React__namespace.Children.count(g)>1?React__namespace.Children.only(null):React__namespace.isValidElement(g)?g.props.children:null:A);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(g)?React__namespace.cloneElement(g,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone$1(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef$1(a),c=mergeProps$1(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$2=Symbol("radix.slottable");function isSlottable$1(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$2}function mergeProps$1(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const f=o(...c);return a(...c),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef$1(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection$1,useCollection$1,createCollectionScope$1]=createCollection(SELECT_NAME),[createSelectContext]=createContextScope$2(SELECT_NAME,[createCollectionScope$1,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$2=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:l,defaultValue:c,onValueChange:f,dir:g,name:R,autoComplete:A,disabled:V,required:Ve,form:Ye}=e,nt=usePopperScope$1(t),[et,rt]=React__namespace.useState(null),[st,ot]=React__namespace.useState(null),[ct,lt]=React__namespace.useState(!1),at=useDirection(g),[ut,pt]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:SELECT_NAME}),[mt,It]=useControllableState({prop:l,defaultProp:c,onChange:f,caller:SELECT_NAME}),Rt=React__namespace.useRef(null),ft=et?Ye||!!et.closest("form"):!0,[Mt,yt]=React__namespace.useState(new Set),Ct=Array.from(Mt).map(Ft=>Ft.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...nt,children:jsxRuntime.jsxs(SelectProvider,{required:Ve,scope:t,trigger:et,onTriggerChange:rt,valueNode:st,onValueNodeChange:ot,valueNodeHasChildren:ct,onValueNodeHasChildrenChange:lt,contentId:useId$1(),value:mt,onValueChange:It,open:ut,onOpenChange:pt,dir:at,triggerPointerDownPosRef:Rt,disabled:V,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Ft=>{yt(Ht=>new Set(Ht).add(Ft))},[]),onNativeOptionRemove:React__namespace.useCallback(Ft=>{yt(Ht=>{const Dt=new Set(Ht);return Dt.delete(Ft),Dt})},[]),children:n})}),ft?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:Ve,tabIndex:-1,name:R,autoComplete:A,value:mt,onChange:Ft=>It(Ft.target.value),disabled:V,form:Ye,children:[mt===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Mt)]},Ct):null]})})};Select$2.displayName=SELECT_NAME;var TRIGGER_NAME$5="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=usePopperScope$1(n),l=useSelectContext(TRIGGER_NAME$5,n),c=l.disabled||s,f=useComposedRefs(t,l.onTriggerChange),g=useCollection$1(n),R=React__namespace.useRef("touch"),[A,V,Ve]=useTypeaheadSearch(nt=>{const et=g().filter(ot=>!ot.disabled),rt=et.find(ot=>ot.value===l.value),st=findNextItem(et,nt,rt);st!==void 0&&l.onValueChange(st.value)}),Ye=nt=>{c||(l.onOpenChange(!0),Ve()),nt&&(l.triggerPointerDownPosRef.current={x:Math.round(nt.pageX),y:Math.round(nt.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":shouldShowPlaceholder(l.value)?"":void 0,...a,ref:f,onClick:composeEventHandlers(a.onClick,nt=>{nt.currentTarget.focus(),R.current!=="mouse"&&Ye(nt)}),onPointerDown:composeEventHandlers(a.onPointerDown,nt=>{R.current=nt.pointerType;const et=nt.target;et.hasPointerCapture(nt.pointerId)&&et.releasePointerCapture(nt.pointerId),nt.button===0&&nt.ctrlKey===!1&&nt.pointerType==="mouse"&&(Ye(nt),nt.preventDefault())}),onKeyDown:composeEventHandlers(a.onKeyDown,nt=>{const et=A.current!=="";!(nt.ctrlKey||nt.altKey||nt.metaKey)&&nt.key.length===1&&V(nt.key),!(et&&nt.key===" ")&&OPEN_KEYS.includes(nt.key)&&(Ye(),nt.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$5;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:l="",...c}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:g}=f,R=o!==void 0,A=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{g(R)},[g,R]),jsxRuntime.jsx(Primitive$4.span,{...c,ref:A,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l}):o})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$4="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$4,e.__scopeSelect),[s,a]=React__namespace.useState();if(useLayoutEffect2(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection$1.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),o):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$4;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$4),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot$1("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et,...rt}=e,st=useSelectContext(CONTENT_NAME$4,n),[ot,ct]=React__namespace.useState(null),[lt,at]=React__namespace.useState(null),ut=useComposedRefs(t,Yt=>ct(Yt)),[pt,mt]=React__namespace.useState(null),[It,Rt]=React__namespace.useState(null),ft=useCollection$1(n),[Mt,yt]=React__namespace.useState(!1),Ct=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(ot)return hideOthers(ot)},[ot]),useFocusGuards();const Ft=React__namespace.useCallback(Yt=>{const[fn,...Jt]=ft().map(Kt=>Kt.ref.current),[mn]=Jt.slice(-1),gn=document.activeElement;for(const Kt of Yt)if(Kt===gn||(Kt==null||Kt.scrollIntoView({block:"nearest"}),Kt===fn&<&&(lt.scrollTop=0),Kt===mn&<&&(lt.scrollTop=lt.scrollHeight),Kt==null||Kt.focus(),document.activeElement!==gn))return},[ft,lt]),Ht=React__namespace.useCallback(()=>Ft([pt,ot]),[Ft,pt,ot]);React__namespace.useEffect(()=>{Mt&&Ht()},[Mt,Ht]);const{onOpenChange:Dt,triggerPointerDownPosRef:$t}=st;React__namespace.useEffect(()=>{if(ot){let Yt={x:0,y:0};const fn=mn=>{var gn,Kt;Yt={x:Math.abs(Math.round(mn.pageX)-(((gn=$t.current)==null?void 0:gn.x)??0)),y:Math.abs(Math.round(mn.pageY)-(((Kt=$t.current)==null?void 0:Kt.y)??0))}},Jt=mn=>{Yt.x<=10&&Yt.y<=10?mn.preventDefault():ot.contains(mn.target)||Dt(!1),document.removeEventListener("pointermove",fn),$t.current=null};return $t.current!==null&&(document.addEventListener("pointermove",fn),document.addEventListener("pointerup",Jt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",fn),document.removeEventListener("pointerup",Jt,{capture:!0})}}},[ot,Dt,$t]),React__namespace.useEffect(()=>{const Yt=()=>Dt(!1);return window.addEventListener("blur",Yt),window.addEventListener("resize",Yt),()=>{window.removeEventListener("blur",Yt),window.removeEventListener("resize",Yt)}},[Dt]);const[zt,en]=useTypeaheadSearch(Yt=>{const fn=ft().filter(gn=>!gn.disabled),Jt=fn.find(gn=>gn.ref.current===document.activeElement),mn=findNextItem(fn,Yt,Jt);mn&&setTimeout(()=>mn.ref.current.focus())}),Xt=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&(mt(Yt),mn&&(Ct.current=!0))},[st.value]),sn=React__namespace.useCallback(()=>ot==null?void 0:ot.focus(),[ot]),un=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&Rt(Yt)},[st.value]),Qt=s==="popper"?SelectPopperPosition:SelectItemAlignedPosition,pn=Qt===SelectPopperPosition?{side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:ot,viewport:lt,onViewportChange:at,itemRefCallback:Xt,selectedItem:pt,onItemLeave:sn,itemTextRefCallback:un,focusSelectedItem:Ht,selectedItemText:It,position:s,isPositioned:Mt,searchRef:zt,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:st.open,onMountAutoFocus:Yt=>{Yt.preventDefault()},onUnmountAutoFocus:composeEventHandlers(a,Yt=>{var fn;(fn=st.trigger)==null||fn.focus({preventScroll:!0}),Yt.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Yt=>Yt.preventDefault(),onDismiss:()=>st.onOpenChange(!1),children:jsxRuntime.jsx(Qt,{role:"listbox",id:st.contentId,"data-state":st.open?"open":"closed",dir:st.dir,onContextMenu:Yt=>Yt.preventDefault(),...rt,...pn,onPlaced:()=>yt(!0),ref:ut,style:{display:"flex",flexDirection:"column",outline:"none",...rt.style},onKeyDown:composeEventHandlers(rt.onKeyDown,Yt=>{const fn=Yt.ctrlKey||Yt.altKey||Yt.metaKey;if(Yt.key==="Tab"&&Yt.preventDefault(),!fn&&Yt.key.length===1&&en(Yt.key),["ArrowUp","ArrowDown","Home","End"].includes(Yt.key)){let mn=ft().filter(gn=>!gn.disabled).map(gn=>gn.ref.current);if(["ArrowUp","End"].includes(Yt.key)&&(mn=mn.slice().reverse()),["ArrowUp","ArrowDown"].includes(Yt.key)){const gn=Yt.target,Kt=mn.indexOf(gn);mn=mn.slice(Kt+1)}setTimeout(()=>Ft(mn)),Yt.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=useSelectContext(CONTENT_NAME$4,n),l=useSelectContentContext(CONTENT_NAME$4,n),[c,f]=React__namespace.useState(null),[g,R]=React__namespace.useState(null),A=useComposedRefs(t,ut=>R(ut)),V=useCollection$1(n),Ve=React__namespace.useRef(!1),Ye=React__namespace.useRef(!0),{viewport:nt,selectedItem:et,selectedItemText:rt,focusSelectedItem:st}=l,ot=React__namespace.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&g&&nt&&et&&rt){const ut=o.trigger.getBoundingClientRect(),pt=g.getBoundingClientRect(),mt=o.valueNode.getBoundingClientRect(),It=rt.getBoundingClientRect();if(o.dir!=="rtl"){const gn=It.left-pt.left,Kt=mt.left-gn,Tn=ut.left-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.left=Rn+"px"}else{const gn=pt.right-It.right,Kt=window.innerWidth-mt.right-gn,Tn=window.innerWidth-ut.right-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.right=Rn+"px"}const Rt=V(),ft=window.innerHeight-CONTENT_MARGIN*2,Mt=nt.scrollHeight,yt=window.getComputedStyle(g),Ct=parseInt(yt.borderTopWidth,10),Ft=parseInt(yt.paddingTop,10),Ht=parseInt(yt.borderBottomWidth,10),Dt=parseInt(yt.paddingBottom,10),$t=Ct+Ft+Mt+Dt+Ht,zt=Math.min(et.offsetHeight*5,$t),en=window.getComputedStyle(nt),Xt=parseInt(en.paddingTop,10),sn=parseInt(en.paddingBottom,10),un=ut.top+ut.height/2-CONTENT_MARGIN,Qt=ft-un,pn=et.offsetHeight/2,Yt=et.offsetTop+pn,fn=Ct+Ft+Yt,Jt=$t-fn;if(fn<=un){const gn=Rt.length>0&&et===Rt[Rt.length-1].ref.current;c.style.bottom="0px";const Kt=g.clientHeight-nt.offsetTop-nt.offsetHeight,Tn=Math.max(Qt,pn+(gn?sn:0)+Kt+Ht),hn=fn+Tn;c.style.height=hn+"px"}else{const gn=Rt.length>0&&et===Rt[0].ref.current;c.style.top="0px";const Tn=Math.max(un,Ct+nt.offsetTop+(gn?Xt:0)+pn)+Jt;c.style.height=Tn+"px",nt.scrollTop=fn-un+nt.offsetTop}c.style.margin=`${CONTENT_MARGIN}px 0`,c.style.minHeight=zt+"px",c.style.maxHeight=ft+"px",s==null||s(),requestAnimationFrame(()=>Ve.current=!0)}},[V,o.trigger,o.valueNode,c,g,nt,et,rt,o.dir,s]);useLayoutEffect2(()=>ot(),[ot]);const[ct,lt]=React__namespace.useState();useLayoutEffect2(()=>{g&<(window.getComputedStyle(g).zIndex)},[g]);const at=React__namespace.useCallback(ut=>{ut&&Ye.current===!0&&(ot(),st==null||st(),Ye.current=!1)},[ot,st]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:Ve,onScrollButtonChange:at,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:ct},children:jsxRuntime.jsx(Primitive$4.div,{...a,ref:A,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=CONTENT_MARGIN,...o}=e,l=usePopperScope$1(n);return jsxRuntime.jsx(Content$2,{...l,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME$4,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=useSelectContentContext(VIEWPORT_NAME,n),l=useSelectViewportContext(VIEWPORT_NAME,n),c=useComposedRefs(t,o.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),jsxRuntime.jsx(Collection$1.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:composeEventHandlers(a.onScroll,g=>{const R=g.currentTarget,{contentWrapper:A,shouldExpandOnScrollRef:V}=l;if(V!=null&&V.current&&A){const Ve=Math.abs(f.current-R.scrollTop);if(Ve>0){const Ye=window.innerHeight-CONTENT_MARGIN*2,nt=parseFloat(A.style.minHeight),et=parseFloat(A.style.height),rt=Math.max(nt,et);if(rt<Ye){const st=rt+Ve,ot=Math.min(Ye,st),ct=st-ot;A.style.height=ot+"px",A.style.bottom==="0px"&&(R.scrollTop=ct>0?ct:0,A.style.justifyContent="flex-end")}}}f.current=R.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useId$1();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:a,children:jsxRuntime.jsx(Primitive$4.div,{role:"group","aria-labelledby":a,...s,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive$4.div,{id:a.id,...s,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME$1="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME$1),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...l}=e,c=useSelectContext(ITEM_NAME$1,n),f=useSelectContentContext(ITEM_NAME$1,n),g=c.value===s,[R,A]=React__namespace.useState(o??""),[V,Ve]=React__namespace.useState(!1),Ye=useComposedRefs(t,st=>{var ot;return(ot=f.itemRefCallback)==null?void 0:ot.call(f,st,s,a)}),nt=useId$1(),et=React__namespace.useRef("touch"),rt=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:s,disabled:a,textId:nt,isSelected:g,onItemTextChange:React__namespace.useCallback(st=>{A(ot=>ot||((st==null?void 0:st.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection$1.ItemSlot,{scope:n,value:s,disabled:a,textValue:R,children:jsxRuntime.jsx(Primitive$4.div,{role:"option","aria-labelledby":nt,"data-highlighted":V?"":void 0,"aria-selected":g&&V,"data-state":g?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:Ye,onFocus:composeEventHandlers(l.onFocus,()=>Ve(!0)),onBlur:composeEventHandlers(l.onBlur,()=>Ve(!1)),onClick:composeEventHandlers(l.onClick,()=>{et.current!=="mouse"&&rt()}),onPointerUp:composeEventHandlers(l.onPointerUp,()=>{et.current==="mouse"&&rt()}),onPointerDown:composeEventHandlers(l.onPointerDown,st=>{et.current=st.pointerType}),onPointerMove:composeEventHandlers(l.onPointerMove,st=>{var ot;et.current=st.pointerType,a?(ot=f.onItemLeave)==null||ot.call(f):et.current==="mouse"&&st.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(l.onPointerLeave,st=>{var ot;st.currentTarget===document.activeElement&&((ot=f.onItemLeave)==null||ot.call(f))}),onKeyDown:composeEventHandlers(l.onKeyDown,st=>{var ct;((ct=f.searchRef)==null?void 0:ct.current)!==""&&st.key===" "||(SELECTION_KEYS.includes(st.key)&&rt(),st.key===" "&&st.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME$1;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,l=useSelectContext(ITEM_TEXT_NAME,n),c=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),g=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[R,A]=React__namespace.useState(null),V=useComposedRefs(t,rt=>A(rt),f.onItemTextChange,rt=>{var st;return(st=c.itemTextRefCallback)==null?void 0:st.call(c,rt,f.value,f.disabled)}),Ve=R==null?void 0:R.textContent,Ye=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:Ve},f.value),[f.disabled,f.value,Ve]),{onNativeOptionAdd:nt,onNativeOptionRemove:et}=g;return useLayoutEffect2(()=>(nt(Ye),()=>et(Ye)),[nt,et,Ye]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:f.textId,...o,ref:V}),f.isSelected&&l.valueNode&&!l.valueNodeHasChildren?ReactDOM__namespace.createPortal(o.children,l.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...s,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollTop>0;o(g)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollHeight-f.clientHeight,R=Math.ceil(f.scrollTop)<g;o(R)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=useSelectContentContext("SelectScrollButton",n),l=React__namespace.useRef(null),c=useCollection$1(n),f=React__namespace.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var R;const g=c().find(A=>A.ref.current===document.activeElement);(R=g==null?void 0:g.ref.current)==null||R.scrollIntoView({block:"nearest"})},[c]),jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:composeEventHandlers(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:composeEventHandlers(a.onPointerMove,()=>{var g;(g=o.onItemLeave)==null||g.call(o),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:composeEventHandlers(a.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...s,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=usePopperScope$1(n),o=useSelectContext(ARROW_NAME$1,n),l=useSelectContentContext(ARROW_NAME$1,n);return o.open&&l.position==="popper"?jsxRuntime.jsx(Arrow,{...a,...s,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=React__namespace.useRef(null),o=useComposedRefs(s,a),l=usePrevious(t);return React__namespace.useEffect(()=>{const c=a.current;if(!c)return;const f=window.HTMLSelectElement.prototype,R=Object.getOwnPropertyDescriptor(f,"value").set;if(l!==t&&R){const A=new Event("change",{bubbles:!0});R.call(c,t),c.dispatchEvent(A)}},[l,t]),jsxRuntime.jsx(Primitive$4.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:o,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),s=React__namespace.useRef(0),a=React__namespace.useCallback(l=>{const c=n.current+l;t(c),(function f(g){n.current=g,window.clearTimeout(s.current),g!==""&&(s.current=window.setTimeout(()=>f(""),1e3))})(c)},[t]),o=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function findNextItem(e,t,n){const a=t.length>1&&Array.from(t).every(g=>g===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=wrapArray(e,Math.max(o,0));a.length===1&&(l=l.filter(g=>g!==n));const f=l.find(g=>g.textValue.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Root2$3=Select$2,Trigger$2=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$3=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$2=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select$1=Root2$3,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Trigger$2,{ref:s,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$2.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$3,{ref:a,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$3.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Item$2,{ref:s,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item$2.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;function ManufacturerProducts({applicationId:e,manufacturer:t,shopifyHostName:n}){var ot,ct,lt,at,ut;const[s]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[a,o]=React.useState(((ct=(ot=t.Categories)==null?void 0:ot[0])==null?void 0:ct.CategoryCode)||""),[l,c]=React.useState(!1),[f,g]=React.useState(!1),[R,A]=React.useState("percentile"),{toast:V}=useToast(),{data:Ve,isLoading:Ye,isFetching:nt}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e,manufacturerId:t.ManufacturerId,categoryCode:a??""},{skip:!t.ManufacturerId||!a}),et=async()=>{try{c(!0),g(!1),await s({routeResellerId:e,manufacturerId:t.ManufacturerId??"",categoryCode:a,shopifyHostName:n}).unwrap()&&V({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(pt){console.error("Error syncing to Shopify:",pt),V({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{c(!1)}},rt=()=>{var pt,mt;return((mt=(pt=t.Categories)==null?void 0:pt.find(It=>It.CategoryCode===a))==null?void 0:mt.CategoryName)||a},st=React.useMemo(()=>Ve!=null&&Ve.Products?[...Ve.Products].sort((pt,mt)=>R==="price-asc"?(pt.MAP??0)-(mt.MAP??0):R==="price-desc"?(mt.MAP??0)-(pt.MAP??0):R==="name"?(pt.Title??"").localeCompare(mt.Title??""):R==="percentile"?(mt.OverallPercentileRank??0)-(pt.OverallPercentileRank??0):0):[],[Ve==null?void 0:Ve.Products,R]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:rt(),niche:(Ve==null?void 0:Ve.Niche)||"",productsNumber:((lt=Ve==null?void 0:Ve.Products)==null?void 0:lt.length)||0,autoreorder:(Ve==null?void 0:Ve.AutoReorder)||!1,starred:(Ve==null?void 0:Ve.Starred)||!1,isLoading:Ye||nt,children:n&&((at=t.Categories)==null?void 0:at.findIndex(pt=>pt.AvailableToBuy))!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",disabled:l,onClick:()=>g(!0),children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(ut=t.Categories)==null?void 0:ut.find(pt=>pt.CategoryCode===a)].filter(Boolean),manufID:t.ManufacturerId,appID:e}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,loading:Ye||nt})]})]}),jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsxs("div",{className:"flex justify-between items-center mt-7 mb-4",children:[jsxRuntime.jsx("h4",{className:"text-xl md:text-2xl text-foreground font-bold",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Sort by:"}),jsxRuntime.jsxs(Select$1,{value:R,onValueChange:A,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[220px]",children:jsxRuntime.jsx(SelectValue,{})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"price-asc",children:"MAP: Low to High"}),jsxRuntime.jsx(SelectItem,{value:"price-desc",children:"MAP: High to Low"}),jsxRuntime.jsx(SelectItem,{value:"name",children:"Name"}),jsxRuntime.jsx(SelectItem,{value:"percentile",children:"Best Selling"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:Ye||nt?Array.from({length:4}).map((pt,mt)=>jsxRuntime.jsx(ProductCard,{},mt)):st.length>0?st.map(pt=>jsxRuntime.jsx(ProductCard,{applicationId:e,product:pt,viewProductLink:`/${e}/Product/${pt.RandmarSKU}`,shopifyHostname:n},pt.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:g,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',rt(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:et,disabled:l,children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:e,partnerId:t,userEmail:n,shopifyHostName:s,isSuperAdmin:a}){var ct,lt,at;const{data:o}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),{data:l,isLoading:c,isFetching:f}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:e,partnerId:t,withSpecification:!0}),{toast:g}=useToast(),[R]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),nt=async()=>{try{V(!0),Ye(!1),await R({routeResellerId:e??"",manufacturerId:t??"",shopifyHostName:s}).unwrap()&&g({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(ut){console.error("Error syncing to Shopify:",ut),g({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{V(!1)}},et=()=>l!=null&&l.Manufacturer?"products":l!=null&&l.Reseller?"reseller-overview":"",rt=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("tab"),st=()=>{const ut=rt();return ut==="assistant"?"assistant":ut==="reseller-overview"&&(l!=null&&l.Reseller)?"reseller-overview":ut==="manufacturer-overview"&&(l!=null&&l.Manufacturer)?"manufacturer-overview":ut==="products"&&(l!=null&&l.Manufacturer)?"products":et()||"assistant"},ot=usePartnershipAssistantPrompt(o,l);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:l,loading:c||f,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((l==null?void 0:l.Manufacturer)||c||f)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:l==null?void 0:l.Manufacturer,loading:c||f,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:e,manufacturer:l==null?void 0:l.Manufacturer}),s&&((lt=(ct=l==null?void 0:l.Manufacturer)==null?void 0:ct.Categories)==null?void 0:lt.findIndex(ut=>ut.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:Ve,onOpenChange:Ye,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',(at=l==null?void 0:l.Manufacturer)==null?void 0:at.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>Ye(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:nt,disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:l==null?void 0:l.Reseller,loading:c||f})]})]}),((l==null?void 0:l.Reseller)||(l==null?void 0:l.Manufacturer))&&!c&&!f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:st(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:l.ApplicationId||"",reseller:l==null?void 0:l.Reseller,userEmail:n,isSuperAdmin:a,withoutReports:!0})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:l==null?void 0:l.Manufacturer,applicationId:e,userEmail:n})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:e,manufacturer:l.Manufacturer,shopifyHostName:s})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:ot,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(c||f)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:e,appID:t,isLoading:n,readonly:s,onUnsavedChanges:a})=>{const{toast:o}=useToast(),[l]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[c,f]=React.useState({}),g=React.useMemo(()=>({publicEmail:e.PublicEmail??"",contactName:e.ContactName??"",phone:e.Phone??"",website:e.Website??""}),[e]),{register:R,handleSubmit:A,reset:V,watch:Ve,formState:{errors:Ye,isSubmitting:nt}}=useForm({defaultValues:g}),et=Ve(),rt=React.useCallback(()=>c?JSON.stringify(et)!==JSON.stringify(c):!1,[et,c]);React.useEffect(()=>{a&&a(rt())},[rt,a]),React.useEffect(()=>{e&&Object.keys(e).length>0&&(V(g),f(g))},[e,V,g]);const st=async ct=>{let lt=!0,at=!1;const ut=Object.keys(ct).map(pt=>({key:pt,keyApi:pt.charAt(0).toUpperCase()+pt.slice(1)}));for(const pt of ut){const mt=ct[pt.key],It=e[pt.keyApi];if(mt!==It&&mt!==void 0){at=!0;try{await l({applicationId:t,fieldName:pt.keyApi,newValue:String(mt)}).unwrap()||(lt=!1)}catch(Rt){console.error(`Error updating ${pt.keyApi}:`,Rt),lt=!1}}}lt&&at?(o({title:"Public info",description:"Information updated successfully",variant:"success"}),f({...ct}),a&&a(!1)):lt||o({title:"Updation error",description:"Failed to update",variant:"destructive"})},ot=ct=>!ct||ct.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",s?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(ot(Ve("contactName"))||ot(Ve("publicEmail"))||ot(Ve("website"))||ot(Ve("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:A(st),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:s,...R("contactName",{}),className:Ye.contactName||ot(Ve("contactName"))?"input-error-indicator":""}),Ye.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:s,...R("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:Ye.publicEmail||ot(Ve("publicEmail"))?"input-error-indicator":""}),Ye.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:s,...R("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.website||ot(Ve("website"))?"input-error-indicator":""}),Ye.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:s,...R("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.phone||ot(Ve("phone"))?"input-error-indicator":""}),Ye.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:nt||s,className:s?"hidden":"",children:nt?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:e,reseller:t,isLoading:n,withoutReports:s,userEmail:a,isSuperAdmin:o}){const{toast:l}=useToast(),{Statement:c,CreditLimit:f}=t,[g,R]=React.useState(!1),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),[nt,et]=React.useState(!1),[rt,st]=React.useState(a||""),[ot,ct]=React.useState(!1),[lt,at]=React.useState((f==null?void 0:f.toString())||""),[ut,{isLoading:pt}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),mt=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:f||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),o&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{ct(!0),at((f==null?void 0:f.toString())||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[It]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),Rt=async Ct=>{Ct?R(!0):V(!0);try{const Ht=(await It({routeResellerId:e,documentNumber:`ST${e}`})).data;if(!Ht)throw new Error("No data received for download.");if(Ct)window.open(Ht);else{const Dt=document.createElement("a");Dt.href=Ht,Dt.download=`ST${e}.pdf`,document.body.appendChild(Dt),Dt.click(),Dt.remove()}l({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Ft){console.error("Download Error:",Ft),l({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{Ct?R(!1):V(!1)}},[ft]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),Mt=async()=>{if(!rt||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(rt)){l({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}Ye(!0);try{await ft({routeResellerId:e,emailAddress:rt}).unwrap(),l({title:"Success",description:`Statement sent to ${rt} successfully.`,variant:"success"}),et(!1)}catch(Ft){console.error("Send Email Error:",Ft),l({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{Ye(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},Ct))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(Ct=>jsxRuntime.jsx("div",{className:Ct===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},Ct))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const yt=!s;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:mt.slice(0,3).map((Ct,Ft)=>jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value},Ft))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:mt.slice(3).map((Ct,Ft)=>jsxRuntime.jsx("div",{className:Ft===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value})},Ft))})]}),yt&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!0),disabled:g,children:g?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!1),disabled:A,children:A?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>et(!0),disabled:Ve,children:Ve?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${e}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:nt,onOpenChange:et,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:rt,onChange:Ct=>st(Ct.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:Mt,disabled:Ve||!rt,children:Ve?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:ot,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:lt,onChange:Ct=>at(Ct.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const Ct=Number(lt);if(isNaN(Ct)){l({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await ut({applicationId:e,newValue:Ct}).unwrap(),ct(!1),l({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Ft){console.error("Update Credit Limit Error:",Ft),l({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:pt,children:pt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:e,label:t,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(e,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:t})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:e,setOpen:t,tier:n,onTierChange:s,isLoading:a}){const o=()=>{t(!1)};return jsxRuntime.jsx(Dialog,{open:e,onOpenChange:t,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:o,disabled:a,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:s,disabled:a,children:a?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=e=>e===1?"The Best":e===2?"Fixed 12.5% GP on all items":e===3?"Advantageous":e===4?"Buying Group":e===5?"Cost":e,getShippingText=e=>e==="A"?"Free or Custom":e==="B"?"Fixed $10 anywhere":e==="C"?`Free shipping on $150+ orders to your location,
|
|
1263
|
+
Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:e,value:t,...n},s)=>jsxRuntime.jsx(Root$2,{ref:s,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Progress.displayName=Root$2.displayName;function ManufacturerInventoryFinanceCard({manufacturer:e,isLoading:t}){const{data:n=[],isLoading:s,isFetching:a}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(e==null?void 0:e.ManufacturerId)??""},{skip:!(e!=null&&e.ManufacturerId)}),o=(e==null?void 0:e.DefaultMaxInventoryValue)??0,l=n.reduce((g,R)=>g+(R.InventoryValue||0),0),c=o-l,f=o>0?Math.round(l/o*100):0;return t||s||a?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[o!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(l)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${c>=0?"text-emerald-600":"text-red-600"}`,children:formatMoney(c)})]})]}),o!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[f,"%"]}),f>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:f>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:f,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:e,isLoading:t}){const n=(e==null?void 0:e.CreditLimit)??0,s=(e==null?void 0:e.OutstandingBalance)??0,a=n-s,o=Math.round(s/n*100);return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(s)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${a>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(a)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[o,"%"]}),o>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:o>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:o,className:"h-2"})]})]})]})}function SalesChartCard({statistics:e,loading:t=!1,mode:n="month",chartHeight:s=300,className:a,size:o="default"}){return t?jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:s},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),o==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:e,mode:n,chartHeight:s,size:o})})]})}function ManufacturerOverviewPage({applicationId:e,readonly:t,withReports:n,manufacturer:s,userEmail:a}){const{data:o,isLoading:l,isError:c}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:e,withSpecification:!0},{skip:!!s}),[f,g]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>t?!1:f.publicInfo.hasUnsavedChanges||f.qualifications.hasUnsavedChanges||f.billingInfo.hasUnsavedChanges,[t,f]),A=React.useCallback((Ye,nt)=>{g(et=>{var rt;return((rt=et[Ye])==null?void 0:rt.hasUnsavedChanges)!==nt.hasUnsavedChanges?(console.log(`Updating form state for ${Ye}:`,nt.hasUnsavedChanges),{...et,[Ye]:nt}):et})},[]),{NavigationGuardDialog:V}=useRouterNavigationGuard(R),Ve=s??o;return jsxRuntime.jsxs("div",{className:"@container",children:[c?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:Ve==null?void 0:Ve.FiscalYearMonthStart,salesData:Ve==null?void 0:Ve.SalesData,isLoading:l}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(Ve==null?void 0:Ve.SalesStatistics)??[],loading:l}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",activeOrders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:Ve??{},onSave:()=>{},loading:l,readonly:t}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("publicInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:Ve,readonly:t,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("billingInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("qualifications",{hasUnsavedChanges:Ye})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",userEmail:a,isLoading:l})]}),jsxRuntime.jsx(V,{})]})}function ManufacturerCategories({categories:e,activeCategory:t,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsxs("div",{className:"flex gap-2 items-baseline",children:[jsxRuntime.jsx("p",{children:"Category filter:"}),e.map(s=>jsxRuntime.jsxs(Button$1,{onClick:()=>n(s.CategoryCode??""),variant:t===s.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[s.CategoryName??"Undefined",s.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${t!==s.CategoryCode?"text-red-500":""}`})]},s.CategoryCode))]})})})}function CategoryStats(e){const{data:t,isLoading:n,isFetching:s}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e.appID,manufacturerId:e.manufID,categoryCode:e.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:e.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(t==null?void 0:t.SalesStatistics)??[],loading:n||s,chartHeight:300})]})})})}function ManufacturerCategoriesStats(e){return(e.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:e.appID,manufID:e.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${e.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:s,children:a,...o},l)=>jsxRuntime.jsxs("div",{ref:l,className:cn(badgeVariants({variant:t,size:n}),e),...o,children:[s&&jsxRuntime.jsx("span",{className:"mr-1",children:s}),a]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:e="N/A",niche:t="N/A",productsNumber:n=0,autoreorder:s=!1,starred:a=!1,isLoading:o=!1,children:l}){return o?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[l,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),a?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:s?"default":"secondary",className:cn("text-xs",s?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:s?"Enabled":"Disabled"})]})]})]})]})})}function createSlot$1(e){const t=createSlotClone$1(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),f=c.find(isSlottable$1);if(f){const g=f.props.children,R=c.map(A=>A===f?React__namespace.Children.count(g)>1?React__namespace.Children.only(null):React__namespace.isValidElement(g)?g.props.children:null:A);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(g)?React__namespace.cloneElement(g,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone$1(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef$1(a),c=mergeProps$1(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$2=Symbol("radix.slottable");function isSlottable$1(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$2}function mergeProps$1(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const f=o(...c);return a(...c),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef$1(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection$1,useCollection$1,createCollectionScope$1]=createCollection(SELECT_NAME),[createSelectContext]=createContextScope$2(SELECT_NAME,[createCollectionScope$1,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$2=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:l,defaultValue:c,onValueChange:f,dir:g,name:R,autoComplete:A,disabled:V,required:Ve,form:Ye}=e,nt=usePopperScope$1(t),[et,rt]=React__namespace.useState(null),[st,ot]=React__namespace.useState(null),[ct,lt]=React__namespace.useState(!1),at=useDirection(g),[ut,pt]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:SELECT_NAME}),[mt,It]=useControllableState({prop:l,defaultProp:c,onChange:f,caller:SELECT_NAME}),Rt=React__namespace.useRef(null),ft=et?Ye||!!et.closest("form"):!0,[Mt,yt]=React__namespace.useState(new Set),Ct=Array.from(Mt).map(Ft=>Ft.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...nt,children:jsxRuntime.jsxs(SelectProvider,{required:Ve,scope:t,trigger:et,onTriggerChange:rt,valueNode:st,onValueNodeChange:ot,valueNodeHasChildren:ct,onValueNodeHasChildrenChange:lt,contentId:useId$1(),value:mt,onValueChange:It,open:ut,onOpenChange:pt,dir:at,triggerPointerDownPosRef:Rt,disabled:V,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Ft=>{yt(Ht=>new Set(Ht).add(Ft))},[]),onNativeOptionRemove:React__namespace.useCallback(Ft=>{yt(Ht=>{const Dt=new Set(Ht);return Dt.delete(Ft),Dt})},[]),children:n})}),ft?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:Ve,tabIndex:-1,name:R,autoComplete:A,value:mt,onChange:Ft=>It(Ft.target.value),disabled:V,form:Ye,children:[mt===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Mt)]},Ct):null]})})};Select$2.displayName=SELECT_NAME;var TRIGGER_NAME$5="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=usePopperScope$1(n),l=useSelectContext(TRIGGER_NAME$5,n),c=l.disabled||s,f=useComposedRefs(t,l.onTriggerChange),g=useCollection$1(n),R=React__namespace.useRef("touch"),[A,V,Ve]=useTypeaheadSearch(nt=>{const et=g().filter(ot=>!ot.disabled),rt=et.find(ot=>ot.value===l.value),st=findNextItem(et,nt,rt);st!==void 0&&l.onValueChange(st.value)}),Ye=nt=>{c||(l.onOpenChange(!0),Ve()),nt&&(l.triggerPointerDownPosRef.current={x:Math.round(nt.pageX),y:Math.round(nt.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":shouldShowPlaceholder(l.value)?"":void 0,...a,ref:f,onClick:composeEventHandlers(a.onClick,nt=>{nt.currentTarget.focus(),R.current!=="mouse"&&Ye(nt)}),onPointerDown:composeEventHandlers(a.onPointerDown,nt=>{R.current=nt.pointerType;const et=nt.target;et.hasPointerCapture(nt.pointerId)&&et.releasePointerCapture(nt.pointerId),nt.button===0&&nt.ctrlKey===!1&&nt.pointerType==="mouse"&&(Ye(nt),nt.preventDefault())}),onKeyDown:composeEventHandlers(a.onKeyDown,nt=>{const et=A.current!=="";!(nt.ctrlKey||nt.altKey||nt.metaKey)&&nt.key.length===1&&V(nt.key),!(et&&nt.key===" ")&&OPEN_KEYS.includes(nt.key)&&(Ye(),nt.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$5;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:l="",...c}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:g}=f,R=o!==void 0,A=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{g(R)},[g,R]),jsxRuntime.jsx(Primitive$4.span,{...c,ref:A,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l}):o})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$4="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$4,e.__scopeSelect),[s,a]=React__namespace.useState();if(useLayoutEffect2(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection$1.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),o):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$4;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$4),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot$1("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et,...rt}=e,st=useSelectContext(CONTENT_NAME$4,n),[ot,ct]=React__namespace.useState(null),[lt,at]=React__namespace.useState(null),ut=useComposedRefs(t,Yt=>ct(Yt)),[pt,mt]=React__namespace.useState(null),[It,Rt]=React__namespace.useState(null),ft=useCollection$1(n),[Mt,yt]=React__namespace.useState(!1),Ct=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(ot)return hideOthers(ot)},[ot]),useFocusGuards();const Ft=React__namespace.useCallback(Yt=>{const[fn,...Jt]=ft().map(Kt=>Kt.ref.current),[mn]=Jt.slice(-1),gn=document.activeElement;for(const Kt of Yt)if(Kt===gn||(Kt==null||Kt.scrollIntoView({block:"nearest"}),Kt===fn&<&&(lt.scrollTop=0),Kt===mn&<&&(lt.scrollTop=lt.scrollHeight),Kt==null||Kt.focus(),document.activeElement!==gn))return},[ft,lt]),Ht=React__namespace.useCallback(()=>Ft([pt,ot]),[Ft,pt,ot]);React__namespace.useEffect(()=>{Mt&&Ht()},[Mt,Ht]);const{onOpenChange:Dt,triggerPointerDownPosRef:$t}=st;React__namespace.useEffect(()=>{if(ot){let Yt={x:0,y:0};const fn=mn=>{var gn,Kt;Yt={x:Math.abs(Math.round(mn.pageX)-(((gn=$t.current)==null?void 0:gn.x)??0)),y:Math.abs(Math.round(mn.pageY)-(((Kt=$t.current)==null?void 0:Kt.y)??0))}},Jt=mn=>{Yt.x<=10&&Yt.y<=10?mn.preventDefault():ot.contains(mn.target)||Dt(!1),document.removeEventListener("pointermove",fn),$t.current=null};return $t.current!==null&&(document.addEventListener("pointermove",fn),document.addEventListener("pointerup",Jt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",fn),document.removeEventListener("pointerup",Jt,{capture:!0})}}},[ot,Dt,$t]),React__namespace.useEffect(()=>{const Yt=()=>Dt(!1);return window.addEventListener("blur",Yt),window.addEventListener("resize",Yt),()=>{window.removeEventListener("blur",Yt),window.removeEventListener("resize",Yt)}},[Dt]);const[zt,en]=useTypeaheadSearch(Yt=>{const fn=ft().filter(gn=>!gn.disabled),Jt=fn.find(gn=>gn.ref.current===document.activeElement),mn=findNextItem(fn,Yt,Jt);mn&&setTimeout(()=>mn.ref.current.focus())}),Xt=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&(mt(Yt),mn&&(Ct.current=!0))},[st.value]),sn=React__namespace.useCallback(()=>ot==null?void 0:ot.focus(),[ot]),un=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&Rt(Yt)},[st.value]),Qt=s==="popper"?SelectPopperPosition:SelectItemAlignedPosition,pn=Qt===SelectPopperPosition?{side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:ot,viewport:lt,onViewportChange:at,itemRefCallback:Xt,selectedItem:pt,onItemLeave:sn,itemTextRefCallback:un,focusSelectedItem:Ht,selectedItemText:It,position:s,isPositioned:Mt,searchRef:zt,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:st.open,onMountAutoFocus:Yt=>{Yt.preventDefault()},onUnmountAutoFocus:composeEventHandlers(a,Yt=>{var fn;(fn=st.trigger)==null||fn.focus({preventScroll:!0}),Yt.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Yt=>Yt.preventDefault(),onDismiss:()=>st.onOpenChange(!1),children:jsxRuntime.jsx(Qt,{role:"listbox",id:st.contentId,"data-state":st.open?"open":"closed",dir:st.dir,onContextMenu:Yt=>Yt.preventDefault(),...rt,...pn,onPlaced:()=>yt(!0),ref:ut,style:{display:"flex",flexDirection:"column",outline:"none",...rt.style},onKeyDown:composeEventHandlers(rt.onKeyDown,Yt=>{const fn=Yt.ctrlKey||Yt.altKey||Yt.metaKey;if(Yt.key==="Tab"&&Yt.preventDefault(),!fn&&Yt.key.length===1&&en(Yt.key),["ArrowUp","ArrowDown","Home","End"].includes(Yt.key)){let mn=ft().filter(gn=>!gn.disabled).map(gn=>gn.ref.current);if(["ArrowUp","End"].includes(Yt.key)&&(mn=mn.slice().reverse()),["ArrowUp","ArrowDown"].includes(Yt.key)){const gn=Yt.target,Kt=mn.indexOf(gn);mn=mn.slice(Kt+1)}setTimeout(()=>Ft(mn)),Yt.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=useSelectContext(CONTENT_NAME$4,n),l=useSelectContentContext(CONTENT_NAME$4,n),[c,f]=React__namespace.useState(null),[g,R]=React__namespace.useState(null),A=useComposedRefs(t,ut=>R(ut)),V=useCollection$1(n),Ve=React__namespace.useRef(!1),Ye=React__namespace.useRef(!0),{viewport:nt,selectedItem:et,selectedItemText:rt,focusSelectedItem:st}=l,ot=React__namespace.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&g&&nt&&et&&rt){const ut=o.trigger.getBoundingClientRect(),pt=g.getBoundingClientRect(),mt=o.valueNode.getBoundingClientRect(),It=rt.getBoundingClientRect();if(o.dir!=="rtl"){const gn=It.left-pt.left,Kt=mt.left-gn,Tn=ut.left-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.left=Rn+"px"}else{const gn=pt.right-It.right,Kt=window.innerWidth-mt.right-gn,Tn=window.innerWidth-ut.right-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.right=Rn+"px"}const Rt=V(),ft=window.innerHeight-CONTENT_MARGIN*2,Mt=nt.scrollHeight,yt=window.getComputedStyle(g),Ct=parseInt(yt.borderTopWidth,10),Ft=parseInt(yt.paddingTop,10),Ht=parseInt(yt.borderBottomWidth,10),Dt=parseInt(yt.paddingBottom,10),$t=Ct+Ft+Mt+Dt+Ht,zt=Math.min(et.offsetHeight*5,$t),en=window.getComputedStyle(nt),Xt=parseInt(en.paddingTop,10),sn=parseInt(en.paddingBottom,10),un=ut.top+ut.height/2-CONTENT_MARGIN,Qt=ft-un,pn=et.offsetHeight/2,Yt=et.offsetTop+pn,fn=Ct+Ft+Yt,Jt=$t-fn;if(fn<=un){const gn=Rt.length>0&&et===Rt[Rt.length-1].ref.current;c.style.bottom="0px";const Kt=g.clientHeight-nt.offsetTop-nt.offsetHeight,Tn=Math.max(Qt,pn+(gn?sn:0)+Kt+Ht),hn=fn+Tn;c.style.height=hn+"px"}else{const gn=Rt.length>0&&et===Rt[0].ref.current;c.style.top="0px";const Tn=Math.max(un,Ct+nt.offsetTop+(gn?Xt:0)+pn)+Jt;c.style.height=Tn+"px",nt.scrollTop=fn-un+nt.offsetTop}c.style.margin=`${CONTENT_MARGIN}px 0`,c.style.minHeight=zt+"px",c.style.maxHeight=ft+"px",s==null||s(),requestAnimationFrame(()=>Ve.current=!0)}},[V,o.trigger,o.valueNode,c,g,nt,et,rt,o.dir,s]);useLayoutEffect2(()=>ot(),[ot]);const[ct,lt]=React__namespace.useState();useLayoutEffect2(()=>{g&<(window.getComputedStyle(g).zIndex)},[g]);const at=React__namespace.useCallback(ut=>{ut&&Ye.current===!0&&(ot(),st==null||st(),Ye.current=!1)},[ot,st]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:Ve,onScrollButtonChange:at,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:ct},children:jsxRuntime.jsx(Primitive$4.div,{...a,ref:A,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=CONTENT_MARGIN,...o}=e,l=usePopperScope$1(n);return jsxRuntime.jsx(Content$2,{...l,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME$4,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=useSelectContentContext(VIEWPORT_NAME,n),l=useSelectViewportContext(VIEWPORT_NAME,n),c=useComposedRefs(t,o.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),jsxRuntime.jsx(Collection$1.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:composeEventHandlers(a.onScroll,g=>{const R=g.currentTarget,{contentWrapper:A,shouldExpandOnScrollRef:V}=l;if(V!=null&&V.current&&A){const Ve=Math.abs(f.current-R.scrollTop);if(Ve>0){const Ye=window.innerHeight-CONTENT_MARGIN*2,nt=parseFloat(A.style.minHeight),et=parseFloat(A.style.height),rt=Math.max(nt,et);if(rt<Ye){const st=rt+Ve,ot=Math.min(Ye,st),ct=st-ot;A.style.height=ot+"px",A.style.bottom==="0px"&&(R.scrollTop=ct>0?ct:0,A.style.justifyContent="flex-end")}}}f.current=R.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useId$1();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:a,children:jsxRuntime.jsx(Primitive$4.div,{role:"group","aria-labelledby":a,...s,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive$4.div,{id:a.id,...s,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME$1="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME$1),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...l}=e,c=useSelectContext(ITEM_NAME$1,n),f=useSelectContentContext(ITEM_NAME$1,n),g=c.value===s,[R,A]=React__namespace.useState(o??""),[V,Ve]=React__namespace.useState(!1),Ye=useComposedRefs(t,st=>{var ot;return(ot=f.itemRefCallback)==null?void 0:ot.call(f,st,s,a)}),nt=useId$1(),et=React__namespace.useRef("touch"),rt=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:s,disabled:a,textId:nt,isSelected:g,onItemTextChange:React__namespace.useCallback(st=>{A(ot=>ot||((st==null?void 0:st.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection$1.ItemSlot,{scope:n,value:s,disabled:a,textValue:R,children:jsxRuntime.jsx(Primitive$4.div,{role:"option","aria-labelledby":nt,"data-highlighted":V?"":void 0,"aria-selected":g&&V,"data-state":g?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:Ye,onFocus:composeEventHandlers(l.onFocus,()=>Ve(!0)),onBlur:composeEventHandlers(l.onBlur,()=>Ve(!1)),onClick:composeEventHandlers(l.onClick,()=>{et.current!=="mouse"&&rt()}),onPointerUp:composeEventHandlers(l.onPointerUp,()=>{et.current==="mouse"&&rt()}),onPointerDown:composeEventHandlers(l.onPointerDown,st=>{et.current=st.pointerType}),onPointerMove:composeEventHandlers(l.onPointerMove,st=>{var ot;et.current=st.pointerType,a?(ot=f.onItemLeave)==null||ot.call(f):et.current==="mouse"&&st.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(l.onPointerLeave,st=>{var ot;st.currentTarget===document.activeElement&&((ot=f.onItemLeave)==null||ot.call(f))}),onKeyDown:composeEventHandlers(l.onKeyDown,st=>{var ct;((ct=f.searchRef)==null?void 0:ct.current)!==""&&st.key===" "||(SELECTION_KEYS.includes(st.key)&&rt(),st.key===" "&&st.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME$1;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,l=useSelectContext(ITEM_TEXT_NAME,n),c=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),g=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[R,A]=React__namespace.useState(null),V=useComposedRefs(t,rt=>A(rt),f.onItemTextChange,rt=>{var st;return(st=c.itemTextRefCallback)==null?void 0:st.call(c,rt,f.value,f.disabled)}),Ve=R==null?void 0:R.textContent,Ye=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:Ve},f.value),[f.disabled,f.value,Ve]),{onNativeOptionAdd:nt,onNativeOptionRemove:et}=g;return useLayoutEffect2(()=>(nt(Ye),()=>et(Ye)),[nt,et,Ye]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:f.textId,...o,ref:V}),f.isSelected&&l.valueNode&&!l.valueNodeHasChildren?ReactDOM__namespace.createPortal(o.children,l.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...s,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollTop>0;o(g)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollHeight-f.clientHeight,R=Math.ceil(f.scrollTop)<g;o(R)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=useSelectContentContext("SelectScrollButton",n),l=React__namespace.useRef(null),c=useCollection$1(n),f=React__namespace.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var R;const g=c().find(A=>A.ref.current===document.activeElement);(R=g==null?void 0:g.ref.current)==null||R.scrollIntoView({block:"nearest"})},[c]),jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:composeEventHandlers(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:composeEventHandlers(a.onPointerMove,()=>{var g;(g=o.onItemLeave)==null||g.call(o),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:composeEventHandlers(a.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...s,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=usePopperScope$1(n),o=useSelectContext(ARROW_NAME$1,n),l=useSelectContentContext(ARROW_NAME$1,n);return o.open&&l.position==="popper"?jsxRuntime.jsx(Arrow,{...a,...s,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=React__namespace.useRef(null),o=useComposedRefs(s,a),l=usePrevious(t);return React__namespace.useEffect(()=>{const c=a.current;if(!c)return;const f=window.HTMLSelectElement.prototype,R=Object.getOwnPropertyDescriptor(f,"value").set;if(l!==t&&R){const A=new Event("change",{bubbles:!0});R.call(c,t),c.dispatchEvent(A)}},[l,t]),jsxRuntime.jsx(Primitive$4.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:o,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),s=React__namespace.useRef(0),a=React__namespace.useCallback(l=>{const c=n.current+l;t(c),(function f(g){n.current=g,window.clearTimeout(s.current),g!==""&&(s.current=window.setTimeout(()=>f(""),1e3))})(c)},[t]),o=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function findNextItem(e,t,n){const a=t.length>1&&Array.from(t).every(g=>g===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=wrapArray(e,Math.max(o,0));a.length===1&&(l=l.filter(g=>g!==n));const f=l.find(g=>g.textValue.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Root2$3=Select$2,Trigger$2=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$3=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$2=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select$1=Root2$3,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Trigger$2,{ref:s,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$2.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$3,{ref:a,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$3.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Item$2,{ref:s,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item$2.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;function ManufacturerProducts({applicationId:e,manufacturer:t,shopifyHostName:n}){var ot,ct,lt,at,ut;const[s]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[a,o]=React.useState(((ct=(ot=t.Categories)==null?void 0:ot[0])==null?void 0:ct.CategoryCode)||""),[l,c]=React.useState(!1),[f,g]=React.useState(!1),[R,A]=React.useState("percentile"),{toast:V}=useToast(),{data:Ve,isLoading:Ye,isFetching:nt}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e,manufacturerId:t.ManufacturerId,categoryCode:a??""},{skip:!t.ManufacturerId||!a}),et=async()=>{try{c(!0),g(!1),await s({routeResellerId:e,manufacturerId:t.ManufacturerId??"",categoryCode:a,shopifyHostName:n}).unwrap()&&V({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(pt){console.error("Error syncing to Shopify:",pt),V({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{c(!1)}},rt=()=>{var pt,mt;return((mt=(pt=t.Categories)==null?void 0:pt.find(It=>It.CategoryCode===a))==null?void 0:mt.CategoryName)||a},st=React.useMemo(()=>Ve!=null&&Ve.Products?[...Ve.Products].sort((pt,mt)=>R==="price-asc"?(pt.MAP??0)-(mt.MAP??0):R==="price-desc"?(mt.MAP??0)-(pt.MAP??0):R==="name"?(pt.Title??"").localeCompare(mt.Title??""):R==="percentile"?(mt.OverallPercentileRank??0)-(pt.OverallPercentileRank??0):0):[],[Ve==null?void 0:Ve.Products,R]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:rt(),niche:(Ve==null?void 0:Ve.Niche)||"",productsNumber:((lt=Ve==null?void 0:Ve.Products)==null?void 0:lt.length)||0,autoreorder:(Ve==null?void 0:Ve.AutoReorder)||!1,starred:(Ve==null?void 0:Ve.Starred)||!1,isLoading:Ye||nt,children:n&&((at=t.Categories)==null?void 0:at.findIndex(pt=>pt.AvailableToBuy))!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",disabled:l,onClick:()=>g(!0),children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(ut=t.Categories)==null?void 0:ut.find(pt=>pt.CategoryCode===a)].filter(Boolean),manufID:t.ManufacturerId,appID:e}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,loading:Ye||nt})]})]}),jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsxs("div",{className:"flex justify-between items-center mt-7 mb-4",children:[jsxRuntime.jsx("h4",{className:"text-xl md:text-2xl text-foreground font-bold",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Sort by:"}),jsxRuntime.jsxs(Select$1,{value:R,onValueChange:A,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[220px]",children:jsxRuntime.jsx(SelectValue,{})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"price-asc",children:"MAP: Low to High"}),jsxRuntime.jsx(SelectItem,{value:"price-desc",children:"MAP: High to Low"}),jsxRuntime.jsx(SelectItem,{value:"name",children:"Name"}),jsxRuntime.jsx(SelectItem,{value:"percentile",children:"Best Selling"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:Ye||nt?Array.from({length:4}).map((pt,mt)=>jsxRuntime.jsx(ProductCard,{},mt)):st.length>0?st.map(pt=>jsxRuntime.jsx(ProductCard,{applicationId:e,product:pt,viewProductLink:`/${e}/Product/${pt.RandmarSKU}`,shopifyHostname:n},pt.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:g,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',rt(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:et,disabled:l,children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:e,partnerId:t,userEmail:n,shopifyHostName:s,isSuperAdmin:a}){var ct,lt,at;const{data:o}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),{data:l,isLoading:c,isFetching:f}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:e,partnerId:t,withSpecification:!0}),{toast:g}=useToast(),[R]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),nt=async()=>{try{V(!0),Ye(!1),await R({routeResellerId:e??"",manufacturerId:t??"",shopifyHostName:s}).unwrap()&&g({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(ut){console.error("Error syncing to Shopify:",ut),g({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{V(!1)}},et=()=>l!=null&&l.Manufacturer?"products":l!=null&&l.Reseller?"reseller-overview":"",rt=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("tab"),st=()=>{const ut=rt();return ut==="assistant"?"assistant":ut==="reseller-overview"&&(l!=null&&l.Reseller)?"reseller-overview":ut==="manufacturer-overview"&&(l!=null&&l.Manufacturer)?"manufacturer-overview":ut==="products"&&(l!=null&&l.Manufacturer)?"products":et()||"assistant"},ot=usePartnershipAssistantPrompt(o,l);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:l,loading:c||f,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((l==null?void 0:l.Manufacturer)||c||f)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:l==null?void 0:l.Manufacturer,loading:c||f,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:e,manufacturer:l==null?void 0:l.Manufacturer}),s&&((lt=(ct=l==null?void 0:l.Manufacturer)==null?void 0:ct.Categories)==null?void 0:lt.findIndex(ut=>ut.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:Ve,onOpenChange:Ye,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',(at=l==null?void 0:l.Manufacturer)==null?void 0:at.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>Ye(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:nt,disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:l==null?void 0:l.Reseller,loading:c||f})]})]}),((l==null?void 0:l.Reseller)||(l==null?void 0:l.Manufacturer))&&!c&&!f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:st(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:l.ApplicationId||"",reseller:l==null?void 0:l.Reseller,userEmail:n,isSuperAdmin:a,withoutReports:!0})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:l==null?void 0:l.Manufacturer,applicationId:e,userEmail:n})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:e,manufacturer:l.Manufacturer,shopifyHostName:s})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:ot,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(c||f)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:e,appID:t,isLoading:n,readonly:s,onUnsavedChanges:a})=>{const{toast:o}=useToast(),[l]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[c,f]=React.useState({}),g=React.useMemo(()=>({publicEmail:e.PublicEmail??"",contactName:e.ContactName??"",phone:e.Phone??"",website:e.Website??""}),[e]),{register:R,handleSubmit:A,reset:V,watch:Ve,formState:{errors:Ye,isSubmitting:nt}}=useForm({defaultValues:g}),et=Ve(),rt=React.useCallback(()=>c?JSON.stringify(et)!==JSON.stringify(c):!1,[et,c]);React.useEffect(()=>{a&&a(rt())},[rt,a]),React.useEffect(()=>{e&&Object.keys(e).length>0&&(V(g),f(g))},[e,V,g]);const st=async ct=>{let lt=!0,at=!1;const ut=Object.keys(ct).map(pt=>({key:pt,keyApi:pt.charAt(0).toUpperCase()+pt.slice(1)}));for(const pt of ut){const mt=ct[pt.key],It=e[pt.keyApi];if(mt!==It&&mt!==void 0){at=!0;try{await l({applicationId:t,fieldName:pt.keyApi,newValue:String(mt)}).unwrap()||(lt=!1)}catch(Rt){console.error(`Error updating ${pt.keyApi}:`,Rt),lt=!1}}}lt&&at?(o({title:"Public info",description:"Information updated successfully",variant:"success"}),f({...ct}),a&&a(!1)):lt||o({title:"Updation error",description:"Failed to update",variant:"destructive"})},ot=ct=>!ct||ct.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",s?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(ot(Ve("contactName"))||ot(Ve("publicEmail"))||ot(Ve("website"))||ot(Ve("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:A(st),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:s,...R("contactName",{}),className:Ye.contactName||ot(Ve("contactName"))?"input-error-indicator":""}),Ye.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:s,...R("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:Ye.publicEmail||ot(Ve("publicEmail"))?"input-error-indicator":""}),Ye.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:s,...R("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.website||ot(Ve("website"))?"input-error-indicator":""}),Ye.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:s,...R("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.phone||ot(Ve("phone"))?"input-error-indicator":""}),Ye.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:nt||s,className:s?"hidden":"",children:nt?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:e,reseller:t,isLoading:n,withoutReports:s,userEmail:a,isSuperAdmin:o}){const{toast:l}=useToast(),{Statement:c,CreditLimit:f}=t,[g,R]=React.useState(!1),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),[nt,et]=React.useState(!1),[rt,st]=React.useState(a||""),[ot,ct]=React.useState(!1),[lt,at]=React.useState((f==null?void 0:f.toString())||""),[ut,{isLoading:pt}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),mt=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:f||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),o&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{ct(!0),at((f==null?void 0:f.toString())||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[It]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),Rt=async Ct=>{Ct?R(!0):V(!0);try{const Ht=(await It({routeResellerId:e,documentNumber:`ST${e}`})).data;if(!Ht)throw new Error("No data received for download.");if(Ct)window.open(Ht);else{const Dt=document.createElement("a");Dt.href=Ht,Dt.download=`ST${e}.pdf`,document.body.appendChild(Dt),Dt.click(),Dt.remove()}l({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Ft){console.error("Download Error:",Ft),l({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{Ct?R(!1):V(!1)}},[ft]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),Mt=async()=>{if(!rt||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(rt)){l({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}Ye(!0);try{await ft({routeResellerId:e,emailAddress:rt}).unwrap(),l({title:"Success",description:`Statement sent to ${rt} successfully.`,variant:"success"}),et(!1)}catch(Ft){console.error("Send Email Error:",Ft),l({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{Ye(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},Ct))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(Ct=>jsxRuntime.jsx("div",{className:Ct===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},Ct))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const yt=!s;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:mt.slice(0,3).map((Ct,Ft)=>jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value},Ft))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:mt.slice(3).map((Ct,Ft)=>jsxRuntime.jsx("div",{className:Ft===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value})},Ft))})]}),yt&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!0),disabled:g,children:g?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!1),disabled:A,children:A?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>et(!0),disabled:Ve,children:Ve?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${e}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:nt,onOpenChange:et,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:rt,onChange:Ct=>st(Ct.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:Mt,disabled:Ve||!rt,children:Ve?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:ot,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:lt,onChange:Ct=>at(Ct.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const Ct=Number(lt);if(isNaN(Ct)){l({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await ut({applicationId:e,newValue:Ct}).unwrap(),ct(!1),l({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Ft){console.error("Update Credit Limit Error:",Ft),l({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:pt,children:pt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:e,label:t,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(e,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:t})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:e,setOpen:t,tier:n,onTierChange:s,isLoading:a}){const o=()=>{t(!1)};return jsxRuntime.jsx(Dialog,{open:e,onOpenChange:t,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:o,disabled:a,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:s,disabled:a,children:a?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=e=>e===1?"The Best":e===2?"Fixed 12.5% GP on all items":e===3?"Advantageous":e===4?"Buying Group":e===5?"Cost":e,getShippingText=e=>e==="A"?"Free or Custom":e==="B"?"Fixed $10 anywhere":e==="C"?`Free shipping on $150+ orders to your location,
|
|
1264
1264
|
$15 for drop shipped orders under $1,500,
|
|
1265
1265
|
$10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full shipping charges":e,getTermsText=e=>e==="STRIPE"?"Credit card payment":e==="NET30"?"Net 30 days":e,AccountTier=({isSuperAdmin:e,readonly:t,reseller:n,appID:s,isLoading:a})=>{const{toast:o}=useToast(),[l,c]=React.useState(!1),[f,g]=React.useState(""),[R,{isLoading:A}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),V=Ct=>Ct&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Ct]||"",Ve=Ct=>Ct&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Ct]||"",Ye=Ct=>Ct&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Ct]||"",[nt,et]=React.useState(V((n==null?void 0:n.Priority)??"")),[rt,st]=React.useState(Ve((n==null?void 0:n.ShippingProfile)??"")),[ot,ct]=React.useState(Ye(n==null?void 0:n.PriceProfile)),lt=Ct=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Ct]||Ct,at=Ct=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Ct]||Ct,ut=Ct=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Ct]||Ct;React.useEffect(()=>{et(V((n==null?void 0:n.Priority)??"")),st(Ve((n==null?void 0:n.ShippingProfile)??"")),ct(Ye(n==null?void 0:n.PriceProfile))},[n]);const pt=async(Ct,Ft,Ht,Dt)=>{try{(await R({applicationId:s,fieldName:Ct,newValue:Ft})).error?o({title:"Error",description:Dt,variant:"destructive"}):o({title:"Success",description:Ht,variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},mt=async Ct=>{et(Ct);const Ft=lt(Ct);pt("Priority",Ft,`Priority updated to ${Ft}`,"Failed to update priority")},It=async Ct=>{st(Ct);const Ft=at(Ct);pt("ShippingProfile",Ft,`Shipping profile updated to ${Ft}`,"Failed to update shipping profile")},Rt=async Ct=>{ct(Ct);const Ft=ut(Ct);pt("PriceProfile",Ft,`Pricing profile updated to ${Ft}`,"Failed to update pricing profile")},ft=async()=>{try{const Ct=await R({applicationId:s,fieldName:"Tier",newValue:f});Ct.error?o({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Ct.data?o({title:"Success",description:`Pricing Tier changed to ${f}`,variant:"success"}):o({title:"Considered",description:"Request being considered",variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{c(!1),g("")}},Mt=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],yt=Ct=>{g(Ct),c(!0)};return a?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Ct))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!t&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:t,className:t?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),Mt.map(Ct=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Ct.enabled,onClick:()=>yt(Ct.name),children:Ct.name},Ct.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:A,open:l,setOpen:c,tier:f,onTierChange:ft}),e&&!t&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:nt,onValueChange:mt,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ct.value,id:`priority-${Ct.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Ct.value}`,className:"cursor-pointer text-xs",children:Ct.label})]},Ct.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:rt,onValueChange:It,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ct.value,id:`shipping-${Ct.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Ct.value}`,className:"cursor-pointer text-xs",children:Ct.label})]},Ct.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:ot,onValueChange:Rt,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ct.value,id:`pricing-${Ct.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Ct.value}`,className:"cursor-pointer text-xs",children:Ct.label})]},Ct.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=(e==null?void 0:e.filter(nt=>nt.DocumentType==="Order"))||[],s=(e==null?void 0:e.filter(nt=>nt.DocumentType==="Shipment"))||[],a=n.filter(nt=>nt.WarehouseCode!=="3PLE"),o=a.reduce((nt,et)=>nt+(et.Quantity??0),0),l=a.reduce((nt,et)=>nt+(et.ExtendedPrice??0),0),c=n.filter(nt=>nt.WarehouseCode==="3PLE"),f=c.reduce((nt,et)=>nt+(et.Quantity??0),0),g=c.reduce((nt,et)=>nt+(et.ExtendedPrice??0),0),R=s.reduce((nt,et)=>nt+(et.Quantity??0),0),A=s.reduce((nt,et)=>nt+(et.ExtendedPrice??0),0),V=o+f+R,Ve=l+g+A,Ye=[{name:"All",icon:Package,color:"bg-blue-500",orders:V,amount:Ve},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:o,amount:l},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:R,amount:A},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:f,amount:g}];return t?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(nt=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},nt))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:Ye.map(nt=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${nt.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:nt.name}),jsxRuntime.jsx("div",{className:`${nt.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(nt.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:nt.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:nt.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},nt.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:s}=useToast(),[a,{isLoading:o}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[l,{isLoading:c}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[R,{isLoading:A}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[V,{isLoading:Ve}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[Ye,{isLoading:nt}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[et,rt]=React.useState(null),[st,ot]=React.useState(t),[ct,lt]=React.useState(!1),[at,ut]=React.useState("all"),{data:pt,isLoading:mt}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),It=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],Rt=async yt=>{rt(yt),yt.id==="Products"&&ut("all"),lt(!0)},ft=async()=>{if(!(!et||!n))try{switch(et.id){case"Products":{const yt={routeResellerId:n,emailAddress:st};at&&at!=="all"&&(yt.manufacturerId=at),await R(yt).unwrap();break}case"AmazonTrackingFile":await l({routeResellerId:n,emailAddress:st}).unwrap();break;case"WalmartTrackingFile":await a({routeResellerId:n,emailAddress:st}).unwrap();break;case"OpenOrders":await f({routeResellerId:n,emailAddress:st}).unwrap();break;case"Invoices":await V({routeResellerId:n,emailAddress:st}).unwrap();break;case"Statement":await Ye({routeResellerId:n,emailAddress:st}).unwrap();break;default:throw new Error("invalid report id")}s({title:"Report requested",description:`The ${et.title} will be sent to ${st} shortly.`,variant:"success"}),lt(!1)}catch(yt){console.error("Error requesting report:",yt),s({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Mt=g||A||c||o||nt||Ve;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(yt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},Ct))]},yt))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:It.map(yt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:yt.name}),yt.reports.map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Ct.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Ct.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ct.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>Rt(Ct),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Ct.id))]},yt.name))})}),jsxRuntime.jsx(Dialog,{open:ct,onOpenChange:lt,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",et==null?void 0:et.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:st,onChange:yt=>ot(yt.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(et==null?void 0:et.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:at,onChange:yt=>ut(yt.target.value),disabled:mt,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!mt&&Array.isArray(pt)&&pt.slice().sort((yt,Ct)=>(yt.PublicName||yt.Name||"").localeCompare(Ct.PublicName||Ct.Name||"")).map(yt=>yt!=null&&yt.ManufacturerId?jsxRuntime.jsx("option",{value:yt.ManufacturerId,children:(yt.PublicName||yt.Name||yt.ManufacturerId)+(yt.OpenToWork?" (Open to Work)":"")},yt.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>lt(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ft,disabled:!st||Mt,children:Mt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:e}){return!e.QualificationId||e.QualificationId==="Suspended"?null:e.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$2,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:e.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),e.QualificationId,e.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:e.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:e,mode:t="month",chartHeight:n,loading:s=!1,size:a="default"}){const[o,l]=React.useState([]),[c,f]=React.useState(!1),g=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(s||!e){l([]);return}let R=[];if(t==="week"){const A=new Map;e.forEach(V=>{var Ye;const Ve=((Ye=V.Day)==null?void 0:Ye.toString())||"";if(Ve.length===8){const nt=parseInt(Ve.substring(0,4),10),et=parseInt(Ve.substring(4,6),10)-1,rt=parseInt(Ve.substring(6,8),10),st=new Date(nt,et,rt),ot=new Date(st);ot.setDate(st.getDate()-st.getDay());const ct=`${ot.getFullYear()}-${String(ot.getMonth()+1).padStart(2,"0")}-${String(ot.getDate()).padStart(2,"0")}`,lt=A.get(ct)||{price:0,quantity:0};lt.price+=V.ExtendedPrice||0,lt.quantity+=V.Quantity||0,A.set(ct,lt)}}),R=Array.from(A).sort(([V],[Ve])=>V.localeCompare(Ve)).map(([V,Ve])=>({date:`${V.substring(5,7)}/${V.substring(8,10)}`,dollarVolume:Ve.price,unitsSold:Ve.quantity}))}else{const A=new Date,V=A.getFullYear(),Ve=A.getMonth(),Ye=A.getDate(),nt=`${V}-${(Ve+1).toString().padStart(2,"0")}`,et=Array.from({length:12},(st,ot)=>{const ct=new Date(V,Ve-(11-ot),1);return`${ct.getFullYear()}-${(ct.getMonth()+1).toString().padStart(2,"0")}`}),rt=Object.fromEntries(et.map(st=>[st,{price:0,quantity:0}]));if(e.forEach(st=>{const ot=String(st.Day??0);if(ot.length!==8)return;const ct=`${ot.substring(0,4)}-${ot.substring(4,6)}`;rt[ct]&&(rt[ct].price+=st.ExtendedPrice??0,rt[ct].quantity+=st.Quantity??0)}),R=et.map(st=>{const ot=rt[st],[ct,lt]=st.split("-").map(Number);return{date:new Date(ct,lt-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:ot.price,unitsSold:ot.quantity}}),c){const st=rt[nt];if(st&&st.price>0&&Ye>0){const ot=new Date(V,Ve+1,0).getDate();if(Ye<ot){const ct=st.price/Ye,lt=st.quantity/Ye,at=ct*ot,ut=lt*ot,pt=R[R.length-1];pt&&(pt.dollarVolume=at,pt.unitsSold=ut)}}}}l(R)},[e,t,c,s]),s?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):o.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:o,series:g,height:n,size:a}),a==="default"&&t==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:c,onCheckedChange:f,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),c&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:e,applicationId:t,publicName:n,name:s,location:a,link:o,linkNewTab:l=!0,children:c}){const[f,g]=React.useState(!1),R=V=>{V.preventDefault(),V.stopPropagation(),navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),2e3)},A=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:48,height:48},`partner_logo_${t}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:e}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:R,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t}),f?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:f?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),s&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:s}),a&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),c&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:c})]});return o?jsxRuntime.jsx(reactRouterDom.Link,{to:o,target:l?"_blank":"_self",children:A}):A}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1,appID:l}){var ct,lt,at;const{toast:c}=useToast(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[R,A]=React.useState(!1),[V,Ve]=React.useState(""),{data:Ye}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:l||""},{skip:!l}),nt=Ye==null?void 0:Ye.IsReseller;if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const et=[e.City,e.Province,e.Country].filter(Boolean),rt=et.length>0?et.join(", "):"",st=((ct=e.Tags)==null?void 0:ct.split(",").map(ut=>ut.trim()).filter(Boolean))||[],ot=async()=>{if(!(!(e!=null&&e.ManufacturerId)||!l||!V))try{await f({routeResellerId:l,emailAddress:V,manufacturerId:e.ManufacturerId}).unwrap(),c({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${V} shortly.`,variant:"success"}),A(!1)}catch(ut){console.error("Error requesting product list:",ut),c({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:rt,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((lt=e.Qualification)!=null&<.QualificationId)&&((at=e.Qualification)==null?void 0:at.QualificationId)!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||st.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),!!e.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),st.map((ut,pt)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ut},pt))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesYearToDay?formatMoney(e.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast3Months?formatMoney(e.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast30Days?formatMoney(e.SalesData.SalesLast30Days):"—"})]})]})}),(s||a||e.PublicResourcesLink||nt&&l&&e.ManufacturerId||t)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s&&s,nt&&l&&e.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>A(!0),disabled:g,children:g?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),e.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:e.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(BookOpen,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("div",{children:a})})]}),jsxRuntime.jsx(Dialog,{open:R,onOpenChange:A,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:V,onChange:ut=>Ve(ut.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ot,disabled:!V||g,children:g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:e,randmarSku:t,inventory:n,buttonSize:s="default",buttonClassName:a}){var Rt;const o=React.useRef(null),l=useIntersectionObserver({elementRef:o,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:c}=useToast(),[f,g]=React.useState(!1),[R,A]=React.useState(!1),[V,Ve]=React.useState(!1),{data:Ye,isLoading:nt,isFetching:et}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!l}),{data:rt,isLoading:st,isFetching:ot}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!l}),[ct]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),lt=n??((Rt=rt==null?void 0:rt.Distribution)==null?void 0:Rt.Inventory);React.useEffect(()=>{g(!1)},[t]);const{inventoryQuantity:at,totalIncomingQuantity:ut}=React.useMemo(()=>{if(!lt||lt.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const ft=lt.reduce((yt,Ct)=>yt+(Ct.AvailableQuantity||0),0),Mt=lt.reduce((yt,Ct)=>yt+(Ct.PurchaseOrderQuantity||0),0);return{inventoryQuantity:ft,totalIncomingQuantity:Mt}},[lt]);if(nt||et||st||ot)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",a)})});const mt=()=>{V||!(Ye!=null&&Ye.IsReseller)||(Ve(!0),ct({routeResellerId:e??"",randmarSku:t??""}).then(ft=>{ft.error||ft.data===!1?c({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):c({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),A(!1)}).catch(ft=>{console.error(ft),c({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{Ve(!1)}))};if(!lt)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:s,variant:"outline",className:cn("text-sm",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(Ye!=null&&Ye.IsReseller&&at<=0&&ut<=0)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm reseller-theme text-primary",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>A(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:mt,disabled:V,children:V?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const It=at<=0&&ut>0;return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:f,onOpenChange:g,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm",It?"manufacturer-theme text-primary":at>0?"text-green-700":"text-red-700",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),It?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(ut)," Incoming"]}):at>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(at)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:lt})]})]})})}function OrdersCard({applicationId:e,orders:t=null,loading:n=!1,title:s="Order Details"}){const a=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:c})=>c.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/GeneralDocument/${c.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:c.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",c.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:c})=>c.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:c})=>formatYYYYMMDDIntToDateString(c.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:c})=>c.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:c})=>c.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:c})=>c.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/${c.original.MPN}`,className:"font-medium text-primary hover:underline",children:c.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",c.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:c})=>c.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:c})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:c.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:c})=>c.original.UnitPrice?formatMoney(c.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:c})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e,randmarSku:c.original.RandmarSKU??"",buttonSize:"sm"})})}],[e]),o=React.useMemo(()=>{const c={};if(t){const f=Array.from(new Set(t.map(Ye=>Ye.WarehouseCode).filter(Ye=>Ye!=null)));c.WarehouseCode=f;const g=Array.from(new Set(t.map(Ye=>Ye.ShipToName).filter(Ye=>Ye!=null)));c.ShipToName=g;const R=Array.from(new Set(t.map(Ye=>Ye.DocumentNumber).filter(Ye=>Ye!=null)));c.DocumentNumber=R;const A=Array.from(new Set(t.map(Ye=>Ye.OrderNumber).filter(Ye=>Ye!=null)));c.OrderNumber=A;const V=Array.from(new Set(t.map(Ye=>Ye.PONumber).filter(Ye=>Ye!=null)));c.PONumber=V;const Ve=Array.from(new Set(t.map(Ye=>Ye.MPN).filter(Ye=>Ye!=null)));c.MPN=Ve}return c},[t]),l=t||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:s})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:a,data:l,uniqueValues:o})})]})}function ResellerOverview({appID:e,reseller:t,readonly:n,userEmail:s,isSuperAdmin:a,withoutReports:o=!1}){var st,ot,ct,lt;const{data:l,isLoading:c,isError:f}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!!t}),[g,R]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),A=React.useCallback(()=>n?!1:g.publicInfo.hasUnsavedChanges,[n,g]),V=React.useCallback((at,ut)=>{R(pt=>{var mt;return((mt=pt[at])==null?void 0:mt.hasUnsavedChanges)!==ut.hasUnsavedChanges?{...pt,[at]:ut}:pt})},[]),{NavigationGuardDialog:Ve}=useRouterNavigationGuard(A),Ye=t??l,nt=!n||!!(Ye!=null&&Ye.Statement)&&(Ye.Statement.Total??0)>0,et=(Ye==null?void 0:Ye.QualifiedManufacturers)??[],rt=(Ye==null?void 0:Ye.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[f?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(Ye==null?void 0:Ye.FiscalYearMonthStart)||1,salesData:Ye==null?void 0:Ye.SalesData,isLoading:c}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(Ye==null?void 0:Ye.SalesStatistics)??[],loading:c}),jsxRuntime.jsx(OrderCategories,{openOrders:(Ye==null?void 0:Ye.ActiveOrderDetails)??[],isLoading:c}),nt&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:Ye||{},withoutReports:o,isLoading:c,userEmail:s,isSuperAdmin:a}),jsxRuntime.jsx(PublicInfo,{reseller:Ye||{},appID:e??"",isLoading:c,readonly:n,onUnsavedChanges:at=>V("publicInfo",{hasUnsavedChanges:at})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:a,readonly:n,reseller:Ye||{},appID:e??"",isLoading:c})]}),c||et.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:c?Array.from({length:2}).map((at,ut)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},ut)):et.map(at=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:at,link:`https://dashboard.randmar.io/${e}/Partner/${at.ManufacturerId}`},at.ManufacturerId))})})]}):rt.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:rt}),(((st=Ye==null?void 0:Ye.Opportunities)==null?void 0:st.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:Ye==null?void 0:Ye.Opportunities,loading:c}),(((ot=Ye==null?void 0:Ye.ActiveOrderDetails)==null?void 0:ot.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:Ye==null?void 0:Ye.ActiveOrderDetails,loading:c}),(((ct=Ye==null?void 0:Ye.CompletedOrderDetails)==null?void 0:ct.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:Ye==null?void 0:Ye.CompletedOrderDetails,loading:c}),(((lt=Ye==null?void 0:Ye.Returns)==null?void 0:lt.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:Ye==null?void 0:Ye.Returns,loading:c}),!o&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:s,isLoading:c})]}),jsxRuntime.jsx(Ve,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:e,variant:t,...n},s)=>jsxRuntime.jsx("div",{ref:s,role:"alert",className:cn(alertVariants({variant:t}),e),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",e),...t}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",e),...t}));AlertDescription.displayName="AlertDescription";/**
|
|
1266
1266
|
* table-core
|
|
@@ -1334,7 +1334,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
|
|
|
1334
1334
|
${R.description}`:R.summary||`${g.toUpperCase()} ${A[A.length-1]}`,parameters:{type:Type.OBJECT,properties:nt,required:et}},ot=async ut=>{var mt;let pt=`https://api.randmar.io${l}`;try{rt.forEach(Ct=>{const Ft=`{${Ct}}`,Ht=Ct;pt=pt.replace(Ft,ut[Ht])});const It=localStorage.getItem("access_token"),Rt={method:g.toUpperCase(),headers:{Authorization:It?`Bearer ${It}`:"","Content-Type":"application/json"}},ft=[];if((((mt=R.parameters)==null?void 0:mt.filter(Ct=>Ct.in==="query"))||[]).forEach(Ct=>{const Ft=Ct.name,Ht=ut[Ft];Ht!=null&&ft.push(`${Ct.name}=${encodeURIComponent(Ht)}`)}),ft.length>0&&(pt+=`?${ft.join("&")}`),g==="post"||g==="put"){const Ft=ut[bodyKey];Ft&&(Rt.body=Ft)}const yt=await fetch(pt,Rt);if(!yt.ok){const Ct=await yt.text();throw console.error(`[API Function] Error response: ${Ct}`),new Error(`Error ${yt.status}: ${Ct}`)}return await yt.text()}catch(It){return console.error(`Error in ${Ye}:`,It),`I'm sorry, I couldn't retrieve the requested information. Error: ${It instanceof Error?It.message:"Unknown error"}`}},ct=((n=R.tags)==null?void 0:n[0])??"Partner",lt=(g==="get"?"Fetching data":"Updating data")+` - Randmar ${ct} API.`,at=`${g} ${l}`;o.push({declaration:st,handler:ot,prettyName:lt,details:at})}}return deduplicateApiFunctions(o)}catch(s){return console.error("Error fetching API functions:",s),[]}}function promisifyRequest(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function createStore(e,t){let n;const s=()=>{if(n)return n;const a=indexedDB.open(e);return a.onupgradeneeded=()=>a.result.createObjectStore(t),n=promisifyRequest(a),n.then(o=>{o.onclose=()=>n=void 0},()=>{}),n};return(a,o)=>s().then(l=>o(l.transaction(t,a).objectStore(t)))}let defaultGetStoreFunc;function defaultGetStore(){return defaultGetStoreFunc||(defaultGetStoreFunc=createStore("keyval-store","keyval")),defaultGetStoreFunc}function get(e,t=defaultGetStore()){return t("readonly",n=>promisifyRequest(n.get(e)))}function set(e,t,n=defaultGetStore()){return n("readwrite",s=>(s.put(t,e),promisifyRequest(s.transaction)))}const useCachedHeavyApiCalls=(e,t)=>{const[n,s]=React.useState({topProducts:[],updatedAtSecondsSinceEpoch:0}),[a,o]=React.useState(!1),l=12,[c]=useLazyGetV4PartnerByRouteApplicationIdProductsQuery();return React.useEffect(()=>{if(!t){s({topProducts:[],updatedAtSecondsSinceEpoch:0}),o(!1);return}const f=`heavy_api_cache_v5_${e}`,g=l*60*60,R=async()=>{o(!0);try{const V=await c({routeApplicationId:e});if(V.data){const Ve={topProducts:V.data.filter(Ye=>(Ye.OverallPercentileRank??0)>=95).sort((Ye,nt)=>(Ye.RandmarSKU??"").localeCompare(nt.RandmarSKU??"")),updatedAtSecondsSinceEpoch:Math.floor(Date.now()/1e3)};await set(f,Ve),s(Ve)}}catch(V){console.error("Failed to fetch products:",V)}finally{o(!1)}},A=async()=>{const V=await get(f);V?Math.floor(Date.now()/1e3)-V.updatedAtSecondsSinceEpoch>g?await R():(s(V),o(!1)):await R()};o(!0),A().catch(V=>{console.error("Failed to process cache, fetching new data",V),R()})},[e,t,c]),{...n,isLoading:a}};function useAIAssistant({userId:e,config:t}){const[n,s]=React.useState(""),[a,o]=React.useState([]),[l,c]=React.useState([]),[f,g]=React.useState([]),[R,A]=React.useState(!1),[V,Ve]=React.useState([]),[Ye,nt]=React.useState([]),[et,rt]=React.useState(0),[st]=useLazyGetV4PartnerByApplicationIdAccountQuery(),[ot]=usePostV4PartnerByApplicationIdGenerationRandmarAssistantMutation(),[ct]=usePostV4PartnerByApplicationIdGenerationUploadMutation(),{topProducts:lt,isLoading:at}=useCachedHeavyApiCalls(e,t.assistantCachedPreloading);React.useEffect(()=>{const Ct=async()=>{A(!0);try{const Ft=await fetchApiFunctions(),Ht={declaration:{name:"set_on_behalf_id",description:"Call this function when the user wants to act on behalf of another one. It will return to you important flags such as: is user specified by the user ID a reseller, manufacturer or an agency?",parameters:{type:Type.OBJECT,properties:{user_id:{type:Type.STRING,description:"The user ID to use going forward."}},required:["user_id"]}},prettyName:"Fetching account details",details:"GET Partner Account",handler:async Dt=>{const zt=await st({applicationId:Dt.user_id});return JSON.stringify(zt.data)}};Ve([...Ft,Ht])}catch(Ft){console.error("Error loading API functions:",Ft)}A(!1)};V.length===0&&!R&&Ct()},[V,R]),React.useEffect(()=>{t.assistantCachedPreloading&&(at?c(Ct=>[...Ct,"Preloading Best-Sellers..."]):lt.length>0&&c(Ct=>[...Ct,"Best-Sellers preloaded."]))},[at,lt.length,t.assistantCachedPreloading]),React.useEffect(()=>{if(n||f.length===0)return;s("Handling message...");const[Ct,Ft]=f[0];g(Ht=>Ht.slice(1)),It(Ct,Ft)},[n,f]),React.useEffect(()=>{yt()},[t.assistantThinkHarder,t.assistantCachedPreloading]);const ut=async Ct=>{const Ft=V.find(Ht=>Ht.declaration.name===Ct.name);if(!Ft){const Ht=`Function ${Ct.name} not found`;return console.error(Ht),JSON.stringify({error:Ht})}try{return c(Ht=>[...Ht,[Ft.prettyName,`${Ft.details} where ${JSON.stringify(Ct.args,null,2)}`]]),await Ft.handler(Ct.args)}catch(Ht){const Dt=`${Ct.name} failed.`;return console.error(Dt,Ht),JSON.stringify({error:Dt,details:Ht instanceof Error?Ht.message:String(Ht)})}},pt=async(Ct,Ft)=>{var Ht,Dt,$t;if(Ft===0){ft({content:"I've reached my action limit for this request. Please let me know if you'd like me to continue.",timestamp:new Date}),s("");return}try{s("Thinking...");const zt=await ot({applicationId:e,body:Ct}).unwrap(),en=zt.Content,Xt=[...Ct,en],sn=zt.ContextUtilization??0;nt(Xt),rt(sn);const un=(Dt=(Ht=en.Parts)==null?void 0:Ht.find(pn=>pn.Text))==null?void 0:Dt.Text;un&&ft({content:un,timestamp:new Date});const Qt=(($t=en.Parts)==null?void 0:$t.map(pn=>pn.FunctionCall).filter(Boolean))??[];if(Qt.length>0){s("Using Randmar API...");const pn=[];for(const Yt of Qt)if(Yt!=null&&Yt.Name){const fn=await ut({name:Yt.Name,args:Yt.Args??{}});pn.push({FunctionResponse:{Name:Yt.Name,Content:fn}})}if(pn.length>0){const Yt={Role:"user",Parts:pn},fn=[...Xt,Yt];nt(fn),s("Composing response..."),await pt(fn,Ft-1);return}}s("")}catch(zt){console.error("Error during AI interaction:",zt),ft({content:"I'm sorry, I encountered an error. Please write continue or try again.",timestamp:new Date}),s("")}},mt=Ct=>Ct==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"||Ct==="application/vnd.ms-excel"?"text/plain":Ct,It=async(Ct,Ft)=>{try{const Ht=[{Text:Ct.trim()}];if(Ft){s("Receiving attached file...");const zt=new File([await Ft.arrayBuffer()],Ft.name,{type:Ft.type}),en=await ct({applicationId:e,body:{file:zt}}).unwrap();Ht.push({FileData:{FileUri:en,MimeType:mt(Ft.type)}})}const Dt={Role:"user",Parts:Ht},$t=[...Ye,Dt];nt($t),await pt($t,100)}catch(Ht){console.error("Error processing user request:",Ht),ft({content:"I'm sorry, there was an issue with your request, especially if a file was attached. Please try again.",timestamp:new Date}),s("")}},Rt=(Ct,Ft)=>{if(V.length>0&&!at){if(Ye.length===0){const Dt=[];if(t.assistantCachedPreloading&<.length>0){const $t=lt.map(zt=>({RandmarSKU:zt.RandmarSKU,RandmarTitle:zt.RandmarTitle,CategoryCode:zt.Category,UPC:zt.UPC,ManufName:zt.ManufacturerName,CategoryName:zt.ProductType,Desc:zt.BodyHTML,MAP:zt.MAP,MSRP:zt.MSRP,ManufID:zt.ManufacturerId,MPN:zt.MPN}));Dt.push(`Here are the current best-selling products: ${JSON.stringify($t)}.`)}Dt.length>0&&nt([{Role:"user",Parts:[{Text:Dt.join(`
|
|
1335
1335
|
|
|
1336
1336
|
`)}]}])}g(Dt=>[...Dt,[Ct,Ft]])}},ft=Ct=>o(Ft=>[...Ft,Ct]),Mt=()=>o([]),yt=()=>{nt([]),g([]),c([]),o([]),s("")};return{handleSubmitToBot:Rt,botMessages:a,clearBotMessages:Mt,botReady:V.length>0&&!at,botStatus:n,debugMessages:l,reset:yt,contextUsage:et,chatHistory:Ye}}const DebugMessageDisplay=({debugMessages:e})=>{const[t,n]=React.useState({}),s=a=>{n(o=>({...o,[a]:!o[a]}))};return jsxRuntime.jsx("div",{children:e.map((a,o)=>{if(typeof a=="string")return jsxRuntime.jsx("p",{className:"text-slate-600",children:a},o);{const l=t[o];return jsxRuntime.jsxs("div",{className:"cursor-pointer",onClick:()=>s(o),children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("p",{className:"text-slate-600 mr-2",children:a[0]}),jsxRuntime.jsx("span",{className:"text-slate-500 text-xs",children:l?"▲":"▼"})]}),l&&jsxRuntime.jsx("p",{className:"text-slate-400 pl-4",children:a[1]})]},o)}})})},STORAGE_KEY="appConfig",COOKIE_NAME="appConfig",COOKIE_DOMAIN=".randmar.io",COOKIE_MAX_AGE_DAYS=365,defaultConfig={assistantThinkHarder:!1,assistantCachedPreloading:!1};function setCookie(e,t,n,s){try{const a=new Date(Date.now()+n*24*60*60*1e3).toUTCString(),o=s?`; domain=${s}`:"";document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; expires=${a}; path=/${o}; Secure; SameSite=Lax`}catch(a){console.warn("Unable to set cookie",a)}}function getCookie(e){try{const t=document.cookie?document.cookie.split("; "):[];for(const n of t){const[s,...a]=n.split("=");if(decodeURIComponent(s)===e)return decodeURIComponent(a.join("="))}return null}catch(t){return console.warn("Unable to read cookie",t),null}}const useConfig=()=>{const[e,t]=React.useState(()=>{try{const n=getCookie(COOKIE_NAME);if(n){const a=JSON.parse(n);return{...defaultConfig,...a}}const s=window.localStorage.getItem(STORAGE_KEY);if(s){const a=JSON.parse(s);return{...defaultConfig,...a}}return defaultConfig}catch(n){return console.warn("Error reading configuration from storage:",n),defaultConfig}});return React.useEffect(()=>{try{const n=JSON.stringify(e);setCookie(COOKIE_NAME,n,COOKIE_MAX_AGE_DAYS,COOKIE_DOMAIN),window.localStorage.setItem(STORAGE_KEY,n)}catch(n){console.warn("Error persisting configuration:",n)}},[e]),[e,t]},ASSISTANT_ID="RandmarAIChatAssistant",AIChatLayout=React.memo(React.forwardRef(({userId:e,userName:t,inputRef:n,className:s},a)=>{const[o,l]=React.useState(!1),[c,f]=React.useState(!1),[g]=usePostV4PartnerByApplicationIdAccountDebugFeedbackMutation(),[R,A]=useConfig(),[V,Ve]=React.useState([]),{handleSubmitToBot:Ye,botMessages:nt,clearBotMessages:et,botReady:rt,debugMessages:st,botStatus:ot,reset:ct,contextUsage:lt,chatHistory:at}=useAIAssistant({userId:e,config:R});React.useEffect(()=>{ft([{partner1:e,partner2:ASSISTANT_ID,name:"Randmar Assistant",unread:0,pending:!1,messages:[],conversationID:-1,lastMessageTime:null}]),f(!0)},[e]);const[ut,pt]=React.useState(""),[mt,It]=React.useState(""),[Rt,ft]=React.useState([]),Mt=React.useRef(null),yt=React.useRef(null),Ct=React.useRef(null),[Ft,Ht]=React.useState(null),[Dt,$t]=React.useState([]),zt=n||yt,en=React.useRef(null),{toast:Xt}=useToast(),[sn]=useLazyGetV4PartnerByApplicationIdGenerationRandmarAssistantInstructionsQuery(),un=()=>Rt.find(Zt=>!!Zt);React.useEffect(()=>{var Zt;Ft!==null&&(Xt({title:"File attached",description:"Add your instruction before sending.",variant:"success"}),(Zt=zt.current)==null||Zt.focus())},[Ft]),React.useEffect(()=>{if(nt.length===0)return;const Zt=[];for(const rn of nt)!rn||rn.isComponent||Zt.push({id:rn.timestamp.toString(),fromPartnerID:ASSISTANT_ID,toPartnerID:e,senderName:"Assistant",timestamp:rn.timestamp.getTime(),content:rn.content});Zt.length>0&&Ve(rn=>[...rn,...Zt]),et()},[nt,et,e]);const Qt=Zt=>Ve(rn=>[...rn,Zt]);React.useEffect(()=>{V.length!=0&&(ft(Zt=>Zt.map(rn=>{const xn=rn.messages??[];if(xn.length===0)return{...rn,messages:[...V]};const En=new Set(xn.map(Vn=>Vn.id)),$n=V.filter(Vn=>!En.has(Vn.id));return $n.length===0?rn:{...rn,messages:[...xn,...$n]}})),requestAnimationFrame(()=>{var Zt;return(Zt=Mt.current)==null?void 0:Zt.scrollIntoView({behavior:"smooth"})}),Ve([]))},[V]);const pn=(Zt,rn)=>{rn=rn.replace(/\n/g,`
|
|
1337
|
-
`);const xn={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:Zt.partner1===e?Zt.partner2:Zt.partner1,content:rn+(Ft?` (${Ft==null?void 0:Ft.name} attached)`:""),timestamp:Date.now()};Qt(xn),Ye(xn.content,Ft??void 0),Ft&&$t(En=>[...En,Ft.name]),pt(""),Ht(null),en.current&&(en.current.value="")},[Yt,fn]=React.useState(null),Jt=Zt=>fn(Zt),mn=Zt=>{Rn(),fn(Zt)};React.useEffect(()=>{if(Yt===null)return;const Zt=un();if(!Zt||!rt)return;const rn=Yt;fn(null),rn&&pn(Zt,rn)},[Yt,Rt,rt]),React.useImperativeHandle(a,()=>({sendMessageToAssistant:Jt,sendMessageToAssistantWithClear:mn}));const gn=Zt=>{var xn;const rn=(xn=Zt.clipboardData)==null?void 0:xn.items;if(rn){for(let En=0;En<rn.length;En++)if(rn[En].type.indexOf("image")!==-1){const $n=rn[En].getAsFile();if($n){Ht($n);return}}}},Kt=()=>{let Zt=ut.trim();!Zt&&Ft&&(Zt="consider this"),!(!bn||!Zt)&&pn(bn,Zt)},Tn=Zt=>{Zt.target.files&&Zt.target.files[0]?Ht(Zt.target.files[0]):Ht(null)},hn=()=>{var Zt;(Zt=en.current)==null||Zt.click()},Sn=()=>{var Zt;Ht(null),Xt({title:"File removed",description:"No file will be sent to the assistant.",variant:"secondary"}),(Zt=zt.current)==null||Zt.focus()},vn=()=>{const rn={messages:un(),debug:st};l(!0),g({applicationId:e,emailAddress:t,body:rn}).then(xn=>{if(xn.error){console.error(xn.error),Xt({title:"Error",description:"Could not send your feedback. Please try again later.",variant:"destructive"});return}Xt({title:"Success",description:"Your feedback has been successfully sent. Thank you!",variant:"success"})}).catch(xn=>{console.error(xn),Xt({title:"Error",description:"Could not send your feedback. Please try again later.",variant:"destructive"})}).finally(()=>{l(!1)})},Rn=()=>{ft(Zt=>Zt.map(xn=>xn.partner1!==ASSISTANT_ID&&xn.partner2!==ASSISTANT_ID?xn:{...xn,messages:[]})),$t([]),ct()},Cn=()=>{try{const Zt=at.map(xn=>{const $n=(Array.isArray(xn==null?void 0:xn.Parts)?xn.Parts:[]).map(Vn=>{const Nn=typeof(Vn==null?void 0:Vn.Text)=="string"?Vn.Text:null,Zn=!!(Nn&&Nn.length>0),rr=(Vn==null?void 0:Vn.FunctionResponse)!=null,ir=(Vn==null?void 0:Vn.FileData)!=null;return!Zn&&!rr&&!ir?null:{...Zn?{Text:Nn}:{},...rr?{FunctionResponse:Vn.FunctionResponse}:{},...ir?{FileData:Vn.FileData}:{}}}).filter(Vn=>Vn!=null);return{Role:typeof(xn==null?void 0:xn.Role)=="string"?xn.Role:null,Parts:$n}});(async()=>{try{const En={SystemInstructions:(await sn({applicationId:e})).data??"",ChatMessages:Zt},$n=JSON.stringify(En,null,2);if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText($n),Xt({title:"Chat JSON copied",description:"The chat history has been copied to your clipboard.",variant:"success"});else{const Vn=document.createElement("textarea");Vn.value=$n,Vn.style.position="fixed",Vn.style.left="-9999px",document.body.appendChild(Vn),Vn.focus(),Vn.select();const Nn=document.execCommand("copy");if(document.body.removeChild(Vn),Nn)Xt({title:"Chat JSON copied",description:"The chat history has been copied to your clipboard.",variant:"success"});else throw new Error("execCommand copy failed")}}catch(xn){console.error("Failed to copy chat JSON",xn),Xt({title:"Error copying JSON",description:"Could not copy to clipboard. See console for details.",variant:"destructive"})}})()}catch(Zt){console.error("Failed to print chat JSON",Zt),Xt({title:"Error printing JSON",description:"See console for details.",variant:"destructive"})}},bn=un(),_n=(((bn==null?void 0:bn.messages)??[]).length??0)===0;React.useEffect(()=>{if(!c||!rt)return;const Zt=_n?Ct:zt;setTimeout(()=>{var rn;return(rn=Zt.current)==null?void 0:rn.focus()},50)},[rt,zt,_n,c]);const Wt=(Zt,rn)=>{A(xn=>({...xn,[Zt]:rn})),Rn()},nn=React.useRef(null);React.useEffect(()=>{var Zt;(Zt=nn.current)==null||Zt.scrollIntoView({behavior:"smooth"})},[st]);const on=({className:Zt="h-4 w-4"})=>jsxRuntime.jsxs("svg",{style:{flex:"none",lineHeight:1},viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:Zt,children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#08B962"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"#F94543"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#FABC12"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),an=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})});return c?jsxRuntime.jsxs("div",{className:cn("flex h-full min-h-0 w-full overflow-hidden",s),children:[jsxRuntime.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:un()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-20 flex items-center border-b bg-white p-4",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>vn()},disabled:o,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsxs(Button$1,{className:"ml-1",onClick:()=>Rn(),children:[jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})," Clear Conversation"]})]})}),jsxRuntime.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:rt?_n?jsxRuntime.jsx("div",{className:"flex-1 bg-slate-50 flex items-center justify-center p-6 animate-in fade-in-0 duration-300",children:jsxRuntime.jsxs("div",{className:"w-full max-w-2xl",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-slate-600",children:"Hi there!"}),jsxRuntime.jsx("h1",{className:"mt-2 text-[32px] leading-[1.15] font-semibold text-slate-900",children:"How can I assist you with your Randmar tasks today?"}),jsxRuntime.jsx("form",{className:"mt-6",onSubmit:Zt=>{if(Zt.preventDefault(),ot)return;const rn=mt.trim();!rn||!bn||(pn(bn,rn),It(""))},children:jsxRuntime.jsx(Input,{ref:Ct,value:mt,onChange:Zt=>It(Zt.target.value),placeholder:"Enter a question or command for Randmar Assistant",className:"h-14 rounded-full bg-white px-5 shadow-sm ring-1 ring-slate-200/80 focus-visible:ring-2 focus-visible:ring-primary/35"})})]})}):jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col animate-in fade-in-0 duration-300",children:[jsxRuntime.jsxs(ScrollArea,{className:"min-h-0 flex-1 bg-slate-50 pl-2 pr-2",children:[jsxRuntime.jsx(ChatMessages,{messages:(bn==null?void 0:bn.messages)??[],appID:e,isAssistantChat:!0,botStatus:ot}),jsxRuntime.jsx("div",{ref:Mt})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 border-r border-t p-4",children:[jsxRuntime.jsx(Textarea,{ref:zt,placeholder:"Type a message...",value:ut,onPaste:gn,onChange:Zt=>pt(Zt.target.value),onKeyDown:Zt=>{Zt.key!=="Enter"||Zt.shiftKey||(Zt.preventDefault(),!(!rt||ot)&&Kt())},className:"flex-1 resize-none field-sizing-content max-h-[30em]"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:bn!=null&&bn.pending?"collapse":"ml-2 h-8 w-8",disabled:!rt||!!ot,onClick:Kt,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsx(Input,{type:"file",onChange:Tn,className:"hidden",ref:en}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:hn,className:bn!=null&&bn.pending?"collapse":"ml-2 h-8 w-8",disabled:!rt||ot!==""||(bn==null?void 0:bn.pending)||!!Ft,children:jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"})}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:Sn,className:bn!=null&&bn.pending?"collapse":"ml-2 h-8 w-8",disabled:!rt||ot!==""||(bn==null?void 0:bn.pending)||!Ft,children:jsxRuntime.jsx(Trash,{className:"h-5 w-5"})})]})]})]}):jsxRuntime.jsx("div",{className:"flex-1 bg-slate-50",children:an})})]}):an}),jsxRuntime.jsx("div",{"data-thin":!0,className:"flex h-full basis-[360px] shrink-0 border-l sm:basis-[380px] lg:basis-[420px]",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-0 flex-col rounded-r-lg border-r bg-slate-50 text-slate-800",children:[jsxRuntime.jsxs("div",{className:"p-4 space-y-4 border-b border-slate-200/80",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Assistant Settings"]}),jsxRuntime.jsx("div",{className:"space-y-5",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5 pr-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"preload-bestsellers-switch",children:"Preload Best-Sellers"}),jsxRuntime.jsx("p",{className:"text-xs text-slate-600",children:"Adds top products to the AI's context for faster answers."})]}),jsxRuntime.jsx(Switch,{id:"preload-bestsellers-switch",checked:R.assistantCachedPreloading,onCheckedChange:Zt=>Wt("assistantCachedPreloading",Zt)})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-slate-200/80 h-32",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:Ft||Dt.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[Ft&&jsxRuntime.jsxs("div",{className:"flex items-center text-blue-600",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{className:"truncate",children:[Ft.name," (pending)"]})]}),Dt.slice().reverse().map((Zt,rn)=>jsxRuntime.jsxs("div",{className:"flex items-center text-slate-700 hover:text-slate-900 transition-colors duration-150",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{className:"truncate",children:Zt})]},rn))]}):jsxRuntime.jsx("p",{className:"text-slate-500 text-xs italic",children:"No files attached yet."})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:st}),jsxRuntime.jsx("div",{ref:nn})]})})]}),jsxRuntime.jsx("div",{className:"p-3 border-t border-slate-200/80",children:jsxRuntime.jsxs(Button$1,{className:"w-full",variant:"secondary",onClick:Cn,children:[jsxRuntime.jsx(CodeXml,{className:"h-4 w-4 mr-2"}),"Export Chat JSON"]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-slate-200/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-3 w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-slate-500",children:"Powered by Gemini"}),jsxRuntime.jsx(on,{})]}),jsxRuntime.jsxs("div",{className:"flex-1 max-w-[160px]",children:[jsxRuntime.jsx(Progress,{value:Math.round((lt||0)*100),className:"h-2"}),jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] text-slate-400 mt-1",children:[jsxRuntime.jsx("span",{children:"Context"}),jsxRuntime.jsxs("span",{children:[Math.round((lt||0)*100),"%"]})]})]})]})})]})})]}):jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"})}));AIChatLayout.displayName="AIChatLayout";const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,chatUserName:s,appID:a,chatRoutePath:o},l)=>{const c=e.filter(nt=>nt.showInNav),f=React.useRef(null),g=React.useRef(null),R=React.useRef(null),[A,V]=React.useState(!1),{data:Ve}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsHasUnreadsQuery({routeApplicationId:a}),{hasUnreads:Ye}=useChat();return React.useImperativeHandle(l,()=>({sendMessageToAssistant:nt=>{var et;(et=R.current)==null||et.click(),setTimeout(()=>{var rt;(rt=f.current)==null||rt.focus(),g.current&&g.current.sendMessageToAssistant(nt)},100)},sendMessageToAssistantWithClear(nt){var et;(et=R.current)==null||et.click(),setTimeout(()=>{var rt;(rt=f.current)==null||rt.focus(),g.current&&g.current.sendMessageToAssistantWithClear(nt)},100)}})),jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx("img",{src:"https://api.randmar.io/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsx(SidebarMenu,{children:c.map(nt=>{const et=nt.icon,rt=`/${nt.path}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:rt,className:"transition-colors hover:bg-muted px-6",children:[et&&jsxRuntime.jsx(et,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:nt.label})]})})},nt.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[jsxRuntime.jsxs(Dialog,{open:A,onOpenChange:V,children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:R,size:"lg",className:"collapse md:visible flex-grow",onClick:()=>setTimeout(()=>{var nt;return(nt=f.current)==null?void 0:nt.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:o,children:jsxRuntime.jsx(Button$1,{size:"icon",className:Ye||(Ve==null?void 0:Ve.HasUnreads)===!0?"pulse-glow bg-white hover:bg-gray-200 text-black":"",children:jsxRuntime.jsx(MessageSquare,{className:"h-5 w-5"})})})]}),jsxRuntime.jsx(DialogContent,{className:"randmar-assistant-dialog max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,overlayClassName:"randmar-assistant-overlay",children:jsxRuntime.jsx(AIChatLayout,{className:"h-[85vh]",ref:g,inputRef:f,userId:a,userName:s??"Unknown user"})})]}),t]})]})}),Layout=React.forwardRef(({children:e,appID:t,rightMenu:n,routes:s,footer:a,handleValidSearch:o,dashboardTitle:l,onSignOut:c,searchPlaceholder:f,chatUserName:g,chatRef:R,chatRoutePath:A},V)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{appID:t,routes:s,footer:a,dashboardTitle:l,chatUserName:g,ref:R,chatRoutePath:A}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col",children:[jsxRuntime.jsx(Topbar,{ref:V,appID:t,onSignOut:c,rightMenu:n,handleValidSearch:o,searchPlaceholder:f}),jsxRuntime.jsx("main",{className:"flex-1 mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:e,manufacturer:t}){const{toast:n}=useToast(),[s,a]=React.useState(!1),[o,l]=React.useState(!1),[c,f]=React.useState(!1),[g,R]=React.useState(""),[A,V]=React.useState(""),[Ve,Ye]=React.useState(!1),[nt,et]=React.useState(""),[rt,st]=React.useState(""),[ot,ct]=React.useState([]),[lt,at]=React.useState(""),[ut,pt]=React.useState(""),[mt,It]=React.useState([]),[Rt,ft]=React.useState(""),[Mt,yt]=React.useState(""),[Ct]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),Ft=()=>{R(""),V("")},Ht=()=>{et(""),st(""),ct([]),at(""),pt(""),It([]),ft(""),yt("")},Dt=()=>{t.PartnerRegistrationLink?a(!0):t.OpenToWork&&l(!0)},$t=Qt=>{if(Qt.preventDefault(),!c){if(!g.trim()){V("Qualification ID is required");return}f(!0),Ct({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:`Hello! I'd like to get started with you. Here's my Qualification ID: ${g}`}).then(pn=>{if(pn.error){console.error(pn.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),a(!1),Ft()}).catch(pn=>{console.error(pn),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{f(!1)})}},zt=Qt=>{if(Qt.preventDefault(),Ve)return;st(""),at(""),ft("");let pn=!1;if(nt.trim().length<10&&(st("Please provide a brief description of your business (minimum 10 characters)"),pn=!0),ot.length===0&&(at("Please select at least one sales channel"),pn=!0),mt.length===0&&(ft("Please select at least one market"),pn=!0),pn)return;const Yt=salesChannels.filter(mn=>ot.includes(mn.id)).map(mn=>mn.label);ut&&Yt.push(`Other: ${ut}`);const fn=markets.filter(mn=>mt.includes(mn.id)).map(mn=>mn.label);Mt&&fn.push(`Other: ${Mt}`);const Jt=["Hello! I'd like to introduce my business:",`**Business Description:** ${nt}`,`**Sales Channels:** ${Yt.join(", ")}`,`**Markets:** ${fn.join(", ")}`].join(`
|
|
1337
|
+
`);const xn={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:Zt.partner1===e?Zt.partner2:Zt.partner1,content:rn+(Ft?` (${Ft==null?void 0:Ft.name} attached)`:""),timestamp:Date.now()};Qt(xn),Ye(xn.content,Ft??void 0),Ft&&$t(En=>[...En,Ft.name]),pt(""),Ht(null),en.current&&(en.current.value="")},[Yt,fn]=React.useState(null),Jt=Zt=>fn(Zt),mn=Zt=>{Rn(),fn(Zt)};React.useEffect(()=>{if(Yt===null)return;const Zt=un();if(!Zt||!rt)return;const rn=Yt;fn(null),rn&&pn(Zt,rn)},[Yt,Rt,rt]),React.useImperativeHandle(a,()=>({sendMessageToAssistant:Jt,sendMessageToAssistantWithClear:mn}));const gn=Zt=>{var xn;const rn=(xn=Zt.clipboardData)==null?void 0:xn.items;if(rn){for(let En=0;En<rn.length;En++)if(rn[En].type.indexOf("image")!==-1){const $n=rn[En].getAsFile();if($n){Ht($n);return}}}},Kt=()=>{let Zt=ut.trim();!Zt&&Ft&&(Zt="consider this"),!(!bn||!Zt)&&pn(bn,Zt)},Tn=Zt=>{Zt.target.files&&Zt.target.files[0]?Ht(Zt.target.files[0]):Ht(null)},hn=()=>{var Zt;(Zt=en.current)==null||Zt.click()},Sn=()=>{var Zt;Ht(null),Xt({title:"File removed",description:"No file will be sent to the assistant.",variant:"secondary"}),(Zt=zt.current)==null||Zt.focus()},vn=()=>{const rn={messages:un(),debug:st};l(!0),g({applicationId:e,emailAddress:t,body:rn}).then(xn=>{if(xn.error){console.error(xn.error),Xt({title:"Error",description:"Could not send your feedback. Please try again later.",variant:"destructive"});return}Xt({title:"Success",description:"Your feedback has been successfully sent. Thank you!",variant:"success"})}).catch(xn=>{console.error(xn),Xt({title:"Error",description:"Could not send your feedback. Please try again later.",variant:"destructive"})}).finally(()=>{l(!1)})},Rn=()=>{ft(Zt=>Zt.map(xn=>xn.partner1!==ASSISTANT_ID&&xn.partner2!==ASSISTANT_ID?xn:{...xn,messages:[]})),$t([]),ct()},Cn=()=>{try{const Zt=at.map(xn=>{const $n=(Array.isArray(xn==null?void 0:xn.Parts)?xn.Parts:[]).map(Vn=>{const Nn=typeof(Vn==null?void 0:Vn.Text)=="string"?Vn.Text:null,Zn=!!(Nn&&Nn.length>0),rr=(Vn==null?void 0:Vn.FunctionResponse)!=null,ir=(Vn==null?void 0:Vn.FileData)!=null;return!Zn&&!rr&&!ir?null:{...Zn?{Text:Nn}:{},...rr?{FunctionResponse:Vn.FunctionResponse}:{},...ir?{FileData:Vn.FileData}:{}}}).filter(Vn=>Vn!=null);return{Role:typeof(xn==null?void 0:xn.Role)=="string"?xn.Role:null,Parts:$n}});(async()=>{try{const En={SystemInstructions:(await sn({applicationId:e})).data??"",ChatMessages:Zt},$n=JSON.stringify(En,null,2);if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText($n),Xt({title:"Chat JSON copied",description:"The chat history has been copied to your clipboard.",variant:"success"});else{const Vn=document.createElement("textarea");Vn.value=$n,Vn.style.position="fixed",Vn.style.left="-9999px",document.body.appendChild(Vn),Vn.focus(),Vn.select();const Nn=document.execCommand("copy");if(document.body.removeChild(Vn),Nn)Xt({title:"Chat JSON copied",description:"The chat history has been copied to your clipboard.",variant:"success"});else throw new Error("execCommand copy failed")}}catch(xn){console.error("Failed to copy chat JSON",xn),Xt({title:"Error copying JSON",description:"Could not copy to clipboard. See console for details.",variant:"destructive"})}})()}catch(Zt){console.error("Failed to print chat JSON",Zt),Xt({title:"Error printing JSON",description:"See console for details.",variant:"destructive"})}},bn=un(),_n=(((bn==null?void 0:bn.messages)??[]).length??0)===0;React.useEffect(()=>{if(!c||!rt)return;const Zt=_n?Ct:zt;setTimeout(()=>{var rn;return(rn=Zt.current)==null?void 0:rn.focus()},50)},[rt,zt,_n,c]);const Wt=(Zt,rn)=>{A(xn=>({...xn,[Zt]:rn})),Rn()},nn=React.useRef(null);React.useEffect(()=>{var Zt;(Zt=nn.current)==null||Zt.scrollIntoView({behavior:"smooth"})},[st]);const on=({className:Zt="h-4 w-4"})=>jsxRuntime.jsxs("svg",{style:{flex:"none",lineHeight:1},viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:Zt,children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#08B962"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"#F94543"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"#FABC12"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),an=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})});return c?jsxRuntime.jsxs("div",{className:cn("flex h-full min-h-0 w-full overflow-hidden",s),children:[jsxRuntime.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:un()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-20 flex items-center border-b bg-white p-4",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>vn()},disabled:o,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsxs(Button$1,{className:"ml-1",onClick:()=>Rn(),children:[jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})," Clear Conversation"]})]})}),jsxRuntime.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:rt?_n?jsxRuntime.jsx("div",{className:"flex-1 bg-slate-50 flex items-center justify-center p-6 animate-in fade-in-0 duration-300",children:jsxRuntime.jsxs("div",{className:"w-full max-w-2xl",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-slate-600",children:"Hi there!"}),jsxRuntime.jsx("h1",{className:"mt-2 text-[32px] leading-[1.15] font-semibold text-slate-900",children:"How can I assist you with your Randmar tasks today?"}),jsxRuntime.jsx("form",{className:"mt-6",onSubmit:Zt=>{if(Zt.preventDefault(),ot)return;const rn=mt.trim();!rn||!bn||(pn(bn,rn),It(""))},children:jsxRuntime.jsx(Input,{ref:Ct,value:mt,onChange:Zt=>It(Zt.target.value),placeholder:"Enter a question or command for Randmar Assistant",className:"h-14 rounded-full bg-white px-5 shadow-sm ring-1 ring-slate-200/80 focus-visible:ring-2 focus-visible:ring-primary/35"})})]})}):jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col animate-in fade-in-0 duration-300",children:[jsxRuntime.jsxs(ScrollArea,{className:"min-h-0 flex-1 bg-slate-50 pl-2 pr-2",children:[jsxRuntime.jsx(ChatMessages,{messages:(bn==null?void 0:bn.messages)??[],appID:e,isAssistantChat:!0,botStatus:ot}),jsxRuntime.jsx("div",{ref:Mt})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 border-r border-t p-4",children:[jsxRuntime.jsx(Textarea,{ref:zt,placeholder:"Type a message...",value:ut,onPaste:gn,onChange:Zt=>pt(Zt.target.value),onKeyDown:Zt=>{Zt.key!=="Enter"||Zt.shiftKey||(Zt.preventDefault(),!(!rt||ot)&&Kt())},className:"flex-1 resize-none field-sizing-content max-h-[30em]"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:bn!=null&&bn.pending?"collapse":"ml-2 h-8 w-8",disabled:!rt||!!ot,onClick:Kt,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsx(Input,{type:"file",onChange:Tn,className:"hidden",ref:en}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:hn,className:bn!=null&&bn.pending?"collapse":"ml-2 h-8 w-8",disabled:!rt||ot!==""||(bn==null?void 0:bn.pending)||!!Ft,children:jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"})}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:Sn,className:bn!=null&&bn.pending?"collapse":"ml-2 h-8 w-8",disabled:!rt||ot!==""||(bn==null?void 0:bn.pending)||!Ft,children:jsxRuntime.jsx(Trash,{className:"h-5 w-5"})})]})]})]}):jsxRuntime.jsx("div",{className:"flex-1 bg-slate-50",children:an})})]}):an}),jsxRuntime.jsx("div",{"data-thin":!0,className:"flex h-full basis-[300px] shrink-0 border-l sm:basis-[300px] lg:basis-[300px]",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-0 flex-col rounded-r-lg border-r bg-slate-50 text-slate-800",children:[jsxRuntime.jsxs("div",{className:"p-4 space-y-4 border-b border-slate-200/80",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Assistant Settings"]}),jsxRuntime.jsx("div",{className:"space-y-5",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5 pr-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"preload-bestsellers-switch",children:"Preload Best-Sellers"}),jsxRuntime.jsx("p",{className:"text-xs text-slate-600",children:"Adds top products to the AI's context for faster answers."})]}),jsxRuntime.jsx(Switch,{id:"preload-bestsellers-switch",checked:R.assistantCachedPreloading,onCheckedChange:Zt=>Wt("assistantCachedPreloading",Zt)})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-slate-200/80 h-32",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:Ft||Dt.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[Ft&&jsxRuntime.jsxs("div",{className:"flex items-center text-blue-600",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{className:"truncate",children:[Ft.name," (pending)"]})]}),Dt.slice().reverse().map((Zt,rn)=>jsxRuntime.jsxs("div",{className:"flex items-center text-slate-700 hover:text-slate-900 transition-colors duration-150",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{className:"truncate",children:Zt})]},rn))]}):jsxRuntime.jsx("p",{className:"text-slate-500 text-xs italic",children:"No files attached yet."})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-slate-500 uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:st}),jsxRuntime.jsx("div",{ref:nn})]})})]}),jsxRuntime.jsx("div",{className:"p-3 border-t border-slate-200/80",children:jsxRuntime.jsxs(Button$1,{className:"w-full",variant:"secondary",onClick:Cn,children:[jsxRuntime.jsx(CodeXml,{className:"h-4 w-4 mr-2"}),"Export Chat JSON"]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-slate-200/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-3 w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-slate-500",children:"Powered by Gemini"}),jsxRuntime.jsx(on,{})]}),jsxRuntime.jsxs("div",{className:"flex-1 max-w-[160px]",children:[jsxRuntime.jsx(Progress,{value:Math.round((lt||0)*100),className:"h-2"}),jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] text-slate-400 mt-1",children:[jsxRuntime.jsx("span",{children:"Context"}),jsxRuntime.jsxs("span",{children:[Math.round((lt||0)*100),"%"]})]})]})]})})]})})]}):jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"})}));AIChatLayout.displayName="AIChatLayout";const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,chatUserName:s,appID:a,chatRoutePath:o},l)=>{const c=e.filter(nt=>nt.showInNav),f=React.useRef(null),g=React.useRef(null),R=React.useRef(null),[A,V]=React.useState(!1),{data:Ve}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsHasUnreadsQuery({routeApplicationId:a}),{hasUnreads:Ye}=useChat();return React.useImperativeHandle(l,()=>({sendMessageToAssistant:nt=>{var et;(et=R.current)==null||et.click(),setTimeout(()=>{var rt;(rt=f.current)==null||rt.focus(),g.current&&g.current.sendMessageToAssistant(nt)},100)},sendMessageToAssistantWithClear(nt){var et;(et=R.current)==null||et.click(),setTimeout(()=>{var rt;(rt=f.current)==null||rt.focus(),g.current&&g.current.sendMessageToAssistantWithClear(nt)},100)}})),jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx("img",{src:"https://api.randmar.io/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsx(SidebarMenu,{children:c.map(nt=>{const et=nt.icon,rt=`/${nt.path}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:rt,className:"transition-colors hover:bg-muted px-6",children:[et&&jsxRuntime.jsx(et,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:nt.label})]})})},nt.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[jsxRuntime.jsxs(Dialog,{open:A,onOpenChange:V,children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:R,size:"lg",className:"collapse md:visible flex-grow",onClick:()=>setTimeout(()=>{var nt;return(nt=f.current)==null?void 0:nt.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:o,children:jsxRuntime.jsx(Button$1,{size:"icon",className:Ye||(Ve==null?void 0:Ve.HasUnreads)===!0?"pulse-glow bg-white hover:bg-gray-200 text-black":"",children:jsxRuntime.jsx(MessageSquare,{className:"h-5 w-5"})})})]}),jsxRuntime.jsx(DialogContent,{className:"randmar-assistant-dialog max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,overlayClassName:"randmar-assistant-overlay",children:jsxRuntime.jsx(AIChatLayout,{className:"h-[85vh]",ref:g,inputRef:f,userId:a,userName:s??"Unknown user"})})]}),t]})]})}),Layout=React.forwardRef(({children:e,appID:t,rightMenu:n,routes:s,footer:a,handleValidSearch:o,dashboardTitle:l,onSignOut:c,searchPlaceholder:f,chatUserName:g,chatRef:R,chatRoutePath:A},V)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{appID:t,routes:s,footer:a,dashboardTitle:l,chatUserName:g,ref:R,chatRoutePath:A}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col",children:[jsxRuntime.jsx(Topbar,{ref:V,appID:t,onSignOut:c,rightMenu:n,handleValidSearch:o,searchPlaceholder:f}),jsxRuntime.jsx("main",{className:"flex-1 mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:e,manufacturer:t}){const{toast:n}=useToast(),[s,a]=React.useState(!1),[o,l]=React.useState(!1),[c,f]=React.useState(!1),[g,R]=React.useState(""),[A,V]=React.useState(""),[Ve,Ye]=React.useState(!1),[nt,et]=React.useState(""),[rt,st]=React.useState(""),[ot,ct]=React.useState([]),[lt,at]=React.useState(""),[ut,pt]=React.useState(""),[mt,It]=React.useState([]),[Rt,ft]=React.useState(""),[Mt,yt]=React.useState(""),[Ct]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),Ft=()=>{R(""),V("")},Ht=()=>{et(""),st(""),ct([]),at(""),pt(""),It([]),ft(""),yt("")},Dt=()=>{t.PartnerRegistrationLink?a(!0):t.OpenToWork&&l(!0)},$t=Qt=>{if(Qt.preventDefault(),!c){if(!g.trim()){V("Qualification ID is required");return}f(!0),Ct({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:`Hello! I'd like to get started with you. Here's my Qualification ID: ${g}`}).then(pn=>{if(pn.error){console.error(pn.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),a(!1),Ft()}).catch(pn=>{console.error(pn),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{f(!1)})}},zt=Qt=>{if(Qt.preventDefault(),Ve)return;st(""),at(""),ft("");let pn=!1;if(nt.trim().length<10&&(st("Please provide a brief description of your business (minimum 10 characters)"),pn=!0),ot.length===0&&(at("Please select at least one sales channel"),pn=!0),mt.length===0&&(ft("Please select at least one market"),pn=!0),pn)return;const Yt=salesChannels.filter(mn=>ot.includes(mn.id)).map(mn=>mn.label);ut&&Yt.push(`Other: ${ut}`);const fn=markets.filter(mn=>mt.includes(mn.id)).map(mn=>mn.label);Mt&&fn.push(`Other: ${Mt}`);const Jt=["Hello! I'd like to introduce my business:",`**Business Description:** ${nt}`,`**Sales Channels:** ${Yt.join(", ")}`,`**Markets:** ${fn.join(", ")}`].join(`
|
|
1338
1338
|
|
|
1339
1339
|
`);Ye(!0),Ct({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:Jt}).then(mn=>{if(mn.error){console.error(mn.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),l(!1),Ht()}).catch(mn=>{console.error(mn),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{Ye(!1)})},en=(Qt,pn)=>{ct(Yt=>pn?[...Yt,Qt]:Yt.filter(fn=>fn!==Qt)),at("")},Xt=(Qt,pn)=>{It(Yt=>pn?[...Yt,Qt]:Yt.filter(fn=>fn!==Qt)),ft("")},sn=ot.includes("other-channel"),un=mt.includes("other-market");return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!t.Qualification&&jsxRuntime.jsxs(Button$1,{onClick:Dt,disabled:!t.PartnerRegistrationLink&&!t.OpenToWork,children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Get Started"]}),t.PartnerRegistrationLink&&jsxRuntime.jsx(Dialog,{open:s,onOpenChange:Qt=>{a(Qt)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[400px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:t.PublicName}),jsxRuntime.jsxs(DialogDescription,{children:[jsxRuntime.jsx("span",{className:"font-bold",children:"Already qualified?"})," Provide your Qualification ID."]})]}),jsxRuntime.jsxs("form",{onSubmit:$t,className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"qualificationId",children:"Qualification ID"}),jsxRuntime.jsx(Input,{id:"qualificationId",placeholder:"Enter your qualification ID",value:g,onChange:Qt=>{R(Qt.target.value),V("")}}),A&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:A})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",className:"w-full",disabled:c,children:c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Applying..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Apply for Qualification"]})})})]}),jsxRuntime.jsx(Separator$1,{className:"my-4"}),jsxRuntime.jsxs("div",{className:"text-center space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Don't have a qualification ID?"}),jsxRuntime.jsx(reactRouterDom.Link,{to:t.PartnerRegistrationLink,target:"_blank",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"w-full",disabled:!t.PartnerRegistrationLink,children:[jsxRuntime.jsx(ExternalLink,{className:"mr-2 h-4 w-4"}),"Register here"]})})]})]})}),jsxRuntime.jsx(Dialog,{open:o,onOpenChange:Qt=>{l(Qt)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[768px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Introduce Yourself"})}),jsxRuntime.jsxs("form",{onSubmit:zt,className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{htmlFor:"businessDescription",children:["Tell Us About Your Business ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Briefly describe your business)"})]}),jsxRuntime.jsx(Textarea,{id:"businessDescription",placeholder:"We are an online retailer specializing in office supplies, serving businesses since 2018...",className:"min-h-[100px]",value:nt,onChange:Qt=>{et(Qt.target.value),st("")}}),rt&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:rt})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Sales Channel(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select where you currently sell your products)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:salesChannels.map(Qt=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`channel-${Qt.id}`,checked:ot.includes(Qt.id),onCheckedChange:pn=>en(Qt.id,pn===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`channel-${Qt.id}`,className:"text-sm font-normal",children:Qt.label})]},Qt.id))}),sn&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:ut,onChange:Qt=>pt(Qt.target.value)}),lt&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:lt})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Your Primary Market(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select which regions you sell to)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:markets.map(Qt=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`market-${Qt.id}`,checked:mt.includes(Qt.id),onCheckedChange:pn=>Xt(Qt.id,pn===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`market-${Qt.id}`,className:"text-sm font-normal",children:Qt.label})]},Qt.id))}),un&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:Mt,onChange:Qt=>yt(Qt.target.value)}),Rt&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:Rt})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:Ve,children:Ve?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit"})})]})]})})]})}const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:s=!1,readonly:a=!1}){const[o,l]=React.useState({...e}),[c,f]=React.useState({...e});React.useEffect(()=>{f({...e}),l({...e})},[e]);const g=(rt,st)=>{a||l(ot=>({...ot,[rt]:st}))},R=(rt,st)=>{a||l(ot=>({...ot,[rt]:st}))},A=(rt,st)=>{a||l(ot=>({...ot,[rt]:st}))},V=()=>{const rt={};return Object.keys(o).forEach(st=>{const ot=st;JSON.stringify(o[ot])!==JSON.stringify(c[ot])&&(rt[ot]=o[ot])}),rt},Ve=()=>{if(!s&&!a){const rt=V();Object.keys(rt).length>0&&t(rt)}},Ye=rt=>rt===-1?"ASAP":rt===void 0||rt<0||rt>6?"Sunday":DAYS_OF_WEEK[rt],nt=rt=>rt==="ASAP"?-1:DAYS_OF_WEEK.indexOf(rt),et=Object.keys(V()).length>0;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[n?jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}):jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Reordering"}),n?jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}):jsxRuntime.jsx(CardDescription,{className:"text-sm",children:"Adjust your reordering settings to control lead times, stocking weeks, minimum orders, and reorder dates, enhancing efficiency in restocking processes."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"automatic-reordering",checked:o.AutoUpdate,onCheckedChange:rt=>g("AutoUpdate",rt),disabled:s||a}),jsxRuntime.jsx(Label$2,{htmlFor:"automatic-reordering",children:"Automatic Reordering"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"reorder-date",children:"Automatic Reorder Date"}),jsxRuntime.jsxs(Select$1,{value:Ye(o.AutoReorderDate),onValueChange:rt=>R("AutoReorderDate",nt(rt)),disabled:s||a,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"ASAP",children:"ASAP"}),DAYS_OF_WEEK.map(rt=>jsxRuntime.jsx(SelectItem,{value:rt,children:rt},rt))]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"weeks-stocking",children:"Default Weeks of Stocking"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"weeks-stocking",type:"number",value:o.DefaultWeeksOfStocking||"",onChange:rt=>R("DefaultWeeksOfStocking",Number(rt.target.value)),disabled:s||a}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"weeks"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"minimum-order",children:"Default Minimum Order"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"minimum-order",type:"number",className:"pl-6",value:o.DefaultMinimumOrder||"",onChange:rt=>R("DefaultMinimumOrder",Number(rt.target.value)),disabled:s||a})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"lead-time",children:"Default Lead Time"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"lead-time",type:"number",value:o.DefaultLeadTime||"",onChange:rt=>R("DefaultLeadTime",Number(rt.target.value)),disabled:s||a}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"days"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"maximum-inventory-value",children:"Default Maximum Inventory Value"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"maximum-inventory-value",type:"number",className:"pl-6",value:o.DefaultMaxInventoryValue||"",onChange:rt=>R("DefaultMaxInventoryValue",Number(rt.target.value)),disabled:s||a})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"order-confirmations",children:"Send Order Confirmations To"}),jsxRuntime.jsx(Input,{id:"order-confirmations",type:"email",value:o.POEmail||"",onChange:rt=>A("POEmail",rt.target.value),placeholder:"email@example.com",disabled:s||a})]})]})]})}),!a&&jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button$1,{onClick:Ve,disabled:s||!et,children:[s&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}function createSlot(e){const t=createSlotClone(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),f=c.find(isSlottable);if(f){const g=f.props.children,R=c.map(A=>A===f?React__namespace.Children.count(g)>1?React__namespace.Children.only(null):React__namespace.isValidElement(g)?g.props.children:null:A);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(g)?React__namespace.cloneElement(g,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef(a),c=mergeProps(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$1=Symbol("radix.slottable");function isSlottable(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$1}function mergeProps(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const f=o(...c);return a(...c),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var POPOVER_NAME="Popover",[createPopoverContext]=createContextScope$2(POPOVER_NAME,[createPopperScope]),usePopperScope=createPopperScope(),[PopoverProvider,usePopoverContext]=createPopoverContext(POPOVER_NAME),Popover$1=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:l=!1}=e,c=usePopperScope(t),f=React__namespace.useRef(null),[g,R]=React__namespace.useState(!1),[A,V]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:POPOVER_NAME});return jsxRuntime.jsx(Root2$7,{...c,children:jsxRuntime.jsx(PopoverProvider,{scope:t,contentId:useId$1(),triggerRef:f,open:A,onOpenChange:V,onOpenToggle:React__namespace.useCallback(()=>V(Ve=>!Ve),[V]),hasCustomAnchor:g,onCustomAnchorAdd:React__namespace.useCallback(()=>R(!0),[]),onCustomAnchorRemove:React__namespace.useCallback(()=>R(!1),[]),modal:l,children:n})})};Popover$1.displayName=POPOVER_NAME;var ANCHOR_NAME="PopoverAnchor",PopoverAnchor$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(ANCHOR_NAME,n),o=usePopperScope(n),{onCustomAnchorAdd:l,onCustomAnchorRemove:c}=a;return React__namespace.useEffect(()=>(l(),()=>c()),[l,c]),jsxRuntime.jsx(Anchor,{...o,...s,ref:t})});PopoverAnchor$1.displayName=ANCHOR_NAME;var TRIGGER_NAME$3="PopoverTrigger",PopoverTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(TRIGGER_NAME$3,n),o=usePopperScope(n),l=useComposedRefs(t,a.triggerRef),c=jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":getState$2(a.open),...s,ref:l,onClick:composeEventHandlers(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:c})});PopoverTrigger$1.displayName=TRIGGER_NAME$3;var PORTAL_NAME$1="PopoverPortal",[PortalProvider,usePortalContext]=createPopoverContext(PORTAL_NAME$1,{forceMount:void 0}),PopoverPortal=e=>{const{__scopePopover:t,forceMount:n,children:s,container:a}=e,o=usePopoverContext(PORTAL_NAME$1,t);return jsxRuntime.jsx(PortalProvider,{scope:t,forceMount:n,children:jsxRuntime.jsx(Presence,{present:n||o.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:a,children:s})})})};PopoverPortal.displayName=PORTAL_NAME$1;var CONTENT_NAME$3="PopoverContent",PopoverContent$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext(CONTENT_NAME$3,e.__scopePopover),{forceMount:s=n.forceMount,...a}=e,o=usePopoverContext(CONTENT_NAME$3,e.__scopePopover);return jsxRuntime.jsx(Presence,{present:s||o.open,children:o.modal?jsxRuntime.jsx(PopoverContentModal,{...a,ref:t}):jsxRuntime.jsx(PopoverContentNonModal,{...a,ref:t})})});PopoverContent$1.displayName=CONTENT_NAME$3;var Slot=createSlot("PopoverContent.RemoveScroll"),PopoverContentModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME$3,e.__scopePopover),s=React__namespace.useRef(null),a=useComposedRefs(t,s),o=React__namespace.useRef(!1);return React__namespace.useEffect(()=>{const l=s.current;if(l)return hideOthers(l)},[]),jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(PopoverContentImpl,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(e.onCloseAutoFocus,l=>{var c;l.preventDefault(),o.current||(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:composeEventHandlers(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,f=c.button===0&&c.ctrlKey===!0,g=c.button===2||f;o.current=g},{checkForDefaultPrevented:!1}),onFocusOutside:composeEventHandlers(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),PopoverContentNonModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME$3,e.__scopePopover),s=React__namespace.useRef(!1),a=React__namespace.useRef(!1);return jsxRuntime.jsx(PopoverContentImpl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,c;(l=e.onCloseAutoFocus)==null||l.call(e,o),o.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var f,g;(f=e.onInteractOutside)==null||f.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((g=n.triggerRef.current)==null?void 0:g.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),PopoverContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:g,onInteractOutside:R,...A}=e,V=usePopoverContext(CONTENT_NAME$3,n),Ve=usePopperScope(n);return useFocusGuards(),jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:R,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:g,onDismiss:()=>V.onOpenChange(!1),children:jsxRuntime.jsx(Content$2,{"data-state":getState$2(V.open),role:"dialog",id:V.contentId,...Ve,...A,ref:t,style:{...A.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CLOSE_NAME="PopoverClose",PopoverClose=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(CLOSE_NAME,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button",...s,ref:t,onClick:composeEventHandlers(e.onClick,()=>a.onOpenChange(!1))})});PopoverClose.displayName=CLOSE_NAME;var ARROW_NAME="PopoverArrow",PopoverArrow=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopperScope(n);return jsxRuntime.jsx(Arrow,{...a,...s,ref:t})});PopoverArrow.displayName=ARROW_NAME;function getState$2(e){return e?"open":"closed"}var Root2$2=Popover$1,Anchor2=PopoverAnchor$1,Trigger$1=PopoverTrigger$1,Portal=PopoverPortal,Content2$2=PopoverContent$1;const Popover=Root2$2,PopoverTrigger=Trigger$1,PopoverAnchor=Anchor2,PopoverContent=React__namespace.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},a)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsx(Content2$2,{ref:a,align:t,sideOffset:n,className:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",e),...s})}));PopoverContent.displayName=Content2$2.displayName;function MultiSelect({options:e,selected:t,onChange:n,placeholder:s="Select items...",disabled:a=!1}){const[o,l]=React__namespace.useState(!1),[c,f]=React__namespace.useState(""),g=React__namespace.useRef(null),[R,A]=React__namespace.useState(void 0),V=React__namespace.useCallback(()=>{g.current&&A(g.current.offsetWidth)},[]);React__namespace.useLayoutEffect(()=>{V()},[V]),React__namespace.useEffect(()=>(window.addEventListener("resize",V),()=>window.removeEventListener("resize",V)),[V]);const Ve=et=>{n(t.filter(rt=>rt!==et))},Ye=et=>{l(!1),t.includes(et)?n(t.filter(rt=>rt!==et)):n([...t,et])},nt=et=>{et.key==="Enter"&&c&&!e.includes(c)&&!t.includes(c)&&(et.preventDefault(),Ye(c),f(""))};return jsxRuntime.jsxs(Popover,{open:o,onOpenChange:l,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:g,variant:"outline",role:"combobox","aria-expanded":o,className:"w-full justify-between h-auto min-h-[40px] py-2",disabled:a,children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1 items-center",children:t.length>0?t.map(et=>jsxRuntime.jsxs(Badge,{variant:"outline",className:"mr-1 mb-1",children:[et,jsxRuntime.jsx("span",{className:"ml-1 cursor-pointer ring-offset-background rounded-full outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",onClick:rt=>{rt.preventDefault(),rt.stopPropagation(),Ve(et)},children:jsxRuntime.jsx(X$2,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},et)):jsxRuntime.jsx("span",{className:"text-muted-foreground",children:s})}),jsxRuntime.jsx(ChevronsUpDown,{className:"h-4 w-4 shrink-0 opacity-50 ml-2"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-full p-0",style:{width:R},children:jsxRuntime.jsxs(Command,{onKeyDown:nt,children:[jsxRuntime.jsx(CommandInput,{placeholder:"Search or add custom item...",value:c,onValueChange:f}),jsxRuntime.jsxs(CommandList,{children:[jsxRuntime.jsx(CommandEmpty,{children:"No item found."}),jsxRuntime.jsxs(CommandGroup,{children:[e.filter(et=>!t.includes(et)).map(et=>jsxRuntime.jsxs(CommandItem,{onSelect:()=>Ye(et),children:[jsxRuntime.jsx(Check,{className:cn("mr-2 h-4 w-4",t.includes(et)?"opacity-100":"opacity-0")}),et]},et)),c&&!e.includes(c)&&!t.includes(c)&&jsxRuntime.jsxs(CommandItem,{onSelect:()=>Ye(c),children:['Add "',c,'"']})]})]})]})})]})}const imgSizeMap={sm:100,md:200,lg:300,xl:400},Placeholder=({size:e})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:e,height:e},"aria-label":"Image not available",children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})}),VideoSkeleton=()=>jsxRuntime.jsx(Skeleton,{className:"w-full",style:{aspectRatio:"16/9"}});function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:s}){const[a,o]=React__namespace.useState(!1),[l,c]=React__namespace.useState(!1),[f,g]=React__namespace.useState(!1),R=imgSizeMap[t],A=React.useRef(null),V=useIntersectionObserver({elementRef:A,threshold:.1,rootMargin:"100px"}),{data:Ve,isFetching:Ye}=useGetProductByProductNumberImageExistsQuery({productNumber:e},{skip:!e||!V}),{data:nt,isFetching:et}=useGetProductByRandmarSkuImageQuery({randmarSku:e,width:R*1.5,height:R*1.5},{skip:!Ve}),{data:rt}=useGetProductByProductNumberVideoExistsQuery({productNumber:e},{skip:!e||!V}),{data:st,isFetching:ot}=useGetProductByProductNumberVideoQuery({productNumber:e},{skip:!rt||!a}),ct=Ye||et;async function lt(){if(st){g(!0);try{const mt=await(await fetch(st)).blob(),It=window.URL.createObjectURL(mt),Rt=document.createElement("a");Rt.href=It,Rt.download=`${e||"product"}-video.mp4`,document.body.appendChild(Rt),Rt.click(),document.body.removeChild(Rt),window.URL.revokeObjectURL(It)}catch(pt){console.error("Error downloading video:",pt)}finally{g(!1)}}}function at(){navigator.clipboard.writeText(`https://api.randmar.io/Product/${e}/Video`),c(!0),setTimeout(()=>c(!1),2e3)}function ut(){rt&&o(!0)}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:a,onOpenChange:o,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:ot||!st?jsxRuntime.jsx(VideoSkeleton,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:s?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:st,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:s})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:st,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:at,children:l?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:lt,disabled:f,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",ref:A,children:[ct?jsxRuntime.jsx(Skeleton,{className:"rounded-md",style:{width:R,height:R}}):nt?jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${rt?"cursor-pointer":""}`,onClick:ut,src:nt,width:R,height:R}):jsxRuntime.jsx(Placeholder,{size:R}),rt==!0&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:ut,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ResellerBillingOverviewCard({reseller:e,actions:t,loading:n=!1}){return n||!e?jsxRuntime.jsx(ResellerBillingOverviewSkeleton,{}):jsxRuntime.jsx(ResellerBillingOverviewData,{reseller:e,actions:t})}function ResellerBillingOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-40"})})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:Array(3).fill(0).map((e,t)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},t))}),jsxRuntime.jsx("div",{className:"space-y-4",children:Array(2).fill(0).map((e,t)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},t))})]}),jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 rounded-md"})})]})]})}function ResellerBillingOverviewData({reseller:e,actions:t}){const n=e.Statement||{},s=[{title:"0 - 30 Days",amount:n.Over0||0,icon:jsxRuntime.jsx(Calendar$1,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"31 - 45 Days",amount:n.Over30||0,icon:jsxRuntime.jsx(Calendar$1,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"45+ Days",amount:n.Over45||0,icon:jsxRuntime.jsx(Calendar$1,{className:"h-5 w-5 text-white"}),color:"bg-primary"}],a=[{title:"Total",amount:n.Total||0,icon:jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-white"}),color:"bg-green-500"},{title:"Credit Limit",amount:e.CreditLimit||0,icon:jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:s.map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:o.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${o.color}`,children:o.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:formatMoney(o.amount)})})]},l))}),jsxRuntime.jsx("div",{className:"space-y-4",children:a.map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:o.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${o.color}`,children:o.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:formatMoney(o.amount)})})]},l))})]}),t&&jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:t})]})]})}function ResellerQualificationsCard({qualifications:e=[],loading:t=!1}){return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 @lg:grid-cols-5 gap-4 gap-y-8",children:Array.from({length:10}).map((n,s)=>jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]},s))})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{children:e&&e.length>0?jsxRuntime.jsx("div",{className:"p-6",children:jsxRuntime.jsx("div",{className:"flex grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 @lg:grid-cols-5 gap-4 gap-y-8",children:e.map((n,s)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${s}`))})}):jsxRuntime.jsx("p",{children:"No qualification available."})})]})}function ManufacturerLogo({manufacturerId:e,opportunityNumber:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 w-full items-center justify-center mb-2",children:jsxRuntime.jsx(PartnerLogo,{id:e,width:96,height:48})}),t&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs",children:t})]})}function SalesOverviewCard({salesData:e,salesStatistics:t=[],loading:n=!1}){return n||!e?jsxRuntime.jsx(SalesOverviewSkeleton,{}):jsxRuntime.jsx(SalesOverviewData,{salesData:e,salesStatistics:t})}function SalesOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg @sm:text-xl",children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 @sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((e,t)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},t))}),jsxRuntime.jsx("div",{className:"mt-6",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-[250px] w-full rounded-lg"})]})})]})]})}function SalesOverviewData({salesData:e,salesStatistics:t=[]}){const n=[{title:"Last 30 days",amount:e.SalesLast30Days||0,icon:jsxRuntime.jsx(Calendar$1,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:e.SalesLast3Months||0,icon:jsxRuntime.jsx(Calendar$1,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:e.SalesYearToDay||0,icon:jsxRuntime.jsx(Calendar$1,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg @sm:text-xl",children:"Sales Overview"})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 @sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3 gap-4",children:n.map((s,a)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"text-sm @sm:text-base font-medium",children:s.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${s.color}`,children:s.icon})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base @sm:text-lg font-bold",children:formatMoney(s.amount)})]})]},a))}),jsxRuntime.jsx("div",{className:"mt-6",children:t&&t.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-4",children:"Sales Trend"}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsx(SalesChart,{statistics:t,chartHeight:300,mode:"week"})})]})})]})]})}var SLOTTABLE_IDENTIFIER=Symbol("radix.slottable");function createSlottable(e){const t=({children:n})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=SLOTTABLE_IDENTIFIER,t}var ROOT_NAME="AlertDialog",[createAlertDialogContext]=createContextScope$2(ROOT_NAME,[createDialogScope]),useDialogScope=createDialogScope(),AlertDialog$1=e=>{const{__scopeAlertDialog:t,...n}=e,s=useDialogScope(t);return jsxRuntime.jsx(Root$a,{...s,...n,modal:!0})};AlertDialog$1.displayName=ROOT_NAME;var TRIGGER_NAME$2="AlertDialogTrigger",AlertDialogTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,a=useDialogScope(n);return jsxRuntime.jsx(Trigger$6,{...a,...s,ref:t})});AlertDialogTrigger$1.displayName=TRIGGER_NAME$2;var PORTAL_NAME="AlertDialogPortal",AlertDialogPortal$1=e=>{const{__scopeAlertDialog:t,...n}=e,s=useDialogScope(t);return jsxRuntime.jsx(Portal$4,{...s,...n})};AlertDialogPortal$1.displayName=PORTAL_NAME;var OVERLAY_NAME="AlertDialogOverlay",AlertDialogOverlay$1=React__namespace.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,a=useDialogScope(n);return jsxRuntime.jsx(Overlay,{...a,...s,ref:t})});AlertDialogOverlay$1.displayName=OVERLAY_NAME;var CONTENT_NAME$2="AlertDialogContent",[AlertDialogContentProvider,useAlertDialogContentContext]=createAlertDialogContext(CONTENT_NAME$2),Slottable=createSlottable("AlertDialogContent"),AlertDialogContent$1=React__namespace.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:s,...a}=e,o=useDialogScope(n),l=React__namespace.useRef(null),c=useComposedRefs(t,l),f=React__namespace.useRef(null);return jsxRuntime.jsx(WarningProvider,{contentName:CONTENT_NAME$2,titleName:TITLE_NAME,docsSlug:"alert-dialog",children:jsxRuntime.jsx(AlertDialogContentProvider,{scope:n,cancelRef:f,children:jsxRuntime.jsxs(Content$3,{role:"alertdialog",...o,...a,ref:c,onOpenAutoFocus:composeEventHandlers(a.onOpenAutoFocus,g=>{var R;g.preventDefault(),(R=f.current)==null||R.focus({preventScroll:!0})}),onPointerDownOutside:g=>g.preventDefault(),onInteractOutside:g=>g.preventDefault(),children:[jsxRuntime.jsx(Slottable,{children:s}),jsxRuntime.jsx(DescriptionWarning,{contentRef:l})]})})})});AlertDialogContent$1.displayName=CONTENT_NAME$2;var TITLE_NAME="AlertDialogTitle",AlertDialogTitle$1=React__namespace.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,a=useDialogScope(n);return jsxRuntime.jsx(Title$1,{...a,...s,ref:t})});AlertDialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="AlertDialogDescription",AlertDialogDescription$1=React__namespace.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,a=useDialogScope(n);return jsxRuntime.jsx(Description$1,{...a,...s,ref:t})});AlertDialogDescription$1.displayName=DESCRIPTION_NAME;var ACTION_NAME="AlertDialogAction",AlertDialogAction$1=React__namespace.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,a=useDialogScope(n);return jsxRuntime.jsx(Close$1,{...a,...s,ref:t})});AlertDialogAction$1.displayName=ACTION_NAME;var CANCEL_NAME="AlertDialogCancel",AlertDialogCancel$1=React__namespace.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,{cancelRef:a}=useAlertDialogContentContext(CANCEL_NAME,n),o=useDialogScope(n),l=useComposedRefs(t,a);return jsxRuntime.jsx(Close$1,{...o,...s,ref:l})});AlertDialogCancel$1.displayName=CANCEL_NAME;var DescriptionWarning=({contentRef:e})=>{const t=`\`${CONTENT_NAME$2}\` requires a description for the component to be accessible for screen reader users.
|
|
1340
1340
|
|